projects
/
blerg.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add license notifications to all source files
[blerg.git]
/
database
/
tags.c
diff --git
a/database/tags.c
b/database/tags.c
index
dc51c4f
..
8386705
100644
(file)
--- a/
database/tags.c
+++ b/
database/tags.c
@@
-1,3
+1,6
@@
+/* Blerg is (C) 2011 The Dominion of Awesome, and is distributed under a
+ * BSD-style license. Please see the COPYING file for details.
+ */
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
@@
-8,6
+11,7
@@
#include <sys/file.h>
#include <sys/mman.h>
#include "tags.h"
#include <sys/file.h>
#include <sys/mman.h>
#include "tags.h"
+#include "util.h"
#include "config.h"
#define MAX_TAG_LENGTH 64
#include "config.h"
#define MAX_TAG_LENGTH 64
@@
-98,6
+102,9
@@
struct tag * tag_list(const char *tag, uint64_t offset, int *count, int directio
struct tag *taglist;
struct tag *retlist;
uint64_t n_tag_records;
struct tag *taglist;
struct tag *retlist;
uint64_t n_tag_records;
+
+ if (!valid_name(tag + 1))
+ return NULL;
switch(tag[0]) {
case '#':
switch(tag[0]) {
case '#':
@@
-108,7
+115,7
@@
struct tag * tag_list(const char *tag, uint64_t offset, int *count, int directio
break;
default:
fprintf(stderr, "Invalid tag type: %s\n", tag);
break;
default:
fprintf(stderr, "Invalid tag type: %s\n", tag);
- return
0
;
+ return
NULL
;
}
int tag_fd = open(filename, O_RDONLY, 0600);
}
int tag_fd = open(filename, O_RDONLY, 0600);
@@
-164,16
+171,11
@@
tag_list_open_failed:
}
int tag_exists(const char *tag) {
}
int tag_exists(const char *tag) {
- int taglen = strlen(tag);
char filename[512];
char filename[512];
- if (taglen < 2) {
- fprintf(stderr, "Tag too short\n");
+ if (!valid_name(tag + 1))
return 0;
return 0;
- } else if (taglen > 33) {
- fprintf(stderr, "Tag too long\n");
- return 0;
- }
+
if (!(tag[0] == '@' || tag[0] == '#')) {
fprintf(stderr, "Invalid tag: %s\n", tag);
return 0;
if (!(tag[0] == '@' || tag[0] == '#')) {
fprintf(stderr, "Invalid tag: %s\n", tag);
return 0;