X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=common%2Fjson.c;fp=common%2Fjson.c;h=eebea2cfaca75df0e2de322b8acdf0c938546836;hb=7d8ef1902ef3030991b50a9414116a0615ac49d9;hp=5494e4a1825386e843351ed1176fc5c064eba26c;hpb=d07aee6282c303bba6ca9dbd0fa0ad3dfca58c5a;p=blerg.git diff --git a/common/json.c b/common/json.c index 5494e4a..eebea2c 100644 --- a/common/json.c +++ b/common/json.c @@ -8,7 +8,7 @@ #include "database.h" #include "json.h" -void json_generate_one_record(yajl_gen g, const char *author, struct blerg *b, uint64_t record) { +void json_generate_one_record(yajl_gen g, const char *author, struct blerg *b, uint64_t record, int brief) { char *data; char number[21]; int len; @@ -18,6 +18,16 @@ void json_generate_one_record(yajl_gen g, const char *author, struct blerg *b, u return; } + if (brief && len > 150) { + len = 150; + /* This is a bit of a hackish way to add an ellipsis, and will + * probably cause weird results if we overwrite part of a UTF-8 + * char */ + data[149] = '.'; + data[148] = '.'; + data[147] = '.'; + } + yajl_gen_map_open(g); if (author != NULL) { yajl_gen_string(g, "author", 6);