added string replace fct
[ppastats.git] / src / lp.c
index 752d397..c0c2b90 100644 (file)
--- a/src/lp.c
+++ b/src/lp.c
@@ -1,30 +1,60 @@
 /*
-    Copyright (C) 2011 jeanfi@gmail.com
+ * Copyright (C) 2011-2012 jeanfi@gmail.com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
 
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
 
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
+#include "lp.h"
 
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-    02110-1301 USA
-*/
+struct distro_series *distro_series_new(const char *name,
+                                       const char *version,
+                                       const char *title,
+                                       const char *displayname)
+{
+       struct distro_series *d;
 
+       d = malloc(sizeof(struct distro_series));
 
-#include <stdlib.h>
-#include <string.h>
+       d->name = strdup(name);
+       d->version = strdup(version);
+       d->title = strdup(title);
+       d->displayname = strdup(displayname);
 
-#include "lp.h"
+       return d;
+}
+
+void distro_series_free(struct distro_series *d)
+{
+       if (d) {
+               free(d->name);
+               free(d->version);
+               free(d->title);
+               free(d->displayname);
+
+               free(d);
+       }
+}
 
 void
-binary_package_publishing_history_free(struct binary_package_publishing_history *b)
+binary_package_publishing_history_free \
+(struct binary_package_publishing_history *b)
 {
        if (b) {
                free(b->binary_package_name);
@@ -39,7 +69,8 @@ struct binary_package_publishing_history *
 binary_package_publishing_history_new(const char *binary_package_name,
                                      const char *binary_package_version,
                                      const char *distro_arch_series_link,
-                                     const char *self_link)
+                                     const char *self_link,
+                                     int architecture_specific)
 {
        struct binary_package_publishing_history *b;
 
@@ -49,12 +80,14 @@ binary_package_publishing_history_new(const char *binary_package_name,
        b->binary_package_version = strdup(binary_package_version);
        b->distro_arch_series_link = strdup(distro_arch_series_link);
        b->self_link = strdup(self_link);
+       b->architecture_specific = architecture_specific;
 
        return b;
 }
 
 void
-binary_package_publishing_history_list_free(struct binary_package_publishing_history **list)
+binary_package_publishing_history_list_free\
+(struct binary_package_publishing_history **list)
 {
        struct binary_package_publishing_history **l_cur = list;
 
@@ -86,7 +119,9 @@ char *get_archive_url(const char *owner, const char *ppa)
 
 struct distro_arch_series *distro_arch_series_new(const char *display_name,
                                                  const char *title,
-                                                 const char *architecture_tag)
+                                                 const char *architecture_tag,
+                                                 int is_nominated_arch_indep,
+                                                 const char *distroseries_link)
 {
        struct distro_arch_series *d;
 
@@ -95,6 +130,8 @@ struct distro_arch_series *distro_arch_series_new(const char *display_name,
        d->display_name = strdup(display_name);
        d->title = strdup(title);
        d->architecture_tag = strdup(architecture_tag);
+       d->is_nominated_arch_indep = is_nominated_arch_indep;
+       d->distroseries_link = strdup(distroseries_link);
 
        return d;
 }
@@ -104,9 +141,11 @@ void distro_arch_series_free(struct distro_arch_series *d)
        free(d->display_name);
        free(d->title);
        free(d->architecture_tag);
+       free(d->distroseries_link);
 
        free(d);
 }
+
 void distro_arch_series_list_free(struct distro_arch_series **list)
 {
        if (list) {
@@ -132,15 +171,3 @@ void daily_download_total_list_free(struct daily_download_total **list)
        }
 }
 
-int list_length(void **list)
-{
-       int n;
-
-       n = 0;
-       while (*list) {
-               list++;
-               n++;
-       }
-
-       return n;
-}