mirror of
https://github.com/open-goal/jak-project
synced 2026-08-06 09:54:10 -04:00
5d5e35fb9b
## Problem Windows builds break with a current local toolchain (Scoop LLVM 22.1.8, CMake 4.4.0, VS 2026), in two independent ways: 1. The build stops at curl's deliberate guard: `#error "no non-blocking method was found/used/set"` in `third-party/curl/lib/nonblock.c`. 2. From the second configure onward, `cmake --build` re-runs CMake in an endless loop (observed 42 consecutive reconfigure cycles in a single build). Likely the same mechanism behind the "endlessly building" VS 2026 note in `docs/setup/dev/vs.md`. ## Root cause 1. `third-party/curl/CMake/CurlTests.c` passes `int *` to `ioctlsocket()`, whose third parameter is `u_long *`. Clang 22 promotes `-Wincompatible-pointer-types` to a hard error in C, so the `HAVE_IOCTLSOCKET_FIONBIO` try_compile silently fails and `curl_config.h` never defines it. Upstream CI does not see this because the windows-2022 runner image ships an older LLVM. GCC 14 promotes the same warning to a hard error, which is very likely the `CurlTests.c.obj` failure reported from MSYS2 in open-goal/jak-project#3551. Upstream curl hit the identical problem with GCC 14 and fixed the probe in curl 8.8.0 (curl/curl#13578). 2. The root CMakeLists copies the build tree's `compile_commands.json` into `<src>/build/` for clangd using `configure_file()`, which registers its input as a configure dependency. CMake rewrites `compile_commands.json` late in every generation, after `CTestTestfile.cmake` and `cmake_install.cmake` (outputs of the same Ninja regen rule), so once the dependency is registered the rule is deterministically dirty and every `ninja` invocation re-runs CMake. A pristine first configure is safe (the file does not exist yet, so the `if(EXISTS ...)` guard skips the copy), which is why the loop looks machine- or IDE-specific. ## Fix 1. Per review, re-vendor `third-party/curl` at the `curl-8_21_0` tag (previously `curl-8_3_0`), which carries the upstream probe fix plus two years of upstream development; `vendor.yaml` updated to match. Adjustments the version jump forced: - curl 8.15 removed the native macOS Secure Transport backend (`CURL_USE_SECTRANSP`), so macOS now builds curl against OpenSSL like Linux. The two macOS workflows install Homebrew `openssl@3` and export `OPENSSL_ROOT_DIR` (keg-only), and the macOS setup docs gained the same two lines. - `CURL_BROTLI` / `CURL_ZSTD` switched to AUTO-detection in curl 8.10; pinned OFF to keep the previous no-compression behavior and avoid silently linking whatever the CI images happen to have. - curl's new top-level `BUILD_EXAMPLES` cache option (default ON) leaked into discord-rpc's identically named option and broke configure at a nonexistent `examples/send-presence` directory; pinned OFF ahead of the third-party subdirectories. The diff is dominated by the mechanical tag-tree swap under `third-party/curl` (linguist-vendored, collapsed in review). The hand-written changes are `CMakeLists.txt`, the two macOS workflows, `docs/setup/system/macos.md`, and `vendor.yaml`. 2. Swap `configure_file()` for `file(COPY ...)`: the same clangd copy with no configure dependency registered. (`file(COPY_FILE ... ONLY_IF_DIFFERENT)` would be cleaner still but requires CMake 3.21, above the declared `cmake_minimum_required(VERSION 3.10)`.) ## Test plan - [x] Fresh `cmake --preset Release-windows-clang` (LLVM 22, no cache seeding) completes and logs `Enabled SSL backends: Schannel`; the FIONBIO probe passes without the previous `#error` - [x] Full Windows Release build from scratch in the branch worktree (all 1422 targets) - [x] goalc-test suite: 1509 passed, 0 failed - [x] Second consecutive configure with `compile_commands.json` present: the regen rule in `build.ninja` has no `compile_commands.json` input; `<src>/build/compile_commands.json` is still refreshed for clangd - [x] Repeated `ninja` invocations after a full build no longer re-run CMake - [x] macOS Intel and ARM CI green (first exercise of the OpenSSL backend switch) --- I work off a self-hosted forge, so this GitHub account is quiet; the configure logs and ninja dirty-node traces from the investigation are available if anyone wants the raw data. (AI-assisted)
537 lines
16 KiB
C
Vendored
Generated
537 lines
16 KiB
C
Vendored
Generated
/***************************************************************************
|
|
* _ _ ____ _
|
|
* Project ___| | | | _ \| |
|
|
* / __| | | | |_) | |
|
|
* | (__| |_| | _ <| |___
|
|
* \___|\___/|_| \_\_____|
|
|
*
|
|
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
|
*
|
|
* This software is licensed as described in the file COPYING, which
|
|
* you should have received as part of this distribution. The terms
|
|
* are also available at https://curl.se/docs/copyright.html.
|
|
*
|
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
* copies of the Software, and permit persons to whom the Software is
|
|
* furnished to do so, under the terms of the COPYING file.
|
|
*
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
* KIND, either express or implied.
|
|
*
|
|
* SPDX-License-Identifier: curl
|
|
*
|
|
***************************************************************************/
|
|
#include "curl_setup.h"
|
|
|
|
#include "protocol.h"
|
|
#include "strcase.h"
|
|
|
|
#include "dict.h"
|
|
#include "file.h"
|
|
#include "ftp.h"
|
|
#include "gopher.h"
|
|
#include "http.h"
|
|
#include "imap.h"
|
|
#include "curl_ldap.h"
|
|
#include "mqtt.h"
|
|
#include "pop3.h"
|
|
#include "rtsp.h"
|
|
#include "smb.h"
|
|
#include "smtp.h"
|
|
#include "telnet.h"
|
|
#include "tftp.h"
|
|
#include "ws.h"
|
|
#include "vssh/ssh.h"
|
|
|
|
|
|
/* All URI schemes known to libcurl, but not necessarily implemented
|
|
* by protocol handlers. */
|
|
const struct Curl_scheme Curl_scheme_dict = {
|
|
"dict", /* scheme */
|
|
#ifdef CURL_DISABLE_DICT
|
|
ZERO_NULL,
|
|
#else
|
|
&Curl_protocol_dict,
|
|
#endif
|
|
CURLPROTO_DICT, /* protocol */
|
|
CURLPROTO_DICT, /* family */
|
|
PROTOPT_NONE | PROTOPT_NOURLQUERY, /* flags */
|
|
PORT_DICT, /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_file = {
|
|
"file", /* scheme */
|
|
#ifdef CURL_DISABLE_FILE
|
|
ZERO_NULL,
|
|
#else
|
|
&Curl_protocol_file,
|
|
#endif
|
|
CURLPROTO_FILE, /* protocol */
|
|
CURLPROTO_FILE, /* family */
|
|
PROTOPT_NONETWORK | PROTOPT_NOURLQUERY, /* flags */
|
|
0 /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_ftp = {
|
|
"ftp", /* scheme */
|
|
#ifdef CURL_DISABLE_FTP
|
|
ZERO_NULL,
|
|
#else
|
|
&Curl_protocol_ftp,
|
|
#endif
|
|
CURLPROTO_FTP, /* protocol */
|
|
CURLPROTO_FTP, /* family */
|
|
PROTOPT_DUAL | PROTOPT_CLOSEACTION | PROTOPT_NEEDSPWD |
|
|
PROTOPT_NOURLQUERY | PROTOPT_PROXY_AS_HTTP |
|
|
PROTOPT_WILDCARD | PROTOPT_SSL_REUSE |
|
|
PROTOPT_CONN_REUSE, /* flags */
|
|
PORT_FTP, /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_ftps = {
|
|
"ftps", /* scheme */
|
|
#if defined(CURL_DISABLE_FTP) || !defined(USE_SSL)
|
|
ZERO_NULL,
|
|
#else
|
|
&Curl_protocol_ftp,
|
|
#endif
|
|
CURLPROTO_FTPS, /* protocol */
|
|
CURLPROTO_FTP, /* family */
|
|
PROTOPT_SSL | PROTOPT_DUAL | PROTOPT_CLOSEACTION |
|
|
PROTOPT_NEEDSPWD | PROTOPT_NOURLQUERY | PROTOPT_WILDCARD |
|
|
PROTOPT_CONN_REUSE, /* flags */
|
|
PORT_FTPS, /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_gopher = {
|
|
"gopher", /* scheme */
|
|
#ifdef CURL_DISABLE_GOPHER
|
|
ZERO_NULL,
|
|
#else
|
|
&Curl_protocol_gopher,
|
|
#endif
|
|
CURLPROTO_GOPHER, /* protocol */
|
|
CURLPROTO_GOPHER, /* family */
|
|
PROTOPT_NONE, /* flags */
|
|
PORT_GOPHER, /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_gophers = {
|
|
"gophers", /* scheme */
|
|
#if defined(CURL_DISABLE_GOPHER) || !defined(USE_SSL)
|
|
ZERO_NULL,
|
|
#else
|
|
&Curl_protocol_gophers,
|
|
#endif
|
|
CURLPROTO_GOPHERS, /* protocol */
|
|
CURLPROTO_GOPHER, /* family */
|
|
PROTOPT_SSL, /* flags */
|
|
PORT_GOPHER, /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_http = {
|
|
"http", /* scheme */
|
|
#ifdef CURL_DISABLE_HTTP
|
|
ZERO_NULL,
|
|
#else
|
|
&Curl_protocol_http,
|
|
#endif
|
|
CURLPROTO_HTTP, /* protocol */
|
|
CURLPROTO_HTTP, /* family */
|
|
PROTOPT_CREDSPERREQUEST | /* flags */
|
|
PROTOPT_USERPWDCTRL | PROTOPT_CONN_REUSE,
|
|
PORT_HTTP, /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_https = {
|
|
"https", /* scheme */
|
|
#if defined(CURL_DISABLE_HTTP) || !defined(USE_SSL)
|
|
ZERO_NULL,
|
|
#else
|
|
&Curl_protocol_http,
|
|
#endif
|
|
CURLPROTO_HTTPS, /* protocol */
|
|
CURLPROTO_HTTP, /* family */
|
|
PROTOPT_SSL | PROTOPT_CREDSPERREQUEST | PROTOPT_ALPN | /* flags */
|
|
PROTOPT_USERPWDCTRL | PROTOPT_CONN_REUSE |
|
|
PROTOPT_HTTP_PROXY_TUNNEL,
|
|
PORT_HTTPS, /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_imap = {
|
|
"imap", /* scheme */
|
|
#ifdef CURL_DISABLE_IMAP
|
|
ZERO_NULL,
|
|
#else
|
|
&Curl_protocol_imap,
|
|
#endif
|
|
CURLPROTO_IMAP, /* protocol */
|
|
CURLPROTO_IMAP, /* family */
|
|
PROTOPT_CLOSEACTION | /* flags */
|
|
PROTOPT_URLOPTIONS | PROTOPT_SSL_REUSE |
|
|
PROTOPT_CONN_REUSE,
|
|
PORT_IMAP, /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_imaps = {
|
|
"imaps", /* scheme */
|
|
#if defined(CURL_DISABLE_IMAP) || !defined(USE_SSL)
|
|
ZERO_NULL,
|
|
#else
|
|
&Curl_protocol_imap,
|
|
#endif
|
|
CURLPROTO_IMAPS, /* protocol */
|
|
CURLPROTO_IMAP, /* family */
|
|
PROTOPT_CLOSEACTION | PROTOPT_SSL | /* flags */
|
|
PROTOPT_URLOPTIONS | PROTOPT_CONN_REUSE,
|
|
PORT_IMAPS, /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_ldap = {
|
|
"ldap", /* scheme */
|
|
#ifdef CURL_DISABLE_LDAP
|
|
ZERO_NULL,
|
|
#else
|
|
&Curl_protocol_ldap,
|
|
#endif
|
|
CURLPROTO_LDAP, /* protocol */
|
|
CURLPROTO_LDAP, /* family */
|
|
PROTOPT_SSL_REUSE, /* flags */
|
|
PORT_LDAP, /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_ldaps = {
|
|
"ldaps", /* scheme */
|
|
#if defined(CURL_DISABLE_LDAP) || !defined(HAVE_LDAP_SSL)
|
|
ZERO_NULL,
|
|
#else
|
|
&Curl_protocol_ldap,
|
|
#endif
|
|
CURLPROTO_LDAPS, /* protocol */
|
|
CURLPROTO_LDAP, /* family */
|
|
PROTOPT_SSL, /* flags */
|
|
PORT_LDAPS, /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_mqtt = {
|
|
"mqtt", /* scheme */
|
|
#ifdef CURL_DISABLE_MQTT
|
|
ZERO_NULL,
|
|
#else
|
|
&Curl_protocol_mqtt,
|
|
#endif
|
|
CURLPROTO_MQTT, /* protocol */
|
|
CURLPROTO_MQTT, /* family */
|
|
PROTOPT_NONE, /* flags */
|
|
PORT_MQTT, /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_mqtts = {
|
|
"mqtts", /* scheme */
|
|
#if defined(CURL_DISABLE_MQTT) || !defined(USE_SSL)
|
|
ZERO_NULL,
|
|
#else
|
|
&Curl_protocol_mqtts,
|
|
#endif
|
|
CURLPROTO_MQTTS, /* protocol */
|
|
CURLPROTO_MQTT, /* family */
|
|
PROTOPT_SSL, /* flags */
|
|
PORT_MQTTS, /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_pop3 = {
|
|
"pop3", /* scheme */
|
|
#ifdef CURL_DISABLE_POP3
|
|
ZERO_NULL,
|
|
#else
|
|
&Curl_protocol_pop3,
|
|
#endif
|
|
CURLPROTO_POP3, /* protocol */
|
|
CURLPROTO_POP3, /* family */
|
|
PROTOPT_CLOSEACTION | PROTOPT_NOURLQUERY | /* flags */
|
|
PROTOPT_URLOPTIONS | PROTOPT_SSL_REUSE | PROTOPT_CONN_REUSE,
|
|
PORT_POP3, /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_pop3s = {
|
|
"pop3s", /* scheme */
|
|
#if defined(CURL_DISABLE_POP3) || !defined(USE_SSL)
|
|
ZERO_NULL,
|
|
#else
|
|
&Curl_protocol_pop3,
|
|
#endif
|
|
CURLPROTO_POP3S, /* protocol */
|
|
CURLPROTO_POP3, /* family */
|
|
PROTOPT_CLOSEACTION | PROTOPT_SSL | /* flags */
|
|
PROTOPT_NOURLQUERY | PROTOPT_URLOPTIONS | PROTOPT_CONN_REUSE,
|
|
PORT_POP3S, /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_rtsp = {
|
|
"rtsp", /* scheme */
|
|
#ifdef CURL_DISABLE_RTSP
|
|
ZERO_NULL,
|
|
#else
|
|
&Curl_protocol_rtsp,
|
|
#endif
|
|
CURLPROTO_RTSP, /* protocol */
|
|
CURLPROTO_RTSP, /* family */
|
|
PROTOPT_CONN_REUSE, /* flags */
|
|
PORT_RTSP, /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_sftp = {
|
|
"sftp", /* scheme */
|
|
#ifndef USE_SSH
|
|
NULL,
|
|
#else
|
|
&Curl_protocol_sftp,
|
|
#endif
|
|
CURLPROTO_SFTP, /* protocol */
|
|
CURLPROTO_SFTP, /* family */
|
|
PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION | /* flags */
|
|
PROTOPT_NOURLQUERY | PROTOPT_CONN_REUSE,
|
|
PORT_SSH /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_scp = {
|
|
"scp", /* scheme */
|
|
#ifndef USE_SSH
|
|
NULL,
|
|
#else
|
|
&Curl_protocol_scp,
|
|
#endif
|
|
CURLPROTO_SCP, /* protocol */
|
|
CURLPROTO_SCP, /* family */
|
|
PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION | /* flags */
|
|
PROTOPT_NOURLQUERY | PROTOPT_CONN_REUSE,
|
|
PORT_SSH, /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_smb = {
|
|
"smb", /* scheme */
|
|
#if defined(CURL_ENABLE_SMB) && defined(USE_CURL_NTLM_CORE)
|
|
&Curl_protocol_smb,
|
|
#else
|
|
ZERO_NULL,
|
|
#endif
|
|
CURLPROTO_SMB, /* protocol */
|
|
CURLPROTO_SMB, /* family */
|
|
PROTOPT_NONE, /* flags */
|
|
PORT_SMB, /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_smbs = {
|
|
"smbs", /* scheme */
|
|
#if defined(CURL_ENABLE_SMB) && defined(USE_CURL_NTLM_CORE) && defined(USE_SSL)
|
|
&Curl_protocol_smb,
|
|
#else
|
|
ZERO_NULL,
|
|
#endif
|
|
CURLPROTO_SMBS, /* protocol */
|
|
CURLPROTO_SMB, /* family */
|
|
PROTOPT_SSL, /* flags */
|
|
PORT_SMBS, /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_smtp = {
|
|
"smtp", /* scheme */
|
|
#ifdef CURL_DISABLE_SMTP
|
|
ZERO_NULL,
|
|
#else
|
|
&Curl_protocol_smtp,
|
|
#endif
|
|
CURLPROTO_SMTP, /* protocol */
|
|
CURLPROTO_SMTP, /* family */
|
|
PROTOPT_CLOSEACTION | PROTOPT_NOURLQUERY | /* flags */
|
|
PROTOPT_URLOPTIONS | PROTOPT_SSL_REUSE | PROTOPT_CONN_REUSE,
|
|
PORT_SMTP, /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_smtps = {
|
|
"smtps", /* scheme */
|
|
#if defined(CURL_DISABLE_SMTP) || !defined(USE_SSL)
|
|
ZERO_NULL,
|
|
#else
|
|
&Curl_protocol_smtp,
|
|
#endif
|
|
CURLPROTO_SMTPS, /* protocol */
|
|
CURLPROTO_SMTP, /* family */
|
|
PROTOPT_CLOSEACTION | PROTOPT_SSL | /* flags */
|
|
PROTOPT_NOURLQUERY | PROTOPT_URLOPTIONS | PROTOPT_CONN_REUSE,
|
|
PORT_SMTPS, /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_socks = {
|
|
"socks", /* scheme */
|
|
ZERO_NULL,
|
|
CURLPROTO_SOCKS, /* protocol */
|
|
CURLPROTO_SOCKS, /* family */
|
|
PROTOPT_NO_TRANSFER, /* flags */
|
|
PORT_SOCKS, /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_socks4 = {
|
|
"socks4", /* scheme */
|
|
ZERO_NULL,
|
|
CURLPROTO_SOCKS, /* protocol */
|
|
CURLPROTO_SOCKS, /* family */
|
|
PROTOPT_NO_TRANSFER, /* flags */
|
|
PORT_SOCKS, /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_socks4a = {
|
|
"socks4a", /* scheme */
|
|
ZERO_NULL,
|
|
CURLPROTO_SOCKS, /* protocol */
|
|
CURLPROTO_SOCKS, /* family */
|
|
PROTOPT_NO_TRANSFER, /* flags */
|
|
PORT_SOCKS, /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_socks5 = {
|
|
"socks5", /* scheme */
|
|
ZERO_NULL,
|
|
CURLPROTO_SOCKS, /* protocol */
|
|
CURLPROTO_SOCKS, /* family */
|
|
PROTOPT_NO_TRANSFER, /* flags */
|
|
PORT_SOCKS, /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_socks5h = {
|
|
"socks5h", /* scheme */
|
|
ZERO_NULL,
|
|
CURLPROTO_SOCKS, /* protocol */
|
|
CURLPROTO_SOCKS, /* family */
|
|
PROTOPT_NO_TRANSFER, /* flags */
|
|
PORT_SOCKS, /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_telnet = {
|
|
"telnet", /* scheme */
|
|
#ifdef CURL_DISABLE_TELNET
|
|
ZERO_NULL,
|
|
#else
|
|
&Curl_protocol_telnet,
|
|
#endif
|
|
CURLPROTO_TELNET, /* protocol */
|
|
CURLPROTO_TELNET, /* family */
|
|
PROTOPT_NONE | PROTOPT_NOURLQUERY, /* flags */
|
|
PORT_TELNET, /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_tftp = {
|
|
"tftp", /* scheme */
|
|
#ifdef CURL_DISABLE_TFTP
|
|
ZERO_NULL,
|
|
#else
|
|
&Curl_protocol_tftp,
|
|
#endif
|
|
CURLPROTO_TFTP, /* protocol */
|
|
CURLPROTO_TFTP, /* family */
|
|
PROTOPT_NOTCPPROXY | PROTOPT_NOURLQUERY, /* flags */
|
|
PORT_TFTP, /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_ws = {
|
|
"ws", /* scheme */
|
|
#if defined(CURL_DISABLE_WEBSOCKETS) || defined(CURL_DISABLE_HTTP)
|
|
ZERO_NULL,
|
|
#else
|
|
&Curl_protocol_ws,
|
|
#endif
|
|
CURLPROTO_WS, /* protocol */
|
|
CURLPROTO_HTTP, /* family */
|
|
PROTOPT_CREDSPERREQUEST | /* flags */
|
|
PROTOPT_USERPWDCTRL | PROTOPT_HTTP_PROXY_TUNNEL,
|
|
PORT_HTTP /* defport */
|
|
};
|
|
|
|
const struct Curl_scheme Curl_scheme_wss = {
|
|
"wss", /* scheme */
|
|
#if defined(CURL_DISABLE_WEBSOCKETS) || defined(CURL_DISABLE_HTTP) || \
|
|
!defined(USE_SSL)
|
|
ZERO_NULL,
|
|
#else
|
|
&Curl_protocol_ws,
|
|
#endif
|
|
CURLPROTO_WSS, /* protocol */
|
|
CURLPROTO_HTTP, /* family */
|
|
PROTOPT_SSL | PROTOPT_CREDSPERREQUEST | /* flags */
|
|
PROTOPT_USERPWDCTRL | PROTOPT_HTTP_PROXY_TUNNEL,
|
|
PORT_HTTPS /* defport */
|
|
};
|
|
|
|
/* Returns a struct scheme pointer if the name is a known scheme. Check the
|
|
->run struct field for non-NULL to figure out if an implementation is
|
|
present. */
|
|
const struct Curl_scheme *Curl_getn_scheme(const char *scheme, size_t len)
|
|
{
|
|
/* table generated by schemetable.c:
|
|
1. gcc schemetable.c && ./a.out
|
|
2. check how small the table gets
|
|
3. tweak the hash algorithm, then rerun from 1
|
|
4. when the table is good enough
|
|
5. copy the table into this source code
|
|
6. make sure this function uses the same hash function that worked for
|
|
schemetable.c
|
|
*/
|
|
static const struct Curl_scheme * const all_schemes[59] = { NULL,
|
|
&Curl_scheme_pop3, NULL,
|
|
&Curl_scheme_smtps,
|
|
&Curl_scheme_socks,
|
|
&Curl_scheme_socks4,
|
|
&Curl_scheme_socks5, NULL, NULL,
|
|
&Curl_scheme_gophers,
|
|
&Curl_scheme_ws,
|
|
&Curl_scheme_sftp,
|
|
&Curl_scheme_socks4a,
|
|
&Curl_scheme_scp,
|
|
&Curl_scheme_rtsp,
|
|
&Curl_scheme_dict, NULL, NULL,
|
|
&Curl_scheme_gopher, NULL, NULL, NULL,
|
|
&Curl_scheme_wss, NULL,
|
|
&Curl_scheme_smb, NULL,
|
|
&Curl_scheme_ldap,
|
|
&Curl_scheme_ldaps,
|
|
&Curl_scheme_imap, NULL, NULL, NULL,
|
|
&Curl_scheme_imaps,
|
|
&Curl_scheme_https,
|
|
&Curl_scheme_tftp,
|
|
&Curl_scheme_telnet, NULL, NULL, NULL,
|
|
&Curl_scheme_file,
|
|
&Curl_scheme_smtp, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
&Curl_scheme_ftp,
|
|
&Curl_scheme_mqtt, NULL,
|
|
&Curl_scheme_socks5h,
|
|
&Curl_scheme_http,
|
|
&Curl_scheme_pop3s, NULL,
|
|
&Curl_scheme_mqtts, NULL,
|
|
&Curl_scheme_smbs,
|
|
&Curl_scheme_ftps,
|
|
};
|
|
|
|
if(len && (len <= 7)) {
|
|
const char *s = scheme;
|
|
size_t l = len;
|
|
const struct Curl_scheme *h;
|
|
unsigned int c = 443;
|
|
while(l) {
|
|
c <<= 5;
|
|
c += (unsigned int)Curl_raw_tolower(*s);
|
|
s++;
|
|
l--;
|
|
}
|
|
|
|
h = all_schemes[c % 59];
|
|
if(h && curl_strnequal(scheme, h->name, len) && !h->name[len])
|
|
return h;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
const struct Curl_scheme *Curl_get_scheme(const char *scheme)
|
|
{
|
|
return Curl_getn_scheme(scheme, strlen(scheme));
|
|
}
|