X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=parse.c;h=ee8d70f84efe34e43d1c37670f0bf89634b872c0;hp=b8c322a24ecdfe60758b2ae1b19f9fc5bf21a369;hb=96d53ff49c308769efbf708e1e65819077cb7af6;hpb=df70e07e24add1869bcc9b7af2277d9d0c09a281 diff --git a/parse.c b/parse.c index b8c322a..ee8d70f 100644 --- a/parse.c +++ b/parse.c @@ -1,19 +1,10 @@ /* + * Copyright notice from original mutt: * Copyright (C) 1996-2000 Michael R. Elkins - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * + * This file is part of mutt-ng, see http://www.muttng.org/. + * It's licensed under the GNU General Public License, + * please see the file GPL in the top level source directory. */ #if HAVE_CONFIG_H @@ -21,14 +12,19 @@ #endif #include "mutt.h" -#include "mutt_regex.h" -#include "mailbox.h" +#include "mx.h" #include "mime.h" #include "rfc2047.h" #include "rfc2231.h" #include "mutt_crypt.h" #include "url.h" +#include "lib/mem.h" +#include "lib/intl.h" +#include "lib/str.h" +#include "lib/rx.h" +#include "lib/debug.h" + #include #include #include @@ -51,7 +47,7 @@ static char *read_rfc822_line (FILE * f, char *line, size_t * linelen) return (line); } - buf += strlen (buf) - 1; + buf += mutt_strlen (buf) - 1; if (*buf == '\n') { /* we did get a full line. remove trailing space */ while (ISSPACE (*buf)) @@ -100,7 +96,7 @@ LIST *mutt_parse_references (char *s, int in_reply_to) new = NULL; if (*s == '<') { - n = strlen (s); + n = mutt_strlen (s); if (s[n - 1] != '>') { o = s; s = NULL; @@ -110,7 +106,7 @@ LIST *mutt_parse_references (char *s, int in_reply_to) new = safe_strdup (s); } else if (o) { - m = strlen (s); + m = mutt_strlen (s); if (s[m - 1] == '>') { new = safe_malloc (sizeof (char) * (n + m + 1)); strcpy (new, o); /* __STRCPY_CHECKED__ */ @@ -173,12 +169,11 @@ static PARAMETER *parse_parameters (const char *s) const char *p; size_t i; - dprint (2, (debugfile, "parse_parameters: `%s'\n", s)); + debug_print (2, ("`%s'\n", s)); while (*s) { if ((p = strpbrk (s, "=;")) == NULL) { - dprint (1, - (debugfile, "parse_parameters: malformed parameter: %s\n", s)); + debug_print (1, ("malformed parameter: %s\n", s)); goto bail; } @@ -238,8 +233,7 @@ static PARAMETER *parse_parameters (const char *s) new->value = safe_strdup (buffer); - dprint (2, (debugfile, "parse_parameter: `%s' = `%s'\n", - new->attribute ? new->attribute : "", + debug_print (2, ("`%s' = `%s'\n", new->attribute ? new->attribute : "", new->value ? new->value : "")); /* Add this parameter to the list */ @@ -251,9 +245,7 @@ static PARAMETER *parse_parameters (const char *s) head = cur = new; } else { - dprint (1, - (debugfile, "parse_parameters(): parameter with no value: %s\n", - s)); + debug_print (1, ("parameter with no value: %s\n", s)); s = p; } @@ -402,7 +394,7 @@ static void parse_content_disposition (char *s, BODY * ct) if ((s = mutt_get_parameter ("filename", (parms = parse_parameters (s)))) != 0) - mutt_str_replace (&ct->filename, s); + str_replace (&ct->filename, s); if ((s = mutt_get_parameter ("name", parms)) != 0) ct->form_name = safe_strdup (s); mutt_free_parameter (&parms); @@ -436,16 +428,12 @@ BODY *mutt_read_mime_header (FILE * fp, int digest) c++; SKIPWS (c); if (!*c) { - dprint (1, - (debugfile, - "mutt_read_mime_header(): skipping empty header field: %s\n", - line)); + debug_print (1, ("skipping empty header field: %s\n", line)); continue; } } else { - dprint (1, - (debugfile, "read_mime_header: bogus MIME header: %s\n", line)); + debug_print (1, ("bogus MIME header: %s\n", line)); break; } @@ -457,7 +445,7 @@ BODY *mutt_read_mime_header (FILE * fp, int digest) else if (!ascii_strcasecmp ("disposition", line + 8)) parse_content_disposition (c, p); else if (!ascii_strcasecmp ("description", line + 8)) { - mutt_str_replace (&p->description, c); + str_replace (&p->description, c); rfc2047_decode (&p->description); } } @@ -470,7 +458,7 @@ BODY *mutt_read_mime_header (FILE * fp, int digest) else if (!ascii_strcasecmp ("content-lines", line + 6)) mutt_set_parameter ("content-lines", c, &(p->parameter)); else if (!ascii_strcasecmp ("data-description", line + 6)) { - mutt_str_replace (&p->description, c); + str_replace (&p->description, c); rfc2047_decode (&p->description); } } @@ -526,7 +514,7 @@ void mutt_parse_part (FILE * fp, BODY * b) /* try to recover from parsing error */ if (!b->parts) { b->type = TYPETEXT; - mutt_str_replace (&b->subtype, "plain"); + str_replace (&b->subtype, "plain"); } } @@ -601,7 +589,7 @@ BODY *mutt_parse_multipart (FILE * fp, const char *boundary, long end_off, crlf = (len > 1 && buffer[len - 2] == '\r') ? 1 : 0; if (buffer[0] == '-' && buffer[1] == '-' && - mutt_strncmp (buffer + 2, boundary, blen) == 0) { + safe_strncmp (buffer + 2, boundary, blen) == 0) { if (last) { last->length = ftell (fp) - last->offset - len - 1 - crlf; if (last->parts && last->parts->length == 0) @@ -841,9 +829,7 @@ time_t mutt_parse_date (const char *s, HEADER * h) else if (sscanf (t, "%d:%d", &hour, &min) == 2) sec = 0; else { - dprint (1, - (debugfile, "parse_date: could not process time format: %s\n", - t)); + debug_print (1, ("could not process time format: %s\n", t)); return (-1); } tm.tm_hour = hour; @@ -903,9 +889,7 @@ time_t mutt_parse_date (const char *s, HEADER * h) } if (count < 4) { /* don't check for missing timezone */ - dprint (1, - (debugfile, - "parse_date(): error parsing date format, using received time\n")); + debug_print (1, ("error parsing date format, using received time\n")); return (-1); } @@ -1009,7 +993,7 @@ int mutt_parse_rfc822_line (ENVELOPE * e, HEADER * hdr, char *line, char *p, } else if (ascii_strcasecmp (line + 8, "description") == 0) { if (hdr) { - mutt_str_replace (&hdr->content->description, p); + str_replace (&hdr->content->description, p); rfc2047_decode (&hdr->content->description); } matched = 1; @@ -1024,7 +1008,7 @@ int mutt_parse_rfc822_line (ENVELOPE * e, HEADER * hdr, char *line, char *p, case 'd': if (!ascii_strcasecmp ("ate", line + 1)) { - mutt_str_replace (&e->date, p); + str_replace (&e->date, p); if (hdr) hdr->date_sent = mutt_parse_date (p, hdr); matched = 1; @@ -1051,10 +1035,10 @@ int mutt_parse_rfc822_line (ENVELOPE * e, HEADER * hdr, char *line, char *p, matched = 1; } #ifdef USE_NNTP - else if (!mutt_strcasecmp (line + 1, "ollowup-to")) { + else if (!safe_strcasecmp (line + 1, "ollowup-to")) { if (!e->followup_to) { - mutt_remove_trailing_ws (p); - e->followup_to = safe_strdup (mutt_skip_whitespace (p)); + str_skip_trailws (p); + e->followup_to = safe_strdup (str_skip_initws (p)); } matched = 1; } @@ -1097,7 +1081,7 @@ int mutt_parse_rfc822_line (ENVELOPE * e, HEADER * hdr, char *line, char *p, /* Take the first mailto URL */ if (url_check_scheme (beg) == U_MAILTO) { FREE (&e->list_post); - e->list_post = mutt_substrdup (beg, end); + e->list_post = str_substrdup (beg, end); break; } } @@ -1134,10 +1118,10 @@ int mutt_parse_rfc822_line (ENVELOPE * e, HEADER * hdr, char *line, char *p, #ifdef USE_NNTP case 'n': - if (!mutt_strcasecmp (line + 1, "ewsgroups")) { + if (!safe_strcasecmp (line + 1, "ewsgroups")) { FREE (&e->newsgroups); - mutt_remove_trailing_ws (p); - e->newsgroups = safe_strdup (mutt_skip_whitespace (p)); + str_skip_trailws (p); + e->newsgroups = safe_strdup (str_skip_initws (p)); matched = 1; } break; @@ -1145,8 +1129,8 @@ int mutt_parse_rfc822_line (ENVELOPE * e, HEADER * hdr, char *line, char *p, case 'o': /* field `Organization:' saves only for pager! */ - if (!mutt_strcasecmp (line + 1, "rganization")) { - if (!e->organization && mutt_strcasecmp (p, "unknown")) + if (!safe_strcasecmp (line + 1, "rganization")) { + if (!e->organization && safe_strcasecmp (p, "unknown")) e->organization = safe_strdup (p); } break; @@ -1243,12 +1227,12 @@ int mutt_parse_rfc822_line (ENVELOPE * e, HEADER * hdr, char *line, char *p, matched = 1; } #ifdef USE_NNTP - else if (!mutt_strcasecmp (line + 1, "-comment-to")) { + else if (!safe_strcasecmp (line + 1, "-comment-to")) { if (!e->x_comment_to) e->x_comment_to = safe_strdup (p); matched = 1; } - else if (!mutt_strcasecmp (line + 1, "ref")) { + else if (!safe_strcasecmp (line + 1, "ref")) { if (!e->xref) e->xref = safe_strdup (p); matched = 1; @@ -1262,7 +1246,7 @@ int mutt_parse_rfc822_line (ENVELOPE * e, HEADER * hdr, char *line, char *p, /* Keep track of the user-defined headers */ if (!matched && user_hdrs) { /* restore the original line */ - line[strlen (line)] = ':'; + line[mutt_strlen (line)] = ':'; if (weed && option (OPTWEED) && mutt_matches_ignore (line, Ignore) && !mutt_matches_ignore (line, UnIgnore)) @@ -1340,7 +1324,7 @@ ENVELOPE *mutt_read_rfc822_header (FILE * f, HEADER * hdr, short user_hdrs, time_t t; /* some bogus MTAs will quote the original "From " line */ - if (mutt_strncmp (">From ", line, 6) == 0) + if (safe_strncmp (">From ", line, 6) == 0) continue; /* just ignore */ else if (is_from (line, return_path, sizeof (return_path), &t)) { /* MH somtimes has the From_ line in the middle of the header! */ @@ -1356,7 +1340,7 @@ ENVELOPE *mutt_read_rfc822_header (FILE * f, HEADER * hdr, short user_hdrs, *buf = '\0'; if (mutt_match_spam_list (line, SpamList, buf, sizeof (buf))) { - if (!mutt_match_rx_list (line, NoSpamList)) { + if (!rx_list_match (NoSpamList, line)) { /* if spam tag already exists, figure out how to amend it */ if (e->spam && *buf) { @@ -1385,7 +1369,7 @@ ENVELOPE *mutt_read_rfc822_header (FILE * f, HEADER * hdr, short user_hdrs, } if (e->spam && e->spam->data) - dprint (5, (debugfile, "p822: spam = %s\n", e->spam->data)); + debug_print (5, ("spam = %s\n", e->spam->data)); } } @@ -1429,9 +1413,7 @@ ENVELOPE *mutt_read_rfc822_header (FILE * f, HEADER * hdr, short user_hdrs, /* check for missing or invalid date */ if (hdr->date_sent <= 0) { - dprint (1, - (debugfile, - "read_rfc822_header(): no date found, using received time from msg separator\n")); + debug_print (1, ("no date found, using received time from msg separator\n")); hdr->date_sent = hdr->received; } }