1428229853ecdedde1dbe666cc2eb5774b67df82
[ppastats.git] / src / lp.h
1 /*
2  * Copyright (C) 2011-2014 jeanfi@gmail.com
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
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
17  * 02110-1301 USA
18  */
19
20 #ifndef _PPASTATS_LP_H_
21 #define _PPASTATS_LP_H_
22
23 #define URL_BASE_LP "https://api.launchpad.net/1.0"
24
25 #include <time.h>
26
27 struct daily_download_total {
28         int count;
29
30         struct tm date;
31 };
32
33 /* (b)inary (p)ackage (p)ublishing (h)istory */
34 struct bpph {
35         char *binary_package_name;
36         char *binary_package_version;
37         char *distro_arch_series_link;
38         char *self_link;
39         char *status;
40         int architecture_specific;
41
42         time_t date_created;
43 };
44
45 struct distro_arch_series {
46         char *display_name;
47         char *title;
48         char *architecture_tag;
49         int is_nominated_arch_indep;
50         char *distroseries_link;
51 };
52
53 struct distro_series {
54         char *displayname;
55         char *name;
56         char *version;
57         char *title;
58 };
59
60 struct distro_series *distro_series_new(const char *name,
61                                         const char *version,
62                                         const char *title,
63                                         const char *displayname);
64
65 void distro_series_free(struct distro_series *distro_series);
66
67 void daily_download_total_list_free(struct daily_download_total **);
68
69 struct distro_arch_series *
70 distro_arch_series_new(const char *display_name,
71                        const char *title,
72                        const char *architecture_tag,
73                        int is_nominated_arch_indep,
74                        const char *distroseries_link);
75
76 void distro_arch_series_free(struct distro_arch_series *);
77
78 void bpph_free(struct bpph *b);
79
80 struct bpph *bpph_new(const char *binary_package_name,
81                       const char *binary_package_version,
82                       const char *distro_arch_series_link,
83                       const char *self_link,
84                       const char *status,
85                       int architecture_specific,
86                       time_t date_created);
87
88 void bpph_list_free(struct bpph **list);
89
90 struct bpph **bpph_list_append_list(struct bpph **list1, struct bpph **list2);
91
92 char *get_archive_url(const char *owner, const char  *ppa);
93
94 time_t ddts_get_last_date(struct daily_download_total **);
95
96 struct daily_download_total **
97 ddts_merge(struct daily_download_total **,
98            struct daily_download_total **);
99
100 int ddts_get_count(struct daily_download_total **);
101
102 struct daily_download_total *ddt_clone(struct daily_download_total *);
103 struct daily_download_total **ddts_clone(struct daily_download_total **);
104
105 #endif