(no commit message)
authorJean-Philippe Orsini <jeanfi@gmail.com>
Tue, 23 Apr 2013 17:20:16 +0000 (17:20 +0000)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Tue, 23 Apr 2013 17:20:16 +0000 (17:20 +0000)
src/Makefile.am
src/Makefile.in
src/http.c [new file with mode: 0644]
src/http.h [new file with mode: 0644]
src/main.c
src/phttp.c [deleted file]
src/phttp.h [deleted file]
src/ttrss.c

index d3055e2..671429e 100644 (file)
@@ -12,14 +12,14 @@ LIBS = $(CURL_LIBS) $(JSON_LIBS) $(GTK_LIBS) $(WEBKIT_LIBS)
 bin_PROGRAMS = prss
 
 prss_SOURCES = main.c \
-              phttp.c \
-              phttp.h \
-              ttrss.c \
-              ttrss.h \
-              url.c \
-              url.h \
-              webbrowser.c \
-              webbrowser.h
+       http.c \
+       http.h \
+       ttrss.c \
+       ttrss.h \
+       url.c \
+       url.h \
+       webbrowser.c \
+       webbrowser.h
 
 gsettings_SCHEMAS=prss.gschema.xml
 
index db54ec0..fee124c 100644 (file)
@@ -64,7 +64,7 @@ CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"
 PROGRAMS = $(bin_PROGRAMS)
-am_prss_OBJECTS = main.$(OBJEXT) phttp.$(OBJEXT) ttrss.$(OBJEXT) \
+am_prss_OBJECTS = main.$(OBJEXT) http.$(OBJEXT) ttrss.$(OBJEXT) \
        url.$(OBJEXT) webbrowser.$(OBJEXT)
 prss_OBJECTS = $(am_prss_OBJECTS)
 prss_LDADD = $(LDADD)
@@ -292,14 +292,14 @@ SUBDIRS = glade
 AM_LDFLAGS = -Wl,--as-needed  -export-dynamic
 AM_CPPFLAGS = -Wall -Werror $(CURL_CFLAGS) $(GTK_CFLAGS) $(JSON_CFLAGS) $(WEBKIT_CFLAGS)
 prss_SOURCES = main.c \
-              phttp.c \
-              phttp.h \
-              ttrss.c \
-              ttrss.h \
-              url.c \
-              url.h \
-              webbrowser.c \
-              webbrowser.h
+       http.c \
+       http.h \
+       ttrss.c \
+       ttrss.h \
+       url.c \
+       url.h \
+       webbrowser.c \
+       webbrowser.h
 
 gsettings_SCHEMAS = prss.gschema.xml
 dist_man_MANS = prss.1
@@ -387,8 +387,8 @@ mostlyclean-compile:
 distclean-compile:
        -rm -f *.tab.c
 
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/http.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/phttp.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ttrss.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/url.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/webbrowser.Po@am__quote@
diff --git a/src/http.c b/src/http.c
new file mode 100644 (file)
index 0000000..a1d0211
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2010-2013 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
+ */
+#include <locale.h>
+#include <libintl.h>
+#define _(str) gettext(str)
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <curl/curl.h>
+#include <json/json.h>
+
+#include "url.h"
+
+struct ucontent {
+       char *data;
+       size_t len;
+};
+
+static CURL *curl;
+
+static size_t cbk_curl(void *buffer, size_t size, size_t nmemb, void *userp)
+{
+       size_t realsize;
+       struct ucontent *mem;
+
+       realsize = size * nmemb;
+       mem = (struct ucontent *)userp;
+
+       mem->data = realloc(mem->data, mem->len + realsize + 1);
+
+       memcpy(&(mem->data[mem->len]), buffer, realsize);
+       mem->len += realsize;
+       mem->data[mem->len] = 0;
+
+       return realsize;
+}
+
+void phttp_init()
+{
+       curl = curl_easy_init();
+}
+
+void phttp_cleanup()
+{
+       curl_easy_cleanup(curl);
+}
+
+json_object *get_json_object(const char *url)
+{
+       struct ucontent chunk;
+       json_object *obj;
+
+       obj = NULL;
+
+       if (!curl)
+               return NULL;
+
+       chunk.data = malloc(1);
+       chunk.len = 0;
+
+       curl_easy_setopt(curl, CURLOPT_URL, url);
+       curl_easy_setopt(curl, CURLOPT_VERBOSE, 0);
+       curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cbk_curl);
+       curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk);
+
+       if (curl_easy_perform(curl) == CURLE_OK)
+               obj = json_tokener_parse(chunk.data);
+       else
+               fprintf(stderr, _("Fail to connect to: %s"), url);
+
+       free(chunk.data);
+
+       return obj;
+}
+
+static json_object *post(const char *url, const char *body)
+{
+       struct ucontent chunk;
+       json_object *obj;
+
+       obj = NULL;
+
+       chunk.data = malloc(1);
+       chunk.len = 0;
+
+       curl_easy_setopt(curl, CURLOPT_URL, url);
+       curl_easy_setopt(curl, CURLOPT_VERBOSE, 0);
+       if (body) {
+               curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body);
+               curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(body));
+       }
+       curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cbk_curl);
+       curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk);
+
+       if (curl_easy_perform(curl) == CURLE_OK)
+               obj = json_tokener_parse(chunk.data);
+       else
+               fprintf(stderr, _("Fail to connect to: %s"), url);
+       free(chunk.data);
+
+       return obj;
+}
+
+json_object *post_json_object(const char *url, struct json_object *j)
+{
+       return post(url, json_object_to_json_string(j));
+}
diff --git a/src/http.h b/src/http.h
new file mode 100644 (file)
index 0000000..3c717c9
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2010-2013 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
+ */
+
+#ifndef _PHTTP_H_
+#define _PHTTP_H_
+
+void phttp_init();
+json_object *get_json_object(const char *url);
+json_object *post_json_object(const char *url, struct json_object *);
+
+#endif
index b01700e..bc1805c 100644 (file)
 #include <getopt.h>
 
 #include <json/json.h>
-#include "ttrss.h"
 #include <webkit/webkit.h>
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
-#include "phttp.h"
+#include "http.h"
+#include "ttrss.h"
 #include "webbrowser.h"
 
 static const char *program_name;
diff --git a/src/phttp.c b/src/phttp.c
deleted file mode 100644 (file)
index a1d0211..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (C) 2010-2013 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
- */
-#include <locale.h>
-#include <libintl.h>
-#define _(str) gettext(str)
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <curl/curl.h>
-#include <json/json.h>
-
-#include "url.h"
-
-struct ucontent {
-       char *data;
-       size_t len;
-};
-
-static CURL *curl;
-
-static size_t cbk_curl(void *buffer, size_t size, size_t nmemb, void *userp)
-{
-       size_t realsize;
-       struct ucontent *mem;
-
-       realsize = size * nmemb;
-       mem = (struct ucontent *)userp;
-
-       mem->data = realloc(mem->data, mem->len + realsize + 1);
-
-       memcpy(&(mem->data[mem->len]), buffer, realsize);
-       mem->len += realsize;
-       mem->data[mem->len] = 0;
-
-       return realsize;
-}
-
-void phttp_init()
-{
-       curl = curl_easy_init();
-}
-
-void phttp_cleanup()
-{
-       curl_easy_cleanup(curl);
-}
-
-json_object *get_json_object(const char *url)
-{
-       struct ucontent chunk;
-       json_object *obj;
-
-       obj = NULL;
-
-       if (!curl)
-               return NULL;
-
-       chunk.data = malloc(1);
-       chunk.len = 0;
-
-       curl_easy_setopt(curl, CURLOPT_URL, url);
-       curl_easy_setopt(curl, CURLOPT_VERBOSE, 0);
-       curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cbk_curl);
-       curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk);
-
-       if (curl_easy_perform(curl) == CURLE_OK)
-               obj = json_tokener_parse(chunk.data);
-       else
-               fprintf(stderr, _("Fail to connect to: %s"), url);
-
-       free(chunk.data);
-
-       return obj;
-}
-
-static json_object *post(const char *url, const char *body)
-{
-       struct ucontent chunk;
-       json_object *obj;
-
-       obj = NULL;
-
-       chunk.data = malloc(1);
-       chunk.len = 0;
-
-       curl_easy_setopt(curl, CURLOPT_URL, url);
-       curl_easy_setopt(curl, CURLOPT_VERBOSE, 0);
-       if (body) {
-               curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body);
-               curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(body));
-       }
-       curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cbk_curl);
-       curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk);
-
-       if (curl_easy_perform(curl) == CURLE_OK)
-               obj = json_tokener_parse(chunk.data);
-       else
-               fprintf(stderr, _("Fail to connect to: %s"), url);
-       free(chunk.data);
-
-       return obj;
-}
-
-json_object *post_json_object(const char *url, struct json_object *j)
-{
-       return post(url, json_object_to_json_string(j));
-}
diff --git a/src/phttp.h b/src/phttp.h
deleted file mode 100644 (file)
index 3c717c9..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2010-2013 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
- */
-
-#ifndef _PHTTP_H_
-#define _PHTTP_H_
-
-void phttp_init();
-json_object *get_json_object(const char *url);
-json_object *post_json_object(const char *url, struct json_object *);
-
-#endif
index e64c7af..7f9e8df 100644 (file)
@@ -23,7 +23,7 @@
 #include <json/json.h>
 #include <gtk/gtk.h>
 
-#include "phttp.h"
+#include "http.h"
 #include "ttrss.h"
 #include "url.h"