RFC1524 Mailcap routines. More...
#include "config.h"
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "mailcap.h"
#include "attach/lib.h"
#include "muttlib.h"
#include "protos.h"
Go to the source code of this file.
Functions | |
int | mailcap_expand_command (struct Body *b, const char *filename, const char *type, struct Buffer *command) |
Expand expandos in a command. | |
static char * | get_field (char *s) |
NUL terminate a RFC1524 field. | |
static int | get_field_text (char *field, char **entry, const char *type, const char *filename, int line) |
Get the matching text from a mailcap. | |
static bool | rfc1524_mailcap_parse (struct Body *b, const char *filename, const char *type, struct MailcapEntry *entry, enum MailcapLookup opt) |
Parse a mailcap entry. | |
struct MailcapEntry * | mailcap_entry_new (void) |
Allocate memory for a new rfc1524 entry. | |
void | mailcap_entry_free (struct MailcapEntry **ptr) |
Deallocate an struct MailcapEntry. | |
bool | mailcap_lookup (struct Body *b, char *type, size_t typelen, struct MailcapEntry *entry, enum MailcapLookup opt) |
Find given type in the list of mailcap files. | |
void | mailcap_expand_filename (const char *nametemplate, const char *oldfile, struct Buffer *newfile) |
Expand a new filename from a template or existing filename. | |
RFC1524 Mailcap routines.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file mailcap.c.
int mailcap_expand_command | ( | struct Body * | b, |
const char * | filename, | ||
const char * | type, | ||
struct Buffer * | command | ||
) |
Expand expandos in a command.
b | Email Body |
filename | File containing the email text |
type | Type, e.g. "text/plain" |
command | Buffer containing command |
The command semantics include the following: s is the filename that contains the mail body data t is the content type, like text/plain %{parameter} is replaced by the parameter value from the content-type field % is % Unsupported rfc1524 parameters: these would probably require some doing by neomutt, and can probably just be done by piping the message to metamail n is the integer number of sub-parts in the multipart F is "content-type filename" repeated for each sub-part
Definition at line 69 of file mailcap.c.
|
static |
NUL terminate a RFC1524 field.
s | String to alter |
ptr | Start of next field |
NULL | Error |
Definition at line 166 of file mailcap.c.
|
static |
Get the matching text from a mailcap.
field | String to parse |
entry | Save the entry here |
type | Type, e.g. "text/plain" |
filename | Mailcap filename |
line | Mailcap line |
1 | Success |
0 | Failure |
Definition at line 202 of file mailcap.c.
|
static |
Parse a mailcap entry.
b | Email Body |
filename | Filename |
type | Type, e.g. "text/plain" |
entry | Entry, e.g. "compose" |
opt | Option, see MailcapLookup |
true | Success |
false | Failure |
Definition at line 234 of file mailcap.c.
struct MailcapEntry * mailcap_entry_new | ( | void | ) |
Allocate memory for a new rfc1524 entry.
ptr | An un-initialized struct MailcapEntry |
Definition at line 445 of file mailcap.c.
void mailcap_entry_free | ( | struct MailcapEntry ** | ptr | ) |
Deallocate an struct MailcapEntry.
[out] | ptr | MailcapEntry to deallocate |
Definition at line 454 of file mailcap.c.
bool mailcap_lookup | ( | struct Body * | b, |
char * | type, | ||
size_t | typelen, | ||
struct MailcapEntry * | entry, | ||
enum MailcapLookup | opt | ||
) |
Find given type in the list of mailcap files.
b | Message body |
type | Text type in "type/subtype" format |
typelen | Length of the type |
entry | struct MailcapEntry to populate with results |
opt | Type of mailcap entry to lookup, see MailcapLookup |
true | If *entry is not NULL it populates it with the mailcap entry |
false | No matching entry is found |
Find the given type in the list of mailcap files.
Definition at line 483 of file mailcap.c.
void mailcap_expand_filename | ( | const char * | nametemplate, |
const char * | oldfile, | ||
struct Buffer * | newfile | ||
) |
Expand a new filename from a template or existing filename.
nametemplate | Template |
oldfile | Original filename |
newfile | Buffer for new filename |
If there is no nametemplate, the stripped oldfile name is used as the template for newfile.
If there is no oldfile, the stripped nametemplate name is used as the template for newfile.
If both a nametemplate and oldfile are specified, the template is checked 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.
Definition at line 552 of file mailcap.c.