X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=cgi%2Fcgi_blerg.c;fp=cgi%2Fcgi_blerg.c;h=abf1237d22d6847ec2887c4d098cd30b4ff9d95a;hb=445d414dca855f352a798fbfd77ad998d938aed4;hp=373c353350f70b3c5306456ac6819b64159e356a;hpb=944c4c731e0a237824496e335f8086fbe038f248;p=blerg.git diff --git a/cgi/cgi_blerg.c b/cgi/cgi_blerg.c index 373c353..abf1237 100644 --- a/cgi/cgi_blerg.c +++ b/cgi/cgi_blerg.c @@ -10,6 +10,7 @@ #include "tags.h" #include "auth.h" #include "subscription.h" +#include "json.h" #include "canned_responses.h" #include "app.h" #include "config.h" @@ -259,17 +260,18 @@ int main(int argc, char *argv[]) { char number[21]; yajl_gen g = yajl_gen_alloc(&yajl_c, NULL); yajl_gen_map_open(g); - yajl_gen_string(g, "record_count", 12); + yajl_gen_string(g, (unsigned char *)"record_count", 12); snprintf(number, 21, "%llu", record_count); - yajl_gen_string(g, number, strlen(number)); + yajl_gen_string(g, (unsigned char *)number, strlen(number)); yajl_gen_map_close(g); const unsigned char *ybuf; - yajl_gen_get_buf(g, &ybuf, &len); + unsigned int content_len; + yajl_gen_get_buf(g, &ybuf, &content_len); printf("Content-type: application/json\r\n"); - printf("Content-length: %d\r\n\r\n", len); - fwrite(ybuf, len, 1, stdout); + printf("Content-length: %d\r\n\r\n", content_len); + fwrite(ybuf, content_len, 1, stdout); yajl_gen_free(g); } else if (strncmp(path, "/create", 8) == 0) { @@ -395,10 +397,10 @@ int main(int argc, char *argv[]) { uint64_t subscription_mark = blerg_get_subscription_mark(b); blerg_close(b); - yajl_gen_string(g, "new", 3); + yajl_gen_string(g, (unsigned char *)"new", 3); yajl_gen_integer(g, subscription_count_items(username) - subscription_mark); } else { - yajl_gen_string(g, "subscribed", 10); + yajl_gen_string(g, (unsigned char *)"subscribed", 10); ret = parse_url_info(path + 10, &info); if ((ret & URL_INFO_NAME) == 1) { yajl_gen_bool(g, is_subscribed(username, info.name)); @@ -409,11 +411,12 @@ int main(int argc, char *argv[]) { yajl_gen_map_close(g); const unsigned char *ybuf; - yajl_gen_get_buf(g, &ybuf, &len); + unsigned int content_len; + yajl_gen_get_buf(g, &ybuf, &content_len); printf("Content-type: application/json\r\n"); - printf("Content-length: %d\r\n\r\n", len); - fwrite(ybuf, len, 1, stdout); + printf("Content-length: %d\r\n\r\n", content_len); + fwrite(ybuf, content_len, 1, stdout); yajl_gen_free(g); } else if (strncmp(path, "/passwd", 7) == 0) {