}
}
-LIST *mutt_parse_references (char *s, int in_reply_to)
+/* TODO: Make that a string list somehow */
+LIST *mutt_parse_references(char *s, int in_reply_to)
{
- LIST *t, *lst = NULL;
- int m, n = 0;
- char *o = NULL, *new, *at;
+ LIST *lst = NULL;
+ int n = 0;
+ char *o = NULL;
- while ((s = strtok (s, " \t;")) != NULL) {
- /*
- * some mail clients add other garbage besides message-ids, so do a quick
+ /* some mail clients add other garbage besides message-ids, so do a quick
* check to make sure this looks like a valid message-id
* some idiotic clients also break their message-ids between lines, deal
* with that too (give up if it's more than two lines, though)
*/
- t = NULL;
- new = NULL;
-
- if (*s == '<') {
- n = m_strlen(s);
- if (s[n - 1] != '>') {
- o = s;
- s = NULL;
- continue;
- }
- new = m_strdup(s);
- }
- else if (o) {
- m = m_strlen(s);
- if (s[m - 1] == '>') {
- new = p_new(char, n + m + 1);
- strcpy (new, o); /* __STRCPY_CHECKED__ */
- strcpy (new + n, s); /* __STRCPY_CHECKED__ */
- }
- }
- if (new) {
- /* make sure that this really does look like a message-id.
- * it should have exactly one @, and if we're looking at
- * an in-reply-to header, make sure that the part before
- * the @ has more than eight characters or it's probably
- * an email address
- */
- if (!(at = strchr (new, '@')) || strchr (at + 1, '@')
- || (in_reply_to && at - new <= 8))
- p_delete(&new);
- else {
- t = p_new(LIST, 1);
- t->data = new;
- t->next = lst;
- lst = t;
- }
+ for (s = strtok(s, " \t;"); s; s = strtok(NULL, " \t;")) {
+ char *new = NULL;
+
+ if (*s == '<') {
+ n = m_strlen(s);
+ if (s[n - 1] != '>') {
+ o = s;
+ continue;
+ }
+
+ new = m_strdup(s);
+ } else if (o) {
+ ssize_t m = m_strlen(s);
+
+ if (s[m - 1] != '>') {
+ o = NULL;
+ } else {
+ new = p_new(char, n + m + 1);
+ strcpy(new, o);
+ strcpy(new + n, s);
+ }
+ }
+
+ /* make sure that this really does look like a message-id.
+ * it should have exactly one @, and if we're looking at
+ * an in-reply-to header, make sure that the part before
+ * the @ has more than eight characters or it's probably
+ * an email address
+ */
+ if (new) {
+ char *at = strchr(new, '@');
+ LIST *tmp;
+
+ if (!at || strchr(at + 1, '@') || (in_reply_to && at - new <= 8)) {
+ p_delete(&new);
+ continue;
+ }
+
+ tmp = p_new(LIST, 1);
+ tmp->data = new;
+ tmp->next = lst;
+ lst = tmp;
+ }
}
- o = NULL;
- s = NULL;
- }
- return (lst);
+ return lst;
}
int mutt_check_encoding (const char *c)
CONTENT *mutt_get_content_info (const char *fname, BODY * b);
LIST *mutt_make_references (ENVELOPE * e);
-LIST *mutt_parse_references (char *, int);
ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short, short);
HEADER *mutt_dup_header (HEADER *);