#endif
#include <curlx.h> /* from the private lib dir */
-#include "util.h"
-
-/* need init from main() */
-const char *pidname = NULL;
-const char *portname = NULL; /* none by default */
-const char *serverlogfile = NULL;
-int serverlogslocked;
-const char *configfile = NULL;
-const char *logdir = "log";
-char loglockfile[256];
+
+/* adjust for old MSVC */
+#if defined(_MSC_VER) && (_MSC_VER < 1900)
+# define snprintf _snprintf
+#endif
+
+#ifdef _WIN32
+# define CURL_STRNICMP(p1, p2, n) _strnicmp(p1, p2, n)
+#elif defined(HAVE_STRCASECMP)
+# ifdef HAVE_STRINGS_H
+# include <strings.h>
+# endif
+# define CURL_STRNICMP(p1, p2, n) strncasecmp(p1, p2, n)
+#elif defined(HAVE_STRCMPI)
+# define CURL_STRNICMP(p1, p2, n) strncmpi(p1, p2, n)
+#elif defined(HAVE_STRICMP)
+# define CURL_STRNICMP(p1, p2, n) strnicmp(p1, p2, n)
+#else
+# error "missing case insensitive comparison function"
+#endif
+
+enum {
+ DOCNUMBER_NOTHING = -7,
+ DOCNUMBER_QUIT = -6,
+ DOCNUMBER_BADCONNECT = -5,
+ DOCNUMBER_INTERNAL = -4,
+ DOCNUMBER_CONNECT = -3,
+ DOCNUMBER_WERULEZ = -2,
+ DOCNUMBER_404 = -1
+};
+
+#define SERVERLOGS_LOCKDIR "lock" /* within logdir */
+
+#include "timeval.h"
+
+#include <curl/curl.h> /* for curl_socket_t */
+
+#ifdef USE_UNIX_SOCKETS
+#ifdef HAVE_SYS_UN_H
+#include <sys/un.h> /* for sockaddr_un */
+#endif
+#endif /* USE_UNIX_SOCKETS */
+
+typedef union {
+ struct sockaddr sa;
+ struct sockaddr_in sa4;
#ifdef USE_IPV6
-bool use_ipv6 = FALSE;
+ struct sockaddr_in6 sa6;
#endif
-const char *ipv_inuse = "IPv4";
-unsigned short server_port = 0;
-const char *socket_type = "IPv4";
-int socket_domain = AF_INET;
+#ifdef USE_UNIX_SOCKETS
+ struct sockaddr_un sau;
+#endif
+} srvr_sockaddr_union_t;
+
+/* global variables */
+static const char *srcpath = "."; /* pointing to the test dir */
+static const char *pidname = NULL;
+static const char *portname = NULL; /* none by default */
+static const char *serverlogfile = NULL;
+static int serverlogslocked;
+static const char *configfile = NULL;
+static const char *logdir = "log";
+static char loglockfile[256];
+#ifdef USE_IPV6
+static bool use_ipv6 = FALSE;
+#endif
+static const char *ipv_inuse = "IPv4";
+static unsigned short server_port = 0;
+static const char *socket_type = "IPv4";
+static int socket_domain = AF_INET;
/* This function returns a pointer to STATIC memory. It converts the given
* binary lump to a hex formatted string usable for output in logs or
* whatever.
*/
-char *data_to_hex(char *data, size_t len)
+static char *data_to_hex(char *data, size_t len)
{
static char buf[256*3];
size_t i;
return buf;
}
-void logmsg(const char *msg, ...)
+static void logmsg(const char *msg, ...)
{
va_list ap;
char buffer[2048 + 1];
}
}
-void loghex(unsigned char *buffer, ssize_t len)
+static void loghex(unsigned char *buffer, ssize_t len)
{
char data[12000];
ssize_t i;
logmsg("'%s'", data);
}
-unsigned char byteval(char *value)
+static unsigned char byteval(char *value)
{
unsigned long num = strtoul(value, NULL, 10);
return num & 0xff;
_flushall();
}
-int win32_init(void)
+static int win32_init(void)
{
curlx_now_init();
#ifdef USE_WINSOCK
}
/* socket-safe strerror (works on Winsock errors, too) */
-const char *sstrerror(int err)
+static const char *sstrerror(int err)
{
static char buf[512];
return curlx_winapi_strerror(err, buf, sizeof(buf));
}
+#else
+#define sstrerror(e) strerror(e)
#endif /* _WIN32 */
-/* set by the main code to point to where the test dir is */
-const char *srcpath = ".";
-
-FILE *test2fopen(long testno, const char *logdir2)
+/* fopens the test case file */
+static FILE *test2fopen(long testno, const char *logdir2)
{
FILE *stream;
char filename[256];
* -1 = system call error, or invalid timeout value
* 0 = specified timeout has elapsed
*/
-int wait_ms(timediff_t timeout_ms)
+static int wait_ms(timediff_t timeout_ms)
{
int r = 0;
#define t_getpid() getpid()
#endif
-curl_off_t our_getpid(void)
+static curl_off_t our_getpid(void)
{
curl_off_t pid = (curl_off_t)t_getpid();
#ifdef _WIN32
return pid;
}
-int write_pidfile(const char *filename)
+static int write_pidfile(const char *filename)
{
FILE *pidfile;
curl_off_t pid;
}
/* store the used port number in a file */
-int write_portfile(const char *filename, int port)
+static int write_portfile(const char *filename, int port)
{
FILE *portfile = fopen(filename, "wb");
if(!portfile) {
return 1; /* success */
}
-void set_advisor_read_lock(const char *filename)
+static void set_advisor_read_lock(const char *filename)
{
FILE *lockfile;
int error = 0;
filename, errno, strerror(errno));
}
-void clear_advisor_read_lock(const char *filename)
+static void clear_advisor_read_lock(const char *filename)
{
int error = 0;
int res;
static HWND hidden_main_window = NULL;
#endif
-/* var which if set indicates that the program should finish execution */
-volatile int got_exit_signal = 0;
+/* global variable which if set indicates that the program should finish */
+static volatile int got_exit_signal = 0;
-/* if next is set indicates the first signal handled in exit_signal_handler */
-volatile int exit_signal = 0;
+/* global variable which if set indicates the first signal handled in
+ exit_signal_handler */
+static volatile int exit_signal = 0;
#ifdef _WIN32
-/* event which if set indicates that the program should finish */
-HANDLE exit_event = NULL;
+/* global event which if set indicates that the program should finish */
+static HANDLE exit_event = NULL;
#endif
/* signal handler that will be triggered to indicate that the program
}
#endif
-void install_signal_handlers(bool keep_sigalrm)
+static void install_signal_handlers(bool keep_sigalrm)
{
#ifdef _WIN32
/* setup Windows exit event before any signal can trigger */
#endif
}
-void restore_signal_handlers(bool keep_sigalrm)
+static void restore_signal_handlers(bool keep_sigalrm)
{
#ifdef SIGHUP
if(SIG_ERR != old_sighup_handler)
#ifdef USE_UNIX_SOCKETS
-int bind_unix_socket(curl_socket_t sock, const char *unix_socket,
- struct sockaddr_un *sau)
+static int bind_unix_socket(curl_socket_t sock, const char *unix_socket,
+ struct sockaddr_un *sau)
{
int error;
int rc;
#define CURL_MASK_USHORT ((unsigned short)~0)
#define CURL_MASK_SSHORT (CURL_MASK_USHORT >> 1)
-unsigned short util_ultous(unsigned long ulnum)
+static unsigned short util_ultous(unsigned long ulnum)
{
#ifdef __INTEL_COMPILER
# pragma warning(push)
+++ /dev/null
-#ifndef HEADER_CURL_SERVER_UTIL_H
-#define HEADER_CURL_SERVER_UTIL_H
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
- *
- * This software is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- * SPDX-License-Identifier: curl
- *
- ***************************************************************************/
-#include "curl_setup.h"
-
-/* adjust for old MSVC */
-#if defined(_MSC_VER) && (_MSC_VER < 1900)
-# define snprintf _snprintf
-#endif
-
-#ifdef _WIN32
-# define CURL_STRNICMP(p1, p2, n) _strnicmp(p1, p2, n)
-#elif defined(HAVE_STRCASECMP)
-# ifdef HAVE_STRINGS_H
-# include <strings.h>
-# endif
-# define CURL_STRNICMP(p1, p2, n) strncasecmp(p1, p2, n)
-#elif defined(HAVE_STRCMPI)
-# define CURL_STRNICMP(p1, p2, n) strncmpi(p1, p2, n)
-#elif defined(HAVE_STRICMP)
-# define CURL_STRNICMP(p1, p2, n) strnicmp(p1, p2, n)
-#else
-# error "missing case insensitive comparison function"
-#endif
-
-enum {
- DOCNUMBER_NOTHING = -7,
- DOCNUMBER_QUIT = -6,
- DOCNUMBER_BADCONNECT = -5,
- DOCNUMBER_INTERNAL = -4,
- DOCNUMBER_CONNECT = -3,
- DOCNUMBER_WERULEZ = -2,
- DOCNUMBER_404 = -1
-};
-
-char *data_to_hex(char *data, size_t len);
-void logmsg(const char *msg, ...) CURL_PRINTF(1, 2);
-void loghex(unsigned char *buffer, ssize_t len);
-unsigned char byteval(char *value);
-
-#define SERVERLOGS_LOCKDIR "lock" /* within logdir */
-
-/* global variables */
-extern const char *srcpath; /* where to find the 'data' dir */
-extern const char *pidname;
-extern const char *portname;
-extern const char *serverlogfile; /* log file name */
-extern int serverlogslocked;
-extern const char *configfile;
-extern const char *logdir;
-extern char loglockfile[256];
-#ifdef USE_IPV6
-extern bool use_ipv6;
-#endif
-extern const char *ipv_inuse;
-extern unsigned short server_port;
-extern const char *socket_type;
-extern int socket_domain;
-
-#ifdef _WIN32
-int win32_init(void);
-const char *sstrerror(int err);
-#else
-#define sstrerror(e) strerror(e)
-#endif
-
-/* fopens the test case file */
-FILE *test2fopen(long testno, const char *logdir);
-
-#include "timeval.h"
-
-int wait_ms(timediff_t timeout_ms);
-curl_off_t our_getpid(void);
-int write_pidfile(const char *filename);
-int write_portfile(const char *filename, int port);
-void set_advisor_read_lock(const char *filename);
-void clear_advisor_read_lock(const char *filename);
-
-/* global variable which if set indicates that the program should finish */
-extern volatile int got_exit_signal;
-
-/* global variable which if set indicates the first signal handled */
-extern volatile int exit_signal;
-
-#ifdef _WIN32
-/* global event which if set indicates that the program should finish */
-extern HANDLE exit_event;
-#endif
-
-void install_signal_handlers(bool keep_sigalrm);
-void restore_signal_handlers(bool keep_sigalrm);
-
-#include <curl/curl.h> /* for curl_socket_t */
-
-#ifdef USE_UNIX_SOCKETS
-#ifdef HAVE_SYS_UN_H
-#include <sys/un.h> /* for sockaddr_un */
-#endif
-int bind_unix_socket(curl_socket_t sock, const char *unix_socket,
- struct sockaddr_un *sau);
-#endif /* USE_UNIX_SOCKETS */
-
-typedef union {
- struct sockaddr sa;
- struct sockaddr_in sa4;
-#ifdef USE_IPV6
- struct sockaddr_in6 sa6;
-#endif
-#ifdef USE_UNIX_SOCKETS
- struct sockaddr_un sau;
-#endif
-} srvr_sockaddr_union_t;
-
-unsigned short util_ultous(unsigned long ulnum);
-
-#endif /* HEADER_CURL_SERVER_UTIL_H */