2 Copyright (C) 2011 jeanfi@gmail.com
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
29 struct binary_package_publishing_history *
30 json_object_to_binary_package_publishing_history(json_object *o)
32 const char *binary_package_name;
33 const char *binary_package_version;
34 const char *distro_arch_series_link;
35 const char *self_link;
37 binary_package_name = json_object_get_string
38 (json_object_object_get(o, "binary_package_name"));
40 binary_package_version = json_object_get_string
41 (json_object_object_get(o, "binary_package_version"));
43 distro_arch_series_link = json_object_get_string
44 (json_object_object_get(o, "distro_arch_series_link"));
46 self_link = json_object_get_string
47 (json_object_object_get(o, "self_link"));
49 return binary_package_publishing_history_new(binary_package_name,
50 binary_package_version,
51 distro_arch_series_link,
55 struct distro_arch_series *json_object_to_distro_arch_series(json_object *o)
57 const char *display_name;
59 const char *architecture_tag;
61 display_name = json_object_get_string
62 (json_object_object_get(o, "display_name"));
64 title = json_object_get_string
65 (json_object_object_get(o, "title"));
67 architecture_tag = json_object_get_string
68 (json_object_object_get(o, "architecture_tag"));
70 return distro_arch_series_new(display_name,
75 struct binary_package_publishing_history * *
76 json_object_to_binary_package_publishing_history_list(json_object *o)
78 json_object *o_entries;
80 struct binary_package_publishing_history **entries;
82 o_entries = json_object_object_get(o, "entries");
87 n = json_object_array_length(o_entries);
90 (sizeof(struct binary_package_publishing_history *)*(n+1));
92 for (i = 0; i < n; i++) {
93 entries[i] = json_object_to_binary_package_publishing_history
94 (json_object_array_get_idx(o_entries, i));
101 struct daily_download_total *
102 json_object_to_daily_download_total(const char *d, json_object *o_c)
104 struct daily_download_total *result;
106 result = malloc(sizeof(struct daily_download_total));
107 result->count = json_object_get_int(o_c);
109 strptime(d, "%FT%T%z", &result->date);
114 static int json_object_get_fields_count(json_object *o)
118 json_object_object_foreach(o, key, val)
124 struct daily_download_total * *
125 json_object_to_daily_download_totals(json_object *o)
128 struct daily_download_total **result;
130 n = json_object_get_fields_count(o);
133 (sizeof(struct daily_download_total *)*(n+1));
136 json_object_object_foreach(o, key, val) {
137 result[i] = json_object_to_daily_download_total(key, val);