diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2000-08-09 13:16:53 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2000-08-09 13:16:53 +0800 |
commit | fbf55cd7f31b6a413ebe785579b840a0091d390c (patch) | |
tree | caf6c732cb655949ef79f81ce8e77c2cbcfad6ba /e-util/e-util.c-8611 | |
parent | a0522bcc255a194232d46dd52ba4a719c66d42f6 (diff) | |
download | gsoc2013-evolution-fbf55cd7f31b6a413ebe785579b840a0091d390c.tar gsoc2013-evolution-fbf55cd7f31b6a413ebe785579b840a0091d390c.tar.gz gsoc2013-evolution-fbf55cd7f31b6a413ebe785579b840a0091d390c.tar.bz2 gsoc2013-evolution-fbf55cd7f31b6a413ebe785579b840a0091d390c.tar.lz gsoc2013-evolution-fbf55cd7f31b6a413ebe785579b840a0091d390c.tar.xz gsoc2013-evolution-fbf55cd7f31b6a413ebe785579b840a0091d390c.tar.zst gsoc2013-evolution-fbf55cd7f31b6a413ebe785579b840a0091d390c.zip |
Added uncompiled e_read_uri function.
2000-08-09 Christopher James Lahey <clahey@helixcode.com>
* e-util.c, e-util.h: Added uncompiled e_read_uri function.
svn path=/trunk/; revision=4629
Diffstat (limited to 'e-util/e-util.c-8611')
-rw-r--r-- | e-util/e-util.c-8611 | 50 |
1 files changed, 49 insertions, 1 deletions
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 <string.h> #include "e-util.h" +#if 0 +#include <libgnomevfs/gnome-vfs.h> +#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, |