ReactOS 0.4.15-dev-7906-g1b85a5f
compat.c
Go to the documentation of this file.
1/*
2 compat: Some compatibility functions (basic memory & string stuff in separate file)
3
4 The mpg123 code is determined to keep it's legacy. A legacy of old, old UNIX.
5 So anything possibly somewhat advanced should be considered to be put here, with proper #ifdef;-)
6
7 copyright 2007-2016 by the mpg123 project - free software under the terms of the LGPL 2.1
8 see COPYING and AUTHORS files in distribution or http://mpg123.org
9 initially written by Thomas Orgis, Windows Unicode stuff by JonY.
10*/
11
12#include "config.h"
13/* This source file does need _POSIX_SOURCE to get some sigaction. */
14#define _POSIX_SOURCE
15#include "compat.h"
16
17#ifdef _MSC_VER
18#include <io.h>
19
20#if(defined(WINAPI_FAMILY) && (WINAPI_FAMILY==WINAPI_FAMILY_APP))
21#define WINDOWS_UWP
22#endif
23
24#endif
25#ifdef HAVE_SYS_STAT_H
26# include <sys/stat.h>
27#endif
28#ifdef HAVE_DIRENT_H
29# include <dirent.h>
30#endif
31
32/* Win32 is only supported with unicode now. These headers also cover
33 module stuff. The WANT_WIN32_UNICODE macro is synonymous with
34 "want windows-specific API, and only the unicode variants of which". */
35#ifdef WANT_WIN32_UNICODE
36#include <wchar.h>
37#include <windows.h>
38#include <winnls.h>
39#include <shlwapi.h>
40#endif
41
42#ifdef USE_MODULES
43# ifdef HAVE_DLFCN_H
44# include <dlfcn.h>
45# endif
46#endif
47
48#include "debug.h"
49
50#ifndef WINDOWS_UWP
51
52char *compat_getenv(const char* name)
53{
54 char *ret = NULL;
55#ifdef WANT_WIN32_UNICODE
56 wchar_t *env;
57 wchar_t *wname = NULL;
58 if(win32_utf8_wide(name, &wname, NULL) > 0)
59 {
60 env = _wgetenv(wname);
61 free(wname);
62 if(env)
64 }
65#else
66 ret = getenv(name);
67 if(ret)
69#endif
70 return ret;
71}
72
73#ifdef WANT_WIN32_UNICODE
74
75/* Convert unix UTF-8 (or ASCII) paths to Windows wide character paths. */
76static wchar_t* u2wpath(const char *upath)
77{
78 wchar_t* wpath, *p;
79 if(!upath || win32_utf8_wide(upath, &wpath, NULL) < 1)
80 return NULL;
81 for(p=wpath; *p; ++p)
82 if(*p == L'/')
83 *p = L'\\';
84 return wpath;
85}
86
87/* Convert Windows wide character paths to unix UTF-8. */
88static char* w2upath(const wchar_t *wpath)
89{
90 char* upath, *p;
91 if(!wpath || win32_wide_utf8(wpath, &upath, NULL) < 1)
92 return NULL;
93 for(p=upath; *p; ++p)
94 if(*p == '\\')
95 *p = '/';
96 return upath;
97}
98
99/* An absolute path that is too long and not already marked with
100 \\?\ can be marked as a long one and still work. */
101static int wpath_need_elongation(wchar_t *wpath)
102{
103 if( wpath && !PathIsRelativeW(wpath)
104 && wcslen(wpath) > MAX_PATH-1
105 && wcsncmp(L"\\\\?\\", wpath, 4) )
106 return 1;
107 else
108 return 0;
109}
110
111/* Take any wide windows path and turn it into a path that is allowed
112 to be longer than MAX_PATH, if it is not already. */
113static wchar_t* wlongpath(wchar_t *wpath)
114{
115 size_t len, plen;
116 const wchar_t *prefix = L"";
117 wchar_t *wlpath = NULL;
118 if(!wpath)
119 return NULL;
120
121 /* Absolute paths that do not start with \\?\ get that prepended
122 to allow them being long. */
123 if(!PathIsRelativeW(wpath) && wcsncmp(L"\\\\?\\", wpath, 4))
124 {
125 if(wcslen(wpath) >= 2 && PathIsUNCW(wpath))
126 {
127 /* \\server\path -> \\?\UNC\server\path */
128 prefix = L"\\\\?\\UNC";
129 ++wpath; /* Skip the first \. */
130 }
131 else /* c:\some/path -> \\?\c:\some\path */
132 prefix = L"\\\\?\\";
133 }
134 plen = wcslen(prefix);
135 len = plen + wcslen(wpath);
136 wlpath = malloc(len+1*sizeof(wchar_t));
137 if(wlpath)
138 {
139 /* Brute force memory copying, swprintf is too dandy. */
140 memcpy(wlpath, prefix, sizeof(wchar_t)*plen);
141 memcpy(wlpath+plen, wpath, sizeof(wchar_t)*(len-plen));
142 wlpath[len] = 0;
143 }
144 return wlpath;
145}
146
147/* Convert unix path to wide windows path, optionally marking
148 it as long path if necessary. */
149static wchar_t* u2wlongpath(const char *upath)
150{
151 wchar_t *wpath = NULL;
152 wchar_t *wlpath = NULL;
153 wpath = u2wpath(upath);
154 if(wpath_need_elongation(wpath))
155 {
156 wlpath = wlongpath(wpath);
157 free(wpath);
158 wpath = wlpath;
159 }
160 return wpath;
161}
162
163#endif
164
165#else
166
167static wchar_t* u2wlongpath(const char *upath)
168{
169 wchar_t* wpath, *p;
170 if (!upath || win32_utf8_wide(upath, &wpath, NULL) < 1)
171 return NULL;
172 for (p = wpath; *p; ++p)
173 if (*p == L'/')
174 *p = L'\\';
175 return wpath;
176}
177
178#endif
179
180/* Always add a default permission mask in case of flags|O_CREAT. */
181int compat_open(const char *filename, int flags)
182{
183 int ret;
184#if defined (WANT_WIN32_UNICODE)
185 wchar_t *frag = NULL;
186
187 frag = u2wlongpath(filename);
188 /* Fallback to plain open when ucs-2 conversion fails */
189 if(!frag)
190 goto open_fallback;
191
192 /*Try _wopen */
194 if(ret != -1 )
195 goto open_ok; /* msdn says -1 means failure */
196
197open_fallback:
198#endif
199
200#if (defined(WIN32) && !defined (__CYGWIN__))
201 /* MSDN says POSIX function is deprecated beginning in Visual C++ 2005 */
202 /* Try plain old _open(), if it fails, do nothing */
204#else
206#endif
207
208#if defined (WANT_WIN32_UNICODE)
209open_ok:
210 free(frag);
211#endif
212
213 return ret;
214}
215
216/* Moved over from wav.c, logic with fallbacks added from the
217 example of compat_open(). */
218FILE* compat_fopen(const char *filename, const char *mode)
219{
220 FILE* stream = NULL;
221#ifdef WANT_WIN32_UNICODE
222 int cnt = 0;
223 wchar_t *wname = NULL;
224 wchar_t *wmode = NULL;
225
226 wname = u2wlongpath(filename);
227 if(!wname)
228 goto fopen_fallback;
229 cnt = win32_utf8_wide(mode, &wmode, NULL);
230 if( (wmode == NULL) || (cnt == 0))
231 goto fopen_fallback;
232
233 stream = _wfopen(wname, wmode);
234 if(stream) goto fopen_ok;
235
236fopen_fallback:
237#endif
239#ifdef WANT_WIN32_UNICODE
240
241fopen_ok:
242 free(wmode);
243 free(wname);
244#endif
245 return stream;
246}
247
248FILE* compat_fdopen(int fd, const char *mode)
249{
250 return fdopen(fd, mode);
251}
252
253int compat_close(int infd)
254{
255#if (defined(WIN32) && !defined (__CYGWIN__)) /* MSDN says POSIX function is deprecated beginning in Visual C++ 2005 */
256 return _close(infd);
257#else
258 return close(infd);
259#endif
260}
261
263{
264 return fclose(stream);
265}
266
267/* Windows Unicode stuff */
268
269#ifdef WANT_WIN32_UNICODE
270int win32_wide_utf8(const wchar_t * const wptr, char **mbptr, size_t * buflen)
271{
272 size_t len;
273 char *buf;
274 int ret = 0;
275
276 len = WideCharToMultiByte(CP_UTF8, 0, wptr, -1, NULL, 0, NULL, NULL); /* Get utf-8 string length */
277 buf = calloc(len + 1, sizeof (char)); /* Can we assume sizeof char always = 1? */
278
279 if(!buf) len = 0;
280 else {
281 if (len != 0) ret = WideCharToMultiByte(CP_UTF8, 0, wptr, -1, buf, len, NULL, NULL); /*Do actual conversion*/
282 buf[len] = '0'; /* Must terminate */
283 }
284 *mbptr = buf; /* Set string pointer to allocated buffer */
285 if(buflen != NULL) *buflen = (len) * sizeof (char); /* Give length of allocated memory if needed. */
286 return ret;
287}
288
289int win32_utf8_wide(const char *const mbptr, wchar_t **wptr, size_t *buflen)
290{
291 size_t len;
292 wchar_t *buf;
293 int ret = 0;
294
295 len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, mbptr, -1, NULL, 0); /* Get converted size */
296 buf = calloc(len + 1, sizeof (wchar_t)); /* Allocate memory accordingly */
297
298 if(!buf) len = 0;
299 else {
300 if (len != 0) ret = MultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS, mbptr, -1, buf, len); /* Do conversion */
301 buf[len] = L'0'; /* Must terminate */
302 }
303 *wptr = buf; /* Set string pointer to allocated buffer */
304 if (buflen != NULL) *buflen = len * sizeof (wchar_t); /* Give length of allocated memory if needed. */
305 return ret; /* Number of characters written */
306}
307#endif
308
309#ifndef WINDOWS_UWP
310
311/*
312 The Windows file and path stuff is an extract of jon_y's win32 loader
313 prototype from the loader_rework branch. It's been divided in to
314 reusable functons by ThOr in the hope to work out some generic-looking
315 loader code for both POSIX and Windows. The routines might be
316 helpful for consistent path work in other parts of mpg123, too.
317
318 This all is about getting some working code on a wide range of
319 systems while staying somewhat sane. If it does ridiculously inefficient
320 things with extraneous copies and grabbing of functions that made
321 it late to some official APIs, that's still fine with us.
322*/
323
324char* compat_catpath(const char *prefix, const char* path)
325{
326 char *ret = NULL;
327#ifdef WANT_WIN32_UNICODE
328 wchar_t *wprefix = NULL; /* Wide windows versions of */
329 wchar_t *wpath = NULL; /* input arguments. */
330 wchar_t *locwret = NULL; /* Tmp return value from LocalAlloc */
331 /*
332 This variation of combinepath can work with long and UNC paths, but
333 is not officially exposed in any DLLs, It also allocates all its buffers
334 internally via LocalAlloc, avoiding buffer overflow problems.
335 ThOr: I presume this hack is for supporting pre-8 Windows, as
336 from Windows 8 on, this is documented in the API.
337 */
338 HRESULT (__stdcall *mypac)( const wchar_t *in, const wchar_t* more
339 , unsigned long flags, wchar_t **out ) = NULL;
340 HMODULE pathcch = NULL;
341
342 if(!prefix && !path)
343 goto catpath_end;
344 wprefix = u2wpath(prefix);
345 wpath = u2wpath(path);
346 if((prefix && !wprefix) || (path && !wpath))
347 goto catpath_end;
348
349 /* Again: I presume this whole fun is to get at PathAllocCombine
350 even when pathcch.h is not available (like in MinGW32). */
351 if( (pathcch = GetModuleHandleA("kernelbase")) )
352 mypac = (void *)GetProcAddress(pathcch, "PathAllocCombine");
353 if(mypac) /* PATHCCH_ALLOW_LONG_PATH = 1 per API docs */
354 {
355 debug("Actually calling PathAllocCombine!");
356 mypac(wprefix, wpath, 1, &locwret);
357 }
358 else
359 {
360 /* Playing safe, if we'd care much about performance, this would be on
361 the stack. */
362 locwret = LocalAlloc(LPTR, sizeof(wchar_t)*MAX_PATH);
363 if(locwret)
364 PathCombineW(locwret, wprefix, wpath);
365 }
366 ret = w2upath(locwret);
367
368catpath_end:
369 LocalFree(locwret);
370 free(wprefix);
371 free(wpath);
372#else
373 size_t len, prelen, patlen;
374
375 if(path && path[0] == '/')
376 prefix = NULL; /* Absolute path stays as it is. */
377 prelen = prefix ? strlen(prefix) : 0;
378 patlen = path ? strlen(path) : 0;
379 /* Concatenate the two, put a / in between if both present. */
380 len = ((prefix && path) ? 1 : 0) + prelen + patlen;
381 ret = malloc(len+1);
382 if(ret)
383 {
384 size_t off=0;
385 memcpy(ret, prefix, prelen);
386 if(prefix && path)
387 ret[prelen+(off++)] = '/';
388 memcpy(ret+prelen+off, path, patlen);
389 ret[len] = 0;
390 }
391#endif
392 return ret;
393}
394
395int compat_isdir(const char *path)
396{
397 int ret = 0;
398#ifdef WANT_WIN32_UNICODE
399 wchar_t *wpath;
400 wpath = u2wlongpath(path);
401 if(wpath)
402 {
405 ret=1;
406 free(wpath);
407 }
408#else
409 struct stat sb;
410 if(path && !stat(path, &sb))
411 {
412 if(S_ISDIR(sb.st_mode))
413 ret=1;
414 }
415#endif
416 return ret;
417}
418
420{
421 char *path;
422#ifdef WANT_WIN32_UNICODE
423 int gotone; /* Got a result stored from FindFirstFileW. */
425 HANDLE ffn;
426#else
428#endif
429};
430
432{
433 struct compat_dir *cd;
434 if(!path)
435 return NULL;
436 cd = malloc(sizeof(*cd));
437 if(!cd)
438 return NULL;
439#ifdef WANT_WIN32_UNICODE
440 cd->gotone = 0;
441 {
442 char *pattern;
443 wchar_t *wpattern;
445 wpattern = u2wlongpath(pattern);
446 if(wpattern)
447 {
448 cd->ffn = FindFirstFileW(wpattern, &(cd->d));
449 if(cd->ffn == INVALID_HANDLE_VALUE)
450 {
451 /* FindClose() only needed after successful first find, right? */
452 free(cd);
453 cd = NULL;
454 }
455 else
456 cd->gotone = 1;
457 }
458 free(wpattern);
459 free(pattern);
460 }
461#else
462 cd->dir = opendir(path);
463 if(!cd->dir)
464 {
465 free(cd);
466 cd = NULL;
467 }
468#endif
469 if(cd)
470 {
471 cd->path = compat_strdup(path);
472 if(!cd->path)
473 {
475 cd = NULL;
476 }
477 }
478 return cd;
479}
480
482{
483 if(cd)
484 {
485 free(cd->path);
486#ifdef WANT_WIN32_UNICODE
487 FindClose(cd->ffn);
488#else
489 closedir(cd->dir);
490#endif
491 free(cd);
492 }
493}
494
496{
497 if(!cd)
498 return NULL;
499#ifdef WANT_WIN32_UNICODE
500 while(cd->gotone || FindNextFileW(cd->ffn, &(cd->d)))
501 {
502 cd->gotone = 0;
503 if(!(cd->d.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
504 {
505 char *ret;
506 win32_wide_utf8(cd->d.cFileName, &ret, NULL);
507 return ret;
508 }
509 }
510#else
511 {
512 struct dirent *dp;
513 while((dp = readdir(cd->dir)))
514 {
515 struct stat fst;
516 char *fullpath = compat_catpath(cd->path, dp->d_name);
517 if(fullpath && !stat(fullpath, &fst) && S_ISREG(fst.st_mode))
518 {
519 free(fullpath);
520 return compat_strdup(dp->d_name);
521 }
522 free(fullpath);
523 }
524 }
525#endif
526 return NULL;
527}
528
530{
531 if(!cd)
532 return NULL;
533#ifdef WANT_WIN32_UNICODE
534 while(cd->gotone || FindNextFileW(cd->ffn, &(cd->d)))
535 {
536 cd->gotone = 0;
537 if(cd->d.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
538 {
539 char *ret;
540 win32_wide_utf8(cd->d.cFileName, &ret, NULL);
541 return ret;
542 }
543 }
544#else
545 {
546 struct dirent *dp;
547 while((dp = readdir(cd->dir)))
548 {
549 struct stat fst;
550 char *fullpath = compat_catpath(cd->path, dp->d_name);
551 if(fullpath && !stat(fullpath, &fst) && S_ISDIR(fst.st_mode))
552 {
553 free(fullpath);
554 return compat_strdup(dp->d_name);
555 }
556 free(fullpath);
557 }
558 }
559#endif
560 return NULL;
561}
562
563#endif
564
565#ifdef USE_MODULES
566/*
567 This is what I expected the platform-specific dance for dynamic module
568 support to be. Little did I know about the peculiarities of (long)
569 paths and directory/file search on Windows.
570*/
571
572void *compat_dlopen(const char *path)
573{
574 void *handle = NULL;
575#ifdef WANT_WIN32_UNICODE
576 wchar_t *wpath;
577 wpath = u2wlongpath(path);
578 if(wpath)
579 handle = LoadLibraryW(wpath);
580 free(wpath);
581#else
582 handle = dlopen(path, RTLD_NOW);
583#endif
584 return handle;
585}
586
587void *compat_dlsym(void *handle, const char *name)
588{
589 void *sym = NULL;
590 if(!handle)
591 return NULL;
592#ifdef WANT_WIN32_UNICODE
593 sym = GetProcAddress(handle, name);
594#else
595 sym = dlsym(handle, name);
596#endif
597 return sym;
598}
599
600void compat_dlclose(void *handle)
601{
602 if(!handle)
603 return;
604#ifdef WANT_WIN32_UNICODE
606#else
607 dlclose(handle);
608#endif
609}
610
611#endif /* USE_MODULES */
612
613
614/* This shall survive signals and any return value less than given byte count
615 is an error */
616size_t unintr_write(int fd, void const *buffer, size_t bytes)
617{
618 size_t written = 0;
619 while(bytes)
620 {
621 ssize_t part = write(fd, (char*)buffer+written, bytes);
622 if(part < 0 && errno != EINTR)
623 break;
624 bytes -= part;
625 written += part;
626 }
627 return written;
628}
629
630/* Same for reading the data. */
631size_t unintr_read(int fd, void *buffer, size_t bytes)
632{
633 size_t got = 0;
634 while(bytes)
635 {
636 ssize_t part = read(fd, (char*)buffer+got, bytes);
637 if(part < 0 && errno != EINTR)
638 break;
639 bytes -= part;
640 got += part;
641 }
642 return got;
643}
644
645#ifndef NO_CATCHSIGNAL
646#if (!defined(WIN32) || defined (__CYGWIN__)) && defined(HAVE_SIGNAL_H)
647void (*catchsignal(int signum, void(*handler)()))()
648{
649 struct sigaction new_sa;
650 struct sigaction old_sa;
651
652#ifdef DONT_CATCH_SIGNALS
653 fprintf (stderr, "Not catching any signals.\n");
654 return ((void (*)()) -1);
655#endif
656
657 new_sa.sa_handler = handler;
658 sigemptyset(&new_sa.sa_mask);
659 new_sa.sa_flags = 0;
660 if(sigaction(signum, &new_sa, &old_sa) == -1)
661 return ((void (*)()) -1);
662 return (old_sa.sa_handler);
663}
664#endif
665#endif
InitDirComponents & cd
#define EINTR
Definition: acclib.h:80
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define stat
Definition: acwin.h:99
#define read
Definition: acwin.h:96
#define open
Definition: acwin.h:95
#define close
Definition: acwin.h:98
#define write
Definition: acwin.h:97
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
#define S_ISDIR(mode)
Definition: various.h:18
#define S_ISREG(mode)
Definition: various.h:17
static LPCWSTR LPCWSTR LPCWSTR env
Definition: db.cpp:170
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define _O_BINARY
Definition: cabinet.h:51
#define _S_IWRITE
Definition: cabinet.h:33
#define _S_IREAD
Definition: cabinet.h:34
#define GetProcAddress(x, y)
Definition: compat.h:753
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define FreeLibrary(x)
Definition: compat.h:748
#define MAX_PATH
Definition: compat.h:34
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
#define LoadLibraryW(x)
Definition: compat.h:747
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7482
BOOL WINAPI PathIsUNCW(LPCWSTR lpszPath)
Definition: path.c:2266
BOOL WINAPI PathIsRelativeW(LPCWSTR lpszPath)
Definition: path.c:1579
superblock * sb
Definition: btrfs.c:4261
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint buffer
Definition: glext.h:5915
GLubyte * pattern
Definition: glext.h:7787
GLenum mode
Definition: glext.h:6217
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint in
Definition: glext.h:9616
GLbitfield flags
Definition: glext.h:7161
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define MB_ERR_INVALID_CHARS
Definition: unicode.h:41
int __cdecl closedir(DIR *)
DIR *__cdecl opendir(const char *)
struct dirent *__cdecl readdir(DIR *)
#define stderr
Definition: stdio.h:100
_Check_return_ _CRTIMP FILE *__cdecl _wfopen(_In_z_ const wchar_t *_Filename, _In_z_ const wchar_t *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_ _CRTIMP FILE *__cdecl fdopen(_In_ int _FileHandle, _In_z_ const char *_Format)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP wchar_t *__cdecl _wgetenv(_In_z_ const wchar_t *_VarName)
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define win32_utf8_wide
Definition: intsym.h:19
#define compat_fclose
Definition: intsym.h:17
#define compat_dlsym
Definition: intsym.h:27
#define compat_close
Definition: intsym.h:16
#define compat_isdir
Definition: intsym.h:21
#define unintr_read
Definition: intsym.h:30
#define compat_dirclose
Definition: intsym.h:23
#define compat_nextfile
Definition: intsym.h:24
#define compat_dlclose
Definition: intsym.h:28
#define compat_strdup
Definition: intsym.h:11
#define compat_nextdir
Definition: intsym.h:25
#define unintr_write
Definition: intsym.h:29
#define compat_dlopen
Definition: intsym.h:26
#define compat_diropen
Definition: intsym.h:22
#define compat_getenv
Definition: intsym.h:12
#define compat_catpath
Definition: intsym.h:20
#define compat_fopen
Definition: intsym.h:14
#define compat_fdopen
Definition: intsym.h:15
#define compat_open
Definition: intsym.h:13
#define catchsignal
Definition: intsym.h:9
#define win32_wide_utf8
Definition: intsym.h:18
const char * filename
Definition: ioapi.h:137
#define d
Definition: ke_i.h:81
#define debug(msg)
Definition: key_call.c:71
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define RTLD_NOW
Definition: port.h:100
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define L(x)
Definition: ntvdm.h:50
#define PathCombineW
Definition: pathcch.h:317
#define S_IROTH
Definition: propsheet.h:53
#define S_IRGRP
Definition: propsheet.h:41
#define S_IWOTH
Definition: propsheet.h:57
#define S_IRUSR
Definition: propsheet.h:29
#define S_IWUSR
Definition: propsheet.h:33
#define S_IWGRP
Definition: propsheet.h:45
static FILE * out
Definition: regtests2xml.c:44
int ssize_t
Definition: rosdhcp.h:48
#define calloc
Definition: rosglue.h:14
#define errno
Definition: errno.h:18
_Check_return_opt_ _CRTIMP int __cdecl _close(_In_ int _FileHandle)
_CRTIMP int __cdecl _wopen(const wchar_t *_Filename, int _OpenFlag,...)
Definition: file.c:2020
_CRTIMP int __cdecl _open(const char *_Filename, int _OpenFlag,...)
Definition: file.c:2001
_Check_return_ _CRTIMP int __cdecl wcsncmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define CP_UTF8
Definition: nls.h:20
static int fd
Definition: io.c:51
Definition: dirent.h:40
Definition: cookie.c:202
DIR * dir
Definition: compat.c:427
char * path
Definition: compat.c:421
Definition: fatfs.h:198
char * d_name
Definition: dirent.h:29
Definition: name.c:39
Definition: stat.h:55
unsigned short st_mode
Definition: stat.h:58
Definition: parse.h:23
#define wchar_t
Definition: wchar.h:102
#define __stdcall
Definition: typedefs.h:25
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
int ret
#define LPTR
Definition: winbase.h:381
#define HRESULT
Definition: msvc.h:7