• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <windows.h>
2 #include <malloc.h>
3 #include <time.h>
4 #include <errno.h>
5 #include <msvcrt.h>
6 
7 static errno_t __cdecl _int_wasctime_s (wchar_t *, size_t, const struct tm *);
8 static errno_t __cdecl _stub (wchar_t *, size_t, const struct tm *);
9 
10 errno_t __cdecl (*__MINGW_IMP_SYMBOL(_wasctime_s))(wchar_t *, size_t, const struct tm *) =
11  _stub;
12 
13 static errno_t __cdecl
_stub(wchar_t * d,size_t dn,const struct tm * pt)14 _stub (wchar_t *d, size_t dn, const struct tm *pt)
15 {
16   errno_t __cdecl (*f)(wchar_t *, size_t, const struct tm *) = __MINGW_IMP_SYMBOL(_wasctime_s);
17 
18   if (f == _stub)
19     {
20 	f = (errno_t __cdecl (*)(wchar_t *, size_t, const struct tm *))
21 	    GetProcAddress (__mingw_get_msvcrt_handle (), "_wasctime_s");
22 	if (!f)
23 	  f = _int_wasctime_s;
24 	__MINGW_IMP_SYMBOL(_wasctime_s) = f;
25     }
26   return (*f)(d, dn, pt);
27 }
28 
29 errno_t __cdecl
_wasctime_s(wchar_t * d,size_t dn,const struct tm * pt)30 _wasctime_s (wchar_t *d, size_t dn, const struct tm *pt)
31 {
32   return _stub (d, dn, pt);
33 }
34 
35 static errno_t __cdecl
_int_wasctime_s(wchar_t * d,size_t dn,const struct tm * pt)36 _int_wasctime_s (wchar_t *d, size_t dn, const struct tm *pt)
37 {
38   wchar_t *tmp;
39   size_t i;
40 
41   if (d && dn)
42     d[0] = 0;
43   if (!d || dn < 26 || !pt || (tmp = _wasctime (pt)) == NULL)
44      {
45         errno = EINVAL;
46 	return EINVAL;
47      }
48   for (i = 0; tmp[i] != 0; i++)
49     d[i] = tmp[i];
50   d[i] = 0;
51   return 0;
52 }
53