CurlTests.c
Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                  _   _ ____  _
00003  *  Project                     ___| | | |  _ \| |
00004  *                             / __| | | | |_) | |
00005  *                            | (__| |_| |  _ <| |___
00006  *                             \___|\___/|_| \_\_____|
00007  *
00008  * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
00009  *
00010  * This software is licensed as described in the file COPYING, which
00011  * you should have received as part of this distribution. The terms
00012  * are also available at https://curl.haxx.se/docs/copyright.html.
00013  *
00014  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
00015  * copies of the Software, and permit persons to whom the Software is
00016  * furnished to do so, under the terms of the COPYING file.
00017  *
00018  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
00019  * KIND, either express or implied.
00020  *
00021  ***************************************************************************/
00022 #ifdef TIME_WITH_SYS_TIME
00023 /* Time with sys/time test */
00024 
00025 #include <sys/types.h>
00026 #include <sys/time.h>
00027 #include <time.h>
00028 
00029 int
00030 main ()
00031 {
00032 if ((struct tm *) 0)
00033 return 0;
00034   ;
00035   return 0;
00036 }
00037 
00038 #endif
00039 
00040 #ifdef HAVE_FCNTL_O_NONBLOCK
00041 
00042 /* headers for FCNTL_O_NONBLOCK test */
00043 #include <sys/types.h>
00044 #include <unistd.h>
00045 #include <fcntl.h>
00046 /* */
00047 #if defined(sun) || defined(__sun__) || \
00048     defined(__SUNPRO_C) || defined(__SUNPRO_CC)
00049 # if defined(__SVR4) || defined(__srv4__)
00050 #  define PLATFORM_SOLARIS
00051 # else
00052 #  define PLATFORM_SUNOS4
00053 # endif
00054 #endif
00055 #if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
00056 # define PLATFORM_AIX_V3
00057 #endif
00058 /* */
00059 #if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
00060 #error "O_NONBLOCK does not work on this platform"
00061 #endif
00062 
00063 int
00064 main ()
00065 {
00066       /* O_NONBLOCK source test */
00067       int flags = 0;
00068       if(0 != fcntl(0, F_SETFL, flags | O_NONBLOCK))
00069           return 1;
00070       return 0;
00071 }
00072 #endif
00073 
00074 /* tests for gethostbyaddr_r or gethostbyname_r */
00075 #if defined(HAVE_GETHOSTBYADDR_R_5_REENTRANT) || \
00076     defined(HAVE_GETHOSTBYADDR_R_7_REENTRANT) || \
00077     defined(HAVE_GETHOSTBYADDR_R_8_REENTRANT) || \
00078     defined(HAVE_GETHOSTBYNAME_R_3_REENTRANT) || \
00079     defined(HAVE_GETHOSTBYNAME_R_5_REENTRANT) || \
00080     defined(HAVE_GETHOSTBYNAME_R_6_REENTRANT)
00081 #   define _REENTRANT
00082     /* no idea whether _REENTRANT is always set, just invent a new flag */
00083 #   define TEST_GETHOSTBYFOO_REENTRANT
00084 #endif
00085 #if defined(HAVE_GETHOSTBYADDR_R_5) || \
00086     defined(HAVE_GETHOSTBYADDR_R_7) || \
00087     defined(HAVE_GETHOSTBYADDR_R_8) || \
00088     defined(HAVE_GETHOSTBYNAME_R_3) || \
00089     defined(HAVE_GETHOSTBYNAME_R_5) || \
00090     defined(HAVE_GETHOSTBYNAME_R_6) || \
00091     defined(TEST_GETHOSTBYFOO_REENTRANT)
00092 #include <sys/types.h>
00093 #include <netdb.h>
00094 int main(void)
00095 {
00096   char *address = "example.com";
00097   int length = 0;
00098   int type = 0;
00099   struct hostent h;
00100   int rc = 0;
00101 #if defined(HAVE_GETHOSTBYADDR_R_5) || \
00102     defined(HAVE_GETHOSTBYADDR_R_5_REENTRANT) || \
00103     \
00104     defined(HAVE_GETHOSTBYNAME_R_3) || \
00105     defined(HAVE_GETHOSTBYNAME_R_3_REENTRANT)
00106   struct hostent_data hdata;
00107 #elif defined(HAVE_GETHOSTBYADDR_R_7) || \
00108       defined(HAVE_GETHOSTBYADDR_R_7_REENTRANT) || \
00109       defined(HAVE_GETHOSTBYADDR_R_8) || \
00110       defined(HAVE_GETHOSTBYADDR_R_8_REENTRANT) || \
00111       \
00112       defined(HAVE_GETHOSTBYNAME_R_5) || \
00113       defined(HAVE_GETHOSTBYNAME_R_5_REENTRANT) || \
00114       defined(HAVE_GETHOSTBYNAME_R_6) || \
00115       defined(HAVE_GETHOSTBYNAME_R_6_REENTRANT)
00116   char buffer[8192];
00117   int h_errnop;
00118   struct hostent *hp;
00119 #endif
00120 
00121 #ifndef gethostbyaddr_r
00122   (void)gethostbyaddr_r;
00123 #endif
00124 
00125 #if   defined(HAVE_GETHOSTBYADDR_R_5) || \
00126       defined(HAVE_GETHOSTBYADDR_R_5_REENTRANT)
00127   rc = gethostbyaddr_r(address, length, type, &h, &hdata);
00128 #elif defined(HAVE_GETHOSTBYADDR_R_7) || \
00129       defined(HAVE_GETHOSTBYADDR_R_7_REENTRANT)
00130   hp = gethostbyaddr_r(address, length, type, &h, buffer, 8192, &h_errnop);
00131   (void)hp;
00132 #elif defined(HAVE_GETHOSTBYADDR_R_8) || \
00133       defined(HAVE_GETHOSTBYADDR_R_8_REENTRANT)
00134   rc = gethostbyaddr_r(address, length, type, &h, buffer, 8192, &hp, &h_errnop);
00135 #endif
00136 
00137 #if   defined(HAVE_GETHOSTBYNAME_R_3) || \
00138       defined(HAVE_GETHOSTBYNAME_R_3_REENTRANT)
00139   rc = gethostbyname_r(address, &h, &hdata);
00140 #elif defined(HAVE_GETHOSTBYNAME_R_5) || \
00141       defined(HAVE_GETHOSTBYNAME_R_5_REENTRANT)
00142   rc = gethostbyname_r(address, &h, buffer, 8192, &h_errnop);
00143   (void)hp; /* not used for test */
00144 #elif defined(HAVE_GETHOSTBYNAME_R_6) || \
00145       defined(HAVE_GETHOSTBYNAME_R_6_REENTRANT)
00146   rc = gethostbyname_r(address, &h, buffer, 8192, &hp, &h_errnop);
00147 #endif
00148 
00149   (void)length;
00150   (void)type;
00151   (void)rc;
00152   return 0;
00153 }
00154 #endif
00155 
00156 #ifdef HAVE_SOCKLEN_T
00157 #ifdef _WIN32
00158 #include <ws2tcpip.h>
00159 #else
00160 #include <sys/types.h>
00161 #include <sys/socket.h>
00162 #endif
00163 int
00164 main ()
00165 {
00166 if ((socklen_t *) 0)
00167   return 0;
00168 if (sizeof (socklen_t))
00169   return 0;
00170   ;
00171   return 0;
00172 }
00173 #endif
00174 #ifdef HAVE_IN_ADDR_T
00175 #include <sys/types.h>
00176 #include <sys/socket.h>
00177 #include <arpa/inet.h>
00178 
00179 int
00180 main ()
00181 {
00182 if ((in_addr_t *) 0)
00183   return 0;
00184 if (sizeof (in_addr_t))
00185   return 0;
00186   ;
00187   return 0;
00188 }
00189 #endif
00190 
00191 #ifdef HAVE_BOOL_T
00192 #ifdef HAVE_SYS_TYPES_H
00193 #include <sys/types.h>
00194 #endif
00195 #ifdef HAVE_STDBOOL_H
00196 #include <stdbool.h>
00197 #endif
00198 int
00199 main ()
00200 {
00201 if (sizeof (bool *) )
00202   return 0;
00203   ;
00204   return 0;
00205 }
00206 #endif
00207 
00208 #ifdef STDC_HEADERS
00209 #include <stdlib.h>
00210 #include <stdarg.h>
00211 #include <string.h>
00212 #include <float.h>
00213 int main() { return 0; }
00214 #endif
00215 #ifdef RETSIGTYPE_TEST
00216 #include <sys/types.h>
00217 #include <signal.h>
00218 #ifdef signal
00219 # undef signal
00220 #endif
00221 #ifdef __cplusplus
00222 extern "C" void (*signal (int, void (*)(int)))(int);
00223 #else
00224 void (*signal ()) ();
00225 #endif
00226 
00227 int
00228 main ()
00229 {
00230   return 0;
00231 }
00232 #endif
00233 #ifdef HAVE_INET_NTOA_R_DECL
00234 #include <arpa/inet.h>
00235 
00236 typedef void (*func_type)();
00237 
00238 int main()
00239 {
00240 #ifndef inet_ntoa_r
00241   func_type func;
00242   func = (func_type)inet_ntoa_r;
00243 #endif
00244   return 0;
00245 }
00246 #endif
00247 #ifdef HAVE_INET_NTOA_R_DECL_REENTRANT
00248 #define _REENTRANT
00249 #include <arpa/inet.h>
00250 
00251 typedef void (*func_type)();
00252 
00253 int main()
00254 {
00255 #ifndef inet_ntoa_r
00256   func_type func;
00257   func = (func_type)&inet_ntoa_r;
00258 #endif
00259   return 0;
00260 }
00261 #endif
00262 #ifdef HAVE_GETADDRINFO
00263 #include <netdb.h>
00264 #include <sys/types.h>
00265 #include <sys/socket.h>
00266 
00267 int main(void) {
00268     struct addrinfo hints, *ai;
00269     int error;
00270 
00271     memset(&hints, 0, sizeof(hints));
00272     hints.ai_family = AF_UNSPEC;
00273     hints.ai_socktype = SOCK_STREAM;
00274 #ifndef getaddrinfo
00275     (void)getaddrinfo;
00276 #endif
00277     error = getaddrinfo("127.0.0.1", "8080", &hints, &ai);
00278     if (error) {
00279         return 1;
00280     }
00281     return 0;
00282 }
00283 #endif
00284 #ifdef HAVE_FILE_OFFSET_BITS
00285 #ifdef _FILE_OFFSET_BITS
00286 #undef _FILE_OFFSET_BITS
00287 #endif
00288 #define _FILE_OFFSET_BITS 64
00289 #include <sys/types.h>
00290  /* Check that off_t can represent 2**63 - 1 correctly.
00291     We can't simply define LARGE_OFF_T to be 9223372036854775807,
00292     since some C++ compilers masquerading as C compilers
00293     incorrectly reject 9223372036854775807.  */
00294 #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
00295   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
00296                        && LARGE_OFF_T % 2147483647 == 1)
00297                       ? 1 : -1];
00298 int main () { ; return 0; }
00299 #endif
00300 #ifdef HAVE_IOCTLSOCKET
00301 /* includes start */
00302 #ifdef HAVE_WINDOWS_H
00303 #  ifndef WIN32_LEAN_AND_MEAN
00304 #    define WIN32_LEAN_AND_MEAN
00305 #  endif
00306 #  include <windows.h>
00307 #  ifdef HAVE_WINSOCK2_H
00308 #    include <winsock2.h>
00309 #  else
00310 #    ifdef HAVE_WINSOCK_H
00311 #      include <winsock.h>
00312 #    endif
00313 #  endif
00314 #endif
00315 
00316 int
00317 main ()
00318 {
00319 
00320 /* ioctlsocket source code */
00321  int socket;
00322  unsigned long flags = ioctlsocket(socket, FIONBIO, &flags);
00323 
00324   ;
00325   return 0;
00326 }
00327 
00328 #endif
00329 #ifdef HAVE_IOCTLSOCKET_CAMEL
00330 /* includes start */
00331 #ifdef HAVE_WINDOWS_H
00332 #  ifndef WIN32_LEAN_AND_MEAN
00333 #    define WIN32_LEAN_AND_MEAN
00334 #  endif
00335 #  include <windows.h>
00336 #  ifdef HAVE_WINSOCK2_H
00337 #    include <winsock2.h>
00338 #  else
00339 #    ifdef HAVE_WINSOCK_H
00340 #      include <winsock.h>
00341 #    endif
00342 #  endif
00343 #endif
00344 
00345 int
00346 main ()
00347 {
00348 
00349 /* IoctlSocket source code */
00350     if(0 != IoctlSocket(0, 0, 0))
00351       return 1;
00352   ;
00353   return 0;
00354 }
00355 #endif
00356 #ifdef HAVE_IOCTLSOCKET_CAMEL_FIONBIO
00357 /* includes start */
00358 #ifdef HAVE_WINDOWS_H
00359 #  ifndef WIN32_LEAN_AND_MEAN
00360 #    define WIN32_LEAN_AND_MEAN
00361 #  endif
00362 #  include <windows.h>
00363 #  ifdef HAVE_WINSOCK2_H
00364 #    include <winsock2.h>
00365 #  else
00366 #    ifdef HAVE_WINSOCK_H
00367 #      include <winsock.h>
00368 #    endif
00369 #  endif
00370 #endif
00371 
00372 int
00373 main ()
00374 {
00375 
00376 /* IoctlSocket source code */
00377         long flags = 0;
00378         if(0 != ioctlsocket(0, FIONBIO, &flags))
00379           return 1;
00380   ;
00381   return 0;
00382 }
00383 #endif
00384 #ifdef HAVE_IOCTLSOCKET_FIONBIO
00385 /* includes start */
00386 #ifdef HAVE_WINDOWS_H
00387 #  ifndef WIN32_LEAN_AND_MEAN
00388 #    define WIN32_LEAN_AND_MEAN
00389 #  endif
00390 #  include <windows.h>
00391 #  ifdef HAVE_WINSOCK2_H
00392 #    include <winsock2.h>
00393 #  else
00394 #    ifdef HAVE_WINSOCK_H
00395 #      include <winsock.h>
00396 #    endif
00397 #  endif
00398 #endif
00399 
00400 int
00401 main ()
00402 {
00403 
00404         int flags = 0;
00405         if(0 != ioctlsocket(0, FIONBIO, &flags))
00406           return 1;
00407 
00408   ;
00409   return 0;
00410 }
00411 #endif
00412 #ifdef HAVE_IOCTL_FIONBIO
00413 /* headers for FIONBIO test */
00414 /* includes start */
00415 #ifdef HAVE_SYS_TYPES_H
00416 #  include <sys/types.h>
00417 #endif
00418 #ifdef HAVE_UNISTD_H
00419 #  include <unistd.h>
00420 #endif
00421 #ifdef HAVE_SYS_SOCKET_H
00422 #  include <sys/socket.h>
00423 #endif
00424 #ifdef HAVE_SYS_IOCTL_H
00425 #  include <sys/ioctl.h>
00426 #endif
00427 #ifdef HAVE_STROPTS_H
00428 #  include <stropts.h>
00429 #endif
00430 
00431 int
00432 main ()
00433 {
00434 
00435         int flags = 0;
00436         if(0 != ioctl(0, FIONBIO, &flags))
00437           return 1;
00438 
00439   ;
00440   return 0;
00441 }
00442 #endif
00443 #ifdef HAVE_IOCTL_SIOCGIFADDR
00444 /* headers for FIONBIO test */
00445 /* includes start */
00446 #ifdef HAVE_SYS_TYPES_H
00447 #  include <sys/types.h>
00448 #endif
00449 #ifdef HAVE_UNISTD_H
00450 #  include <unistd.h>
00451 #endif
00452 #ifdef HAVE_SYS_SOCKET_H
00453 #  include <sys/socket.h>
00454 #endif
00455 #ifdef HAVE_SYS_IOCTL_H
00456 #  include <sys/ioctl.h>
00457 #endif
00458 #ifdef HAVE_STROPTS_H
00459 #  include <stropts.h>
00460 #endif
00461 #include <net/if.h>
00462 
00463 int
00464 main ()
00465 {
00466         struct ifreq ifr;
00467         if(0 != ioctl(0, SIOCGIFADDR, &ifr))
00468           return 1;
00469 
00470   ;
00471   return 0;
00472 }
00473 #endif
00474 #ifdef HAVE_SETSOCKOPT_SO_NONBLOCK
00475 /* includes start */
00476 #ifdef HAVE_WINDOWS_H
00477 #  ifndef WIN32_LEAN_AND_MEAN
00478 #    define WIN32_LEAN_AND_MEAN
00479 #  endif
00480 #  include <windows.h>
00481 #  ifdef HAVE_WINSOCK2_H
00482 #    include <winsock2.h>
00483 #  else
00484 #    ifdef HAVE_WINSOCK_H
00485 #      include <winsock.h>
00486 #    endif
00487 #  endif
00488 #endif
00489 /* includes start */
00490 #ifdef HAVE_SYS_TYPES_H
00491 #  include <sys/types.h>
00492 #endif
00493 #ifdef HAVE_SYS_SOCKET_H
00494 #  include <sys/socket.h>
00495 #endif
00496 /* includes end */
00497 
00498 int
00499 main ()
00500 {
00501         if(0 != setsockopt(0, SOL_SOCKET, SO_NONBLOCK, 0, 0))
00502           return 1;
00503   ;
00504   return 0;
00505 }
00506 #endif
00507 #ifdef HAVE_GLIBC_STRERROR_R
00508 #include <string.h>
00509 #include <errno.h>
00510 int
00511 main () {
00512   char buffer[1024]; /* big enough to play with */
00513   char *string =
00514     strerror_r(EACCES, buffer, sizeof(buffer));
00515     /* this should've returned a string */
00516     if(!string || !string[0])
00517       return 99;
00518     return 0;
00519 }
00520 #endif
00521 #ifdef HAVE_POSIX_STRERROR_R
00522 #include <string.h>
00523 #include <errno.h>
00524 int
00525 main () {
00526   char buffer[1024]; /* big enough to play with */
00527   int error =
00528     strerror_r(EACCES, buffer, sizeof(buffer));
00529     /* This should've returned zero, and written an error string in the
00530        buffer.*/
00531     if(!buffer[0] || error)
00532       return 99;
00533     return 0;
00534 }
00535 #endif


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:02