1 #include "notmuch-private.h"
3 /* Advance 'str' past any whitespace or RFC 822 comments. A comment is
4 * a (potentially nested) parenthesized sequence with '\' used to
5 * escape any character (including parentheses).
7 * If the sequence to be skipped continues to the end of the string,
8 * then 'str' will be left pointing at the final terminating '\0'
12 skip_space_and_comments (const char **str)
17 while (*s && (isspace (*s) || *s == '(')) {
18 while (*s && isspace (*s))
23 while (*s && nesting) {
26 } else if (*s == ')') {
28 } else if (*s == '\\') {
41 _notmuch_message_id_parse (void *ctx, const char *message_id, const char **next)
46 if (message_id == NULL || *message_id == '\0')
51 skip_space_and_comments (&s);
53 /* Skip any unstructured text as well. */
54 while (*s && *s != '<')
65 skip_space_and_comments (&s);
68 while (*end && *end != '>')
77 if (end > s && *end == '>')
82 result = talloc_strndup (ctx, s, end - s + 1);
84 /* Finally, collapse any whitespace that is within the message-id
90 for (r = result, len = strlen (r); *r; r++, len--)
91 if (*r == ' ' || *r == '\t')
92 memmove (r, r+1, len);