quickjs-tart

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

first.h (4902B)


      1 #ifndef HEADER_SERVER_FIRST_H
      2 #define HEADER_SERVER_FIRST_H
      3 /***************************************************************************
      4  *                                  _   _ ____  _
      5  *  Project                     ___| | | |  _ \| |
      6  *                             / __| | | | |_) | |
      7  *                            | (__| |_| |  _ <| |___
      8  *                             \___|\___/|_| \_\_____|
      9  *
     10  * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
     11  *
     12  * This software is licensed as described in the file COPYING, which
     13  * you should have received as part of this distribution. The terms
     14  * are also available at https://curl.se/docs/copyright.html.
     15  *
     16  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
     17  * copies of the Software, and permit persons to whom the Software is
     18  * furnished to do so, under the terms of the COPYING file.
     19  *
     20  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
     21  * KIND, either express or implied.
     22  *
     23  * SPDX-License-Identifier: curl
     24  *
     25  ***************************************************************************/
     26 #include "curl_setup.h"
     27 
     28 typedef int (*entry_func_t)(int, char **);
     29 
     30 struct entry_s {
     31   const char *name;
     32   entry_func_t ptr;
     33 };
     34 
     35 extern const struct entry_s s_entries[];
     36 
     37 #ifndef UNDER_CE
     38 #include <signal.h>
     39 #endif
     40 #ifdef HAVE_NETINET_IN_H
     41 #include <netinet/in.h>
     42 #endif
     43 #ifdef HAVE_NETINET_IN6_H
     44 #include <netinet/in6.h>
     45 #endif
     46 #ifdef HAVE_ARPA_INET_H
     47 #include <arpa/inet.h>
     48 #endif
     49 #ifdef HAVE_NETDB_H
     50 #include <netdb.h>
     51 #endif
     52 
     53 #include <curlx/curlx.h>
     54 
     55 /* adjust for old MSVC */
     56 #if defined(_MSC_VER) && (_MSC_VER < 1900)
     57 #  define snprintf _snprintf
     58 #endif
     59 
     60 #ifdef _WIN32
     61 #  define CURL_STRNICMP(p1, p2, n) _strnicmp(p1, p2, n)
     62 #elif defined(HAVE_STRCASECMP)
     63 #  ifdef HAVE_STRINGS_H
     64 #  include <strings.h>
     65 #  endif
     66 #  define CURL_STRNICMP(p1, p2, n) strncasecmp(p1, p2, n)
     67 #elif defined(HAVE_STRCMPI)
     68 #  define CURL_STRNICMP(p1, p2, n) strncmpi(p1, p2, n)
     69 #elif defined(HAVE_STRICMP)
     70 #  define CURL_STRNICMP(p1, p2, n) strnicmp(p1, p2, n)
     71 #else
     72 #  error "missing case insensitive comparison function"
     73 #endif
     74 
     75 enum {
     76   DOCNUMBER_NOTHING    = -7,
     77   DOCNUMBER_QUIT       = -6,
     78   DOCNUMBER_BADCONNECT = -5,
     79   DOCNUMBER_INTERNAL   = -4,
     80   DOCNUMBER_CONNECT    = -3,
     81   DOCNUMBER_WERULEZ    = -2,
     82   DOCNUMBER_404        = -1
     83 };
     84 
     85 #include <curl/curl.h> /* for curl_socket_t */
     86 
     87 #ifdef USE_UNIX_SOCKETS
     88 #ifdef HAVE_SYS_UN_H
     89 #include <sys/un.h> /* for sockaddr_un */
     90 #endif
     91 #endif /* USE_UNIX_SOCKETS */
     92 
     93 typedef union {
     94   struct sockaddr      sa;
     95   struct sockaddr_in   sa4;
     96 #ifdef USE_IPV6
     97   struct sockaddr_in6  sa6;
     98 #endif
     99 #ifdef USE_UNIX_SOCKETS
    100   struct sockaddr_un   sau;
    101 #endif
    102 } srvr_sockaddr_union_t;
    103 
    104 /* getpart */
    105 #define GPE_NO_BUFFER_SPACE -2
    106 #define GPE_OUT_OF_MEMORY   -1
    107 #define GPE_OK               0
    108 #define GPE_END_OF_FILE      1
    109 
    110 extern int getpart(char **outbuf, size_t *outlen,
    111                    const char *main, const char *sub, FILE *stream);
    112 
    113 /* utility functions */
    114 extern char *data_to_hex(char *data, size_t len);
    115 extern void logmsg(const char *msg, ...);
    116 extern void loghex(unsigned char *buffer, ssize_t len);
    117 extern unsigned char byteval(char *value);
    118 extern int win32_init(void);
    119 extern const char *sstrerror(int err);
    120 extern FILE *test2fopen(long testno, const char *logdir2);
    121 extern curl_off_t our_getpid(void);
    122 extern int write_pidfile(const char *filename);
    123 extern int write_portfile(const char *filename, int port);
    124 extern void set_advisor_read_lock(const char *filename);
    125 extern void clear_advisor_read_lock(const char *filename);
    126 static volatile int got_exit_signal = 0;
    127 static volatile int exit_signal = 0;
    128 #ifdef _WIN32
    129 static HANDLE exit_event = NULL;
    130 #endif
    131 extern void install_signal_handlers(bool keep_sigalrm);
    132 extern void restore_signal_handlers(bool keep_sigalrm);
    133 #ifdef USE_UNIX_SOCKETS
    134 extern int bind_unix_socket(curl_socket_t sock, const char *unix_socket,
    135                             struct sockaddr_un *sau);
    136 #endif
    137 extern unsigned short util_ultous(unsigned long ulnum);
    138 extern curl_socket_t sockdaemon(curl_socket_t sock,
    139                                 unsigned short *listenport,
    140                                 const char *unix_socket,
    141                                 bool bind_only);
    142 
    143 /* global variables */
    144 static const char *srcpath = "."; /* pointing to the test dir */
    145 static const char *pidname = NULL;
    146 static const char *portname = NULL; /* none by default */
    147 static const char *serverlogfile = NULL;
    148 static int serverlogslocked;
    149 static const char *configfile = NULL;
    150 static const char *logdir = "log";
    151 static char loglockfile[256];
    152 #ifdef USE_IPV6
    153 static bool use_ipv6 = FALSE;
    154 #endif
    155 static const char *ipv_inuse = "IPv4";
    156 static unsigned short server_port = 0;
    157 static const char *socket_type = "IPv4";
    158 static int socket_domain = AF_INET;
    159 
    160 #define SERVERLOGS_LOCKDIR "lock"  /* within logdir */
    161 
    162 #endif /* HEADER_SERVER_FIRST_H */