struct part **pp;
CT ct;
FILE *in;
+ HF hp;
umask(~m_gmprot());
/*
** Allocate space for primary (outside) content
*/
- if ((ct = (CT) calloc(1, sizeof(*ct))) == NULL)
- adios(EX_OSERR, NULL, "out of memory");
+ ct = (CT) mh_xcalloc(1, sizeof(*ct));
/*
** Allocate structure for handling decoded content
switch (state = m_getfld(state, name, buf, sizeof(buf), in)) {
case FLD:
case FLDPLUS:
- case FLDEOF:
compnum++;
/* abort if draft has Mime-Version header field */
while (state == FLDPLUS)
state = m_getfld(state, name, buf,
sizeof(buf), in);
- goto finish_field;
+ continue;
}
/* get copies of the buffers */
/* Now add the header data to the list */
add_header(ct, np, vp);
-finish_field:
- /* if this wasn't the last hdr field, then continue */
- if (state != FLDEOF)
- continue;
- /* else fall... */
+ continue;
case FILEEOF:
adios(EX_CONFIG, NULL, "draft has empty body -- no directives!");
/* NOTREACHED */
case BODY:
- case BODYEOF:
fseek(in, (long) (-strlen(buf)), SEEK_CUR);
break;
}
/*
+ ** Iterate through the list of headers and call the function to
+ ** MIME-ify them if required.
+ */
+ for (hp = ct->c_first_hf; hp != NULL; hp = hp->next) {
+ if (encode_rfc2047(hp->name, &hp->value, NULL)) {
+ adios(EX_DATAERR, NULL, "Unable to encode header \"%s\"", hp->name);
+ }
+ }
+
+ /*
** Now add the MIME-Version header field
** to the list of header fields.
*/
ct->c_subtype = MULTI_MIXED;
ct->c_file = getcpy(infile);
- if ((m = (struct multipart *) calloc(1, sizeof(*m))) == NULL)
- adios(EX_OSERR, NULL, "out of memory");
+ m = (struct multipart *) mh_xcalloc(1, sizeof(*m));
ct->c_ctparams = (void *) m;
pp = &m->mp_parts;
if (!p)
continue;
- if ((part = (struct part *) calloc(1, sizeof(*part))) == NULL)
- adios(EX_OSERR, NULL, "out of memory");
+ part = (struct part *) mh_xcalloc(1, sizeof(*part));
*pp = part;
pp = &part->mp_next;
part->mp_part = p;
{
CE ce;
- if ((ce = (CE) calloc(1, sizeof(*ce))) == NULL)
- adios(EX_OSERR, NULL, "out of memory");
+ ce = (CE) mh_xcalloc(1, sizeof(*ce));
ct->c_cefile = ce;
ct->c_ceopenfnx = open7Bit; /* since unencoded */
}
/* allocate basic Content structure */
- if ((ct = (CT) calloc(1, sizeof(*ct))) == NULL)
- adios(EX_OSERR, NULL, "out of memory");
+ ct = (CT) mh_xcalloc(1, sizeof(*ct));
*ctp = ct;
/* allocate basic structure for handling decoded content */
ct->c_type = CT_MULTIPART;
ct->c_subtype = MULTI_DIGEST;
- if ((m = (struct multipart *)
- calloc(1, sizeof(*m))) == NULL)
- adios(EX_OSERR, NULL, "out of memory");
+ m = (struct multipart *) mh_xcalloc(1, sizeof(*m));
ct->c_ctparams = (void *) m;
pp = &m->mp_parts;
CT p;
CE pe;
- if ((p = (CT) calloc(1, sizeof(*p)))
- == NULL)
- adios(EX_OSERR, NULL, "out of memory");
+ p = (CT) mh_xcalloc(1, sizeof(*p));
init_decoded_content(p);
pe = p->c_cefile;
if (get_ctinfo("message/rfc822", p, 0)
msgnum);
pe->ce_file = getcpy(buffer);
- if ((part = (struct part *) calloc(1, sizeof(*part))) == NULL)
- adios(EX_OSERR, NULL, "out of memory");
+ part = (struct part *) mh_xcalloc(1, sizeof(*part));
*pp = part;
pp = &part->mp_next;
part->mp_part = p;
ct->c_type = CT_MULTIPART;
ct->c_subtype = vrsn;
- if ((m = (struct multipart *) calloc(1, sizeof(*m))) == NULL)
- adios(EX_OSERR, NULL, "out of memory");
+ m = (struct multipart *) mh_xcalloc(1, sizeof(*m));
ct->c_ctparams = (void *) m;
pp = &m->mp_parts;
if (!p)
continue;
- if ((part = (struct part *)
- calloc(1, sizeof(*part))) == NULL)
- adios(EX_OSERR, NULL, "out of memory");
+ part = (struct part *) mh_xcalloc(1, sizeof(*part));
*pp = part;
pp = &part->mp_next;
part->mp_part = p;
if (ct->c_descr) {
np = getcpy(DESCR_FIELD);
vp = concat(" ", ct->c_descr, NULL);
+ if (encode_rfc2047(DESCR_FIELD, &vp, NULL)) {
+ adios(EX_DATAERR, NULL, "Unable to encode %s header", DESCR_FIELD);
+ }
add_header(ct, np, vp);
}