*
* @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;
}
*/
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();
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)
{
if (!fp_in)
{
mutt_perror("fopen");
- rfc1524_free_entry(&entry);
+ mailcap_entry_free(&entry);
rc = -1;
goto cleanup;
}
}
cleanup:
- rfc1524_free_entry(&entry);
+ mailcap_entry_free(&entry);
mutt_buffer_pool_release(&cmd);
mutt_buffer_pool_release(&tempfile);
*/
/**
- * @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
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"
* %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();
* @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;
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 */
}
/**
- * 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);
}
/**
- * 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
}
/**
- * 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
* 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;
extern bool C_MailcapSanitize;
/**
- * struct Rfc1524MailcapEntry - A mailcap entry
+ * struct MailcapEntry - A mailcap entry
*/
-struct Rfc1524MailcapEntry
+struct MailcapEntry
{
char *command;
char *testcommand;
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 */
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)
{
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();
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)
{
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)
{
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"));
mutt_buffer_pool_release(&newfile);
mutt_buffer_pool_release(&tmpfile);
- rfc1524_free_entry(&entry);
+ mailcap_entry_free(&entry);
return rc;
}
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)
{
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"));
mutt_buffer_pool_release(&cmd);
mutt_buffer_pool_release(&newfile);
- rfc1524_free_entry(&entry);
+ mailcap_entry_free(&entry);
return rc;
}
char type[256];
char desc[256];
char *fname = NULL;
- struct Rfc1524MailcapEntry *entry = NULL;
+ struct MailcapEntry *entry = NULL;
int rc = -1;
bool unlink_tempfile = false;
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;
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)
{
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;
}
}
}
- rfc1524_free_entry(&entry);
+ mailcap_entry_free(&entry);
if (mutt_b2s(pagerfile)[0] != '\0')
mutt_file_unlink(mutt_b2s(pagerfile));
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)
{
}
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();
if (!fp_in)
{
mutt_perror("fopen");
- rfc1524_free_entry(&entry);
+ mailcap_entry_free(&entry);
goto mailcap_cleanup;
}
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;
}
else if (unlink_newfile)
unlink(mutt_b2s(newfile));
- rfc1524_free_entry(&entry);
+ mailcap_entry_free(&entry);
goto out;
}
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))
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))