static int eai = 0;
void
-enable_eai(void) {
+enable_eai(void)
+{
eai = 1;
}
*/
int
decodeBase64 (const char *encoded, unsigned char **decoded, size_t *len,
- int skip_crs, unsigned char *digest) {
+ int skip_crs, unsigned char *digest)
+{
const char *cp = encoded;
int bitno, skip;
uint32_t bits;
* is allocated by the function and must be freed by the caller.
*/
void
-hexify (const unsigned char *input, size_t len, char **output) {
+hexify (const unsigned char *input, size_t len, char **output)
+{
/* Start with a charstring capacity that's arbitrarily larger than len. */
const charstring_t tmp = charstring_create (2 * len);
const unsigned char *cp = input;
static void
-charstring_reserve (charstring_t s, size_t need) {
+charstring_reserve (charstring_t s, size_t need)
+{
const size_t cur = s->cur - s->buffer;
while (need >= s->max - cur) {
* max is in characters
*/
charstring_t
-charstring_create (size_t max) {
+charstring_create (size_t max)
+{
charstring_t s;
NEW(s);
}
charstring_t
-charstring_copy (const charstring_t src) {
+charstring_copy (const charstring_t src)
+{
const size_t num = src->cur - src->buffer;
charstring_t s;
* OK to call charstring_free with a NULL argument.
*/
void
-charstring_free (charstring_t s) {
+charstring_free (charstring_t s)
+{
if (s) {
free (s->buffer);
free (s);
}
void
-charstring_push_back (charstring_t s, const char c) {
+charstring_push_back (charstring_t s, const char c)
+{
charstring_reserve (s, s->cur - s->buffer + 1);
*s->cur++ = c;
++s->chars;
*/
void
charstring_push_back_chars (charstring_t s, const char c[], size_t num,
- size_t width) {
+ size_t width)
+{
size_t i;
charstring_reserve (s, s->cur - s->buffer + num);
}
void
-charstring_append (charstring_t dest, const charstring_t src) {
+charstring_append (charstring_t dest, const charstring_t src)
+{
const size_t num = src->cur - src->buffer;
if (num > 0) {
}
void
-charstring_append_cstring (charstring_t dest, const char src[]) {
+charstring_append_cstring (charstring_t dest, const char src[])
+{
const size_t num = strlen (src);
if (num > 0) {
}
void
-charstring_clear (charstring_t s) {
+charstring_clear (charstring_t s)
+{
s->cur = s->buffer;
s->chars = 0;
}
* intervening push_back's; use charstring_buffer_copy() instead.
*/
const char *
-charstring_buffer (const charstring_t s) {
+charstring_buffer (const charstring_t s)
+{
charstring_reserve (s, s->cur - s->buffer + 1);
/* This is the only place that we null-terminate the buffer. */
}
char *
-charstring_buffer_copy (const charstring_t s) {
+charstring_buffer_copy (const charstring_t s)
+{
char *copy = mh_xmalloc (s->cur - s->buffer + 1);
/* Use charstring_buffer() to null terminate the buffer. */
}
size_t
-charstring_bytes (const charstring_t s) {
+charstring_bytes (const charstring_t s)
+{
return s->cur - s->buffer;
}
size_t
-charstring_chars (const charstring_t s) {
+charstring_chars (const charstring_t s)
+{
return s->chars;
}
int
-charstring_last_char_len (const charstring_t s) {
+charstring_last_char_len (const charstring_t s)
+{
int len = 0;
#ifdef MULTIBYTE_SUPPORT
const char *sp = charstring_buffer (s);
*/
char *
context_find_by_type (const char *string, const char *type,
- const char *subtype) {
+ const char *subtype)
+{
char *value = NULL;
if (subtype) {
* The search is case insensitive.
*/
int
-context_find_prefix (const char *prefix) {
+context_find_prefix (const char *prefix)
+{
struct node *np;
size_t len;
};
void
-init_credentials_file(void) {
+init_credentials_file(void)
+{
if (credentials_file == NULL) {
char *cred_style = context_find ("credentials");
*/
static int
parse_datetime (const char *datetime, const char *zone, bool dst,
- struct tws *tws) {
+ struct tws *tws)
+{
char utc_indicator;
bool form_1;
int items_matched;
}
tzdesc_t
-load_timezones (const contentline *clines) {
+load_timezones (const contentline *clines)
+{
tzdesc_t timezones = NULL, timezone = NULL;
bool in_vtimezone, in_standard, in_daylight;
tzparams *params = NULL;
}
void
-free_timezones (tzdesc_t timezone) {
+free_timezones (tzdesc_t timezone)
+{
tzdesc_t next;
for ( ; timezone; timezone = next) {
*/
time_t
rrule_clock (const char *rrule, const char *starttime, const char *zone,
- unsigned int year) {
+ unsigned int year)
+{
time_t clock = 0;
if (nmh_strcasestr (rrule, "FREQ=YEARLY;INTERVAL=1") ||
}
char *
-format_datetime (tzdesc_t timezones, const contentline *node) {
+format_datetime (tzdesc_t timezones, const contentline *node)
+{
param_list *p;
char *dt_timezone = NULL;
int dst = 0;
void
-escape_display_name (char *name, size_t namesize) {
+escape_display_name (char *name, size_t namesize)
+{
char *specials = "\"(),.:;<>@[\\]";
escape_component (name, namesize, specials);
}
void
-escape_local_part (char *name, size_t namesize) {
+escape_local_part (char *name, size_t namesize)
+{
/* wsp (whitespace) is horizontal tab or space, according to
RFC 5234. */
char *specials_less_dot_plus_wsp = " \"(),:;<>@[\\]";
namesize argument. The need_escape argument is a string of
characters that require that name be escaped. */
static void
-escape_component (char *name, size_t namesize, char *chars_to_escape) {
+escape_component (char *name, size_t namesize, char *chars_to_escape)
+{
/* If name contains any chars_to_escape:
1) enclose it in ""
2) escape any embedded "
void
-free_fs(void) {
+free_fs(void)
+{
free (formats);
formats = 0;
}
* copy a number to the destination subject to a maximum width
*/
void
-cpnumber(charstring_t dest, int num, int wid, char fill, size_t max) {
+cpnumber(charstring_t dest, int num, int wid, char fill, size_t max)
+{
/* Maybe we should handle left padding at some point? */
if (wid == 0)
return;
* aligned no more than max characters are copied
*/
void
-cptrimmed(charstring_t dest, char *str, int wid, char fill, size_t max) {
+cptrimmed(charstring_t dest, char *str, int wid, char fill, size_t max)
+{
int remaining; /* remaining output width available */
bool rjust;
struct charstring *trimmed;
%%
static char *
-unfold (char *text, size_t *leng) {
+unfold (char *text, size_t *leng)
+{
/* It's legal to shorten text and modify leng (because we don't
use yymore()). */
char *cp;
* with something other than flex.
*/
static void
-destroy_icallex(void) {
+destroy_icallex(void)
+{
#if defined FLEX_SCANNER && defined YY_FLEX_SUBMINOR_VERSION
/* Hack: rely on fact that the the YY_FLEX_SUBMINOR_VERSION
#define was added to flex (flex.skl v. 2.163) after
* because flex 2.5.4 doesn't.
*/
void
-icalset_inputfile (FILE *file) {
+icalset_inputfile (FILE *file)
+{
yyin = file;
}
void
-icalset_outputfile (FILE *file) {
+icalset_outputfile (FILE *file)
+{
yyout = file;
}
* Remove the contentline node (by setting its name to NULL).
*/
void
-remove_contentline (contentline *node) {
+remove_contentline (contentline *node)
+{
free (node->name);
node->name = NULL;
}
contentline *
-add_contentline (contentline *node, const char *name) {
+add_contentline (contentline *node, const char *name)
+{
contentline *new_node;
NEW0(new_node);
* Remove the value from a value_list.
*/
void
-remove_value (value_list *node) {
+remove_value (value_list *node)
+{
free (node->value);
node->value = NULL;
}
*/
contentline *
find_contentline (contentline *contentlines, const char *name,
- const char *val) {
+ const char *val)
+{
contentline *node;
for (node = contentlines; node; node = node->next) {
}
static char *
-append (contentline *cline, const char *src, const size_t src_len) {
+append (contentline *cline, const char *src, const size_t src_len)
+{
if (src_len > 0) {
const size_t len = cline->input_line_len + src_len;
}
static void
-new_content_line (contentline **cline) {
+new_content_line (contentline **cline)
+{
contentline *new_node;
NEW0(new_node);
}
static void
-new_vevent (vevent *event) {
+new_vevent (vevent *event)
+{
vevent *new_node, *node;
NEW0(new_node);
}
void
-add_param_name (contentline *cline, char *name) {
+add_param_name (contentline *cline, char *name)
+{
param_list *new_node;
param_list *p;
* Add a value to the last parameter seen.
*/
void
-add_param_value (contentline *cline, char *value) {
+add_param_value (contentline *cline, char *value)
+{
value_list *new_node;
param_list *p;
value_list *v;
}
void
-free_contentlines (contentline *root) {
+free_contentlines (contentline *root)
+{
contentline *i, *next;
for (i = root; i; i = next) {
}
static void
-free_param_names (param_list *p) {
+free_param_names (param_list *p)
+{
param_list *next;
for ( ; p; p = next) {
}
static void
-free_param_values (value_list *v) {
+free_param_values (value_list *v)
+{
value_list *next;
for ( ; v; v = next) {
}
static int
-icalerror (const char *error) {
+icalerror (const char *error)
+{
contentline *c;
charstring_t context = NULL;
/* scan() needs to force an initial state of FLD for each message. */
void
-m_getfld_state_reset (m_getfld_state_t *gstate) {
+m_getfld_state_reset (m_getfld_state_t *gstate)
+{
if (*gstate) {
(*gstate)->state = FLD;
}
calls, m_getfld() must keep track of the file position. The caller
must use this function to inform m_getfld(). */
void
-m_getfld_track_filepos (m_getfld_state_t *gstate, FILE *iob) {
+m_getfld_track_filepos (m_getfld_state_t *gstate, FILE *iob)
+{
if (! *gstate) {
*gstate = m_getfld_state_init(iob);
}
m_getfld_track_filepos(gstate, (*gstate)->iob);
}
-void m_getfld_state_destroy (m_getfld_state_t *gstate) {
+void m_getfld_state_destroy (m_getfld_state_t *gstate)
+{
m_getfld_state_t s = *gstate;
if (s) {
static void
-enter_getfld (m_getfld_state_t *gstate, FILE *iob) {
+enter_getfld (m_getfld_state_t *gstate, FILE *iob)
+{
m_getfld_state_t s;
off_t pos;
off_t pos_movement;
}
static void
-leave_getfld (m_getfld_state_t s) {
+leave_getfld (m_getfld_state_t s)
+{
s->total_bytes_read += s->bytes_read;
if (s->track_filepos) {
}
static size_t
-read_more (m_getfld_state_t s) {
+read_more (m_getfld_state_t s)
+{
/* Retain at least edelimlen characters that have already been read,
if at least edelimlen have been read, so that we can back up to them
in m_Eom(). */
/* Return the next character consumed from the input, fetching more of
* the input for the buffer if required, or EOF on end of file. */
static int
-Getc (m_getfld_state_t s) {
+Getc (m_getfld_state_t s)
+{
if ((s->end - s->readpos < 1 && read_more (s) == 0) ||
s->readpos >= s->end)
return EOF;
* Register a file for removal at program termination.
*/
static void
-register_for_removal(const char *pathname) {
+register_for_removal(const char *pathname)
+{
if (exit_filelist == NULL) exit_filelist = svector_create(20);
(void) svector_push_back(exit_filelist, mh_xstrdup(pathname));
}
* quickly created with the same name.
*/
void
-unregister_for_removal(int remove_files) {
+unregister_for_removal(int remove_files)
+{
if (exit_filelist) {
size_t i;
* any case, unlink it.
*/
int
-m_unlink(const char *pathname) {
+m_unlink(const char *pathname)
+{
if (exit_filelist) {
char **slot = svector_find(exit_filelist, pathname);
* Remove all registered temporary files.
*/
void
-remove_registered_files_atexit(void) {
+remove_registered_files_atexit(void)
+{
unregister_for_removal(1);
}
* in case the use was expecting a core dump.
*/
void
-remove_registered_files(int sig) {
+remove_registered_files(int sig)
+{
struct sigaction act;
/*
int
-m_rand (unsigned char *buf, size_t n) {
+m_rand (unsigned char *buf, size_t n)
+{
#if !HAVE_ARC4RANDOM
if (! seeded) {
FILE *devurandom;
/* Convert name of message id style to integer value and store it. */
int
-save_message_id_style (const char *value) {
+save_message_id_style (const char *value)
+{
if (! strcasecmp (value, "localname")) {
message_id_style = NMH_MESSAGE_ID_LOCALNAME;
return 0;
char *
-message_id (time_t tclock, int content_id) {
+message_id (time_t tclock, int content_id)
+{
switch (message_id_style) {
case NMH_MESSAGE_ID_LOCALNAME: {
#define P(fmt) \
* is responsible for free'ing returned memory.
*/
char *
-mime_type(const char *file_name) {
+mime_type(const char *file_name)
+{
char *content_type = NULL; /* mime content type */
char *p;
/* Convert name of mts method to integer value and store it. */
void
-save_mts_method (const char *value) {
+save_mts_method (const char *value)
+{
if (! strcasecmp (value, "smtp")) {
mts_method = "smtp";
sm_mts = MTS_SMTP;
"at http://www.nongnu.org/nmh/ .\n";
void
-print_intro (FILE *file, bool brief) {
+print_intro (FILE *file, bool brief)
+{
fputs (nmh_intro1, file);
if (! brief) {
fputs (nmh_intro2, file);
void
-add_profile_entry (const char *key, const char *value) {
+add_profile_entry (const char *key, const char *value)
+{
struct node *newnode;
/* This inserts the new node at the beginning of m_defs because
* For use by nmh_init().
*/
int
-setup_signal_handlers(void) {
+setup_signal_handlers(void)
+{
/*
* Catch HUP, INT, QUIT, and TERM so that we can clean up tmp
* files when the user terminates the process early. And also a
* complete copyright information.
*/
char *
-cpytrim (const char *sp) {
+cpytrim (const char *sp)
+{
char *dp;
char *cp;
* complete copyright information.
*/
char *
-rtrim (char *sp) {
+rtrim (char *sp)
+{
char *cp;
/* start at the end and zap trailing whitespace */
* pointer so that the caller can modify it.
*/
char *
-find_str (const char buf[], size_t buflen, const char *str) {
+find_str (const char buf[], size_t buflen, const char *str)
+{
const size_t len = strlen (str);
size_t i;
* pointer so that the caller can modify it.
*/
char *
-rfind_str (const char buf[], size_t buflen, const char *str) {
+rfind_str (const char buf[], size_t buflen, const char *str)
+{
const size_t len = strlen (str);
size_t i;
/* POSIX doesn't have strcasestr() so emulate it. */
char *
-nmh_strcasestr (const char *s1, const char *s2) {
+nmh_strcasestr (const char *s1, const char *s2)
+{
const size_t len = strlen (s2);
if (isupper ((unsigned char) s2[0]) || islower ((unsigned char)s2[0])) {
* use that prefix here.
*/
int
-nmh_version_changed (int older) {
+nmh_version_changed (int older)
+{
const char *const context_version = context_find("Version");
if (older) {
* See if input has any 8-bit bytes.
*/
int
-scan_input (int fd, int *eightbit) {
+scan_input (int fd, int *eightbit)
+{
int state;
char buf[BUFSIZ];
* Convert an int to a char string.
*/
char *
-m_str(int value) {
+m_str(int value)
+{
return m_strn(value, 0);
}
#define SIZE(n) (sizeof STR(n))
char *
-m_strn(int value, unsigned int width) {
+m_strn(int value, unsigned int width)
+{
/* Need to include space for negative sign. But don't use INT_MIN
because it could be a macro that would fool SIZE(n). */
static char buffer[SIZE(-INT_MAX)];
static void bvector_resize (bvector_t vec, size_t newsize);
bvector_t
-bvector_create (void) {
+bvector_create (void)
+{
bvector_t vec;
/* See "wider than unsigned long" comment above. */
}
void
-bvector_copy (bvector_t dest, bvector_t src) {
+bvector_copy (bvector_t dest, bvector_t src)
+{
size_t bytes = BVEC_BYTES(src->maxsize);
if (dest->bits != dest->tiny)
}
void
-bvector_free (bvector_t vec) {
+bvector_free (bvector_t vec)
+{
bvector_fini(vec);
free (vec);
}
}
void
-bvector_clear (bvector_t vec, size_t n) {
+bvector_clear (bvector_t vec, size_t n)
+{
if (n < vec->maxsize)
vec->bits[BVEC_WORD(n)] &= ~(1ul << BVEC_OFFSET(n));
}
void
-bvector_clear_all (bvector_t vec) {
+bvector_clear_all (bvector_t vec)
+{
memset (vec->bits, 0, BVEC_BYTES(vec->maxsize));
}
void
-bvector_set (bvector_t vec, size_t n) {
+bvector_set (bvector_t vec, size_t n)
+{
size_t word = BVEC_WORD(n);
size_t offset = BVEC_OFFSET(n);
}
unsigned int
-bvector_at (bvector_t vec, size_t i) {
+bvector_at (bvector_t vec, size_t i)
+{
if (i < vec->maxsize)
return !!(vec->bits[BVEC_WORD(i)] & (1ul << BVEC_OFFSET(i)));
}
static void
-bvector_resize (bvector_t vec, size_t newsize) {
+bvector_resize (bvector_t vec, size_t newsize)
+{
size_t oldsize = vec->maxsize;
size_t bytes;
}
unsigned long
-bvector_first_bits (bvector_t vec) {
+bvector_first_bits (bvector_t vec)
+{
return *vec->bits;
}
static void svector_resize (svector_t, size_t);
svector_t
-svector_create (size_t init_size) {
+svector_create (size_t init_size)
+{
svector_t vec;
size_t bytes;
}
void
-svector_free (svector_t vec) {
+svector_free (svector_t vec)
+{
free (vec->strs);
free (vec);
}
char *
-svector_push_back (svector_t vec, char *s) {
+svector_push_back (svector_t vec, char *s)
+{
if (++vec->size >= vec->maxsize)
svector_resize (vec, vec->size);
return vec->strs[vec->size-1] = s;
}
char *
-svector_at (svector_t vec, size_t i) {
+svector_at (svector_t vec, size_t i)
+{
if (i >= vec->maxsize)
svector_resize (vec, i);
return vec->strs[i];
* The caller can replace the contents of the return address.
*/
char **
-svector_find (svector_t vec, const char *s) {
+svector_find (svector_t vec, const char *s)
+{
size_t i;
char **str = vec->strs;
}
char **
-svector_strs (svector_t vec) {
+svector_strs (svector_t vec)
+{
return vec->strs;
}
size_t
-svector_size (svector_t vec) {
+svector_size (svector_t vec)
+{
return vec->size;
}
static void
-svector_resize (svector_t vec, size_t maxsize) {
+svector_resize (svector_t vec, size_t maxsize)
+{
size_t old_maxsize = vec->maxsize;
while ((vec->maxsize *= 2) < maxsize)
static void ivector_resize (ivector_t, size_t);
ivector_t
-ivector_create (size_t init_size) {
+ivector_create (size_t init_size)
+{
ivector_t vec;
size_t bytes;
}
void
-ivector_free (ivector_t vec) {
+ivector_free (ivector_t vec)
+{
free (vec->ints);
free (vec);
}
int
-ivector_push_back (ivector_t vec, int n) {
+ivector_push_back (ivector_t vec, int n)
+{
if (++vec->size >= vec->maxsize)
ivector_resize (vec, vec->size);
return vec->ints[vec->size-1] = n;
}
int
-ivector_at (ivector_t vec, size_t i) {
+ivector_at (ivector_t vec, size_t i)
+{
if (i >= vec->maxsize)
ivector_resize (vec, i);
return vec->ints[i];
}
int *
-ivector_atp (ivector_t vec, size_t i) {
+ivector_atp (ivector_t vec, size_t i)
+{
if (i >= vec->maxsize)
ivector_resize (vec, i);
return &vec->ints[i];
}
static void
-ivector_resize (ivector_t vec, size_t maxsize) {
+ivector_resize (ivector_t vec, size_t maxsize)
+{
size_t old_maxsize = vec->maxsize;
while ((vec->maxsize *= 2) < maxsize)
*/
static
void
-nonexistent_folder (int status) {
+nonexistent_folder (int status)
+{
NMH_UNUSED (status);
die("folder %s does not exist", folder);
}
* 'attachment'.
*/
void
-set_disposition (CT ct) {
+set_disposition (CT ct)
+{
if (ct->c_dispo_type == NULL) {
char *cp = context_find_by_type ("disposition", ct->c_ctinfo.ci_type,
ct->c_ctinfo.ci_subtype);
* -1: ignore content and use user's locale to determine charset
*/
void
-set_charset (CT ct, int contains8bit) {
+set_charset (CT ct, int contains8bit)
+{
if (ct->c_type == CT_TEXT) {
struct text *t;
*/
void
expand_pseudoheaders (CT ct, struct multipart *m, const char *infile,
- const convert_list *convert_head) {
+ const convert_list *convert_head)
+{
/* text_plain_ct is used to concatenate all of the text/plain
replies into one part, instead of having each one in a separate
part. */
void
expand_pseudoheader (CT ct, CT *text_plain_ct, struct multipart *m,
const char *infile, const char *type,
- const char *argstring) {
+ const char *argstring)
+{
char *reply_file;
FILE *reply_fp = NULL;
char *convert, *type_p, *subtype_p;
/* Extract any Content-Type header from beginning of convert output. */
int
-extract_headers (CT ct, char *reply_file, FILE **reply_fp) {
+extract_headers (CT ct, char *reply_file, FILE **reply_fp)
+{
char *buffer = NULL, *cp, *end_of_header;
bool found_header = false;
struct stat statbuf;
int
-main (int argc, char **argv) {
+main (int argc, char **argv)
+{
int msgnum;
char *cp, *file = NULL, *folder = NULL;
char *maildir = NULL, buf[100], *outfile = NULL;
*/
static int
mhfixmsgsbr (CT *ctp, char *maildir, const fix_transformations *fx,
- FILE **infp, char *outfile, FILE **outfp) {
+ FILE **infp, char *outfile, FILE **outfp)
+{
/* Store input filename in case one of the transformations, i.e.,
fix_boundary(), rewrites to a tmp file. */
char *input_filename = maildir
*/
static int
copy_input_to_output (const char *input_filename, FILE *infp,
- const char *output_filename, FILE *outfp) {
+ const char *output_filename, FILE *outfp)
+{
int in = fileno (infp);
int out = fileno (outfp);
int status = OK;
* Fix mismatched outer level boundary.
*/
static int
-fix_boundary (CT *ct, int *message_mods) {
+fix_boundary (CT *ct, int *message_mods)
+{
struct multipart *mp;
int status = OK;
* Find boundary at end of multipart.
*/
static int
-get_multipart_boundary (CT ct, char **part_boundary) {
+get_multipart_boundary (CT ct, char **part_boundary)
+{
char buffer[NMH_BUFSIZ];
char *end_boundary = NULL;
off_t begin = (off_t) ct->c_end > (off_t) (ct->c_begin + sizeof buffer)
* Open and copy ct->c_file to file, replacing the multipart boundary.
*/
static int
-replace_boundary (CT ct, char *file, char *boundary) {
+replace_boundary (CT ct, char *file, char *boundary)
+{
FILE *fpin, *fpout;
int compnum, state;
char buf[NMH_BUFSIZ], name[NAMESZ];
* Fix Content-Type header to reflect the content of its part.
*/
static int
-fix_types (CT ct, svector_t fixtypes, int *message_mods) {
+fix_types (CT ct, svector_t fixtypes, int *message_mods)
+{
int status = OK;
switch (ct->c_type) {
* Replace a substring, allocating space to hold the new one.
*/
char *
-replace_substring (char **str, const char *old, const char *new) {
+replace_substring (char **str, const char *old, const char *new)
+{
char *cp;
if ((cp = strstr (*str, old))) {
* Remove a name=value parameter, given just its name, from a header value.
*/
char *
-remove_parameter (char *str, const char *name) {
+remove_parameter (char *str, const char *name)
+{
/* It looks to me, based on the BNF in RFC 2045, than there can't
be whitespace between the parameter name and the "=", or
between the "=" and the parameter value. */
* 8 bit.
*/
static int
-fix_composite_cte (CT ct, int *message_mods) {
+fix_composite_cte (CT ct, int *message_mods)
+{
int status = OK;
if (ct->c_type == CT_MESSAGE || ct->c_type == CT_MULTIPART) {
* Set content encoding.
*/
static int
-set_ce (CT ct, int encoding) {
+set_ce (CT ct, int encoding)
+{
const char *ce = ce_str (encoding);
const struct str2init *ctinit = get_ce_method (ce);
* Make sure each text part has a corresponding text/plain part.
*/
static int
-ensure_text_plain (CT *ct, CT parent, int *message_mods, int replacetextplain) {
+ensure_text_plain (CT *ct, CT parent, int *message_mods, int replacetextplain)
+{
int status = OK;
switch ((*ct)->c_type) {
*/
static int
find_textplain_sibling (CT parent, int replacetextplain,
- int *new_subpart_number) {
+ int *new_subpart_number)
+{
struct multipart *mp = (struct multipart *) parent->c_ctparams;
struct part *part, *prev;
bool has_text_plain = false;
* Insert a new text/plain part.
*/
static int
-insert_new_text_plain_part (CT ct, int new_subpart_number, CT parent) {
+insert_new_text_plain_part (CT ct, int new_subpart_number, CT parent)
+{
struct multipart *mp = (struct multipart *) parent->c_ctparams;
struct part *new_part;
* Create a text/plain part to go along with non-plain sibling part.
*/
static CT
-build_text_plain_part (CT encoded_part) {
+build_text_plain_part (CT encoded_part)
+{
CT tp_part = divide_part (encoded_part);
char *tmp_plain_file = NULL;
* Slip new text/plain part into a new multipart/alternative.
*/
static int
-insert_into_new_mp_alt (CT *ct, int *message_mods) {
+insert_into_new_mp_alt (CT *ct, int *message_mods)
+{
CT tp_part = build_text_plain_part (*ct);
int status = OK;
* Clone a MIME part.
*/
static CT
-divide_part (CT ct) {
+divide_part (CT ct)
+{
CT new_part;
NEW0(new_part);
* Copy the content info from one part to another.
*/
static void
-copy_ctinfo (CI dest, CI src) {
+copy_ctinfo (CI dest, CI src)
+{
PM s_pm, d_pm;
dest->ci_type = src->ci_type ? mh_xstrdup (src->ci_type) : NULL;
* Decode content.
*/
static int
-decode_part (CT ct) {
+decode_part (CT ct)
+{
char *tmp_decoded;
int status;
FILE *file;
* be in the future for other than text types.
*/
static int
-reformat_part (CT ct, char *file, char *type, char *subtype, int c_type) {
+reformat_part (CT ct, char *file, char *type, char *subtype, int c_type)
+{
int output_subtype, output_encoding;
const char *reason = NULL;
char *cp, *cf;
* Fill in a multipart/alternative part.
*/
static CT
-build_multipart_alt (CT first_alt, CT new_part, int type, int subtype) {
+build_multipart_alt (CT first_alt, CT new_part, int type, int subtype)
+{
char *boundary_prefix = "----=_nmh-multipart";
char *boundary = concat (boundary_prefix, first_alt->c_partno, NULL);
char *boundary_indicator = "; boundary=";
* Check that the boundary does not appear in the content.
*/
static int
-boundary_in_content (FILE **fp, char *file, const char *boundary) {
+boundary_in_content (FILE **fp, char *file, const char *boundary)
+{
char buffer[NMH_BUFSIZ];
size_t bytes_read;
bool found_boundary = false;
* Remove all non-Content headers.
*/
static void
-transfer_noncontent_headers (CT old, CT new) {
+transfer_noncontent_headers (CT old, CT new)
+{
HF hp, hp_prev;
hp_prev = hp = old->c_first_hf;
* Set content type.
*/
static int
-set_ct_type (CT ct, int type, int subtype, int encoding) {
+set_ct_type (CT ct, int type, int subtype, int encoding)
+{
char *typename = ct_type_str (type);
char *subtypename = ct_subtype_str (type, subtype);
/* E.g, " text/plain" */
*/
static int
decode_text_parts (CT ct, int encoding, const char *decodetypes,
- int *message_mods) {
+ int *message_mods)
+{
int status = OK;
int lf_line_endings = 0;
* decodetypes (which came from the -decodetypes switch).
*/
static int
-should_decode(const char *decodetypes, const char *type, const char *subtype) {
+should_decode(const char *decodetypes, const char *type, const char *subtype)
+{
/* Quick search for matching type[/subtype] in decodetypes: bracket
decodetypes with commas, then search for ,type, and ,type/subtype, in
it. */
* to a string explaining why.
*/
static int
-content_encoding (CT ct, const char **reason) {
+content_encoding (CT ct, const char **reason)
+{
CE ce = &ct->c_cefile;
int encoding = CE_7BIT;
* Strip carriage returns from content.
*/
static int
-strip_crs (CT ct, int *message_mods) {
+strip_crs (CT ct, int *message_mods)
+{
char *charset = content_charset (ct);
int status = OK;
* of the part C-T-E's.
*/
static void
-update_cte (CT ct) {
+update_cte (CT ct)
+{
const int least_restrictive_enc = least_restrictive_encoding (ct);
if (least_restrictive_enc != CE_UNKNOWN &&
* within a message.
*/
static int
-least_restrictive_encoding (CT ct) {
+least_restrictive_encoding (CT ct)
+{
int encoding = CE_UNKNOWN;
switch (ct->c_type) {
* CE_8BIT is less restrictive than CE_7BIT.
*/
static int
-less_restrictive (int encoding, int second_encoding) {
+less_restrictive (int encoding, int second_encoding)
+{
switch (second_encoding) {
case CE_BINARY:
return encoding != CE_BINARY;
* Convert character set of each part.
*/
static int
-convert_charsets (CT ct, char *dest_charset, int *message_mods) {
+convert_charsets (CT ct, char *dest_charset, int *message_mods)
+{
int status = OK;
switch (ct->c_type) {
* headers, respectively.
*/
static int
-fix_always (CT ct, int *message_mods) {
+fix_always (CT ct, int *message_mods)
+{
int status = OK;
switch (ct->c_type) {
* Factor out common code for loops in fix_filename_encoding().
*/
static int
-fix_filename_param (char *name, char *value, PM *first_pm, PM *last_pm) {
+fix_filename_param (char *name, char *value, PM *first_pm, PM *last_pm)
+{
bool fixed = false;
if (has_prefix(value, "=?") && has_suffix(value, "?=")) {
* headers, respectively.
*/
static int
-fix_filename_encoding (CT ct) {
+fix_filename_encoding (CT ct)
+{
PM pm;
HF hf;
int fixed = 0;
*/
static int
write_content (CT ct, const char *input_filename, char *outfile, FILE *outfp,
- int modify_inplace, int message_mods) {
+ int modify_inplace, int message_mods)
+{
int status = OK;
if (modify_inplace) {
* function to do it. It touches the parts the decodetypes identifies.
*/
static void
-set_text_ctparams(CT ct, char *decodetypes, int lf_line_endings) {
+set_text_ctparams(CT ct, char *decodetypes, int lf_line_endings)
+{
switch (ct->c_type) {
case CT_MULTIPART: {
struct multipart *m = (struct multipart *) ct->c_ctparams;
* use the standard MH backup file.
*/
static int
-remove_file (const char *file) {
+remove_file (const char *file)
+{
if (rmmproc) {
char *rmm_command = concat (rmmproc, " ", file, NULL);
int status = system (rmm_command);
* Output formatted message to user.
*/
static void
-report (char *what, char *partno, char *filename, char *message, ...) {
+report (char *what, char *partno, char *filename, char *message, ...)
+{
va_list args;
char *fmt;
int parser_status = 0;
int
-main (int argc, char *argv[]) {
+main (int argc, char *argv[])
+{
/* RFC 5322 § 3.3 date-time format, including the optional
day-of-week and not including the optional seconds. The
zone is required by the RFC but not always output by this
* - Excise VALARM sections.
*/
static void
-convert_to_reply (contentline *clines, act action) {
+convert_to_reply (contentline *clines, act action)
+{
char *partstat = NULL;
bool found_my_attendee_line = false;
contentline *node;
* - Excise VALARM sections.
*/
static void
-convert_to_cancellation (contentline *clines) {
+convert_to_cancellation (contentline *clines)
+{
contentline *node;
convert_common (clines, ACT_CANCEL);
}
static void
-convert_common (contentline *clines, act action) {
+convert_common (contentline *clines, act action)
+{
contentline *node;
bool in_valarm;
/* Echo the input, but with unfolded lines. */
static void
-dump_unfolded (FILE *file, contentline *clines) {
+dump_unfolded (FILE *file, contentline *clines)
+{
contentline *node;
for (node = clines; node; node = node->next) {
}
static void
-output (FILE *file, contentline *clines, int contenttype) {
+output (FILE *file, contentline *clines, int contenttype)
+{
contentline *node;
if (contenttype) {
* - attendees (limited to number specified in initialization)
*/
static void
-display (FILE *file, contentline *clines, char *nfs) {
+display (FILE *file, contentline *clines, char *nfs)
+{
tzdesc_t timezones = load_timezones (clines);
bool in_vtimezone;
bool in_valarm;
}
static const char *
-identity (const contentline *node) {
+identity (const contentline *node)
+{
/* According to RFC 5545 § 3.3.3, an email address in the value
must be a mailto URI. */
if (! strncasecmp (node->value, "mailto:", 7)) {
}
static char *
-format_params (char *line, param_list *p) {
+format_params (char *line, param_list *p)
+{
for ( ; p && p->param_name; p = p->next) {
value_list *v;
size_t num_values = 0;
}
static char *
-fold (char *line, int uses_cr) {
+fold (char *line, int uses_cr)
+{
size_t remaining = strlen (line);
size_t current_line_len = 0;
charstring_t folded_line = charstring_create (2 * remaining);
example, a text/plain part before a text/html part in a
multipart/alternative part, for example, where it belongs. */
void
-reverse_alternative_parts (CT ct) {
+reverse_alternative_parts (CT ct)
+{
if (ct->c_type == CT_MULTIPART) {
struct multipart *m = (struct multipart *) ct->c_ctparams;
struct part *part;
char *
-ct_type_str (int type) {
+ct_type_str (int type)
+{
switch (type) {
case CT_APPLICATION:
return "application";
char *
-ct_subtype_str (int type, int subtype) {
+ct_subtype_str (int type, int subtype)
+{
switch (type) {
case CT_APPLICATION:
switch (subtype) {
int
-ct_str_type (const char *type) {
+ct_str_type (const char *type)
+{
struct str2init *s2i;
for (s2i = str2cts; s2i->si_key; ++s2i) {
int
-ct_str_subtype (int type, const char *subtype) {
+ct_str_subtype (int type, const char *subtype)
+{
struct k2v *kv;
switch (type) {
/* Find the content type and InitFunc for the CT. */
const struct str2init *
-get_ct_init (int type) {
+get_ct_init (int type)
+{
const struct str2init *sp;
for (sp = str2cts; sp->si_key; ++sp) {
}
const char *
-ce_str (int encoding) {
+ce_str (int encoding)
+{
switch (encoding) {
case CE_BASE64:
return "base64";
/* Find the content type and InitFunc for the content encoding method. */
const struct str2init *
-get_ce_method (const char *method) {
+get_ce_method (const char *method)
+{
struct str2init *sp;
for (sp = str2ces; sp->si_key; ++sp) {
*/
char *
-content_charset (CT ct) {
+content_charset (CT ct)
+{
char *ret_charset = NULL;
ret_charset = get_param(ct->c_ctinfo.ci_first_pm, "charset", '?', 0);
static int
parse_display_string (CT ct, char *cp, int *xstdin, int *xlist,
char *file, char *buffer, size_t buflen,
- int multipart) {
+ int multipart)
+{
int len;
bool quoted = false;
char *bp = buffer, *pp;
int
-convert_charset (CT ct, char *dest_charset, int *message_mods) {
+convert_charset (CT ct, char *dest_charset, int *message_mods)
+{
char *src_charset = content_charset (ct);
int status = OK;
static int
-convert_content_charset (CT ct, char **file) {
+convert_content_charset (CT ct, char **file)
+{
int status = OK;
#ifdef HAVE_ICONV
static bool use_param_as_filename(const char *p);
mhstoreinfo_t
-mhstoreinfo_create (CT *ct, char *pwd, const char *csw, int asw, int vsw) {
+mhstoreinfo_create (CT *ct, char *pwd, const char *csw, int asw, int vsw)
+{
mhstoreinfo_t info;
NEW(info);
}
void
-mhstoreinfo_free (mhstoreinfo_t info) {
+mhstoreinfo_free (mhstoreinfo_t info)
+{
free (info->cwd);
free (info->dir);
free (info);
}
int
-mhstoreinfo_files_not_clobbered (const mhstoreinfo_t info) {
+mhstoreinfo_files_not_clobbered (const mhstoreinfo_t info)
+{
return info->files_not_clobbered;
}
static
enum clobber_policy_t
-clobber_policy (const char *value) {
+clobber_policy (const char *value)
+{
if (value == NULL || ! strcasecmp (value, "always")) {
return NMH_CLOBBER_ALWAYS;
}
static char *
-next_version (char *file, enum clobber_policy_t clobber_policy) {
+next_version (char *file, enum clobber_policy_t clobber_policy)
+{
const size_t max_versions = 1000000;
/* 8 = log max_versions + one for - or . + one for null terminator */
const size_t buflen = strlen (file) + 8;
static char *
-clobber_check (char *original_file, mhstoreinfo_t info) {
+clobber_check (char *original_file, mhstoreinfo_t info)
+{
/* clobber policy return value
* -------------- ------------
* -always original_file
*/
int
-main(int argc, char *argv[]) {
+main(int argc, char *argv[])
+{
const char *directory = "", *prefix = "", *suffix = "";
size_t suffix_len;
int fd;
static char *
-build_template(const char *directory, const char *prefix, const char *suffix) {
+build_template(const char *directory, const char *prefix, const char *suffix)
+{
const char pattern[] = "XXXXXX";
size_t len, directory_len, pathsep_len, prefix_len, suffix_len;
char *template;
static void
process_args(int argc, char **argv, const char **directory,
- const char **prefix, const char **suffix) {
+ const char **prefix, const char **suffix)
+{
char **argp, **arguments, *cp, buf[100];
# if ! HAVE_MKSTEMPS
NMH_UNUSED(suffix);
#else /* ! NMH */
static void
process_args(int argc, char **argv, const char **directory,
- const char **prefix, const char **suffix) {
+ const char **prefix, const char **suffix)
+{
# if HAVE_MKSTEMPS
const char usage[] =
"usage: %s [-h] [-d directory] [-p prefix] [-s suffix]\n";
*/
static void
add_convert_header (const char *convert_type, char *convert_arg,
- char *filename, char *drft) {
+ char *filename, char *drft)
+{
char *field_name;
field_name = concat (MHBUILD_FILE_PSEUDOHEADER, convert_type, NULL);
static
char *
-fix_addresses (char *str) {
+fix_addresses (char *str)
+{
char *fixed_str = NULL;
bool fixed_address = false;
/* The following two functions allow access to the global gstate above. */
void
-scan_finished(void) {
+scan_finished(void)
+{
m_getfld_state_destroy (&gstate);
}
void
-scan_detect_mbox_style (FILE *f) {
+scan_detect_mbox_style (FILE *f)
+{
m_unknown (&gstate, f);
}
static
void
-handle_sendfrom(char **vec, int *vecp, char *draft, const char *auth_svc) {
+handle_sendfrom(char **vec, int *vecp, char *draft, const char *auth_svc)
+{
const char *addr, *host;
const char *message;
*/
static int
setup_oauth_params(char *vec[], int *vecp, const char *auth_svc,
- const char **message) {
+ const char **message)
+{
const char *saslmech = NULL, *user = NULL;
mh_oauth_service_info svc;
char errbuf[256];
*/
static
int
-get_from_header_info(const char *filename, const char **addr, const char **host, const char **message) {
+get_from_header_info(const char *filename, const char **addr, const char **host, const char **message)
+{
struct stat st;
FILE *in;
*/
static
const char *
-get_message_header_info(FILE *in, char *format) {
+get_message_header_info(FILE *in, char *format)
+{
int dat[5];
struct format *fmt;
struct stat st;
*/
static
void
-merge_profile_entry(const char *addr, const char *host, char *vec[], int *vecp) {
+merge_profile_entry(const char *addr, const char *host, char *vec[], int *vecp)
+{
char *addr_entry = concat("sendfrom-", addr, NULL);
char *profile_entry = context_find(addr_entry);