Add some subscription (a.k.a. "follow") functionality
[blerg.git] / database / tags.c
index a28df02..d15f8b8 100644 (file)
 #include <sys/mman.h>
 #include "tags.h"
 #include "util.h"
+#include "database.h"
 #include "config.h"
 
-#define TAG_CHAR(c) ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '-' || c == '_')
-#define WHITESPACE(c) (c == ' ' || c == '\t' || c == '\n' || c == '\r')
 
 int tag_scan(const char *author, const char *data, int len, uint64_t record) {
        char *taglist[MAX_TAGS_PER_RECORD];
@@ -32,7 +31,7 @@ tag_scan_start:
                        }
                        int begin = i;
                        int start = ++i;
-                       while (i < len && TAG_CHAR(data[i]) && (i - start < MAX_TAG_LENGTH)) {
+                       while (i < len && VALID_CHAR(data[i]) && (i - start < MAX_TAG_LENGTH)) {
                                i++;
                        }
                        if (start - i == 0) continue;
@@ -105,7 +104,7 @@ struct tag * tag_list(const char *tag, uint64_t offset, int *count, int directio
        struct tag *retlist;
        uint64_t n_tag_records;
 
-       if (!valid_name(tag + 1))
+       if (!valid_tag_name(tag + 1))
                return NULL;
        
        switch(tag[0]) {
@@ -175,7 +174,7 @@ tag_list_open_failed:
 int tag_exists(const char *tag) {
        char filename[512];
 
-       if (!valid_name(tag + 1))
+       if (!valid_tag_name(tag + 1))
                return 0;
 
        if (!(tag[0] == '@' || tag[0] == '#')) {