From 48adae7cac47f09a5ac0ce7c3b53359b340a1110 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Orsini Date: Fri, 11 May 2012 13:26:39 +0000 Subject: [PATCH] only save useful att for bpph --- src/lp.c | 3 +++ src/lp.h | 1 + src/lp_json.c | 30 ++++++++++++++---------------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/lp.c b/src/lp.c index b8c24f1..9ba2eec 100644 --- a/src/lp.c +++ b/src/lp.c @@ -59,6 +59,7 @@ void bpph_free(struct bpph *b) free(b->binary_package_version); free(b->distro_arch_series_link); free(b->self_link); + free(b->status); free(b); } } @@ -78,6 +79,8 @@ struct bpph *bpph_new(const char *binary_package_name, h->distro_arch_series_link = strdup(distro_arch_series_link); h->self_link = strdup(self_link); h->architecture_specific = architecture_specific; + h->status = NULL; + h->date_created.tm_isdst = -1; return h; } diff --git a/src/lp.h b/src/lp.h index 5b2a1ed..11c6481 100644 --- a/src/lp.h +++ b/src/lp.h @@ -37,6 +37,7 @@ struct bpph { char *binary_package_version; char *distro_arch_series_link; char *self_link; + char *status; int architecture_specific; struct tm date_created; diff --git a/src/lp_json.c b/src/lp_json.c index a2b88f6..d88587a 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; + if (date_created) strptime(date_created, "%FT%T%z", &bpph->date_created); - } + + status = json_object_get_string(json_object_object_get(o, "status")); + if (status) + bpph->status = strdup(status); return bpph; } @@ -99,6 +100,9 @@ static json_object *bpph_to_json(struct bpph *bpph) "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, @@ -106,10 +110,7 @@ static json_object *bpph_to_json(struct bpph *bpph) &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 +156,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, -- 2.7.4