return false;
hdr = mutt_header_new();
- tmp_envelope = mutt_rfc822_read_header(f, hdr, 0, 0);
+ tmp_envelope = mutt_rfc822_read_header(f, hdr, false, false);
if (!(hdr->read || hdr->old))
result = true;
* and the information put in the Envelope or Header.
*/
int mutt_rfc822_parse_line(struct Envelope *e, struct Header *hdr, char *line,
- char *p, short user_hdrs, short weed, short do_2047)
+ char *p, bool user_hdrs, bool weed, bool do_2047)
{
- int matched = 0;
+ bool matched = false;
switch (tolower(line[0]))
{
if (mutt_str_strcasecmp(line + 1, "pparently-to") == 0)
{
e->to = mutt_addr_parse_list(e->to, p);
- matched = 1;
+ matched = true;
}
else if (mutt_str_strcasecmp(line + 1, "pparently-from") == 0)
{
e->from = mutt_addr_parse_list(e->from, p);
- matched = 1;
+ matched = true;
}
break;
if (mutt_str_strcasecmp(line + 1, "cc") == 0)
{
e->bcc = mutt_addr_parse_list(e->bcc, p);
- matched = 1;
+ matched = true;
}
break;
if (mutt_str_strcasecmp(line + 1, "c") == 0)
{
e->cc = mutt_addr_parse_list(e->cc, p);
- matched = 1;
+ matched = true;
}
else if (mutt_str_strncasecmp(line + 1, "ontent-", 7) == 0)
{
{
if (hdr)
mutt_parse_content_type(p, hdr->content);
- matched = 1;
+ matched = true;
}
else if (mutt_str_strcasecmp(line + 8, "language") == 0)
{
if (hdr)
parse_content_language(p, hdr->content);
- matched = 1;
+ matched = true;
}
else if (mutt_str_strcasecmp(line + 8, "transfer-encoding") == 0)
{
if (hdr)
hdr->content->encoding = mutt_check_encoding(p);
- matched = 1;
+ matched = true;
}
else if (mutt_str_strcasecmp(line + 8, "length") == 0)
{
if (hdr->content->length < 0)
hdr->content->length = -1;
}
- matched = 1;
+ matched = true;
}
else if (mutt_str_strcasecmp(line + 8, "description") == 0)
{
mutt_str_replace(&hdr->content->description, p);
rfc2047_decode(&hdr->content->description);
}
- matched = 1;
+ matched = true;
}
else if (mutt_str_strcasecmp(line + 8, "disposition") == 0)
{
if (hdr)
parse_content_disposition(p, hdr->content);
- matched = 1;
+ matched = true;
}
}
break;
hdr->zoccident = tz.zoccident;
}
}
- matched = 1;
+ matched = true;
}
break;
if (mutt_str_strcasecmp("rom", line + 1) == 0)
{
e->from = mutt_addr_parse_list(e->from, p);
- matched = 1;
+ matched = true;
}
#ifdef USE_NNTP
else if (mutt_str_strcasecmp(line + 1, "ollowup-to") == 0)
mutt_str_remove_trailing_ws(p);
e->followup_to = mutt_str_strdup(mutt_str_skip_whitespace(p));
}
- matched = 1;
+ matched = true;
}
#endif
break;
{
mutt_list_free(&e->in_reply_to);
parse_references(&e->in_reply_to, p);
- matched = 1;
+ matched = true;
}
break;
hdr->lines = 0;
}
- matched = 1;
+ matched = true;
}
else if (mutt_str_strcasecmp(line + 1, "ist-Post") == 0)
{
}
}
}
- matched = 1;
+ matched = true;
}
break;
{
if (hdr)
hdr->mime = true;
- matched = 1;
+ matched = true;
}
else if (mutt_str_strcasecmp(line + 1, "essage-id") == 0)
{
/* We add a new "Message-ID:" when building a message */
FREE(&e->message_id);
e->message_id = mutt_extract_message_id(p, NULL);
- matched = 1;
+ matched = true;
}
else if (mutt_str_strncasecmp(line + 1, "ail-", 4) == 0)
{
/* override the Reply-To: field */
mutt_addr_free(&e->reply_to);
e->reply_to = mutt_addr_parse_list(e->reply_to, p);
- matched = 1;
+ matched = true;
}
else if (mutt_str_strcasecmp(line + 5, "followup-to") == 0)
{
e->mail_followup_to = mutt_addr_parse_list(e->mail_followup_to, p);
- matched = 1;
+ matched = true;
}
}
break;
FREE(&e->newsgroups);
mutt_str_remove_trailing_ws(p);
e->newsgroups = mutt_str_strdup(mutt_str_skip_whitespace(p));
- matched = 1;
+ matched = true;
}
break;
#endif
{
mutt_list_free(&e->references);
parse_references(&e->references, p);
- matched = 1;
+ matched = true;
}
else if (mutt_str_strcasecmp(line + 1, "eply-to") == 0)
{
e->reply_to = mutt_addr_parse_list(e->reply_to, p);
- matched = 1;
+ matched = true;
}
else if (mutt_str_strcasecmp(line + 1, "eturn-path") == 0)
{
e->return_path = mutt_addr_parse_list(e->return_path, p);
- matched = 1;
+ matched = true;
}
else if (mutt_str_strcasecmp(line + 1, "eceived") == 0)
{
{
if (!e->subject)
e->subject = mutt_str_strdup(p);
- matched = 1;
+ matched = true;
}
else if (mutt_str_strcasecmp(line + 1, "ender") == 0)
{
e->sender = mutt_addr_parse_list(e->sender, p);
- matched = 1;
+ matched = true;
}
else if (mutt_str_strcasecmp(line + 1, "tatus") == 0)
{
p++;
}
}
- matched = 1;
+ matched = true;
}
else if (((mutt_str_strcasecmp("upersedes", line + 1) == 0) ||
(mutt_str_strcasecmp("upercedes", line + 1) == 0)) &&
if (mutt_str_strcasecmp(line + 1, "o") == 0)
{
e->to = mutt_addr_parse_list(e->to, p);
- matched = 1;
+ matched = true;
}
break;
p++;
}
}
- matched = 1;
+ matched = true;
}
else if (mutt_str_strcasecmp(line + 1, "-label") == 0)
{
FREE(&e->x_label);
e->x_label = mutt_str_strdup(p);
- matched = 1;
+ matched = true;
}
#ifdef USE_NNTP
else if (mutt_str_strcasecmp(line + 1, "-comment-to") == 0)
{
if (!e->x_comment_to)
e->x_comment_to = mutt_str_strdup(p);
- matched = 1;
+ matched = true;
}
else if (mutt_str_strcasecmp(line + 1, "ref") == 0)
{
if (!e->xref)
e->xref = mutt_str_strdup(p);
- matched = 1;
+ matched = true;
}
#endif
else if (mutt_str_strcasecmp(line + 1, "-original-to") == 0)
{
e->x_original_to = mutt_addr_parse_list(e->x_original_to, p);
- matched = 1;
+ matched = true;
}
default:
* Caller should free the Envelope using mutt_env_free().
*/
struct Envelope *mutt_rfc822_read_header(FILE *f, struct Header *hdr,
- short user_hdrs, short weed)
+ bool user_hdrs, bool weed)
{
struct Envelope *e = mutt_env_new();
char *line = mutt_mem_malloc(LONG_STRING);
if (!*p)
continue; /* skip empty header fields */
- mutt_rfc822_parse_line(e, hdr, line, p, user_hdrs, weed, 1);
+ mutt_rfc822_parse_line(e, hdr, line, p, user_hdrs, weed, true);
}
FREE(&line);
{
parent->hdr = mutt_header_new();
parent->hdr->offset = ftello(fp);
- parent->hdr->env = mutt_rfc822_read_header(fp, parent->hdr, 0, 0);
+ parent->hdr->env = mutt_rfc822_read_header(fp, parent->hdr, false, false);
struct Body *msg = parent->hdr->content;
/* ignore the length given in the content-length since it could be wrong
struct Body * mutt_parse_multipart(FILE *fp, const char *boundary, LOFF_T end_off, bool digest);
void mutt_parse_part(FILE *fp, struct Body *b);
struct Body * mutt_read_mime_header(FILE *fp, bool digest);
-int mutt_rfc822_parse_line(struct Envelope *e, struct Header *hdr, char *line, char *p, short user_hdrs, short weed, short do_2047);
+int mutt_rfc822_parse_line(struct Envelope *e, struct Header *hdr, char *line, char *p, bool user_hdrs, bool weed, bool do_2047);
struct Body * mutt_rfc822_parse_message(FILE *fp, struct Body *parent);
-struct Envelope *mutt_rfc822_read_header(FILE *f, struct Header *hdr, short user_hdrs, short weed);
+struct Envelope *mutt_rfc822_read_header(FILE *f, struct Header *hdr, bool user_hdrs, bool weed);
char * mutt_rfc822_read_line(FILE *f, char *line, size_t *linelen);
#endif /* _EMAIL_PARSE_H */
*/
int rfc2231_encode_string(char **pd)
{
- int ext = 0, encode = 0;
+ int ext = 0;
+ bool encode = false;
char *charset = NULL, *s = NULL, *t = NULL, *e = NULL, *d = NULL;
size_t slen, dlen = 0;
}
if (!mutt_ch_is_us_ascii(charset))
- encode = 1;
+ encode = true;
for (s = d, slen = dlen; slen; s++, slen--)
{
if ((*s < 0x20) || (*s >= 0x7f))
{
- encode = 1;
+ encode = true;
ext++;
}
else if (strchr(MimeSpecials, *s) || strchr("*'%", *s))
rewind(fp);
/* NOTE: if Date: header is missing, mutt_rfc822_read_header depends
* on h.received being set */
- ctx->hdrs[idx]->env = mutt_rfc822_read_header(fp, ctx->hdrs[idx], 0, 0);
+ ctx->hdrs[idx]->env = mutt_rfc822_read_header(fp, ctx->hdrs[idx], false, false);
/* content built as a side-effect of mutt_rfc822_read_header */
ctx->hdrs[idx]->content->length = h.content_length;
ctx->size += h.content_length;
* picked up in mutt_rfc822_read_header, we mark the message (and context
* changed). Another possibility: ignore Status on IMAP? */
read = h->read;
- newenv = mutt_rfc822_read_header(msg->fp, h, 0, 0);
+ newenv = mutt_rfc822_read_header(msg->fp, h, false, false);
mutt_env_merge(h->env, &newenv);
/* see above. We want the new status in h->read, so we unset it manually
if (!h)
h = mutt_header_new();
- h->env = mutt_rfc822_read_header(f, h, 0, 0);
+ h->env = mutt_rfc822_read_header(f, h, false, false);
fstat(fileno(f), &st);
}
context_hdr->content->length = st.st_size;
- if (mutt_prepare_template(fin, NULL, msg, context_hdr, 0) < 0)
+ if (mutt_prepare_template(fin, NULL, msg, context_hdr, false) < 0)
{
mutt_error(_("Cannot parse message template: %s"), draft_file);
mutt_env_free(&opts_env);
else
hdr->received = t - mutt_date_local_tz(t);
- hdr->env = mutt_rfc822_read_header(ctx->fp, hdr, 0, 0);
+ hdr->env = mutt_rfc822_read_header(ctx->fp, hdr, false, false);
loc = ftello(ctx->fp);
if (loc < 0)
curhdr->offset = loc;
curhdr->index = ctx->msgcount;
- curhdr->env = mutt_rfc822_read_header(ctx->fp, curhdr, 0, 0);
+ curhdr->env = mutt_rfc822_read_header(ctx->fp, curhdr, false, false);
/* if we know how long this message is, either just skip over the body,
* or if we don't know how many lines there are, count them now (this will
return;
}
- n = mutt_rfc822_read_header(ifp, NULL, 1, 0);
+ n = mutt_rfc822_read_header(ifp, NULL, true, false);
while ((i = fread(buffer, 1, sizeof(buffer), ifp)) > 0)
fwrite(buffer, 1, i, ofp);
mutt_file_fclose(&ofp);
safe_asprintf(&scratch, "%s: %s", tag, value);
scratch[taglen] = 0; /* overwrite the colon as mutt_rfc822_parse_line expects */
value = mutt_str_skip_email_wsp(&scratch[taglen + 1]);
- mutt_rfc822_parse_line(e, NULL, scratch, value, 1, 0, 1);
+ mutt_rfc822_parse_line(e, NULL, scratch, value, true, false, true);
FREE(&scratch);
}
}
/* parse header */
hdr = ctx->hdrs[ctx->msgcount] = mutt_header_new();
- hdr->env = mutt_rfc822_read_header(fp, hdr, 0, 0);
+ hdr->env = mutt_rfc822_read_header(fp, hdr, false, false);
hdr->env->newsgroups = mutt_str_strdup(nntp_data->group);
hdr->received = hdr->date_sent;
mutt_file_fclose(&fp);
/* parse header */
hdr = ctx->hdrs[ctx->msgcount] = mutt_header_new();
- hdr->env = mutt_rfc822_read_header(fp, hdr, 0, 0);
+ hdr->env = mutt_rfc822_read_header(fp, hdr, false, false);
hdr->received = hdr->date_sent;
mutt_file_fclose(&fp);
}
mutt_hash_delete(ctx->subj_hash, hdr->env->real_subj, hdr);
mutt_env_free(&hdr->env);
- hdr->env = mutt_rfc822_read_header(msg->fp, hdr, 0, 0);
+ hdr->env = mutt_rfc822_read_header(msg->fp, hdr, false, false);
if (ctx->id_hash && hdr->env->message_id)
mutt_hash_insert(ctx->id_hash, hdr->env->message_id, hdr);
mx_alloc_memory(ctx);
struct Header *hdr = ctx->hdrs[ctx->msgcount] = mutt_header_new();
hdr->data = mutt_mem_calloc(1, sizeof(struct NntpHeaderData));
- hdr->env = mutt_rfc822_read_header(fp, hdr, 0, 0);
+ hdr->env = mutt_rfc822_read_header(fp, hdr, false, false);
mutt_file_fclose(&fp);
/* get article number */
case 0:
{
rewind(f);
- h->env = mutt_rfc822_read_header(f, h, 0, 0);
+ h->env = mutt_rfc822_read_header(f, h, false, false);
h->content->length = length - h->content->offset + 1;
rewind(f);
while (!feof(f))
mutt_hash_delete(ctx->subj_hash, h->env->real_subj, h);
mutt_label_hash_remove(ctx, h);
mutt_env_free(&h->env);
- h->env = mutt_rfc822_read_header(msg->fp, h, 0, 0);
+ h->env = mutt_rfc822_read_header(msg->fp, h, false, false);
if (ctx->subj_hash && h->env->real_subj)
mutt_hash_insert(ctx->subj_hash, h->env->real_subj, h);
mutt_label_hash_add(ctx, h);
return -1;
}
- if (mutt_prepare_template(NULL, PostContext, hdr, h, 0) < 0)
+ if (mutt_prepare_template(NULL, PostContext, hdr, h, false) < 0)
{
mx_fastclose_mailbox(PostContext);
FREE(&PostContext);
* @retval -1 Error
*/
int mutt_prepare_template(FILE *fp, struct Context *ctx, struct Header *newhdr,
- struct Header *hdr, short resend)
+ struct Header *hdr, bool resend)
{
struct Message *msg = NULL;
char file[PATH_MAX];
fseeko(fp, hdr->offset, SEEK_SET);
newhdr->offset = hdr->offset;
/* enable header weeding for resent messages */
- newhdr->env = mutt_rfc822_read_header(fp, newhdr, 1, resend);
+ newhdr->env = mutt_rfc822_read_header(fp, newhdr, true, resend);
newhdr->content->length = hdr->content->length;
mutt_parse_part(fp, newhdr->content);
int mutt_complete(char *buf, size_t buflen);
int mutt_edit_message(struct Context *ctx, struct Header *hdr);
int mutt_view_message(struct Context *ctx, struct Header *hdr);
-int mutt_prepare_template(FILE *fp, struct Context *ctx, struct Header *newhdr, struct Header *hdr, short resend);
+int mutt_prepare_template(FILE *fp, struct Context *ctx, struct Header *newhdr, struct Header *hdr, bool resend);
int mutt_enter_string(char *buf, size_t buflen, int col, int flags);
int mutt_enter_string_full(char *buf, size_t buflen, int col, int flags, int multiple,
char ***files, int *numfiles, struct EnterState *state);
{
struct Header *msg = mutt_header_new();
- if (mutt_prepare_template(fp, ctx, msg, cur, 1) < 0)
+ if (mutt_prepare_template(fp, ctx, msg, cur, true) < 0)
{
mutt_header_free(&msg);
return -1;
body->hdr = mutt_header_new();
body->hdr->offset = 0;
/* we don't need the user headers here */
- body->hdr->env = mutt_rfc822_read_header(fp, body->hdr, 0, 0);
+ body->hdr->env = mutt_rfc822_read_header(fp, body->hdr, false, false);
if (WithCrypto)
body->hdr->security = pgp;
mutt_update_encoding(body);