quickjs-tart

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

testutil.c (1747B)


      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 #include "testutil.h"
     25 
     26 #include "memdebug.h"
     27 
     28 /* build request url */
     29 char *tutil_suburl(const char *base, int i)
     30 {
     31   return curl_maprintf("%s%.4d", base, i);
     32 }
     33 
     34 #if defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT)
     35 void tutil_rlim2str(char *buf, size_t len, rlim_t val)
     36 {
     37 #ifdef RLIM_INFINITY
     38   if(val == RLIM_INFINITY) {
     39     curl_msnprintf(buf, len, "INFINITY");
     40     return;
     41   }
     42 #endif
     43 #ifdef HAVE_LONGLONG
     44   if(sizeof(rlim_t) > sizeof(long))
     45     curl_msnprintf(buf, len, "%llu", (unsigned long long)val);
     46   else
     47 #endif
     48   {
     49     if(sizeof(rlim_t) < sizeof(long))
     50       curl_msnprintf(buf, len, "%u", (unsigned int)val);
     51     else
     52       curl_msnprintf(buf, len, "%lu", (unsigned long)val);
     53   }
     54 }
     55 #endif