File: win_patch.h

package info (click to toggle)
haskell-unix-time 0.4.15-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 280 kB
  • sloc: ansic: 1,373; haskell: 260; makefile: 4
file content (175 lines) | stat: -rw-r--r-- 3,944 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#ifndef UNIX_TIME_WIN_PATCH_H
#define UNIX_TIME_WIN_PATCH_H

#include "config.h"

#include <sys/cdefs.h>

#include <time.h>
#include <ctype.h>
#include <errno.h>
#include <locale.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>

#if defined(_WIN32)
#include <windows.h>
#endif

#if !defined(TM_YEAR_BASE)
#define TM_YEAR_BASE 1900
#endif

#if !defined(TM_SUNDAY)
#define TM_SUNDAY   0
#endif

#if !defined(TM_MONDAY)
#define TM_MONDAY   1
#endif

#if !defined(DAYSPERLYEAR)
#define DAYSPERLYEAR    366
#endif

#if !defined(SECSPERMIN)
#define SECSPERMIN  60
#endif

#if !defined(MINSPERHOUR)
#define MINSPERHOUR 60
#endif

#if !defined(HOURSPERDAY)
#define HOURSPERDAY 24
#endif

#if !defined(TM_YEAR_BASE)
#define TM_YEAR_BASE    1900
#endif

#if !defined(MONSPERYEAR)
#define MONSPERYEAR 12
#endif

#if !defined(DAYSPERWEEK)
#define DAYSPERWEEK 7
#endif

#if !defined(DAYSPERNYEAR)
#define DAYSPERNYEAR    365
#endif

#ifndef TYPE_BIT
#define TYPE_BIT(type)  (sizeof (type) * CHAR_BIT)
#endif /* !defined TYPE_BIT */

#ifndef TYPE_SIGNED
#define TYPE_SIGNED(type) (((type) -1) < 0)
#endif /* !defined TYPE_SIGNED */

#ifndef INT_STRLEN_MAXIMUM
/*
** 302 / 1000 is log10(2.0) rounded up.
** Subtract one for the sign bit if the type is signed;
** add one for integer division truncation;
** add one more for a minus sign if the type is signed.
*/
#define INT_STRLEN_MAXIMUM(type) \
    ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + \
    1 + TYPE_SIGNED(type))
#endif /* !defined INT_STRLEN_MAXIMUM */

#if HAVE__ISSPACE_L
#define isspace_l _isspace_l
#else
#define isspace_l(ch, locale) isspace(ch)
#endif

#if HAVE__ISUPPER_L
#define isupper_l _isupper_l
#else
#define isupper_l(ch, locale) isupper(ch)
#endif

#if HAVE__ISDIGIT_L
#define isdigit_l _isdigit_l
#else
#define isdigit_l(ch, locale) isdigit(ch)
#endif

#if !HAVE_STRTOL_L
long strtol_l(const char *nptr, char **endptr, int base, _locale_t locale);
#endif

#if !HAVE_STRTOLL_L
long long strtoll_l(const char *nptr, char **endptr, int base, _locale_t locale);
#endif

#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))

#ifndef isleap_sum
/*
** See tzfile.h for details on isleap_sum.
*/
#define isleap_sum(a, b)    isleap((a) % 400 + (b) % 400)
#endif /* !defined isleap_sum */

#if HAVE__ISBLANK_L
#define isblank_l _isblank_l
// Needed to avoid -Wimplicit-function-declaration warnings
int _isblank_l(int c, _locale_t  loc);
#else
int isblank_l( int c, _locale_t _loc);
#endif

int strncasecmp_l(const char *s1, const char *s2, int len, _locale_t _loc);

struct tm *gmtime_r(const time_t *_time_t, struct tm *_tm);

struct tm *localtime_r(const time_t *_time_t, struct tm *_tm);

#if HAVE_DECL__MKGMTIME
#define timegm _mkgmtime
#define HAVE_TIMEGM 1
#endif

#define fprintf_l(fp, loc, ...) fprintf(fp, ##__VA_ARGS__)
#define sprintf_l(buf, loc, ...) sprintf(buf, ##__VA_ARGS__)

struct lc_time_T {
    const char  *mon[12];
    const char  *month[12];
    const char  *wday[7];
    const char  *weekday[7];
    const char  *X_fmt;
    const char  *x_fmt;
    const char  *c_fmt;
    const char  *am;
    const char  *pm;
    const char  *date_fmt;
    const char  *alt_month[12];
    const char  *md_order;
    const char  *ampm_fmt;
};

extern const struct lc_time_T   _C_time_locale;

int _patch_setenv(const char *var, const char *val, int ovr);

int _patch_unsetenv(const char *name);

size_t _patch_strftime(char * __restrict s, size_t maxsize, const char * __restrict format,
    const struct tm * __restrict t);

size_t _patch_strftime_l(char * __restrict s, size_t maxsize, const char * __restrict format,
    const struct tm * __restrict t, _locale_t loc);

char *strptime_l(const char * __restrict buf, const char * __restrict fmt,
    struct tm * __restrict tm, _locale_t loc);

char *strptime(const char * __restrict buf, const char * __restrict fmt,
    struct tm * __restrict tm);

#endif // UNIX_TIME_WIN_PATCH_H