projects
/
blerg.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Some missing includes and a format error in blergtool
[blerg.git]
/
tools
/
blerglatest.c
diff --git
a/tools/blerglatest.c
b/tools/blerglatest.c
index
1fe133d
..
eaf887e
100644
(file)
--- a/
tools/blerglatest.c
+++ b/
tools/blerglatest.c
@@
-12,6
+12,7
@@
#include "database.h"
#include "json.h"
#include "config.h"
#include "database.h"
#include "json.h"
#include "config.h"
+#include "configuration.h"
yajl_gen_config yajl_config = {0, 0};
yajl_gen_config yajl_config = {0, 0};
@@
-82,6
+83,11
@@
struct things * latest_things(const char *path, const char *file, int minlen) {
int i;
d = opendir(path);
int i;
d = opendir(path);
+ if (d == NULL) {
+ fprintf(stderr, "Could not open %s: ", path);
+ perror("");
+ exit(1);
+ }
while (f = readdir(d)) {
if (f->d_name[0] == '.') continue;
if (minlen > 0 && strlen(f->d_name) < minlen) continue;
while (f = readdir(d)) {
if (f->d_name[0] == '.') continue;
if (minlen > 0 && strlen(f->d_name) < minlen) continue;
@@
-102,7
+108,7
@@
struct things * latest_things(const char *path, const char *file, int minlen) {
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, 3);
+ struct things * things = latest_things(
blergconf.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);
@@
-116,7
+122,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", 0);
+ struct things * things = latest_things(
blergconf.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);
@@
-139,6
+145,9
@@
int main(int argc, char *argv[]) {
const unsigned char *buf;
unsigned int len;
const unsigned char *buf;
unsigned int len;
+ if (!blerg_init())
+ exit(1);
+
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);