• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <windows.h>
2 #include <malloc.h>
3 #include <errno.h>
4 #include <msvcrt.h>
5 #include <sec_api/wchar_s.h>
6 
7 static errno_t __cdecl _int_waccess_s (const wchar_t *, int);
8 static errno_t __cdecl _stub (const wchar_t *, int);
9 
10 errno_t __cdecl (*__MINGW_IMP_SYMBOL(_waccess_s))(const wchar_t *, int) =
11  _stub;
12 
13 static errno_t __cdecl
_stub(const wchar_t * s,int m)14 _stub (const wchar_t *s, int m)
15 {
16   errno_t __cdecl (*f)(const wchar_t *, int) = __MINGW_IMP_SYMBOL(_waccess_s);
17 
18   if (f == _stub)
19     {
20 	f = (errno_t __cdecl (*)(const wchar_t *, int))
21 	    GetProcAddress (__mingw_get_msvcrt_handle (), "_waccess_s");
22 	if (!f)
23 	  f = _int_waccess_s;
24 	__MINGW_IMP_SYMBOL(_waccess_s) = f;
25     }
26   return (*f)(s, m);
27 }
28 
29 errno_t __cdecl
_waccess_s(const wchar_t * s,int m)30 _waccess_s (const wchar_t *s, int m)
31 {
32   return _stub (s, m);
33 }
34 
35 static errno_t __cdecl
_int_waccess_s(const wchar_t * s,int m)36 _int_waccess_s (const wchar_t *s, int m)
37 {
38   if (!s || (m & ~6) != 0)
39     {
40       _waccess (NULL, m);
41       return EINVAL;
42     }
43   if (!_waccess (s, m))
44     return 0;
45   return errno;
46 }
47