Mercurial > audlegacy-plugins
annotate src/stdio/stdio.c @ 1925:2662c3a11f9f
- Enable https:// transport
author | Ralf Ertzinger <ralf@skytale.net> |
---|---|
date | Sun, 30 Sep 2007 22:19:11 +0200 |
parents | 31e9908cf91e |
children | c276e2b74646 |
rev | line source |
---|---|
306 | 1 /* Audacious |
2 * Copyright (c) 2006 William Pitcock | |
3 * | |
4 * This program is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; either version 2 of the License, or | |
7 * (at your option) any later version. | |
8 * | |
9 * This program is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 * GNU General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU General Public License | |
15 * along with this program; if not, write to the Free Software | |
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 */ | |
18 | |
19 #include <audacious/vfs.h> | |
20 #include <audacious/plugin.h> | |
1190
ed2d7787779e
more warning elimination.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1146
diff
changeset
|
21 #include "audacious/strings.h" |
306 | 22 #include <stdio.h> |
23 | |
24 #include <unistd.h> | |
25 #include <sys/stat.h> | |
26 #include <sys/types.h> | |
27 | |
500
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
28 #include <string.h> |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
29 |
1921
31e9908cf91e
experimental patch to use libmagic for mimetype support
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
30 #include <magic.h> |
31e9908cf91e
experimental patch to use libmagic for mimetype support
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
31 |
500
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
32 static gchar * |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
33 vfs_stdio_urldecode_path(const gchar * encoded_path) |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
34 { |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
35 const gchar *cur, *ext; |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
36 gchar *path, *tmp; |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
37 gint realchar; |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
38 |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
39 if (!encoded_path) |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
40 return NULL; |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
41 |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
42 if (!str_has_prefix_nocase(encoded_path, "file:")) |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
43 return NULL; |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
44 |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
45 cur = encoded_path + 5; |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
46 |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
47 if (str_has_prefix_nocase(cur, "//localhost")) |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
48 cur += 11; |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
49 |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
50 if (*cur == '/') |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
51 while (cur[1] == '/') |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
52 cur++; |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
53 |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
54 tmp = g_malloc0(strlen(cur) + 1); |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
55 |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
56 while ((ext = strchr(cur, '%')) != NULL) { |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
57 strncat(tmp, cur, ext - cur); |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
58 ext++; |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
59 cur = ext + 2; |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
60 if (!sscanf(ext, "%2x", &realchar)) { |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
61 /* Assume it is a literal '%'. Several file |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
62 * managers send unencoded file: urls on drag |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
63 * and drop. */ |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
64 realchar = '%'; |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
65 cur -= 2; |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
66 } |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
67 tmp[strlen(tmp)] = realchar; |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
68 } |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
69 |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
70 path = g_strconcat(tmp, cur, NULL); |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
71 g_free(tmp); |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
72 return path; |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
73 } |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
74 |
306 | 75 VFSFile * |
76 stdio_vfs_fopen_impl(const gchar * path, | |
77 const gchar * mode) | |
78 { | |
79 VFSFile *file; | |
500
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
80 gchar *decpath; |
306 | 81 |
82 if (!path || !mode) | |
83 return NULL; | |
84 | |
500
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
85 decpath = vfs_stdio_urldecode_path(path); |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
86 |
306 | 87 file = g_new(VFSFile, 1); |
88 | |
500
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
89 file->handle = fopen(decpath != NULL ? decpath : path, mode); |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
90 |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
91 if (decpath != NULL) |
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
326
diff
changeset
|
92 g_free(decpath); |
306 | 93 |
94 if (file->handle == NULL) { | |
95 g_free(file); | |
96 file = NULL; | |
97 } | |
98 | |
99 return file; | |
100 } | |
101 | |
102 gint | |
103 stdio_vfs_fclose_impl(VFSFile * file) | |
104 { | |
105 gint ret = 0; | |
106 | |
107 if (file == NULL) | |
108 return -1; | |
109 | |
326
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
110 if (file->handle) |
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
111 { |
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
112 FILE *handle = (FILE *) file->handle; |
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
113 |
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
114 if (fclose(handle) != 0) |
306 | 115 ret = -1; |
1228
01efa0e5b554
file->handle should be cleared on close, otherwise it can lead to double free.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1210
diff
changeset
|
116 file->handle = NULL; |
306 | 117 } |
118 | |
119 return ret; | |
120 } | |
121 | |
122 size_t | |
123 stdio_vfs_fread_impl(gpointer ptr, | |
124 size_t size, | |
125 size_t nmemb, | |
126 VFSFile * file) | |
127 { | |
326
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
128 FILE *handle; |
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
129 |
306 | 130 if (file == NULL) |
131 return 0; | |
132 | |
326
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
133 handle = (FILE *) file->handle; |
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
134 |
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
135 return fread(ptr, size, nmemb, handle); |
306 | 136 } |
137 | |
138 size_t | |
139 stdio_vfs_fwrite_impl(gconstpointer ptr, | |
140 size_t size, | |
141 size_t nmemb, | |
142 VFSFile * file) | |
143 { | |
326
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
144 FILE *handle; |
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
145 |
306 | 146 if (file == NULL) |
147 return 0; | |
148 | |
326
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
149 handle = (FILE *) file->handle; |
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
150 |
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
151 return fwrite(ptr, size, nmemb, handle); |
306 | 152 } |
153 | |
154 gint | |
155 stdio_vfs_getc_impl(VFSFile *stream) | |
156 { | |
326
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
157 FILE *handle = (FILE *) stream->handle; |
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
158 |
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
159 return getc( handle ); |
306 | 160 } |
161 | |
162 gint | |
163 stdio_vfs_ungetc_impl(gint c, VFSFile *stream) | |
164 { | |
326
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
165 FILE *handle = (FILE *) stream->handle; |
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
166 |
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
167 return ungetc( c , handle ); |
306 | 168 } |
169 | |
170 gint | |
171 stdio_vfs_fseek_impl(VFSFile * file, | |
172 glong offset, | |
173 gint whence) | |
174 { | |
326
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
175 FILE *handle; |
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
176 |
306 | 177 if (file == NULL) |
178 return 0; | |
179 | |
326
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
180 handle = (FILE *) file->handle; |
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
181 |
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
182 return fseek(handle, offset, whence); |
306 | 183 } |
184 | |
185 void | |
186 stdio_vfs_rewind_impl(VFSFile * file) | |
187 { | |
326
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
188 FILE *handle; |
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
189 |
306 | 190 if (file == NULL) |
191 return; | |
192 | |
326
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
193 handle = (FILE *) file->handle; |
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
194 |
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
195 rewind(handle); |
306 | 196 } |
197 | |
198 glong | |
199 stdio_vfs_ftell_impl(VFSFile * file) | |
200 { | |
326
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
201 FILE *handle; |
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
202 |
306 | 203 if (file == NULL) |
204 return 0; | |
205 | |
326
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
206 handle = (FILE *) file->handle; |
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
207 |
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
208 return ftell(handle); |
306 | 209 } |
210 | |
211 gboolean | |
212 stdio_vfs_feof_impl(VFSFile * file) | |
213 { | |
326
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
214 FILE *handle; |
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
215 |
306 | 216 if (file == NULL) |
217 return FALSE; | |
218 | |
326
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
219 handle = (FILE *) file->handle; |
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
220 |
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
221 return (gboolean) feof(handle); |
306 | 222 } |
223 | |
224 gint | |
225 stdio_vfs_truncate_impl(VFSFile * file, glong size) | |
226 { | |
326
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
227 FILE *handle; |
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
228 |
306 | 229 if (file == NULL) |
230 return -1; | |
231 | |
326
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
232 handle = (FILE *) file->handle; |
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
233 |
90a843d02970
[svn] - some OSes use macros for some f*() functions, therefore make sure we
nenolod
parents:
306
diff
changeset
|
234 return ftruncate(fileno(handle), size); |
306 | 235 } |
236 | |
965 | 237 off_t |
238 stdio_vfs_fsize_impl(VFSFile * file) | |
239 { | |
240 FILE *handle; | |
241 struct stat s; | |
242 | |
243 if (file == NULL) | |
244 return -1; | |
245 | |
246 handle = (FILE *) file->handle; | |
247 | |
248 if (-1 == fstat(fileno(handle), &s)) | |
249 return -1; | |
250 | |
251 return s.st_size; | |
252 } | |
253 | |
1921
31e9908cf91e
experimental patch to use libmagic for mimetype support
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
254 static magic_t mdb_handle = NULL; |
31e9908cf91e
experimental patch to use libmagic for mimetype support
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
255 |
31e9908cf91e
experimental patch to use libmagic for mimetype support
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
256 gchar * |
31e9908cf91e
experimental patch to use libmagic for mimetype support
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
257 stdio_vfs_metadata_impl(VFSFile *file, const gchar *field) |
31e9908cf91e
experimental patch to use libmagic for mimetype support
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
258 { |
31e9908cf91e
experimental patch to use libmagic for mimetype support
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
259 if (!g_ascii_strcasecmp(field, "content-type")) |
31e9908cf91e
experimental patch to use libmagic for mimetype support
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
260 { |
31e9908cf91e
experimental patch to use libmagic for mimetype support
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
261 gchar *decpath; |
31e9908cf91e
experimental patch to use libmagic for mimetype support
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
262 const gchar *out; |
31e9908cf91e
experimental patch to use libmagic for mimetype support
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
263 |
31e9908cf91e
experimental patch to use libmagic for mimetype support
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
264 if (mdb_handle == NULL) |
31e9908cf91e
experimental patch to use libmagic for mimetype support
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
265 mdb_handle = magic_open(MAGIC_MIME); |
31e9908cf91e
experimental patch to use libmagic for mimetype support
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
266 |
31e9908cf91e
experimental patch to use libmagic for mimetype support
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
267 decpath = vfs_stdio_urldecode_path(file->uri); |
31e9908cf91e
experimental patch to use libmagic for mimetype support
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
268 out = magic_file(mdb_handle, decpath); |
31e9908cf91e
experimental patch to use libmagic for mimetype support
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
269 |
31e9908cf91e
experimental patch to use libmagic for mimetype support
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
270 return g_strdup(out); |
31e9908cf91e
experimental patch to use libmagic for mimetype support
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
271 } |
31e9908cf91e
experimental patch to use libmagic for mimetype support
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
272 |
31e9908cf91e
experimental patch to use libmagic for mimetype support
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
273 return NULL; |
31e9908cf91e
experimental patch to use libmagic for mimetype support
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
274 } |
31e9908cf91e
experimental patch to use libmagic for mimetype support
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
275 |
306 | 276 VFSConstructor file_const = { |
277 "file://", | |
278 stdio_vfs_fopen_impl, | |
279 stdio_vfs_fclose_impl, | |
280 stdio_vfs_fread_impl, | |
281 stdio_vfs_fwrite_impl, | |
282 stdio_vfs_getc_impl, | |
283 stdio_vfs_ungetc_impl, | |
284 stdio_vfs_fseek_impl, | |
285 stdio_vfs_rewind_impl, | |
286 stdio_vfs_ftell_impl, | |
287 stdio_vfs_feof_impl, | |
965 | 288 stdio_vfs_truncate_impl, |
1921
31e9908cf91e
experimental patch to use libmagic for mimetype support
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
289 stdio_vfs_fsize_impl, |
31e9908cf91e
experimental patch to use libmagic for mimetype support
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
290 stdio_vfs_metadata_impl |
306 | 291 }; |
292 | |
293 static void init(void) | |
294 { | |
295 vfs_register_transport(&file_const); | |
296 } | |
297 | |
298 static void cleanup(void) | |
299 { | |
300 #if 0 | |
301 vfs_unregister_transport(&file_const); | |
302 #endif | |
303 } | |
304 | |
1395
761e17b23e0c
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
1228
diff
changeset
|
305 DECLARE_PLUGIN(stdio, init, cleanup, NULL, NULL, NULL, NULL, NULL, NULL); |