projects
/
blerg.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add apache Authorization header hack
[blerg.git]
/
tools
/
blerglatest.c
diff --git
a/tools/blerglatest.c
b/tools/blerglatest.c
index
a2d1c67
..
1fe133d
100644
(file)
--- a/
tools/blerglatest.c
+++ b/
tools/blerglatest.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 <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@
-70,7
+73,7
@@
void things_sort(struct things *things) {
qsort(things->arr, things->len, sizeof(struct thing), thing_compare);
}
qsort(things->arr, things->len, sizeof(struct thing), thing_compare);
}
-struct things * latest_things(const char *path, const char *file) {
+struct things * latest_things(const char *path, const char *file
, int minlen
) {
DIR* d;
struct dirent *f;
struct things * things = things_alloc();
DIR* d;
struct dirent *f;
struct things * things = things_alloc();
@@
-81,6
+84,7
@@
struct things * latest_things(const char *path, const char *file) {
d = opendir(path);
while (f = readdir(d)) {
if (f->d_name[0] == '.') continue;
d = opendir(path);
while (f = readdir(d)) {
if (f->d_name[0] == '.') continue;
+ if (minlen > 0 && strlen(f->d_name) < minlen) continue;
if (file) {
snprintf(filename, 512, "%s/%s/%s", path, f->d_name, file);
} else {
if (file) {
snprintf(filename, 512, "%s/%s/%s", path, f->d_name, file);
} else {
@@
-98,7
+102,7
@@
struct things * latest_things(const char *path, const char *file) {
void latest_tags(yajl_gen g) {
int i;
void latest_tags(yajl_gen g) {
int i;
- struct things * things = latest_things(HASH_TAGS_PATH, NULL);
+ struct things * things = latest_things(HASH_TAGS_PATH, NULL
, 3
);
unsigned int count = (things->len >= 50 ? 50 : things->len);
yajl_gen_array_open(g);
unsigned int count = (things->len >= 50 ? 50 : things->len);
yajl_gen_array_open(g);
@@
-112,7
+116,7
@@
void latest_tags(yajl_gen g) {
void latest_records(yajl_gen g) {
int i;
void latest_records(yajl_gen g) {
int i;
- struct things * things = latest_things(DATA_PATH, "meta");
+ struct things * things = latest_things(DATA_PATH, "meta"
, 0
);
unsigned int count = (things->len >= 50 ? 50 : things->len);
yajl_gen_array_open(g);
unsigned int count = (things->len >= 50 ? 50 : things->len);
yajl_gen_array_open(g);
@@
-124,7
+128,7
@@
void latest_records(yajl_gen g) {
}
uint64_t record_count = blerg_get_record_count(b);
if (record_count > 0)
}
uint64_t record_count = blerg_get_record_count(b);
if (record_count > 0)
- json_generate_one_record(g, things->arr[i].name, b, record_count - 1);
+ json_generate_one_record(g, things->arr[i].name, b, record_count - 1
, 1
);
blerg_close(b);
}
yajl_gen_array_close(g);
blerg_close(b);
}
yajl_gen_array_close(g);