X-Git-Url: http://git.wpitchoune.net/gitweb/?p=ppastats.git;a=blobdiff_plain;f=src%2Flp_json.c;h=e217180062a6ba4a20c393f054b3d574660027a4;hp=a2b88f6a25cdc68cadf78ef5e0c57a474e9b05bc;hb=cbe5f873c5f0306a7a5d2f431992dbbb6edbe332;hpb=60892f2ef45fa1ee656e1a00cac0578f9d6f9536 diff --git a/src/lp_json.c b/src/lp_json.c index a2b88f6..e217180 100644 --- a/src/lp_json.c +++ b/src/lp_json.c @@ -16,10 +16,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA */ - +#define _XOPEN_SOURCE_EXTENDED #define _XOPEN_SOURCE -#include - #include #include #include @@ -37,6 +35,7 @@ static struct bpph *json_to_bpph(json_object *o) int architecture_specific; const char *date_created; struct bpph *bpph; + const char *status; binary_package_name = json_object_get_string (json_object_object_get(o, "binary_package_name")); @@ -64,10 +63,12 @@ static struct bpph *json_to_bpph(json_object *o) date_created = json_object_get_string (json_object_object_get(o, "date_created")); - if (date_created) { - bpph->date_created.tm_isdst = -1; - strptime(date_created, "%FT%T%z", &bpph->date_created); - } + if (date_created) + strptime(date_created, "%FT%T", &bpph->date_created); + + status = json_object_get_string(json_object_object_get(o, "status")); + if (status) + bpph->status = strdup(status); return bpph; } @@ -96,20 +97,25 @@ static json_object *bpph_to_json(struct bpph *bpph) json_object_object_add (json, + "self_link", + json_object_new_string(bpph->self_link)); + + json_object_object_add + (json, "architecture_specific", json_object_new_boolean(bpph->architecture_specific)); + json_object_object_add + (json, "status", json_object_new_string(bpph->status)); + date = malloc(strlen("YY-MM-DDThh:mm:ss+xxx") + 1); strftime(date, strlen("YY-MM-DDThh:mm:ss+xxx") + 1, - "%FT%T%z", + "%FT%T", &bpph->date_created); json_object_object_add - (json, - "date_created", - json_object_new_string(date)); - + (json, "date_created", json_object_new_string(date)); free(date); return json; @@ -155,14 +161,11 @@ struct distro_series *json_object_to_distro_series(json_object *o) displayname = json_object_get_string (json_object_object_get(o, "displayname")); - title = json_object_get_string - (json_object_object_get(o, "title")); + title = json_object_get_string(json_object_object_get(o, "title")); - version = json_object_get_string - (json_object_object_get(o, "version")); + version = json_object_get_string(json_object_object_get(o, "version")); - name = json_object_get_string - (json_object_object_get(o, "name")); + name = json_object_get_string(json_object_object_get(o, "name")); return distro_series_new(name, version, @@ -219,8 +222,9 @@ json_object *bpph_list_to_json(struct bpph **list) entries = json_object_new_array(); json_object_object_add(result, "entries", entries); - for (cur = list; *cur; cur++) - json_object_array_add(entries, bpph_to_json(*cur)); + if (list) + for (cur = list; *cur; cur++) + json_object_array_add(entries, bpph_to_json(*cur)); return result; }