]> git.notmuchmail.org Git - notmuch/blobdiff - lib/message-id.c
emacs: Add new option notmuch-search-hide-excluded
[notmuch] / lib / message-id.c
index d7541d50102d671ca6fd465ff047ceb4c220753a..540123548248010eb329c96fa34b3db1e94ae477 100644 (file)
@@ -1,4 +1,5 @@
 #include "notmuch-private.h"
+#include "string-util.h"
 
 /* Advance 'str' past any whitespace or RFC 822 comments. A comment is
  * a (potentially nested) parenthesized sequence with '\' used to
@@ -26,7 +27,7 @@ skip_space_and_comments (const char **str)
                } else if (*s == ')') {
                    nesting--;
                } else if (*s == '\\') {
-                   if (*(s+1))
+                   if (*(s + 1))
                        s++;
                }
                s++;
@@ -89,8 +90,37 @@ _notmuch_message_id_parse (void *ctx, const char *message_id, const char **next)
 
        for (r = result, len = strlen (r); *r; r++, len--)
            if (*r == ' ' || *r == '\t')
-               memmove (r, r+1, len);
+               memmove (r, r + 1, len);
     }
 
     return result;
 }
+
+char *
+_notmuch_message_id_parse_strict (void *ctx, const char *message_id)
+{
+    const char *s, *end;
+
+    if (message_id == NULL || *message_id == '\0')
+       return NULL;
+
+    s = skip_space (message_id);
+    if (*s == '<')
+       s++;
+    else
+       return NULL;
+
+    for (end = s; *end && *end != '>'; end++)
+       if (isspace (*end))
+           return NULL;
+
+    if (*end != '>')
+       return NULL;
+    else {
+       const char *last = skip_space (end + 1);
+       if (*last != '\0')
+           return NULL;
+    }
+
+    return talloc_strndup (ctx, s, end - s);
+}