Go to the documentation of this file.00001 #ifndef HEADER_CURL_SETUP_ONCE_H
00002 #define HEADER_CURL_SETUP_ONCE_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include <stdio.h>
00031 #include <stdlib.h>
00032 #include <string.h>
00033 #include <stdarg.h>
00034 #include <ctype.h>
00035
00036 #ifdef HAVE_ERRNO_H
00037 #include <errno.h>
00038 #endif
00039
00040 #ifdef HAVE_SYS_TYPES_H
00041 #include <sys/types.h>
00042 #endif
00043
00044 #ifdef NEED_MALLOC_H
00045 #include <malloc.h>
00046 #endif
00047
00048 #ifdef NEED_MEMORY_H
00049 #include <memory.h>
00050 #endif
00051
00052 #ifdef HAVE_SYS_STAT_H
00053 #include <sys/stat.h>
00054 #endif
00055
00056 #ifdef HAVE_SYS_TIME_H
00057 #include <sys/time.h>
00058 #ifdef TIME_WITH_SYS_TIME
00059 #include <time.h>
00060 #endif
00061 #else
00062 #ifdef HAVE_TIME_H
00063 #include <time.h>
00064 #endif
00065 #endif
00066
00067 #ifdef WIN32
00068 #include <io.h>
00069 #include <fcntl.h>
00070 #endif
00071
00072 #if defined(HAVE_STDBOOL_H) && defined(HAVE_BOOL_T)
00073 #include <stdbool.h>
00074 #endif
00075
00076 #ifdef HAVE_UNISTD_H
00077 #include <unistd.h>
00078 #endif
00079
00080 #ifdef __hpux
00081 # if !defined(_XOPEN_SOURCE_EXTENDED) || defined(_KERNEL)
00082 # ifdef _APP32_64BIT_OFF_T
00083 # define OLD_APP32_64BIT_OFF_T _APP32_64BIT_OFF_T
00084 # undef _APP32_64BIT_OFF_T
00085 # else
00086 # undef OLD_APP32_64BIT_OFF_T
00087 # endif
00088 # endif
00089 #endif
00090
00091 #ifdef HAVE_SYS_SOCKET_H
00092 #include <sys/socket.h>
00093 #endif
00094
00095 #ifdef __hpux
00096 # if !defined(_XOPEN_SOURCE_EXTENDED) || defined(_KERNEL)
00097 # ifdef OLD_APP32_64BIT_OFF_T
00098 # define _APP32_64BIT_OFF_T OLD_APP32_64BIT_OFF_T
00099 # undef OLD_APP32_64BIT_OFF_T
00100 # endif
00101 # endif
00102 #endif
00103
00104
00105
00106
00107
00108
00109 #ifndef HAVE_STRUCT_TIMEVAL
00110 struct timeval {
00111 long tv_sec;
00112 long tv_usec;
00113 };
00114 #endif
00115
00116
00117
00118
00119
00120
00121
00122 #ifdef HAVE_MSG_NOSIGNAL
00123 #define SEND_4TH_ARG MSG_NOSIGNAL
00124 #else
00125 #define SEND_4TH_ARG 0
00126 #endif
00127
00128
00129 #if defined(__minix)
00130
00131 #define sread(x,y,z) (ssize_t)read((RECV_TYPE_ARG1)(x), \
00132 (RECV_TYPE_ARG2)(y), \
00133 (RECV_TYPE_ARG3)(z))
00134
00135 #elif defined(HAVE_RECV)
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158 #if !defined(RECV_TYPE_ARG1) || \
00159 !defined(RECV_TYPE_ARG2) || \
00160 !defined(RECV_TYPE_ARG3) || \
00161 !defined(RECV_TYPE_ARG4) || \
00162 !defined(RECV_TYPE_RETV)
00163
00164 Error Missing_definition_of_return_and_arguments_types_of_recv
00165
00166 #else
00167 #define sread(x,y,z) (ssize_t)recv((RECV_TYPE_ARG1)(x), \
00168 (RECV_TYPE_ARG2)(y), \
00169 (RECV_TYPE_ARG3)(z), \
00170 (RECV_TYPE_ARG4)(0))
00171 #endif
00172 #else
00173 #ifndef sread
00174
00175 Error Missing_definition_of_macro_sread
00176
00177 #endif
00178 #endif
00179
00180
00181 #if defined(__minix)
00182
00183 #define swrite(x,y,z) (ssize_t)write((SEND_TYPE_ARG1)(x), \
00184 (SEND_TYPE_ARG2)(y), \
00185 (SEND_TYPE_ARG3)(z))
00186
00187 #elif defined(HAVE_SEND)
00188 #if !defined(SEND_TYPE_ARG1) || \
00189 !defined(SEND_QUAL_ARG2) || \
00190 !defined(SEND_TYPE_ARG2) || \
00191 !defined(SEND_TYPE_ARG3) || \
00192 !defined(SEND_TYPE_ARG4) || \
00193 !defined(SEND_TYPE_RETV)
00194
00195 Error Missing_definition_of_return_and_arguments_types_of_send
00196
00197 #else
00198 #define swrite(x,y,z) (ssize_t)send((SEND_TYPE_ARG1)(x), \
00199 (SEND_TYPE_ARG2)(y), \
00200 (SEND_TYPE_ARG3)(z), \
00201 (SEND_TYPE_ARG4)(SEND_4TH_ARG))
00202 #endif
00203 #else
00204 #ifndef swrite
00205
00206 Error Missing_definition_of_macro_swrite
00207
00208 #endif
00209 #endif
00210
00211
00212 #if 0
00213 #if defined(HAVE_RECVFROM)
00214
00215
00216
00217 #if !defined(RECVFROM_TYPE_ARG1) || \
00218 !defined(RECVFROM_TYPE_ARG2) || \
00219 !defined(RECVFROM_TYPE_ARG3) || \
00220 !defined(RECVFROM_TYPE_ARG4) || \
00221 !defined(RECVFROM_TYPE_ARG5) || \
00222 !defined(RECVFROM_TYPE_ARG6) || \
00223 !defined(RECVFROM_TYPE_RETV)
00224
00225 Error Missing_definition_of_return_and_arguments_types_of_recvfrom
00226
00227 #else
00228 #define sreadfrom(s,b,bl,f,fl) (ssize_t)recvfrom((RECVFROM_TYPE_ARG1) (s), \
00229 (RECVFROM_TYPE_ARG2 *)(b), \
00230 (RECVFROM_TYPE_ARG3) (bl), \
00231 (RECVFROM_TYPE_ARG4) (0), \
00232 (RECVFROM_TYPE_ARG5 *)(f), \
00233 (RECVFROM_TYPE_ARG6 *)(fl))
00234 #endif
00235 #else
00236 #ifndef sreadfrom
00237
00238 Error Missing_definition_of_macro_sreadfrom
00239
00240 #endif
00241 #endif
00242
00243
00244 #ifdef RECVFROM_TYPE_ARG6_IS_VOID
00245 # define RECVFROM_ARG6_T int
00246 #else
00247 # define RECVFROM_ARG6_T RECVFROM_TYPE_ARG6
00248 #endif
00249 #endif
00250
00251
00252
00253
00254
00255
00256 #if defined(HAVE_CLOSESOCKET)
00257 # define sclose(x) closesocket((x))
00258 #elif defined(HAVE_CLOSESOCKET_CAMEL)
00259 # define sclose(x) CloseSocket((x))
00260 #elif defined(HAVE_CLOSE_S)
00261 # define sclose(x) close_s((x))
00262 #elif defined(USE_LWIPSOCK)
00263 # define sclose(x) lwip_close((x))
00264 #else
00265 # define sclose(x) close((x))
00266 #endif
00267
00268
00269
00270
00271 #if defined(USE_LWIPSOCK)
00272 # define sfcntl lwip_fcntl
00273 #else
00274 # define sfcntl fcntl
00275 #endif
00276
00277
00278
00279
00280
00281
00282 #define ISSPACE(x) (isspace((int) ((unsigned char)x)))
00283 #define ISDIGIT(x) (isdigit((int) ((unsigned char)x)))
00284 #define ISALNUM(x) (isalnum((int) ((unsigned char)x)))
00285 #define ISXDIGIT(x) (isxdigit((int) ((unsigned char)x)))
00286 #define ISGRAPH(x) (isgraph((int) ((unsigned char)x)))
00287 #define ISALPHA(x) (isalpha((int) ((unsigned char)x)))
00288 #define ISPRINT(x) (isprint((int) ((unsigned char)x)))
00289 #define ISUPPER(x) (isupper((int) ((unsigned char)x)))
00290 #define ISLOWER(x) (islower((int) ((unsigned char)x)))
00291 #define ISASCII(x) (isascii((int) ((unsigned char)x)))
00292
00293 #define ISBLANK(x) (int)((((unsigned char)x) == ' ') || \
00294 (((unsigned char)x) == '\t'))
00295
00296 #define TOLOWER(x) (tolower((int) ((unsigned char)x)))
00297
00298
00299
00300
00301
00302
00303 #if defined(__hpux) && !defined(HAVE_BOOL_T)
00304 typedef int bool;
00305 # define false 0
00306 # define true 1
00307 # define HAVE_BOOL_T
00308 #endif
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318 #ifndef HAVE_BOOL_T
00319 typedef enum {
00320 bool_false = 0,
00321 bool_true = 1
00322 } bool;
00323
00324
00325
00326
00327
00328
00329
00330 # define false bool_false
00331 # define true bool_true
00332 # define HAVE_BOOL_T
00333 #endif
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343 #ifndef TRUE
00344 #define TRUE true
00345 #endif
00346 #ifndef FALSE
00347 #define FALSE false
00348 #endif
00349
00350
00351
00352
00353
00354
00355
00356 #define WHILE_FALSE while(0)
00357
00358 #if defined(_MSC_VER) && !defined(__POCC__)
00359 # undef WHILE_FALSE
00360 # if (_MSC_VER < 1500)
00361 # define WHILE_FALSE while(1, 0)
00362 # else
00363 # define WHILE_FALSE \
00364 __pragma(warning(push)) \
00365 __pragma(warning(disable:4127)) \
00366 while(0) \
00367 __pragma(warning(pop))
00368 # endif
00369 #endif
00370
00371
00372
00373
00374
00375
00376 #ifndef HAVE_SIG_ATOMIC_T
00377 typedef int sig_atomic_t;
00378 #define HAVE_SIG_ATOMIC_T
00379 #endif
00380
00381
00382
00383
00384
00385
00386 #ifdef HAVE_SIG_ATOMIC_T_VOLATILE
00387 #define SIG_ATOMIC_T static sig_atomic_t
00388 #else
00389 #define SIG_ATOMIC_T static volatile sig_atomic_t
00390 #endif
00391
00392
00393
00394
00395
00396
00397 #ifndef RETSIGTYPE
00398 #define RETSIGTYPE void
00399 #endif
00400
00401
00402
00403
00404
00405
00406 #ifdef DEBUGBUILD
00407 #define DEBUGF(x) x
00408 #else
00409 #define DEBUGF(x) do { } WHILE_FALSE
00410 #endif
00411
00412
00413
00414
00415
00416
00417 #if defined(DEBUGBUILD) && defined(HAVE_ASSERT_H)
00418 #define DEBUGASSERT(x) assert(x)
00419 #else
00420 #define DEBUGASSERT(x) do { } WHILE_FALSE
00421 #endif
00422
00423
00424
00425
00426
00427
00428
00429 #ifdef USE_WINSOCK
00430 #define SOCKERRNO ((int)WSAGetLastError())
00431 #define SET_SOCKERRNO(x) (WSASetLastError((int)(x)))
00432 #else
00433 #define SOCKERRNO (errno)
00434 #define SET_SOCKERRNO(x) (errno = (x))
00435 #endif
00436
00437
00438
00439
00440
00441
00442
00443 #if defined(WIN32) && !defined(USE_LWIPSOCK)
00444 #define ERRNO ((int)GetLastError())
00445 #define SET_ERRNO(x) (SetLastError((DWORD)(x)))
00446 #else
00447 #define ERRNO (errno)
00448 #define SET_ERRNO(x) (errno = (x))
00449 #endif
00450
00451
00452
00453
00454
00455
00456 #ifdef USE_WINSOCK
00457 #undef EBADF
00458 #define EBADF WSAEBADF
00459 #undef EINTR
00460 #define EINTR WSAEINTR
00461 #undef EINVAL
00462 #define EINVAL WSAEINVAL
00463 #undef EWOULDBLOCK
00464 #define EWOULDBLOCK WSAEWOULDBLOCK
00465 #undef EINPROGRESS
00466 #define EINPROGRESS WSAEINPROGRESS
00467 #undef EALREADY
00468 #define EALREADY WSAEALREADY
00469 #undef ENOTSOCK
00470 #define ENOTSOCK WSAENOTSOCK
00471 #undef EDESTADDRREQ
00472 #define EDESTADDRREQ WSAEDESTADDRREQ
00473 #undef EMSGSIZE
00474 #define EMSGSIZE WSAEMSGSIZE
00475 #undef EPROTOTYPE
00476 #define EPROTOTYPE WSAEPROTOTYPE
00477 #undef ENOPROTOOPT
00478 #define ENOPROTOOPT WSAENOPROTOOPT
00479 #undef EPROTONOSUPPORT
00480 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
00481 #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
00482 #undef EOPNOTSUPP
00483 #define EOPNOTSUPP WSAEOPNOTSUPP
00484 #define EPFNOSUPPORT WSAEPFNOSUPPORT
00485 #undef EAFNOSUPPORT
00486 #define EAFNOSUPPORT WSAEAFNOSUPPORT
00487 #undef EADDRINUSE
00488 #define EADDRINUSE WSAEADDRINUSE
00489 #undef EADDRNOTAVAIL
00490 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
00491 #undef ENETDOWN
00492 #define ENETDOWN WSAENETDOWN
00493 #undef ENETUNREACH
00494 #define ENETUNREACH WSAENETUNREACH
00495 #undef ENETRESET
00496 #define ENETRESET WSAENETRESET
00497 #undef ECONNABORTED
00498 #define ECONNABORTED WSAECONNABORTED
00499 #undef ECONNRESET
00500 #define ECONNRESET WSAECONNRESET
00501 #undef ENOBUFS
00502 #define ENOBUFS WSAENOBUFS
00503 #undef EISCONN
00504 #define EISCONN WSAEISCONN
00505 #undef ENOTCONN
00506 #define ENOTCONN WSAENOTCONN
00507 #define ESHUTDOWN WSAESHUTDOWN
00508 #define ETOOMANYREFS WSAETOOMANYREFS
00509 #undef ETIMEDOUT
00510 #define ETIMEDOUT WSAETIMEDOUT
00511 #undef ECONNREFUSED
00512 #define ECONNREFUSED WSAECONNREFUSED
00513 #undef ELOOP
00514 #define ELOOP WSAELOOP
00515 #ifndef ENAMETOOLONG
00516 #define ENAMETOOLONG WSAENAMETOOLONG
00517 #endif
00518 #define EHOSTDOWN WSAEHOSTDOWN
00519 #undef EHOSTUNREACH
00520 #define EHOSTUNREACH WSAEHOSTUNREACH
00521 #ifndef ENOTEMPTY
00522 #define ENOTEMPTY WSAENOTEMPTY
00523 #endif
00524 #define EPROCLIM WSAEPROCLIM
00525 #define EUSERS WSAEUSERS
00526 #define EDQUOT WSAEDQUOT
00527 #define ESTALE WSAESTALE
00528 #define EREMOTE WSAEREMOTE
00529 #endif
00530
00531
00532
00533
00534
00535 #ifdef __VMS
00536 #define argv_item_t __char_ptr32
00537 #else
00538 #define argv_item_t char *
00539 #endif
00540
00541
00542
00543
00544
00545
00546
00547 #define ZERO_NULL 0
00548
00549
00550 #endif
00551