1
/* $Id: gnome-uri.c 4618 2004-07-14 20:17:58Z benny $ */
11
#include <engines/balou/gnome-uri.h>
13
/*** the next three routines are taken straight from gnome-libs so that the
14
gtk-only version can receive drag and drops as well ***/
16
* gnome_uri_list_free_strings:
17
* @list: A GList returned by gnome_uri_list_extract_uris() or gnome_uri_list_extract_filenames()
19
* Releases all of the resources allocated by @list.
22
gnome_uri_list_free_strings (GList * list)
24
g_list_foreach (list, (GFunc) g_free, NULL);
29
* gnome_uri_list_extract_uris:
30
* @uri_list: an uri-list in the standard format.
32
* Returns a GList containing strings allocated with g_malloc
33
* that have been splitted from @uri-list.
36
gnome_uri_list_extract_uris (const gchar * uri_list)
42
g_return_val_if_fail (uri_list != NULL, NULL);
46
/* We don't actually try to validate the URI according to RFC
47
* 2396, or even check for allowed characters - we just ignore
48
* comments and trim whitespace off the ends. We also
49
* allow LF delimination as well as the specified CRLF.
55
while (g_ascii_isspace ((int) (*p)))
59
while (*q && (*q != '\n') && (*q != '\r'))
65
while (q > p && g_ascii_isspace ((int) (*q)))
68
retval = (char *) g_malloc (q - p + 2);
69
strncpy (retval, p, q - p + 1);
70
retval[q - p + 1] = '\0';
72
result = g_list_prepend (result, retval);
80
return g_list_reverse (result);
85
* gnome_uri_list_extract_filenames:
86
* @uri_list: an uri-list in the standard format
88
* Returns a GList containing strings allocated with g_malloc
89
* that contain the filenames in the uri-list.
91
* Note that unlike gnome_uri_list_extract_uris() function, this
92
* will discard any non-file uri from the result value.
95
gnome_uri_list_extract_filenames (const gchar * uri_list)
97
GList *tmp_list, *node, *result;
99
g_return_val_if_fail (uri_list != NULL, NULL);
101
result = gnome_uri_list_extract_uris (uri_list);
106
gchar *s = (char *) tmp_list->data;
109
tmp_list = tmp_list->next;
111
if (!strncmp (s, "file:", 5))
113
/* added by Jasper Huijsmans
114
remove leading multiple slashes */
115
if (!strncmp (s + 5, "///", 3))
116
node->data = g_strdup (s + 7);
118
node->data = g_strdup (s + 5);
122
node->data = g_strdup (s);