projects
/
ppastats.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
normalize #include
[ppastats.git]
/
src
/
lp_json.c
diff --git
a/src/lp_json.c
b/src/lp_json.c
index
c3345fd
..
f050307
100644
(file)
--- a/
src/lp_json.c
+++ b/
src/lp_json.c
@@
-23,8
+23,9
@@
#include <string.h>
#include <time.h>
#include <string.h>
#include <time.h>
-#include "lp_json.h"
-#include "lp_ws.h"
+#include <lp_json.h>
+#include <lp_ws.h>
+#include <ptime.h>
static time_t json_to_time(json_object *json)
{
static time_t json_to_time(json_object *json)
{
@@
-47,16
+48,20
@@
static time_t json_to_time(json_object *json)
return -1;
}
return -1;
}
-
static
json_object *time_to_json(time_t t)
+json_object *time_to_json(time_t t)
{
char *str;
{
char *str;
+ json_object *j;
- str = time_to_
str(
t);
+ str = time_to_
ISO8601_time(&
t);
- if (str)
- return json_object_new_string(str);
- else
+ if (str) {
+ j = json_object_new_string(str);
+ free(str);
+ return j;
+ } else {
return NULL;
return NULL;
+ }
}
static struct bpph *json_to_bpph(json_object *o)
}
static struct bpph *json_to_bpph(json_object *o)
@@
-102,7
+107,7
@@
static struct bpph *json_to_bpph(json_object *o)
static json_object *bpph_to_json(struct bpph *bpph)
{
static json_object *bpph_to_json(struct bpph *bpph)
{
- json_object *json;
+ json_object *json
, *time
;
json = json_object_new_object();
json = json_object_new_object();
@@
-132,8
+137,9
@@
static json_object *bpph_to_json(struct bpph *bpph)
json_object_object_add
(json, "status", json_object_new_string(bpph->status));
json_object_object_add
(json, "status", json_object_new_string(bpph->status));
+ time = time_to_json(bpph->date_created);
json_object_object_add
json_object_object_add
- (json, "date_created", time
_to_json(bpph->date_created)
);
+ (json, "date_created", time);
return json;
}
return json;
}