From: Richard Russon Date: Sat, 31 Aug 2019 12:33:50 +0000 (+0100) Subject: rename mailcap structs/functions X-Git-Tag: 2019-10-25~63^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c3a2bf5a42a6461e1b01441477af5f06ac334fc1;p=neomutt rename mailcap structs/functions --- diff --git a/handler.c b/handler.c index 24a6fc8ca..b886ea03b 100644 --- a/handler.c +++ b/handler.c @@ -518,7 +518,7 @@ static bool is_autoview(struct Body *b) * * @warning type is altered by this call as a result of 'mime_lookup' support */ if (is_av) - return rfc1524_mailcap_lookup(b, type, NULL, MUTT_MC_AUTOVIEW); + return mailcap_lookup(b, type, NULL, MUTT_MC_AUTOVIEW); return false; } @@ -528,7 +528,7 @@ static bool is_autoview(struct Body *b) */ static int autoview_handler(struct Body *a, struct State *s) { - struct Rfc1524MailcapEntry *entry = rfc1524_new_entry(); + struct MailcapEntry *entry = mailcap_entry_new(); char buf[1024]; char type[256]; struct Buffer *cmd = mutt_buffer_pool_get(); @@ -541,19 +541,19 @@ static int autoview_handler(struct Body *a, struct State *s) int rc = 0; snprintf(type, sizeof(type), "%s/%s", TYPE(a), a->subtype); - rfc1524_mailcap_lookup(a, type, entry, MUTT_MC_AUTOVIEW); + mailcap_lookup(a, type, entry, MUTT_MC_AUTOVIEW); fname = mutt_str_strdup(a->filename); mutt_file_sanitize_filename(fname, true); - mutt_rfc1524_expand_filename(entry->nametemplate, fname, tempfile); + mailcap_expand_filename(entry->nametemplate, fname, tempfile); FREE(&fname); if (entry->command) { mutt_buffer_strcpy(cmd, entry->command); - /* mutt_rfc1524_expand_command returns 0 if the file is required */ - bool piped = mutt_rfc1524_expand_command(a, mutt_b2s(tempfile), type, cmd); + /* mailcap_expand_command returns 0 if the file is required */ + bool piped = mailcap_expand_command(a, mutt_b2s(tempfile), type, cmd); if (s->flags & MUTT_DISPLAY) { @@ -566,7 +566,7 @@ static int autoview_handler(struct Body *a, struct State *s) if (!fp_in) { mutt_perror("fopen"); - rfc1524_free_entry(&entry); + mailcap_entry_free(&entry); rc = -1; goto cleanup; } @@ -656,7 +656,7 @@ static int autoview_handler(struct Body *a, struct State *s) } cleanup: - rfc1524_free_entry(&entry); + mailcap_entry_free(&entry); mutt_buffer_pool_release(&cmd); mutt_buffer_pool_release(&tempfile); diff --git a/mailcap.c b/mailcap.c index f1a572e8d..c55f7bb50 100644 --- a/mailcap.c +++ b/mailcap.c @@ -21,7 +21,7 @@ */ /** - * @page rfc1524 RFC1524 Mailcap routines + * @page mailcap RFC1524 Mailcap routines * * RFC1524 defines a format for the Multimedia Mail Configuration, which is the * standard mailcap file format under Unix which specifies what external @@ -49,7 +49,7 @@ bool C_MailcapSanitize; ///< Config: Restrict the possible characters in mailcap expandos /** - * mutt_rfc1524_expand_command - Expand expandos in a command + * mailcap_expand_command - Expand expandos in a command * @param a Email Body * @param filename File containing the email text * @param type Type, e.g. "text/plain" @@ -67,8 +67,8 @@ bool C_MailcapSanitize; ///< Config: Restrict the possible characters in mailcap * %n is the integer number of sub-parts in the multipart * %F is "content-type filename" repeated for each sub-part */ -int mutt_rfc1524_expand_command(struct Body *a, const char *filename, - const char *type, struct Buffer *command) +int mailcap_expand_command(struct Body *a, const char *filename, + const char *type, struct Buffer *command) { int needspipe = true; struct Buffer *buf = mutt_buffer_pool_get(); @@ -229,7 +229,7 @@ static int get_field_text(char *field, char **entry, char *type, char *filename, * @retval false Failure */ static bool rfc1524_mailcap_parse(struct Body *a, char *filename, char *type, - struct Rfc1524MailcapEntry *entry, enum MailcapLookup opt) + struct MailcapEntry *entry, enum MailcapLookup opt) { char *buf = NULL; bool found = false; @@ -358,7 +358,7 @@ static bool rfc1524_mailcap_parse(struct Body *a, char *filename, char *type, mutt_buffer_sanitize_filename(afilename, NONULL(a->filename), true); else mutt_buffer_strcpy(afilename, NONULL(a->filename)); - mutt_rfc1524_expand_command(a, mutt_b2s(afilename), type, command); + mailcap_expand_command(a, mutt_b2s(afilename), type, command); if (mutt_system(mutt_b2s(command))) { /* a non-zero exit code means test failed */ @@ -422,24 +422,24 @@ static bool rfc1524_mailcap_parse(struct Body *a, char *filename, char *type, } /** - * rfc1524_new_entry - Allocate memory for a new rfc1524 entry - * @retval ptr An un-initialized struct Rfc1524MailcapEntry + * mailcap_entry_new - Allocate memory for a new rfc1524 entry + * @retval ptr An un-initialized struct MailcapEntry */ -struct Rfc1524MailcapEntry *rfc1524_new_entry(void) +struct MailcapEntry *mailcap_entry_new(void) { - return mutt_mem_calloc(1, sizeof(struct Rfc1524MailcapEntry)); + return mutt_mem_calloc(1, sizeof(struct MailcapEntry)); } /** - * rfc1524_free_entry - Deallocate an struct Rfc1524MailcapEntry - * @param[out] entry Rfc1524MailcapEntry to deallocate + * mailcap_entry_free - Deallocate an struct MailcapEntry + * @param[out] entry MailcapEntry to deallocate */ -void rfc1524_free_entry(struct Rfc1524MailcapEntry **entry) +void mailcap_entry_free(struct MailcapEntry **entry) { if (!entry || !*entry) return; - struct Rfc1524MailcapEntry *p = *entry; + struct MailcapEntry *p = *entry; FREE(&p->command); FREE(&p->testcommand); @@ -452,18 +452,17 @@ void rfc1524_free_entry(struct Rfc1524MailcapEntry **entry) } /** - * rfc1524_mailcap_lookup - Find given type in the list of mailcap files + * mailcap_lookup - Find given type in the list of mailcap files * @param a Message body * @param type Text type in "type/subtype" format - * @param entry struct Rfc1524MailcapEntry to populate with results + * @param entry struct MailcapEntry to populate with results * @param opt Type of mailcap entry to lookup, see #MailcapLookup * @retval true If *entry is not NULL it populates it with the mailcap entry * @retval false No matching entry is found * * Find the given type in the list of mailcap files. */ -bool rfc1524_mailcap_lookup(struct Body *a, char *type, - struct Rfc1524MailcapEntry *entry, enum MailcapLookup opt) +bool mailcap_lookup(struct Body *a, char *type, struct MailcapEntry *entry, enum MailcapLookup opt) { /* rfc1524 specifies that a path of mailcap files should be searched. * joy. They say @@ -500,7 +499,7 @@ bool rfc1524_mailcap_lookup(struct Body *a, char *type, } /** - * mutt_rfc1524_expand_filename - Expand a new filename from a template or existing filename + * mailcap_expand_filename - Expand a new filename from a template or existing filename * @param nametemplate Template * @param oldfile Original filename * @param newfile Buffer for new filename @@ -515,8 +514,8 @@ bool rfc1524_mailcap_lookup(struct Body *a, char *type, * for a "%s". If none is found, the nametemplate is used as the template for * newfile. The first path component of the nametemplate and oldfile are ignored. */ -void mutt_rfc1524_expand_filename(const char *nametemplate, const char *oldfile, - struct Buffer *newfile) +void mailcap_expand_filename(const char *nametemplate, const char *oldfile, + struct Buffer *newfile) { int i, j, k; char *s = NULL; diff --git a/mailcap.h b/mailcap.h index 52ae80abe..7de89eacf 100644 --- a/mailcap.h +++ b/mailcap.h @@ -32,9 +32,9 @@ struct Buffer; extern bool C_MailcapSanitize; /** - * struct Rfc1524MailcapEntry - A mailcap entry + * struct MailcapEntry - A mailcap entry */ -struct Rfc1524MailcapEntry +struct MailcapEntry { char *command; char *testcommand; @@ -61,11 +61,10 @@ enum MailcapLookup MUTT_MC_AUTOVIEW, ///< Mailcap autoview field }; -struct Rfc1524MailcapEntry *rfc1524_new_entry(void); -void rfc1524_free_entry(struct Rfc1524MailcapEntry **entry); -void mutt_rfc1524_expand_filename(const char *nametemplate, const char *oldfile, struct Buffer *newfile); -bool rfc1524_mailcap_lookup(struct Body *a, char *type, struct Rfc1524MailcapEntry *entry, enum MailcapLookup opt); - -int mutt_rfc1524_expand_command(struct Body *a, const char *filename, const char *type, struct Buffer *command); +void mailcap_entry_free(struct MailcapEntry **entry); +struct MailcapEntry *mailcap_entry_new(void); +int mailcap_expand_command(struct Body *a, const char *filename, const char *type, struct Buffer *command); +void mailcap_expand_filename(const char *nametemplate, const char *oldfile, struct Buffer *newfile); +bool mailcap_lookup(struct Body *a, char *type, struct MailcapEntry *entry, enum MailcapLookup opt); #endif /* MUTT_MAILCAP_H */ diff --git a/mutt_attach.c b/mutt_attach.c index a02455a58..f5efc0cfe 100644 --- a/mutt_attach.c +++ b/mutt_attach.c @@ -71,12 +71,12 @@ int mutt_get_tmp_attachment(struct Body *a) return 0; struct Buffer *tmpfile = mutt_buffer_pool_get(); - struct Rfc1524MailcapEntry *entry = rfc1524_new_entry(); + struct MailcapEntry *entry = mailcap_entry_new(); snprintf(type, sizeof(type), "%s/%s", TYPE(a), a->subtype); - rfc1524_mailcap_lookup(a, type, entry, MUTT_MC_NO_FLAGS); - mutt_rfc1524_expand_filename(entry->nametemplate, a->filename, tmpfile); + mailcap_lookup(a, type, entry, MUTT_MC_NO_FLAGS); + mailcap_expand_filename(entry->nametemplate, a->filename, tmpfile); - rfc1524_free_entry(&entry); + mailcap_entry_free(&entry); if (stat(a->filename, &st) == -1) { @@ -115,7 +115,7 @@ int mutt_get_tmp_attachment(struct Body *a) int mutt_compose_attachment(struct Body *a) { char type[256]; - struct Rfc1524MailcapEntry *entry = rfc1524_new_entry(); + struct MailcapEntry *entry = mailcap_entry_new(); bool unlink_newfile = false; int rc = 0; struct Buffer *cmd = mutt_buffer_pool_get(); @@ -123,7 +123,7 @@ int mutt_compose_attachment(struct Body *a) struct Buffer *tmpfile = mutt_buffer_pool_get(); snprintf(type, sizeof(type), "%s/%s", TYPE(a), a->subtype); - if (rfc1524_mailcap_lookup(a, type, entry, MUTT_MC_COMPOSE)) + if (mailcap_lookup(a, type, entry, MUTT_MC_COMPOSE)) { if (entry->composecommand || entry->composetypecommand) { @@ -132,7 +132,7 @@ int mutt_compose_attachment(struct Body *a) else mutt_buffer_strcpy(cmd, entry->composecommand); - mutt_rfc1524_expand_filename(entry->nametemplate, a->filename, newfile); + mailcap_expand_filename(entry->nametemplate, a->filename, newfile); mutt_debug(LL_DEBUG1, "oldfile: %s\t newfile: %s\n", a->filename, mutt_b2s(newfile)); if (mutt_file_symlink(a->filename, mutt_b2s(newfile)) == -1) { @@ -143,7 +143,7 @@ int mutt_compose_attachment(struct Body *a) else unlink_newfile = true; - if (mutt_rfc1524_expand_command(a, mutt_b2s(newfile), type, cmd)) + if (mailcap_expand_command(a, mutt_b2s(newfile), type, cmd)) { /* For now, editing requires a file, no piping */ mutt_error(_("Mailcap compose entry requires %%s")); @@ -234,7 +234,7 @@ bailout: mutt_buffer_pool_release(&newfile); mutt_buffer_pool_release(&tmpfile); - rfc1524_free_entry(&entry); + mailcap_entry_free(&entry); return rc; } @@ -254,19 +254,19 @@ bailout: int mutt_edit_attachment(struct Body *a) { char type[256]; - struct Rfc1524MailcapEntry *entry = rfc1524_new_entry(); + struct MailcapEntry *entry = mailcap_entry_new(); bool unlink_newfile = false; int rc = 0; struct Buffer *cmd = mutt_buffer_pool_get(); struct Buffer *newfile = mutt_buffer_pool_get(); snprintf(type, sizeof(type), "%s/%s", TYPE(a), a->subtype); - if (rfc1524_mailcap_lookup(a, type, entry, MUTT_MC_EDIT)) + if (mailcap_lookup(a, type, entry, MUTT_MC_EDIT)) { if (entry->editcommand) { mutt_buffer_strcpy(cmd, entry->editcommand); - mutt_rfc1524_expand_filename(entry->nametemplate, a->filename, newfile); + mailcap_expand_filename(entry->nametemplate, a->filename, newfile); mutt_debug(LL_DEBUG1, "oldfile: %s\t newfile: %s\n", a->filename, mutt_b2s(newfile)); if (mutt_file_symlink(a->filename, mutt_b2s(newfile)) == -1) { @@ -277,7 +277,7 @@ int mutt_edit_attachment(struct Body *a) else unlink_newfile = true; - if (mutt_rfc1524_expand_command(a, mutt_b2s(newfile), type, cmd)) + if (mailcap_expand_command(a, mutt_b2s(newfile), type, cmd)) { /* For now, editing requires a file, no piping */ mutt_error(_("Mailcap Edit entry requires %%s")); @@ -316,7 +316,7 @@ bailout: mutt_buffer_pool_release(&cmd); mutt_buffer_pool_release(&newfile); - rfc1524_free_entry(&entry); + mailcap_entry_free(&entry); return rc; } @@ -390,7 +390,7 @@ int mutt_view_attachment(FILE *fp, struct Body *a, enum ViewAttachMode mode, char type[256]; char desc[256]; char *fname = NULL; - struct Rfc1524MailcapEntry *entry = NULL; + struct MailcapEntry *entry = NULL; int rc = -1; bool unlink_tempfile = false; @@ -411,13 +411,13 @@ int mutt_view_attachment(FILE *fp, struct Body *a, enum ViewAttachMode mode, if (use_mailcap) { - entry = rfc1524_new_entry(); - if (!rfc1524_mailcap_lookup(a, type, entry, MUTT_MC_NO_FLAGS)) + entry = mailcap_entry_new(); + if (!mailcap_lookup(a, type, entry, MUTT_MC_NO_FLAGS)) { if (mode == MUTT_VA_REGULAR) { /* fallback to view as text */ - rfc1524_free_entry(&entry); + mailcap_entry_free(&entry); mutt_error(_("No matching mailcap entry found. Viewing as text.")); mode = MUTT_VA_AS_TEXT; use_mailcap = false; @@ -444,7 +444,7 @@ int mutt_view_attachment(FILE *fp, struct Body *a, enum ViewAttachMode mode, else fname = a->filename; - mutt_rfc1524_expand_filename(entry->nametemplate, fname, tmpfile); + mailcap_expand_filename(entry->nametemplate, fname, tmpfile); /* send case: the file is already there; symlink to it */ if (!fp) { @@ -466,7 +466,7 @@ int mutt_view_attachment(FILE *fp, struct Body *a, enum ViewAttachMode mode, mutt_file_chmod(mutt_b2s(tmpfile), S_IRUSR); } - use_pipe = mutt_rfc1524_expand_command(a, mutt_b2s(tmpfile), type, cmd); + use_pipe = mailcap_expand_command(a, mutt_b2s(tmpfile), type, cmd); use_pager = entry->copiousoutput; } @@ -648,7 +648,7 @@ return_error: } } - rfc1524_free_entry(&entry); + mailcap_entry_free(&entry); if (mutt_b2s(pagerfile)[0] != '\0') mutt_file_unlink(mutt_b2s(pagerfile)); @@ -1029,15 +1029,15 @@ int mutt_print_attachment(FILE *fp, struct Body *a) snprintf(type, sizeof(type), "%s/%s", TYPE(a), a->subtype); - if (rfc1524_mailcap_lookup(a, type, NULL, MUTT_MC_PRINT)) + if (mailcap_lookup(a, type, NULL, MUTT_MC_PRINT)) { int piped = false; mutt_debug(LL_DEBUG2, "Using mailcap\n"); - struct Rfc1524MailcapEntry *entry = rfc1524_new_entry(); - rfc1524_mailcap_lookup(a, type, entry, MUTT_MC_PRINT); - mutt_rfc1524_expand_filename(entry->nametemplate, a->filename, newfile); + struct MailcapEntry *entry = mailcap_entry_new(); + mailcap_lookup(a, type, entry, MUTT_MC_PRINT); + mailcap_expand_filename(entry->nametemplate, a->filename, newfile); /* send mode: symlink from existing file to the newfile */ if (!fp) { @@ -1058,7 +1058,7 @@ int mutt_print_attachment(FILE *fp, struct Body *a) } mutt_buffer_strcpy(cmd, entry->printcommand); - piped = mutt_rfc1524_expand_command(a, mutt_b2s(newfile), type, cmd); + piped = mailcap_expand_command(a, mutt_b2s(newfile), type, cmd); mutt_endwin(); @@ -1069,7 +1069,7 @@ int mutt_print_attachment(FILE *fp, struct Body *a) if (!fp_in) { mutt_perror("fopen"); - rfc1524_free_entry(&entry); + mailcap_entry_free(&entry); goto mailcap_cleanup; } @@ -1077,7 +1077,7 @@ int mutt_print_attachment(FILE *fp, struct Body *a) if (pid < 0) { mutt_perror(_("Can't create filter")); - rfc1524_free_entry(&entry); + mailcap_entry_free(&entry); mutt_file_fclose(&fp_in); goto mailcap_cleanup; } @@ -1105,7 +1105,7 @@ int mutt_print_attachment(FILE *fp, struct Body *a) else if (unlink_newfile) unlink(mutt_b2s(newfile)); - rfc1524_free_entry(&entry); + mailcap_entry_free(&entry); goto out; } diff --git a/recvattach.c b/recvattach.c index 50434405c..46b54650b 100644 --- a/recvattach.c +++ b/recvattach.c @@ -920,7 +920,7 @@ static bool can_print(struct AttachCtx *actx, struct Body *top, bool tag) snprintf(type, sizeof(type), "%s/%s", TYPE(top), top->subtype); if (!tag || top->tagged) { - if (!rfc1524_mailcap_lookup(top, type, NULL, MUTT_MC_PRINT)) + if (!mailcap_lookup(top, type, NULL, MUTT_MC_PRINT)) { if ((mutt_str_strcasecmp("text/plain", top->subtype) != 0) && (mutt_str_strcasecmp("application/postscript", top->subtype) != 0)) @@ -964,7 +964,7 @@ static void print_attachment_list(struct AttachCtx *actx, FILE *fp, bool tag, if (!tag || top->tagged) { snprintf(type, sizeof(type), "%s/%s", TYPE(top), top->subtype); - if (!C_AttachSplit && !rfc1524_mailcap_lookup(top, type, NULL, MUTT_MC_PRINT)) + if (!C_AttachSplit && !mailcap_lookup(top, type, NULL, MUTT_MC_PRINT)) { if ((mutt_str_strcasecmp("text/plain", top->subtype) == 0) || (mutt_str_strcasecmp("application/postscript", top->subtype) == 0))