X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=common%2Fjson.c;h=eebea2cfaca75df0e2de322b8acdf0c938546836;hb=4d670f36be4aa9843fd429f545fe340cbb2e4d7f;hp=6b793ab7982903cb55f46c8c5fe514961725b3ce;hpb=ec27db46cef1c4643087fa2eeaad2ca72228bc06;p=blerg.git diff --git a/common/json.c b/common/json.c index 6b793ab..eebea2c 100644 --- a/common/json.c +++ b/common/json.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 #include #include @@ -5,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; @@ -15,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);