Merge branch 'ical'
[alpine.git] / include / system.h
blob36c87445ade305b8f485e331ee24d74e8f4f97a3
1 /*----------------------------------------------------------------------
2 $Id: system.h 776 2007-10-24 23:14:26Z hubert@u.washington.edu $
3 ----------------------------------------------------------------------*/
5 /* ========================================================================
6 * Copyright 2006-2007 University of Washington
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * ========================================================================
18 * System-Specific includes, macros and prototypes based on config.h definitions
22 #ifndef _SYSTEM_INCLUDED
23 #define _SYSTEM_INCLUDED
25 #ifndef _WINDOWS
26 #include "config.h"
27 #else
28 #include "config.wnt.h"
29 #endif
31 #include <stdio.h>
33 #ifdef HAVE_UNISTD_H
34 # include <unistd.h>
35 #endif
37 #ifdef HAVE_CTYPE_H
38 # include <ctype.h>
39 #endif
41 #ifdef STDC_HEADERS
42 # include <stdlib.h>
44 # if HAVE_STRING_H
45 # include <string.h>
46 # endif
48 # if HAVE_STRINGS_H
49 # include <strings.h>
50 # endif
52 # if HAVE_WCHAR_H
53 # include <wchar.h>
54 # endif
56 # include <stdarg.h>
58 #else
59 void *malloc (size_t);
60 void *realloc (void *, size_t);
61 void free (void *);
62 size_t strlen (const char *);
63 int strcmp (const char *, const char *);
64 char *strcpy (char *, const char *);
65 char *strcat (char *, const char *);
66 char *strtok (char *, const char *);
67 # ifndef HAVE_STRCHR
68 # warn "No strchr(); trying to use index() instead."
69 # define strchr index
70 # define strrchr rindex
71 # endif
72 # ifndef HAVE_STRDUP
73 # error "C library missing strdup()!"
74 # endif
75 char *strdup (const char *);
76 char *strstr (const char *, const char *);
77 # ifdef HAVE_MEMORY_H
78 # include <memory.h>
79 # else
80 # ifdef HAVE_MEMCPY
81 void *memcpy(void *, const void *, size_t);
82 void *memmove(void *, const void *, size_t);
83 void *memset(void *, int, size_t);
84 # else
85 # define memcpy(d, s, n) bcopy ((s), (d), (n))
86 # define memmove(d, s, n) bcopy ((s), (d), (n))
87 # define memset(d, c, n) bzero ((d), (n))
88 # endif
89 # endif
90 #endif
92 /* Set System Collator */
93 #if HAVE_STRCOLL
94 # define collator strcoll
95 #else
96 # define collator strucmp
97 #endif
99 #define PREREQ_FOR_SYS_TRANSLATION (HAVE_WCHAR_H && HAVE_WCRTOMB && HAVE_WCWIDTH && HAVE_MBSTOWCS && HAVE_LANGINFO_H && defined(CODESET) && !defined(_WINDOWS))
101 /* System uin32 definition */
102 #if HAVE_STDINT_H
103 # include <stdint.h>
104 #endif
106 #if HAVE_INTTYPES_H
107 # include <inttypes.h>
108 #endif
110 #if HAVE_SYS_TYPES_H
111 # include <sys/types.h>
112 #endif
114 #if HAVE_SYS_WAIT_H
115 # include <sys/wait.h>
116 #endif
118 /* set MAXPATH based on what's available */
120 #if HAVE_LIMITS_H
121 # include <limits.h>
122 #endif
124 #ifdef PATH_MAX
125 # define MAXPATH PATH_MAX
126 #else
127 # if HAVE_SYS_PARAM_H
128 # include <sys/param.h>
129 # endif
130 # if MAXPATHLEN
131 # define MAXPATH MAXPATHLEN
132 # else
133 # define MAXPATH (512)
134 # endif
135 #endif
137 #if TIME_WITH_SYS_TIME
138 # include <sys/time.h>
139 # include <time.h>
140 #else
141 # if HAVE_SYS_TIME_H
142 # include <sys/time.h>
143 # else
144 # include <time.h>
145 # endif
146 #endif
148 #if HAVE_UTIME_H
149 # include <utime.h>
150 #elif HAVE_SYS_UTIME_H
151 # include <sys/utime.h>
152 #endif
154 #if HAVE_ERRNO_H
155 #include <errno.h>
156 #endif
158 #if HAVE_SYS_STAT_H
159 #include <sys/stat.h>
160 #endif
162 #if HAVE_FCNTL_H
163 #include <fcntl.h>
164 #endif
166 #if defined(O_NONBLOCK)
167 # define NON_BLOCKING_IO O_NONBLOCK
168 #elif defined(FNDELAY)
169 # define NON_BLOCKING_IO FNDELAY
170 #endif
172 #if HAVE_PWD_H
173 # include <pwd.h>
174 #endif
176 #if HAVE_SIGNAL_H
177 # include <signal.h>
178 #endif
180 #if HAVE_SETJMP_H
181 # include <setjmp.h>
182 #endif
184 #if HAS_TERMIOS
185 # include <termios.h>
186 #endif
188 #if HAS_TERMIO
189 # include <termio.h>
190 #endif
192 #if HAS_SGTTY
193 # include <sgtty.h>
194 #endif
196 #if HAVE_NETDB_H
197 # include <netdb.h>
198 #endif
200 #if defined(GWINSZ_IN_SYS_IOCTL) || defined(HAVE_SYS_IOCTL_H)
201 # include <sys/ioctl.h>
202 #endif
204 #if HAVE_SYS_SOCKET_H
205 #include <sys/socket.h>
206 #endif
208 #if HAVE_SYS_UIO_H
209 #include <sys/uio.h>
210 #endif
212 #if HAVE_SYS_UN_H
213 #include <sys/un.h>
214 #else
215 struct sockaddr_un {
216 short sun_family; /* AF_UNIX */
217 char sun_path[108]; /* path name (gag) */
219 #endif
221 #if HAVE_PTHREAD_H
222 # include <pthread.h>
223 #endif
225 #if HAVE_ASSERT_H
226 # include <assert.h>
227 #endif
229 #if HAVE_LOCALE_H
230 # include <locale.h>
231 #endif
233 #if HAVE_LANGINFO_H
234 # include <langinfo.h>
235 #endif
237 #if HAVE_REGEX_H
238 # include <regex.h>
239 #endif
241 #ifdef ENABLE_NLS
243 # include <libintl.h>
245 # define _(String) gettext (String)
246 # define N_(String) String
248 #else /* !ENABLE_NLS */
250 # define _(String) String
251 # define N_(String) String
253 #endif /* !ENABLE_NLS */
256 #ifdef ENABLE_LDAP
258 # include <lber.h>
259 # include <ldap.h>
261 # ifndef LDAPAPI
262 # if defined(LDAP_API_VERSION) /* draft-ietf-ldapext-ldap-c-api-04 */
263 # define LDAPAPI LDAP_API_VERSION
264 # elif defined(LDAP_OPT_SIZELIMIT)
265 # define LDAPAPI 15 /* Netscape SDK */
266 # elif defined(LDAP_BEGIN_DECL)
267 # define LDAPAPI 11 /* OpenLDAP 1.x */
268 # else /* older version */
269 # define LDAPAPI 10 /* Umich */
270 # endif
272 # ifndef LDAP_OPT_ON
273 # define LDAP_OPT_ON ((void *)1)
274 # endif
275 # ifndef LDAP_OPT_OFF
276 # define LDAP_OPT_OFF ((void *)0)
277 # endif
278 # ifndef LDAP_OPT_SIZELIMIT
279 # define LDAP_OPT_SIZELIMIT 1134 /* we're hacking now! */
280 # endif
281 # ifndef LDAP_OPT_TIMELIMIT
282 # define LDAP_OPT_TIMELIMIT 1135
283 # endif
284 # ifndef LDAP_OPT_PROTOCOL_VERSION
285 # define LDAP_OPT_PROTOCOL_VERSION 1136
286 # endif
288 # ifndef LDAP_MSG_ONE
289 # define LDAP_MSG_ONE (0x00)
290 # define LDAP_MSG_ALL (0x01)
291 # define LDAP_MSG_RECEIVED (0x02)
292 # endif
293 # endif
294 #endif /* ENABLE_LDAP */
297 #if defined(DOS) || defined(OS2)
298 # define NEWLINE "\r\n" /* local EOL convention... */
299 #else
300 # define NEWLINE "\n" /* necessary for gf_* funcs */
301 #endif
303 #if OSX_TARGET
304 # include <Carbon/Carbon.h>
305 # include <ApplicationServices/ApplicationServices.h>
307 /* Avoid OSX Conflicts */
308 #define Fixed PineFixed
309 #define Handle PineHandle
310 #define Comment PineComment
311 #define normal PineNormal
312 #endif
314 #if HAVE_SYSLOG_H
315 # include <syslog.h>
316 #elif HAVE_SYS_SYSLOG_H
317 # include <sys/syslog.h>
318 #endif
320 #ifdef ENABLE_DMALLOC
321 # include <dmalloc.h>
322 #endif
324 #ifdef _WINDOWS
327 * Defining these turns generic data types and function calls
328 * into their unicode (wide) versions. Not defining it will
329 * break the code, so leave it defined.
331 #ifndef _UNICODE
332 # define _UNICODE
333 #endif
334 #ifndef UNICODE
335 # define UNICODE
336 #endif
338 #define _WIN32_WINNT WINVER
340 /*-------- Standard windows defines and then our window module defines. */
341 #include <dos.h>
342 #include <direct.h>
343 #include <search.h>
344 #undef CTRL
345 #include <io.h>
346 #include <windows.h>
347 #include <commdlg.h>
348 #include <cderr.h>
349 #include <winsock.h>
350 #include <shellapi.h>
351 #include <sys/timeb.h>
352 #include <tchar.h>
353 #include <wchar.h>
354 #include <assert.h>
356 #if defined(WINVER) && WINVER >= 0x0501
357 # define WINCRED 1 /* WINCRED will work */
358 #else
359 # define WINCRED 0 /* too old for WINCRED to work */
360 #endif
362 #undef ERROR
364 typedef int mode_t;
365 typedef int uid_t;
366 typedef int gid_t;
368 #undef snprintf
369 #define snprintf _snprintf
370 #undef CM_NONE
372 #undef utimbuf
373 #define utimbuf _utimbuf
375 #endif /* _WINDOWS */
378 #if defined(PASSFILE) && defined(APPLEKEYCHAIN)
379 # error "Cant define both PASSFILE and APPLEKEYCHAIN"
380 #endif
381 #if defined(PASSFILE) && defined(WINCRED)
382 # error "Cant define both PASSFILE and WINCRED"
383 #endif
384 #if defined(APPLEKEYCHAIN) && defined(WINCRED)
385 # error "Cant define both APPLEKEYCHAIN and WINCRED"
386 #endif
388 #if defined(PASSFILE) || defined(APPLEKEYCHAIN) || defined(WINCRED)
389 # define LOCAL_PASSWD_CACHE
390 #endif
392 #endif /* _SYSTEM_INCLUDED */