diff options
Diffstat (limited to 'src/include/plibc/plibc.h')
-rw-r--r-- | src/include/plibc/plibc.h | 83 |
1 files changed, 75 insertions, 8 deletions
diff --git a/src/include/plibc/plibc.h b/src/include/plibc/plibc.h index 4e3204c9..36698bf7 100644 --- a/src/include/plibc/plibc.h +++ b/src/include/plibc/plibc.h | |||
@@ -22,7 +22,7 @@ | |||
22 | * @brief PlibC header | 22 | * @brief PlibC header |
23 | * @attention This file is usually not installed under Unix, | 23 | * @attention This file is usually not installed under Unix, |
24 | * so ship it with your application | 24 | * so ship it with your application |
25 | * @version $Revision: 69 $ | 25 | * @version $Revision: 87 $ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #ifndef _PLIBC_H_ | 28 | #ifndef _PLIBC_H_ |
@@ -50,8 +50,8 @@ extern "C" { | |||
50 | #include "langinfo.h" | 50 | #include "langinfo.h" |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <windows.h> | ||
54 | #include <ws2tcpip.h> | 53 | #include <ws2tcpip.h> |
54 | #include <windows.h> | ||
55 | #include <sys/types.h> | 55 | #include <sys/types.h> |
56 | #include <time.h> | 56 | #include <time.h> |
57 | #include <stdio.h> | 57 | #include <stdio.h> |
@@ -70,7 +70,7 @@ extern "C" { | |||
70 | /* Convert LARGE_INTEGER to double */ | 70 | /* Convert LARGE_INTEGER to double */ |
71 | #define Li2Double(x) ((double)((x).HighPart) * 4.294967296E9 + \ | 71 | #define Li2Double(x) ((double)((x).HighPart) * 4.294967296E9 + \ |
72 | (double)((x).LowPart)) | 72 | (double)((x).LowPart)) |
73 | 73 | #ifndef __MINGW64__ | |
74 | struct stat64 | 74 | struct stat64 |
75 | { | 75 | { |
76 | _dev_t st_dev; | 76 | _dev_t st_dev; |
@@ -85,7 +85,7 @@ struct stat64 | |||
85 | __time64_t st_mtime; | 85 | __time64_t st_mtime; |
86 | __time64_t st_ctime; | 86 | __time64_t st_ctime; |
87 | }; | 87 | }; |
88 | 88 | #endif | |
89 | typedef unsigned int sa_family_t; | 89 | typedef unsigned int sa_family_t; |
90 | 90 | ||
91 | struct sockaddr_un { | 91 | struct sockaddr_un { |
@@ -226,8 +226,13 @@ enum | |||
226 | #define MAP_SHARED 0x1 | 226 | #define MAP_SHARED 0x1 |
227 | #define MAP_PRIVATE 0x2 /* unsupported */ | 227 | #define MAP_PRIVATE 0x2 /* unsupported */ |
228 | #define MAP_FIXED 0x10 | 228 | #define MAP_FIXED 0x10 |
229 | #define MAP_ANONYMOUS 0x20 /* unsupported */ | ||
229 | #define MAP_FAILED ((void *)-1) | 230 | #define MAP_FAILED ((void *)-1) |
230 | 231 | ||
232 | #define MS_ASYNC 1 /* sync memory asynchronously */ | ||
233 | #define MS_INVALIDATE 2 /* invalidate the caches */ | ||
234 | #define MS_SYNC 4 /* synchronous memory sync */ | ||
235 | |||
231 | struct statfs | 236 | struct statfs |
232 | { | 237 | { |
233 | long f_type; /* type of filesystem (see below) */ | 238 | long f_type; /* type of filesystem (see below) */ |
@@ -331,17 +336,29 @@ typedef struct | |||
331 | #define SetErrnoFromWinError(e) _SetErrnoFromWinError(e, __FILE__, __LINE__) | 336 | #define SetErrnoFromWinError(e) _SetErrnoFromWinError(e, __FILE__, __LINE__) |
332 | 337 | ||
333 | BOOL _plibc_CreateShortcut(const char *pszSrc, const char *pszDest); | 338 | BOOL _plibc_CreateShortcut(const char *pszSrc, const char *pszDest); |
339 | BOOL _plibc_CreateShortcutW(const wchar_t *pwszSrc, const wchar_t *pwszDest); | ||
334 | BOOL _plibc_DereferenceShortcut(char *pszShortcut); | 340 | BOOL _plibc_DereferenceShortcut(char *pszShortcut); |
341 | BOOL _plibc_DereferenceShortcutW(wchar_t *pwszShortcut); | ||
335 | char *plibc_ChooseDir(char *pszTitle, unsigned long ulFlags); | 342 | char *plibc_ChooseDir(char *pszTitle, unsigned long ulFlags); |
343 | wchar_t *plibc_ChooseDirW(wchar_t *pwszTitle, unsigned long ulFlags); | ||
336 | char *plibc_ChooseFile(char *pszTitle, unsigned long ulFlags); | 344 | char *plibc_ChooseFile(char *pszTitle, unsigned long ulFlags); |
337 | long QueryRegistry(HKEY hMainKey, char *pszKey, char *pszSubKey, | 345 | wchar_t *plibc_ChooseFileW(wchar_t *pwszTitle, unsigned long ulFlags); |
346 | |||
347 | long QueryRegistry(HKEY hMainKey, const char *pszKey, const char *pszSubKey, | ||
338 | char *pszBuffer, long *pdLength); | 348 | char *pszBuffer, long *pdLength); |
349 | long QueryRegistryW(HKEY hMainKey, const wchar_t *pszKey, const wchar_t *pszSubKey, | ||
350 | wchar_t *pszBuffer, long *pdLength); | ||
339 | 351 | ||
340 | BOOL __win_IsHandleMarkedAsBlocking(int hHandle); | 352 | BOOL __win_IsHandleMarkedAsBlocking(int hHandle); |
341 | void __win_SetHandleBlockingMode(int s, BOOL bBlocking); | 353 | void __win_SetHandleBlockingMode(int s, BOOL bBlocking); |
342 | void __win_DiscardHandleBlockingMode(int s); | 354 | void __win_DiscardHandleBlockingMode(int s); |
343 | int _win_isSocketValid(int s); | 355 | int _win_isSocketValid(int s); |
344 | int plibc_conv_to_win_path(const char *pszUnix, char *pszWindows); | 356 | int plibc_conv_to_win_path(const char *pszUnix, char *pszWindows); |
357 | int plibc_conv_to_win_pathw(const wchar_t *pszUnix, wchar_t *pwszWindows); | ||
358 | |||
359 | int plibc_conv_to_win_pathwconv(const char *pszUnix, wchar_t *pwszWindows); | ||
360 | int plibc_conv_to_win_pathwconv_ex(const char *pszUnix, wchar_t *pszWindows, int derefLinks); | ||
361 | |||
345 | unsigned plibc_get_handle_count(); | 362 | unsigned plibc_get_handle_count(); |
346 | 363 | ||
347 | typedef void (*TPanicProc) (int, char *); | 364 | typedef void (*TPanicProc) (int, char *); |
@@ -360,18 +377,25 @@ const char *hstrerror(int err); | |||
360 | int mkstemp(char *tmplate); | 377 | int mkstemp(char *tmplate); |
361 | char *strptime (const char *buf, const char *format, struct tm *tm); | 378 | char *strptime (const char *buf, const char *format, struct tm *tm); |
362 | const char *inet_ntop(int af, const void *src, char *dst, size_t size); | 379 | const char *inet_ntop(int af, const void *src, char *dst, size_t size); |
380 | #ifndef gmtime_r | ||
381 | struct tm *gmtime_r(const time_t *clock, struct tm *result); | ||
382 | #endif | ||
363 | 383 | ||
364 | int plibc_init(char *pszOrg, char *pszApp); | 384 | int plibc_init(char *pszOrg, char *pszApp); |
385 | int plibc_init_utf8(char *pszOrg, char *pszApp, int utf8_mode); | ||
365 | void plibc_shutdown(); | 386 | void plibc_shutdown(); |
366 | int plibc_initialized(); | 387 | int plibc_initialized(); |
367 | int plibc_conv_to_win_path_ex(const char *pszUnix, char *pszWindows, int derefLinks); | 388 | |
368 | void _SetErrnoFromWinError(long lWinError, char *pszCaller, int iLine); | 389 | void _SetErrnoFromWinError(long lWinError, char *pszCaller, int iLine); |
369 | void SetErrnoFromWinsockError(long lWinError); | 390 | void SetErrnoFromWinsockError(long lWinError); |
370 | void SetHErrnoFromWinError(long lWinError); | 391 | void SetHErrnoFromWinError(long lWinError); |
371 | void SetErrnoFromHRESULT(HRESULT hRes); | 392 | void SetErrnoFromHRESULT(HRESULT hRes); |
372 | int GetErrnoFromWinsockError(long lWinError); | 393 | int GetErrnoFromWinsockError(long lWinError); |
373 | FILE *_win_fopen(const char *filename, const char *mode); | 394 | FILE *_win_fopen(const char *filename, const char *mode); |
395 | int _win_fclose(FILE *); | ||
374 | DIR *_win_opendir(const char *dirname); | 396 | DIR *_win_opendir(const char *dirname); |
397 | struct dirent *_win_readdir(DIR *dirp); | ||
398 | int _win_closedir(DIR *dirp); | ||
375 | int _win_open(const char *filename, int oflag, ...); | 399 | int _win_open(const char *filename, int oflag, ...); |
376 | #ifdef ENABLE_NLS | 400 | #ifdef ENABLE_NLS |
377 | char *_win_bindtextdomain(const char *domainname, const char *dirname); | 401 | char *_win_bindtextdomain(const char *domainname, const char *dirname); |
@@ -405,25 +429,56 @@ size_t _win_fread( void *buffer, size_t size, size_t count, FILE *stream ); | |||
405 | int _win_symlink(const char *path1, const char *path2); | 429 | int _win_symlink(const char *path1, const char *path2); |
406 | void *_win_mmap(void *start, size_t len, int access, int flags, int fd, | 430 | void *_win_mmap(void *start, size_t len, int access, int flags, int fd, |
407 | unsigned long long offset); | 431 | unsigned long long offset); |
432 | int _win_msync(void *start, size_t length, int flags); | ||
408 | int _win_munmap(void *start, size_t length); | 433 | int _win_munmap(void *start, size_t length); |
409 | int _win_lstat(const char *path, struct stat *buf); | 434 | int _win_lstat(const char *path, struct stat *buf); |
410 | int _win_lstat64(const char *path, struct stat64 *buf); | 435 | int _win_lstat64(const char *path, struct stat64 *buf); |
411 | int _win_readlink(const char *path, char *buf, size_t bufsize); | 436 | int _win_readlink(const char *path, char *buf, size_t bufsize); |
412 | int _win_accept(int s, struct sockaddr *addr, int *addrlen); | 437 | int _win_accept(int s, struct sockaddr *addr, int *addrlen); |
438 | |||
413 | int _win_printf(const char *format,...); | 439 | int _win_printf(const char *format,...); |
440 | int _win_wprintf(const wchar_t *format, ...); | ||
441 | |||
414 | int _win_fprintf(FILE *f,const char *format,...); | 442 | int _win_fprintf(FILE *f,const char *format,...); |
443 | int _win_fwprintf(FILE *f,const wchar_t *format, ...); | ||
444 | |||
415 | int _win_vprintf(const char *format, va_list ap); | 445 | int _win_vprintf(const char *format, va_list ap); |
446 | int _win_vfwprintf(FILE *stream, const wchar_t *format, va_list arg_ptr); | ||
447 | |||
416 | int _win_vfprintf(FILE *stream, const char *format, va_list arg_ptr); | 448 | int _win_vfprintf(FILE *stream, const char *format, va_list arg_ptr); |
449 | int _win_vwprintf(const wchar_t *format, va_list ap); | ||
450 | |||
417 | int _win_vsprintf(char *dest,const char *format, va_list arg_ptr); | 451 | int _win_vsprintf(char *dest,const char *format, va_list arg_ptr); |
452 | int _win_vswprintf(wchar_t *dest, const wchar_t *format, va_list arg_ptr); | ||
453 | |||
418 | int _win_vsnprintf(char* str, size_t size, const char *format, va_list arg_ptr); | 454 | int _win_vsnprintf(char* str, size_t size, const char *format, va_list arg_ptr); |
455 | int _win_vsnwprintf(wchar_t* wstr, size_t size, const wchar_t *format, va_list arg_ptr); | ||
456 | |||
419 | int _win_snprintf(char *str,size_t size,const char *format,...); | 457 | int _win_snprintf(char *str,size_t size,const char *format,...); |
458 | int _win_snwprintf(wchar_t *str, size_t size, const wchar_t *format, ...); | ||
459 | |||
420 | int _win_sprintf(char *dest,const char *format,...); | 460 | int _win_sprintf(char *dest,const char *format,...); |
461 | int _win_swprintf(wchar_t *dest, const wchar_t *format, ...); | ||
462 | |||
421 | int _win_vsscanf(const char* str, const char* format, va_list arg_ptr); | 463 | int _win_vsscanf(const char* str, const char* format, va_list arg_ptr); |
464 | int _win_vswscanf(const wchar_t* wstr, const wchar_t* format, va_list arg_ptr); | ||
465 | |||
422 | int _win_sscanf(const char *str, const char *format, ...); | 466 | int _win_sscanf(const char *str, const char *format, ...); |
467 | int _win_swscanf(const wchar_t *wstr, const wchar_t *format, ...); | ||
468 | |||
423 | int _win_vfscanf(FILE *stream, const char *format, va_list arg_ptr); | 469 | int _win_vfscanf(FILE *stream, const char *format, va_list arg_ptr); |
470 | int _win_vfwscanf(FILE *stream, const wchar_t *format, va_list arg_ptr); | ||
471 | |||
424 | int _win_vscanf(const char *format, va_list arg_ptr); | 472 | int _win_vscanf(const char *format, va_list arg_ptr); |
473 | int _win_vwscanf(const wchar_t *format, va_list arg_ptr); | ||
474 | |||
425 | int _win_scanf(const char *format, ...); | 475 | int _win_scanf(const char *format, ...); |
476 | int _win_wscanf(const wchar_t *format, ...); | ||
477 | |||
426 | int _win_fscanf(FILE *stream, const char *format, ...); | 478 | int _win_fscanf(FILE *stream, const char *format, ...); |
479 | int _win_fwscanf(FILE *stream, const wchar_t *format, ...); | ||
480 | |||
481 | |||
427 | pid_t _win_waitpid(pid_t pid, int *stat_loc, int options); | 482 | pid_t _win_waitpid(pid_t pid, int *stat_loc, int options); |
428 | int _win_bind(int s, const struct sockaddr *name, int namelen); | 483 | int _win_bind(int s, const struct sockaddr *name, int namelen); |
429 | int _win_connect(int s,const struct sockaddr *name, int namelen); | 484 | int _win_connect(int s,const struct sockaddr *name, int namelen); |
@@ -461,10 +516,12 @@ size_t strnlen (const char *str, size_t maxlen); | |||
461 | #endif | 516 | #endif |
462 | char *stpcpy(char *dest, const char *src); | 517 | char *stpcpy(char *dest, const char *src); |
463 | char *strcasestr(const char *haystack_start, const char *needle_start); | 518 | char *strcasestr(const char *haystack_start, const char *needle_start); |
464 | 519 | #ifndef __MINGW64__ | |
465 | #define strcasecmp(a, b) stricmp(a, b) | 520 | #define strcasecmp(a, b) stricmp(a, b) |
521 | #define wcscasecmp(a, b) wcsicmp(a, b) | ||
466 | #define strncasecmp(a, b, c) strnicmp(a, b, c) | 522 | #define strncasecmp(a, b, c) strnicmp(a, b, c) |
467 | 523 | #define wcsncasecmp(a, b, c) wcsnicmp(a, b, c) | |
524 | #endif | ||
468 | #endif /* WINDOWS */ | 525 | #endif /* WINDOWS */ |
469 | 526 | ||
470 | #ifndef WINDOWS | 527 | #ifndef WINDOWS |
@@ -482,8 +539,11 @@ char *strcasestr(const char *haystack_start, const char *needle_start); | |||
482 | #define CTIME_R(c, b) ctime_r(c, b) | 539 | #define CTIME_R(c, b) ctime_r(c, b) |
483 | #undef FOPEN | 540 | #undef FOPEN |
484 | #define FOPEN(f, m) fopen(f, m) | 541 | #define FOPEN(f, m) fopen(f, m) |
542 | #define FCLOSE(f) fclose(f) | ||
485 | #define FTRUNCATE(f, l) ftruncate(f, l) | 543 | #define FTRUNCATE(f, l) ftruncate(f, l) |
486 | #define OPENDIR(d) opendir(d) | 544 | #define OPENDIR(d) opendir(d) |
545 | #define CLOSEDIR(d) closedir(d) | ||
546 | #define READDIR(d) readdir(d) | ||
487 | #define OPEN open | 547 | #define OPEN open |
488 | #define CHDIR(d) chdir(d) | 548 | #define CHDIR(d) chdir(d) |
489 | #define CLOSE(f) close(f) | 549 | #define CLOSE(f) close(f) |
@@ -506,6 +566,8 @@ char *strcasestr(const char *haystack_start, const char *needle_start); | |||
506 | #define GN_FWRITE(b, s, c, f) fwrite(b, s, c, f) | 566 | #define GN_FWRITE(b, s, c, f) fwrite(b, s, c, f) |
507 | #define SYMLINK(a, b) symlink(a, b) | 567 | #define SYMLINK(a, b) symlink(a, b) |
508 | #define MMAP(s, l, p, f, d, o) mmap(s, l, p, f, d, o) | 568 | #define MMAP(s, l, p, f, d, o) mmap(s, l, p, f, d, o) |
569 | #define MKFIFO(p, m) mkfifo(p, m) | ||
570 | #define MSYNC(s, l, f) msync(s, l, f) | ||
509 | #define MUNMAP(s, l) munmap(s, l) | 571 | #define MUNMAP(s, l) munmap(s, l) |
510 | #define STRERROR(i) strerror(i) | 572 | #define STRERROR(i) strerror(i) |
511 | #define RANDOM() random() | 573 | #define RANDOM() random() |
@@ -575,8 +637,11 @@ char *strcasestr(const char *haystack_start, const char *needle_start); | |||
575 | #define PLIBC_CTIME(c) _win_ctime(c) | 637 | #define PLIBC_CTIME(c) _win_ctime(c) |
576 | #define CTIME_R(c, b) _win_ctime_r(c, b) | 638 | #define CTIME_R(c, b) _win_ctime_r(c, b) |
577 | #define FOPEN(f, m) _win_fopen(f, m) | 639 | #define FOPEN(f, m) _win_fopen(f, m) |
640 | #define FCLOSE(f) _win_fclose(f) | ||
578 | #define FTRUNCATE(f, l) _win_ftruncate(f, l) | 641 | #define FTRUNCATE(f, l) _win_ftruncate(f, l) |
579 | #define OPENDIR(d) _win_opendir(d) | 642 | #define OPENDIR(d) _win_opendir(d) |
643 | #define CLOSEDIR(d) _win_closedir(d) | ||
644 | #define READDIR(d) _win_readdir(d) | ||
580 | #define OPEN _win_open | 645 | #define OPEN _win_open |
581 | #define CHDIR(d) _win_chdir(d) | 646 | #define CHDIR(d) _win_chdir(d) |
582 | #define CLOSE(f) _win_close(f) | 647 | #define CLOSE(f) _win_close(f) |
@@ -601,6 +666,8 @@ char *strcasestr(const char *haystack_start, const char *needle_start); | |||
601 | #define GN_FWRITE(b, s, c, f) _win_fwrite(b, s, c, f) | 666 | #define GN_FWRITE(b, s, c, f) _win_fwrite(b, s, c, f) |
602 | #define SYMLINK(a, b) _win_symlink(a, b) | 667 | #define SYMLINK(a, b) _win_symlink(a, b) |
603 | #define MMAP(s, l, p, f, d, o) _win_mmap(s, l, p, f, d, o) | 668 | #define MMAP(s, l, p, f, d, o) _win_mmap(s, l, p, f, d, o) |
669 | #define MKFIFO(p, m) _win_mkfifo(p, m) | ||
670 | #define MSYNC(s, l, f) _win_msync(s, l, f) | ||
604 | #define MUNMAP(s, l) _win_munmap(s, l) | 671 | #define MUNMAP(s, l) _win_munmap(s, l) |
605 | #define STRERROR(i) _win_strerror(i) | 672 | #define STRERROR(i) _win_strerror(i) |
606 | #define READLINK(p, b, s) _win_readlink(p, b, s) | 673 | #define READLINK(p, b, s) _win_readlink(p, b, s) |