From fbf55cd7f31b6a413ebe785579b840a0091d390c Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Wed, 9 Aug 2000 05:16:53 +0000 Subject: Added uncompiled e_read_uri function. 2000-08-09 Christopher James Lahey * e-util.c, e-util.h: Added uncompiled e_read_uri function. svn path=/trunk/; revision=4629 --- e-util/e-util.c-8611 | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) (limited to 'e-util/e-util.c-8611') diff --git a/e-util/e-util.c-8611 b/e-util/e-util.c-8611 index 83e83f7a75..90a5697fb0 100644 --- a/e-util/e-util.c-8611 +++ b/e-util/e-util.c-8611 @@ -29,6 +29,9 @@ #include #include "e-util.h" +#if 0 +#include +#endif int g_str_compare(const void *x, const void *y) @@ -105,7 +108,9 @@ e_read_file(const char *filename) bytes = read(fd, buffer, BUFF_SIZE); while (bytes) { if (bytes > 0) { - list = g_list_prepend(list, g_strndup(buffer, bytes)); + char *temp = g_malloc(bytes); + memcpy (temp, buffer, bytes); + list = g_list_prepend(list, temp); lengths = g_list_prepend(lengths, GINT_TO_POINTER(bytes)); length += bytes; } else { @@ -161,6 +166,49 @@ e_write_file(const char *filename, const char *data, int flags) return 0; } +#if 0 +char * +e_read_uri(const char *uri) +{ + GnomeVFSHandle *handle; + GList *list = NULL, *list_iterator; + GList *lengths = NULL, *lengths_iterator; + gchar buffer[1025]; + gchar *ret_val; + int length = 0; + GnomeVFSFileSize bytes; + + gnome_vfs_open(&handle, uri, GNOME_VFS_OPEN_READ); + + gnome_vfs_read(handle, buffer, 1024, &bytes); + while (bytes) { + if (bytes) { + char *temp = g_malloc(bytes); + memcpy (temp, buffer, bytes); + list = g_list_prepend(list, temp); + lengths = g_list_prepend(lengths, GINT_TO_POINTER((gint) bytes)); + length += bytes; + } + gnome_vfs_read(handle, buffer, 1024, &bytes); + } + + ret_val = g_new(char, length + 1); + ret_val[length] = 0; + lengths_iterator = lengths; + list_iterator = list; + for ( ; list_iterator; list_iterator = list_iterator->next, lengths_iterator = lengths_iterator->next) { + int this_length = GPOINTER_TO_INT(lengths_iterator->data); + length -= this_length; + memcpy(ret_val + length, list_iterator->data, this_length); + } + gnome_vfs_close(handle); + g_list_foreach(list, (GFunc) g_free, NULL); + g_list_free(list); + g_list_free(lengths); + return ret_val; +} +#endif + typedef gint (*GtkSignal_INT__INT_INT_POINTER) (GtkObject * object, gint arg1, gint arg2, -- cgit v1.2.3