projects
/
blerg.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add install routine (of sorts)
[blerg.git]
/
tools
/
blerglatest.c
diff --git
a/tools/blerglatest.c
b/tools/blerglatest.c
index
c0279af
..
94c1679
100644
(file)
--- a/
tools/blerglatest.c
+++ b/
tools/blerglatest.c
@@
-33,6
+33,7
@@
struct things * things_alloc() {
things->len = 0;
things->size = 65536;
things->arr = malloc(sizeof(struct thing) * things->size);
things->len = 0;
things->size = 65536;
things->arr = malloc(sizeof(struct thing) * things->size);
+ return things;
}
void things_free(struct things *things) {
}
void things_free(struct things *things) {
@@
-83,7
+84,12
@@
struct things * latest_things(const char *path, const char *file, int minlen) {
int i;
d = opendir(path);
int i;
d = opendir(path);
- while (f = readdir(d)) {
+ if (d == NULL) {
+ fprintf(stderr, "Could not open %s: ", path);
+ perror("");
+ exit(1);
+ }
+ while ((f = readdir(d)) != NULL) {
if (f->d_name[0] == '.') continue;
if (minlen > 0 && strlen(f->d_name) < minlen) continue;
if (file) {
if (f->d_name[0] == '.') continue;
if (minlen > 0 && strlen(f->d_name) < minlen) continue;
if (file) {
@@
-108,7
+114,7
@@
void latest_tags(yajl_gen g) {
unsigned int count = (things->len >= 50 ? 50 : things->len);
yajl_gen_array_open(g);
for (i = 0; i < count; i++) {
unsigned int count = (things->len >= 50 ? 50 : things->len);
yajl_gen_array_open(g);
for (i = 0; i < count; i++) {
- yajl_gen_string(g, things->arr[i].name, things->arr[i].len);
+ yajl_gen_string(g,
(unsigned char *)
things->arr[i].name, things->arr[i].len);
}
yajl_gen_array_close(g);
}
yajl_gen_array_close(g);
@@
-146,7
+152,7
@@
int main(int argc, char *argv[]) {
yajl_gen g = yajl_gen_alloc(&yajl_config, NULL);
yajl_gen_map_open(g);
yajl_gen g = yajl_gen_alloc(&yajl_config, NULL);
yajl_gen_map_open(g);
- yajl_gen_string(g, "tags", 4);
+ yajl_gen_string(g,
(unsigned char *)
"tags", 4);
latest_tags(g);
latest_tags(g);
@@
-154,7
+160,7
@@
int main(int argc, char *argv[]) {
fwrite(buf, len, 1, stdout);
yajl_gen_clear(g);
fwrite(buf, len, 1, stdout);
yajl_gen_clear(g);
- yajl_gen_string(g, "records", 7);
+ yajl_gen_string(g,
(unsigned char *)
"records", 7);
latest_records(g);
latest_records(g);