From 91b1d3e109b84e311b38e0448b359b3635526824 Mon Sep 17 00:00:00 2001 From: Scott Prive Date: Tue, 16 Jul 2024 00:25:41 -0400 Subject: [PATCH 1/3] simpler example + execute cmd + link --- README.md | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 492c6e3..98e924a 100644 --- a/README.md +++ b/README.md @@ -53,35 +53,27 @@ Current Status * Mac OS * passed go1 (Mac OS X 10.7.3, curl 7.21.4) +NOTE: Above information is outdated ("help wanted") + Sample Program -------------- +Following comes from [examples/https.go](./examples/https.go) +Simply type `go run ./examples/https.go` to execute. ```go package main import ( - "fmt" - curl "github.com/andelf/go-curl" + curl "github.com/andelf/go-curl" ) func main() { - easy := curl.EasyInit() - defer easy.Cleanup() - - easy.Setopt(curl.OPT_URL, "https://www.baidu.com/") - - // OPTIONAL - make a callback function - fooTest := func (buf []byte, userdata interface{}) bool { - println("DEBUG: size=>", len(buf)) - println("DEBUG: content=>", string(buf)) - return true - } - - easy.Setopt(curl.OPT_WRITEFUNCTION, fooTest) - - if err := easy.Perform(); err != nil { - fmt.Printf("ERROR: %v\n", err) - } + easy := curl.EasyInit() + defer easy.Cleanup() + if easy != nil { + easy.Setopt(curl.OPT_URL, "https://baidu.com/") + easy.Perform() + } } ``` From c6f9fe374f5edeebebe1f65a8a0cddf786aea62d Mon Sep 17 00:00:00 2001 From: Scott Prive Date: Tue, 16 Jul 2024 00:28:48 -0400 Subject: [PATCH 2/3] lots of cleanup + borrowed @Laeri's draft fixes --- compat.h | 322 +++++++++++++++++++++++++--------------------- misc/compatgen.py | 82 ++++++++++-- 2 files changed, 250 insertions(+), 154 deletions(-) diff --git a/compat.h b/compat.h index 4552b52..0e21bf6 100644 --- a/compat.h +++ b/compat.h @@ -4,6 +4,127 @@ +#if (LIBCURL_VERSION_MINOR == 8 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 8 +#define CURLE_ECH_REQUIRED -1 +#if (LIBCURL_VERSION_MINOR == 7 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 7 +#if (LIBCURL_VERSION_MINOR == 7 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 7 +#define CURLINFO_USED_PROXY 0 +#if (LIBCURL_VERSION_MINOR == 6 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 6 +#define CURLE_TOO_LARGE -1 +#define CURLINFO_QUEUE_TIME_T 0 +#if (LIBCURL_VERSION_MINOR == 5 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 5 +#if (LIBCURL_VERSION_MINOR == 4 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 4 +#if (LIBCURL_VERSION_MINOR == 3 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 3 +#if (LIBCURL_VERSION_MINOR == 2 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 2 +#if (LIBCURL_VERSION_MINOR == 2 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 2 +#define CURLOPT_MAIL_RCPT_ALLLOWFAILS 0 +#define CURLINFO_XFER_ID 0 +#define CURLINFO_CONN_ID 0 +#if (LIBCURL_VERSION_MINOR == 1 && LIBCURL_VERSION_PATCH < 2) || LIBCURL_VERSION_MINOR < 1 +#if (LIBCURL_VERSION_MINOR == 1 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 1 +#if (LIBCURL_VERSION_MINOR == 1 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 1 +#if (LIBCURL_VERSION_MINOR == 0 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 0 +#if (LIBCURL_VERSION_MINOR == 0 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 0 +#if (LIBCURL_VERSION_MINOR == 88 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 88 +#if (LIBCURL_VERSION_MINOR == 88 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 88 +#if (LIBCURL_VERSION_MINOR == 87 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 87 +#if (LIBCURL_VERSION_MINOR == 86 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 86 +#if (LIBCURL_VERSION_MINOR == 85 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 85 +#define CURLOPT_FTP_RESPONSE_TIMEOUT 0 +#define CURLE_OBSOLETE75 -1 +#if (LIBCURL_VERSION_MINOR == 84 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 84 +#define CURLE_UNRECOVERABLE_POLL -1 +#define CURLINFO_CAINFO 0 +#define CURLINFO_CAPATH 0 +#define CURL_VERSION_THREADSAFE 0 +#if (LIBCURL_VERSION_MINOR == 83 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 83 +#if (LIBCURL_VERSION_MINOR == 83 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 83 +#if (LIBCURL_VERSION_MINOR == 82 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 82 +#define CURLE_OBSOLETE62 -1 +#define CURLE_OBSOLETE76 -1 +#if (LIBCURL_VERSION_MINOR == 81 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 81 +#if (LIBCURL_VERSION_MINOR == 80 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 80 +#if (LIBCURL_VERSION_MINOR == 79 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 79 +#if (LIBCURL_VERSION_MINOR == 79 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 79 +#if (LIBCURL_VERSION_MINOR == 78 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 78 +#define CURLE_SETOPT_OPTION_SYNTAX -1 +#if (LIBCURL_VERSION_MINOR == 77 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 77 +#define CURLE_SSL_CLIENTCERT -1 +#if (LIBCURL_VERSION_MINOR == 76 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 76 +#if (LIBCURL_VERSION_MINOR == 76 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 76 +#define CURLINFO_REFERER 0 +#define CURL_VERSION_GSASL 0 +#if (LIBCURL_VERSION_MINOR == 75 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 75 +#define CURLAUTH_AWS_SIGV4 0 +#if (LIBCURL_VERSION_MINOR == 74 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 74 +#define CURL_VERSION_HSTS 0 +#if (LIBCURL_VERSION_MINOR == 73 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 73 +#define CURLOPT_PROGRESSDATA 0 +#define CURLE_PROXY -1 +#define CURLINFO_PROXY_ERROR 0 +#if (LIBCURL_VERSION_MINOR == 72 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 72 +#define CURLINFO_EFFECTIVE_METHOD 0 +#define CURL_VERSION_ZSTD 0 +#define CURL_VERSION_UNICODE 0 +#if (LIBCURL_VERSION_MINOR == 71 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 71 +#if (LIBCURL_VERSION_MINOR == 71 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 71 +#if (LIBCURL_VERSION_MINOR == 70 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 70 +#if (LIBCURL_VERSION_MINOR == 69 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 69 +#if (LIBCURL_VERSION_MINOR == 69 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 69 +#define CURLE_QUIC_CONNECT_ERROR -1 +#if (LIBCURL_VERSION_MINOR == 68 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 68 +#define CURLE_HTTP3 -1 +#if (LIBCURL_VERSION_MINOR == 67 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 67 +#define CURL_VERSION_ESNI 0 +#if (LIBCURL_VERSION_MINOR == 66 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 66 +#define CURLOPT_SASL_AUTHZID 0 +#define CURLE_AUTH_ERROR -1 +#define CURLINFO_RETRY_AFTER 0 +#define CURL_VERSION_HTTP3 0 +#if (LIBCURL_VERSION_MINOR == 65 && LIBCURL_VERSION_PATCH < 3) || LIBCURL_VERSION_MINOR < 65 +#if (LIBCURL_VERSION_MINOR == 65 && LIBCURL_VERSION_PATCH < 2) || LIBCURL_VERSION_MINOR < 65 +#if (LIBCURL_VERSION_MINOR == 65 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 65 +#if (LIBCURL_VERSION_MINOR == 65 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 65 +#define CURLOPT_MAXAGE_CONN 0 +#if (LIBCURL_VERSION_MINOR == 64 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 64 +#define CURLOPT_ALTSVC_CTRL 0 +#define CURLOPT_ALTSVC 0 +#define CURL_VERSION_ALTSVC 0 +#if (LIBCURL_VERSION_MINOR == 64 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 64 +#define CURLOPT_TRAILERFUNCTION 0 +#define CURLOPT_TRAILERDATA 0 +#define CURLOPT_HTTP09_ALLOWED 0 +#if (LIBCURL_VERSION_MINOR == 63 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 63 +#define CURLOPT_CURLU 0 +#if (LIBCURL_VERSION_MINOR == 62 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 62 +#define CURLOPT_DOH_URL 0 +#define CURLOPT_UPLOAD_BUFFERSIZE 0 +#define CURLOPT_UPKEEP_INTERVAL_MS 0 +#define CURLE_OBSOLETE51 -1 +#if (LIBCURL_VERSION_MINOR == 61 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 61 +#if (LIBCURL_VERSION_MINOR == 61 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 61 +#define CURLOPT_TLS13_CIPHERS 0 +#define CURLOPT_PROXY_TLS13_CIPHERS 0 +#define CURLOPT_DISALLOW_USERNAME_IN_URL 0 +#define CURLINFO_TOTAL_TIME_T 0 +#define CURLINFO_NAMELOOKUP_TIME_T 0 +#define CURLINFO_CONNECT_TIME_T 0 +#define CURLINFO_PRETRANSFER_TIME_T 0 +#define CURLINFO_STARTTRANSFER_TIME_T 0 +#define CURLINFO_REDIRECT_TIME_T 0 +#define CURLINFO_APPCONNECT_TIME_T 0 +#define CURLAUTH_BEARER 0 +#if (LIBCURL_VERSION_MINOR == 60 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 60 +#define CURLOPT_HAPROXYPROTOCOL 0 +#define CURLOPT_DNS_SHUFFLE_ADDRESSES 0 +#if (LIBCURL_VERSION_MINOR == 59 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 59 +#define CURLOPT_TIMEVALUE_LARGE 0 +#define CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS 0 +#define CURLOPT_RESOLVER_START_FUNCTION 0 +#define CURLOPT_RESOLVER_START_DATA 0 +#define CURLE_RECURSIVE_API_CALL -1 +#define CURLINFO_FILETIME_T 0 +#if (LIBCURL_VERSION_MINOR == 58 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 58 #if (LIBCURL_VERSION_MINOR == 57 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 57 #define CURL_VERSION_BROTLI 0 #if (LIBCURL_VERSION_MINOR == 56 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 56 @@ -301,152 +422,7 @@ #define CURLE_SSH -1 #define CURLE_SSL_SHUTDOWN_FAILED -1 #if (LIBCURL_VERSION_MINOR == 16 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 16 -#define CURLOPT_SOCKOPTFUNCTION 0 -#define CURLOPT_SOCKOPTDATA 0 -#define CURLOPT_SSL_SESSIONID_CACHE 0 -#define CURLE_SSL_CACERT_BADFILE -1 -#if (LIBCURL_VERSION_MINOR == 15 && LIBCURL_VERSION_PATCH < 5) || LIBCURL_VERSION_MINOR < 15 -#define CURLOPT_MAX_SEND_SPEED_LARGE 0 -#define CURLOPT_MAX_RECV_SPEED_LARGE 0 -#define CURLOPT_FTP_ALTERNATIVE_TO_USER 0 -#if (LIBCURL_VERSION_MINOR == 15 && LIBCURL_VERSION_PATCH < 4) || LIBCURL_VERSION_MINOR < 15 -#define CURLOPT_CONV_FROM_NETWORK_FUNCTION 0 -#define CURLOPT_CONV_TO_NETWORK_FUNCTION 0 -#define CURLOPT_CONV_FROM_UTF8_FUNCTION 0 -#define CURLE_CONV_FAILED -1 -#define CURLE_CONV_REQD -1 -#define CURLINFO_FTP_ENTRY_PATH 0 -#define CURL_VERSION_CONV 0 -#if (LIBCURL_VERSION_MINOR == 15 && LIBCURL_VERSION_PATCH < 3) || LIBCURL_VERSION_MINOR < 15 -#if (LIBCURL_VERSION_MINOR == 15 && LIBCURL_VERSION_PATCH < 2) || LIBCURL_VERSION_MINOR < 15 -#define CURLOPT_LOCALPORT 0 -#define CURLOPT_LOCALPORTRANGE 0 -#define CURLOPT_CONNECT_ONLY 0 -#define CURLINFO_LASTSOCKET 0 -#if (LIBCURL_VERSION_MINOR == 15 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 15 -#define CURLOPT_FTP_FILEMETHOD 0 -#if (LIBCURL_VERSION_MINOR == 15 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 15 -#define CURLOPT_FTP_SKIP_PASV_IP 0 -#define CURLE_TFTP_NOTFOUND -1 -#define CURLE_TFTP_PERM -1 -#define CURLE_TFTP_DISKFULL -1 -#define CURLE_TFTP_ILLEGAL -1 -#define CURLE_TFTP_UNKNOWNID -1 -#define CURLE_TFTP_EXISTS -1 -#define CURLE_TFTP_NOSUCHUSER -1 -#if (LIBCURL_VERSION_MINOR == 14 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 14 -#define CURLOPT_COOKIELIST 0 -#define CURLOPT_IGNORE_CONTENT_LENGTH 0 -#define CURLINFO_COOKIELIST 0 -#if (LIBCURL_VERSION_MINOR == 14 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 14 -#if (LIBCURL_VERSION_MINOR == 13 && LIBCURL_VERSION_PATCH < 2) || LIBCURL_VERSION_MINOR < 13 -#define CURL_VERSION_SSPI 0 -#if (LIBCURL_VERSION_MINOR == 13 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 13 -#define CURLE_LOGIN_DENIED -1 -#if (LIBCURL_VERSION_MINOR == 13 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 13 -#define CURLOPT_SOURCE_URL 0 -#define CURLOPT_SOURCE_QUOTE 0 -#define CURLOPT_FTP_ACCOUNT 0 -#if (LIBCURL_VERSION_MINOR == 12 && LIBCURL_VERSION_PATCH < 3) || LIBCURL_VERSION_MINOR < 12 -#define CURLOPT_IOCTLFUNCTION 0 -#define CURLOPT_IOCTLDATA 0 -#define CURLE_SEND_FAIL_REWIND -1 -#define CURLE_SSL_ENGINE_INITFAILED -1 -#define CURLINFO_NUM_CONNECTS 0 -#define CURLINFO_SSL_ENGINES 0 -#if (LIBCURL_VERSION_MINOR == 12 && LIBCURL_VERSION_PATCH < 2) || LIBCURL_VERSION_MINOR < 12 -#define CURLOPT_FTPSSLAUTH 0 -#define CURLINFO_OS_ERRNO 0 -#if (LIBCURL_VERSION_MINOR == 12 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 12 -#define CURLOPT_SOURCE_HOST 0 -#define CURLOPT_SOURCE_USERPWD 0 -#define CURLOPT_SOURCE_PATH 0 -#define CURLOPT_SOURCE_PORT 0 -#define CURLOPT_PASV_HOST 0 -#define CURLOPT_SOURCE_PREQUOTE 0 -#define CURLOPT_SOURCE_POSTQUOTE 0 -#if (LIBCURL_VERSION_MINOR == 12 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 12 -#define CURLE_INTERFACE_FAILED -1 -#define CURL_VERSION_IDN 0 -#if (LIBCURL_VERSION_MINOR == 11 && LIBCURL_VERSION_PATCH < 2) || LIBCURL_VERSION_MINOR < 11 -#define CURLOPT_TCP_NODELAY 0 -#if (LIBCURL_VERSION_MINOR == 11 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 11 -#define CURLOPT_POSTFIELDSIZE_LARGE 0 -#define CURL_VERSION_LARGEFILE 0 -#if (LIBCURL_VERSION_MINOR == 11 && LIBCURL_VERSION_PATCH < 0) || LIBCURL_VERSION_MINOR < 11 -#define CURLOPT_INFILESIZE_LARGE 0 -#define CURLOPT_RESUME_FROM_LARGE 0 -#define CURLOPT_MAXFILESIZE_LARGE 0 -#define CURLOPT_NETRC_FILE 0 -#define CURLOPT_FTP_SSL 0 -#define CURLE_FTP_SSL_FAILED -1 -#if (LIBCURL_VERSION_MINOR == 10 && LIBCURL_VERSION_PATCH < 8) || LIBCURL_VERSION_MINOR < 10 -#define CURLOPT_IPRESOLVE 0 -#define CURLOPT_MAXFILESIZE 0 -#define CURLE_LDAP_INVALID_URL -1 -#define CURLE_FILESIZE_EXCEEDED -1 -#define CURLINFO_RESPONSE_CODE 0 -#define CURLINFO_HTTPAUTH_AVAIL 0 -#define CURLINFO_PROXYAUTH_AVAIL 0 -#define CURL_VERSION_SPNEGO 0 -#if (LIBCURL_VERSION_MINOR == 10 && LIBCURL_VERSION_PATCH < 7) || LIBCURL_VERSION_MINOR < 10 -#define CURLOPT_FTP_CREATE_MISSING_DIRS 0 -#define CURLOPT_PROXYAUTH 0 -#define CURLINFO_HTTP_CONNECTCODE 0 -#define CURL_VERSION_ASYNCHDNS 0 -#if (LIBCURL_VERSION_MINOR == 10 && LIBCURL_VERSION_PATCH < 6) || LIBCURL_VERSION_MINOR < 10 -#define CURLOPT_HTTPAUTH 0 -#define CURLOPT_SSL_CTX_FUNCTION 0 -#define CURLOPT_SSL_CTX_DATA 0 -#define CURL_VERSION_NTLM 0 -#define CURL_VERSION_GSSNEGOTIATE 0 -#define CURL_VERSION_DEBUG 0 -#define CURLAUTH_NONE 0 -#define CURLAUTH_BASIC 0 -#define CURLAUTH_DIGEST 0 -#define CURLAUTH_GSSNEGOTIATE 0 -#define CURLAUTH_NTLM 0 -#define CURLAUTH_ANY 0 -#define CURLAUTH_ANYSAFE 0 -#if (LIBCURL_VERSION_MINOR == 10 && LIBCURL_VERSION_PATCH < 5) || LIBCURL_VERSION_MINOR < 10 -#define CURLOPT_FTP_USE_EPRT 0 -#if (LIBCURL_VERSION_MINOR == 10 && LIBCURL_VERSION_PATCH < 4) || LIBCURL_VERSION_MINOR < 10 -#define CURLOPT_UNRESTRICTED_AUTH 0 -#if (LIBCURL_VERSION_MINOR == 10 && LIBCURL_VERSION_PATCH < 3) || LIBCURL_VERSION_MINOR < 10 -#define CURLOPT_PRIVATE 0 -#define CURLOPT_HTTP200ALIASES 0 -#define CURLE_HTTP_RETURNED_ERROR -1 -#define CURLINFO_PRIVATE 0 -#if (LIBCURL_VERSION_MINOR == 10 && LIBCURL_VERSION_PATCH < 2) || LIBCURL_VERSION_MINOR < 10 -#define CURLE_OPERATION_TIMEDOUT -1 -#if (LIBCURL_VERSION_MINOR == 10 && LIBCURL_VERSION_PATCH < 1) || LIBCURL_VERSION_MINOR < 10 #error your version is TOOOOOOOO low -#endif /* 7.10.1 */ -#endif /* 7.10.2 */ -#endif /* 7.10.3 */ -#endif /* 7.10.4 */ -#endif /* 7.10.5 */ -#endif /* 7.10.6 */ -#endif /* 7.10.7 */ -#endif /* 7.10.8 */ -#endif /* 7.11.0 */ -#endif /* 7.11.1 */ -#endif /* 7.11.2 */ -#endif /* 7.12.0 */ -#endif /* 7.12.1 */ -#endif /* 7.12.2 */ -#endif /* 7.12.3 */ -#endif /* 7.13.0 */ -#endif /* 7.13.1 */ -#endif /* 7.13.2 */ -#endif /* 7.14.0 */ -#endif /* 7.14.1 */ -#endif /* 7.15.0 */ -#endif /* 7.15.1 */ -#endif /* 7.15.2 */ -#endif /* 7.15.3 */ -#endif /* 7.15.4 */ -#endif /* 7.15.5 */ #endif /* 7.16.0 */ #endif /* 7.16.1 */ #endif /* 7.16.2 */ @@ -525,4 +501,60 @@ #endif /* 7.56.0 */ #endif /* 7.56.1 */ #endif /* 7.57.0 */ +#endif /* 7.58.0 */ +#endif /* 7.59.0 */ +#endif /* 7.60.0 */ +#endif /* 7.61.0 */ +#endif /* 7.61.1 */ +#endif /* 7.62.0 */ +#endif /* 7.63.0 */ +#endif /* 7.64.0 */ +#endif /* 7.64.1 */ +#endif /* 7.65.0 */ +#endif /* 7.65.1 */ +#endif /* 7.65.2 */ +#endif /* 7.65.3 */ +#endif /* 7.66.0 */ +#endif /* 7.67.0 */ +#endif /* 7.68.0 */ +#endif /* 7.69.0 */ +#endif /* 7.69.1 */ +#endif /* 7.70.0 */ +#endif /* 7.71.0 */ +#endif /* 7.71.1 */ +#endif /* 7.72.0 */ +#endif /* 7.73.0 */ +#endif /* 7.74.0 */ +#endif /* 7.75.0 */ +#endif /* 7.76.0 */ +#endif /* 7.76.1 */ +#endif /* 7.77.0 */ +#endif /* 7.78.0 */ +#endif /* 7.79.0 */ +#endif /* 7.79.1 */ +#endif /* 7.80.0 */ +#endif /* 7.81.0 */ +#endif /* 7.82.0 */ +#endif /* 7.83.0 */ +#endif /* 7.83.1 */ +#endif /* 7.84.0 */ +#endif /* 7.85.0 */ +#endif /* 7.86.0 */ +#endif /* 7.87.0 */ +#endif /* 7.88.0 */ +#endif /* 7.88.1 */ +#endif /* 8.0.0 */ +#endif /* 8.0.1 */ +#endif /* 8.1.0 */ +#endif /* 8.1.1 */ +#endif /* 8.1.2 */ +#endif /* 8.2.0 */ +#endif /* 8.2.1 */ +#endif /* 8.3.0 */ +#endif /* 8.4.0 */ +#endif /* 8.5.0 */ +#endif /* 8.6.0 */ +#endif /* 8.7.0 */ +#endif /* 8.7.1 */ +#endif /* 8.8.0 */ /* generated ends */ diff --git a/misc/compatgen.py b/misc/compatgen.py index cb41359..09f02d6 100644 --- a/misc/compatgen.py +++ b/misc/compatgen.py @@ -1,9 +1,45 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- + +""" codegen.py reads curl project's curl.h, outputting go-curl's compat.h + +The purpose of compatggen.py is to generate compat.h defines which are needed +by go-curl build process. Most users of co-curl can stop reading here, +because a usable compat.h is already included in the go-curl source. + +compatgen.py should be run from the go-curl source root, where it will +attempt to locate 'curl.h' in the locations defined by `target_dirs`. + + +CURL_GIT_PATH (if defined) must point to the location of your curl source +repository. For example you might check out curl from +https://github.com/curl/curl and have that saved to your local +directory `/Users/example-home/git/curl` + +Usage: + +CURL_GIT_PATH=/path-to-git-repos/curl ./misc/compatgen.py + +Example: +CURL_GIT_PATH=/Users/example-user/Projects/c/curl python3 ./misc/compatgen.py + +File Input: +(curl project) include/curl/header.h + +File Output: +compat.h + +Todo: +* Further code review ("help wanted") +* More docstrings/help. Error checking. Cleanup redefined variable scopes. +""" + import os import re +# CURL_GIT_PATH is the location you git checked out the curl project. +# You will need to supply this variable and value when invoking this script. CURL_GIT_PATH = os.environ.get("CURL_GIT_PATH", './curl') target_dirs = [ @@ -15,7 +51,7 @@ ] -def get_curl_path(): +def get_curl_path() -> str: for d in target_dirs: for root, dirs, files in os.walk(d): if 'curl.h' in files: @@ -23,8 +59,13 @@ def get_curl_path(): raise Exception("Not found") -def version_symbol(ver): - os.system('cd "{}" && git status --porcelain && git checkout -f "{}"'.format(CURL_GIT_PATH, ver)) +def version_symbol(ver:str) -> list[list[str], list[str], list[str], list[str], list[str]]: + """Returns lists of symbol info, when given argument of curl's Git tag.""" + + # force switch (discard changes) and checkout each of the curl branches + checkout_cmd = 'cd "{}" && git status --porcelain && git -c advice.detachedHead=false checkout -f "{}"'.format(CURL_GIT_PATH, ver) + + os.system(checkout_cmd) opts = [] codes = [] infos = [] @@ -70,9 +111,28 @@ def version_symbol(ver): return opts, codes, infos, vers, auths -tags = os.popen("cd {} && git tag | grep -E 'curl-7_[0-9]+_[0-9]+$'".format(CURL_GIT_PATH)).read().split('\n')[:-1] -tags = filter(lambda t: int(t.split('-')[1].split('_')[1]) >= 10, tags) -versions = sorted(tags, key=lambda o: map(int, o.split('-')[1].split('_')), reverse=True) +def extract_version(tag_str:str) -> dict: + """Converts a curl git tag (curl-8_8_0) into a dict, ex.: {'major': 8, 'minor': 8, 'patch': 0, 'version': 'curl-8_8_0'}""" + fields = re.search(r"curl-([0-9]+)_([0-9]+)_([0-9]+)", tag_str) + version = { + "major" : int(fields.group(1)), + "minor" : int(fields.group(2)), + "patch" : int(fields.group(3)), + "version" : tag_str + } + return version + +## valid versions that are compatible are 7_16_XXX or higher +def is_valid_version(version:dict) -> bool: + """Returns false when curl version (branch) is less than 7_16_XXX.""" + return version["major"] >= 8 or (version["major"] == 7 and version["minor"] >= 16) + +# fetches a list of tags from the curl repo, matching only format "curl-X_Y_Z" +get_tags_raw_cmd = "cd {} && git tag | grep -E '^curl-[0-9]+_[0-9]+_[0-9]+$'".format(CURL_GIT_PATH) +tags_raw = os.popen(get_tags_raw_cmd).read().split('\n')[:-1] +tags = map(extract_version, tags_raw) +tags = filter(is_valid_version, tags) +versions = sorted(tags, key=lambda v: [v["major"], v["minor"], v["patch"]], reverse=True) last = version_symbol("master") template = """ @@ -84,11 +144,15 @@ def version_symbol(ver): result = [template] result_tail = ["/* generated ends */\n"] + + if __name__ == '__main__': for ver in versions: - minor, patch = map(int, ver.split("_")[-2:]) + major = ver["major"] + minor = ver["minor"] + patch = ver["patch"] + opts, codes, infos, vers, auths = curr = version_symbol(ver["version"]) - opts, codes, infos, vers, auths = curr = version_symbol(ver) for o in last[0]: if o not in opts: @@ -110,7 +174,7 @@ def version_symbol(ver): "#if (LIBCURL_VERSION_MINOR == {} && LIBCURL_VERSION_PATCH < {}) || LIBCURL_VERSION_MINOR < {} ".format( minor, patch, minor)) - result_tail.insert(0, "#endif /* 7.{}.{} */".format(minor, patch)) + result_tail.insert(0, "#endif /* {}.{}.{} */".format(major, minor, patch)) last = curr From 6ce6d3d813611db0bd4627ae077467e33aa456cb Mon Sep 17 00:00:00 2001 From: Scott Prive Date: Tue, 16 Jul 2024 00:29:47 -0400 Subject: [PATCH 3/3] carry over some cleanup from compatgen.py --- const_gen.go | 289 +++++++----------------------------------------- misc/codegen.py | 35 +++++- 2 files changed, 74 insertions(+), 250 deletions(-) diff --git a/const_gen.go b/const_gen.go index 4a9e88c..d2b3b00 100644 --- a/const_gen.go +++ b/const_gen.go @@ -12,146 +12,96 @@ const ( E_UNSUPPORTED_PROTOCOL = C.CURLE_UNSUPPORTED_PROTOCOL E_FAILED_INIT = C.CURLE_FAILED_INIT E_URL_MALFORMAT = C.CURLE_URL_MALFORMAT - E_NOT_BUILT_IN = C.CURLE_NOT_BUILT_IN + E_URL_MALFORMAT_USER = C.CURLE_URL_MALFORMAT_USER E_COULDNT_RESOLVE_PROXY = C.CURLE_COULDNT_RESOLVE_PROXY E_COULDNT_RESOLVE_HOST = C.CURLE_COULDNT_RESOLVE_HOST E_COULDNT_CONNECT = C.CURLE_COULDNT_CONNECT - E_WEIRD_SERVER_REPLY = C.CURLE_WEIRD_SERVER_REPLY - E_REMOTE_ACCESS_DENIED = C.CURLE_REMOTE_ACCESS_DENIED - E_FTP_ACCEPT_FAILED = C.CURLE_FTP_ACCEPT_FAILED + E_FTP_WEIRD_SERVER_REPLY = C.CURLE_FTP_WEIRD_SERVER_REPLY + E_FTP_ACCESS_DENIED = C.CURLE_FTP_ACCESS_DENIED + E_FTP_USER_PASSWORD_INCORRECT = C.CURLE_FTP_USER_PASSWORD_INCORRECT E_FTP_WEIRD_PASS_REPLY = C.CURLE_FTP_WEIRD_PASS_REPLY - E_FTP_ACCEPT_TIMEOUT = C.CURLE_FTP_ACCEPT_TIMEOUT + E_FTP_WEIRD_USER_REPLY = C.CURLE_FTP_WEIRD_USER_REPLY E_FTP_WEIRD_PASV_REPLY = C.CURLE_FTP_WEIRD_PASV_REPLY E_FTP_WEIRD_227_FORMAT = C.CURLE_FTP_WEIRD_227_FORMAT E_FTP_CANT_GET_HOST = C.CURLE_FTP_CANT_GET_HOST - E_HTTP2 = C.CURLE_HTTP2 - E_FTP_COULDNT_SET_TYPE = C.CURLE_FTP_COULDNT_SET_TYPE + E_FTP_CANT_RECONNECT = C.CURLE_FTP_CANT_RECONNECT + E_FTP_COULDNT_SET_BINARY = C.CURLE_FTP_COULDNT_SET_BINARY E_PARTIAL_FILE = C.CURLE_PARTIAL_FILE E_FTP_COULDNT_RETR_FILE = C.CURLE_FTP_COULDNT_RETR_FILE - E_OBSOLETE20 = C.CURLE_OBSOLETE20 - E_QUOTE_ERROR = C.CURLE_QUOTE_ERROR + E_FTP_WRITE_ERROR = C.CURLE_FTP_WRITE_ERROR + E_FTP_QUOTE_ERROR = C.CURLE_FTP_QUOTE_ERROR E_HTTP_RETURNED_ERROR = C.CURLE_HTTP_RETURNED_ERROR E_WRITE_ERROR = C.CURLE_WRITE_ERROR - E_OBSOLETE24 = C.CURLE_OBSOLETE24 - E_UPLOAD_FAILED = C.CURLE_UPLOAD_FAILED + E_MALFORMAT_USER = C.CURLE_MALFORMAT_USER + E_FTP_COULDNT_STOR_FILE = C.CURLE_FTP_COULDNT_STOR_FILE E_READ_ERROR = C.CURLE_READ_ERROR E_OUT_OF_MEMORY = C.CURLE_OUT_OF_MEMORY - E_OPERATION_TIMEDOUT = C.CURLE_OPERATION_TIMEDOUT - E_OBSOLETE29 = C.CURLE_OBSOLETE29 + E_OPERATION_TIMEOUTED = C.CURLE_OPERATION_TIMEOUTED + E_FTP_COULDNT_SET_ASCII = C.CURLE_FTP_COULDNT_SET_ASCII E_FTP_PORT_FAILED = C.CURLE_FTP_PORT_FAILED E_FTP_COULDNT_USE_REST = C.CURLE_FTP_COULDNT_USE_REST - E_OBSOLETE32 = C.CURLE_OBSOLETE32 - E_RANGE_ERROR = C.CURLE_RANGE_ERROR + E_FTP_COULDNT_GET_SIZE = C.CURLE_FTP_COULDNT_GET_SIZE + E_HTTP_RANGE_ERROR = C.CURLE_HTTP_RANGE_ERROR E_HTTP_POST_ERROR = C.CURLE_HTTP_POST_ERROR E_SSL_CONNECT_ERROR = C.CURLE_SSL_CONNECT_ERROR E_BAD_DOWNLOAD_RESUME = C.CURLE_BAD_DOWNLOAD_RESUME E_FILE_COULDNT_READ_FILE = C.CURLE_FILE_COULDNT_READ_FILE E_LDAP_CANNOT_BIND = C.CURLE_LDAP_CANNOT_BIND E_LDAP_SEARCH_FAILED = C.CURLE_LDAP_SEARCH_FAILED - E_OBSOLETE40 = C.CURLE_OBSOLETE40 + E_LIBRARY_NOT_FOUND = C.CURLE_LIBRARY_NOT_FOUND E_FUNCTION_NOT_FOUND = C.CURLE_FUNCTION_NOT_FOUND E_ABORTED_BY_CALLBACK = C.CURLE_ABORTED_BY_CALLBACK E_BAD_FUNCTION_ARGUMENT = C.CURLE_BAD_FUNCTION_ARGUMENT - E_OBSOLETE44 = C.CURLE_OBSOLETE44 + E_BAD_CALLING_ORDER = C.CURLE_BAD_CALLING_ORDER E_INTERFACE_FAILED = C.CURLE_INTERFACE_FAILED - E_OBSOLETE46 = C.CURLE_OBSOLETE46 - E_TOO_MANY_REDIRECTS = C.CURLE_TOO_MANY_REDIRECTS - E_UNKNOWN_OPTION = C.CURLE_UNKNOWN_OPTION - E_TELNET_OPTION_SYNTAX = C.CURLE_TELNET_OPTION_SYNTAX - E_OBSOLETE50 = C.CURLE_OBSOLETE50 - E_PEER_FAILED_VERIFICATION = C.CURLE_PEER_FAILED_VERIFICATION + E_BAD_PASSWORD_ENTERED = C.CURLE_BAD_PASSWORD_ENTERED + E_UNKNOWN_TELNET_OPTION = C.CURLE_UNKNOWN_TELNET_OPTION + E_OBSOLETE = C.CURLE_OBSOLETE + E_SSL_PEER_CERTIFICATE = C.CURLE_SSL_PEER_CERTIFICATE E_GOT_NOTHING = C.CURLE_GOT_NOTHING E_SSL_ENGINE_NOTFOUND = C.CURLE_SSL_ENGINE_NOTFOUND E_SSL_ENGINE_SETFAILED = C.CURLE_SSL_ENGINE_SETFAILED E_SEND_ERROR = C.CURLE_SEND_ERROR E_RECV_ERROR = C.CURLE_RECV_ERROR - E_OBSOLETE57 = C.CURLE_OBSOLETE57 + E_SHARE_IN_USE = C.CURLE_SHARE_IN_USE E_SSL_CERTPROBLEM = C.CURLE_SSL_CERTPROBLEM E_SSL_CIPHER = C.CURLE_SSL_CIPHER E_SSL_CACERT = C.CURLE_SSL_CACERT E_BAD_CONTENT_ENCODING = C.CURLE_BAD_CONTENT_ENCODING E_LDAP_INVALID_URL = C.CURLE_LDAP_INVALID_URL E_FILESIZE_EXCEEDED = C.CURLE_FILESIZE_EXCEEDED - E_USE_SSL_FAILED = C.CURLE_USE_SSL_FAILED + E_FTP_SSL_FAILED = C.CURLE_FTP_SSL_FAILED E_SEND_FAIL_REWIND = C.CURLE_SEND_FAIL_REWIND E_SSL_ENGINE_INITFAILED = C.CURLE_SSL_ENGINE_INITFAILED E_LOGIN_DENIED = C.CURLE_LOGIN_DENIED E_TFTP_NOTFOUND = C.CURLE_TFTP_NOTFOUND E_TFTP_PERM = C.CURLE_TFTP_PERM - E_REMOTE_DISK_FULL = C.CURLE_REMOTE_DISK_FULL + E_TFTP_DISKFULL = C.CURLE_TFTP_DISKFULL E_TFTP_ILLEGAL = C.CURLE_TFTP_ILLEGAL E_TFTP_UNKNOWNID = C.CURLE_TFTP_UNKNOWNID - E_REMOTE_FILE_EXISTS = C.CURLE_REMOTE_FILE_EXISTS + E_TFTP_EXISTS = C.CURLE_TFTP_EXISTS E_TFTP_NOSUCHUSER = C.CURLE_TFTP_NOSUCHUSER E_CONV_FAILED = C.CURLE_CONV_FAILED E_CONV_REQD = C.CURLE_CONV_REQD E_SSL_CACERT_BADFILE = C.CURLE_SSL_CACERT_BADFILE - E_REMOTE_FILE_NOT_FOUND = C.CURLE_REMOTE_FILE_NOT_FOUND - E_SSH = C.CURLE_SSH - E_SSL_SHUTDOWN_FAILED = C.CURLE_SSL_SHUTDOWN_FAILED - E_AGAIN = C.CURLE_AGAIN - E_SSL_CRL_BADFILE = C.CURLE_SSL_CRL_BADFILE - E_SSL_ISSUER_ERROR = C.CURLE_SSL_ISSUER_ERROR - E_FTP_PRET_FAILED = C.CURLE_FTP_PRET_FAILED - E_RTSP_CSEQ_ERROR = C.CURLE_RTSP_CSEQ_ERROR - E_RTSP_SESSION_ERROR = C.CURLE_RTSP_SESSION_ERROR - E_FTP_BAD_FILE_LIST = C.CURLE_FTP_BAD_FILE_LIST - E_CHUNK_FAILED = C.CURLE_CHUNK_FAILED - E_NO_CONNECTION_AVAILABLE = C.CURLE_NO_CONNECTION_AVAILABLE - E_SSL_PINNEDPUBKEYNOTMATCH = C.CURLE_SSL_PINNEDPUBKEYNOTMATCH - E_SSL_INVALIDCERTSTATUS = C.CURLE_SSL_INVALIDCERTSTATUS - E_HTTP2_STREAM = C.CURLE_HTTP2_STREAM - E_OBSOLETE16 = C.CURLE_OBSOLETE16 - E_OBSOLETE10 = C.CURLE_OBSOLETE10 - E_OBSOLETE12 = C.CURLE_OBSOLETE12 - E_FTP_WEIRD_SERVER_REPLY = C.CURLE_FTP_WEIRD_SERVER_REPLY - E_UNKNOWN_TELNET_OPTION = C.CURLE_UNKNOWN_TELNET_OPTION - E_SSL_PEER_CERTIFICATE = C.CURLE_SSL_PEER_CERTIFICATE - E_OBSOLETE = C.CURLE_OBSOLETE - E_BAD_PASSWORD_ENTERED = C.CURLE_BAD_PASSWORD_ENTERED - E_BAD_CALLING_ORDER = C.CURLE_BAD_CALLING_ORDER - E_FTP_USER_PASSWORD_INCORRECT = C.CURLE_FTP_USER_PASSWORD_INCORRECT - E_FTP_CANT_RECONNECT = C.CURLE_FTP_CANT_RECONNECT - E_FTP_COULDNT_GET_SIZE = C.CURLE_FTP_COULDNT_GET_SIZE - E_FTP_COULDNT_SET_ASCII = C.CURLE_FTP_COULDNT_SET_ASCII - E_FTP_WEIRD_USER_REPLY = C.CURLE_FTP_WEIRD_USER_REPLY - E_FTP_WRITE_ERROR = C.CURLE_FTP_WRITE_ERROR - E_LIBRARY_NOT_FOUND = C.CURLE_LIBRARY_NOT_FOUND - E_MALFORMAT_USER = C.CURLE_MALFORMAT_USER - E_SHARE_IN_USE = C.CURLE_SHARE_IN_USE - E_URL_MALFORMAT_USER = C.CURLE_URL_MALFORMAT_USER - E_FTP_ACCESS_DENIED = C.CURLE_FTP_ACCESS_DENIED - E_FTP_COULDNT_SET_BINARY = C.CURLE_FTP_COULDNT_SET_BINARY - E_FTP_QUOTE_ERROR = C.CURLE_FTP_QUOTE_ERROR - E_TFTP_DISKFULL = C.CURLE_TFTP_DISKFULL - E_TFTP_EXISTS = C.CURLE_TFTP_EXISTS - E_HTTP_RANGE_ERROR = C.CURLE_HTTP_RANGE_ERROR - E_FTP_SSL_FAILED = C.CURLE_FTP_SSL_FAILED - E_OPERATION_TIMEOUTED = C.CURLE_OPERATION_TIMEOUTED + E_OPERATION_TIMEDOUT = C.CURLE_OPERATION_TIMEDOUT E_HTTP_NOT_FOUND = C.CURLE_HTTP_NOT_FOUND E_HTTP_PORT_FAILED = C.CURLE_HTTP_PORT_FAILED - E_FTP_COULDNT_STOR_FILE = C.CURLE_FTP_COULDNT_STOR_FILE + E_ALREADY_COMPLETE = C.CURLE_ALREADY_COMPLETE E_FTP_PARTIAL_FILE = C.CURLE_FTP_PARTIAL_FILE E_FTP_BAD_DOWNLOAD_RESUME = C.CURLE_FTP_BAD_DOWNLOAD_RESUME - E_ALREADY_COMPLETE = C.CURLE_ALREADY_COMPLETE ) // easy.Setopt(flag, ...) const ( - OPT_ENCODING = C.CURLOPT_ENCODING OPT_FILE = C.CURLOPT_FILE - OPT_INFILE = C.CURLOPT_INFILE - OPT_WRITEHEADER = C.CURLOPT_WRITEHEADER - OPT_WRITEINFO = C.CURLOPT_WRITEINFO - OPT_CLOSEPOLICY = C.CURLOPT_CLOSEPOLICY - OPT_WRITEDATA = C.CURLOPT_WRITEDATA OPT_URL = C.CURLOPT_URL OPT_PORT = C.CURLOPT_PORT OPT_PROXY = C.CURLOPT_PROXY OPT_USERPWD = C.CURLOPT_USERPWD OPT_PROXYUSERPWD = C.CURLOPT_PROXYUSERPWD OPT_RANGE = C.CURLOPT_RANGE - OPT_READDATA = C.CURLOPT_READDATA + OPT_INFILE = C.CURLOPT_INFILE OPT_ERRORBUFFER = C.CURLOPT_ERRORBUFFER OPT_WRITEFUNCTION = C.CURLOPT_WRITEFUNCTION OPT_READFUNCTION = C.CURLOPT_READFUNCTION @@ -161,17 +111,17 @@ const ( OPT_REFERER = C.CURLOPT_REFERER OPT_FTPPORT = C.CURLOPT_FTPPORT OPT_USERAGENT = C.CURLOPT_USERAGENT - OPT_LOW_SPEED_LIMIT = C.CURLOPT_LOW_SPEED_LIMIT OPT_LOW_SPEED_TIME = C.CURLOPT_LOW_SPEED_TIME OPT_RESUME_FROM = C.CURLOPT_RESUME_FROM OPT_COOKIE = C.CURLOPT_COOKIE OPT_HTTPHEADER = C.CURLOPT_HTTPHEADER OPT_HTTPPOST = C.CURLOPT_HTTPPOST OPT_SSLCERT = C.CURLOPT_SSLCERT - OPT_KEYPASSWD = C.CURLOPT_KEYPASSWD + OPT_SSLCERTPASSWD = C.CURLOPT_SSLCERTPASSWD + OPT_SSLKEYPASSWD = C.CURLOPT_SSLKEYPASSWD OPT_CRLF = C.CURLOPT_CRLF OPT_QUOTE = C.CURLOPT_QUOTE - OPT_HEADERDATA = C.CURLOPT_HEADERDATA + OPT_WRITEHEADER = C.CURLOPT_WRITEHEADER OPT_COOKIEFILE = C.CURLOPT_COOKIEFILE OPT_SSLVERSION = C.CURLOPT_SSLVERSION OPT_TIMECONDITION = C.CURLOPT_TIMECONDITION @@ -179,7 +129,7 @@ const ( OPT_CUSTOMREQUEST = C.CURLOPT_CUSTOMREQUEST OPT_STDERR = C.CURLOPT_STDERR OPT_POSTQUOTE = C.CURLOPT_POSTQUOTE - OPT_OBSOLETE40 = C.CURLOPT_OBSOLETE40 + OPT_WRITEINFO = C.CURLOPT_WRITEINFO OPT_VERBOSE = C.CURLOPT_VERBOSE OPT_HEADER = C.CURLOPT_HEADER OPT_NOPROGRESS = C.CURLOPT_NOPROGRESS @@ -187,28 +137,27 @@ const ( OPT_FAILONERROR = C.CURLOPT_FAILONERROR OPT_UPLOAD = C.CURLOPT_UPLOAD OPT_POST = C.CURLOPT_POST - OPT_DIRLISTONLY = C.CURLOPT_DIRLISTONLY - OPT_APPEND = C.CURLOPT_APPEND + OPT_FTPLISTONLY = C.CURLOPT_FTPLISTONLY + OPT_FTPAPPEND = C.CURLOPT_FTPAPPEND OPT_NETRC = C.CURLOPT_NETRC OPT_FOLLOWLOCATION = C.CURLOPT_FOLLOWLOCATION OPT_TRANSFERTEXT = C.CURLOPT_TRANSFERTEXT OPT_PUT = C.CURLOPT_PUT OPT_PROGRESSFUNCTION = C.CURLOPT_PROGRESSFUNCTION OPT_PROGRESSDATA = C.CURLOPT_PROGRESSDATA - OPT_XFERINFODATA = C.CURLOPT_XFERINFODATA OPT_AUTOREFERER = C.CURLOPT_AUTOREFERER OPT_PROXYPORT = C.CURLOPT_PROXYPORT OPT_POSTFIELDSIZE = C.CURLOPT_POSTFIELDSIZE OPT_HTTPPROXYTUNNEL = C.CURLOPT_HTTPPROXYTUNNEL OPT_INTERFACE = C.CURLOPT_INTERFACE - OPT_KRBLEVEL = C.CURLOPT_KRBLEVEL + OPT_KRB4LEVEL = C.CURLOPT_KRB4LEVEL OPT_SSL_VERIFYPEER = C.CURLOPT_SSL_VERIFYPEER OPT_CAINFO = C.CURLOPT_CAINFO OPT_MAXREDIRS = C.CURLOPT_MAXREDIRS OPT_FILETIME = C.CURLOPT_FILETIME OPT_TELNETOPTIONS = C.CURLOPT_TELNETOPTIONS OPT_MAXCONNECTS = C.CURLOPT_MAXCONNECTS - OPT_OBSOLETE72 = C.CURLOPT_OBSOLETE72 + OPT_CLOSEPOLICY = C.CURLOPT_CLOSEPOLICY OPT_FRESH_CONNECT = C.CURLOPT_FRESH_CONNECT OPT_FORBID_REUSE = C.CURLOPT_FORBID_REUSE OPT_RANDOM_FILE = C.CURLOPT_RANDOM_FILE @@ -237,7 +186,7 @@ const ( OPT_NOSIGNAL = C.CURLOPT_NOSIGNAL OPT_SHARE = C.CURLOPT_SHARE OPT_PROXYTYPE = C.CURLOPT_PROXYTYPE - OPT_ACCEPT_ENCODING = C.CURLOPT_ACCEPT_ENCODING + OPT_ENCODING = C.CURLOPT_ENCODING OPT_PRIVATE = C.CURLOPT_PRIVATE OPT_HTTP200ALIASES = C.CURLOPT_HTTP200ALIASES OPT_UNRESTRICTED_AUTH = C.CURLOPT_UNRESTRICTED_AUTH @@ -247,15 +196,13 @@ const ( OPT_SSL_CTX_DATA = C.CURLOPT_SSL_CTX_DATA OPT_FTP_CREATE_MISSING_DIRS = C.CURLOPT_FTP_CREATE_MISSING_DIRS OPT_PROXYAUTH = C.CURLOPT_PROXYAUTH - OPT_FTP_RESPONSE_TIMEOUT = C.CURLOPT_FTP_RESPONSE_TIMEOUT - OPT_SERVER_RESPONSE_TIMEOUT = C.CURLOPT_SERVER_RESPONSE_TIMEOUT OPT_IPRESOLVE = C.CURLOPT_IPRESOLVE OPT_MAXFILESIZE = C.CURLOPT_MAXFILESIZE OPT_INFILESIZE_LARGE = C.CURLOPT_INFILESIZE_LARGE OPT_RESUME_FROM_LARGE = C.CURLOPT_RESUME_FROM_LARGE OPT_MAXFILESIZE_LARGE = C.CURLOPT_MAXFILESIZE_LARGE OPT_NETRC_FILE = C.CURLOPT_NETRC_FILE - OPT_USE_SSL = C.CURLOPT_USE_SSL + OPT_FTP_SSL = C.CURLOPT_FTP_SSL OPT_POSTFIELDSIZE_LARGE = C.CURLOPT_POSTFIELDSIZE_LARGE OPT_TCP_NODELAY = C.CURLOPT_TCP_NODELAY OPT_FTPSSLAUTH = C.CURLOPT_FTPSSLAUTH @@ -278,133 +225,9 @@ const ( OPT_SOCKOPTFUNCTION = C.CURLOPT_SOCKOPTFUNCTION OPT_SOCKOPTDATA = C.CURLOPT_SOCKOPTDATA OPT_SSL_SESSIONID_CACHE = C.CURLOPT_SSL_SESSIONID_CACHE - OPT_SSH_AUTH_TYPES = C.CURLOPT_SSH_AUTH_TYPES - OPT_SSH_PUBLIC_KEYFILE = C.CURLOPT_SSH_PUBLIC_KEYFILE - OPT_SSH_PRIVATE_KEYFILE = C.CURLOPT_SSH_PRIVATE_KEYFILE - OPT_FTP_SSL_CCC = C.CURLOPT_FTP_SSL_CCC - OPT_TIMEOUT_MS = C.CURLOPT_TIMEOUT_MS - OPT_CONNECTTIMEOUT_MS = C.CURLOPT_CONNECTTIMEOUT_MS - OPT_HTTP_TRANSFER_DECODING = C.CURLOPT_HTTP_TRANSFER_DECODING - OPT_HTTP_CONTENT_DECODING = C.CURLOPT_HTTP_CONTENT_DECODING - OPT_NEW_FILE_PERMS = C.CURLOPT_NEW_FILE_PERMS - OPT_NEW_DIRECTORY_PERMS = C.CURLOPT_NEW_DIRECTORY_PERMS - OPT_POSTREDIR = C.CURLOPT_POSTREDIR - OPT_SSH_HOST_PUBLIC_KEY_MD5 = C.CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 - OPT_OPENSOCKETFUNCTION = C.CURLOPT_OPENSOCKETFUNCTION - OPT_OPENSOCKETDATA = C.CURLOPT_OPENSOCKETDATA - OPT_COPYPOSTFIELDS = C.CURLOPT_COPYPOSTFIELDS - OPT_PROXY_TRANSFER_MODE = C.CURLOPT_PROXY_TRANSFER_MODE - OPT_SEEKFUNCTION = C.CURLOPT_SEEKFUNCTION - OPT_SEEKDATA = C.CURLOPT_SEEKDATA - OPT_CRLFILE = C.CURLOPT_CRLFILE - OPT_ISSUERCERT = C.CURLOPT_ISSUERCERT - OPT_ADDRESS_SCOPE = C.CURLOPT_ADDRESS_SCOPE - OPT_CERTINFO = C.CURLOPT_CERTINFO - OPT_USERNAME = C.CURLOPT_USERNAME - OPT_PASSWORD = C.CURLOPT_PASSWORD - OPT_PROXYUSERNAME = C.CURLOPT_PROXYUSERNAME - OPT_PROXYPASSWORD = C.CURLOPT_PROXYPASSWORD - OPT_NOPROXY = C.CURLOPT_NOPROXY - OPT_TFTP_BLKSIZE = C.CURLOPT_TFTP_BLKSIZE - OPT_SOCKS5_GSSAPI_SERVICE = C.CURLOPT_SOCKS5_GSSAPI_SERVICE - OPT_SOCKS5_GSSAPI_NEC = C.CURLOPT_SOCKS5_GSSAPI_NEC - OPT_PROTOCOLS = C.CURLOPT_PROTOCOLS - OPT_REDIR_PROTOCOLS = C.CURLOPT_REDIR_PROTOCOLS - OPT_SSH_KNOWNHOSTS = C.CURLOPT_SSH_KNOWNHOSTS - OPT_SSH_KEYFUNCTION = C.CURLOPT_SSH_KEYFUNCTION - OPT_SSH_KEYDATA = C.CURLOPT_SSH_KEYDATA - OPT_MAIL_FROM = C.CURLOPT_MAIL_FROM - OPT_MAIL_RCPT = C.CURLOPT_MAIL_RCPT - OPT_FTP_USE_PRET = C.CURLOPT_FTP_USE_PRET - OPT_RTSP_REQUEST = C.CURLOPT_RTSP_REQUEST - OPT_RTSP_SESSION_ID = C.CURLOPT_RTSP_SESSION_ID - OPT_RTSP_STREAM_URI = C.CURLOPT_RTSP_STREAM_URI - OPT_RTSP_TRANSPORT = C.CURLOPT_RTSP_TRANSPORT - OPT_RTSP_CLIENT_CSEQ = C.CURLOPT_RTSP_CLIENT_CSEQ - OPT_RTSP_SERVER_CSEQ = C.CURLOPT_RTSP_SERVER_CSEQ - OPT_INTERLEAVEDATA = C.CURLOPT_INTERLEAVEDATA - OPT_INTERLEAVEFUNCTION = C.CURLOPT_INTERLEAVEFUNCTION - OPT_WILDCARDMATCH = C.CURLOPT_WILDCARDMATCH - OPT_CHUNK_BGN_FUNCTION = C.CURLOPT_CHUNK_BGN_FUNCTION - OPT_CHUNK_END_FUNCTION = C.CURLOPT_CHUNK_END_FUNCTION - OPT_FNMATCH_FUNCTION = C.CURLOPT_FNMATCH_FUNCTION - OPT_CHUNK_DATA = C.CURLOPT_CHUNK_DATA - OPT_FNMATCH_DATA = C.CURLOPT_FNMATCH_DATA - OPT_RESOLVE = C.CURLOPT_RESOLVE - OPT_TLSAUTH_USERNAME = C.CURLOPT_TLSAUTH_USERNAME - OPT_TLSAUTH_PASSWORD = C.CURLOPT_TLSAUTH_PASSWORD - OPT_TLSAUTH_TYPE = C.CURLOPT_TLSAUTH_TYPE - OPT_TRANSFER_ENCODING = C.CURLOPT_TRANSFER_ENCODING - OPT_CLOSESOCKETFUNCTION = C.CURLOPT_CLOSESOCKETFUNCTION - OPT_CLOSESOCKETDATA = C.CURLOPT_CLOSESOCKETDATA - OPT_GSSAPI_DELEGATION = C.CURLOPT_GSSAPI_DELEGATION - OPT_DNS_SERVERS = C.CURLOPT_DNS_SERVERS - OPT_ACCEPTTIMEOUT_MS = C.CURLOPT_ACCEPTTIMEOUT_MS - OPT_TCP_KEEPALIVE = C.CURLOPT_TCP_KEEPALIVE - OPT_TCP_KEEPIDLE = C.CURLOPT_TCP_KEEPIDLE - OPT_TCP_KEEPINTVL = C.CURLOPT_TCP_KEEPINTVL - OPT_SSL_OPTIONS = C.CURLOPT_SSL_OPTIONS - OPT_MAIL_AUTH = C.CURLOPT_MAIL_AUTH - OPT_SASL_IR = C.CURLOPT_SASL_IR - OPT_XFERINFOFUNCTION = C.CURLOPT_XFERINFOFUNCTION - OPT_XOAUTH2_BEARER = C.CURLOPT_XOAUTH2_BEARER - OPT_DNS_INTERFACE = C.CURLOPT_DNS_INTERFACE - OPT_DNS_LOCAL_IP4 = C.CURLOPT_DNS_LOCAL_IP4 - OPT_DNS_LOCAL_IP6 = C.CURLOPT_DNS_LOCAL_IP6 - OPT_LOGIN_OPTIONS = C.CURLOPT_LOGIN_OPTIONS - OPT_SSL_ENABLE_NPN = C.CURLOPT_SSL_ENABLE_NPN - OPT_SSL_ENABLE_ALPN = C.CURLOPT_SSL_ENABLE_ALPN - OPT_EXPECT_100_TIMEOUT_MS = C.CURLOPT_EXPECT_100_TIMEOUT_MS - OPT_PROXYHEADER = C.CURLOPT_PROXYHEADER - OPT_HEADEROPT = C.CURLOPT_HEADEROPT - OPT_PINNEDPUBLICKEY = C.CURLOPT_PINNEDPUBLICKEY - OPT_UNIX_SOCKET_PATH = C.CURLOPT_UNIX_SOCKET_PATH - OPT_SSL_VERIFYSTATUS = C.CURLOPT_SSL_VERIFYSTATUS - OPT_SSL_FALSESTART = C.CURLOPT_SSL_FALSESTART - OPT_PATH_AS_IS = C.CURLOPT_PATH_AS_IS - OPT_PROXY_SERVICE_NAME = C.CURLOPT_PROXY_SERVICE_NAME - OPT_SERVICE_NAME = C.CURLOPT_SERVICE_NAME - OPT_PIPEWAIT = C.CURLOPT_PIPEWAIT - OPT_DEFAULT_PROTOCOL = C.CURLOPT_DEFAULT_PROTOCOL - OPT_STREAM_WEIGHT = C.CURLOPT_STREAM_WEIGHT - OPT_STREAM_DEPENDS = C.CURLOPT_STREAM_DEPENDS - OPT_STREAM_DEPENDS_E = C.CURLOPT_STREAM_DEPENDS_E - OPT_TFTP_NO_OPTIONS = C.CURLOPT_TFTP_NO_OPTIONS - OPT_CONNECT_TO = C.CURLOPT_CONNECT_TO - OPT_TCP_FASTOPEN = C.CURLOPT_TCP_FASTOPEN - OPT_KEEP_SENDING_ON_ERROR = C.CURLOPT_KEEP_SENDING_ON_ERROR - OPT_PROXY_CAINFO = C.CURLOPT_PROXY_CAINFO - OPT_PROXY_CAPATH = C.CURLOPT_PROXY_CAPATH - OPT_PROXY_SSL_VERIFYPEER = C.CURLOPT_PROXY_SSL_VERIFYPEER - OPT_PROXY_SSL_VERIFYHOST = C.CURLOPT_PROXY_SSL_VERIFYHOST - OPT_PROXY_SSLVERSION = C.CURLOPT_PROXY_SSLVERSION - OPT_PROXY_TLSAUTH_USERNAME = C.CURLOPT_PROXY_TLSAUTH_USERNAME - OPT_PROXY_TLSAUTH_PASSWORD = C.CURLOPT_PROXY_TLSAUTH_PASSWORD - OPT_PROXY_TLSAUTH_TYPE = C.CURLOPT_PROXY_TLSAUTH_TYPE - OPT_PROXY_SSLCERT = C.CURLOPT_PROXY_SSLCERT - OPT_PROXY_SSLCERTTYPE = C.CURLOPT_PROXY_SSLCERTTYPE - OPT_PROXY_SSLKEY = C.CURLOPT_PROXY_SSLKEY - OPT_PROXY_SSLKEYTYPE = C.CURLOPT_PROXY_SSLKEYTYPE - OPT_PROXY_KEYPASSWD = C.CURLOPT_PROXY_KEYPASSWD - OPT_PROXY_SSL_CIPHER_LIST = C.CURLOPT_PROXY_SSL_CIPHER_LIST - OPT_PROXY_CRLFILE = C.CURLOPT_PROXY_CRLFILE - OPT_PROXY_SSL_OPTIONS = C.CURLOPT_PROXY_SSL_OPTIONS - OPT_PRE_PROXY = C.CURLOPT_PRE_PROXY - OPT_PROXY_PINNEDPUBLICKEY = C.CURLOPT_PROXY_PINNEDPUBLICKEY - OPT_ABSTRACT_UNIX_SOCKET = C.CURLOPT_ABSTRACT_UNIX_SOCKET - OPT_SUPPRESS_CONNECT_HEADERS = C.CURLOPT_SUPPRESS_CONNECT_HEADERS - OPT_REQUEST_TARGET = C.CURLOPT_REQUEST_TARGET - OPT_SOCKS5_AUTH = C.CURLOPT_SOCKS5_AUTH - OPT_SSH_COMPRESSION = C.CURLOPT_SSH_COMPRESSION - OPT_MIMEPOST = C.CURLOPT_MIMEPOST - OPT_POST301 = C.CURLOPT_POST301 - OPT_SSLKEYPASSWD = C.CURLOPT_SSLKEYPASSWD - OPT_FTPAPPEND = C.CURLOPT_FTPAPPEND - OPT_FTPLISTONLY = C.CURLOPT_FTPLISTONLY - OPT_FTP_SSL = C.CURLOPT_FTP_SSL - OPT_SSLCERTPASSWD = C.CURLOPT_SSLCERTPASSWD - OPT_KRB4LEVEL = C.CURLOPT_KRB4LEVEL - OPT_RTSPHEADER = C.CURLOPT_RTSPHEADER + OPT_WRITEDATA = C.CURLOPT_WRITEDATA + OPT_READDATA = C.CURLOPT_READDATA + OPT_HEADERDATA = C.CURLOPT_HEADERDATA ) // easy.Getinfo(flag) @@ -417,21 +240,15 @@ const ( INFO_CONNECT_TIME = C.CURLINFO_CONNECT_TIME INFO_PRETRANSFER_TIME = C.CURLINFO_PRETRANSFER_TIME INFO_SIZE_UPLOAD = C.CURLINFO_SIZE_UPLOAD - INFO_SIZE_UPLOAD_T = C.CURLINFO_SIZE_UPLOAD_T INFO_SIZE_DOWNLOAD = C.CURLINFO_SIZE_DOWNLOAD - INFO_SIZE_DOWNLOAD_T = C.CURLINFO_SIZE_DOWNLOAD_T INFO_SPEED_DOWNLOAD = C.CURLINFO_SPEED_DOWNLOAD - INFO_SPEED_DOWNLOAD_T = C.CURLINFO_SPEED_DOWNLOAD_T INFO_SPEED_UPLOAD = C.CURLINFO_SPEED_UPLOAD - INFO_SPEED_UPLOAD_T = C.CURLINFO_SPEED_UPLOAD_T INFO_HEADER_SIZE = C.CURLINFO_HEADER_SIZE INFO_REQUEST_SIZE = C.CURLINFO_REQUEST_SIZE INFO_SSL_VERIFYRESULT = C.CURLINFO_SSL_VERIFYRESULT INFO_FILETIME = C.CURLINFO_FILETIME INFO_CONTENT_LENGTH_DOWNLOAD = C.CURLINFO_CONTENT_LENGTH_DOWNLOAD - INFO_CONTENT_LENGTH_DOWNLOAD_T = C.CURLINFO_CONTENT_LENGTH_DOWNLOAD_T INFO_CONTENT_LENGTH_UPLOAD = C.CURLINFO_CONTENT_LENGTH_UPLOAD - INFO_CONTENT_LENGTH_UPLOAD_T = C.CURLINFO_CONTENT_LENGTH_UPLOAD_T INFO_STARTTRANSFER_TIME = C.CURLINFO_STARTTRANSFER_TIME INFO_CONTENT_TYPE = C.CURLINFO_CONTENT_TYPE INFO_REDIRECT_TIME = C.CURLINFO_REDIRECT_TIME @@ -446,25 +263,6 @@ const ( INFO_COOKIELIST = C.CURLINFO_COOKIELIST INFO_LASTSOCKET = C.CURLINFO_LASTSOCKET INFO_FTP_ENTRY_PATH = C.CURLINFO_FTP_ENTRY_PATH - INFO_REDIRECT_URL = C.CURLINFO_REDIRECT_URL - INFO_PRIMARY_IP = C.CURLINFO_PRIMARY_IP - INFO_APPCONNECT_TIME = C.CURLINFO_APPCONNECT_TIME - INFO_CERTINFO = C.CURLINFO_CERTINFO - INFO_CONDITION_UNMET = C.CURLINFO_CONDITION_UNMET - INFO_RTSP_SESSION_ID = C.CURLINFO_RTSP_SESSION_ID - INFO_RTSP_CLIENT_CSEQ = C.CURLINFO_RTSP_CLIENT_CSEQ - INFO_RTSP_SERVER_CSEQ = C.CURLINFO_RTSP_SERVER_CSEQ - INFO_RTSP_CSEQ_RECV = C.CURLINFO_RTSP_CSEQ_RECV - INFO_PRIMARY_PORT = C.CURLINFO_PRIMARY_PORT - INFO_LOCAL_IP = C.CURLINFO_LOCAL_IP - INFO_LOCAL_PORT = C.CURLINFO_LOCAL_PORT - INFO_TLS_SESSION = C.CURLINFO_TLS_SESSION - INFO_ACTIVESOCKET = C.CURLINFO_ACTIVESOCKET - INFO_TLS_SSL_PTR = C.CURLINFO_TLS_SSL_PTR - INFO_HTTP_VERSION = C.CURLINFO_HTTP_VERSION - INFO_PROXY_SSL_VERIFYRESULT = C.CURLINFO_PROXY_SSL_VERIFYRESULT - INFO_PROTOCOL = C.CURLINFO_PROTOCOL - INFO_SCHEME = C.CURLINFO_SCHEME INFO_LASTONE = C.CURLINFO_LASTONE INFO_HTTP_CODE = C.CURLINFO_HTTP_CODE ) @@ -474,13 +272,8 @@ const ( AUTH_NONE = C.CURLAUTH_NONE & (1<<32 - 1) AUTH_BASIC = C.CURLAUTH_BASIC & (1<<32 - 1) AUTH_DIGEST = C.CURLAUTH_DIGEST & (1<<32 - 1) - AUTH_NEGOTIATE = C.CURLAUTH_NEGOTIATE & (1<<32 - 1) AUTH_GSSNEGOTIATE = C.CURLAUTH_GSSNEGOTIATE & (1<<32 - 1) - AUTH_GSSAPI = C.CURLAUTH_GSSAPI & (1<<32 - 1) AUTH_NTLM = C.CURLAUTH_NTLM & (1<<32 - 1) - AUTH_DIGEST_IE = C.CURLAUTH_DIGEST_IE & (1<<32 - 1) - AUTH_NTLM_WB = C.CURLAUTH_NTLM_WB & (1<<32 - 1) - AUTH_ONLY = C.CURLAUTH_ONLY & (1<<32 - 1) AUTH_ANY = C.CURLAUTH_ANY & (1<<32 - 1) AUTH_ANYSAFE = C.CURLAUTH_ANYSAFE & (1<<32 - 1) ) diff --git a/misc/codegen.py b/misc/codegen.py index 7ee8310..dc0c8f7 100644 --- a/misc/codegen.py +++ b/misc/codegen.py @@ -1,9 +1,40 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +""" codegen.py reads curl project's curl.h, outputting go-curl's const_gen.go + +codegen.py should be run from the go-curl source root, where it will +attempt to locate 'curl.h' in the locations defined by `target_dirs`. + + +CURL_GIT_PATH (if defined) must point to the location of your curl source +repository. For example you might check out curl from +https://github.com/curl/curl and have that saved to your local +directory `/Users/example-home/git/curl` + +Usage: + +CURL_GIT_PATH=/path-to-git-repos/curl ./misc/codegen.py + +Example: +CURL_GIT_PATH=/Users/example-user/Projects/c/curl python3 ./misc/codegen.py + +File Input: +(curl project) include/curl/header.h + +File Output: +const_gen.go + +Todo: +* Further code review ("help wanted") +* More docstrings/help. Error checking. Cleanup redefined variable scopes. +""" + import os import re +# CURL_GIT_PATH is the location you git checked out the curl project. +# You will need to supply this variable and value when invoking this script. CURL_GIT_PATH = os.environ.get("CURL_GIT_PATH", './curl') target_dirs = [ @@ -14,7 +45,7 @@ '/usr/include', ] -def get_curl_path(): +def get_curl_path() -> str: for d in target_dirs: for root, dirs, files in os.walk(d): if 'curl.h' in files: @@ -116,5 +147,5 @@ def get_curl_path(): auth_part = '\n'.join(auth_part) -with open('./const_gen.go', 'w') as fp: +with open('./const_gen.go', 'w', encoding="utf-8") as fp: fp.write(template.format(**locals()))