mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-07 08:52:01 +00:00
Merge branch 'http-mserv' into 'next'
HTTP Based Master Server + Multithreading See merge request STJr/SRB2!940
This commit is contained in:
commit
23f218117c
37 changed files with 4499 additions and 1839 deletions
19
.travis.yml
19
.travis.yml
|
@ -26,6 +26,7 @@ matrix:
|
||||||
- libgl1-mesa-dev
|
- libgl1-mesa-dev
|
||||||
- libgme-dev
|
- libgme-dev
|
||||||
- libopenmpt-dev
|
- libopenmpt-dev
|
||||||
|
- libcurl4-openssl-dev
|
||||||
- p7zip-full
|
- p7zip-full
|
||||||
- gcc-4.4
|
- gcc-4.4
|
||||||
compiler: gcc-4.4
|
compiler: gcc-4.4
|
||||||
|
@ -43,6 +44,7 @@ matrix:
|
||||||
- libgl1-mesa-dev
|
- libgl1-mesa-dev
|
||||||
- libgme-dev
|
- libgme-dev
|
||||||
- libopenmpt-dev
|
- libopenmpt-dev
|
||||||
|
- libcurl4-openssl-dev
|
||||||
- p7zip-full
|
- p7zip-full
|
||||||
- gcc-4.6
|
- gcc-4.6
|
||||||
compiler: gcc-4.6
|
compiler: gcc-4.6
|
||||||
|
@ -60,6 +62,7 @@ matrix:
|
||||||
- libgl1-mesa-dev
|
- libgl1-mesa-dev
|
||||||
- libgme-dev
|
- libgme-dev
|
||||||
- libopenmpt-dev
|
- libopenmpt-dev
|
||||||
|
- libcurl4-openssl-dev
|
||||||
- p7zip-full
|
- p7zip-full
|
||||||
- gcc-4.7
|
- gcc-4.7
|
||||||
compiler: gcc-4.7
|
compiler: gcc-4.7
|
||||||
|
@ -83,6 +86,7 @@ matrix:
|
||||||
- libgl1-mesa-dev
|
- libgl1-mesa-dev
|
||||||
- libgme-dev
|
- libgme-dev
|
||||||
- libopenmpt-dev
|
- libopenmpt-dev
|
||||||
|
- libcurl4-openssl-dev
|
||||||
- p7zip-full
|
- p7zip-full
|
||||||
- gcc-4.8
|
- gcc-4.8
|
||||||
compiler: gcc-4.8
|
compiler: gcc-4.8
|
||||||
|
@ -101,6 +105,7 @@ matrix:
|
||||||
- libgl1-mesa-dev
|
- libgl1-mesa-dev
|
||||||
- libgme-dev
|
- libgme-dev
|
||||||
- libopenmpt-dev
|
- libopenmpt-dev
|
||||||
|
- libcurl4-openssl-dev
|
||||||
- p7zip-full
|
- p7zip-full
|
||||||
- gcc-7
|
- gcc-7
|
||||||
compiler: gcc-7
|
compiler: gcc-7
|
||||||
|
@ -119,6 +124,7 @@ matrix:
|
||||||
- libgl1-mesa-dev
|
- libgl1-mesa-dev
|
||||||
- libgme-dev
|
- libgme-dev
|
||||||
- libopenmpt-dev
|
- libopenmpt-dev
|
||||||
|
- libcurl4-openssl-dev
|
||||||
- p7zip-full
|
- p7zip-full
|
||||||
- gcc-8
|
- gcc-8
|
||||||
compiler: gcc-8
|
compiler: gcc-8
|
||||||
|
@ -141,6 +147,7 @@ matrix:
|
||||||
- libgl1-mesa-dev
|
- libgl1-mesa-dev
|
||||||
- libgme-dev
|
- libgme-dev
|
||||||
- libopenmpt-dev
|
- libopenmpt-dev
|
||||||
|
- libcurl4-openssl-dev
|
||||||
- p7zip-full
|
- p7zip-full
|
||||||
- clang-3.5
|
- clang-3.5
|
||||||
compiler: clang-3.5
|
compiler: clang-3.5
|
||||||
|
@ -159,6 +166,7 @@ matrix:
|
||||||
- libgl1-mesa-dev
|
- libgl1-mesa-dev
|
||||||
- libgme-dev
|
- libgme-dev
|
||||||
- libopenmpt-dev
|
- libopenmpt-dev
|
||||||
|
- libcurl4-openssl-dev
|
||||||
- p7zip-full
|
- p7zip-full
|
||||||
- clang-3.6
|
- clang-3.6
|
||||||
compiler: clang-3.6
|
compiler: clang-3.6
|
||||||
|
@ -177,6 +185,7 @@ matrix:
|
||||||
- libgl1-mesa-dev
|
- libgl1-mesa-dev
|
||||||
- libgme-dev
|
- libgme-dev
|
||||||
- libopenmpt-dev
|
- libopenmpt-dev
|
||||||
|
- libcurl4-openssl-dev
|
||||||
- p7zip-full
|
- p7zip-full
|
||||||
- clang-3.7
|
- clang-3.7
|
||||||
compiler: clang-3.7
|
compiler: clang-3.7
|
||||||
|
@ -195,6 +204,7 @@ matrix:
|
||||||
- libgl1-mesa-dev
|
- libgl1-mesa-dev
|
||||||
- libgme-dev
|
- libgme-dev
|
||||||
- libopenmpt-dev
|
- libopenmpt-dev
|
||||||
|
- libcurl4-openssl-dev
|
||||||
- p7zip-full
|
- p7zip-full
|
||||||
- clang-3.8
|
- clang-3.8
|
||||||
compiler: clang-3.8
|
compiler: clang-3.8
|
||||||
|
@ -213,6 +223,7 @@ matrix:
|
||||||
- libgl1-mesa-dev
|
- libgl1-mesa-dev
|
||||||
- libgme-dev
|
- libgme-dev
|
||||||
- libopenmpt-dev
|
- libopenmpt-dev
|
||||||
|
- libcurl4-openssl-dev
|
||||||
- p7zip-full
|
- p7zip-full
|
||||||
- clang-3.9
|
- clang-3.9
|
||||||
compiler: clang-3.9
|
compiler: clang-3.9
|
||||||
|
@ -323,6 +334,7 @@ matrix:
|
||||||
- libpng-dev
|
- libpng-dev
|
||||||
- libgl1-mesa-dev
|
- libgl1-mesa-dev
|
||||||
- libgme-dev
|
- libgme-dev
|
||||||
|
- libcurl4-openssl-dev
|
||||||
- p7zip-full
|
- p7zip-full
|
||||||
- gcc-4.8
|
- gcc-4.8
|
||||||
compiler: gcc-4.8
|
compiler: gcc-4.8
|
||||||
|
@ -468,6 +480,7 @@ matrix:
|
||||||
- libgl1-mesa-dev
|
- libgl1-mesa-dev
|
||||||
- libgme-dev
|
- libgme-dev
|
||||||
- libopenmpt-dev
|
- libopenmpt-dev
|
||||||
|
- libcurl4-openssl-dev
|
||||||
- p7zip-full
|
- p7zip-full
|
||||||
- gcc-4.8
|
- gcc-4.8
|
||||||
compiler: gcc-4.8
|
compiler: gcc-4.8
|
||||||
|
@ -495,6 +508,7 @@ matrix:
|
||||||
- libgl1-mesa-dev
|
- libgl1-mesa-dev
|
||||||
- libgme-dev
|
- libgme-dev
|
||||||
- libopenmpt-dev
|
- libopenmpt-dev
|
||||||
|
- libcurl4-openssl-dev
|
||||||
- p7zip-full
|
- p7zip-full
|
||||||
- gcc-4.8
|
- gcc-4.8
|
||||||
compiler: gcc-4.8
|
compiler: gcc-4.8
|
||||||
|
@ -522,6 +536,7 @@ matrix:
|
||||||
- libgl1-mesa-dev
|
- libgl1-mesa-dev
|
||||||
- libgme-dev
|
- libgme-dev
|
||||||
- libopenmpt-dev
|
- libopenmpt-dev
|
||||||
|
- libcurl4-openssl-dev
|
||||||
- p7zip-full
|
- p7zip-full
|
||||||
- gcc-4.8
|
- gcc-4.8
|
||||||
compiler: gcc-4.8
|
compiler: gcc-4.8
|
||||||
|
@ -549,6 +564,7 @@ matrix:
|
||||||
- libgl1-mesa-dev
|
- libgl1-mesa-dev
|
||||||
- libgme-dev
|
- libgme-dev
|
||||||
- libopenmpt-dev
|
- libopenmpt-dev
|
||||||
|
- libcurl4-openssl-dev
|
||||||
- p7zip-full
|
- p7zip-full
|
||||||
- gcc-4.8
|
- gcc-4.8
|
||||||
compiler: gcc-4.8
|
compiler: gcc-4.8
|
||||||
|
@ -576,6 +592,7 @@ matrix:
|
||||||
- libgl1-mesa-dev
|
- libgl1-mesa-dev
|
||||||
- libgme-dev
|
- libgme-dev
|
||||||
- libopenmpt-dev
|
- libopenmpt-dev
|
||||||
|
- libcurl4-openssl-dev
|
||||||
- p7zip-full
|
- p7zip-full
|
||||||
- gcc-4.8
|
- gcc-4.8
|
||||||
compiler: gcc-4.8
|
compiler: gcc-4.8
|
||||||
|
@ -619,6 +636,7 @@ addons:
|
||||||
- libgme-dev
|
- libgme-dev
|
||||||
- zlib1g-dev
|
- zlib1g-dev
|
||||||
- libopenmpt-dev
|
- libopenmpt-dev
|
||||||
|
- libcurl4-openssl-dev
|
||||||
- p7zip-full
|
- p7zip-full
|
||||||
homebrew:
|
homebrew:
|
||||||
taps:
|
taps:
|
||||||
|
@ -629,6 +647,7 @@ addons:
|
||||||
- p7zip
|
- p7zip
|
||||||
- libopenmpt
|
- libopenmpt
|
||||||
- cmake
|
- cmake
|
||||||
|
- curl
|
||||||
update: true
|
update: true
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ Build-Depends: debhelper (>= 7.0.50~),
|
||||||
zlib1g-dev,
|
zlib1g-dev,
|
||||||
libgme-dev,
|
libgme-dev,
|
||||||
libopenmpt-dev,
|
libopenmpt-dev,
|
||||||
|
libcurl4-openssl-dev,
|
||||||
libglu1-dev | libglu-dev,
|
libglu1-dev | libglu-dev,
|
||||||
libosmesa6-dev | libgl-dev,
|
libosmesa6-dev | libgl-dev,
|
||||||
nasm [i386]
|
nasm [i386]
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
||||||
#ifndef __CURL_CURLVER_H
|
#ifndef CURLINC_CURLVER_H
|
||||||
#define __CURL_CURLVER_H
|
#define CURLINC_CURLVER_H
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* _ _ ____ _
|
* _ _ ____ _
|
||||||
* Project ___| | | | _ \| |
|
* Project ___| | | | _ \| |
|
||||||
|
@ -7,11 +7,11 @@
|
||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||||
*
|
*
|
||||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
* 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
|
* copies of the Software, and permit persons to whom the Software is
|
||||||
|
@ -26,17 +26,17 @@
|
||||||
a script at release-time. This was made its own header file in 7.11.2 */
|
a script at release-time. This was made its own header file in 7.11.2 */
|
||||||
|
|
||||||
/* This is the global package copyright */
|
/* This is the global package copyright */
|
||||||
#define LIBCURL_COPYRIGHT "1996 - 2011 Daniel Stenberg, <daniel@haxx.se>."
|
#define LIBCURL_COPYRIGHT "1996 - 2020 Daniel Stenberg, <daniel@haxx.se>."
|
||||||
|
|
||||||
/* This is the version number of the libcurl package from which this header
|
/* This is the version number of the libcurl package from which this header
|
||||||
file origins: */
|
file origins: */
|
||||||
#define LIBCURL_VERSION "7.21.6"
|
#define LIBCURL_VERSION "7.69.0"
|
||||||
|
|
||||||
/* The numeric version number is also available "in parts" by using these
|
/* The numeric version number is also available "in parts" by using these
|
||||||
defines: */
|
defines: */
|
||||||
#define LIBCURL_VERSION_MAJOR 7
|
#define LIBCURL_VERSION_MAJOR 7
|
||||||
#define LIBCURL_VERSION_MINOR 21
|
#define LIBCURL_VERSION_MINOR 69
|
||||||
#define LIBCURL_VERSION_PATCH 6
|
#define LIBCURL_VERSION_PATCH 0
|
||||||
|
|
||||||
/* This is the numeric version of the libcurl version number, meant for easier
|
/* This is the numeric version of the libcurl version number, meant for easier
|
||||||
parsing and comparions by programs. The LIBCURL_VERSION_NUM define will
|
parsing and comparions by programs. The LIBCURL_VERSION_NUM define will
|
||||||
|
@ -52,18 +52,26 @@
|
||||||
This 6-digit (24 bits) hexadecimal number does not show pre-release number,
|
This 6-digit (24 bits) hexadecimal number does not show pre-release number,
|
||||||
and it is always a greater number in a more recent release. It makes
|
and it is always a greater number in a more recent release. It makes
|
||||||
comparisons with greater than and less than work.
|
comparisons with greater than and less than work.
|
||||||
|
|
||||||
|
Note: This define is the full hex number and _does not_ use the
|
||||||
|
CURL_VERSION_BITS() macro since curl's own configure script greps for it
|
||||||
|
and needs it to contain the full number.
|
||||||
*/
|
*/
|
||||||
#define LIBCURL_VERSION_NUM 0x071506
|
#define LIBCURL_VERSION_NUM 0x074500
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is the date and time when the full source package was created. The
|
* This is the date and time when the full source package was created. The
|
||||||
* timestamp is not stored in git, as the timestamp is properly set in the
|
* timestamp is not stored in git, as the timestamp is properly set in the
|
||||||
* tarballs by the maketgz script.
|
* tarballs by the maketgz script.
|
||||||
*
|
*
|
||||||
* The format of the date should follow this template:
|
* The format of the date follows this template:
|
||||||
*
|
*
|
||||||
* "Mon Feb 12 11:35:33 UTC 2007"
|
* "2007-11-23"
|
||||||
*/
|
*/
|
||||||
#define LIBCURL_TIMESTAMP "Fri Apr 22 17:18:50 UTC 2011"
|
#define LIBCURL_TIMESTAMP "2020-03-04"
|
||||||
|
|
||||||
#endif /* __CURL_CURLVER_H */
|
#define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|(z))
|
||||||
|
#define CURL_AT_LEAST_VERSION(x,y,z) \
|
||||||
|
(LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z))
|
||||||
|
|
||||||
|
#endif /* CURLINC_CURLVER_H */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef __CURL_EASY_H
|
#ifndef CURLINC_EASY_H
|
||||||
#define __CURL_EASY_H
|
#define CURLINC_EASY_H
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* _ _ ____ _
|
* _ _ ____ _
|
||||||
* Project ___| | | | _ \| |
|
* Project ___| | | | _ \| |
|
||||||
|
@ -7,11 +7,11 @@
|
||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||||
*
|
*
|
||||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
* 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
|
* copies of the Software, and permit persons to whom the Software is
|
||||||
|
@ -95,6 +95,16 @@ CURL_EXTERN CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen,
|
||||||
CURL_EXTERN CURLcode curl_easy_send(CURL *curl, const void *buffer,
|
CURL_EXTERN CURLcode curl_easy_send(CURL *curl, const void *buffer,
|
||||||
size_t buflen, size_t *n);
|
size_t buflen, size_t *n);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NAME curl_easy_upkeep()
|
||||||
|
*
|
||||||
|
* DESCRIPTION
|
||||||
|
*
|
||||||
|
* Performs connection upkeep for the given session handle.
|
||||||
|
*/
|
||||||
|
CURL_EXTERN CURLcode curl_easy_upkeep(CURL *curl);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef __CURL_MPRINTF_H
|
#ifndef CURLINC_MPRINTF_H
|
||||||
#define __CURL_MPRINTF_H
|
#define CURLINC_MPRINTF_H
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* _ _ ____ _
|
* _ _ ____ _
|
||||||
* Project ___| | | | _ \| |
|
* Project ___| | | | _ \| |
|
||||||
|
@ -7,11 +7,11 @@
|
||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||||
*
|
*
|
||||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
* 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
|
* copies of the Software, and permit persons to whom the Software is
|
||||||
|
@ -24,8 +24,7 @@
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h> /* needed for FILE */
|
#include <stdio.h> /* needed for FILE */
|
||||||
|
#include "curl.h" /* for CURL_EXTERN */
|
||||||
#include "curl.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -44,38 +43,8 @@ CURL_EXTERN int curl_mvsnprintf(char *buffer, size_t maxlength,
|
||||||
CURL_EXTERN char *curl_maprintf(const char *format, ...);
|
CURL_EXTERN char *curl_maprintf(const char *format, ...);
|
||||||
CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args);
|
CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args);
|
||||||
|
|
||||||
#ifdef _MPRINTF_REPLACE
|
|
||||||
# undef printf
|
|
||||||
# undef fprintf
|
|
||||||
# undef sprintf
|
|
||||||
# undef vsprintf
|
|
||||||
# undef snprintf
|
|
||||||
# undef vprintf
|
|
||||||
# undef vfprintf
|
|
||||||
# undef vsnprintf
|
|
||||||
# undef aprintf
|
|
||||||
# undef vaprintf
|
|
||||||
# define printf curl_mprintf
|
|
||||||
# define fprintf curl_mfprintf
|
|
||||||
#ifdef CURLDEBUG
|
|
||||||
/* When built with CURLDEBUG we define away the sprintf() functions since we
|
|
||||||
don't want internal code to be using them */
|
|
||||||
# define sprintf sprintf_was_used
|
|
||||||
# define vsprintf vsprintf_was_used
|
|
||||||
#else
|
|
||||||
# define sprintf curl_msprintf
|
|
||||||
# define vsprintf curl_mvsprintf
|
|
||||||
#endif
|
|
||||||
# define snprintf curl_msnprintf
|
|
||||||
# define vprintf curl_mvprintf
|
|
||||||
# define vfprintf curl_mvfprintf
|
|
||||||
# define vsnprintf curl_mvsnprintf
|
|
||||||
# define aprintf curl_maprintf
|
|
||||||
# define vaprintf curl_mvaprintf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* __CURL_MPRINTF_H */
|
#endif /* CURLINC_MPRINTF_H */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef __CURL_MULTI_H
|
#ifndef CURLINC_MULTI_H
|
||||||
#define __CURL_MULTI_H
|
#define CURLINC_MULTI_H
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* _ _ ____ _
|
* _ _ ____ _
|
||||||
* Project ___| | | | _ \| |
|
* Project ___| | | | _ \| |
|
||||||
|
@ -7,11 +7,11 @@
|
||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||||
*
|
*
|
||||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
* 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
|
* copies of the Software, and permit persons to whom the Software is
|
||||||
|
@ -52,7 +52,11 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(BUILDING_LIBCURL) || defined(CURL_STRICTER)
|
||||||
|
typedef struct Curl_multi CURLM;
|
||||||
|
#else
|
||||||
typedef void CURLM;
|
typedef void CURLM;
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or
|
CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or
|
||||||
|
@ -64,6 +68,12 @@ typedef enum {
|
||||||
CURLM_INTERNAL_ERROR, /* this is a libcurl bug */
|
CURLM_INTERNAL_ERROR, /* this is a libcurl bug */
|
||||||
CURLM_BAD_SOCKET, /* the passed in socket argument did not match */
|
CURLM_BAD_SOCKET, /* the passed in socket argument did not match */
|
||||||
CURLM_UNKNOWN_OPTION, /* curl_multi_setopt() with unsupported option */
|
CURLM_UNKNOWN_OPTION, /* curl_multi_setopt() with unsupported option */
|
||||||
|
CURLM_ADDED_ALREADY, /* an easy handle already added to a multi handle was
|
||||||
|
attempted to get added - again */
|
||||||
|
CURLM_RECURSIVE_API_CALL, /* an api function was called from inside a
|
||||||
|
callback */
|
||||||
|
CURLM_WAKEUP_FAILURE, /* wakeup is unavailable or failed */
|
||||||
|
CURLM_BAD_FUNCTION_ARGUMENT, /* function called with a bad parameter */
|
||||||
CURLM_LAST
|
CURLM_LAST
|
||||||
} CURLMcode;
|
} CURLMcode;
|
||||||
|
|
||||||
|
@ -72,6 +82,11 @@ typedef enum {
|
||||||
curl_multi_perform() and CURLM_CALL_MULTI_PERFORM */
|
curl_multi_perform() and CURLM_CALL_MULTI_PERFORM */
|
||||||
#define CURLM_CALL_MULTI_SOCKET CURLM_CALL_MULTI_PERFORM
|
#define CURLM_CALL_MULTI_SOCKET CURLM_CALL_MULTI_PERFORM
|
||||||
|
|
||||||
|
/* bitmask bits for CURLMOPT_PIPELINING */
|
||||||
|
#define CURLPIPE_NOTHING 0L
|
||||||
|
#define CURLPIPE_HTTP1 1L
|
||||||
|
#define CURLPIPE_MULTIPLEX 2L
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CURLMSG_NONE, /* first, not used */
|
CURLMSG_NONE, /* first, not used */
|
||||||
CURLMSG_DONE, /* This easy handle has completed. 'result' contains
|
CURLMSG_DONE, /* This easy handle has completed. 'result' contains
|
||||||
|
@ -89,6 +104,19 @@ struct CURLMsg {
|
||||||
};
|
};
|
||||||
typedef struct CURLMsg CURLMsg;
|
typedef struct CURLMsg CURLMsg;
|
||||||
|
|
||||||
|
/* Based on poll(2) structure and values.
|
||||||
|
* We don't use pollfd and POLL* constants explicitly
|
||||||
|
* to cover platforms without poll(). */
|
||||||
|
#define CURL_WAIT_POLLIN 0x0001
|
||||||
|
#define CURL_WAIT_POLLPRI 0x0002
|
||||||
|
#define CURL_WAIT_POLLOUT 0x0004
|
||||||
|
|
||||||
|
struct curl_waitfd {
|
||||||
|
curl_socket_t fd;
|
||||||
|
short events;
|
||||||
|
short revents; /* not supported yet */
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Name: curl_multi_init()
|
* Name: curl_multi_init()
|
||||||
*
|
*
|
||||||
|
@ -133,6 +161,43 @@ CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle,
|
||||||
fd_set *exc_fd_set,
|
fd_set *exc_fd_set,
|
||||||
int *max_fd);
|
int *max_fd);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Name: curl_multi_wait()
|
||||||
|
*
|
||||||
|
* Desc: Poll on all fds within a CURLM set as well as any
|
||||||
|
* additional fds passed to the function.
|
||||||
|
*
|
||||||
|
* Returns: CURLMcode type, general multi error code.
|
||||||
|
*/
|
||||||
|
CURL_EXTERN CURLMcode curl_multi_wait(CURLM *multi_handle,
|
||||||
|
struct curl_waitfd extra_fds[],
|
||||||
|
unsigned int extra_nfds,
|
||||||
|
int timeout_ms,
|
||||||
|
int *ret);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Name: curl_multi_poll()
|
||||||
|
*
|
||||||
|
* Desc: Poll on all fds within a CURLM set as well as any
|
||||||
|
* additional fds passed to the function.
|
||||||
|
*
|
||||||
|
* Returns: CURLMcode type, general multi error code.
|
||||||
|
*/
|
||||||
|
CURL_EXTERN CURLMcode curl_multi_poll(CURLM *multi_handle,
|
||||||
|
struct curl_waitfd extra_fds[],
|
||||||
|
unsigned int extra_nfds,
|
||||||
|
int timeout_ms,
|
||||||
|
int *ret);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Name: curl_multi_wakeup()
|
||||||
|
*
|
||||||
|
* Desc: wakes up a sleeping curl_multi_poll call.
|
||||||
|
*
|
||||||
|
* Returns: CURLMcode type, general multi error code.
|
||||||
|
*/
|
||||||
|
CURL_EXTERN CURLMcode curl_multi_wakeup(CURLM *multi_handle);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Name: curl_multi_perform()
|
* Name: curl_multi_perform()
|
||||||
*
|
*
|
||||||
|
@ -146,8 +211,8 @@ CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle,
|
||||||
*
|
*
|
||||||
* Returns: CURLMcode type, general multi error code. *NOTE* that this only
|
* Returns: CURLMcode type, general multi error code. *NOTE* that this only
|
||||||
* returns errors etc regarding the whole multi stack. There might
|
* returns errors etc regarding the whole multi stack. There might
|
||||||
* still have occurred problems on invidual transfers even when this
|
* still have occurred problems on individual transfers even when
|
||||||
* returns OK.
|
* this returns OK.
|
||||||
*/
|
*/
|
||||||
CURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle,
|
CURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle,
|
||||||
int *running_handles);
|
int *running_handles);
|
||||||
|
@ -180,7 +245,7 @@ CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle);
|
||||||
* curl_multi_cleanup().
|
* curl_multi_cleanup().
|
||||||
*
|
*
|
||||||
* The 'CURLMsg' struct is meant to be very simple and only contain
|
* The 'CURLMsg' struct is meant to be very simple and only contain
|
||||||
* very basic informations. If more involved information is wanted,
|
* very basic information. If more involved information is wanted,
|
||||||
* we will provide the particular "transfer handle" in that struct
|
* we will provide the particular "transfer handle" in that struct
|
||||||
* and that should/could/would be used in subsequent
|
* and that should/could/would be used in subsequent
|
||||||
* curl_easy_getinfo() calls (or similar). The point being that we
|
* curl_easy_getinfo() calls (or similar). The point being that we
|
||||||
|
@ -279,37 +344,58 @@ CURL_EXTERN CURLMcode curl_multi_socket_all(CURLM *multi_handle,
|
||||||
CURL_EXTERN CURLMcode curl_multi_timeout(CURLM *multi_handle,
|
CURL_EXTERN CURLMcode curl_multi_timeout(CURLM *multi_handle,
|
||||||
long *milliseconds);
|
long *milliseconds);
|
||||||
|
|
||||||
#undef CINIT /* re-using the same name as in curl.h */
|
|
||||||
|
|
||||||
#ifdef CURL_ISOCPP
|
|
||||||
#define CINIT(name,type,num) CURLMOPT_ ## name = CURLOPTTYPE_ ## type + num
|
|
||||||
#else
|
|
||||||
/* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */
|
|
||||||
#define LONG CURLOPTTYPE_LONG
|
|
||||||
#define OBJECTPOINT CURLOPTTYPE_OBJECTPOINT
|
|
||||||
#define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT
|
|
||||||
#define OFF_T CURLOPTTYPE_OFF_T
|
|
||||||
#define CINIT(name,type,number) CURLMOPT_/**/name = type + number
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
/* This is the socket callback function pointer */
|
/* This is the socket callback function pointer */
|
||||||
CINIT(SOCKETFUNCTION, FUNCTIONPOINT, 1),
|
CURLOPT(CURLMOPT_SOCKETFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 1),
|
||||||
|
|
||||||
/* This is the argument passed to the socket callback */
|
/* This is the argument passed to the socket callback */
|
||||||
CINIT(SOCKETDATA, OBJECTPOINT, 2),
|
CURLOPT(CURLMOPT_SOCKETDATA, CURLOPTTYPE_OBJECTPOINT, 2),
|
||||||
|
|
||||||
/* set to 1 to enable pipelining for this multi handle */
|
/* set to 1 to enable pipelining for this multi handle */
|
||||||
CINIT(PIPELINING, LONG, 3),
|
CURLOPT(CURLMOPT_PIPELINING, CURLOPTTYPE_LONG, 3),
|
||||||
|
|
||||||
/* This is the timer callback function pointer */
|
/* This is the timer callback function pointer */
|
||||||
CINIT(TIMERFUNCTION, FUNCTIONPOINT, 4),
|
CURLOPT(CURLMOPT_TIMERFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 4),
|
||||||
|
|
||||||
/* This is the argument passed to the timer callback */
|
/* This is the argument passed to the timer callback */
|
||||||
CINIT(TIMERDATA, OBJECTPOINT, 5),
|
CURLOPT(CURLMOPT_TIMERDATA, CURLOPTTYPE_OBJECTPOINT, 5),
|
||||||
|
|
||||||
/* maximum number of entries in the connection cache */
|
/* maximum number of entries in the connection cache */
|
||||||
CINIT(MAXCONNECTS, LONG, 6),
|
CURLOPT(CURLMOPT_MAXCONNECTS, CURLOPTTYPE_LONG, 6),
|
||||||
|
|
||||||
|
/* maximum number of (pipelining) connections to one host */
|
||||||
|
CURLOPT(CURLMOPT_MAX_HOST_CONNECTIONS, CURLOPTTYPE_LONG, 7),
|
||||||
|
|
||||||
|
/* maximum number of requests in a pipeline */
|
||||||
|
CURLOPT(CURLMOPT_MAX_PIPELINE_LENGTH, CURLOPTTYPE_LONG, 8),
|
||||||
|
|
||||||
|
/* a connection with a content-length longer than this
|
||||||
|
will not be considered for pipelining */
|
||||||
|
CURLOPT(CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE, CURLOPTTYPE_OFF_T, 9),
|
||||||
|
|
||||||
|
/* a connection with a chunk length longer than this
|
||||||
|
will not be considered for pipelining */
|
||||||
|
CURLOPT(CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE, CURLOPTTYPE_OFF_T, 10),
|
||||||
|
|
||||||
|
/* a list of site names(+port) that are blacklisted from
|
||||||
|
pipelining */
|
||||||
|
CURLOPT(CURLMOPT_PIPELINING_SITE_BL, CURLOPTTYPE_OBJECTPOINT, 11),
|
||||||
|
|
||||||
|
/* a list of server types that are blacklisted from
|
||||||
|
pipelining */
|
||||||
|
CURLOPT(CURLMOPT_PIPELINING_SERVER_BL, CURLOPTTYPE_OBJECTPOINT, 12),
|
||||||
|
|
||||||
|
/* maximum number of open connections in total */
|
||||||
|
CURLOPT(CURLMOPT_MAX_TOTAL_CONNECTIONS, CURLOPTTYPE_LONG, 13),
|
||||||
|
|
||||||
|
/* This is the server push callback function pointer */
|
||||||
|
CURLOPT(CURLMOPT_PUSHFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 14),
|
||||||
|
|
||||||
|
/* This is the argument passed to the server push callback */
|
||||||
|
CURLOPT(CURLMOPT_PUSHDATA, CURLOPTTYPE_OBJECTPOINT, 15),
|
||||||
|
|
||||||
|
/* maximum number of concurrent streams to support on a connection */
|
||||||
|
CURLOPT(CURLMOPT_MAX_CONCURRENT_STREAMS, CURLOPTTYPE_LONG, 16),
|
||||||
|
|
||||||
CURLMOPT_LASTENTRY /* the last unused */
|
CURLMOPT_LASTENTRY /* the last unused */
|
||||||
} CURLMoption;
|
} CURLMoption;
|
||||||
|
@ -338,6 +424,31 @@ CURL_EXTERN CURLMcode curl_multi_setopt(CURLM *multi_handle,
|
||||||
CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle,
|
CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle,
|
||||||
curl_socket_t sockfd, void *sockp);
|
curl_socket_t sockfd, void *sockp);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Name: curl_push_callback
|
||||||
|
*
|
||||||
|
* Desc: This callback gets called when a new stream is being pushed by the
|
||||||
|
* server. It approves or denies the new stream.
|
||||||
|
*
|
||||||
|
* Returns: CURL_PUSH_OK or CURL_PUSH_DENY.
|
||||||
|
*/
|
||||||
|
#define CURL_PUSH_OK 0
|
||||||
|
#define CURL_PUSH_DENY 1
|
||||||
|
|
||||||
|
struct curl_pushheaders; /* forward declaration only */
|
||||||
|
|
||||||
|
CURL_EXTERN char *curl_pushheader_bynum(struct curl_pushheaders *h,
|
||||||
|
size_t num);
|
||||||
|
CURL_EXTERN char *curl_pushheader_byname(struct curl_pushheaders *h,
|
||||||
|
const char *name);
|
||||||
|
|
||||||
|
typedef int (*curl_push_callback)(CURL *parent,
|
||||||
|
CURL *easy,
|
||||||
|
size_t num_headers,
|
||||||
|
struct curl_pushheaders *headers,
|
||||||
|
void *userp);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* end of extern "C" */
|
} /* end of extern "C" */
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef __STDC_HEADERS_H
|
#ifndef CURLINC_STDCHEADERS_H
|
||||||
#define __STDC_HEADERS_H
|
#define CURLINC_STDCHEADERS_H
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* _ _ ____ _
|
* _ _ ____ _
|
||||||
* Project ___| | | | _ \| |
|
* Project ___| | | | _ \| |
|
||||||
|
@ -7,11 +7,11 @@
|
||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||||
*
|
*
|
||||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
* 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
|
* copies of the Software, and permit persons to whom the Software is
|
||||||
|
@ -30,4 +30,4 @@ size_t fwrite (const void *, size_t, size_t, FILE *);
|
||||||
int strcasecmp(const char *, const char *);
|
int strcasecmp(const char *, const char *);
|
||||||
int strncasecmp(const char *, const char *, size_t);
|
int strncasecmp(const char *, const char *, size_t);
|
||||||
|
|
||||||
#endif /* __STDC_HEADERS_H */
|
#endif /* CURLINC_STDCHEADERS_H */
|
||||||
|
|
504
libs/curl/include/curl/system.h
Normal file
504
libs/curl/include/curl/system.h
Normal file
|
@ -0,0 +1,504 @@
|
||||||
|
#ifndef CURLINC_SYSTEM_H
|
||||||
|
#define CURLINC_SYSTEM_H
|
||||||
|
/***************************************************************************
|
||||||
|
* _ _ ____ _
|
||||||
|
* Project ___| | | | _ \| |
|
||||||
|
* / __| | | | |_) | |
|
||||||
|
* | (__| |_| | _ <| |___
|
||||||
|
* \___|\___/|_| \_\_____|
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998 - 2019, 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.haxx.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.
|
||||||
|
*
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Try to keep one section per platform, compiler and architecture, otherwise,
|
||||||
|
* if an existing section is reused for a different one and later on the
|
||||||
|
* original is adjusted, probably the piggybacking one can be adversely
|
||||||
|
* changed.
|
||||||
|
*
|
||||||
|
* In order to differentiate between platforms/compilers/architectures use
|
||||||
|
* only compiler built in predefined preprocessor symbols.
|
||||||
|
*
|
||||||
|
* curl_off_t
|
||||||
|
* ----------
|
||||||
|
*
|
||||||
|
* For any given platform/compiler curl_off_t must be typedef'ed to a 64-bit
|
||||||
|
* wide signed integral data type. The width of this data type must remain
|
||||||
|
* constant and independent of any possible large file support settings.
|
||||||
|
*
|
||||||
|
* As an exception to the above, curl_off_t shall be typedef'ed to a 32-bit
|
||||||
|
* wide signed integral data type if there is no 64-bit type.
|
||||||
|
*
|
||||||
|
* As a general rule, curl_off_t shall not be mapped to off_t. This rule shall
|
||||||
|
* only be violated if off_t is the only 64-bit data type available and the
|
||||||
|
* size of off_t is independent of large file support settings. Keep your
|
||||||
|
* build on the safe side avoiding an off_t gating. If you have a 64-bit
|
||||||
|
* off_t then take for sure that another 64-bit data type exists, dig deeper
|
||||||
|
* and you will find it.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(__DJGPP__) || defined(__GO32__)
|
||||||
|
# if defined(__DJGPP__) && (__DJGPP__ > 1)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# else
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# endif
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||||
|
|
||||||
|
#elif defined(__SALFORDC__)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||||
|
|
||||||
|
#elif defined(__BORLANDC__)
|
||||||
|
# if (__BORLANDC__ < 0x520)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# else
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||||
|
# endif
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||||
|
|
||||||
|
#elif defined(__TURBOC__)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||||
|
|
||||||
|
#elif defined(__WATCOMC__)
|
||||||
|
# if defined(__386__)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||||
|
# else
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# endif
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||||
|
|
||||||
|
#elif defined(__POCC__)
|
||||||
|
# if (__POCC__ < 280)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# elif defined(_MSC_VER)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||||
|
# else
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# endif
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||||
|
|
||||||
|
#elif defined(__LCC__)
|
||||||
|
# if defined(__e2k__) /* MCST eLbrus C Compiler */
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||||
|
# define CURL_PULL_SYS_TYPES_H 1
|
||||||
|
# define CURL_PULL_SYS_SOCKET_H 1
|
||||||
|
# else /* Local (or Little) C Compiler */
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#elif defined(__SYMBIAN32__)
|
||||||
|
# if defined(__EABI__) /* Treat all ARM compilers equally */
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# elif defined(__CW32__)
|
||||||
|
# pragma longlong on
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# elif defined(__VC32__)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# endif
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
|
||||||
|
|
||||||
|
#elif defined(__MWERKS__)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||||
|
|
||||||
|
#elif defined(_WIN32_WCE)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||||
|
|
||||||
|
#elif defined(__MINGW32__)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||||
|
# define CURL_PULL_SYS_TYPES_H 1
|
||||||
|
# define CURL_PULL_WS2TCPIP_H 1
|
||||||
|
|
||||||
|
#elif defined(__VMS)
|
||||||
|
# if defined(__VAX)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# else
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# endif
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
|
||||||
|
|
||||||
|
#elif defined(__OS400__)
|
||||||
|
# if defined(__ILEC400__)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||||
|
# define CURL_PULL_SYS_TYPES_H 1
|
||||||
|
# define CURL_PULL_SYS_SOCKET_H 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#elif defined(__MVS__)
|
||||||
|
# if defined(__IBMC__) || defined(__IBMCPP__)
|
||||||
|
# if defined(_ILP32)
|
||||||
|
# elif defined(_LP64)
|
||||||
|
# endif
|
||||||
|
# if defined(_LONG_LONG)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# elif defined(_LP64)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# else
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# endif
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||||
|
# define CURL_PULL_SYS_TYPES_H 1
|
||||||
|
# define CURL_PULL_SYS_SOCKET_H 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#elif defined(__370__)
|
||||||
|
# if defined(__IBMC__) || defined(__IBMCPP__)
|
||||||
|
# if defined(_ILP32)
|
||||||
|
# elif defined(_LP64)
|
||||||
|
# endif
|
||||||
|
# if defined(_LONG_LONG)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# elif defined(_LP64)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# else
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# endif
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||||
|
# define CURL_PULL_SYS_TYPES_H 1
|
||||||
|
# define CURL_PULL_SYS_SOCKET_H 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#elif defined(TPF)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||||
|
|
||||||
|
#elif defined(__TINYC__) /* also known as tcc */
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||||
|
# define CURL_PULL_SYS_TYPES_H 1
|
||||||
|
# define CURL_PULL_SYS_SOCKET_H 1
|
||||||
|
|
||||||
|
#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) /* Oracle Solaris Studio */
|
||||||
|
# if !defined(__LP64) && (defined(__ILP32) || \
|
||||||
|
defined(__i386) || \
|
||||||
|
defined(__sparcv8) || \
|
||||||
|
defined(__sparcv8plus))
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# elif defined(__LP64) || \
|
||||||
|
defined(__amd64) || defined(__sparcv9)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# endif
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||||
|
# define CURL_PULL_SYS_TYPES_H 1
|
||||||
|
# define CURL_PULL_SYS_SOCKET_H 1
|
||||||
|
|
||||||
|
#elif defined(__xlc__) /* IBM xlc compiler */
|
||||||
|
# if !defined(_LP64)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# else
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# endif
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||||
|
# define CURL_PULL_SYS_TYPES_H 1
|
||||||
|
# define CURL_PULL_SYS_SOCKET_H 1
|
||||||
|
|
||||||
|
/* ===================================== */
|
||||||
|
/* KEEP MSVC THE PENULTIMATE ENTRY */
|
||||||
|
/* ===================================== */
|
||||||
|
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
# if (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||||
|
# else
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# endif
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||||
|
|
||||||
|
/* ===================================== */
|
||||||
|
/* KEEP GENERIC GCC THE LAST ENTRY */
|
||||||
|
/* ===================================== */
|
||||||
|
|
||||||
|
#elif defined(__GNUC__) && !defined(_SCO_DS)
|
||||||
|
# if !defined(__LP64__) && \
|
||||||
|
(defined(__ILP32__) || defined(__i386__) || defined(__hppa__) || \
|
||||||
|
defined(__ppc__) || defined(__powerpc__) || defined(__arm__) || \
|
||||||
|
defined(__sparc__) || defined(__mips__) || defined(__sh__) || \
|
||||||
|
defined(__XTENSA__) || \
|
||||||
|
(defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 4) || \
|
||||||
|
(defined(__LONG_MAX__) && __LONG_MAX__ == 2147483647L))
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
# elif defined(__LP64__) || \
|
||||||
|
defined(__x86_64__) || defined(__ppc64__) || defined(__sparc64__) || \
|
||||||
|
defined(__e2k__) || \
|
||||||
|
(defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 8) || \
|
||||||
|
(defined(__LONG_MAX__) && __LONG_MAX__ == 9223372036854775807L)
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# endif
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||||
|
# define CURL_PULL_SYS_TYPES_H 1
|
||||||
|
# define CURL_PULL_SYS_SOCKET_H 1
|
||||||
|
|
||||||
|
#else
|
||||||
|
/* generic "safe guess" on old 32 bit style */
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T L
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||||
|
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _AIX
|
||||||
|
/* AIX needs <sys/poll.h> */
|
||||||
|
#define CURL_PULL_SYS_POLL_H
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* CURL_PULL_WS2TCPIP_H is defined above when inclusion of header file */
|
||||||
|
/* ws2tcpip.h is required here to properly make type definitions below. */
|
||||||
|
#ifdef CURL_PULL_WS2TCPIP_H
|
||||||
|
# include <winsock2.h>
|
||||||
|
# include <windows.h>
|
||||||
|
# include <ws2tcpip.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* CURL_PULL_SYS_TYPES_H is defined above when inclusion of header file */
|
||||||
|
/* sys/types.h is required here to properly make type definitions below. */
|
||||||
|
#ifdef CURL_PULL_SYS_TYPES_H
|
||||||
|
# include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* CURL_PULL_SYS_SOCKET_H is defined above when inclusion of header file */
|
||||||
|
/* sys/socket.h is required here to properly make type definitions below. */
|
||||||
|
#ifdef CURL_PULL_SYS_SOCKET_H
|
||||||
|
# include <sys/socket.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* CURL_PULL_SYS_POLL_H is defined above when inclusion of header file */
|
||||||
|
/* sys/poll.h is required here to properly make type definitions below. */
|
||||||
|
#ifdef CURL_PULL_SYS_POLL_H
|
||||||
|
# include <sys/poll.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Data type definition of curl_socklen_t. */
|
||||||
|
#ifdef CURL_TYPEOF_CURL_SOCKLEN_T
|
||||||
|
typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Data type definition of curl_off_t. */
|
||||||
|
|
||||||
|
#ifdef CURL_TYPEOF_CURL_OFF_T
|
||||||
|
typedef CURL_TYPEOF_CURL_OFF_T curl_off_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CURL_ISOCPP and CURL_OFF_T_C definitions are done here in order to allow
|
||||||
|
* these to be visible and exported by the external libcurl interface API,
|
||||||
|
* while also making them visible to the library internals, simply including
|
||||||
|
* curl_setup.h, without actually needing to include curl.h internally.
|
||||||
|
* If some day this section would grow big enough, all this should be moved
|
||||||
|
* to its own header file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Figure out if we can use the ## preprocessor operator, which is supported
|
||||||
|
* by ISO/ANSI C and C++. Some compilers support it without setting __STDC__
|
||||||
|
* or __cplusplus so we need to carefully check for them too.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \
|
||||||
|
defined(__HP_aCC) || defined(__BORLANDC__) || defined(__LCC__) || \
|
||||||
|
defined(__POCC__) || defined(__SALFORDC__) || defined(__HIGHC__) || \
|
||||||
|
defined(__ILEC400__)
|
||||||
|
/* This compiler is believed to have an ISO compatible preprocessor */
|
||||||
|
#define CURL_ISOCPP
|
||||||
|
#else
|
||||||
|
/* This compiler is believed NOT to have an ISO compatible preprocessor */
|
||||||
|
#undef CURL_ISOCPP
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Macros for minimum-width signed and unsigned curl_off_t integer constants.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(__BORLANDC__) && (__BORLANDC__ == 0x0551)
|
||||||
|
# define CURLINC_OFF_T_C_HLPR2(x) x
|
||||||
|
# define CURLINC_OFF_T_C_HLPR1(x) CURLINC_OFF_T_C_HLPR2(x)
|
||||||
|
# define CURL_OFF_T_C(Val) CURLINC_OFF_T_C_HLPR1(Val) ## \
|
||||||
|
CURLINC_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_T)
|
||||||
|
# define CURL_OFF_TU_C(Val) CURLINC_OFF_T_C_HLPR1(Val) ## \
|
||||||
|
CURLINC_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_TU)
|
||||||
|
#else
|
||||||
|
# ifdef CURL_ISOCPP
|
||||||
|
# define CURLINC_OFF_T_C_HLPR2(Val,Suffix) Val ## Suffix
|
||||||
|
# else
|
||||||
|
# define CURLINC_OFF_T_C_HLPR2(Val,Suffix) Val/**/Suffix
|
||||||
|
# endif
|
||||||
|
# define CURLINC_OFF_T_C_HLPR1(Val,Suffix) CURLINC_OFF_T_C_HLPR2(Val,Suffix)
|
||||||
|
# define CURL_OFF_T_C(Val) CURLINC_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_T)
|
||||||
|
# define CURL_OFF_TU_C(Val) CURLINC_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_TU)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* CURLINC_SYSTEM_H */
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef __CURL_TYPECHECK_GCC_H
|
#ifndef CURLINC_TYPECHECK_GCC_H
|
||||||
#define __CURL_TYPECHECK_GCC_H
|
#define CURLINC_TYPECHECK_GCC_H
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* _ _ ____ _
|
* _ _ ____ _
|
||||||
* Project ___| | | | _ \| |
|
* Project ___| | | | _ \| |
|
||||||
|
@ -7,11 +7,11 @@
|
||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||||
*
|
*
|
||||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
* 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
|
* copies of the Software, and permit persons to whom the Software is
|
||||||
|
@ -25,10 +25,10 @@
|
||||||
/* wraps curl_easy_setopt() with typechecking */
|
/* wraps curl_easy_setopt() with typechecking */
|
||||||
|
|
||||||
/* To add a new kind of warning, add an
|
/* To add a new kind of warning, add an
|
||||||
* if(_curl_is_sometype_option(_curl_opt))
|
* if(curlcheck_sometype_option(_curl_opt))
|
||||||
* if(!_curl_is_sometype(value))
|
* if(!curlcheck_sometype(value))
|
||||||
* _curl_easy_setopt_err_sometype();
|
* _curl_easy_setopt_err_sometype();
|
||||||
* block and define _curl_is_sometype_option, _curl_is_sometype and
|
* block and define curlcheck_sometype_option, curlcheck_sometype and
|
||||||
* _curl_easy_setopt_err_sometype below
|
* _curl_easy_setopt_err_sometype below
|
||||||
*
|
*
|
||||||
* NOTE: We use two nested 'if' statements here instead of the && operator, in
|
* NOTE: We use two nested 'if' statements here instead of the && operator, in
|
||||||
|
@ -42,95 +42,111 @@
|
||||||
__extension__({ \
|
__extension__({ \
|
||||||
__typeof__(option) _curl_opt = option; \
|
__typeof__(option) _curl_opt = option; \
|
||||||
if(__builtin_constant_p(_curl_opt)) { \
|
if(__builtin_constant_p(_curl_opt)) { \
|
||||||
if (_curl_is_long_option(_curl_opt)) \
|
if(curlcheck_long_option(_curl_opt)) \
|
||||||
if (!_curl_is_long(value)) \
|
if(!curlcheck_long(value)) \
|
||||||
_curl_easy_setopt_err_long(); \
|
_curl_easy_setopt_err_long(); \
|
||||||
if (_curl_is_off_t_option(_curl_opt)) \
|
if(curlcheck_off_t_option(_curl_opt)) \
|
||||||
if (!_curl_is_off_t(value)) \
|
if(!curlcheck_off_t(value)) \
|
||||||
_curl_easy_setopt_err_curl_off_t(); \
|
_curl_easy_setopt_err_curl_off_t(); \
|
||||||
if (_curl_is_string_option(_curl_opt)) \
|
if(curlcheck_string_option(_curl_opt)) \
|
||||||
if (!_curl_is_string(value)) \
|
if(!curlcheck_string(value)) \
|
||||||
_curl_easy_setopt_err_string(); \
|
_curl_easy_setopt_err_string(); \
|
||||||
if (_curl_is_write_cb_option(_curl_opt)) \
|
if(curlcheck_write_cb_option(_curl_opt)) \
|
||||||
if (!_curl_is_write_cb(value)) \
|
if(!curlcheck_write_cb(value)) \
|
||||||
_curl_easy_setopt_err_write_callback(); \
|
_curl_easy_setopt_err_write_callback(); \
|
||||||
|
if((_curl_opt) == CURLOPT_RESOLVER_START_FUNCTION) \
|
||||||
|
if(!curlcheck_resolver_start_callback(value)) \
|
||||||
|
_curl_easy_setopt_err_resolver_start_callback(); \
|
||||||
if((_curl_opt) == CURLOPT_READFUNCTION) \
|
if((_curl_opt) == CURLOPT_READFUNCTION) \
|
||||||
if (!_curl_is_read_cb(value)) \
|
if(!curlcheck_read_cb(value)) \
|
||||||
_curl_easy_setopt_err_read_cb(); \
|
_curl_easy_setopt_err_read_cb(); \
|
||||||
if((_curl_opt) == CURLOPT_IOCTLFUNCTION) \
|
if((_curl_opt) == CURLOPT_IOCTLFUNCTION) \
|
||||||
if (!_curl_is_ioctl_cb(value)) \
|
if(!curlcheck_ioctl_cb(value)) \
|
||||||
_curl_easy_setopt_err_ioctl_cb(); \
|
_curl_easy_setopt_err_ioctl_cb(); \
|
||||||
if((_curl_opt) == CURLOPT_SOCKOPTFUNCTION) \
|
if((_curl_opt) == CURLOPT_SOCKOPTFUNCTION) \
|
||||||
if (!_curl_is_sockopt_cb(value)) \
|
if(!curlcheck_sockopt_cb(value)) \
|
||||||
_curl_easy_setopt_err_sockopt_cb(); \
|
_curl_easy_setopt_err_sockopt_cb(); \
|
||||||
if((_curl_opt) == CURLOPT_OPENSOCKETFUNCTION) \
|
if((_curl_opt) == CURLOPT_OPENSOCKETFUNCTION) \
|
||||||
if (!_curl_is_opensocket_cb(value)) \
|
if(!curlcheck_opensocket_cb(value)) \
|
||||||
_curl_easy_setopt_err_opensocket_cb(); \
|
_curl_easy_setopt_err_opensocket_cb(); \
|
||||||
if((_curl_opt) == CURLOPT_PROGRESSFUNCTION) \
|
if((_curl_opt) == CURLOPT_PROGRESSFUNCTION) \
|
||||||
if (!_curl_is_progress_cb(value)) \
|
if(!curlcheck_progress_cb(value)) \
|
||||||
_curl_easy_setopt_err_progress_cb(); \
|
_curl_easy_setopt_err_progress_cb(); \
|
||||||
if((_curl_opt) == CURLOPT_DEBUGFUNCTION) \
|
if((_curl_opt) == CURLOPT_DEBUGFUNCTION) \
|
||||||
if (!_curl_is_debug_cb(value)) \
|
if(!curlcheck_debug_cb(value)) \
|
||||||
_curl_easy_setopt_err_debug_cb(); \
|
_curl_easy_setopt_err_debug_cb(); \
|
||||||
if((_curl_opt) == CURLOPT_SSL_CTX_FUNCTION) \
|
if((_curl_opt) == CURLOPT_SSL_CTX_FUNCTION) \
|
||||||
if (!_curl_is_ssl_ctx_cb(value)) \
|
if(!curlcheck_ssl_ctx_cb(value)) \
|
||||||
_curl_easy_setopt_err_ssl_ctx_cb(); \
|
_curl_easy_setopt_err_ssl_ctx_cb(); \
|
||||||
if (_curl_is_conv_cb_option(_curl_opt)) \
|
if(curlcheck_conv_cb_option(_curl_opt)) \
|
||||||
if (!_curl_is_conv_cb(value)) \
|
if(!curlcheck_conv_cb(value)) \
|
||||||
_curl_easy_setopt_err_conv_cb(); \
|
_curl_easy_setopt_err_conv_cb(); \
|
||||||
if((_curl_opt) == CURLOPT_SEEKFUNCTION) \
|
if((_curl_opt) == CURLOPT_SEEKFUNCTION) \
|
||||||
if (!_curl_is_seek_cb(value)) \
|
if(!curlcheck_seek_cb(value)) \
|
||||||
_curl_easy_setopt_err_seek_cb(); \
|
_curl_easy_setopt_err_seek_cb(); \
|
||||||
if (_curl_is_cb_data_option(_curl_opt)) \
|
if(curlcheck_cb_data_option(_curl_opt)) \
|
||||||
if (!_curl_is_cb_data(value)) \
|
if(!curlcheck_cb_data(value)) \
|
||||||
_curl_easy_setopt_err_cb_data(); \
|
_curl_easy_setopt_err_cb_data(); \
|
||||||
if((_curl_opt) == CURLOPT_ERRORBUFFER) \
|
if((_curl_opt) == CURLOPT_ERRORBUFFER) \
|
||||||
if (!_curl_is_error_buffer(value)) \
|
if(!curlcheck_error_buffer(value)) \
|
||||||
_curl_easy_setopt_err_error_buffer(); \
|
_curl_easy_setopt_err_error_buffer(); \
|
||||||
if((_curl_opt) == CURLOPT_STDERR) \
|
if((_curl_opt) == CURLOPT_STDERR) \
|
||||||
if (!_curl_is_FILE(value)) \
|
if(!curlcheck_FILE(value)) \
|
||||||
_curl_easy_setopt_err_FILE(); \
|
_curl_easy_setopt_err_FILE(); \
|
||||||
if (_curl_is_postfields_option(_curl_opt)) \
|
if(curlcheck_postfields_option(_curl_opt)) \
|
||||||
if (!_curl_is_postfields(value)) \
|
if(!curlcheck_postfields(value)) \
|
||||||
_curl_easy_setopt_err_postfields(); \
|
_curl_easy_setopt_err_postfields(); \
|
||||||
if((_curl_opt) == CURLOPT_HTTPPOST) \
|
if((_curl_opt) == CURLOPT_HTTPPOST) \
|
||||||
if (!_curl_is_arr((value), struct curl_httppost)) \
|
if(!curlcheck_arr((value), struct curl_httppost)) \
|
||||||
_curl_easy_setopt_err_curl_httpost(); \
|
_curl_easy_setopt_err_curl_httpost(); \
|
||||||
if (_curl_is_slist_option(_curl_opt)) \
|
if((_curl_opt) == CURLOPT_MIMEPOST) \
|
||||||
if (!_curl_is_arr((value), struct curl_slist)) \
|
if(!curlcheck_ptr((value), curl_mime)) \
|
||||||
|
_curl_easy_setopt_err_curl_mimepost(); \
|
||||||
|
if(curlcheck_slist_option(_curl_opt)) \
|
||||||
|
if(!curlcheck_arr((value), struct curl_slist)) \
|
||||||
_curl_easy_setopt_err_curl_slist(); \
|
_curl_easy_setopt_err_curl_slist(); \
|
||||||
if((_curl_opt) == CURLOPT_SHARE) \
|
if((_curl_opt) == CURLOPT_SHARE) \
|
||||||
if (!_curl_is_ptr((value), CURLSH)) \
|
if(!curlcheck_ptr((value), CURLSH)) \
|
||||||
_curl_easy_setopt_err_CURLSH(); \
|
_curl_easy_setopt_err_CURLSH(); \
|
||||||
} \
|
} \
|
||||||
curl_easy_setopt(handle, _curl_opt, value); \
|
curl_easy_setopt(handle, _curl_opt, value); \
|
||||||
})
|
})
|
||||||
|
|
||||||
/* wraps curl_easy_getinfo() with typechecking */
|
/* wraps curl_easy_getinfo() with typechecking */
|
||||||
/* FIXME: don't allow const pointers */
|
|
||||||
#define curl_easy_getinfo(handle, info, arg) \
|
#define curl_easy_getinfo(handle, info, arg) \
|
||||||
__extension__({ \
|
__extension__({ \
|
||||||
__typeof__(info) _curl_info = info; \
|
__typeof__(info) _curl_info = info; \
|
||||||
if(__builtin_constant_p(_curl_info)) { \
|
if(__builtin_constant_p(_curl_info)) { \
|
||||||
if (_curl_is_string_info(_curl_info)) \
|
if(curlcheck_string_info(_curl_info)) \
|
||||||
if (!_curl_is_arr((arg), char *)) \
|
if(!curlcheck_arr((arg), char *)) \
|
||||||
_curl_easy_getinfo_err_string(); \
|
_curl_easy_getinfo_err_string(); \
|
||||||
if (_curl_is_long_info(_curl_info)) \
|
if(curlcheck_long_info(_curl_info)) \
|
||||||
if (!_curl_is_arr((arg), long)) \
|
if(!curlcheck_arr((arg), long)) \
|
||||||
_curl_easy_getinfo_err_long(); \
|
_curl_easy_getinfo_err_long(); \
|
||||||
if (_curl_is_double_info(_curl_info)) \
|
if(curlcheck_double_info(_curl_info)) \
|
||||||
if (!_curl_is_arr((arg), double)) \
|
if(!curlcheck_arr((arg), double)) \
|
||||||
_curl_easy_getinfo_err_double(); \
|
_curl_easy_getinfo_err_double(); \
|
||||||
if (_curl_is_slist_info(_curl_info)) \
|
if(curlcheck_slist_info(_curl_info)) \
|
||||||
if (!_curl_is_arr((arg), struct curl_slist *)) \
|
if(!curlcheck_arr((arg), struct curl_slist *)) \
|
||||||
_curl_easy_getinfo_err_curl_slist(); \
|
_curl_easy_getinfo_err_curl_slist(); \
|
||||||
|
if(curlcheck_tlssessioninfo_info(_curl_info)) \
|
||||||
|
if(!curlcheck_arr((arg), struct curl_tlssessioninfo *)) \
|
||||||
|
_curl_easy_getinfo_err_curl_tlssesssioninfo(); \
|
||||||
|
if(curlcheck_certinfo_info(_curl_info)) \
|
||||||
|
if(!curlcheck_arr((arg), struct curl_certinfo *)) \
|
||||||
|
_curl_easy_getinfo_err_curl_certinfo(); \
|
||||||
|
if(curlcheck_socket_info(_curl_info)) \
|
||||||
|
if(!curlcheck_arr((arg), curl_socket_t)) \
|
||||||
|
_curl_easy_getinfo_err_curl_socket(); \
|
||||||
|
if(curlcheck_off_t_info(_curl_info)) \
|
||||||
|
if(!curlcheck_arr((arg), curl_off_t)) \
|
||||||
|
_curl_easy_getinfo_err_curl_off_t(); \
|
||||||
} \
|
} \
|
||||||
curl_easy_getinfo(handle, _curl_info, arg); \
|
curl_easy_getinfo(handle, _curl_info, arg); \
|
||||||
})
|
})
|
||||||
|
|
||||||
/* TODO: typechecking for curl_share_setopt() and curl_multi_setopt(),
|
/*
|
||||||
* for now just make sure that the functions are called with three
|
* For now, just make sure that the functions are called with three arguments
|
||||||
* arguments
|
|
||||||
*/
|
*/
|
||||||
#define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param)
|
#define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param)
|
||||||
#define curl_multi_setopt(handle,opt,param) curl_multi_setopt(handle,opt,param)
|
#define curl_multi_setopt(handle,opt,param) curl_multi_setopt(handle,opt,param)
|
||||||
|
@ -140,61 +156,84 @@ __extension__ ({ \
|
||||||
* functions */
|
* functions */
|
||||||
|
|
||||||
/* To define a new warning, use _CURL_WARNING(identifier, "message") */
|
/* To define a new warning, use _CURL_WARNING(identifier, "message") */
|
||||||
#define _CURL_WARNING(id, message) \
|
#define CURLWARNING(id, message) \
|
||||||
static void __attribute__((warning(message))) __attribute__((unused)) \
|
static void __attribute__((__warning__(message))) \
|
||||||
__attribute__((noinline)) id(void) { __asm__(""); }
|
__attribute__((__unused__)) __attribute__((__noinline__)) \
|
||||||
|
id(void) { __asm__(""); }
|
||||||
|
|
||||||
_CURL_WARNING(_curl_easy_setopt_err_long,
|
CURLWARNING(_curl_easy_setopt_err_long,
|
||||||
"curl_easy_setopt expects a long argument for this option")
|
"curl_easy_setopt expects a long argument for this option")
|
||||||
_CURL_WARNING(_curl_easy_setopt_err_curl_off_t,
|
CURLWARNING(_curl_easy_setopt_err_curl_off_t,
|
||||||
"curl_easy_setopt expects a curl_off_t argument for this option")
|
"curl_easy_setopt expects a curl_off_t argument for this option")
|
||||||
_CURL_WARNING(_curl_easy_setopt_err_string,
|
CURLWARNING(_curl_easy_setopt_err_string,
|
||||||
"curl_easy_setopt expects a string (char* or char[]) argument for this option"
|
"curl_easy_setopt expects a "
|
||||||
|
"string ('char *' or char[]) argument for this option"
|
||||||
)
|
)
|
||||||
_CURL_WARNING(_curl_easy_setopt_err_write_callback,
|
CURLWARNING(_curl_easy_setopt_err_write_callback,
|
||||||
"curl_easy_setopt expects a curl_write_callback argument for this option")
|
"curl_easy_setopt expects a curl_write_callback argument for this option")
|
||||||
_CURL_WARNING(_curl_easy_setopt_err_read_cb,
|
CURLWARNING(_curl_easy_setopt_err_resolver_start_callback,
|
||||||
"curl_easy_setopt expects a curl_read_callback argument for this option")
|
"curl_easy_setopt expects a "
|
||||||
_CURL_WARNING(_curl_easy_setopt_err_ioctl_cb,
|
"curl_resolver_start_callback argument for this option"
|
||||||
"curl_easy_setopt expects a curl_ioctl_callback argument for this option")
|
|
||||||
_CURL_WARNING(_curl_easy_setopt_err_sockopt_cb,
|
|
||||||
"curl_easy_setopt expects a curl_sockopt_callback argument for this option")
|
|
||||||
_CURL_WARNING(_curl_easy_setopt_err_opensocket_cb,
|
|
||||||
"curl_easy_setopt expects a curl_opensocket_callback argument for this option"
|
|
||||||
)
|
)
|
||||||
_CURL_WARNING(_curl_easy_setopt_err_progress_cb,
|
CURLWARNING(_curl_easy_setopt_err_read_cb,
|
||||||
|
"curl_easy_setopt expects a curl_read_callback argument for this option")
|
||||||
|
CURLWARNING(_curl_easy_setopt_err_ioctl_cb,
|
||||||
|
"curl_easy_setopt expects a curl_ioctl_callback argument for this option")
|
||||||
|
CURLWARNING(_curl_easy_setopt_err_sockopt_cb,
|
||||||
|
"curl_easy_setopt expects a curl_sockopt_callback argument for this option")
|
||||||
|
CURLWARNING(_curl_easy_setopt_err_opensocket_cb,
|
||||||
|
"curl_easy_setopt expects a "
|
||||||
|
"curl_opensocket_callback argument for this option"
|
||||||
|
)
|
||||||
|
CURLWARNING(_curl_easy_setopt_err_progress_cb,
|
||||||
"curl_easy_setopt expects a curl_progress_callback argument for this option")
|
"curl_easy_setopt expects a curl_progress_callback argument for this option")
|
||||||
_CURL_WARNING(_curl_easy_setopt_err_debug_cb,
|
CURLWARNING(_curl_easy_setopt_err_debug_cb,
|
||||||
"curl_easy_setopt expects a curl_debug_callback argument for this option")
|
"curl_easy_setopt expects a curl_debug_callback argument for this option")
|
||||||
_CURL_WARNING(_curl_easy_setopt_err_ssl_ctx_cb,
|
CURLWARNING(_curl_easy_setopt_err_ssl_ctx_cb,
|
||||||
"curl_easy_setopt expects a curl_ssl_ctx_callback argument for this option")
|
"curl_easy_setopt expects a curl_ssl_ctx_callback argument for this option")
|
||||||
_CURL_WARNING(_curl_easy_setopt_err_conv_cb,
|
CURLWARNING(_curl_easy_setopt_err_conv_cb,
|
||||||
"curl_easy_setopt expects a curl_conv_callback argument for this option")
|
"curl_easy_setopt expects a curl_conv_callback argument for this option")
|
||||||
_CURL_WARNING(_curl_easy_setopt_err_seek_cb,
|
CURLWARNING(_curl_easy_setopt_err_seek_cb,
|
||||||
"curl_easy_setopt expects a curl_seek_callback argument for this option")
|
"curl_easy_setopt expects a curl_seek_callback argument for this option")
|
||||||
_CURL_WARNING(_curl_easy_setopt_err_cb_data,
|
CURLWARNING(_curl_easy_setopt_err_cb_data,
|
||||||
"curl_easy_setopt expects a private data pointer as argument for this option")
|
"curl_easy_setopt expects a "
|
||||||
_CURL_WARNING(_curl_easy_setopt_err_error_buffer,
|
"private data pointer as argument for this option")
|
||||||
"curl_easy_setopt expects a char buffer of CURL_ERROR_SIZE as argument for this option")
|
CURLWARNING(_curl_easy_setopt_err_error_buffer,
|
||||||
_CURL_WARNING(_curl_easy_setopt_err_FILE,
|
"curl_easy_setopt expects a "
|
||||||
"curl_easy_setopt expects a FILE* argument for this option")
|
"char buffer of CURL_ERROR_SIZE as argument for this option")
|
||||||
_CURL_WARNING(_curl_easy_setopt_err_postfields,
|
CURLWARNING(_curl_easy_setopt_err_FILE,
|
||||||
"curl_easy_setopt expects a void* or char* argument for this option")
|
"curl_easy_setopt expects a 'FILE *' argument for this option")
|
||||||
_CURL_WARNING(_curl_easy_setopt_err_curl_httpost,
|
CURLWARNING(_curl_easy_setopt_err_postfields,
|
||||||
"curl_easy_setopt expects a struct curl_httppost* argument for this option")
|
"curl_easy_setopt expects a 'void *' or 'char *' argument for this option")
|
||||||
_CURL_WARNING(_curl_easy_setopt_err_curl_slist,
|
CURLWARNING(_curl_easy_setopt_err_curl_httpost,
|
||||||
"curl_easy_setopt expects a struct curl_slist* argument for this option")
|
"curl_easy_setopt expects a 'struct curl_httppost *' "
|
||||||
_CURL_WARNING(_curl_easy_setopt_err_CURLSH,
|
"argument for this option")
|
||||||
|
CURLWARNING(_curl_easy_setopt_err_curl_mimepost,
|
||||||
|
"curl_easy_setopt expects a 'curl_mime *' "
|
||||||
|
"argument for this option")
|
||||||
|
CURLWARNING(_curl_easy_setopt_err_curl_slist,
|
||||||
|
"curl_easy_setopt expects a 'struct curl_slist *' argument for this option")
|
||||||
|
CURLWARNING(_curl_easy_setopt_err_CURLSH,
|
||||||
"curl_easy_setopt expects a CURLSH* argument for this option")
|
"curl_easy_setopt expects a CURLSH* argument for this option")
|
||||||
|
|
||||||
_CURL_WARNING(_curl_easy_getinfo_err_string,
|
CURLWARNING(_curl_easy_getinfo_err_string,
|
||||||
"curl_easy_getinfo expects a pointer to char * for this info")
|
"curl_easy_getinfo expects a pointer to 'char *' for this info")
|
||||||
_CURL_WARNING(_curl_easy_getinfo_err_long,
|
CURLWARNING(_curl_easy_getinfo_err_long,
|
||||||
"curl_easy_getinfo expects a pointer to long for this info")
|
"curl_easy_getinfo expects a pointer to long for this info")
|
||||||
_CURL_WARNING(_curl_easy_getinfo_err_double,
|
CURLWARNING(_curl_easy_getinfo_err_double,
|
||||||
"curl_easy_getinfo expects a pointer to double for this info")
|
"curl_easy_getinfo expects a pointer to double for this info")
|
||||||
_CURL_WARNING(_curl_easy_getinfo_err_curl_slist,
|
CURLWARNING(_curl_easy_getinfo_err_curl_slist,
|
||||||
"curl_easy_getinfo expects a pointer to struct curl_slist * for this info")
|
"curl_easy_getinfo expects a pointer to 'struct curl_slist *' for this info")
|
||||||
|
CURLWARNING(_curl_easy_getinfo_err_curl_tlssesssioninfo,
|
||||||
|
"curl_easy_getinfo expects a pointer to "
|
||||||
|
"'struct curl_tlssessioninfo *' for this info")
|
||||||
|
CURLWARNING(_curl_easy_getinfo_err_curl_certinfo,
|
||||||
|
"curl_easy_getinfo expects a pointer to "
|
||||||
|
"'struct curl_certinfo *' for this info")
|
||||||
|
CURLWARNING(_curl_easy_getinfo_err_curl_socket,
|
||||||
|
"curl_easy_getinfo expects a pointer to curl_socket_t for this info")
|
||||||
|
CURLWARNING(_curl_easy_getinfo_err_curl_off_t,
|
||||||
|
"curl_easy_getinfo expects a pointer to curl_off_t for this info")
|
||||||
|
|
||||||
/* groups of curl_easy_setops options that take the same type of argument */
|
/* groups of curl_easy_setops options that take the same type of argument */
|
||||||
|
|
||||||
|
@ -205,131 +244,188 @@ _CURL_WARNING(_curl_easy_getinfo_err_curl_slist,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* evaluates to true if option takes a long argument */
|
/* evaluates to true if option takes a long argument */
|
||||||
#define _curl_is_long_option(option) \
|
#define curlcheck_long_option(option) \
|
||||||
(0 < (option) && (option) < CURLOPTTYPE_OBJECTPOINT)
|
(0 < (option) && (option) < CURLOPTTYPE_OBJECTPOINT)
|
||||||
|
|
||||||
#define _curl_is_off_t_option(option) \
|
#define curlcheck_off_t_option(option) \
|
||||||
((option) > CURLOPTTYPE_OFF_T)
|
((option) > CURLOPTTYPE_OFF_T)
|
||||||
|
|
||||||
/* evaluates to true if option takes a char* argument */
|
/* evaluates to true if option takes a char* argument */
|
||||||
#define _curl_is_string_option(option) \
|
#define curlcheck_string_option(option) \
|
||||||
((option) == CURLOPT_URL || \
|
((option) == CURLOPT_ABSTRACT_UNIX_SOCKET || \
|
||||||
(option) == CURLOPT_PROXY || \
|
|
||||||
(option) == CURLOPT_INTERFACE || \
|
|
||||||
(option) == CURLOPT_NETRC_FILE || \
|
|
||||||
(option) == CURLOPT_USERPWD || \
|
|
||||||
(option) == CURLOPT_USERNAME || \
|
|
||||||
(option) == CURLOPT_PASSWORD || \
|
|
||||||
(option) == CURLOPT_PROXYUSERPWD || \
|
|
||||||
(option) == CURLOPT_PROXYUSERNAME || \
|
|
||||||
(option) == CURLOPT_PROXYPASSWORD || \
|
|
||||||
(option) == CURLOPT_NOPROXY || \
|
|
||||||
(option) == CURLOPT_ACCEPT_ENCODING || \
|
(option) == CURLOPT_ACCEPT_ENCODING || \
|
||||||
(option) == CURLOPT_REFERER || \
|
(option) == CURLOPT_ALTSVC || \
|
||||||
(option) == CURLOPT_USERAGENT || \
|
(option) == CURLOPT_CAINFO || \
|
||||||
|
(option) == CURLOPT_CAPATH || \
|
||||||
(option) == CURLOPT_COOKIE || \
|
(option) == CURLOPT_COOKIE || \
|
||||||
(option) == CURLOPT_COOKIEFILE || \
|
(option) == CURLOPT_COOKIEFILE || \
|
||||||
(option) == CURLOPT_COOKIEJAR || \
|
(option) == CURLOPT_COOKIEJAR || \
|
||||||
(option) == CURLOPT_COOKIELIST || \
|
(option) == CURLOPT_COOKIELIST || \
|
||||||
(option) == CURLOPT_FTPPORT || \
|
|
||||||
(option) == CURLOPT_FTP_ALTERNATIVE_TO_USER || \
|
|
||||||
(option) == CURLOPT_FTP_ACCOUNT || \
|
|
||||||
(option) == CURLOPT_RANGE || \
|
|
||||||
(option) == CURLOPT_CUSTOMREQUEST || \
|
|
||||||
(option) == CURLOPT_SSLCERT || \
|
|
||||||
(option) == CURLOPT_SSLCERTTYPE || \
|
|
||||||
(option) == CURLOPT_SSLKEY || \
|
|
||||||
(option) == CURLOPT_SSLKEYTYPE || \
|
|
||||||
(option) == CURLOPT_KEYPASSWD || \
|
|
||||||
(option) == CURLOPT_SSLENGINE || \
|
|
||||||
(option) == CURLOPT_CAINFO || \
|
|
||||||
(option) == CURLOPT_CAPATH || \
|
|
||||||
(option) == CURLOPT_RANDOM_FILE || \
|
|
||||||
(option) == CURLOPT_EGDSOCKET || \
|
|
||||||
(option) == CURLOPT_SSL_CIPHER_LIST || \
|
|
||||||
(option) == CURLOPT_KRBLEVEL || \
|
|
||||||
(option) == CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 || \
|
|
||||||
(option) == CURLOPT_SSH_PUBLIC_KEYFILE || \
|
|
||||||
(option) == CURLOPT_SSH_PRIVATE_KEYFILE || \
|
|
||||||
(option) == CURLOPT_CRLFILE || \
|
(option) == CURLOPT_CRLFILE || \
|
||||||
|
(option) == CURLOPT_CUSTOMREQUEST || \
|
||||||
|
(option) == CURLOPT_DEFAULT_PROTOCOL || \
|
||||||
|
(option) == CURLOPT_DNS_INTERFACE || \
|
||||||
|
(option) == CURLOPT_DNS_LOCAL_IP4 || \
|
||||||
|
(option) == CURLOPT_DNS_LOCAL_IP6 || \
|
||||||
|
(option) == CURLOPT_DNS_SERVERS || \
|
||||||
|
(option) == CURLOPT_DOH_URL || \
|
||||||
|
(option) == CURLOPT_EGDSOCKET || \
|
||||||
|
(option) == CURLOPT_FTPPORT || \
|
||||||
|
(option) == CURLOPT_FTP_ACCOUNT || \
|
||||||
|
(option) == CURLOPT_FTP_ALTERNATIVE_TO_USER || \
|
||||||
|
(option) == CURLOPT_INTERFACE || \
|
||||||
(option) == CURLOPT_ISSUERCERT || \
|
(option) == CURLOPT_ISSUERCERT || \
|
||||||
(option) == CURLOPT_SOCKS5_GSSAPI_SERVICE || \
|
(option) == CURLOPT_KEYPASSWD || \
|
||||||
(option) == CURLOPT_SSH_KNOWNHOSTS || \
|
(option) == CURLOPT_KRBLEVEL || \
|
||||||
|
(option) == CURLOPT_LOGIN_OPTIONS || \
|
||||||
|
(option) == CURLOPT_MAIL_AUTH || \
|
||||||
(option) == CURLOPT_MAIL_FROM || \
|
(option) == CURLOPT_MAIL_FROM || \
|
||||||
|
(option) == CURLOPT_NETRC_FILE || \
|
||||||
|
(option) == CURLOPT_NOPROXY || \
|
||||||
|
(option) == CURLOPT_PASSWORD || \
|
||||||
|
(option) == CURLOPT_PINNEDPUBLICKEY || \
|
||||||
|
(option) == CURLOPT_PRE_PROXY || \
|
||||||
|
(option) == CURLOPT_PROXY || \
|
||||||
|
(option) == CURLOPT_PROXYPASSWORD || \
|
||||||
|
(option) == CURLOPT_PROXYUSERNAME || \
|
||||||
|
(option) == CURLOPT_PROXYUSERPWD || \
|
||||||
|
(option) == CURLOPT_PROXY_CAINFO || \
|
||||||
|
(option) == CURLOPT_PROXY_CAPATH || \
|
||||||
|
(option) == CURLOPT_PROXY_CRLFILE || \
|
||||||
|
(option) == CURLOPT_PROXY_KEYPASSWD || \
|
||||||
|
(option) == CURLOPT_PROXY_PINNEDPUBLICKEY || \
|
||||||
|
(option) == CURLOPT_PROXY_SERVICE_NAME || \
|
||||||
|
(option) == CURLOPT_PROXY_SSLCERT || \
|
||||||
|
(option) == CURLOPT_PROXY_SSLCERTTYPE || \
|
||||||
|
(option) == CURLOPT_PROXY_SSLKEY || \
|
||||||
|
(option) == CURLOPT_PROXY_SSLKEYTYPE || \
|
||||||
|
(option) == CURLOPT_PROXY_SSL_CIPHER_LIST || \
|
||||||
|
(option) == CURLOPT_PROXY_TLS13_CIPHERS || \
|
||||||
|
(option) == CURLOPT_PROXY_TLSAUTH_PASSWORD || \
|
||||||
|
(option) == CURLOPT_PROXY_TLSAUTH_TYPE || \
|
||||||
|
(option) == CURLOPT_PROXY_TLSAUTH_USERNAME || \
|
||||||
|
(option) == CURLOPT_RANDOM_FILE || \
|
||||||
|
(option) == CURLOPT_RANGE || \
|
||||||
|
(option) == CURLOPT_REFERER || \
|
||||||
|
(option) == CURLOPT_REQUEST_TARGET || \
|
||||||
(option) == CURLOPT_RTSP_SESSION_ID || \
|
(option) == CURLOPT_RTSP_SESSION_ID || \
|
||||||
(option) == CURLOPT_RTSP_STREAM_URI || \
|
(option) == CURLOPT_RTSP_STREAM_URI || \
|
||||||
(option) == CURLOPT_RTSP_TRANSPORT || \
|
(option) == CURLOPT_RTSP_TRANSPORT || \
|
||||||
|
(option) == CURLOPT_SASL_AUTHZID || \
|
||||||
|
(option) == CURLOPT_SERVICE_NAME || \
|
||||||
|
(option) == CURLOPT_SOCKS5_GSSAPI_SERVICE || \
|
||||||
|
(option) == CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 || \
|
||||||
|
(option) == CURLOPT_SSH_KNOWNHOSTS || \
|
||||||
|
(option) == CURLOPT_SSH_PRIVATE_KEYFILE || \
|
||||||
|
(option) == CURLOPT_SSH_PUBLIC_KEYFILE || \
|
||||||
|
(option) == CURLOPT_SSLCERT || \
|
||||||
|
(option) == CURLOPT_SSLCERTTYPE || \
|
||||||
|
(option) == CURLOPT_SSLENGINE || \
|
||||||
|
(option) == CURLOPT_SSLKEY || \
|
||||||
|
(option) == CURLOPT_SSLKEYTYPE || \
|
||||||
|
(option) == CURLOPT_SSL_CIPHER_LIST || \
|
||||||
|
(option) == CURLOPT_TLS13_CIPHERS || \
|
||||||
|
(option) == CURLOPT_TLSAUTH_PASSWORD || \
|
||||||
|
(option) == CURLOPT_TLSAUTH_TYPE || \
|
||||||
|
(option) == CURLOPT_TLSAUTH_USERNAME || \
|
||||||
|
(option) == CURLOPT_UNIX_SOCKET_PATH || \
|
||||||
|
(option) == CURLOPT_URL || \
|
||||||
|
(option) == CURLOPT_USERAGENT || \
|
||||||
|
(option) == CURLOPT_USERNAME || \
|
||||||
|
(option) == CURLOPT_USERPWD || \
|
||||||
|
(option) == CURLOPT_XOAUTH2_BEARER || \
|
||||||
0)
|
0)
|
||||||
|
|
||||||
/* evaluates to true if option takes a curl_write_callback argument */
|
/* evaluates to true if option takes a curl_write_callback argument */
|
||||||
#define _curl_is_write_cb_option(option) \
|
#define curlcheck_write_cb_option(option) \
|
||||||
((option) == CURLOPT_HEADERFUNCTION || \
|
((option) == CURLOPT_HEADERFUNCTION || \
|
||||||
(option) == CURLOPT_WRITEFUNCTION)
|
(option) == CURLOPT_WRITEFUNCTION)
|
||||||
|
|
||||||
/* evaluates to true if option takes a curl_conv_callback argument */
|
/* evaluates to true if option takes a curl_conv_callback argument */
|
||||||
#define _curl_is_conv_cb_option(option) \
|
#define curlcheck_conv_cb_option(option) \
|
||||||
((option) == CURLOPT_CONV_TO_NETWORK_FUNCTION || \
|
((option) == CURLOPT_CONV_TO_NETWORK_FUNCTION || \
|
||||||
(option) == CURLOPT_CONV_FROM_NETWORK_FUNCTION || \
|
(option) == CURLOPT_CONV_FROM_NETWORK_FUNCTION || \
|
||||||
(option) == CURLOPT_CONV_FROM_UTF8_FUNCTION)
|
(option) == CURLOPT_CONV_FROM_UTF8_FUNCTION)
|
||||||
|
|
||||||
/* evaluates to true if option takes a data argument to pass to a callback */
|
/* evaluates to true if option takes a data argument to pass to a callback */
|
||||||
#define _curl_is_cb_data_option(option) \
|
#define curlcheck_cb_data_option(option) \
|
||||||
((option) == CURLOPT_WRITEDATA || \
|
((option) == CURLOPT_CHUNK_DATA || \
|
||||||
(option) == CURLOPT_READDATA || \
|
(option) == CURLOPT_CLOSESOCKETDATA || \
|
||||||
(option) == CURLOPT_IOCTLDATA || \
|
|
||||||
(option) == CURLOPT_SOCKOPTDATA || \
|
|
||||||
(option) == CURLOPT_OPENSOCKETDATA || \
|
|
||||||
(option) == CURLOPT_PROGRESSDATA || \
|
|
||||||
(option) == CURLOPT_WRITEHEADER || \
|
|
||||||
(option) == CURLOPT_DEBUGDATA || \
|
(option) == CURLOPT_DEBUGDATA || \
|
||||||
(option) == CURLOPT_SSL_CTX_DATA || \
|
|
||||||
(option) == CURLOPT_SEEKDATA || \
|
|
||||||
(option) == CURLOPT_PRIVATE || \
|
|
||||||
(option) == CURLOPT_SSH_KEYDATA || \
|
|
||||||
(option) == CURLOPT_INTERLEAVEDATA || \
|
|
||||||
(option) == CURLOPT_CHUNK_DATA || \
|
|
||||||
(option) == CURLOPT_FNMATCH_DATA || \
|
(option) == CURLOPT_FNMATCH_DATA || \
|
||||||
|
(option) == CURLOPT_HEADERDATA || \
|
||||||
|
(option) == CURLOPT_INTERLEAVEDATA || \
|
||||||
|
(option) == CURLOPT_IOCTLDATA || \
|
||||||
|
(option) == CURLOPT_OPENSOCKETDATA || \
|
||||||
|
(option) == CURLOPT_PRIVATE || \
|
||||||
|
(option) == CURLOPT_PROGRESSDATA || \
|
||||||
|
(option) == CURLOPT_READDATA || \
|
||||||
|
(option) == CURLOPT_SEEKDATA || \
|
||||||
|
(option) == CURLOPT_SOCKOPTDATA || \
|
||||||
|
(option) == CURLOPT_SSH_KEYDATA || \
|
||||||
|
(option) == CURLOPT_SSL_CTX_DATA || \
|
||||||
|
(option) == CURLOPT_WRITEDATA || \
|
||||||
|
(option) == CURLOPT_RESOLVER_START_DATA || \
|
||||||
|
(option) == CURLOPT_TRAILERDATA || \
|
||||||
0)
|
0)
|
||||||
|
|
||||||
/* evaluates to true if option takes a POST data argument (void* or char*) */
|
/* evaluates to true if option takes a POST data argument (void* or char*) */
|
||||||
#define _curl_is_postfields_option(option) \
|
#define curlcheck_postfields_option(option) \
|
||||||
((option) == CURLOPT_POSTFIELDS || \
|
((option) == CURLOPT_POSTFIELDS || \
|
||||||
(option) == CURLOPT_COPYPOSTFIELDS || \
|
(option) == CURLOPT_COPYPOSTFIELDS || \
|
||||||
0)
|
0)
|
||||||
|
|
||||||
/* evaluates to true if option takes a struct curl_slist * argument */
|
/* evaluates to true if option takes a struct curl_slist * argument */
|
||||||
#define _curl_is_slist_option(option) \
|
#define curlcheck_slist_option(option) \
|
||||||
((option) == CURLOPT_HTTPHEADER || \
|
((option) == CURLOPT_HTTP200ALIASES || \
|
||||||
(option) == CURLOPT_HTTP200ALIASES || \
|
(option) == CURLOPT_HTTPHEADER || \
|
||||||
(option) == CURLOPT_QUOTE || \
|
(option) == CURLOPT_MAIL_RCPT || \
|
||||||
(option) == CURLOPT_POSTQUOTE || \
|
(option) == CURLOPT_POSTQUOTE || \
|
||||||
(option) == CURLOPT_PREQUOTE || \
|
(option) == CURLOPT_PREQUOTE || \
|
||||||
|
(option) == CURLOPT_PROXYHEADER || \
|
||||||
|
(option) == CURLOPT_QUOTE || \
|
||||||
|
(option) == CURLOPT_RESOLVE || \
|
||||||
(option) == CURLOPT_TELNETOPTIONS || \
|
(option) == CURLOPT_TELNETOPTIONS || \
|
||||||
(option) == CURLOPT_MAIL_RCPT || \
|
(option) == CURLOPT_CONNECT_TO || \
|
||||||
0)
|
0)
|
||||||
|
|
||||||
/* groups of curl_easy_getinfo infos that take the same type of argument */
|
/* groups of curl_easy_getinfo infos that take the same type of argument */
|
||||||
|
|
||||||
/* evaluates to true if info expects a pointer to char * argument */
|
/* evaluates to true if info expects a pointer to char * argument */
|
||||||
#define _curl_is_string_info(info) \
|
#define curlcheck_string_info(info) \
|
||||||
(CURLINFO_STRING < (info) && (info) < CURLINFO_LONG)
|
(CURLINFO_STRING < (info) && (info) < CURLINFO_LONG)
|
||||||
|
|
||||||
/* evaluates to true if info expects a pointer to long argument */
|
/* evaluates to true if info expects a pointer to long argument */
|
||||||
#define _curl_is_long_info(info) \
|
#define curlcheck_long_info(info) \
|
||||||
(CURLINFO_LONG < (info) && (info) < CURLINFO_DOUBLE)
|
(CURLINFO_LONG < (info) && (info) < CURLINFO_DOUBLE)
|
||||||
|
|
||||||
/* evaluates to true if info expects a pointer to double argument */
|
/* evaluates to true if info expects a pointer to double argument */
|
||||||
#define _curl_is_double_info(info) \
|
#define curlcheck_double_info(info) \
|
||||||
(CURLINFO_DOUBLE < (info) && (info) < CURLINFO_SLIST)
|
(CURLINFO_DOUBLE < (info) && (info) < CURLINFO_SLIST)
|
||||||
|
|
||||||
/* true if info expects a pointer to struct curl_slist * argument */
|
/* true if info expects a pointer to struct curl_slist * argument */
|
||||||
#define _curl_is_slist_info(info) \
|
#define curlcheck_slist_info(info) \
|
||||||
(CURLINFO_SLIST < (info))
|
(((info) == CURLINFO_SSL_ENGINES) || ((info) == CURLINFO_COOKIELIST))
|
||||||
|
|
||||||
|
/* true if info expects a pointer to struct curl_tlssessioninfo * argument */
|
||||||
|
#define curlcheck_tlssessioninfo_info(info) \
|
||||||
|
(((info) == CURLINFO_TLS_SSL_PTR) || ((info) == CURLINFO_TLS_SESSION))
|
||||||
|
|
||||||
|
/* true if info expects a pointer to struct curl_certinfo * argument */
|
||||||
|
#define curlcheck_certinfo_info(info) ((info) == CURLINFO_CERTINFO)
|
||||||
|
|
||||||
|
/* true if info expects a pointer to struct curl_socket_t argument */
|
||||||
|
#define curlcheck_socket_info(info) \
|
||||||
|
(CURLINFO_SOCKET < (info) && (info) < CURLINFO_OFF_T)
|
||||||
|
|
||||||
|
/* true if info expects a pointer to curl_off_t argument */
|
||||||
|
#define curlcheck_off_t_info(info) \
|
||||||
|
(CURLINFO_OFF_T < (info))
|
||||||
|
|
||||||
|
|
||||||
/* typecheck helpers -- check whether given expression has requested type*/
|
/* typecheck helpers -- check whether given expression has requested type*/
|
||||||
|
|
||||||
/* For pointers, you can use the _curl_is_ptr/_curl_is_arr macros,
|
/* For pointers, you can use the curlcheck_ptr/curlcheck_arr macros,
|
||||||
* otherwise define a new macro. Search for __builtin_types_compatible_p
|
* otherwise define a new macro. Search for __builtin_types_compatible_p
|
||||||
* in the GCC manual.
|
* in the GCC manual.
|
||||||
* NOTE: these macros MUST NOT EVALUATE their arguments! The argument is
|
* NOTE: these macros MUST NOT EVALUATE their arguments! The argument is
|
||||||
|
@ -338,36 +434,36 @@ _CURL_WARNING(_curl_easy_getinfo_err_curl_slist,
|
||||||
* == or whatsoever.
|
* == or whatsoever.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* XXX: should evaluate to true iff expr is a pointer */
|
/* XXX: should evaluate to true if expr is a pointer */
|
||||||
#define _curl_is_any_ptr(expr) \
|
#define curlcheck_any_ptr(expr) \
|
||||||
(sizeof(expr) == sizeof(void *))
|
(sizeof(expr) == sizeof(void *))
|
||||||
|
|
||||||
/* evaluates to true if expr is NULL */
|
/* evaluates to true if expr is NULL */
|
||||||
/* XXX: must not evaluate expr, so this check is not accurate */
|
/* XXX: must not evaluate expr, so this check is not accurate */
|
||||||
#define _curl_is_NULL(expr) \
|
#define curlcheck_NULL(expr) \
|
||||||
(__builtin_types_compatible_p(__typeof__(expr), __typeof__(NULL)))
|
(__builtin_types_compatible_p(__typeof__(expr), __typeof__(NULL)))
|
||||||
|
|
||||||
/* evaluates to true if expr is type*, const type* or NULL */
|
/* evaluates to true if expr is type*, const type* or NULL */
|
||||||
#define _curl_is_ptr(expr, type) \
|
#define curlcheck_ptr(expr, type) \
|
||||||
(_curl_is_NULL(expr) || \
|
(curlcheck_NULL(expr) || \
|
||||||
__builtin_types_compatible_p(__typeof__(expr), type *) || \
|
__builtin_types_compatible_p(__typeof__(expr), type *) || \
|
||||||
__builtin_types_compatible_p(__typeof__(expr), const type *))
|
__builtin_types_compatible_p(__typeof__(expr), const type *))
|
||||||
|
|
||||||
/* evaluates to true if expr is one of type[], type*, NULL or const type* */
|
/* evaluates to true if expr is one of type[], type*, NULL or const type* */
|
||||||
#define _curl_is_arr(expr, type) \
|
#define curlcheck_arr(expr, type) \
|
||||||
(_curl_is_ptr((expr), type) || \
|
(curlcheck_ptr((expr), type) || \
|
||||||
__builtin_types_compatible_p(__typeof__(expr), type []))
|
__builtin_types_compatible_p(__typeof__(expr), type []))
|
||||||
|
|
||||||
/* evaluates to true if expr is a string */
|
/* evaluates to true if expr is a string */
|
||||||
#define _curl_is_string(expr) \
|
#define curlcheck_string(expr) \
|
||||||
(_curl_is_arr((expr), char) || \
|
(curlcheck_arr((expr), char) || \
|
||||||
_curl_is_arr((expr), signed char) || \
|
curlcheck_arr((expr), signed char) || \
|
||||||
_curl_is_arr((expr), unsigned char))
|
curlcheck_arr((expr), unsigned char))
|
||||||
|
|
||||||
/* evaluates to true if expr is a long (no matter the signedness)
|
/* evaluates to true if expr is a long (no matter the signedness)
|
||||||
* XXX: for now, int is also accepted (and therefore short and char, which
|
* XXX: for now, int is also accepted (and therefore short and char, which
|
||||||
* are promoted to int when passed to a variadic function) */
|
* are promoted to int when passed to a variadic function) */
|
||||||
#define _curl_is_long(expr) \
|
#define curlcheck_long(expr) \
|
||||||
(__builtin_types_compatible_p(__typeof__(expr), long) || \
|
(__builtin_types_compatible_p(__typeof__(expr), long) || \
|
||||||
__builtin_types_compatible_p(__typeof__(expr), signed long) || \
|
__builtin_types_compatible_p(__typeof__(expr), signed long) || \
|
||||||
__builtin_types_compatible_p(__typeof__(expr), unsigned long) || \
|
__builtin_types_compatible_p(__typeof__(expr), unsigned long) || \
|
||||||
|
@ -382,175 +478,194 @@ _CURL_WARNING(_curl_easy_getinfo_err_curl_slist,
|
||||||
__builtin_types_compatible_p(__typeof__(expr), unsigned char))
|
__builtin_types_compatible_p(__typeof__(expr), unsigned char))
|
||||||
|
|
||||||
/* evaluates to true if expr is of type curl_off_t */
|
/* evaluates to true if expr is of type curl_off_t */
|
||||||
#define _curl_is_off_t(expr) \
|
#define curlcheck_off_t(expr) \
|
||||||
(__builtin_types_compatible_p(__typeof__(expr), curl_off_t))
|
(__builtin_types_compatible_p(__typeof__(expr), curl_off_t))
|
||||||
|
|
||||||
/* evaluates to true if expr is abuffer suitable for CURLOPT_ERRORBUFFER */
|
/* evaluates to true if expr is abuffer suitable for CURLOPT_ERRORBUFFER */
|
||||||
/* XXX: also check size of an char[] array? */
|
/* XXX: also check size of an char[] array? */
|
||||||
#define _curl_is_error_buffer(expr) \
|
#define curlcheck_error_buffer(expr) \
|
||||||
(__builtin_types_compatible_p(__typeof__(expr), char *) || \
|
(curlcheck_NULL(expr) || \
|
||||||
|
__builtin_types_compatible_p(__typeof__(expr), char *) || \
|
||||||
__builtin_types_compatible_p(__typeof__(expr), char[]))
|
__builtin_types_compatible_p(__typeof__(expr), char[]))
|
||||||
|
|
||||||
/* evaluates to true if expr is of type (const) void* or (const) FILE* */
|
/* evaluates to true if expr is of type (const) void* or (const) FILE* */
|
||||||
#if 0
|
#if 0
|
||||||
#define _curl_is_cb_data(expr) \
|
#define curlcheck_cb_data(expr) \
|
||||||
(_curl_is_ptr((expr), void) || \
|
(curlcheck_ptr((expr), void) || \
|
||||||
_curl_is_ptr((expr), FILE))
|
curlcheck_ptr((expr), FILE))
|
||||||
#else /* be less strict */
|
#else /* be less strict */
|
||||||
#define _curl_is_cb_data(expr) \
|
#define curlcheck_cb_data(expr) \
|
||||||
_curl_is_any_ptr(expr)
|
curlcheck_any_ptr(expr)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* evaluates to true if expr is of type FILE* */
|
/* evaluates to true if expr is of type FILE* */
|
||||||
#define _curl_is_FILE(expr) \
|
#define curlcheck_FILE(expr) \
|
||||||
(__builtin_types_compatible_p(__typeof__(expr), FILE *))
|
(curlcheck_NULL(expr) || \
|
||||||
|
(__builtin_types_compatible_p(__typeof__(expr), FILE *)))
|
||||||
|
|
||||||
/* evaluates to true if expr can be passed as POST data (void* or char*) */
|
/* evaluates to true if expr can be passed as POST data (void* or char*) */
|
||||||
#define _curl_is_postfields(expr) \
|
#define curlcheck_postfields(expr) \
|
||||||
(_curl_is_ptr((expr), void) || \
|
(curlcheck_ptr((expr), void) || \
|
||||||
_curl_is_arr((expr), char))
|
curlcheck_arr((expr), char) || \
|
||||||
|
curlcheck_arr((expr), unsigned char))
|
||||||
|
|
||||||
/* FIXME: the whole callback checking is messy...
|
|
||||||
* The idea is to tolerate char vs. void and const vs. not const
|
|
||||||
* pointers in arguments at least
|
|
||||||
*/
|
|
||||||
/* helper: __builtin_types_compatible_p distinguishes between functions and
|
/* helper: __builtin_types_compatible_p distinguishes between functions and
|
||||||
* function pointers, hide it */
|
* function pointers, hide it */
|
||||||
#define _curl_callback_compatible(func, type) \
|
#define curlcheck_cb_compatible(func, type) \
|
||||||
(__builtin_types_compatible_p(__typeof__(func), type) || \
|
(__builtin_types_compatible_p(__typeof__(func), type) || \
|
||||||
__builtin_types_compatible_p(__typeof__(func), type*))
|
__builtin_types_compatible_p(__typeof__(func) *, type))
|
||||||
|
|
||||||
|
/* evaluates to true if expr is of type curl_resolver_start_callback */
|
||||||
|
#define curlcheck_resolver_start_callback(expr) \
|
||||||
|
(curlcheck_NULL(expr) || \
|
||||||
|
curlcheck_cb_compatible((expr), curl_resolver_start_callback))
|
||||||
|
|
||||||
/* evaluates to true if expr is of type curl_read_callback or "similar" */
|
/* evaluates to true if expr is of type curl_read_callback or "similar" */
|
||||||
#define _curl_is_read_cb(expr) \
|
#define curlcheck_read_cb(expr) \
|
||||||
(_curl_is_NULL(expr) || \
|
(curlcheck_NULL(expr) || \
|
||||||
__builtin_types_compatible_p(__typeof__(expr), __typeof__(fread)) || \
|
curlcheck_cb_compatible((expr), __typeof__(fread) *) || \
|
||||||
__builtin_types_compatible_p(__typeof__(expr), curl_read_callback) || \
|
curlcheck_cb_compatible((expr), curl_read_callback) || \
|
||||||
_curl_callback_compatible((expr), _curl_read_callback1) || \
|
curlcheck_cb_compatible((expr), _curl_read_callback1) || \
|
||||||
_curl_callback_compatible((expr), _curl_read_callback2) || \
|
curlcheck_cb_compatible((expr), _curl_read_callback2) || \
|
||||||
_curl_callback_compatible((expr), _curl_read_callback3) || \
|
curlcheck_cb_compatible((expr), _curl_read_callback3) || \
|
||||||
_curl_callback_compatible((expr), _curl_read_callback4) || \
|
curlcheck_cb_compatible((expr), _curl_read_callback4) || \
|
||||||
_curl_callback_compatible((expr), _curl_read_callback5) || \
|
curlcheck_cb_compatible((expr), _curl_read_callback5) || \
|
||||||
_curl_callback_compatible((expr), _curl_read_callback6))
|
curlcheck_cb_compatible((expr), _curl_read_callback6))
|
||||||
typedef size_t (_curl_read_callback1)(char *, size_t, size_t, void*);
|
typedef size_t (*_curl_read_callback1)(char *, size_t, size_t, void *);
|
||||||
typedef size_t (_curl_read_callback2)(char *, size_t, size_t, const void*);
|
typedef size_t (*_curl_read_callback2)(char *, size_t, size_t, const void *);
|
||||||
typedef size_t (_curl_read_callback3)(char *, size_t, size_t, FILE*);
|
typedef size_t (*_curl_read_callback3)(char *, size_t, size_t, FILE *);
|
||||||
typedef size_t (_curl_read_callback4)(void *, size_t, size_t, void*);
|
typedef size_t (*_curl_read_callback4)(void *, size_t, size_t, void *);
|
||||||
typedef size_t (_curl_read_callback5)(void *, size_t, size_t, const void*);
|
typedef size_t (*_curl_read_callback5)(void *, size_t, size_t, const void *);
|
||||||
typedef size_t (_curl_read_callback6)(void *, size_t, size_t, FILE*);
|
typedef size_t (*_curl_read_callback6)(void *, size_t, size_t, FILE *);
|
||||||
|
|
||||||
/* evaluates to true if expr is of type curl_write_callback or "similar" */
|
/* evaluates to true if expr is of type curl_write_callback or "similar" */
|
||||||
#define _curl_is_write_cb(expr) \
|
#define curlcheck_write_cb(expr) \
|
||||||
(_curl_is_read_cb(expr) || \
|
(curlcheck_read_cb(expr) || \
|
||||||
__builtin_types_compatible_p(__typeof__(expr), __typeof__(fwrite)) || \
|
curlcheck_cb_compatible((expr), __typeof__(fwrite) *) || \
|
||||||
__builtin_types_compatible_p(__typeof__(expr), curl_write_callback) || \
|
curlcheck_cb_compatible((expr), curl_write_callback) || \
|
||||||
_curl_callback_compatible((expr), _curl_write_callback1) || \
|
curlcheck_cb_compatible((expr), _curl_write_callback1) || \
|
||||||
_curl_callback_compatible((expr), _curl_write_callback2) || \
|
curlcheck_cb_compatible((expr), _curl_write_callback2) || \
|
||||||
_curl_callback_compatible((expr), _curl_write_callback3) || \
|
curlcheck_cb_compatible((expr), _curl_write_callback3) || \
|
||||||
_curl_callback_compatible((expr), _curl_write_callback4) || \
|
curlcheck_cb_compatible((expr), _curl_write_callback4) || \
|
||||||
_curl_callback_compatible((expr), _curl_write_callback5) || \
|
curlcheck_cb_compatible((expr), _curl_write_callback5) || \
|
||||||
_curl_callback_compatible((expr), _curl_write_callback6))
|
curlcheck_cb_compatible((expr), _curl_write_callback6))
|
||||||
typedef size_t (_curl_write_callback1)(const char *, size_t, size_t, void*);
|
typedef size_t (*_curl_write_callback1)(const char *, size_t, size_t, void *);
|
||||||
typedef size_t (_curl_write_callback2)(const char *, size_t, size_t,
|
typedef size_t (*_curl_write_callback2)(const char *, size_t, size_t,
|
||||||
const void *);
|
const void *);
|
||||||
typedef size_t (_curl_write_callback3)(const char *, size_t, size_t, FILE*);
|
typedef size_t (*_curl_write_callback3)(const char *, size_t, size_t, FILE *);
|
||||||
typedef size_t (_curl_write_callback4)(const void *, size_t, size_t, void*);
|
typedef size_t (*_curl_write_callback4)(const void *, size_t, size_t, void *);
|
||||||
typedef size_t (_curl_write_callback5)(const void *, size_t, size_t,
|
typedef size_t (*_curl_write_callback5)(const void *, size_t, size_t,
|
||||||
const void *);
|
const void *);
|
||||||
typedef size_t (_curl_write_callback6)(const void *, size_t, size_t, FILE*);
|
typedef size_t (*_curl_write_callback6)(const void *, size_t, size_t, FILE *);
|
||||||
|
|
||||||
/* evaluates to true if expr is of type curl_ioctl_callback or "similar" */
|
/* evaluates to true if expr is of type curl_ioctl_callback or "similar" */
|
||||||
#define _curl_is_ioctl_cb(expr) \
|
#define curlcheck_ioctl_cb(expr) \
|
||||||
(_curl_is_NULL(expr) || \
|
(curlcheck_NULL(expr) || \
|
||||||
__builtin_types_compatible_p(__typeof__(expr), curl_ioctl_callback) || \
|
curlcheck_cb_compatible((expr), curl_ioctl_callback) || \
|
||||||
_curl_callback_compatible((expr), _curl_ioctl_callback1) || \
|
curlcheck_cb_compatible((expr), _curl_ioctl_callback1) || \
|
||||||
_curl_callback_compatible((expr), _curl_ioctl_callback2) || \
|
curlcheck_cb_compatible((expr), _curl_ioctl_callback2) || \
|
||||||
_curl_callback_compatible((expr), _curl_ioctl_callback3) || \
|
curlcheck_cb_compatible((expr), _curl_ioctl_callback3) || \
|
||||||
_curl_callback_compatible((expr), _curl_ioctl_callback4))
|
curlcheck_cb_compatible((expr), _curl_ioctl_callback4))
|
||||||
typedef curlioerr (_curl_ioctl_callback1)(CURL *, int, void*);
|
typedef curlioerr (*_curl_ioctl_callback1)(CURL *, int, void *);
|
||||||
typedef curlioerr (_curl_ioctl_callback2)(CURL *, int, const void*);
|
typedef curlioerr (*_curl_ioctl_callback2)(CURL *, int, const void *);
|
||||||
typedef curlioerr (_curl_ioctl_callback3)(CURL *, curliocmd, void*);
|
typedef curlioerr (*_curl_ioctl_callback3)(CURL *, curliocmd, void *);
|
||||||
typedef curlioerr (_curl_ioctl_callback4)(CURL *, curliocmd, const void*);
|
typedef curlioerr (*_curl_ioctl_callback4)(CURL *, curliocmd, const void *);
|
||||||
|
|
||||||
/* evaluates to true if expr is of type curl_sockopt_callback or "similar" */
|
/* evaluates to true if expr is of type curl_sockopt_callback or "similar" */
|
||||||
#define _curl_is_sockopt_cb(expr) \
|
#define curlcheck_sockopt_cb(expr) \
|
||||||
(_curl_is_NULL(expr) || \
|
(curlcheck_NULL(expr) || \
|
||||||
__builtin_types_compatible_p(__typeof__(expr), curl_sockopt_callback) || \
|
curlcheck_cb_compatible((expr), curl_sockopt_callback) || \
|
||||||
_curl_callback_compatible((expr), _curl_sockopt_callback1) || \
|
curlcheck_cb_compatible((expr), _curl_sockopt_callback1) || \
|
||||||
_curl_callback_compatible((expr), _curl_sockopt_callback2))
|
curlcheck_cb_compatible((expr), _curl_sockopt_callback2))
|
||||||
typedef int (_curl_sockopt_callback1)(void *, curl_socket_t, curlsocktype);
|
typedef int (*_curl_sockopt_callback1)(void *, curl_socket_t, curlsocktype);
|
||||||
typedef int (_curl_sockopt_callback2)(const void *, curl_socket_t,
|
typedef int (*_curl_sockopt_callback2)(const void *, curl_socket_t,
|
||||||
curlsocktype);
|
curlsocktype);
|
||||||
|
|
||||||
/* evaluates to true if expr is of type curl_opensocket_callback or "similar" */
|
/* evaluates to true if expr is of type curl_opensocket_callback or
|
||||||
#define _curl_is_opensocket_cb(expr) \
|
"similar" */
|
||||||
(_curl_is_NULL(expr) || \
|
#define curlcheck_opensocket_cb(expr) \
|
||||||
__builtin_types_compatible_p(__typeof__(expr), curl_opensocket_callback) ||\
|
(curlcheck_NULL(expr) || \
|
||||||
_curl_callback_compatible((expr), _curl_opensocket_callback1) || \
|
curlcheck_cb_compatible((expr), curl_opensocket_callback) || \
|
||||||
_curl_callback_compatible((expr), _curl_opensocket_callback2) || \
|
curlcheck_cb_compatible((expr), _curl_opensocket_callback1) || \
|
||||||
_curl_callback_compatible((expr), _curl_opensocket_callback3) || \
|
curlcheck_cb_compatible((expr), _curl_opensocket_callback2) || \
|
||||||
_curl_callback_compatible((expr), _curl_opensocket_callback4))
|
curlcheck_cb_compatible((expr), _curl_opensocket_callback3) || \
|
||||||
typedef curl_socket_t (_curl_opensocket_callback1)
|
curlcheck_cb_compatible((expr), _curl_opensocket_callback4))
|
||||||
|
typedef curl_socket_t (*_curl_opensocket_callback1)
|
||||||
(void *, curlsocktype, struct curl_sockaddr *);
|
(void *, curlsocktype, struct curl_sockaddr *);
|
||||||
typedef curl_socket_t (_curl_opensocket_callback2)
|
typedef curl_socket_t (*_curl_opensocket_callback2)
|
||||||
(void *, curlsocktype, const struct curl_sockaddr *);
|
(void *, curlsocktype, const struct curl_sockaddr *);
|
||||||
typedef curl_socket_t (_curl_opensocket_callback3)
|
typedef curl_socket_t (*_curl_opensocket_callback3)
|
||||||
(const void *, curlsocktype, struct curl_sockaddr *);
|
(const void *, curlsocktype, struct curl_sockaddr *);
|
||||||
typedef curl_socket_t (_curl_opensocket_callback4)
|
typedef curl_socket_t (*_curl_opensocket_callback4)
|
||||||
(const void *, curlsocktype, const struct curl_sockaddr *);
|
(const void *, curlsocktype, const struct curl_sockaddr *);
|
||||||
|
|
||||||
/* evaluates to true if expr is of type curl_progress_callback or "similar" */
|
/* evaluates to true if expr is of type curl_progress_callback or "similar" */
|
||||||
#define _curl_is_progress_cb(expr) \
|
#define curlcheck_progress_cb(expr) \
|
||||||
(_curl_is_NULL(expr) || \
|
(curlcheck_NULL(expr) || \
|
||||||
__builtin_types_compatible_p(__typeof__(expr), curl_progress_callback) || \
|
curlcheck_cb_compatible((expr), curl_progress_callback) || \
|
||||||
_curl_callback_compatible((expr), _curl_progress_callback1) || \
|
curlcheck_cb_compatible((expr), _curl_progress_callback1) || \
|
||||||
_curl_callback_compatible((expr), _curl_progress_callback2))
|
curlcheck_cb_compatible((expr), _curl_progress_callback2))
|
||||||
typedef int (_curl_progress_callback1)(void *,
|
typedef int (*_curl_progress_callback1)(void *,
|
||||||
double, double, double, double);
|
double, double, double, double);
|
||||||
typedef int (_curl_progress_callback2)(const void *,
|
typedef int (*_curl_progress_callback2)(const void *,
|
||||||
double, double, double, double);
|
double, double, double, double);
|
||||||
|
|
||||||
/* evaluates to true if expr is of type curl_debug_callback or "similar" */
|
/* evaluates to true if expr is of type curl_debug_callback or "similar" */
|
||||||
#define _curl_is_debug_cb(expr) \
|
#define curlcheck_debug_cb(expr) \
|
||||||
(_curl_is_NULL(expr) || \
|
(curlcheck_NULL(expr) || \
|
||||||
__builtin_types_compatible_p(__typeof__(expr), curl_debug_callback) || \
|
curlcheck_cb_compatible((expr), curl_debug_callback) || \
|
||||||
_curl_callback_compatible((expr), _curl_debug_callback1) || \
|
curlcheck_cb_compatible((expr), _curl_debug_callback1) || \
|
||||||
_curl_callback_compatible((expr), _curl_debug_callback2) || \
|
curlcheck_cb_compatible((expr), _curl_debug_callback2) || \
|
||||||
_curl_callback_compatible((expr), _curl_debug_callback3) || \
|
curlcheck_cb_compatible((expr), _curl_debug_callback3) || \
|
||||||
_curl_callback_compatible((expr), _curl_debug_callback4))
|
curlcheck_cb_compatible((expr), _curl_debug_callback4) || \
|
||||||
typedef int (_curl_debug_callback1) (CURL *,
|
curlcheck_cb_compatible((expr), _curl_debug_callback5) || \
|
||||||
|
curlcheck_cb_compatible((expr), _curl_debug_callback6) || \
|
||||||
|
curlcheck_cb_compatible((expr), _curl_debug_callback7) || \
|
||||||
|
curlcheck_cb_compatible((expr), _curl_debug_callback8))
|
||||||
|
typedef int (*_curl_debug_callback1) (CURL *,
|
||||||
curl_infotype, char *, size_t, void *);
|
curl_infotype, char *, size_t, void *);
|
||||||
typedef int (_curl_debug_callback2) (CURL *,
|
typedef int (*_curl_debug_callback2) (CURL *,
|
||||||
curl_infotype, char *, size_t, const void *);
|
curl_infotype, char *, size_t, const void *);
|
||||||
typedef int (_curl_debug_callback3) (CURL *,
|
typedef int (*_curl_debug_callback3) (CURL *,
|
||||||
curl_infotype, const char *, size_t, void *);
|
curl_infotype, const char *, size_t, void *);
|
||||||
typedef int (_curl_debug_callback4) (CURL *,
|
typedef int (*_curl_debug_callback4) (CURL *,
|
||||||
curl_infotype, const char *, size_t, const void *);
|
curl_infotype, const char *, size_t, const void *);
|
||||||
|
typedef int (*_curl_debug_callback5) (CURL *,
|
||||||
|
curl_infotype, unsigned char *, size_t, void *);
|
||||||
|
typedef int (*_curl_debug_callback6) (CURL *,
|
||||||
|
curl_infotype, unsigned char *, size_t, const void *);
|
||||||
|
typedef int (*_curl_debug_callback7) (CURL *,
|
||||||
|
curl_infotype, const unsigned char *, size_t, void *);
|
||||||
|
typedef int (*_curl_debug_callback8) (CURL *,
|
||||||
|
curl_infotype, const unsigned char *, size_t, const void *);
|
||||||
|
|
||||||
/* evaluates to true if expr is of type curl_ssl_ctx_callback or "similar" */
|
/* evaluates to true if expr is of type curl_ssl_ctx_callback or "similar" */
|
||||||
/* this is getting even messier... */
|
/* this is getting even messier... */
|
||||||
#define _curl_is_ssl_ctx_cb(expr) \
|
#define curlcheck_ssl_ctx_cb(expr) \
|
||||||
(_curl_is_NULL(expr) || \
|
(curlcheck_NULL(expr) || \
|
||||||
__builtin_types_compatible_p(__typeof__(expr), curl_ssl_ctx_callback) || \
|
curlcheck_cb_compatible((expr), curl_ssl_ctx_callback) || \
|
||||||
_curl_callback_compatible((expr), _curl_ssl_ctx_callback1) || \
|
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback1) || \
|
||||||
_curl_callback_compatible((expr), _curl_ssl_ctx_callback2) || \
|
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback2) || \
|
||||||
_curl_callback_compatible((expr), _curl_ssl_ctx_callback3) || \
|
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback3) || \
|
||||||
_curl_callback_compatible((expr), _curl_ssl_ctx_callback4) || \
|
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback4) || \
|
||||||
_curl_callback_compatible((expr), _curl_ssl_ctx_callback5) || \
|
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback5) || \
|
||||||
_curl_callback_compatible((expr), _curl_ssl_ctx_callback6) || \
|
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback6) || \
|
||||||
_curl_callback_compatible((expr), _curl_ssl_ctx_callback7) || \
|
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback7) || \
|
||||||
_curl_callback_compatible((expr), _curl_ssl_ctx_callback8))
|
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback8))
|
||||||
typedef CURLcode (_curl_ssl_ctx_callback1)(CURL *, void *, void *);
|
typedef CURLcode (*_curl_ssl_ctx_callback1)(CURL *, void *, void *);
|
||||||
typedef CURLcode (_curl_ssl_ctx_callback2)(CURL *, void *, const void *);
|
typedef CURLcode (*_curl_ssl_ctx_callback2)(CURL *, void *, const void *);
|
||||||
typedef CURLcode (_curl_ssl_ctx_callback3)(CURL *, const void *, void *);
|
typedef CURLcode (*_curl_ssl_ctx_callback3)(CURL *, const void *, void *);
|
||||||
typedef CURLcode (_curl_ssl_ctx_callback4)(CURL *, const void *, const void *);
|
typedef CURLcode (*_curl_ssl_ctx_callback4)(CURL *, const void *,
|
||||||
|
const void *);
|
||||||
#ifdef HEADER_SSL_H
|
#ifdef HEADER_SSL_H
|
||||||
/* hack: if we included OpenSSL's ssl.h, we know about SSL_CTX
|
/* hack: if we included OpenSSL's ssl.h, we know about SSL_CTX
|
||||||
* this will of course break if we're included before OpenSSL headers...
|
* this will of course break if we're included before OpenSSL headers...
|
||||||
*/
|
*/
|
||||||
typedef CURLcode (_curl_ssl_ctx_callback5)(CURL *, SSL_CTX, void *);
|
typedef CURLcode (*_curl_ssl_ctx_callback5)(CURL *, SSL_CTX, void *);
|
||||||
typedef CURLcode (_curl_ssl_ctx_callback6)(CURL *, SSL_CTX, const void *);
|
typedef CURLcode (*_curl_ssl_ctx_callback6)(CURL *, SSL_CTX, const void *);
|
||||||
typedef CURLcode (_curl_ssl_ctx_callback7)(CURL *, const SSL_CTX, void *);
|
typedef CURLcode (*_curl_ssl_ctx_callback7)(CURL *, const SSL_CTX, void *);
|
||||||
typedef CURLcode (_curl_ssl_ctx_callback8)(CURL *, const SSL_CTX, const void *);
|
typedef CURLcode (*_curl_ssl_ctx_callback8)(CURL *, const SSL_CTX,
|
||||||
|
const void *);
|
||||||
#else
|
#else
|
||||||
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback5;
|
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback5;
|
||||||
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback6;
|
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback6;
|
||||||
|
@ -559,26 +674,26 @@ typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback8;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* evaluates to true if expr is of type curl_conv_callback or "similar" */
|
/* evaluates to true if expr is of type curl_conv_callback or "similar" */
|
||||||
#define _curl_is_conv_cb(expr) \
|
#define curlcheck_conv_cb(expr) \
|
||||||
(_curl_is_NULL(expr) || \
|
(curlcheck_NULL(expr) || \
|
||||||
__builtin_types_compatible_p(__typeof__(expr), curl_conv_callback) || \
|
curlcheck_cb_compatible((expr), curl_conv_callback) || \
|
||||||
_curl_callback_compatible((expr), _curl_conv_callback1) || \
|
curlcheck_cb_compatible((expr), _curl_conv_callback1) || \
|
||||||
_curl_callback_compatible((expr), _curl_conv_callback2) || \
|
curlcheck_cb_compatible((expr), _curl_conv_callback2) || \
|
||||||
_curl_callback_compatible((expr), _curl_conv_callback3) || \
|
curlcheck_cb_compatible((expr), _curl_conv_callback3) || \
|
||||||
_curl_callback_compatible((expr), _curl_conv_callback4))
|
curlcheck_cb_compatible((expr), _curl_conv_callback4))
|
||||||
typedef CURLcode (*_curl_conv_callback1)(char *, size_t length);
|
typedef CURLcode (*_curl_conv_callback1)(char *, size_t length);
|
||||||
typedef CURLcode (*_curl_conv_callback2)(const char *, size_t length);
|
typedef CURLcode (*_curl_conv_callback2)(const char *, size_t length);
|
||||||
typedef CURLcode (*_curl_conv_callback3)(void *, size_t length);
|
typedef CURLcode (*_curl_conv_callback3)(void *, size_t length);
|
||||||
typedef CURLcode (*_curl_conv_callback4)(const void *, size_t length);
|
typedef CURLcode (*_curl_conv_callback4)(const void *, size_t length);
|
||||||
|
|
||||||
/* evaluates to true if expr is of type curl_seek_callback or "similar" */
|
/* evaluates to true if expr is of type curl_seek_callback or "similar" */
|
||||||
#define _curl_is_seek_cb(expr) \
|
#define curlcheck_seek_cb(expr) \
|
||||||
(_curl_is_NULL(expr) || \
|
(curlcheck_NULL(expr) || \
|
||||||
__builtin_types_compatible_p(__typeof__(expr), curl_seek_callback) || \
|
curlcheck_cb_compatible((expr), curl_seek_callback) || \
|
||||||
_curl_callback_compatible((expr), _curl_seek_callback1) || \
|
curlcheck_cb_compatible((expr), _curl_seek_callback1) || \
|
||||||
_curl_callback_compatible((expr), _curl_seek_callback2))
|
curlcheck_cb_compatible((expr), _curl_seek_callback2))
|
||||||
typedef CURLcode (*_curl_seek_callback1)(void *, curl_off_t, int);
|
typedef CURLcode (*_curl_seek_callback1)(void *, curl_off_t, int);
|
||||||
typedef CURLcode (*_curl_seek_callback2)(const void *, curl_off_t, int);
|
typedef CURLcode (*_curl_seek_callback2)(const void *, curl_off_t, int);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __CURL_TYPECHECK_GCC_H */
|
#endif /* CURLINC_TYPECHECK_GCC_H */
|
||||||
|
|
125
libs/curl/include/curl/urlapi.h
Normal file
125
libs/curl/include/curl/urlapi.h
Normal file
|
@ -0,0 +1,125 @@
|
||||||
|
#ifndef CURLINC_URLAPI_H
|
||||||
|
#define CURLINC_URLAPI_H
|
||||||
|
/***************************************************************************
|
||||||
|
* _ _ ____ _
|
||||||
|
* Project ___| | | | _ \| |
|
||||||
|
* / __| | | | |_) | |
|
||||||
|
* | (__| |_| | _ <| |___
|
||||||
|
* \___|\___/|_| \_\_____|
|
||||||
|
*
|
||||||
|
* Copyright (C) 2018 - 2019, 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.haxx.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.
|
||||||
|
*
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "curl.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* the error codes for the URL API */
|
||||||
|
typedef enum {
|
||||||
|
CURLUE_OK,
|
||||||
|
CURLUE_BAD_HANDLE, /* 1 */
|
||||||
|
CURLUE_BAD_PARTPOINTER, /* 2 */
|
||||||
|
CURLUE_MALFORMED_INPUT, /* 3 */
|
||||||
|
CURLUE_BAD_PORT_NUMBER, /* 4 */
|
||||||
|
CURLUE_UNSUPPORTED_SCHEME, /* 5 */
|
||||||
|
CURLUE_URLDECODE, /* 6 */
|
||||||
|
CURLUE_OUT_OF_MEMORY, /* 7 */
|
||||||
|
CURLUE_USER_NOT_ALLOWED, /* 8 */
|
||||||
|
CURLUE_UNKNOWN_PART, /* 9 */
|
||||||
|
CURLUE_NO_SCHEME, /* 10 */
|
||||||
|
CURLUE_NO_USER, /* 11 */
|
||||||
|
CURLUE_NO_PASSWORD, /* 12 */
|
||||||
|
CURLUE_NO_OPTIONS, /* 13 */
|
||||||
|
CURLUE_NO_HOST, /* 14 */
|
||||||
|
CURLUE_NO_PORT, /* 15 */
|
||||||
|
CURLUE_NO_QUERY, /* 16 */
|
||||||
|
CURLUE_NO_FRAGMENT /* 17 */
|
||||||
|
} CURLUcode;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
CURLUPART_URL,
|
||||||
|
CURLUPART_SCHEME,
|
||||||
|
CURLUPART_USER,
|
||||||
|
CURLUPART_PASSWORD,
|
||||||
|
CURLUPART_OPTIONS,
|
||||||
|
CURLUPART_HOST,
|
||||||
|
CURLUPART_PORT,
|
||||||
|
CURLUPART_PATH,
|
||||||
|
CURLUPART_QUERY,
|
||||||
|
CURLUPART_FRAGMENT,
|
||||||
|
CURLUPART_ZONEID /* added in 7.65.0 */
|
||||||
|
} CURLUPart;
|
||||||
|
|
||||||
|
#define CURLU_DEFAULT_PORT (1<<0) /* return default port number */
|
||||||
|
#define CURLU_NO_DEFAULT_PORT (1<<1) /* act as if no port number was set,
|
||||||
|
if the port number matches the
|
||||||
|
default for the scheme */
|
||||||
|
#define CURLU_DEFAULT_SCHEME (1<<2) /* return default scheme if
|
||||||
|
missing */
|
||||||
|
#define CURLU_NON_SUPPORT_SCHEME (1<<3) /* allow non-supported scheme */
|
||||||
|
#define CURLU_PATH_AS_IS (1<<4) /* leave dot sequences */
|
||||||
|
#define CURLU_DISALLOW_USER (1<<5) /* no user+password allowed */
|
||||||
|
#define CURLU_URLDECODE (1<<6) /* URL decode on get */
|
||||||
|
#define CURLU_URLENCODE (1<<7) /* URL encode on set */
|
||||||
|
#define CURLU_APPENDQUERY (1<<8) /* append a form style part */
|
||||||
|
#define CURLU_GUESS_SCHEME (1<<9) /* legacy curl-style guessing */
|
||||||
|
#define CURLU_NO_AUTHORITY (1<<10) /* Allow empty authority when the
|
||||||
|
scheme is unknown. */
|
||||||
|
|
||||||
|
typedef struct Curl_URL CURLU;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* curl_url() creates a new CURLU handle and returns a pointer to it.
|
||||||
|
* Must be freed with curl_url_cleanup().
|
||||||
|
*/
|
||||||
|
CURL_EXTERN CURLU *curl_url(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* curl_url_cleanup() frees the CURLU handle and related resources used for
|
||||||
|
* the URL parsing. It will not free strings previously returned with the URL
|
||||||
|
* API.
|
||||||
|
*/
|
||||||
|
CURL_EXTERN void curl_url_cleanup(CURLU *handle);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* curl_url_dup() duplicates a CURLU handle and returns a new copy. The new
|
||||||
|
* handle must also be freed with curl_url_cleanup().
|
||||||
|
*/
|
||||||
|
CURL_EXTERN CURLU *curl_url_dup(CURLU *in);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* curl_url_get() extracts a specific part of the URL from a CURLU
|
||||||
|
* handle. Returns error code. The returned pointer MUST be freed with
|
||||||
|
* curl_free() afterwards.
|
||||||
|
*/
|
||||||
|
CURL_EXTERN CURLUcode curl_url_get(CURLU *handle, CURLUPart what,
|
||||||
|
char **part, unsigned int flags);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* curl_url_set() sets a specific part of the URL in a CURLU handle. Returns
|
||||||
|
* error code. The passed in string will be copied. Passing a NULL instead of
|
||||||
|
* a part string, clears that part.
|
||||||
|
*/
|
||||||
|
CURL_EXTERN CURLUcode curl_url_set(CURLU *handle, CURLUPart what,
|
||||||
|
const char *part, unsigned int flags);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* end of extern "C" */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* CURLINC_URLAPI_H */
|
Binary file not shown.
BIN
libs/curl/lib32/libcurl.dll
Normal file
BIN
libs/curl/lib32/libcurl.dll
Normal file
Binary file not shown.
BIN
libs/curl/lib32/libcurl.dll.a
Normal file
BIN
libs/curl/lib32/libcurl.dll.a
Normal file
Binary file not shown.
BIN
libs/curl/lib64/libcurl-x64.dll
Normal file
BIN
libs/curl/lib64/libcurl-x64.dll
Normal file
Binary file not shown.
Binary file not shown.
BIN
libs/curl/lib64/libcurl.dll.a
Normal file
BIN
libs/curl/lib64/libcurl.dll.a
Normal file
Binary file not shown.
|
@ -226,6 +226,8 @@ set(SRB2_CONFIG_HAVE_GME ON CACHE BOOL
|
||||||
"Enable GME support.")
|
"Enable GME support.")
|
||||||
set(SRB2_CONFIG_HAVE_OPENMPT ON CACHE BOOL
|
set(SRB2_CONFIG_HAVE_OPENMPT ON CACHE BOOL
|
||||||
"Enable OpenMPT support.")
|
"Enable OpenMPT support.")
|
||||||
|
set(SRB2_CONFIG_HAVE_CURL ON CACHE BOOL
|
||||||
|
"Enable curl support, used for downloading files via HTTP.")
|
||||||
if(${CMAKE_SYSTEM} MATCHES Windows)
|
if(${CMAKE_SYSTEM} MATCHES Windows)
|
||||||
set(SRB2_CONFIG_HAVE_MIXERX ON CACHE BOOL
|
set(SRB2_CONFIG_HAVE_MIXERX ON CACHE BOOL
|
||||||
"Enable SDL Mixer X support.")
|
"Enable SDL Mixer X support.")
|
||||||
|
@ -445,6 +447,26 @@ if(${SRB2_CONFIG_HAVE_PNG} AND ${SRB2_CONFIG_HAVE_ZLIB})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(${SRB2_CONFIG_HAVE_CURL})
|
||||||
|
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
|
||||||
|
set(CURL_FOUND ON)
|
||||||
|
set(CURL_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/curl)
|
||||||
|
if(${SRB2_SYSTEM_BITS} EQUAL 64)
|
||||||
|
set(CURL_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/curl/lib32 -lcurl")
|
||||||
|
else() # 32-bit
|
||||||
|
set(CURL_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/curl/lib64 -lcurl")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
find_package(CURL)
|
||||||
|
endif()
|
||||||
|
if(${CURL_FOUND})
|
||||||
|
set(SRB2_HAVE_CURL ON)
|
||||||
|
add_definitions(-DHAVE_CURL)
|
||||||
|
else()
|
||||||
|
message(WARNING "You have specified that CURL is available but it was not found. SRB2 may not compile correctly.")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if(${SRB2_CONFIG_HWRENDER})
|
if(${SRB2_CONFIG_HWRENDER})
|
||||||
add_definitions(-DHWRENDER)
|
add_definitions(-DHWRENDER)
|
||||||
set(SRB2_HWRENDER_SOURCES
|
set(SRB2_HWRENDER_SOURCES
|
||||||
|
|
12
src/Makefile
12
src/Makefile
|
@ -207,6 +207,7 @@ endif
|
||||||
|
|
||||||
ifdef NONET
|
ifdef NONET
|
||||||
OPTS+=-DNONET
|
OPTS+=-DNONET
|
||||||
|
NOCURL=1
|
||||||
else
|
else
|
||||||
ifdef NO_IPV6
|
ifdef NO_IPV6
|
||||||
OPTS+=-DNO_IPV6
|
OPTS+=-DNO_IPV6
|
||||||
|
@ -316,6 +317,16 @@ else
|
||||||
NOPNG=1
|
NOPNG=1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifndef NOCURL
|
||||||
|
OPTS+=-DHAVE_CURL
|
||||||
|
CURLCONFIG?=curl-config
|
||||||
|
CURL_CFLAGS?=$(shell $(CURLCONFIG) --cflags)
|
||||||
|
CURL_LDFLAGS?=$(shell $(CURLCONFIG) --libs)
|
||||||
|
|
||||||
|
LIBS+=$(CURL_LDFLAGS)
|
||||||
|
CFLAGS+=$(CURL_CFLAGS)
|
||||||
|
endif
|
||||||
|
|
||||||
ifdef STATIC
|
ifdef STATIC
|
||||||
LIBS:=-static $(LIBS)
|
LIBS:=-static $(LIBS)
|
||||||
endif
|
endif
|
||||||
|
@ -472,6 +483,7 @@ OBJS:=$(i_main_o) \
|
||||||
$(OBJDIR)/w_wad.o \
|
$(OBJDIR)/w_wad.o \
|
||||||
$(OBJDIR)/filesrch.o \
|
$(OBJDIR)/filesrch.o \
|
||||||
$(OBJDIR)/mserv.o \
|
$(OBJDIR)/mserv.o \
|
||||||
|
$(OBJDIR)/http-mserv.o\
|
||||||
$(OBJDIR)/i_tcp.o \
|
$(OBJDIR)/i_tcp.o \
|
||||||
$(OBJDIR)/lzf.o \
|
$(OBJDIR)/lzf.o \
|
||||||
$(OBJDIR)/vid_copy.o \
|
$(OBJDIR)/vid_copy.o \
|
||||||
|
|
151
src/console.c
151
src/console.c
|
@ -29,6 +29,7 @@
|
||||||
#include "i_video.h"
|
#include "i_video.h"
|
||||||
#include "z_zone.h"
|
#include "z_zone.h"
|
||||||
#include "i_system.h"
|
#include "i_system.h"
|
||||||
|
#include "i_threads.h"
|
||||||
#include "d_main.h"
|
#include "d_main.h"
|
||||||
#include "m_menu.h"
|
#include "m_menu.h"
|
||||||
#include "filesrch.h"
|
#include "filesrch.h"
|
||||||
|
@ -44,6 +45,16 @@
|
||||||
|
|
||||||
#define MAXHUDLINES 20
|
#define MAXHUDLINES 20
|
||||||
|
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
I_mutex con_mutex;
|
||||||
|
|
||||||
|
# define Lock_state() I_lock_mutex(&con_mutex)
|
||||||
|
# define Unlock_state() I_unlock_mutex(con_mutex)
|
||||||
|
#else/*HAVE_THREADS*/
|
||||||
|
# define Lock_state()
|
||||||
|
# define Unlock_state()
|
||||||
|
#endif/*HAVE_THREADS*/
|
||||||
|
|
||||||
static boolean con_started = false; // console has been initialised
|
static boolean con_started = false; // console has been initialised
|
||||||
boolean con_startup = false; // true at game startup, screen need refreshing
|
boolean con_startup = false; // true at game startup, screen need refreshing
|
||||||
static boolean con_forcepic = true; // at startup toggle console translucency when first off
|
static boolean con_forcepic = true; // at startup toggle console translucency when first off
|
||||||
|
@ -150,6 +161,8 @@ static void CONS_hudlines_Change(void)
|
||||||
{
|
{
|
||||||
INT32 i;
|
INT32 i;
|
||||||
|
|
||||||
|
Lock_state();
|
||||||
|
|
||||||
// Clear the currently displayed lines
|
// Clear the currently displayed lines
|
||||||
for (i = 0; i < con_hudlines; i++)
|
for (i = 0; i < con_hudlines; i++)
|
||||||
con_hudtime[i] = 0;
|
con_hudtime[i] = 0;
|
||||||
|
@ -161,6 +174,8 @@ static void CONS_hudlines_Change(void)
|
||||||
|
|
||||||
con_hudlines = cons_hudlines.value;
|
con_hudlines = cons_hudlines.value;
|
||||||
|
|
||||||
|
Unlock_state();
|
||||||
|
|
||||||
CONS_Printf(M_GetText("Number of console HUD lines is now %d\n"), con_hudlines);
|
CONS_Printf(M_GetText("Number of console HUD lines is now %d\n"), con_hudlines);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,12 +183,16 @@ static void CONS_hudlines_Change(void)
|
||||||
//
|
//
|
||||||
static void CONS_Clear_f(void)
|
static void CONS_Clear_f(void)
|
||||||
{
|
{
|
||||||
|
Lock_state();
|
||||||
|
|
||||||
memset(con_buffer, 0, CON_BUFFERSIZE);
|
memset(con_buffer, 0, CON_BUFFERSIZE);
|
||||||
|
|
||||||
con_cx = 0;
|
con_cx = 0;
|
||||||
con_cy = con_totallines-1;
|
con_cy = con_totallines-1;
|
||||||
con_line = &con_buffer[con_cy*con_width];
|
con_line = &con_buffer[con_cy*con_width];
|
||||||
con_scrollup = 0;
|
con_scrollup = 0;
|
||||||
|
|
||||||
|
Unlock_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Choose english keymap
|
// Choose english keymap
|
||||||
|
@ -377,20 +396,29 @@ void CON_Init(void)
|
||||||
for (i = 0; i < NUMINPUTS; i++)
|
for (i = 0; i < NUMINPUTS; i++)
|
||||||
bindtable[i] = NULL;
|
bindtable[i] = NULL;
|
||||||
|
|
||||||
|
Lock_state();
|
||||||
|
|
||||||
// clear all lines
|
// clear all lines
|
||||||
memset(con_buffer, 0, CON_BUFFERSIZE);
|
memset(con_buffer, 0, CON_BUFFERSIZE);
|
||||||
|
|
||||||
// make sure it is ready for the loading screen
|
// make sure it is ready for the loading screen
|
||||||
con_width = 0;
|
con_width = 0;
|
||||||
|
|
||||||
|
Unlock_state();
|
||||||
|
|
||||||
CON_RecalcSize();
|
CON_RecalcSize();
|
||||||
|
|
||||||
CON_SetupColormaps();
|
CON_SetupColormaps();
|
||||||
|
|
||||||
|
Lock_state();
|
||||||
|
|
||||||
//note: CON_Ticker should always execute at least once before D_Display()
|
//note: CON_Ticker should always execute at least once before D_Display()
|
||||||
con_clipviewtop = -1; // -1 does not clip
|
con_clipviewtop = -1; // -1 does not clip
|
||||||
|
|
||||||
con_hudlines = atoi(cons_hudlines.defaultvalue);
|
con_hudlines = atoi(cons_hudlines.defaultvalue);
|
||||||
|
|
||||||
|
Unlock_state();
|
||||||
|
|
||||||
// setup console input filtering
|
// setup console input filtering
|
||||||
CON_InputInit();
|
CON_InputInit();
|
||||||
|
|
||||||
|
@ -399,15 +427,23 @@ void CON_Init(void)
|
||||||
COM_AddCommand("cls", CONS_Clear_f);
|
COM_AddCommand("cls", CONS_Clear_f);
|
||||||
//COM_AddCommand("english", CONS_English_f);
|
//COM_AddCommand("english", CONS_English_f);
|
||||||
// set console full screen for game startup MAKE SURE VID_Init() done !!!
|
// set console full screen for game startup MAKE SURE VID_Init() done !!!
|
||||||
|
Lock_state();
|
||||||
|
|
||||||
con_destlines = vid.height;
|
con_destlines = vid.height;
|
||||||
con_curlines = vid.height;
|
con_curlines = vid.height;
|
||||||
|
|
||||||
|
Unlock_state();
|
||||||
|
|
||||||
if (!dedicated)
|
if (!dedicated)
|
||||||
{
|
{
|
||||||
|
Lock_state();
|
||||||
|
|
||||||
con_started = true;
|
con_started = true;
|
||||||
con_startup = true; // need explicit screen refresh until we are in Doom loop
|
con_startup = true; // need explicit screen refresh until we are in Doom loop
|
||||||
consoletoggle = false;
|
consoletoggle = false;
|
||||||
|
|
||||||
|
Unlock_state();
|
||||||
|
|
||||||
CV_RegisterVar(&cons_msgtimeout);
|
CV_RegisterVar(&cons_msgtimeout);
|
||||||
CV_RegisterVar(&cons_hudlines);
|
CV_RegisterVar(&cons_hudlines);
|
||||||
CV_RegisterVar(&cons_speed);
|
CV_RegisterVar(&cons_speed);
|
||||||
|
@ -418,19 +454,27 @@ void CON_Init(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Lock_state();
|
||||||
|
|
||||||
con_started = true;
|
con_started = true;
|
||||||
con_startup = false; // need explicit screen refresh until we are in Doom loop
|
con_startup = false; // need explicit screen refresh until we are in Doom loop
|
||||||
consoletoggle = true;
|
consoletoggle = true;
|
||||||
|
|
||||||
|
Unlock_state();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Console input initialization
|
// Console input initialization
|
||||||
//
|
//
|
||||||
static void CON_InputInit(void)
|
static void CON_InputInit(void)
|
||||||
{
|
{
|
||||||
|
Lock_state();
|
||||||
|
|
||||||
// prepare the first prompt line
|
// prepare the first prompt line
|
||||||
memset(inputlines, 0, sizeof (inputlines));
|
memset(inputlines, 0, sizeof (inputlines));
|
||||||
inputline = 0;
|
inputline = 0;
|
||||||
input_cur = input_sel = input_len = 0;
|
input_cur = input_sel = input_len = 0;
|
||||||
|
|
||||||
|
Unlock_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
//======================================================================
|
//======================================================================
|
||||||
|
@ -446,6 +490,8 @@ static void CON_RecalcSize(void)
|
||||||
char *tmp_buffer;
|
char *tmp_buffer;
|
||||||
char *string;
|
char *string;
|
||||||
|
|
||||||
|
Lock_state();
|
||||||
|
|
||||||
switch (cv_constextsize.value)
|
switch (cv_constextsize.value)
|
||||||
{
|
{
|
||||||
case V_NOSCALEPATCH:
|
case V_NOSCALEPATCH:
|
||||||
|
@ -483,11 +529,18 @@ static void CON_RecalcSize(void)
|
||||||
|
|
||||||
// check for change of video width
|
// check for change of video width
|
||||||
if (conw == con_width)
|
if (conw == con_width)
|
||||||
|
{
|
||||||
|
Unlock_state();
|
||||||
return; // didn't change
|
return; // didn't change
|
||||||
|
}
|
||||||
|
|
||||||
|
Unlock_state();
|
||||||
|
|
||||||
tmp_buffer = Z_Malloc(CON_BUFFERSIZE, PU_STATIC, NULL);
|
tmp_buffer = Z_Malloc(CON_BUFFERSIZE, PU_STATIC, NULL);
|
||||||
string = Z_Malloc(CON_BUFFERSIZE, PU_STATIC, NULL); // BP: it is a line but who know
|
string = Z_Malloc(CON_BUFFERSIZE, PU_STATIC, NULL); // BP: it is a line but who know
|
||||||
|
|
||||||
|
Lock_state();
|
||||||
|
|
||||||
oldcon_width = con_width;
|
oldcon_width = con_width;
|
||||||
oldnumlines = con_totallines;
|
oldnumlines = con_totallines;
|
||||||
oldcon_cy = con_cy;
|
oldcon_cy = con_cy;
|
||||||
|
@ -508,6 +561,8 @@ static void CON_RecalcSize(void)
|
||||||
con_line = &con_buffer[con_cy*con_width];
|
con_line = &con_buffer[con_cy*con_width];
|
||||||
con_scrollup = 0;
|
con_scrollup = 0;
|
||||||
|
|
||||||
|
Unlock_state();
|
||||||
|
|
||||||
// re-arrange console text buffer to keep text
|
// re-arrange console text buffer to keep text
|
||||||
if (oldcon_width) // not the first time
|
if (oldcon_width) // not the first time
|
||||||
{
|
{
|
||||||
|
@ -532,7 +587,11 @@ static void CON_RecalcSize(void)
|
||||||
|
|
||||||
static void CON_ChangeHeight(void)
|
static void CON_ChangeHeight(void)
|
||||||
{
|
{
|
||||||
INT32 minheight = 20 * con_scalefactor; // 20 = 8+8+4
|
INT32 minheight;
|
||||||
|
|
||||||
|
Lock_state();
|
||||||
|
|
||||||
|
minheight = 20 * con_scalefactor; // 20 = 8+8+4
|
||||||
|
|
||||||
// toggle console in
|
// toggle console in
|
||||||
con_destlines = (cons_height.value*vid.height)/100;
|
con_destlines = (cons_height.value*vid.height)/100;
|
||||||
|
@ -542,13 +601,19 @@ static void CON_ChangeHeight(void)
|
||||||
con_destlines = vid.height;
|
con_destlines = vid.height;
|
||||||
|
|
||||||
con_destlines &= ~0x3; // multiple of text row height
|
con_destlines &= ~0x3; // multiple of text row height
|
||||||
|
|
||||||
|
Unlock_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handles Console moves in/out of screen (per frame)
|
// Handles Console moves in/out of screen (per frame)
|
||||||
//
|
//
|
||||||
static void CON_MoveConsole(void)
|
static void CON_MoveConsole(void)
|
||||||
{
|
{
|
||||||
const fixed_t conspeed = FixedDiv(cons_speed.value*vid.fdupy, FRACUNIT);
|
fixed_t conspeed;
|
||||||
|
|
||||||
|
Lock_state();
|
||||||
|
|
||||||
|
conspeed = FixedDiv(cons_speed.value*vid.fdupy, FRACUNIT);
|
||||||
|
|
||||||
// instant
|
// instant
|
||||||
if (!cons_speed.value)
|
if (!cons_speed.value)
|
||||||
|
@ -570,6 +635,8 @@ static void CON_MoveConsole(void)
|
||||||
if (con_curlines < con_destlines)
|
if (con_curlines < con_destlines)
|
||||||
con_curlines = con_destlines;
|
con_curlines = con_destlines;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Unlock_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear time of console heads up messages
|
// Clear time of console heads up messages
|
||||||
|
@ -578,16 +645,25 @@ void CON_ClearHUD(void)
|
||||||
{
|
{
|
||||||
INT32 i;
|
INT32 i;
|
||||||
|
|
||||||
|
Lock_state();
|
||||||
|
|
||||||
for (i = 0; i < con_hudlines; i++)
|
for (i = 0; i < con_hudlines; i++)
|
||||||
con_hudtime[i] = 0;
|
con_hudtime[i] = 0;
|
||||||
|
|
||||||
|
Unlock_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Force console to move out immediately
|
// Force console to move out immediately
|
||||||
// note: con_ticker will set consoleready false
|
// note: con_ticker will set consoleready false
|
||||||
void CON_ToggleOff(void)
|
void CON_ToggleOff(void)
|
||||||
{
|
{
|
||||||
|
Lock_state();
|
||||||
|
|
||||||
if (!con_destlines)
|
if (!con_destlines)
|
||||||
|
{
|
||||||
|
Unlock_state();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
con_destlines = 0;
|
con_destlines = 0;
|
||||||
con_curlines = 0;
|
con_curlines = 0;
|
||||||
|
@ -596,11 +672,19 @@ void CON_ToggleOff(void)
|
||||||
con_clipviewtop = -1; // remove console clipping of view
|
con_clipviewtop = -1; // remove console clipping of view
|
||||||
|
|
||||||
I_UpdateMouseGrab();
|
I_UpdateMouseGrab();
|
||||||
|
|
||||||
|
Unlock_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean CON_Ready(void)
|
boolean CON_Ready(void)
|
||||||
{
|
{
|
||||||
return consoleready;
|
boolean ready;
|
||||||
|
Lock_state();
|
||||||
|
{
|
||||||
|
ready = consoleready;
|
||||||
|
}
|
||||||
|
Unlock_state();
|
||||||
|
return ready;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Console ticker: handles console move in/out, cursor blinking
|
// Console ticker: handles console move in/out, cursor blinking
|
||||||
|
@ -608,7 +692,11 @@ boolean CON_Ready(void)
|
||||||
void CON_Ticker(void)
|
void CON_Ticker(void)
|
||||||
{
|
{
|
||||||
INT32 i;
|
INT32 i;
|
||||||
INT32 minheight = 20 * con_scalefactor; // 20 = 8+8+4
|
INT32 minheight;
|
||||||
|
|
||||||
|
Lock_state();
|
||||||
|
|
||||||
|
minheight = 20 * con_scalefactor; // 20 = 8+8+4
|
||||||
|
|
||||||
// cursor blinking
|
// cursor blinking
|
||||||
con_tick++;
|
con_tick++;
|
||||||
|
@ -659,6 +747,8 @@ void CON_Ticker(void)
|
||||||
if (con_hudtime[i] < 0)
|
if (con_hudtime[i] < 0)
|
||||||
con_hudtime[i] = 0;
|
con_hudtime[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Unlock_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -670,32 +760,51 @@ void CON_Ticker(void)
|
||||||
|
|
||||||
static void CON_InputClear(void)
|
static void CON_InputClear(void)
|
||||||
{
|
{
|
||||||
|
Lock_state();
|
||||||
|
|
||||||
memset(inputlines[inputline], 0, CON_MAXPROMPTCHARS);
|
memset(inputlines[inputline], 0, CON_MAXPROMPTCHARS);
|
||||||
input_cur = input_sel = input_len = 0;
|
input_cur = input_sel = input_len = 0;
|
||||||
|
|
||||||
|
Unlock_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CON_InputSetString(const char *c)
|
static void CON_InputSetString(const char *c)
|
||||||
{
|
{
|
||||||
|
Lock_state();
|
||||||
|
|
||||||
memset(inputlines[inputline], 0, CON_MAXPROMPTCHARS);
|
memset(inputlines[inputline], 0, CON_MAXPROMPTCHARS);
|
||||||
strcpy(inputlines[inputline], c);
|
strcpy(inputlines[inputline], c);
|
||||||
input_cur = input_sel = input_len = strlen(c);
|
input_cur = input_sel = input_len = strlen(c);
|
||||||
|
|
||||||
|
Unlock_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CON_InputAddString(const char *c)
|
static void CON_InputAddString(const char *c)
|
||||||
{
|
{
|
||||||
size_t csize = strlen(c);
|
size_t csize = strlen(c);
|
||||||
|
|
||||||
|
Lock_state();
|
||||||
|
|
||||||
if (input_len + csize > CON_MAXPROMPTCHARS-1)
|
if (input_len + csize > CON_MAXPROMPTCHARS-1)
|
||||||
|
{
|
||||||
|
Unlock_state();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (input_cur != input_len)
|
if (input_cur != input_len)
|
||||||
memmove(&inputlines[inputline][input_cur+csize], &inputlines[inputline][input_cur], input_len-input_cur);
|
memmove(&inputlines[inputline][input_cur+csize], &inputlines[inputline][input_cur], input_len-input_cur);
|
||||||
memcpy(&inputlines[inputline][input_cur], c, csize);
|
memcpy(&inputlines[inputline][input_cur], c, csize);
|
||||||
input_len += csize;
|
input_len += csize;
|
||||||
input_sel = (input_cur += csize);
|
input_sel = (input_cur += csize);
|
||||||
|
|
||||||
|
Unlock_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CON_InputDelSelection(void)
|
static void CON_InputDelSelection(void)
|
||||||
{
|
{
|
||||||
size_t start, end, len;
|
size_t start, end, len;
|
||||||
|
|
||||||
|
Lock_state();
|
||||||
|
|
||||||
if (input_cur > input_sel)
|
if (input_cur > input_sel)
|
||||||
{
|
{
|
||||||
start = input_sel;
|
start = input_sel;
|
||||||
|
@ -714,27 +823,39 @@ static void CON_InputDelSelection(void)
|
||||||
|
|
||||||
input_len -= len;
|
input_len -= len;
|
||||||
input_sel = input_cur = start;
|
input_sel = input_cur = start;
|
||||||
|
|
||||||
|
Unlock_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CON_InputAddChar(char c)
|
static void CON_InputAddChar(char c)
|
||||||
{
|
{
|
||||||
if (input_len >= CON_MAXPROMPTCHARS-1)
|
if (input_len >= CON_MAXPROMPTCHARS-1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Lock_state();
|
||||||
|
|
||||||
if (input_cur != input_len)
|
if (input_cur != input_len)
|
||||||
memmove(&inputlines[inputline][input_cur+1], &inputlines[inputline][input_cur], input_len-input_cur);
|
memmove(&inputlines[inputline][input_cur+1], &inputlines[inputline][input_cur], input_len-input_cur);
|
||||||
inputlines[inputline][input_cur++] = c;
|
inputlines[inputline][input_cur++] = c;
|
||||||
inputlines[inputline][++input_len] = 0;
|
inputlines[inputline][++input_len] = 0;
|
||||||
input_sel = input_cur;
|
input_sel = input_cur;
|
||||||
|
|
||||||
|
Unlock_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CON_InputDelChar(void)
|
static void CON_InputDelChar(void)
|
||||||
{
|
{
|
||||||
if (!input_cur)
|
if (!input_cur)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Lock_state();
|
||||||
|
|
||||||
if (input_cur != input_len)
|
if (input_cur != input_len)
|
||||||
memmove(&inputlines[inputline][input_cur-1], &inputlines[inputline][input_cur], input_len-input_cur);
|
memmove(&inputlines[inputline][input_cur-1], &inputlines[inputline][input_cur], input_len-input_cur);
|
||||||
inputlines[inputline][--input_len] = 0;
|
inputlines[inputline][--input_len] = 0;
|
||||||
input_sel = --input_cur;
|
input_sel = --input_cur;
|
||||||
|
|
||||||
|
Unlock_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1153,6 +1274,8 @@ static void CON_Print(char *msg)
|
||||||
S_StartSound(NULL, sfx_radio);
|
S_StartSound(NULL, sfx_radio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Lock_state();
|
||||||
|
|
||||||
if (!(*msg & 0x80))
|
if (!(*msg & 0x80))
|
||||||
{
|
{
|
||||||
con_line[con_cx++] = '\x80';
|
con_line[con_cx++] = '\x80';
|
||||||
|
@ -1213,7 +1336,10 @@ static void CON_Print(char *msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*msg == '\0')
|
if (*msg == '\0')
|
||||||
|
{
|
||||||
|
Unlock_state();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// printable character
|
// printable character
|
||||||
for (l = 0; l < (con_width-11) && msg[l] > ' '; l++)
|
for (l = 0; l < (con_width-11) && msg[l] > ' '; l++)
|
||||||
|
@ -1231,6 +1357,8 @@ static void CON_Print(char *msg)
|
||||||
for (; l > 0; l--)
|
for (; l > 0; l--)
|
||||||
con_line[con_cx++] = *(msg++);
|
con_line[con_cx++] = *(msg++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Unlock_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CON_LogMessage(const char *msg)
|
void CON_LogMessage(const char *msg)
|
||||||
|
@ -1262,6 +1390,7 @@ void CONS_Printf(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
static char *txt = NULL;
|
static char *txt = NULL;
|
||||||
|
boolean startup;
|
||||||
|
|
||||||
if (txt == NULL)
|
if (txt == NULL)
|
||||||
txt = malloc(8192);
|
txt = malloc(8192);
|
||||||
|
@ -1279,11 +1408,16 @@ void CONS_Printf(const char *fmt, ...)
|
||||||
|
|
||||||
CON_LogMessage(txt);
|
CON_LogMessage(txt);
|
||||||
|
|
||||||
|
Lock_state();
|
||||||
|
|
||||||
// make sure new text is visible
|
// make sure new text is visible
|
||||||
con_scrollup = 0;
|
con_scrollup = 0;
|
||||||
|
startup = con_startup;
|
||||||
|
|
||||||
|
Unlock_state();
|
||||||
|
|
||||||
// if not in display loop, force screen update
|
// if not in display loop, force screen update
|
||||||
if (con_startup && (!setrenderneeded))
|
if (startup && (!setrenderneeded))
|
||||||
{
|
{
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
patch_t *con_backpic = W_CachePatchName("CONSBACK", PU_PATCH);
|
patch_t *con_backpic = W_CachePatchName("CONSBACK", PU_PATCH);
|
||||||
|
@ -1635,8 +1769,13 @@ static void CON_DrawConsole(void)
|
||||||
//
|
//
|
||||||
void CON_Drawer(void)
|
void CON_Drawer(void)
|
||||||
{
|
{
|
||||||
|
Lock_state();
|
||||||
|
|
||||||
if (!con_started || !graphics_started)
|
if (!con_started || !graphics_started)
|
||||||
|
{
|
||||||
|
Unlock_state();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (needpatchrecache)
|
if (needpatchrecache)
|
||||||
HU_LoadGraphics();
|
HU_LoadGraphics();
|
||||||
|
@ -1654,4 +1793,6 @@ void CON_Drawer(void)
|
||||||
|| gamestate == GS_INTERMISSION || gamestate == GS_ENDING || gamestate == GS_CUTSCENE
|
|| gamestate == GS_INTERMISSION || gamestate == GS_ENDING || gamestate == GS_CUTSCENE
|
||||||
|| gamestate == GS_CREDITS || gamestate == GS_EVALUATION)
|
|| gamestate == GS_CREDITS || gamestate == GS_EVALUATION)
|
||||||
CON_DrawHudlines();
|
CON_DrawHudlines();
|
||||||
|
|
||||||
|
Unlock_state();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,11 +12,16 @@
|
||||||
|
|
||||||
#include "d_event.h"
|
#include "d_event.h"
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
|
#include "i_threads.h"
|
||||||
|
|
||||||
void CON_Init(void);
|
void CON_Init(void);
|
||||||
|
|
||||||
boolean CON_Responder(event_t *ev);
|
boolean CON_Responder(event_t *ev);
|
||||||
|
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
extern I_mutex con_mutex;
|
||||||
|
#endif
|
||||||
|
|
||||||
// set true when screen size has changed, to adapt console
|
// set true when screen size has changed, to adapt console
|
||||||
extern boolean con_recalc;
|
extern boolean con_recalc;
|
||||||
|
|
||||||
|
|
166
src/d_clisrv.c
166
src/d_clisrv.c
|
@ -2228,7 +2228,7 @@ static void CL_LoadReceivedSavegame(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NONET
|
#ifndef NONET
|
||||||
static void SendAskInfo(INT32 node, boolean viams)
|
static void SendAskInfo(INT32 node)
|
||||||
{
|
{
|
||||||
const tic_t asktime = I_GetTime();
|
const tic_t asktime = I_GetTime();
|
||||||
netbuffer->packettype = PT_ASKINFO;
|
netbuffer->packettype = PT_ASKINFO;
|
||||||
|
@ -2239,10 +2239,6 @@ static void SendAskInfo(INT32 node, boolean viams)
|
||||||
// now allowed traffic from the host to us in, so once the MS relays
|
// now allowed traffic from the host to us in, so once the MS relays
|
||||||
// our address to the host, it'll be able to speak to us.
|
// our address to the host, it'll be able to speak to us.
|
||||||
HSendPacket(node, false, 0, sizeof (askinfo_pak));
|
HSendPacket(node, false, 0, sizeof (askinfo_pak));
|
||||||
|
|
||||||
// Also speak to the MS.
|
|
||||||
if (viams && node != 0 && node != BROADCASTADDR)
|
|
||||||
SendAskInfoViaMS(node, asktime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
serverelem_t serverlist[MAXSERVERLIST];
|
serverelem_t serverlist[MAXSERVERLIST];
|
||||||
|
@ -2310,50 +2306,69 @@ static void SL_InsertServer(serverinfo_pak* info, SINT8 node)
|
||||||
M_SortServerList();
|
M_SortServerList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CL_UpdateServerList(boolean internetsearch, INT32 room)
|
#ifdef HAVE_THREADS
|
||||||
|
struct Fetch_servers_ctx
|
||||||
{
|
{
|
||||||
SL_ClearServerList(0);
|
int room;
|
||||||
|
int id;
|
||||||
|
};
|
||||||
|
|
||||||
if (!netgame && I_NetOpenSocket)
|
static void
|
||||||
|
Fetch_servers_thread (struct Fetch_servers_ctx *ctx)
|
||||||
{
|
{
|
||||||
MSCloseUDPSocket(); // Tidy up before wiping the slate.
|
msg_server_t *server_list;
|
||||||
if (I_NetOpenSocket())
|
|
||||||
{
|
|
||||||
netgame = true;
|
|
||||||
multiplayer = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// search for local servers
|
server_list = GetShortServersList(ctx->room, ctx->id);
|
||||||
if (netgame)
|
|
||||||
SendAskInfo(BROADCASTADDR, false);
|
|
||||||
|
|
||||||
if (internetsearch)
|
|
||||||
{
|
|
||||||
const msg_server_t *server_list;
|
|
||||||
INT32 i = -1;
|
|
||||||
server_list = GetShortServersList(room);
|
|
||||||
if (server_list)
|
if (server_list)
|
||||||
{
|
{
|
||||||
char version[8] = "";
|
I_lock_mutex(&ms_QueryId_mutex);
|
||||||
#ifndef DEVELOP
|
{
|
||||||
strcpy(version, SRB2VERSION);
|
if (ctx->id != ms_QueryId)
|
||||||
#else
|
{
|
||||||
strcpy(version, GetRevisionString());
|
free(server_list);
|
||||||
#endif
|
server_list = NULL;
|
||||||
version[sizeof (version) - 1] = '\0';
|
}
|
||||||
|
}
|
||||||
|
I_unlock_mutex(ms_QueryId_mutex);
|
||||||
|
|
||||||
|
if (server_list)
|
||||||
|
{
|
||||||
|
I_lock_mutex(&m_menu_mutex);
|
||||||
|
{
|
||||||
|
if (m_waiting_mode == M_WAITING_SERVERS)
|
||||||
|
m_waiting_mode = M_NOT_WAITING;
|
||||||
|
}
|
||||||
|
I_unlock_mutex(m_menu_mutex);
|
||||||
|
|
||||||
|
I_lock_mutex(&ms_ServerList_mutex);
|
||||||
|
{
|
||||||
|
ms_ServerList = server_list;
|
||||||
|
}
|
||||||
|
I_unlock_mutex(ms_ServerList_mutex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(ctx);
|
||||||
|
}
|
||||||
|
#endif/*HAVE_THREADS*/
|
||||||
|
|
||||||
|
void CL_QueryServerList (msg_server_t *server_list)
|
||||||
|
{
|
||||||
|
INT32 i;
|
||||||
|
|
||||||
for (i = 0; server_list[i].header.buffer[0]; i++)
|
for (i = 0; server_list[i].header.buffer[0]; i++)
|
||||||
{
|
{
|
||||||
// Make sure MS version matches our own, to
|
// Make sure MS version matches our own, to
|
||||||
// thwart nefarious servers who lie to the MS.
|
// thwart nefarious servers who lie to the MS.
|
||||||
|
|
||||||
if (strcmp(version, server_list[i].version) == 0)
|
/* lol bruh, that version COMES from the servers */
|
||||||
|
//if (strcmp(version, server_list[i].version) == 0)
|
||||||
{
|
{
|
||||||
INT32 node = I_NetMakeNodewPort(server_list[i].ip, server_list[i].port);
|
INT32 node = I_NetMakeNodewPort(server_list[i].ip, server_list[i].port);
|
||||||
if (node == -1)
|
if (node == -1)
|
||||||
break; // no more node free
|
break; // no more node free
|
||||||
SendAskInfo(node, true);
|
SendAskInfo(node);
|
||||||
// Force close the connection so that servers can't eat
|
// Force close the connection so that servers can't eat
|
||||||
// up nodes forever if we never get a reply back from them
|
// up nodes forever if we never get a reply back from them
|
||||||
// (usually when they've not forwarded their ports).
|
// (usually when they've not forwarded their ports).
|
||||||
|
@ -2371,26 +2386,69 @@ void CL_UpdateServerList(boolean internetsearch, INT32 room)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//no server list?(-1) or no servers?(0)
|
void CL_UpdateServerList(boolean internetsearch, INT32 room)
|
||||||
if (!i)
|
|
||||||
{
|
{
|
||||||
; /// TODO: display error or warning?
|
#ifdef HAVE_THREADS
|
||||||
|
struct Fetch_servers_ctx *ctx;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SL_ClearServerList(0);
|
||||||
|
|
||||||
|
if (!netgame && I_NetOpenSocket)
|
||||||
|
{
|
||||||
|
if (I_NetOpenSocket())
|
||||||
|
{
|
||||||
|
netgame = true;
|
||||||
|
multiplayer = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// search for local servers
|
||||||
|
if (netgame)
|
||||||
|
SendAskInfo(BROADCASTADDR);
|
||||||
|
|
||||||
|
if (internetsearch)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
ctx = malloc(sizeof *ctx);
|
||||||
|
|
||||||
|
/* This called from M_Refresh so I don't use a mutex */
|
||||||
|
m_waiting_mode = M_WAITING_SERVERS;
|
||||||
|
|
||||||
|
I_lock_mutex(&ms_QueryId_mutex);
|
||||||
|
{
|
||||||
|
ctx->id = ms_QueryId;
|
||||||
|
}
|
||||||
|
I_unlock_mutex(ms_QueryId_mutex);
|
||||||
|
|
||||||
|
ctx->room = room;
|
||||||
|
|
||||||
|
I_spawn_thread("fetch-servers", (I_thread_fn)Fetch_servers_thread, ctx);
|
||||||
|
#else
|
||||||
|
msg_server_t *server_list;
|
||||||
|
|
||||||
|
server_list = GetShortServersList(room, 0);
|
||||||
|
|
||||||
|
if (server_list)
|
||||||
|
{
|
||||||
|
CL_QueryServerList(server_list);
|
||||||
|
free(server_list);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ifndef NONET
|
#endif // ifndef NONET
|
||||||
|
|
||||||
/** Called by CL_ServerConnectionTicker
|
/** Called by CL_ServerConnectionTicker
|
||||||
*
|
*
|
||||||
* \param viams ???
|
* \param asksent The last time we asked the server to join. We re-ask every second in case our request got lost in transmit.
|
||||||
* \param asksent ???
|
|
||||||
* \return False if the connection was aborted
|
* \return False if the connection was aborted
|
||||||
* \sa CL_ServerConnectionTicker
|
* \sa CL_ServerConnectionTicker
|
||||||
* \sa CL_ConnectToServer
|
* \sa CL_ConnectToServer
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static boolean CL_ServerConnectionSearchTicker(boolean viams, tic_t *asksent)
|
static boolean CL_ServerConnectionSearchTicker(tic_t *asksent)
|
||||||
{
|
{
|
||||||
#ifndef NONET
|
#ifndef NONET
|
||||||
INT32 i;
|
INT32 i;
|
||||||
|
@ -2501,7 +2559,7 @@ static boolean CL_ServerConnectionSearchTicker(boolean viams, tic_t *asksent)
|
||||||
// Ask the info to the server (askinfo packet)
|
// Ask the info to the server (askinfo packet)
|
||||||
if (*asksent + NEWTICRATE < I_GetTime())
|
if (*asksent + NEWTICRATE < I_GetTime())
|
||||||
{
|
{
|
||||||
SendAskInfo(servernode, viams);
|
SendAskInfo(servernode);
|
||||||
*asksent = I_GetTime();
|
*asksent = I_GetTime();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -2516,7 +2574,6 @@ static boolean CL_ServerConnectionSearchTicker(boolean viams, tic_t *asksent)
|
||||||
|
|
||||||
/** Called by CL_ConnectToServer
|
/** Called by CL_ConnectToServer
|
||||||
*
|
*
|
||||||
* \param viams ???
|
|
||||||
* \param tmpsave The name of the gamestate file???
|
* \param tmpsave The name of the gamestate file???
|
||||||
* \param oldtic Used for knowing when to poll events and redraw
|
* \param oldtic Used for knowing when to poll events and redraw
|
||||||
* \param asksent ???
|
* \param asksent ???
|
||||||
|
@ -2525,7 +2582,7 @@ static boolean CL_ServerConnectionSearchTicker(boolean viams, tic_t *asksent)
|
||||||
* \sa CL_ConnectToServer
|
* \sa CL_ConnectToServer
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic_t *oldtic, tic_t *asksent)
|
static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic_t *asksent)
|
||||||
{
|
{
|
||||||
boolean waitmore;
|
boolean waitmore;
|
||||||
INT32 i;
|
INT32 i;
|
||||||
|
@ -2537,7 +2594,7 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic
|
||||||
switch (cl_mode)
|
switch (cl_mode)
|
||||||
{
|
{
|
||||||
case CL_SEARCHING:
|
case CL_SEARCHING:
|
||||||
if (!CL_ServerConnectionSearchTicker(viams, asksent))
|
if (!CL_ServerConnectionSearchTicker(asksent))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -2673,11 +2730,10 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic
|
||||||
|
|
||||||
/** Use adaptive send using net_bandwidth and stat.sendbytes
|
/** Use adaptive send using net_bandwidth and stat.sendbytes
|
||||||
*
|
*
|
||||||
* \param viams ???
|
|
||||||
* \todo Better description...
|
* \todo Better description...
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void CL_ConnectToServer(boolean viams)
|
static void CL_ConnectToServer(void)
|
||||||
{
|
{
|
||||||
INT32 pnumnodes, nodewaited = doomcom->numnodes, i;
|
INT32 pnumnodes, nodewaited = doomcom->numnodes, i;
|
||||||
tic_t oldtic;
|
tic_t oldtic;
|
||||||
|
@ -2737,9 +2793,9 @@ static void CL_ConnectToServer(boolean viams)
|
||||||
{
|
{
|
||||||
// If the connection was aborted for some reason, leave
|
// If the connection was aborted for some reason, leave
|
||||||
#ifndef NONET
|
#ifndef NONET
|
||||||
if (!CL_ServerConnectionTicker(viams, tmpsave, &oldtic, &asksent))
|
if (!CL_ServerConnectionTicker(tmpsave, &oldtic, &asksent))
|
||||||
#else
|
#else
|
||||||
if (!CL_ServerConnectionTicker(viams, (char*)NULL, &oldtic, (tic_t *)NULL))
|
if (!CL_ServerConnectionTicker((char*)NULL, &oldtic, (tic_t *)NULL))
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -2916,9 +2972,6 @@ static void Command_ReloadBan(void) //recheck ban.txt
|
||||||
|
|
||||||
static void Command_connect(void)
|
static void Command_connect(void)
|
||||||
{
|
{
|
||||||
// Assume we connect directly.
|
|
||||||
boolean viams = false;
|
|
||||||
|
|
||||||
if (COM_Argc() < 2 || *COM_Argv(1) == 0)
|
if (COM_Argc() < 2 || *COM_Argv(1) == 0)
|
||||||
{
|
{
|
||||||
CONS_Printf(M_GetText(
|
CONS_Printf(M_GetText(
|
||||||
|
@ -2954,9 +3007,6 @@ static void Command_connect(void)
|
||||||
if (netgame && !stricmp(COM_Argv(1), "node"))
|
if (netgame && !stricmp(COM_Argv(1), "node"))
|
||||||
{
|
{
|
||||||
servernode = (SINT8)atoi(COM_Argv(2));
|
servernode = (SINT8)atoi(COM_Argv(2));
|
||||||
|
|
||||||
// Use MS to traverse NAT firewalls.
|
|
||||||
viams = true;
|
|
||||||
}
|
}
|
||||||
else if (netgame)
|
else if (netgame)
|
||||||
{
|
{
|
||||||
|
@ -2965,7 +3015,6 @@ static void Command_connect(void)
|
||||||
}
|
}
|
||||||
else if (I_NetOpenSocket)
|
else if (I_NetOpenSocket)
|
||||||
{
|
{
|
||||||
MSCloseUDPSocket(); // Tidy up before wiping the slate.
|
|
||||||
I_NetOpenSocket();
|
I_NetOpenSocket();
|
||||||
netgame = true;
|
netgame = true;
|
||||||
multiplayer = true;
|
multiplayer = true;
|
||||||
|
@ -2994,7 +3043,7 @@ static void Command_connect(void)
|
||||||
SplitScreen_OnChange();
|
SplitScreen_OnChange();
|
||||||
botingame = false;
|
botingame = false;
|
||||||
botskin = 0;
|
botskin = 0;
|
||||||
CL_ConnectToServer(viams);
|
CL_ConnectToServer();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -4055,7 +4104,6 @@ boolean SV_SpawnServer(void)
|
||||||
SV_GenContext();
|
SV_GenContext();
|
||||||
if (netgame && I_NetOpenSocket)
|
if (netgame && I_NetOpenSocket)
|
||||||
{
|
{
|
||||||
MSCloseUDPSocket(); // Tidy up before wiping the slate.
|
|
||||||
I_NetOpenSocket();
|
I_NetOpenSocket();
|
||||||
if (ms_RoomId > 0)
|
if (ms_RoomId > 0)
|
||||||
RegisterServer();
|
RegisterServer();
|
||||||
|
@ -4063,7 +4111,7 @@ boolean SV_SpawnServer(void)
|
||||||
|
|
||||||
// non dedicated server just connect to itself
|
// non dedicated server just connect to itself
|
||||||
if (!dedicated)
|
if (!dedicated)
|
||||||
CL_ConnectToServer(false);
|
CL_ConnectToServer();
|
||||||
else doomcom->numslots = 1;
|
else doomcom->numslots = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5595,7 +5643,13 @@ void NetUpdate(void)
|
||||||
if (nowtime > resptime)
|
if (nowtime > resptime)
|
||||||
{
|
{
|
||||||
resptime = nowtime;
|
resptime = nowtime;
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
I_lock_mutex(&m_menu_mutex);
|
||||||
|
#endif
|
||||||
M_Ticker();
|
M_Ticker();
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
I_unlock_mutex(m_menu_mutex);
|
||||||
|
#endif
|
||||||
CON_Ticker();
|
CON_Ticker();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "d_net.h"
|
#include "d_net.h"
|
||||||
#include "tables.h"
|
#include "tables.h"
|
||||||
#include "d_player.h"
|
#include "d_player.h"
|
||||||
|
#include "mserv.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The 'packet version' is used to distinguish packet formats.
|
The 'packet version' is used to distinguish packet formats.
|
||||||
|
@ -526,6 +527,7 @@ typedef enum
|
||||||
} kickreason_t;
|
} kickreason_t;
|
||||||
|
|
||||||
extern boolean server;
|
extern boolean server;
|
||||||
|
extern boolean serverrunning;
|
||||||
#define client (!server)
|
#define client (!server)
|
||||||
extern boolean dedicated; // For dedicated server
|
extern boolean dedicated; // For dedicated server
|
||||||
extern UINT16 software_MAXPACKETLENGTH;
|
extern UINT16 software_MAXPACKETLENGTH;
|
||||||
|
@ -565,6 +567,7 @@ void CL_AddSplitscreenPlayer(void);
|
||||||
void CL_RemoveSplitscreenPlayer(void);
|
void CL_RemoveSplitscreenPlayer(void);
|
||||||
void CL_Reset(void);
|
void CL_Reset(void);
|
||||||
void CL_ClearPlayer(INT32 playernum);
|
void CL_ClearPlayer(INT32 playernum);
|
||||||
|
void CL_QueryServerList(msg_server_t *list);
|
||||||
void CL_UpdateServerList(boolean internetsearch, INT32 room);
|
void CL_UpdateServerList(boolean internetsearch, INT32 room);
|
||||||
// Is there a game running
|
// Is there a game running
|
||||||
boolean Playing(void);
|
boolean Playing(void);
|
||||||
|
|
33
src/d_main.c
33
src/d_main.c
|
@ -40,6 +40,7 @@
|
||||||
#include "hu_stuff.h"
|
#include "hu_stuff.h"
|
||||||
#include "i_sound.h"
|
#include "i_sound.h"
|
||||||
#include "i_system.h"
|
#include "i_system.h"
|
||||||
|
#include "i_threads.h"
|
||||||
#include "i_video.h"
|
#include "i_video.h"
|
||||||
#include "m_argv.h"
|
#include "m_argv.h"
|
||||||
#include "m_menu.h"
|
#include "m_menu.h"
|
||||||
|
@ -172,6 +173,8 @@ void D_ProcessEvents(void)
|
||||||
{
|
{
|
||||||
event_t *ev;
|
event_t *ev;
|
||||||
|
|
||||||
|
boolean eaten;
|
||||||
|
|
||||||
for (; eventtail != eventhead; eventtail = (eventtail+1) & (MAXEVENTS-1))
|
for (; eventtail != eventhead; eventtail = (eventtail+1) & (MAXEVENTS-1))
|
||||||
{
|
{
|
||||||
ev = &events[eventtail];
|
ev = &events[eventtail];
|
||||||
|
@ -187,11 +190,31 @@ void D_ProcessEvents(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Menu input
|
// Menu input
|
||||||
if (M_Responder(ev))
|
#ifdef HAVE_THREADS
|
||||||
|
I_lock_mutex(&m_menu_mutex);
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
eaten = M_Responder(ev);
|
||||||
|
}
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
I_unlock_mutex(m_menu_mutex);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (eaten)
|
||||||
continue; // menu ate the event
|
continue; // menu ate the event
|
||||||
|
|
||||||
// console input
|
// console input
|
||||||
if (CON_Responder(ev))
|
#ifdef HAVE_THREADS
|
||||||
|
I_lock_mutex(&con_mutex);
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
eaten = CON_Responder(ev);
|
||||||
|
}
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
I_unlock_mutex(con_mutex);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (eaten)
|
||||||
continue; // ate the event
|
continue; // ate the event
|
||||||
|
|
||||||
G_Responder(ev);
|
G_Responder(ev);
|
||||||
|
@ -510,7 +533,13 @@ static void D_Display(void)
|
||||||
// vid size change is now finished if it was on...
|
// vid size change is now finished if it was on...
|
||||||
vid.recalc = 0;
|
vid.recalc = 0;
|
||||||
|
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
I_lock_mutex(&m_menu_mutex);
|
||||||
|
#endif
|
||||||
M_Drawer(); // menu is drawn even on top of everything
|
M_Drawer(); // menu is drawn even on top of everything
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
I_unlock_mutex(m_menu_mutex);
|
||||||
|
#endif
|
||||||
// focus lost moved to M_Drawer
|
// focus lost moved to M_Drawer
|
||||||
|
|
||||||
CON_Drawer();
|
CON_Drawer();
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "w_wad.h"
|
#include "w_wad.h"
|
||||||
#include "z_zone.h"
|
#include "z_zone.h"
|
||||||
#include "i_system.h"
|
#include "i_system.h"
|
||||||
|
#include "i_threads.h"
|
||||||
#include "m_menu.h"
|
#include "m_menu.h"
|
||||||
#include "dehacked.h"
|
#include "dehacked.h"
|
||||||
#include "g_input.h"
|
#include "g_input.h"
|
||||||
|
@ -959,7 +960,13 @@ void F_IntroDrawer(void)
|
||||||
|
|
||||||
I_OsPolling();
|
I_OsPolling();
|
||||||
I_UpdateNoBlit();
|
I_UpdateNoBlit();
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
I_lock_mutex(&m_menu_mutex);
|
||||||
|
#endif
|
||||||
M_Drawer(); // menu is drawn even on top of wipes
|
M_Drawer(); // menu is drawn even on top of wipes
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
I_unlock_mutex(m_menu_mutex);
|
||||||
|
#endif
|
||||||
I_FinishUpdate(); // Update the screen with the image Tails 06-19-2001
|
I_FinishUpdate(); // Update the screen with the image Tails 06-19-2001
|
||||||
|
|
||||||
if (moviemode) // make sure we save frames for the white hold too
|
if (moviemode) // make sure we save frames for the white hold too
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "z_zone.h"
|
#include "z_zone.h"
|
||||||
|
|
||||||
#include "i_system.h"
|
#include "i_system.h"
|
||||||
|
#include "i_threads.h"
|
||||||
#include "m_menu.h"
|
#include "m_menu.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "d_main.h"
|
#include "d_main.h"
|
||||||
|
@ -595,7 +596,15 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu)
|
||||||
I_UpdateNoBlit();
|
I_UpdateNoBlit();
|
||||||
|
|
||||||
if (drawMenu)
|
if (drawMenu)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
I_lock_mutex(&m_menu_mutex);
|
||||||
|
#endif
|
||||||
M_Drawer(); // menu is drawn even on top of wipes
|
M_Drawer(); // menu is drawn even on top of wipes
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
I_unlock_mutex(m_menu_mutex);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
I_FinishUpdate(); // page flip or blit buffer
|
I_FinishUpdate(); // page flip or blit buffer
|
||||||
|
|
||||||
|
|
673
src/http-mserv.c
Normal file
673
src/http-mserv.c
Normal file
|
@ -0,0 +1,673 @@
|
||||||
|
// SONIC ROBO BLAST 2
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Copyright (C) 2020 by James R.
|
||||||
|
//
|
||||||
|
// This program is free software distributed under the
|
||||||
|
// terms of the GNU General Public License, version 2.
|
||||||
|
// See the 'LICENSE' file for more details.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// \brief HTTP based master server
|
||||||
|
|
||||||
|
/*
|
||||||
|
Documentation available here.
|
||||||
|
|
||||||
|
<http://mb.srb2.org/MS/tools/api/v1/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <curl/curl.h>
|
||||||
|
|
||||||
|
#include "doomdef.h"
|
||||||
|
#include "d_clisrv.h"
|
||||||
|
#include "command.h"
|
||||||
|
#include "m_argv.h"
|
||||||
|
#include "m_menu.h"
|
||||||
|
#include "mserv.h"
|
||||||
|
#include "i_tcp.h"/* for current_port */
|
||||||
|
#include "i_threads.h"
|
||||||
|
|
||||||
|
/* reasonable default I guess?? */
|
||||||
|
#define DEFAULT_BUFFER_SIZE (4096)
|
||||||
|
|
||||||
|
/* I just stop myself from making macros anymore. */
|
||||||
|
#define Blame( ... ) \
|
||||||
|
CONS_Printf("\x85" __VA_ARGS__)
|
||||||
|
|
||||||
|
static void MasterServer_Debug_OnChange (void);
|
||||||
|
|
||||||
|
consvar_t cv_masterserver_timeout = {
|
||||||
|
"masterserver_timeout", "5", CV_SAVE, CV_Unsigned,
|
||||||
|
NULL, 0, NULL, NULL, 0, 0, NULL/* C90 moment */
|
||||||
|
};
|
||||||
|
|
||||||
|
consvar_t cv_masterserver_debug = {
|
||||||
|
"masterserver_debug", "Off", CV_SAVE|CV_CALL, CV_OnOff,
|
||||||
|
MasterServer_Debug_OnChange, 0, NULL, NULL, 0, 0, NULL/* C90 moment */
|
||||||
|
};
|
||||||
|
|
||||||
|
consvar_t cv_masterserver_token = {
|
||||||
|
"masterserver_token", "", CV_SAVE, NULL,
|
||||||
|
NULL, 0, NULL, NULL, 0, 0, NULL/* C90 moment */
|
||||||
|
};
|
||||||
|
|
||||||
|
static int hms_started;
|
||||||
|
|
||||||
|
static char *hms_api;
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
static I_mutex hms_api_mutex;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static char *hms_server_token;
|
||||||
|
|
||||||
|
struct HMS_buffer
|
||||||
|
{
|
||||||
|
CURL *curl;
|
||||||
|
char *buffer;
|
||||||
|
int needle;
|
||||||
|
int end;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
Contact_error (void)
|
||||||
|
{
|
||||||
|
CONS_Alert(CONS_ERROR,
|
||||||
|
"There was a problem contacting the master server...\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static size_t
|
||||||
|
HMS_on_read (char *s, size_t _1, size_t n, void *userdata)
|
||||||
|
{
|
||||||
|
struct HMS_buffer *buffer;
|
||||||
|
size_t blocks;
|
||||||
|
|
||||||
|
(void)_1;
|
||||||
|
|
||||||
|
buffer = userdata;
|
||||||
|
|
||||||
|
if (n >= (size_t)( buffer->end - buffer->needle ))
|
||||||
|
{
|
||||||
|
/* resize to next multiple of buffer size */
|
||||||
|
blocks = ( n / DEFAULT_BUFFER_SIZE + 1 );
|
||||||
|
buffer->end += ( blocks * DEFAULT_BUFFER_SIZE );
|
||||||
|
|
||||||
|
buffer->buffer = realloc(buffer->buffer, buffer->end);
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(&buffer->buffer[buffer->needle], s, n);
|
||||||
|
buffer->needle += n;
|
||||||
|
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct HMS_buffer *
|
||||||
|
HMS_connect (const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
CURL *curl;
|
||||||
|
char *url;
|
||||||
|
char *quack_token;
|
||||||
|
size_t seek;
|
||||||
|
size_t token_length;
|
||||||
|
struct HMS_buffer *buffer;
|
||||||
|
|
||||||
|
if (! hms_started)
|
||||||
|
{
|
||||||
|
if (curl_global_init(CURL_GLOBAL_ALL) != 0)
|
||||||
|
{
|
||||||
|
Contact_error();
|
||||||
|
Blame("From curl_global_init.\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
atexit(curl_global_cleanup);
|
||||||
|
hms_started = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
curl = curl_easy_init();
|
||||||
|
|
||||||
|
if (! curl)
|
||||||
|
{
|
||||||
|
Contact_error();
|
||||||
|
Blame("From curl_easy_init.\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cv_masterserver_token.string[0])
|
||||||
|
{
|
||||||
|
quack_token = curl_easy_escape(curl, cv_masterserver_token.string, 0);
|
||||||
|
token_length = ( sizeof "?token="-1 )+ strlen(quack_token);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
quack_token = NULL;
|
||||||
|
token_length = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
I_lock_mutex(&hms_api_mutex);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
seek = strlen(hms_api) + 1;/* + '/' */
|
||||||
|
|
||||||
|
va_start (ap, format);
|
||||||
|
url = malloc(seek + vsnprintf(0, 0, format, ap) + token_length + 1);
|
||||||
|
va_end (ap);
|
||||||
|
|
||||||
|
sprintf(url, "%s/", hms_api);
|
||||||
|
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
I_unlock_mutex(hms_api_mutex);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
va_start (ap, format);
|
||||||
|
seek += vsprintf(&url[seek], format, ap);
|
||||||
|
va_end (ap);
|
||||||
|
|
||||||
|
if (quack_token)
|
||||||
|
sprintf(&url[seek], "?token=%s", quack_token);
|
||||||
|
|
||||||
|
CONS_Printf("HMS: connecting '%s'...\n", url);
|
||||||
|
|
||||||
|
buffer = malloc(sizeof *buffer);
|
||||||
|
buffer->curl = curl;
|
||||||
|
buffer->end = DEFAULT_BUFFER_SIZE;
|
||||||
|
buffer->buffer = malloc(buffer->end);
|
||||||
|
buffer->needle = 0;
|
||||||
|
|
||||||
|
if (cv_masterserver_debug.value)
|
||||||
|
{
|
||||||
|
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_STDERR, logstream);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (M_CheckParm("-bindaddr") && M_IsNextParm())
|
||||||
|
{
|
||||||
|
curl_easy_setopt(curl, CURLOPT_INTERFACE, M_GetNextParm());
|
||||||
|
}
|
||||||
|
|
||||||
|
curl_easy_setopt(curl, CURLOPT_URL, url);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
|
||||||
|
|
||||||
|
curl_easy_setopt(curl, CURLOPT_TIMEOUT, cv_masterserver_timeout.value);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, HMS_on_read);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, buffer);
|
||||||
|
|
||||||
|
curl_free(quack_token);
|
||||||
|
free(url);
|
||||||
|
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
HMS_do (struct HMS_buffer *buffer)
|
||||||
|
{
|
||||||
|
CURLcode cc;
|
||||||
|
long status;
|
||||||
|
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
cc = curl_easy_perform(buffer->curl);
|
||||||
|
|
||||||
|
if (cc != CURLE_OK)
|
||||||
|
{
|
||||||
|
Contact_error();
|
||||||
|
Blame(
|
||||||
|
"From curl_easy_perform: %s\n",
|
||||||
|
curl_easy_strerror(cc)
|
||||||
|
);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer->buffer[buffer->needle] = '\0';
|
||||||
|
|
||||||
|
curl_easy_getinfo(buffer->curl, CURLINFO_RESPONSE_CODE, &status);
|
||||||
|
|
||||||
|
if (status != 200)
|
||||||
|
{
|
||||||
|
p = strchr(buffer->buffer, '\n');
|
||||||
|
|
||||||
|
if (p)
|
||||||
|
*p = '\0';
|
||||||
|
|
||||||
|
Contact_error();
|
||||||
|
Blame(
|
||||||
|
"Master server error %ld: %s%s\n",
|
||||||
|
status,
|
||||||
|
buffer->buffer,
|
||||||
|
( (p) ? "" : " (malformed)" )
|
||||||
|
);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
HMS_end (struct HMS_buffer *buffer)
|
||||||
|
{
|
||||||
|
curl_easy_cleanup(buffer->curl);
|
||||||
|
free(buffer->buffer);
|
||||||
|
free(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
HMS_fetch_rooms (int joining, int query_id)
|
||||||
|
{
|
||||||
|
struct HMS_buffer *hms;
|
||||||
|
int ok;
|
||||||
|
|
||||||
|
int doing_shit;
|
||||||
|
|
||||||
|
char *id;
|
||||||
|
char *title;
|
||||||
|
char *room_motd;
|
||||||
|
|
||||||
|
int id_no;
|
||||||
|
|
||||||
|
char *p;
|
||||||
|
char *end;
|
||||||
|
|
||||||
|
int i;
|
||||||
|
|
||||||
|
(void)query_id;
|
||||||
|
|
||||||
|
hms = HMS_connect("rooms");
|
||||||
|
|
||||||
|
if (! hms)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (HMS_do(hms))
|
||||||
|
{
|
||||||
|
doing_shit = 1;
|
||||||
|
|
||||||
|
p = hms->buffer;
|
||||||
|
|
||||||
|
for (i = 0; i < NUM_LIST_ROOMS && ( end = strstr(p, "\n\n\n") );)
|
||||||
|
{
|
||||||
|
*end = '\0';
|
||||||
|
|
||||||
|
id = strtok(p, "\n");
|
||||||
|
title = strtok(0, "\n");
|
||||||
|
room_motd = strtok(0, "");
|
||||||
|
|
||||||
|
if (id && title && room_motd)
|
||||||
|
{
|
||||||
|
id_no = atoi(id);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Don't show the 'All' room if hosting. And it's a hack like this
|
||||||
|
because I'm way too lazy to add another feature to the MS.
|
||||||
|
*/
|
||||||
|
if (joining || id_no != 0)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
I_lock_mutex(&ms_QueryId_mutex);
|
||||||
|
{
|
||||||
|
if (query_id != ms_QueryId)
|
||||||
|
doing_shit = 0;
|
||||||
|
}
|
||||||
|
I_unlock_mutex(ms_QueryId_mutex);
|
||||||
|
|
||||||
|
if (! doing_shit)
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
room_list[i].header.buffer[0] = 1;
|
||||||
|
|
||||||
|
room_list[i].id = id_no;
|
||||||
|
strlcpy(room_list[i].name, title, sizeof room_list[i].name);
|
||||||
|
strlcpy(room_list[i].motd, room_motd, sizeof room_list[i].motd);
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
p = ( end + 3 );/* skip the three linefeeds */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doing_shit)
|
||||||
|
room_list[i].header.buffer[0] = 0;
|
||||||
|
|
||||||
|
ok = 1;
|
||||||
|
|
||||||
|
if (doing_shit)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
I_lock_mutex(&m_menu_mutex);
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
for (i = 0; room_list[i].header.buffer[0]; i++)
|
||||||
|
{
|
||||||
|
if(*room_list[i].name != '\0')
|
||||||
|
{
|
||||||
|
MP_RoomMenu[i+1].text = room_list[i].name;
|
||||||
|
roomIds[i] = room_list[i].id;
|
||||||
|
MP_RoomMenu[i+1].status = IT_STRING|IT_CALL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
I_unlock_mutex(m_menu_mutex);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ok = 0;
|
||||||
|
|
||||||
|
HMS_end(hms);
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
HMS_register (void)
|
||||||
|
{
|
||||||
|
struct HMS_buffer *hms;
|
||||||
|
int ok;
|
||||||
|
|
||||||
|
char post[256];
|
||||||
|
|
||||||
|
char *title;
|
||||||
|
|
||||||
|
hms = HMS_connect("rooms/%d/register", ms_RoomId);
|
||||||
|
|
||||||
|
if (! hms)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
title = curl_easy_escape(hms->curl, cv_servername.string, 0);
|
||||||
|
|
||||||
|
snprintf(post, sizeof post,
|
||||||
|
"port=%d&"
|
||||||
|
"title=%s&"
|
||||||
|
"version=%s",
|
||||||
|
|
||||||
|
current_port,
|
||||||
|
|
||||||
|
title,
|
||||||
|
|
||||||
|
SRB2VERSION
|
||||||
|
);
|
||||||
|
|
||||||
|
curl_free(title);
|
||||||
|
|
||||||
|
curl_easy_setopt(hms->curl, CURLOPT_POSTFIELDS, post);
|
||||||
|
|
||||||
|
ok = HMS_do(hms);
|
||||||
|
|
||||||
|
if (ok)
|
||||||
|
{
|
||||||
|
hms_server_token = strdup(strtok(hms->buffer, "\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
HMS_end(hms);
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
HMS_unlist (void)
|
||||||
|
{
|
||||||
|
struct HMS_buffer *hms;
|
||||||
|
int ok;
|
||||||
|
|
||||||
|
hms = HMS_connect("servers/%s/unlist", hms_server_token);
|
||||||
|
|
||||||
|
if (! hms)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
curl_easy_setopt(hms->curl, CURLOPT_CUSTOMREQUEST, "POST");
|
||||||
|
|
||||||
|
ok = HMS_do(hms);
|
||||||
|
HMS_end(hms);
|
||||||
|
|
||||||
|
free(hms_server_token);
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
HMS_update (void)
|
||||||
|
{
|
||||||
|
struct HMS_buffer *hms;
|
||||||
|
int ok;
|
||||||
|
|
||||||
|
char post[256];
|
||||||
|
|
||||||
|
char *title;
|
||||||
|
|
||||||
|
hms = HMS_connect("servers/%s/update", hms_server_token);
|
||||||
|
|
||||||
|
if (! hms)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
title = curl_easy_escape(hms->curl, cv_servername.string, 0);
|
||||||
|
|
||||||
|
snprintf(post, sizeof post,
|
||||||
|
"title=%s",
|
||||||
|
title
|
||||||
|
);
|
||||||
|
|
||||||
|
curl_free(title);
|
||||||
|
|
||||||
|
curl_easy_setopt(hms->curl, CURLOPT_POSTFIELDS, post);
|
||||||
|
|
||||||
|
ok = HMS_do(hms);
|
||||||
|
HMS_end(hms);
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
HMS_list_servers (void)
|
||||||
|
{
|
||||||
|
struct HMS_buffer *hms;
|
||||||
|
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
hms = HMS_connect("servers");
|
||||||
|
|
||||||
|
if (! hms)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (HMS_do(hms))
|
||||||
|
{
|
||||||
|
p = &hms->buffer[strlen(hms->buffer)];
|
||||||
|
while (*--p == '\n')
|
||||||
|
;
|
||||||
|
|
||||||
|
CONS_Printf("%s\n", hms->buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
HMS_end(hms);
|
||||||
|
}
|
||||||
|
|
||||||
|
msg_server_t *
|
||||||
|
HMS_fetch_servers (msg_server_t *list, int room_number, int query_id)
|
||||||
|
{
|
||||||
|
struct HMS_buffer *hms;
|
||||||
|
|
||||||
|
int doing_shit;
|
||||||
|
|
||||||
|
char local_version[9];
|
||||||
|
|
||||||
|
char *room;
|
||||||
|
|
||||||
|
char *address;
|
||||||
|
char *port;
|
||||||
|
char *title;
|
||||||
|
char *version;
|
||||||
|
|
||||||
|
char *end;
|
||||||
|
char *section_end;
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
int i;
|
||||||
|
|
||||||
|
(void)query_id;
|
||||||
|
|
||||||
|
if (room_number > 0)
|
||||||
|
{
|
||||||
|
hms = HMS_connect("rooms/%d/servers", room_number);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
hms = HMS_connect("servers");
|
||||||
|
|
||||||
|
if (! hms)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (HMS_do(hms))
|
||||||
|
{
|
||||||
|
doing_shit = 1;
|
||||||
|
|
||||||
|
snprintf(local_version, sizeof local_version,
|
||||||
|
"%s",
|
||||||
|
SRB2VERSION
|
||||||
|
);
|
||||||
|
|
||||||
|
p = hms->buffer;
|
||||||
|
i = 0;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
section_end = strstr(p, "\n\n");
|
||||||
|
|
||||||
|
room = strtok(p, "\n");
|
||||||
|
|
||||||
|
p = strtok(0, "");
|
||||||
|
|
||||||
|
if (! p)
|
||||||
|
break;
|
||||||
|
|
||||||
|
while (i < MAXSERVERLIST && ( end = strchr(p, '\n') ))
|
||||||
|
{
|
||||||
|
*end = '\0';
|
||||||
|
|
||||||
|
address = strtok(p, " ");
|
||||||
|
port = strtok(0, " ");
|
||||||
|
title = strtok(0, " ");
|
||||||
|
version = strtok(0, "");
|
||||||
|
|
||||||
|
if (address && port && title && version)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
I_lock_mutex(&ms_QueryId_mutex);
|
||||||
|
{
|
||||||
|
if (query_id != ms_QueryId)
|
||||||
|
doing_shit = 0;
|
||||||
|
}
|
||||||
|
I_unlock_mutex(ms_QueryId_mutex);
|
||||||
|
|
||||||
|
if (! doing_shit)
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (strcmp(version, local_version) == 0)
|
||||||
|
{
|
||||||
|
strlcpy(list[i].ip, address, sizeof list[i].ip);
|
||||||
|
strlcpy(list[i].port, port, sizeof list[i].port);
|
||||||
|
strlcpy(list[i].name, title, sizeof list[i].name);
|
||||||
|
strlcpy(list[i].version, version, sizeof list[i].version);
|
||||||
|
|
||||||
|
list[i].room = atoi(room);
|
||||||
|
|
||||||
|
list[i].header.buffer[0] = 1;
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (end == section_end)/* end of list for this room */
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
p = ( end + 1 );/* skip server delimiter */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
section_end = 0;/* malformed so quit the parsing */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! doing_shit)
|
||||||
|
break;
|
||||||
|
|
||||||
|
p = ( section_end + 2 );
|
||||||
|
}
|
||||||
|
while (section_end) ;
|
||||||
|
|
||||||
|
if (doing_shit)
|
||||||
|
list[i].header.buffer[0] = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
list = NULL;
|
||||||
|
|
||||||
|
HMS_end(hms);
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
HMS_compare_mod_version (char *buffer, size_t buffer_size)
|
||||||
|
{
|
||||||
|
struct HMS_buffer *hms;
|
||||||
|
int ok;
|
||||||
|
|
||||||
|
char *version;
|
||||||
|
char *version_name;
|
||||||
|
|
||||||
|
hms = HMS_connect("versions/%d", MODID);
|
||||||
|
|
||||||
|
if (! hms)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ok = 0;
|
||||||
|
|
||||||
|
if (HMS_do(hms))
|
||||||
|
{
|
||||||
|
version = strtok(hms->buffer, " ");
|
||||||
|
version_name = strtok(0, "\n");
|
||||||
|
|
||||||
|
if (version && version_name)
|
||||||
|
{
|
||||||
|
if (atoi(version) != MODVERSION)
|
||||||
|
{
|
||||||
|
strlcpy(buffer, version_name, buffer_size);
|
||||||
|
ok = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ok = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HMS_end(hms);
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
HMS_set_api (char *api)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
I_lock_mutex(&hms_api_mutex);
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
free(hms_api);
|
||||||
|
hms_api = api;
|
||||||
|
}
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
I_unlock_mutex(hms_api_mutex);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
MasterServer_Debug_OnChange (void)
|
||||||
|
{
|
||||||
|
/* TODO: change to 'latest-log.txt' for log files revision. */
|
||||||
|
if (cv_masterserver_debug.value)
|
||||||
|
CONS_Printf("Master server debug messages will appear in log.txt\n");
|
||||||
|
}
|
39
src/i_threads.h
Normal file
39
src/i_threads.h
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
// SONIC ROBO BLAST 2 KART
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Copyright (C) 2020 by James R.
|
||||||
|
//
|
||||||
|
// This program is free software distributed under the
|
||||||
|
// terms of the GNU General Public License, version 2.
|
||||||
|
// See the 'LICENSE' file for more details.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
/// \file i_threads.h
|
||||||
|
/// \brief Multithreading abstraction
|
||||||
|
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
|
||||||
|
#ifndef I_THREADS_H
|
||||||
|
#define I_THREADS_H
|
||||||
|
|
||||||
|
typedef void (*I_thread_fn)(void *userdata);
|
||||||
|
|
||||||
|
typedef void * I_mutex;
|
||||||
|
typedef void * I_cond;
|
||||||
|
|
||||||
|
void I_start_threads (void);
|
||||||
|
void I_stop_threads (void);
|
||||||
|
|
||||||
|
void I_spawn_thread (const char *name, I_thread_fn, void *userdata);
|
||||||
|
|
||||||
|
/* check in your thread whether to return early */
|
||||||
|
int I_thread_is_stopped (void);
|
||||||
|
|
||||||
|
void I_lock_mutex (I_mutex *);
|
||||||
|
void I_unlock_mutex (I_mutex);
|
||||||
|
|
||||||
|
void I_hold_cond (I_cond *, I_mutex);
|
||||||
|
|
||||||
|
void I_wake_one_cond (I_cond *);
|
||||||
|
void I_wake_all_cond (I_cond *);
|
||||||
|
|
||||||
|
#endif/*I_THREADS_H*/
|
||||||
|
#endif/*HAVE_THREADS*/
|
213
src/m_menu.c
213
src/m_menu.c
|
@ -32,6 +32,7 @@
|
||||||
#include "sounds.h"
|
#include "sounds.h"
|
||||||
#include "s_sound.h"
|
#include "s_sound.h"
|
||||||
#include "i_system.h"
|
#include "i_system.h"
|
||||||
|
#include "i_threads.h"
|
||||||
|
|
||||||
// Addfile
|
// Addfile
|
||||||
#include "filesrch.h"
|
#include "filesrch.h"
|
||||||
|
@ -116,6 +117,12 @@ typedef enum
|
||||||
NUM_QUITMESSAGES
|
NUM_QUITMESSAGES
|
||||||
} text_enum;
|
} text_enum;
|
||||||
|
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
I_mutex m_menu_mutex;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
M_waiting_mode_t m_waiting_mode = M_NOT_WAITING;
|
||||||
|
|
||||||
const char *quitmsg[NUM_QUITMESSAGES];
|
const char *quitmsg[NUM_QUITMESSAGES];
|
||||||
|
|
||||||
// Stuff for customizing the player select screen Tails 09-22-2003
|
// Stuff for customizing the player select screen Tails 09-22-2003
|
||||||
|
@ -1027,7 +1034,7 @@ enum
|
||||||
FIRSTSERVERLINE
|
FIRSTSERVERLINE
|
||||||
};
|
};
|
||||||
|
|
||||||
static menuitem_t MP_RoomMenu[] =
|
menuitem_t MP_RoomMenu[] =
|
||||||
{
|
{
|
||||||
{IT_STRING | IT_CALL, NULL, "<Unlisted Mode>", M_ChooseRoom, 9},
|
{IT_STRING | IT_CALL, NULL, "<Unlisted Mode>", M_ChooseRoom, 9},
|
||||||
{IT_DISABLED, NULL, "", M_ChooseRoom, 18},
|
{IT_DISABLED, NULL, "", M_ChooseRoom, 18},
|
||||||
|
@ -3074,7 +3081,6 @@ static void M_GoBack(INT32 choice)
|
||||||
//make sure the game doesn't still think we're in a netgame.
|
//make sure the game doesn't still think we're in a netgame.
|
||||||
if (!Playing() && netgame && multiplayer)
|
if (!Playing() && netgame && multiplayer)
|
||||||
{
|
{
|
||||||
MSCloseUDPSocket(); // Clean up so we can re-open the connection later.
|
|
||||||
netgame = multiplayer = false;
|
netgame = multiplayer = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3833,6 +3839,30 @@ void M_SetupNextMenu(menu_t *menudef)
|
||||||
{
|
{
|
||||||
INT16 i;
|
INT16 i;
|
||||||
|
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
if (currentMenu == &MP_RoomDef || currentMenu == &MP_ConnectDef)
|
||||||
|
{
|
||||||
|
I_lock_mutex(&ms_QueryId_mutex);
|
||||||
|
{
|
||||||
|
ms_QueryId++;
|
||||||
|
}
|
||||||
|
I_unlock_mutex(ms_QueryId_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentMenu == &MP_ConnectDef)
|
||||||
|
{
|
||||||
|
I_lock_mutex(&ms_ServerList_mutex);
|
||||||
|
{
|
||||||
|
if (ms_ServerList)
|
||||||
|
{
|
||||||
|
free(ms_ServerList);
|
||||||
|
ms_ServerList = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
I_unlock_mutex(ms_ServerList_mutex);
|
||||||
|
}
|
||||||
|
#endif/*HAVE_THREADS*/
|
||||||
|
|
||||||
if (currentMenu->quitroutine)
|
if (currentMenu->quitroutine)
|
||||||
{
|
{
|
||||||
// If you're going from a menu to itself, why are you running the quitroutine? You're not quitting it! -SH
|
// If you're going from a menu to itself, why are you running the quitroutine? You're not quitting it! -SH
|
||||||
|
@ -3896,6 +3926,19 @@ void M_Ticker(void)
|
||||||
|
|
||||||
if (currentMenu == &OP_ScreenshotOptionsDef)
|
if (currentMenu == &OP_ScreenshotOptionsDef)
|
||||||
M_SetupScreenshotMenu();
|
M_SetupScreenshotMenu();
|
||||||
|
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
I_lock_mutex(&ms_ServerList_mutex);
|
||||||
|
{
|
||||||
|
if (ms_ServerList)
|
||||||
|
{
|
||||||
|
CL_QueryServerList(ms_ServerList);
|
||||||
|
free(ms_ServerList);
|
||||||
|
ms_ServerList = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
I_unlock_mutex(ms_ServerList_mutex);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -10913,13 +10956,43 @@ static INT32 menuRoomIndex = 0;
|
||||||
|
|
||||||
static void M_DrawRoomMenu(void)
|
static void M_DrawRoomMenu(void)
|
||||||
{
|
{
|
||||||
|
static int frame = -12;
|
||||||
|
int dot_frame;
|
||||||
|
char text[4];
|
||||||
|
|
||||||
const char *rmotd;
|
const char *rmotd;
|
||||||
|
const char *waiting_message;
|
||||||
|
|
||||||
|
int dots;
|
||||||
|
|
||||||
|
if (m_waiting_mode)
|
||||||
|
{
|
||||||
|
dot_frame = frame / 4;
|
||||||
|
dots = dot_frame + 3;
|
||||||
|
|
||||||
|
strcpy(text, " ");
|
||||||
|
|
||||||
|
if (dots > 0)
|
||||||
|
{
|
||||||
|
if (dot_frame < 0)
|
||||||
|
dot_frame = 0;
|
||||||
|
|
||||||
|
strncpy(&text[dot_frame], "...", min(dots, 3 - dot_frame));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (++frame == 12)
|
||||||
|
frame = -12;
|
||||||
|
|
||||||
|
currentMenu->menuitems[0].text = text;
|
||||||
|
}
|
||||||
|
|
||||||
// use generic drawer for cursor, items and title
|
// use generic drawer for cursor, items and title
|
||||||
M_DrawGenericMenu();
|
M_DrawGenericMenu();
|
||||||
|
|
||||||
V_DrawString(currentMenu->x - 16, currentMenu->y, V_YELLOWMAP, M_GetText("Select a room"));
|
V_DrawString(currentMenu->x - 16, currentMenu->y, V_YELLOWMAP, M_GetText("Select a room"));
|
||||||
|
|
||||||
|
if (m_waiting_mode == M_NOT_WAITING)
|
||||||
|
{
|
||||||
M_DrawTextBox(144, 24, 20, 20);
|
M_DrawTextBox(144, 24, 20, 20);
|
||||||
|
|
||||||
if (itemOn == 0)
|
if (itemOn == 0)
|
||||||
|
@ -10931,6 +11004,19 @@ static void M_DrawRoomMenu(void)
|
||||||
V_DrawString(144+8, 32, V_ALLOWLOWERCASE|V_RETURN8, rmotd);
|
V_DrawString(144+8, 32, V_ALLOWLOWERCASE|V_RETURN8, rmotd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_waiting_mode)
|
||||||
|
{
|
||||||
|
// Display a little "please wait" message.
|
||||||
|
M_DrawTextBox(52, BASEVIDHEIGHT/2-10, 25, 3);
|
||||||
|
if (m_waiting_mode == M_WAITING_VERSION)
|
||||||
|
waiting_message = "Checking for updates...";
|
||||||
|
else
|
||||||
|
waiting_message = "Fetching room info...";
|
||||||
|
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2, 0, waiting_message);
|
||||||
|
V_DrawCenteredString(BASEVIDWIDTH/2, (BASEVIDHEIGHT/2)+12, 0, "Please wait.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void M_DrawConnectMenu(void)
|
static void M_DrawConnectMenu(void)
|
||||||
{
|
{
|
||||||
UINT16 i;
|
UINT16 i;
|
||||||
|
@ -10996,6 +11082,14 @@ static void M_DrawConnectMenu(void)
|
||||||
localservercount = serverlistcount;
|
localservercount = serverlistcount;
|
||||||
|
|
||||||
M_DrawGenericMenu();
|
M_DrawGenericMenu();
|
||||||
|
|
||||||
|
if (m_waiting_mode)
|
||||||
|
{
|
||||||
|
// Display a little "please wait" message.
|
||||||
|
M_DrawTextBox(52, BASEVIDHEIGHT/2-10, 25, 3);
|
||||||
|
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2, 0, "Searching for servers...");
|
||||||
|
V_DrawCenteredString(BASEVIDWIDTH/2, (BASEVIDHEIGHT/2)+12, 0, "Please wait.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean M_CancelConnect(void)
|
static boolean M_CancelConnect(void)
|
||||||
|
@ -11085,10 +11179,10 @@ void M_SortServerList(void)
|
||||||
|
|
||||||
#ifndef NONET
|
#ifndef NONET
|
||||||
#ifdef UPDATE_ALERT
|
#ifdef UPDATE_ALERT
|
||||||
static boolean M_CheckMODVersion(void)
|
static boolean M_CheckMODVersion(int id)
|
||||||
{
|
{
|
||||||
char updatestring[500];
|
char updatestring[500];
|
||||||
const char *updatecheck = GetMODVersion();
|
const char *updatecheck = GetMODVersion(id);
|
||||||
if(updatecheck)
|
if(updatecheck)
|
||||||
{
|
{
|
||||||
sprintf(updatestring, UPDATE_ALERT_STRING, VERSIONSTRING, updatecheck);
|
sprintf(updatestring, UPDATE_ALERT_STRING, VERSIONSTRING, updatecheck);
|
||||||
|
@ -11097,7 +11191,62 @@ static boolean M_CheckMODVersion(void)
|
||||||
} else
|
} else
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
static void
|
||||||
|
Check_new_version_thread (int *id)
|
||||||
|
{
|
||||||
|
int hosting;
|
||||||
|
int okay;
|
||||||
|
|
||||||
|
okay = 0;
|
||||||
|
|
||||||
|
if (M_CheckMODVersion(*id))
|
||||||
|
{
|
||||||
|
I_lock_mutex(&ms_QueryId_mutex);
|
||||||
|
{
|
||||||
|
okay = ( *id == ms_QueryId );
|
||||||
|
}
|
||||||
|
I_unlock_mutex(ms_QueryId_mutex);
|
||||||
|
|
||||||
|
if (okay)
|
||||||
|
{
|
||||||
|
I_lock_mutex(&m_menu_mutex);
|
||||||
|
{
|
||||||
|
m_waiting_mode = M_WAITING_ROOMS;
|
||||||
|
hosting = ( currentMenu->prevMenu == &MP_ServerDef );
|
||||||
|
}
|
||||||
|
I_unlock_mutex(m_menu_mutex);
|
||||||
|
|
||||||
|
GetRoomsList(hosting, *id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
I_lock_mutex(&ms_QueryId_mutex);
|
||||||
|
{
|
||||||
|
okay = ( *id == ms_QueryId );
|
||||||
|
}
|
||||||
|
I_unlock_mutex(ms_QueryId_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (okay)
|
||||||
|
{
|
||||||
|
I_lock_mutex(&m_menu_mutex);
|
||||||
|
{
|
||||||
|
if (m_waiting_mode)
|
||||||
|
{
|
||||||
|
m_waiting_mode = M_NOT_WAITING;
|
||||||
|
MP_RoomMenu[0].text = "<Offline Mode>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
I_unlock_mutex(m_menu_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(id);
|
||||||
|
}
|
||||||
|
#endif/*HAVE_THREADS*/
|
||||||
|
#endif/*UPDATE_ALERT*/
|
||||||
|
|
||||||
static void M_ConnectMenu(INT32 choice)
|
static void M_ConnectMenu(INT32 choice)
|
||||||
{
|
{
|
||||||
|
@ -11133,11 +11282,14 @@ static void M_ConnectMenuModChecks(INT32 choice)
|
||||||
M_ConnectMenu(-1);
|
M_ConnectMenu(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static UINT32 roomIds[NUM_LIST_ROOMS];
|
UINT32 roomIds[NUM_LIST_ROOMS];
|
||||||
|
|
||||||
static void M_RoomMenu(INT32 choice)
|
static void M_RoomMenu(INT32 choice)
|
||||||
{
|
{
|
||||||
INT32 i;
|
INT32 i;
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
int *id;
|
||||||
|
#endif
|
||||||
|
|
||||||
(void)choice;
|
(void)choice;
|
||||||
|
|
||||||
|
@ -11150,34 +11302,47 @@ static void M_RoomMenu(INT32 choice)
|
||||||
if (rendermode == render_soft)
|
if (rendermode == render_soft)
|
||||||
I_FinishUpdate(); // page flip or blit buffer
|
I_FinishUpdate(); // page flip or blit buffer
|
||||||
|
|
||||||
if (GetRoomsList(currentMenu == &MP_ServerDef) < 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
#ifdef UPDATE_ALERT
|
|
||||||
if (!M_CheckMODVersion())
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i = 1; i < NUM_LIST_ROOMS+1; ++i)
|
for (i = 1; i < NUM_LIST_ROOMS+1; ++i)
|
||||||
MP_RoomMenu[i].status = IT_DISABLED;
|
MP_RoomMenu[i].status = IT_DISABLED;
|
||||||
memset(roomIds, 0, sizeof(roomIds));
|
memset(roomIds, 0, sizeof(roomIds));
|
||||||
|
|
||||||
for (i = 0; room_list[i].header.buffer[0]; i++)
|
|
||||||
{
|
|
||||||
if(*room_list[i].name != '\0')
|
|
||||||
{
|
|
||||||
MP_RoomMenu[i+1].text = room_list[i].name;
|
|
||||||
roomIds[i] = room_list[i].id;
|
|
||||||
MP_RoomMenu[i+1].status = IT_STRING|IT_CALL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MP_RoomDef.prevMenu = currentMenu;
|
MP_RoomDef.prevMenu = currentMenu;
|
||||||
M_SetupNextMenu(&MP_RoomDef);
|
M_SetupNextMenu(&MP_RoomDef);
|
||||||
|
|
||||||
|
#ifdef UPDATE_ALERT
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
m_waiting_mode = M_WAITING_VERSION;
|
||||||
|
MP_RoomMenu[0].text = "";
|
||||||
|
|
||||||
|
id = malloc(sizeof *id);
|
||||||
|
|
||||||
|
I_lock_mutex(&ms_QueryId_mutex);
|
||||||
|
{
|
||||||
|
*id = ms_QueryId;
|
||||||
|
}
|
||||||
|
I_unlock_mutex(ms_QueryId_mutex);
|
||||||
|
|
||||||
|
I_spawn_thread("check-new-version",
|
||||||
|
(I_thread_fn)Check_new_version_thread, id);
|
||||||
|
#else/*HAVE_THREADS*/
|
||||||
|
if (M_CheckMODVersion(0))
|
||||||
|
{
|
||||||
|
GetRoomsList(currentMenu->prevMenu == &MP_ServerDef, 0);
|
||||||
|
}
|
||||||
|
#endif/*HAVE_THREADS*/
|
||||||
|
#endif/*UPDATE_ALERT*/
|
||||||
}
|
}
|
||||||
|
|
||||||
static void M_ChooseRoom(INT32 choice)
|
static void M_ChooseRoom(INT32 choice)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
I_lock_mutex(&ms_QueryId_mutex);
|
||||||
|
{
|
||||||
|
ms_QueryId++;
|
||||||
|
}
|
||||||
|
I_unlock_mutex(ms_QueryId_mutex);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (choice == 0)
|
if (choice == 0)
|
||||||
ms_RoomId = -1;
|
ms_RoomId = -1;
|
||||||
else
|
else
|
||||||
|
|
23
src/m_menu.h
23
src/m_menu.h
|
@ -18,8 +18,10 @@
|
||||||
#include "doomstat.h" // for NUMGAMETYPES
|
#include "doomstat.h" // for NUMGAMETYPES
|
||||||
#include "d_event.h"
|
#include "d_event.h"
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
#include "r_skins.h" // for SKINNAMESIZE
|
|
||||||
#include "f_finale.h" // for ttmode_enum
|
#include "f_finale.h" // for ttmode_enum
|
||||||
|
#include "i_threads.h"
|
||||||
|
#include "mserv.h"
|
||||||
|
#include "r_things.h" // for SKINNAMESIZE
|
||||||
|
|
||||||
// Compatibility with old-style named NiGHTS replay files.
|
// Compatibility with old-style named NiGHTS replay files.
|
||||||
#define OLDNREPLAYNAME
|
#define OLDNREPLAYNAME
|
||||||
|
@ -226,6 +228,18 @@ typedef enum
|
||||||
} menumessagetype_t;
|
} menumessagetype_t;
|
||||||
void M_StartMessage(const char *string, void *routine, menumessagetype_t itemtype);
|
void M_StartMessage(const char *string, void *routine, menumessagetype_t itemtype);
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
M_NOT_WAITING,
|
||||||
|
|
||||||
|
M_WAITING_VERSION,
|
||||||
|
M_WAITING_ROOMS,
|
||||||
|
M_WAITING_SERVERS,
|
||||||
|
}
|
||||||
|
M_waiting_mode_t;
|
||||||
|
|
||||||
|
extern M_waiting_mode_t m_waiting_mode;
|
||||||
|
|
||||||
// Called by linux_x/i_video_xshm.c
|
// Called by linux_x/i_video_xshm.c
|
||||||
void M_QuitResponse(INT32 ch);
|
void M_QuitResponse(INT32 ch);
|
||||||
|
|
||||||
|
@ -316,6 +330,9 @@ typedef struct menuitem_s
|
||||||
UINT8 alphaKey;
|
UINT8 alphaKey;
|
||||||
} menuitem_t;
|
} menuitem_t;
|
||||||
|
|
||||||
|
extern menuitem_t MP_RoomMenu[];
|
||||||
|
extern UINT32 roomIds[NUM_LIST_ROOMS];
|
||||||
|
|
||||||
typedef struct menu_s
|
typedef struct menu_s
|
||||||
{
|
{
|
||||||
UINT32 menuid; // ID to encode menu type and hierarchy
|
UINT32 menuid; // ID to encode menu type and hierarchy
|
||||||
|
@ -335,6 +352,10 @@ void M_ClearMenus(boolean callexitmenufunc);
|
||||||
// Maybe this goes here????? Who knows.
|
// Maybe this goes here????? Who knows.
|
||||||
boolean M_MouseNeeded(void);
|
boolean M_MouseNeeded(void);
|
||||||
|
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
extern I_mutex m_menu_mutex;
|
||||||
|
#endif
|
||||||
|
|
||||||
extern menu_t *currentMenu;
|
extern menu_t *currentMenu;
|
||||||
|
|
||||||
extern menu_t MainDef;
|
extern menu_t MainDef;
|
||||||
|
|
1244
src/mserv.c
1244
src/mserv.c
File diff suppressed because it is too large
Load diff
35
src/mserv.h
35
src/mserv.h
|
@ -2,6 +2,7 @@
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||||
|
// Copyright (C) 2020 by James R.
|
||||||
//
|
//
|
||||||
// This program is free software distributed under the
|
// This program is free software distributed under the
|
||||||
// terms of the GNU General Public License, version 2.
|
// terms of the GNU General Public License, version 2.
|
||||||
|
@ -13,7 +14,7 @@
|
||||||
#ifndef _MSERV_H_
|
#ifndef _MSERV_H_
|
||||||
#define _MSERV_H_
|
#define _MSERV_H_
|
||||||
|
|
||||||
#define MASTERSERVERS21 // MasterServer v2.1
|
#include "i_threads.h"
|
||||||
|
|
||||||
// lowered from 32 due to menu changes
|
// lowered from 32 due to menu changes
|
||||||
#define NUM_LIST_ROOMS 16
|
#define NUM_LIST_ROOMS 16
|
||||||
|
@ -64,33 +65,47 @@ typedef struct
|
||||||
// ================================ GLOBALS ===============================
|
// ================================ GLOBALS ===============================
|
||||||
|
|
||||||
extern consvar_t cv_masterserver, cv_servername;
|
extern consvar_t cv_masterserver, cv_servername;
|
||||||
|
extern consvar_t cv_masterserver_update_rate;
|
||||||
|
extern consvar_t cv_masterserver_timeout;
|
||||||
|
extern consvar_t cv_masterserver_debug;
|
||||||
|
extern consvar_t cv_masterserver_token;
|
||||||
|
|
||||||
// < 0 to not connect (usually -1) (offline mode)
|
// < 0 to not connect (usually -1) (offline mode)
|
||||||
// == 0 to show all rooms, not a valid hosting room
|
// == 0 to show all rooms, not a valid hosting room
|
||||||
// anything else is whatever room the MS assigns to that number (online mode)
|
// anything else is whatever room the MS assigns to that number (online mode)
|
||||||
extern INT16 ms_RoomId;
|
extern INT16 ms_RoomId;
|
||||||
|
|
||||||
const char *GetMasterServerPort(void);
|
#ifdef HAVE_THREADS
|
||||||
const char *GetMasterServerIP(void);
|
extern int ms_QueryId;
|
||||||
|
extern I_mutex ms_QueryId_mutex;
|
||||||
|
|
||||||
void MSOpenUDPSocket(void);
|
extern msg_server_t *ms_ServerList;
|
||||||
void MSCloseUDPSocket(void);
|
extern I_mutex ms_ServerList_mutex;
|
||||||
|
#endif
|
||||||
void SendAskInfoViaMS(INT32 node, tic_t asktime);
|
|
||||||
|
|
||||||
void RegisterServer(void);
|
void RegisterServer(void);
|
||||||
void UnregisterServer(void);
|
void UnregisterServer(void);
|
||||||
|
|
||||||
void MasterClient_Ticker(void);
|
void MasterClient_Ticker(void);
|
||||||
|
|
||||||
const msg_server_t *GetShortServersList(INT32 room);
|
msg_server_t *GetShortServersList(INT32 room, int id);
|
||||||
INT32 GetRoomsList(boolean hosting);
|
INT32 GetRoomsList(boolean hosting, int id);
|
||||||
#ifdef UPDATE_ALERT
|
#ifdef UPDATE_ALERT
|
||||||
const char *GetMODVersion(void);
|
char *GetMODVersion(int id);
|
||||||
void GetMODVersion_Console(void);
|
void GetMODVersion_Console(void);
|
||||||
#endif
|
#endif
|
||||||
extern msg_rooms_t room_list[NUM_LIST_ROOMS+1];
|
extern msg_rooms_t room_list[NUM_LIST_ROOMS+1];
|
||||||
|
|
||||||
void AddMServCommands(void);
|
void AddMServCommands(void);
|
||||||
|
|
||||||
|
/* HTTP */
|
||||||
|
void HMS_set_api (char *api);
|
||||||
|
int HMS_fetch_rooms (int joining, int id);
|
||||||
|
int HMS_register (void);
|
||||||
|
int HMS_unlist (void);
|
||||||
|
int HMS_update (void);
|
||||||
|
void HMS_list_servers (void);
|
||||||
|
msg_server_t * HMS_fetch_servers (msg_server_t *list, int room, int id);
|
||||||
|
int HMS_compare_mod_version (char *buffer, size_t size_of_buffer);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -166,6 +166,7 @@ if(${SDL2_FOUND})
|
||||||
${PNG_LIBRARIES}
|
${PNG_LIBRARIES}
|
||||||
${ZLIB_LIBRARIES}
|
${ZLIB_LIBRARIES}
|
||||||
${OPENGL_LIBRARIES}
|
${OPENGL_LIBRARIES}
|
||||||
|
${CURL_LIBRARIES}
|
||||||
)
|
)
|
||||||
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
|
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
|
||||||
else()
|
else()
|
||||||
|
@ -178,6 +179,7 @@ if(${SDL2_FOUND})
|
||||||
${PNG_LIBRARIES}
|
${PNG_LIBRARIES}
|
||||||
${ZLIB_LIBRARIES}
|
${ZLIB_LIBRARIES}
|
||||||
${OPENGL_LIBRARIES}
|
${OPENGL_LIBRARIES}
|
||||||
|
${CURL_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
if(${CMAKE_SYSTEM} MATCHES Linux)
|
if(${CMAKE_SYSTEM} MATCHES Linux)
|
||||||
|
@ -259,6 +261,7 @@ if(${SDL2_FOUND})
|
||||||
${PNG_INCLUDE_DIRS}
|
${PNG_INCLUDE_DIRS}
|
||||||
${ZLIB_INCLUDE_DIRS}
|
${ZLIB_INCLUDE_DIRS}
|
||||||
${OPENGL_INCLUDE_DIRS}
|
${OPENGL_INCLUDE_DIRS}
|
||||||
|
${CURL_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
|
||||||
if((${SRB2_HAVE_MIXER}) OR (${SRB2_HAVE_MIXERX}))
|
if((${SRB2_HAVE_MIXER}) OR (${SRB2_HAVE_MIXERX}))
|
||||||
|
|
|
@ -88,6 +88,11 @@ else
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifndef NOTHREADS
|
||||||
|
OPTS+=-DHAVE_THREADS
|
||||||
|
OBJS+=$(OBJDIR)/i_threads.o
|
||||||
|
endif
|
||||||
|
|
||||||
ifdef SDL_TTF
|
ifdef SDL_TTF
|
||||||
OPTS+=-DHAVE_TTF
|
OPTS+=-DHAVE_TTF
|
||||||
SDL_LDFLAGS+=-lSDL2_ttf -lfreetype -lz
|
SDL_LDFLAGS+=-lSDL2_ttf -lfreetype -lz
|
||||||
|
|
|
@ -173,6 +173,7 @@ static char returnWadPath[256];
|
||||||
#include "../i_video.h"
|
#include "../i_video.h"
|
||||||
#include "../i_sound.h"
|
#include "../i_sound.h"
|
||||||
#include "../i_system.h"
|
#include "../i_system.h"
|
||||||
|
#include "../i_threads.h"
|
||||||
#include "../screen.h" //vid.WndParent
|
#include "../screen.h" //vid.WndParent
|
||||||
#include "../d_net.h"
|
#include "../d_net.h"
|
||||||
#include "../g_game.h"
|
#include "../g_game.h"
|
||||||
|
@ -2282,6 +2283,10 @@ INT32 I_StartupSystem(void)
|
||||||
SDL_version SDLlinked;
|
SDL_version SDLlinked;
|
||||||
SDL_VERSION(&SDLcompiled)
|
SDL_VERSION(&SDLcompiled)
|
||||||
SDL_GetVersion(&SDLlinked);
|
SDL_GetVersion(&SDLlinked);
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
I_start_threads();
|
||||||
|
I_AddExitFunc(I_stop_threads);
|
||||||
|
#endif
|
||||||
I_StartupConsole();
|
I_StartupConsole();
|
||||||
#ifdef NEWSIGNALHANDLER
|
#ifdef NEWSIGNALHANDLER
|
||||||
I_Fork();
|
I_Fork();
|
||||||
|
|
356
src/sdl/i_threads.c
Normal file
356
src/sdl/i_threads.c
Normal file
|
@ -0,0 +1,356 @@
|
||||||
|
// SONIC ROBO BLAST 2 KART
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Copyright (C) 2020 by James R.
|
||||||
|
//
|
||||||
|
// This program is free software distributed under the
|
||||||
|
// terms of the GNU General Public License, version 2.
|
||||||
|
// See the 'LICENSE' file for more details.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
/// \file i_threads.c
|
||||||
|
/// \brief Multithreading abstraction
|
||||||
|
|
||||||
|
#include "../doomdef.h"
|
||||||
|
#include "../i_threads.h"
|
||||||
|
|
||||||
|
#include <SDL.h>
|
||||||
|
|
||||||
|
typedef void * (*Create_fn)(void);
|
||||||
|
|
||||||
|
struct Link;
|
||||||
|
struct Thread;
|
||||||
|
|
||||||
|
typedef struct Link * Link;
|
||||||
|
typedef struct Thread * Thread;
|
||||||
|
|
||||||
|
struct Link
|
||||||
|
{
|
||||||
|
void * data;
|
||||||
|
Link next;
|
||||||
|
Link prev;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Thread
|
||||||
|
{
|
||||||
|
I_thread_fn entry;
|
||||||
|
void * userdata;
|
||||||
|
|
||||||
|
SDL_Thread * thread;
|
||||||
|
};
|
||||||
|
|
||||||
|
static Link i_thread_pool;
|
||||||
|
static Link i_mutex_pool;
|
||||||
|
static Link i_cond_pool;
|
||||||
|
|
||||||
|
static I_mutex i_thread_pool_mutex;
|
||||||
|
static I_mutex i_mutex_pool_mutex;
|
||||||
|
static I_mutex i_cond_pool_mutex;
|
||||||
|
|
||||||
|
static SDL_atomic_t i_threads_running = {1};
|
||||||
|
|
||||||
|
static Link
|
||||||
|
Insert_link (
|
||||||
|
Link * head,
|
||||||
|
Link link
|
||||||
|
){
|
||||||
|
link->prev = NULL;
|
||||||
|
link->next = (*head);
|
||||||
|
if ((*head))
|
||||||
|
(*head)->prev = link;
|
||||||
|
(*head) = link;
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
Free_link (
|
||||||
|
Link * head,
|
||||||
|
Link link
|
||||||
|
){
|
||||||
|
if (link->prev)
|
||||||
|
link->prev->next = link->next;
|
||||||
|
else
|
||||||
|
(*head) = link->next;
|
||||||
|
|
||||||
|
if (link->next)
|
||||||
|
link->next->prev = link->prev;
|
||||||
|
|
||||||
|
free(link->data);
|
||||||
|
free(link);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Link
|
||||||
|
New_link (void *data)
|
||||||
|
{
|
||||||
|
Link link;
|
||||||
|
|
||||||
|
link = malloc(sizeof *link);
|
||||||
|
|
||||||
|
if (! link)
|
||||||
|
abort();
|
||||||
|
|
||||||
|
link->data = data;
|
||||||
|
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *
|
||||||
|
Identity (
|
||||||
|
Link * pool_anchor,
|
||||||
|
I_mutex pool_mutex,
|
||||||
|
|
||||||
|
void ** anchor,
|
||||||
|
|
||||||
|
Create_fn create_fn
|
||||||
|
){
|
||||||
|
void * id;
|
||||||
|
|
||||||
|
id = SDL_AtomicGetPtr(anchor);
|
||||||
|
|
||||||
|
if (! id)
|
||||||
|
{
|
||||||
|
I_lock_mutex(&pool_mutex);
|
||||||
|
{
|
||||||
|
id = SDL_AtomicGetPtr(anchor);
|
||||||
|
|
||||||
|
if (! id)
|
||||||
|
{
|
||||||
|
id = (*create_fn)();
|
||||||
|
|
||||||
|
if (! id)
|
||||||
|
abort();
|
||||||
|
|
||||||
|
Insert_link(pool_anchor, New_link(id));
|
||||||
|
|
||||||
|
SDL_AtomicSetPtr(anchor, id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
I_unlock_mutex(pool_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
Worker (
|
||||||
|
Link link
|
||||||
|
){
|
||||||
|
Thread th;
|
||||||
|
|
||||||
|
th = link->data;
|
||||||
|
|
||||||
|
(*th->entry)(th->userdata);
|
||||||
|
|
||||||
|
if (SDL_AtomicGet(&i_threads_running))
|
||||||
|
{
|
||||||
|
I_lock_mutex(&i_thread_pool_mutex);
|
||||||
|
{
|
||||||
|
if (SDL_AtomicGet(&i_threads_running))
|
||||||
|
{
|
||||||
|
SDL_DetachThread(th->thread);
|
||||||
|
Free_link(&i_thread_pool, link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
I_unlock_mutex(i_thread_pool_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
I_spawn_thread (
|
||||||
|
const char * name,
|
||||||
|
I_thread_fn entry,
|
||||||
|
void * userdata
|
||||||
|
){
|
||||||
|
Link link;
|
||||||
|
Thread th;
|
||||||
|
|
||||||
|
th = malloc(sizeof *th);
|
||||||
|
|
||||||
|
if (! th)
|
||||||
|
abort();/* this is pretty GNU of me */
|
||||||
|
|
||||||
|
th->entry = entry;
|
||||||
|
th->userdata = userdata;
|
||||||
|
|
||||||
|
I_lock_mutex(&i_thread_pool_mutex);
|
||||||
|
{
|
||||||
|
link = Insert_link(&i_thread_pool, New_link(th));
|
||||||
|
|
||||||
|
if (SDL_AtomicGet(&i_threads_running))
|
||||||
|
{
|
||||||
|
th->thread = SDL_CreateThread(
|
||||||
|
(SDL_ThreadFunction)Worker,
|
||||||
|
name,
|
||||||
|
link
|
||||||
|
);
|
||||||
|
|
||||||
|
if (! th->thread)
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
I_unlock_mutex(i_thread_pool_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
I_thread_is_stopped (void)
|
||||||
|
{
|
||||||
|
return ( ! SDL_AtomicGet(&i_threads_running) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
I_start_threads (void)
|
||||||
|
{
|
||||||
|
i_thread_pool_mutex = SDL_CreateMutex();
|
||||||
|
i_mutex_pool_mutex = SDL_CreateMutex();
|
||||||
|
i_cond_pool_mutex = SDL_CreateMutex();
|
||||||
|
|
||||||
|
if (!(
|
||||||
|
i_thread_pool_mutex &&
|
||||||
|
i_mutex_pool_mutex &&
|
||||||
|
i_cond_pool_mutex
|
||||||
|
)){
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
I_stop_threads (void)
|
||||||
|
{
|
||||||
|
Link link;
|
||||||
|
Link next;
|
||||||
|
|
||||||
|
Thread th;
|
||||||
|
SDL_mutex * mutex;
|
||||||
|
SDL_cond * cond;
|
||||||
|
|
||||||
|
if (i_threads_running.value)
|
||||||
|
{
|
||||||
|
/* rely on the good will of thread-san */
|
||||||
|
SDL_AtomicSet(&i_threads_running, 0);
|
||||||
|
|
||||||
|
I_lock_mutex(&i_thread_pool_mutex);
|
||||||
|
{
|
||||||
|
for (
|
||||||
|
link = i_thread_pool;
|
||||||
|
link;
|
||||||
|
link = next
|
||||||
|
){
|
||||||
|
next = link->next;
|
||||||
|
th = link->data;
|
||||||
|
|
||||||
|
SDL_WaitThread(th->thread, NULL);
|
||||||
|
|
||||||
|
free(th);
|
||||||
|
free(link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
I_unlock_mutex(i_thread_pool_mutex);
|
||||||
|
|
||||||
|
for (
|
||||||
|
link = i_mutex_pool;
|
||||||
|
link;
|
||||||
|
link = next
|
||||||
|
){
|
||||||
|
next = link->next;
|
||||||
|
mutex = link->data;
|
||||||
|
|
||||||
|
SDL_DestroyMutex(mutex);
|
||||||
|
|
||||||
|
free(link);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (
|
||||||
|
link = i_cond_pool;
|
||||||
|
link;
|
||||||
|
link = next
|
||||||
|
){
|
||||||
|
next = link->next;
|
||||||
|
cond = link->data;
|
||||||
|
|
||||||
|
SDL_DestroyCond(cond);
|
||||||
|
|
||||||
|
free(link);
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_DestroyMutex(i_thread_pool_mutex);
|
||||||
|
SDL_DestroyMutex(i_mutex_pool_mutex);
|
||||||
|
SDL_DestroyMutex(i_cond_pool_mutex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
I_lock_mutex (
|
||||||
|
I_mutex * anchor
|
||||||
|
){
|
||||||
|
SDL_mutex * mutex;
|
||||||
|
|
||||||
|
mutex = Identity(
|
||||||
|
&i_mutex_pool,
|
||||||
|
i_mutex_pool_mutex,
|
||||||
|
anchor,
|
||||||
|
(Create_fn)SDL_CreateMutex
|
||||||
|
);
|
||||||
|
|
||||||
|
if (SDL_LockMutex(mutex) == -1)
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
I_unlock_mutex (
|
||||||
|
I_mutex id
|
||||||
|
){
|
||||||
|
if (SDL_UnlockMutex(id) == -1)
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
I_hold_cond (
|
||||||
|
I_cond * cond_anchor,
|
||||||
|
I_mutex mutex_id
|
||||||
|
){
|
||||||
|
SDL_cond * cond;
|
||||||
|
|
||||||
|
cond = Identity(
|
||||||
|
&i_cond_pool,
|
||||||
|
i_cond_pool_mutex,
|
||||||
|
cond_anchor,
|
||||||
|
(Create_fn)SDL_CreateCond
|
||||||
|
);
|
||||||
|
|
||||||
|
if (SDL_CondWait(cond, mutex_id) == -1)
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
I_wake_one_cond (
|
||||||
|
I_cond * anchor
|
||||||
|
){
|
||||||
|
SDL_cond * cond;
|
||||||
|
|
||||||
|
cond = Identity(
|
||||||
|
&i_cond_pool,
|
||||||
|
i_cond_pool_mutex,
|
||||||
|
anchor,
|
||||||
|
(Create_fn)SDL_CreateCond
|
||||||
|
);
|
||||||
|
|
||||||
|
if (SDL_CondSignal(cond) == -1)
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
I_wake_all_cond (
|
||||||
|
I_cond * anchor
|
||||||
|
){
|
||||||
|
SDL_cond * cond;
|
||||||
|
|
||||||
|
cond = Identity(
|
||||||
|
&i_cond_pool,
|
||||||
|
i_cond_pool_mutex,
|
||||||
|
anchor,
|
||||||
|
(Create_fn)SDL_CreateCond
|
||||||
|
);
|
||||||
|
|
||||||
|
if (SDL_CondBroadcast(cond) == -1)
|
||||||
|
abort();
|
||||||
|
}
|
|
@ -154,3 +154,12 @@ else
|
||||||
LDFLAGS+=-L../libs/miniupnpc/mingw32
|
LDFLAGS+=-L../libs/miniupnpc/mingw32
|
||||||
endif #MINGW64
|
endif #MINGW64
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifndef NOCURL
|
||||||
|
CURL_CFLAGS+=-I../libs/curl/include
|
||||||
|
ifdef MINGW64
|
||||||
|
CURL_LDFLAGS+=-L../libs/curl/lib64 -lcurl
|
||||||
|
else
|
||||||
|
CURL_LDFLAGS+=-L../libs/curl/lib32 -lcurl
|
||||||
|
endif #MINGW64
|
||||||
|
endif
|
Loading…
Reference in a new issue