diff -brc mutt-0.60/handler.c mutt-0.60.1/handler.c *** mutt-0.60/handler.c Wed Jan 22 19:32:10 1997 --- mutt-0.60.1/handler.c Wed Feb 5 10:42:07 1997 *************** *** 17,26 **** --- 17,29 ---- */ #include "muttlib.h" + #include "mutt_curses.h" #include #include #include + #include + #include "rfc1524.h" typedef void handler (BODY *, STATE *); typedef handler *handler_t; *************** *** 390,397 **** --- 393,467 ---- } } + void autoview_handler (BODY *a, STATE *s) + { + rfc1524_entry *entry = rfc1524_new_entry(); + char buffer[LONG_STRING]; + char type[STRING]; + char command[LONG_STRING]; + char tempfile[_POSIX_PATH_MAX] = ""; + FILE *fpin = NULL; + FILE *fpout = NULL; + int piped = FALSE; + + snprintf (type, sizeof (type), "%s/%s", TYPE (a->type), a->subtype); + rfc1524_mailcap_lookup(a, type, entry, M_AUTOVIEW); + + if (a->filename) strfcpy (tempfile, a->filename, sizeof (tempfile)); + mutt_adv_mktemp (tempfile); + + if (entry->command) { + strfcpy(command,entry->command,sizeof(command)); + /* rfc1524_expand_command returns 0 if the file is required */ + piped = rfc1524_expand_command(a,tempfile, type, command, sizeof(command)); + + if (s->displaying) { + char buffer[STRING]; + snprintf(buffer,sizeof(buffer),"[ Autoview using %s ]\n",command); + state_puts(buffer, s); + } + + if (piped) { + mutt_create_filter (command, &fpin, &fpout); + fseek(s->fpin, a->offset, 0); + mutt_copy_bytes (s->fpin, fpin, a->length); + fclose(fpin); + } else { + mutt_save_attachment (a, tempfile); + mutt_create_filter (command, NULL, &fpout); + } + if (s->prefix) + { + while (fgets (buffer, sizeof(buffer), fpout) != NULL) + { + state_puts (s->prefix, s); + state_puts (buffer, s); + } + } else { + int len; + while ((len = fread (buffer, 1, sizeof (buffer), fpout)) > 0) + fwrite (buffer, 1, len, s->fpout); + } + fclose (fpout); + wait (NULL); + mutt_unlink(tempfile); + } + } + handler_t get_handler (BODY *a) { + char type[STRING]; + + snprintf (type, sizeof (type), "%s/%s", TYPE (a->type), a->subtype); + if (mutt_in_list(AutoViewList,type)) { + rfc1524_entry *entry = rfc1524_new_entry(); + + if (rfc1524_mailcap_lookup(a, type, entry, M_AUTOVIEW)) { + rfc1524_free_entry(&entry); + return autoview_handler; + } + rfc1524_free_entry(&entry); + } if (a->type == TYPETEXT) { if (strcasecmp("plain", a->subtype) == 0) diff -brc mutt-0.60/init.c mutt-0.60.1/init.c *** mutt-0.60/init.c Fri Jan 31 10:40:18 1997 --- mutt-0.60.1/init.c Wed Feb 5 10:42:08 1997 *************** *** 871,876 **** --- 871,878 ---- mutt_add_to_list(&Localsites, skip_whitespace(s+9)); else if (strncmp(s, "unlocalsite", 11) == 0) remove_from_list(&Localsites, skip_whitespace(s+11)); + else if (strncmp(s, "auto_view", 9) == 0) + mutt_add_to_list (&AutoViewList, skip_whitespace(s+9)); else if (strncmp(s, "mono", 4) == 0) { if (!option(OPTBATCHMODE)) diff -brc mutt-0.60/lib.c mutt-0.60.1/lib.c *** mutt-0.60/lib.c Thu Jan 30 14:28:42 1997 --- mutt-0.60.1/lib.c Wed Feb 5 10:42:08 1997 *************** *** 163,168 **** --- 163,179 ---- } } + int mutt_in_list(LIST *t, const char *s) + { + while (t) + { + if (!strcmp(s,t->data)) + return 1; + t = t->next; + } + return 0; + } + /* returns true if the header contained in "s" is in list "t" */ int mutt_matches_ignore (const char *s, LIST *t) { diff -brc mutt-0.60/main.c mutt-0.60.1/main.c *** mutt-0.60/main.c Thu Jan 30 14:05:26 1997 --- mutt-0.60.1/main.c Wed Feb 5 10:49:01 1997 *************** *** 229,234 **** --- 229,236 ---- #ifdef _PGPPATH printf ("_PGPPATH=\"%s\"\n", _PGPPATH); #endif + printf ("\nPATCHES\n"); + printf ("\tMIME Autoview .60 v1 by blong"); exit (0); } diff -brc mutt-0.60/muttlib.h mutt-0.60.1/muttlib.h *** mutt-0.60/muttlib.h Fri Jan 31 10:12:12 1997 --- mutt-0.60.1/muttlib.h Wed Feb 5 10:42:08 1997 *************** *** 162,168 **** M_FLAG, M_TAG, M_UNTAG, ! M_LIMIT }; /* possible arguments to set_trioption() */ --- 162,174 ---- M_FLAG, M_TAG, M_UNTAG, ! M_LIMIT, ! ! /* Options for Mailcap lookup */ ! M_EDIT, ! M_COMPOSE, ! M_PRINT, ! M_AUTOVIEW }; /* possible arguments to set_trioption() */ *************** *** 494,499 **** --- 500,506 ---- void mutt_pipe_message (HEADER *, const char *); void mutt_postpone_message (const char *, ENVELOPE *, const char *, BODY *); void mutt_print_message (HEADER *); + int mutt_save_attachment (BODY *m, char *path);; void mutt_set_flag (HEADER *, int, int); void mutt_version (void); void mutt_simple_address (char *, size_t, ADDRESS *); *************** *** 519,524 **** --- 526,532 ---- int mutt_create_filter (const char *, FILE **, FILE **); int mutt_get_password (char *, char *, size_t); int mutt_getvaluebyname (const char *, const struct mapping_t *); + int mutt_in_list(LIST *, const char *); int mutt_is_mail_list (ADDRESS *); int mutt_is_text_type (int, char *); int mutt_is_valid_mailbox (const char *); *************** *** 770,775 **** --- 778,784 ---- WHERE ADDRESS *Alternates INITVAL(0); WHERE USERHEADER *User_defined_headers INITVAL(0); WHERE LIST *Localsites INITVAL(0); + WHERE LIST *AutoViewList INITVAL(0); #ifdef DEBUG WHERE FILE *debugfile INITVAL(0); diff -brc mutt-0.60/recvattach.c mutt-0.60.1/recvattach.c *** mutt-0.60/recvattach.c Mon Jan 27 11:31:18 1997 --- mutt-0.60.1/recvattach.c Wed Feb 5 10:42:08 1997 *************** *** 106,112 **** } } ! static int save_attachment (BODY *m, char *path) { STATE s; --- 106,112 ---- } } ! int mutt_save_attachment (BODY *m, char *path) { STATE s; *************** *** 158,164 **** rfc1524_entry *entry = rfc1524_new_entry(); snprintf (type, sizeof (type), "%s/%s", TYPE (a->type), a->subtype); ! if (rfc1524_mailcap_lookup (a,type, entry)) { if (entry->command) { --- 158,164 ---- rfc1524_entry *entry = rfc1524_new_entry(); snprintf (type, sizeof (type), "%s/%s", TYPE (a->type), a->subtype); ! if (rfc1524_mailcap_lookup (a,type, entry, 0)) { if (entry->command) { *************** *** 166,172 **** if (!rfc1524_expand_command(a,tempfile, type, command, sizeof(command))) { /* rfc1524_expand_command returns 0 if the file is required */ ! save_attachment (a, tempfile); if (entry->copiousoutput) { /* Use a pager: The assumption is the info is coming from --- 166,172 ---- if (!rfc1524_expand_command(a,tempfile, type, command, sizeof(command))) { /* rfc1524_expand_command returns 0 if the file is required */ ! mutt_save_attachment (a, tempfile); if (entry->copiousoutput) { /* Use a pager: The assumption is the info is coming from *************** *** 339,345 **** !buffer[0]) break; mutt_expand_path (buffer, sizeof (buffer)); ! if (save_attachment (idx[menu->current]->content, buffer) == 0) mutt_error ("Attachment saved."); else { --- 339,345 ---- !buffer[0]) break; mutt_expand_path (buffer, sizeof (buffer)); ! if (mutt_save_attachment (idx[menu->current]->content, buffer) == 0) mutt_error ("Attachment saved."); else { diff -brc mutt-0.60/rfc1524.c mutt-0.60.1/rfc1524.c *** mutt-0.60/rfc1524.c Tue Jan 21 19:11:04 1997 --- mutt-0.60.1/rfc1524.c Wed Feb 5 10:46:09 1997 *************** *** 105,111 **** return needspipe; } ! int rfc1524_mailcap_parse (BODY *a, char *filename, char *type, rfc1524_entry *entry) { FILE *fp = NULL; char buf[LONG_STRING]; --- 105,112 ---- return needspipe; } ! int rfc1524_mailcap_parse (BODY *a, char *filename, char *type, ! rfc1524_entry *entry, int opt) { FILE *fp = NULL; char buf[LONG_STRING]; *************** *** 246,253 **** --- 247,263 ---- } tok = strtokq (NULL, ";"); } + if (opt == M_AUTOVIEW) { + if (entry->copiousoutput != TRUE) found = FALSE; + } else if (opt == M_COMPOSE) { + if (entry->composecommand == NULL) found = FALSE; + } else if (opt == M_EDIT) { + if (entry->editcommand == NULL) found = FALSE; + } else if (opt == M_PRINT) { + if (entry->printcommand == NULL) found = FALSE; } } + } fclose(fp); return found; } else return FALSE; *************** *** 277,283 **** } ! int rfc1524_mailcap_lookup (BODY *a, char *type, rfc1524_entry *entry) { char path[_POSIX_PATH_MAX]; int x; --- 287,293 ---- } ! int rfc1524_mailcap_lookup (BODY *a, char *type, rfc1524_entry *entry, int opt) { char path[_POSIX_PATH_MAX]; int x; *************** *** 304,310 **** mutt_expand_path(path,sizeof(path)); dprint(2,(debugfile,"Checking mailcap file: %s\n",path)); ! found = rfc1524_mailcap_parse(a, path, type, entry); x = 0; curr++; while(*curr && *curr != ':' && x