quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

lib1555.c (2422B)


      1 /***************************************************************************
      2  *                                  _   _ ____  _
      3  *  Project                     ___| | | |  _ \| |
      4  *                             / __| | | | |_) | |
      5  *                            | (__| |_| |  _ <| |___
      6  *                             \___|\___/|_| \_\_____|
      7  *
      8  * Copyright (C) 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.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  * SPDX-License-Identifier: curl
     22  *
     23  ***************************************************************************/
     24 /*
     25  * Verify that some API functions are locked from being called inside callback
     26  */
     27 
     28 #include "first.h"
     29 
     30 #include "memdebug.h"
     31 
     32 static CURL *t1555_curl;
     33 
     34 static int progressCallback(void *arg,
     35                             double dltotal,
     36                             double dlnow,
     37                             double ultotal,
     38                             double ulnow)
     39 {
     40   CURLcode res = CURLE_OK;
     41   char buffer[256];
     42   size_t n = 0;
     43   (void)arg;
     44   (void)dltotal;
     45   (void)dlnow;
     46   (void)ultotal;
     47   (void)ulnow;
     48   res = curl_easy_recv(t1555_curl, buffer, 256, &n);
     49   curl_mprintf("curl_easy_recv returned %d\n", res);
     50   res = curl_easy_send(t1555_curl, buffer, n, &n);
     51   curl_mprintf("curl_easy_send returned %d\n", res);
     52 
     53   return 1;
     54 }
     55 
     56 static CURLcode test_lib1555(char *URL)
     57 {
     58   CURLcode res = CURLE_OK;
     59 
     60   global_init(CURL_GLOBAL_ALL);
     61 
     62   easy_init(t1555_curl);
     63 
     64   easy_setopt(t1555_curl, CURLOPT_URL, URL);
     65   easy_setopt(t1555_curl, CURLOPT_TIMEOUT, (long)7);
     66   easy_setopt(t1555_curl, CURLOPT_NOSIGNAL, (long)1);
     67   easy_setopt(t1555_curl, CURLOPT_PROGRESSFUNCTION, progressCallback);
     68   easy_setopt(t1555_curl, CURLOPT_PROGRESSDATA, NULL);
     69   easy_setopt(t1555_curl, CURLOPT_NOPROGRESS, (long)0);
     70 
     71   res = curl_easy_perform(t1555_curl);
     72 
     73 test_cleanup:
     74 
     75   /* undocumented cleanup sequence - type UA */
     76 
     77   curl_easy_cleanup(t1555_curl);
     78   curl_global_cleanup();
     79 
     80   return res;
     81 }