1 #ifndef HEADER_CURL_SERVER_UTIL_H 2 #define HEADER_CURL_SERVER_UTIL_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 "server_setup.h" 27 28 char *data_to_hex(char *data, size_t len); 29 void logmsg(const char *msg, ...); 30 long timediff(struct timeval newer, struct timeval older); 31 32 #define TEST_DATA_PATH "%s/data/test%ld" 33 #define ALTTEST_DATA_PATH "%s/test%ld" 34 #define SERVERLOGS_LOCKDIR "lock" /* within logdir */ 35 36 /* global variable, where to find the 'data' dir */ 37 extern const char *path; 38 39 /* global variable, log file name */ 40 extern const char *serverlogfile; 41 42 extern const char *cmdfile; 43 44 #ifdef WIN32 45 #include <process.h> 46 #include <fcntl.h> 47 48 #define sleep(sec) Sleep ((sec)*1000) 49 50 #undef perror 51 #define perror(m) win32_perror(m) 52 void win32_perror(const char *msg); 53 54 void win32_init(void); 55 void win32_cleanup(void); 56 const char *sstrerror(int err); 57 #else /* WIN32 */ 58 59 #define sstrerror(e) strerror(e) 60 #endif /* WIN32 */ 61 62 /* fopens the test case file */ 63 FILE *test2fopen(long testno, const char *logdir); 64 65 int wait_ms(int timeout_ms); 66 curl_off_t our_getpid(void); 67 int write_pidfile(const char *filename); 68 int write_portfile(const char *filename, int port); 69 void set_advisor_read_lock(const char *filename); 70 void clear_advisor_read_lock(const char *filename); 71 int strncasecompare(const char *first, const char *second, size_t max); 72 73 /* global variable which if set indicates that the program should finish */ 74 extern volatile int got_exit_signal; 75 76 /* global variable which if set indicates the first signal handled */ 77 extern volatile int exit_signal; 78 79 #ifdef WIN32 80 /* global event which if set indicates that the program should finish */ 81 extern HANDLE exit_event; 82 #endif 83 84 void install_signal_handlers(bool keep_sigalrm); 85 void restore_signal_handlers(bool keep_sigalrm); 86 87 #ifdef USE_UNIX_SOCKETS 88 89 #include <curl/curl.h> /* for curl_socket_t */ 90 91 #ifdef HAVE_SYS_UN_H 92 #include <sys/un.h> /* for sockaddr_un */ 93 #endif /* HAVE_SYS_UN_H */ 94 95 int bind_unix_socket(curl_socket_t sock, const char *unix_socket, 96 struct sockaddr_un *sau); 97 #endif /* USE_UNIX_SOCKETS */ 98 99 #endif /* HEADER_CURL_SERVER_UTIL_H */ 100