evolution-rss r411 - trunk/src



Author: lucilanga
Date: Tue Nov 25 17:14:13 2008
New Revision: 411
URL: http://svn.gnome.org/viewvc/evolution-rss?rev=411&view=rev

Log:
2008-11-25  Lucian Langa  <lucilanga gnome org>

* src/rss.c: fetch_blocking() new function
allow to retrieve network, file streams
* configure.ac: bump to devel version
* src/misc.c: sanitize_url() add file://
schmeme

Added:
   trunk/src/fetch.c

Added: trunk/src/fetch.c
==============================================================================
--- (empty file)
+++ trunk/src/fetch.c	Tue Nov 25 17:14:13 2008
@@ -0,0 +1,36 @@
+
+#include "network.h"
+
+GString*
+fetch_blocking(const char *url, GSList *headers, GString *post,
+                  NetStatusCallback cb, gpointer data,
+                  GError **err) {
+
+	gchar *scheme = NULL;
+	GString *result = NULL;
+	
+	scheme = g_uri_parse_scheme(url);
+	if (!g_ascii_strcasecmp(scheme, "file")) {
+		gchar *fname = g_filename_from_uri(url, NULL, NULL);
+		FILE *f = g_fopen(fname, "rb");
+		g_free(fname);
+		g_free(scheme);
+	 	if (f == NULL)
+                	goto error;	
+		gchar *buf = g_new0 (gchar, 4096);
+		result = g_string_new(NULL);
+		while (fgets(buf, 4096, f) != NULL) {
+			g_string_append_len(result, buf, strlen(buf));
+		}
+		fclose(f);
+		return result;
+	} else {
+		g_free(scheme);
+        	return net_post_blocking(url, NULL, post, cb, data, &err);
+	}
+error:
+	g_print("error\n");
+	g_set_error(err, NET_ERROR, NET_ERROR_GENERIC,
+                                g_strerror(errno));
+	return result;
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]