Return to lib1905.c CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / curl / tests / libtest |
1.1 ! misho 1: /*************************************************************************** ! 2: * _ _ ____ _ ! 3: * Project ___| | | | _ \| | ! 4: * / __| | | | |_) | | ! 5: * | (__| |_| | _ <| |___ ! 6: * \___|\___/|_| \_\_____| ! 7: * ! 8: * Copyright (C) 2019, 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 https://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: ! 24: #include "testutil.h" ! 25: #include "warnless.h" ! 26: #include "memdebug.h" ! 27: ! 28: int test(char *URL) ! 29: { ! 30: CURLSH *sh = NULL; ! 31: CURL *ch = NULL; ! 32: int unfinished; ! 33: ! 34: CURLM *cm = curl_multi_init(); ! 35: if(!cm) ! 36: return 1; ! 37: sh = curl_share_init(); ! 38: if(!sh) ! 39: goto cleanup; ! 40: ! 41: curl_share_setopt(sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE); ! 42: curl_share_setopt(sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE); ! 43: ! 44: ch = curl_easy_init(); ! 45: if(!ch) ! 46: goto cleanup; ! 47: ! 48: curl_easy_setopt(ch, CURLOPT_SHARE, sh); ! 49: curl_easy_setopt(ch, CURLOPT_URL, URL); ! 50: curl_easy_setopt(ch, CURLOPT_COOKIEFILE, "log/cookies1905"); ! 51: curl_easy_setopt(ch, CURLOPT_COOKIEJAR, "log/cookies1905"); ! 52: ! 53: curl_multi_add_handle(cm, ch); ! 54: ! 55: unfinished = 1; ! 56: while(unfinished) { ! 57: int MAX = 0; ! 58: long max_tout; ! 59: fd_set R, W, E; ! 60: struct timeval timeout; ! 61: ! 62: FD_ZERO(&R); ! 63: FD_ZERO(&W); ! 64: FD_ZERO(&E); ! 65: curl_multi_perform(cm, &unfinished); ! 66: ! 67: curl_multi_fdset(cm, &R, &W, &E, &MAX); ! 68: curl_multi_timeout(cm, &max_tout); ! 69: ! 70: if(max_tout > 0) { ! 71: timeout.tv_sec = max_tout / 1000; ! 72: timeout.tv_usec = (max_tout % 1000) * 1000; ! 73: } ! 74: else { ! 75: timeout.tv_sec = 0; ! 76: timeout.tv_usec = 1000; ! 77: } ! 78: ! 79: select(MAX + 1, &R, &W, &E, &timeout); ! 80: } ! 81: ! 82: curl_easy_setopt(ch, CURLOPT_COOKIELIST, "FLUSH"); ! 83: curl_easy_setopt(ch, CURLOPT_SHARE, NULL); ! 84: ! 85: curl_multi_remove_handle(cm, ch); ! 86: cleanup: ! 87: curl_easy_cleanup(ch); ! 88: curl_share_cleanup(sh); ! 89: curl_multi_cleanup(cm); ! 90: curl_global_cleanup(); ! 91: ! 92: return 0; ! 93: }