Mercurial > audlegacy
comparison src/audacious/vfs.c @ 2335:e80c9dfc93aa trunk
[svn] - g_strsplit() wraps strsplit(3), and thus has different results on
different systems (strsplit nul-terminates on uclibc). process URIs
in a different way, as a result.
author | nenolod |
---|---|
date | Mon, 15 Jan 2007 08:44:39 -0800 |
parents | 3149d4b1a9a9 |
children | b332cdd2ea43 |
comparison
equal
deleted
inserted
replaced
2334:345d38f25eb1 | 2335:e80c9dfc93aa |
---|---|
23 #include <sys/types.h> | 23 #include <sys/types.h> |
24 | 24 |
25 #include "libaudacious/urldecode.h" | 25 #include "libaudacious/urldecode.h" |
26 | 26 |
27 static GList *vfs_transports = NULL; | 27 static GList *vfs_transports = NULL; |
28 | |
29 #define VFS_DEBUG | |
28 | 30 |
29 #ifdef VFS_DEBUG | 31 #ifdef VFS_DEBUG |
30 # define DBG(x, args...) g_print(x, ## args); | 32 # define DBG(x, args...) g_print(x, ## args); |
31 #else | 33 #else |
32 # define DBG(x, args...) | 34 # define DBG(x, args...) |
60 VFSFile * | 62 VFSFile * |
61 vfs_fopen(const gchar * path, | 63 vfs_fopen(const gchar * path, |
62 const gchar * mode) | 64 const gchar * mode) |
63 { | 65 { |
64 VFSFile *file; | 66 VFSFile *file; |
65 gchar **vec; | |
66 VFSConstructor *vtable = NULL; | 67 VFSConstructor *vtable = NULL; |
67 GList *node; | 68 GList *node; |
68 gchar *decpath; | 69 gchar *decpath; |
69 | 70 |
70 if (!path || !mode) | 71 if (!path || !mode) |
71 return NULL; | 72 return NULL; |
72 | 73 |
73 decpath = xmms_urldecode_plain(path); | 74 decpath = xmms_urldecode_plain(path); |
74 | 75 |
75 vec = g_strsplit(decpath, "://", 2); | 76 for (node = vfs_transports; node != NULL; node = g_list_next(node)) |
76 | |
77 /* special case: no transport specified, look for the "/" transport */ | |
78 if (vec[1] == NULL) | |
79 { | 77 { |
80 for (node = vfs_transports; node != NULL; node = g_list_next(node)) | 78 vtable = (VFSConstructor *) node->data; |
81 { | 79 |
82 vtable = (VFSConstructor *) node->data; | 80 if (!strncasecmp(decpath, vtable->uri_id, strlen(vtable->uri_id))) |
83 | 81 break; |
84 if (*vtable->uri_id == '/') | |
85 break; | |
86 } | |
87 } | |
88 else | |
89 { | |
90 for (node = vfs_transports; node != NULL; node = g_list_next(node)) | |
91 { | |
92 vtable = (VFSConstructor *) node->data; | |
93 | |
94 if (!g_strcasecmp(vec[0], vtable->uri_id)) | |
95 break; | |
96 } | |
97 } | 82 } |
98 | 83 |
99 /* no transport vtable has been registered, bail. */ | 84 /* no transport vtable has been registered, bail. */ |
100 if (vtable == NULL) | 85 if (vtable == NULL) |
101 { | |
102 g_strfreev(vec); | |
103 return NULL; | 86 return NULL; |
104 } | 87 |
105 | 88 file = vtable->vfs_fopen_impl(decpath + strlen(vtable->uri_id), mode); |
106 file = vtable->vfs_fopen_impl(vec[1] ? vec[1] : vec[0], mode); | 89 |
107 | 90 if (file == NULL) |
108 if (file == NULL) | |
109 { | |
110 g_strfreev(vec); | |
111 return NULL; | 91 return NULL; |
112 } | |
113 | 92 |
114 file->uri = g_strdup(path); | 93 file->uri = g_strdup(path); |
115 file->base = vtable; | 94 file->base = vtable; |
116 | 95 |
117 g_strfreev(vec); | |
118 g_free(decpath); | 96 g_free(decpath); |
119 | 97 |
120 return file; | 98 return file; |
121 } | 99 } |
122 | 100 |