Mercurial > pidgin.yaz
comparison src/win32/libc_interface.c @ 10589:0f7452b1f777
[gaim-migrate @ 11994]
Use GLib 2.6's gstdio functions. This should fix gaim not liking non-ascii filenames in win32.
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Fri, 11 Feb 2005 05:10:40 +0000 |
parents | 5e78d07f6b36 |
children | e46b51de549a |
comparison
equal
deleted
inserted
replaced
10588:529111933c9c | 10589:0f7452b1f777 |
---|---|
29 #include <stdio.h> | 29 #include <stdio.h> |
30 #include <errno.h> | 30 #include <errno.h> |
31 #include <sys/timeb.h> | 31 #include <sys/timeb.h> |
32 #include <sys/stat.h> | 32 #include <sys/stat.h> |
33 #include <time.h> | 33 #include <time.h> |
34 #include <glib.h> | |
34 #include "debug.h" | 35 #include "debug.h" |
35 #include "libc_internal.h" | 36 #include "libc_internal.h" |
36 | 37 |
38 #if !GLIB_CHECK_VERSION(2,6,0) | |
39 # define g_remove remove | |
40 #endif | |
37 /* | 41 /* |
38 * PROTOS | 42 * PROTOS |
39 */ | 43 */ |
40 | 44 |
41 /* | 45 /* |
213 } | 217 } |
214 else | 218 else |
215 return strerror( errornum ); | 219 return strerror( errornum ); |
216 } | 220 } |
217 | 221 |
218 /* From glibc 2.2.5 */ | |
219 char* wgaim_strsep(char **stringp, const char *delim) { | |
220 char *begin, *end; | |
221 | |
222 begin = *stringp; | |
223 if (begin == NULL) | |
224 return NULL; | |
225 | |
226 /* A frequent case is when the delimiter string contains only one | |
227 character. Here we don't need to call the expensive `strpbrk' | |
228 function and instead work using `strchr'. */ | |
229 if (delim[0] == '\0' || delim[1] == '\0') { | |
230 char ch = delim[0]; | |
231 | |
232 if (ch == '\0') | |
233 end = NULL; | |
234 else { | |
235 if (*begin == ch) | |
236 end = begin; | |
237 else if (*begin == '\0') | |
238 end = NULL; | |
239 else | |
240 end = strchr (begin + 1, ch); | |
241 } | |
242 } | |
243 else | |
244 /* Find the end of the token. */ | |
245 end = strpbrk (begin, delim); | |
246 | |
247 if (end) { | |
248 /* Terminate the token and set *STRINGP past NUL character. */ | |
249 *end++ = '\0'; | |
250 *stringp = end; | |
251 } | |
252 else | |
253 /* No more delimiters; this is the last token. */ | |
254 *stringp = NULL; | |
255 | |
256 return begin; | |
257 } | |
258 | |
259 /* unistd.h */ | 222 /* unistd.h */ |
260 | 223 |
261 /* | 224 /* |
262 * We need to figure out whether fd is a file or socket handle. | 225 * We need to figure out whether fd is a file or socket handle. |
263 */ | 226 */ |
347 return res; | 310 return res; |
348 } | 311 } |
349 | 312 |
350 /* stdio.h */ | 313 /* stdio.h */ |
351 | 314 |
315 #if !GLIB_CHECK_VERSION(2,6,0) | |
352 int wgaim_rename (const char *oldname, const char *newname) { | 316 int wgaim_rename (const char *oldname, const char *newname) { |
353 struct _stat oldstat, newstat; | 317 struct _stat oldstat, newstat; |
354 | 318 |
355 if(_stat(oldname, &oldstat) == 0) { | 319 if(_stat(oldname, &oldstat) == 0) { |
356 /* newname exists */ | 320 /* newname exists */ |
377 errno = EISDIR; | 341 errno = EISDIR; |
378 return -1; | 342 return -1; |
379 } | 343 } |
380 /* newname is not a dir */ | 344 /* newname is not a dir */ |
381 else { | 345 else { |
382 remove(newname); | 346 g_remove(newname); |
383 return rename(oldname, newname); | 347 return rename(oldname, newname); |
384 } | 348 } |
385 } | 349 } |
386 } | 350 } |
387 /* newname doesn't exist */ | 351 /* newname doesn't exist */ |
393 errno = ENOENT; | 357 errno = ENOENT; |
394 return -1; | 358 return -1; |
395 } | 359 } |
396 | 360 |
397 } | 361 } |
362 #endif | |
398 | 363 |
399 /* time.h */ | 364 /* time.h */ |
400 | 365 |
401 struct tm * wgaim_localtime_r (const time_t *time, struct tm *resultp) { | 366 struct tm * wgaim_localtime_r (const time_t *time, struct tm *resultp) { |
402 struct tm* tmptm; | 367 struct tm* tmptm; |