诸暨麻将添加redis
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

132 lignes
3.5 KiB

  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. *
  10. * This software is licensed as described in the file COPYING, which
  11. * you should have received as part of this distribution. The terms
  12. * are also available at http://curl.haxx.se/docs/copyright.html.
  13. *
  14. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. * copies of the Software, and permit persons to whom the Software is
  16. * furnished to do so, under the terms of the COPYING file.
  17. *
  18. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. * KIND, either express or implied.
  20. *
  21. ***************************************************************************/
  22. #include "test.h"
  23. #ifdef HAVE_LOCALE_H
  24. #include <locale.h> /* for setlocale() */
  25. #endif
  26. #ifdef CURLDEBUG
  27. # define MEMDEBUG_NODEFINES
  28. # include "memdebug.h"
  29. #endif
  30. int select_wrapper(int nfds, fd_set *rd, fd_set *wr, fd_set *exc,
  31. struct timeval *tv)
  32. {
  33. if(nfds < 0) {
  34. SET_SOCKERRNO(EINVAL);
  35. return -1;
  36. }
  37. #ifdef USE_WINSOCK
  38. /*
  39. * Winsock select() requires that at least one of the three fd_set
  40. * pointers is not NULL and points to a non-empty fdset. IOW Winsock
  41. * select() can not be used to sleep without a single fd_set.
  42. */
  43. if(!nfds) {
  44. Sleep(1000*tv->tv_sec + tv->tv_usec/1000);
  45. return 0;
  46. }
  47. #endif
  48. return select(nfds, rd, wr, exc, tv);
  49. }
  50. char *libtest_arg2=NULL;
  51. char *libtest_arg3=NULL;
  52. int test_argc;
  53. char **test_argv;
  54. struct timeval tv_test_start; /* for test timing */
  55. #ifdef UNITTESTS
  56. int unitfail; /* for unittests */
  57. #endif
  58. #ifdef CURLDEBUG
  59. static void memory_tracking_init(void)
  60. {
  61. char *env;
  62. /* if CURL_MEMDEBUG is set, this starts memory tracking message logging */
  63. env = curl_getenv("CURL_MEMDEBUG");
  64. if(env) {
  65. /* use the value as file name */
  66. char fname[CURL_MT_LOGFNAME_BUFSIZE];
  67. if(strlen(env) >= CURL_MT_LOGFNAME_BUFSIZE)
  68. env[CURL_MT_LOGFNAME_BUFSIZE-1] = '\0';
  69. strcpy(fname, env);
  70. curl_free(env);
  71. curl_memdebug(fname);
  72. /* this weird stuff here is to make curl_free() get called
  73. before curl_memdebug() as otherwise memory tracking will
  74. log a free() without an alloc! */
  75. }
  76. /* if CURL_MEMLIMIT is set, this enables fail-on-alloc-number-N feature */
  77. env = curl_getenv("CURL_MEMLIMIT");
  78. if(env) {
  79. char *endptr;
  80. long num = strtol(env, &endptr, 10);
  81. if((endptr != env) && (endptr == env + strlen(env)) && (num > 0))
  82. curl_memlimit(num);
  83. curl_free(env);
  84. }
  85. }
  86. #else
  87. # define memory_tracking_init() Curl_nop_stmt
  88. #endif
  89. int main(int argc, char **argv)
  90. {
  91. char *URL;
  92. memory_tracking_init();
  93. /*
  94. * Setup proper locale from environment. This is needed to enable locale-
  95. * specific behaviour by the C library in order to test for undesired side
  96. * effects that could cause in libcurl.
  97. */
  98. #ifdef HAVE_SETLOCALE
  99. setlocale(LC_ALL, "");
  100. #endif
  101. if(argc< 2 ) {
  102. fprintf(stderr, "Pass URL as argument please\n");
  103. return 1;
  104. }
  105. test_argc = argc;
  106. test_argv = argv;
  107. if(argc>2)
  108. libtest_arg2=argv[2];
  109. if(argc>3)
  110. libtest_arg3=argv[3];
  111. URL = argv[1]; /* provide this to the rest */
  112. fprintf(stderr, "URL: %s\n", URL);
  113. return test(URL);
  114. }