From 57d6042339d3898c7191bcd7d4160b7cc9ba64d6 Mon Sep 17 00:00:00 2001 From: Dan Liebault Date: Mon, 16 Feb 2026 18:11:34 +0100 Subject: [PATCH 01/18] update curl to 8.8 -> 8.18 --- build.zig.zon | 10 +++--- libs/curl.zig | 77 ++++++++++++++++++++++++++++++----------------- src/MultiPart.zig | 2 +- 3 files changed, 54 insertions(+), 35 deletions(-) diff --git a/build.zig.zon b/build.zig.zon index cefb69b..12d2f6b 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -11,12 +11,6 @@ "LICENSE", }, .dependencies = .{ - .curl = .{ - // https://github.com/curl/curl/releases/tag/curl-8_8_0 - .url = "https://github.com/curl/curl/releases/download/curl-8_8_0/curl-8.8.0.tar.gz", - .hash = "N-V-__8AAHipPQF9UuLPiaV1CtJzZIxvTN61tMGdFx8LGjIV", - .lazy = true, - }, // https://github.com/madler/zlib/releases/tag/v1.3.1 .zlib = .{ .url = "https://github.com/madler/zlib/releases/download/v1.3.1/zlib-1.3.1.tar.gz", @@ -28,5 +22,9 @@ .hash = "N-V-__8AAFrtpQI1j9eOv7aN3lt3eH1TJfH4npAdRIrg2gGH", .lazy = true, }, + .curl = .{ + .url = "https://github.com/curl/curl/releases/download/curl-8_18_0/curl-8.18.0.tar.gz", + .hash = "N-V-__8AALp9QAGn6CCHZ6fK_FfMyGtG824LSHYHHasM3w-y", + }, }, } diff --git a/libs/curl.zig b/libs/curl.zig index 01b0d4a..c407bd3 100644 --- a/libs/curl.zig +++ b/libs/curl.zig @@ -204,12 +204,15 @@ pub fn create(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.bui } const srcs = &.{ + "lib/cw-pause.c", + "lib/curlx/winapi.c", + "lib/curlx/strerr.c", "lib/cookie.c", "lib/http_chunks.c", "lib/escape.c", - "lib/version_win32.c", + "lib/curlx/version_win32.c", "lib/url.c", - "lib/base64.c", + "lib/curlx/base64.c", "lib/mqtt.c", "lib/setopt.c", "lib/telnet.c", @@ -229,57 +232,73 @@ const srcs = &.{ "lib/bufref.c", "lib/slist.c", "lib/curl_trc.c", + "lib/ratelimit.c", + "lib/strequal.c", "lib/vtls/rustls.c", "lib/vtls/mbedtls.c", "lib/vtls/wolfssl.c", "lib/vtls/schannel.c", "lib/vtls/gtls.c", - "lib/vtls/sectransp.c", + // "lib/vtls/sectransp.c", "lib/vtls/vtls.c", - "lib/vtls/mbedtls_threadlock.c", + // "lib/vtls/mbedtls_threadlock.c", "lib/vtls/schannel_verify.c", "lib/vtls/hostcheck.c", - "lib/vtls/bearssl.c", + // "lib/vtls/bearssl.c", "lib/vtls/openssl.c", "lib/vtls/x509asn1.c", "lib/vtls/keylog.c", + "lib/vtls/vtls_scache.c", + "lib/cshutdn.c", + "lib/multi_ev.c", + "lib/curlx/wait.c", + "lib/uint-spbset.c", + "lib/uint-bset.c", "lib/file.c", "lib/socks_gssapi.c", "lib/select.c", "lib/socketpair.c", "lib/curl_memrchr.c", "lib/cfilters.c", - "lib/strtok.c", + "lib/cf-ip-happy.c", + "lib/multi_ntfy.c", + "lib/uint-table.c", + "lib/curlx/strparse.c", + // "lib/strtok.c", "lib/version.c", - "lib/fopen.c", + "lib/curlx/fopen.c", + "lib/curl_fopen.c", "lib/http_aws_sigv4.c", "lib/mprintf.c", - "lib/curl_path.c", + // "lib/curl_path.c", "lib/parsedate.c", - "lib/rename.c", + // "lib/rename.c", "lib/ftplistparser.c", "lib/content_encoding.c", "lib/mime.c", "lib/rand.c", - "lib/curl_des.c", + // "lib/curl_des.c", "lib/curl_ntlm_core.c", "lib/pop3.c", "lib/curl_sspi.c", "lib/smb.c", "lib/conncache.c", - "lib/inet_pton.c", + "lib/curlx/inet_pton.c", "lib/if2ip.c", "lib/openldap.c", "lib/http_digest.c", "lib/cf-h1-proxy.c", - "lib/asyn-thread.c", + // "lib/asyn-thread.c", + "lib/asyn-ares.c", + "lib/asyn-thrdd.c", "lib/strerror.c", "lib/ftp.c", "lib/strdup.c", + "lib/curlx/strcopy.c", "lib/memdebug.c", - "lib/speedcheck.c", + // "lib/speedcheck.c", "lib/vquic/curl_ngtcp2.c", - "lib/vquic/curl_msh3.c", + // "lib/vquic/curl_msh3.c", "lib/vquic/vquic.c", "lib/vquic/curl_quiche.c", "lib/getinfo.c", @@ -303,16 +322,16 @@ const srcs = &.{ "lib/hostip4.c", "lib/curl_rtmp.c", "lib/amigaos.c", - "lib/share.c", - "lib/warnless.c", - "lib/hostsyn.c", + "lib/curl_share.c", + "lib/curlx/warnless.c", + // "lib/hostsyn.c", "lib/md5.c", - "lib/strtoofft.c", + // "lib/strtoofft.c", "lib/altsvc.c", "lib/formdata.c", - "lib/dynbuf.c", + "lib/curlx/dynbuf.c", "lib/curl_addrinfo.c", - "lib/hostasyn.c", + // "lib/hostasyn.c", "lib/doh.c", "lib/request.c", "lib/cw-out.c", @@ -320,24 +339,26 @@ const srcs = &.{ "lib/vtls/cipher_suite.c", "lib/easygetopt.c", "lib/ldap.c", - "lib/nonblock.c", + "lib/curlx/nonblock.c", "lib/idn.c", "lib/pingpong.c", "lib/imap.c", "lib/vssh/libssh.c", - "lib/vssh/wolfssh.c", + // "lib/vssh/wolfssh.c", "lib/vssh/libssh2.c", + "lib/vssh/vssh.c", "lib/splay.c", - "lib/krb5.c", + // "lib/krb5.c", "lib/progress.c", "lib/cf-haproxy.c", "lib/easyoptions.c", "lib/curl_range.c", "lib/curl_endian.c", "lib/http_proxy.c", - "lib/inet_ntop.c", - "lib/timeval.c", + "lib/curlx/inet_ntop.c", + "lib/curlx/timeval.c", "lib/asyn-ares.c", + "lib/asyn-base.c", "lib/rtsp.c", "lib/sha256.c", "lib/curl_threads.c", @@ -355,19 +376,19 @@ const srcs = &.{ "lib/psl.c", "lib/ws.c", "lib/hostip6.c", - "lib/curl_multibyte.c", + "lib/curlx/multibyte.c", "lib/netrc.c", "lib/llist.c", "lib/urlapi.c", "lib/strcase.c", "lib/sendf.c", - "lib/timediff.c", + "lib/curlx/timediff.c", "lib/http.c", "lib/cf-h2-proxy.c", "lib/socks.c", "lib/http_negotiate.c", "lib/transfer.c", - "lib/c-hyper.c", + // "lib/c-hyper.c", "lib/hmac.c", "lib/fileinfo.c", }; diff --git a/src/MultiPart.zig b/src/MultiPart.zig index 92b66be..9b7f06b 100644 --- a/src/MultiPart.zig +++ b/src/MultiPart.zig @@ -77,7 +77,7 @@ pub const NonCopyingData = struct { return to_read; } - pub fn seek(user_data: ?*anyopaque, offset: c_long, origin: c_int) callconv(.c) c_int { + pub fn seek(user_data: ?*anyopaque, offset: c_longlong, origin: c_int) callconv(.c) c_int { var source: *DataWithOffset = @ptrCast(@alignCast(user_data orelse return c.CURL_READFUNC_ABORT)); const new_pos = switch (origin) { c.SEEK_SET => offset, From 4841794716c1cd9701abec4124f0adf9566bfcec Mon Sep 17 00:00:00 2001 From: Dan Liebault Date: Mon, 16 Feb 2026 18:12:50 +0100 Subject: [PATCH 02/18] rm comments --- libs/curl.zig | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/libs/curl.zig b/libs/curl.zig index c407bd3..1d69651 100644 --- a/libs/curl.zig +++ b/libs/curl.zig @@ -239,12 +239,9 @@ const srcs = &.{ "lib/vtls/wolfssl.c", "lib/vtls/schannel.c", "lib/vtls/gtls.c", - // "lib/vtls/sectransp.c", "lib/vtls/vtls.c", - // "lib/vtls/mbedtls_threadlock.c", "lib/vtls/schannel_verify.c", "lib/vtls/hostcheck.c", - // "lib/vtls/bearssl.c", "lib/vtls/openssl.c", "lib/vtls/x509asn1.c", "lib/vtls/keylog.c", @@ -264,20 +261,16 @@ const srcs = &.{ "lib/multi_ntfy.c", "lib/uint-table.c", "lib/curlx/strparse.c", - // "lib/strtok.c", "lib/version.c", "lib/curlx/fopen.c", "lib/curl_fopen.c", "lib/http_aws_sigv4.c", "lib/mprintf.c", - // "lib/curl_path.c", "lib/parsedate.c", - // "lib/rename.c", "lib/ftplistparser.c", "lib/content_encoding.c", "lib/mime.c", "lib/rand.c", - // "lib/curl_des.c", "lib/curl_ntlm_core.c", "lib/pop3.c", "lib/curl_sspi.c", @@ -288,7 +281,6 @@ const srcs = &.{ "lib/openldap.c", "lib/http_digest.c", "lib/cf-h1-proxy.c", - // "lib/asyn-thread.c", "lib/asyn-ares.c", "lib/asyn-thrdd.c", "lib/strerror.c", @@ -296,9 +288,7 @@ const srcs = &.{ "lib/strdup.c", "lib/curlx/strcopy.c", "lib/memdebug.c", - // "lib/speedcheck.c", "lib/vquic/curl_ngtcp2.c", - // "lib/vquic/curl_msh3.c", "lib/vquic/vquic.c", "lib/vquic/curl_quiche.c", "lib/getinfo.c", @@ -324,14 +314,11 @@ const srcs = &.{ "lib/amigaos.c", "lib/curl_share.c", "lib/curlx/warnless.c", - // "lib/hostsyn.c", "lib/md5.c", - // "lib/strtoofft.c", "lib/altsvc.c", "lib/formdata.c", "lib/curlx/dynbuf.c", "lib/curl_addrinfo.c", - // "lib/hostasyn.c", "lib/doh.c", "lib/request.c", "lib/cw-out.c", @@ -344,11 +331,9 @@ const srcs = &.{ "lib/pingpong.c", "lib/imap.c", "lib/vssh/libssh.c", - // "lib/vssh/wolfssh.c", "lib/vssh/libssh2.c", "lib/vssh/vssh.c", "lib/splay.c", - // "lib/krb5.c", "lib/progress.c", "lib/cf-haproxy.c", "lib/easyoptions.c", @@ -388,7 +373,6 @@ const srcs = &.{ "lib/socks.c", "lib/http_negotiate.c", "lib/transfer.c", - // "lib/c-hyper.c", "lib/hmac.c", "lib/fileinfo.c", }; From 4e98a879e16685015553d6beb7ff2006710bbebf Mon Sep 17 00:00:00 2001 From: Dan Liebault Date: Wed, 18 Feb 2026 10:10:31 +0100 Subject: [PATCH 03/18] define CURL_OS as expected by makefile --- libs/curl.zig | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/libs/curl.zig b/libs/curl.zig index 1d69651..9f9df8f 100644 --- a/libs/curl.zig +++ b/libs/curl.zig @@ -200,6 +200,37 @@ pub fn create(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.bui lib.root_module.addCMacro("USE_THREADS_POSIX", "1"); lib.root_module.addCMacro("USE_UNIX_SOCKETS", "1"); lib.root_module.addCMacro("_FILE_OFFSET_BITS", "64"); + + // define CURL_OS based on target platform + // current insupported platform : Itanium, RiscOS, OS/400 + switch(target.result.os.tag) { + .windows => { + switch(target.result.cpu.arch) { + .x86 => lib.root_module.addCMacro("CURL_OS", "i386-pc-win32"), + .x86_64 => lib.root_module.addCMacro("CURL_OS", "x86_64-pc-win32"), + .thumb => lib.root_module.addCMacro("CURL_OS", "thumbv7a-pc-win32"), + .aarch64 => lib.root_module.addCMacro("CURL_OS", "aarch64-pc-win32"), + else => lib.root_module.addCMacro("CURL_OS", "unknown-pc-win32") + } + }, + .linux => { + switch(target.result.cpu.arch) { + .x86_64 => lib.root_module.addCMacro("CURL_OS", "x86_64-pc-linux-gnu"), + .aarch64 => lib.root_module.addCMacro("CURL_OS", "aarch64-pc-linux-gnu"), + else => lib.root_module.addCMacro("CURL_OS", "Linux") + } + }, + .macos => lib.root_module.addCMacro("CURL_OS", "mac"), + .freebsd => lib.root_module.addCMacro("CURL_OS", "freebsd"), + else => { + const arch = @tagName(target.result.cpu.arch); + const os = @tagName(target.result.os.tag); + + const system_name = std.fmt.allocPrint(b.allocator, "{s}-pc-{s}", .{ arch, os }) catch "unknown-pc-unknown"; + lib.root_module.addCMacro("CURL_OS", system_name); + } + } + return lib; } @@ -342,7 +373,6 @@ const srcs = &.{ "lib/http_proxy.c", "lib/curlx/inet_ntop.c", "lib/curlx/timeval.c", - "lib/asyn-ares.c", "lib/asyn-base.c", "lib/rtsp.c", "lib/sha256.c", From 6ddbcc6bf0ea4a75174c3bdda27d57da90eeb8e7 Mon Sep 17 00:00:00 2001 From: Dan Liebault Date: Wed, 18 Feb 2026 10:15:18 +0100 Subject: [PATCH 04/18] update readme --- README.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.org b/README.org index 17c8fb5..bff0136 100644 --- a/README.org +++ b/README.org @@ -15,7 +15,7 @@ Zig bindings for [[https://curl.haxx.se/libcurl/][libcurl]], a free and easy-to- The vendored libraries consist of: | Library | Version | |---------+---------| -| libcurl | [[https://github.com/curl/curl/tree/curl-8_8_0][8.8.0]] | +| libcurl | [[https://github.com/curl/curl/tree/curl-8_18_0][8.18.0]] | | zlib | [[https://github.com/madler/zlib/tree/v1.3.1][1.3.1]] | | mbedtls | [[https://github.com/Mbed-TLS/mbedtls/tree/v3.6.0][3.6.0]] | From f038421d50b09606c03c05dabd0a1f1f7c080d04 Mon Sep 17 00:00:00 2001 From: Dan Liebault Date: Wed, 18 Feb 2026 14:40:05 +0100 Subject: [PATCH 05/18] format error fixed --- libs/curl.zig | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libs/curl.zig b/libs/curl.zig index 9f9df8f..cdd848f 100644 --- a/libs/curl.zig +++ b/libs/curl.zig @@ -202,22 +202,22 @@ pub fn create(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.bui lib.root_module.addCMacro("_FILE_OFFSET_BITS", "64"); // define CURL_OS based on target platform - // current insupported platform : Itanium, RiscOS, OS/400 - switch(target.result.os.tag) { + // current insupported platform : Itanium, RiscOS, OS/400 + switch (target.result.os.tag) { .windows => { - switch(target.result.cpu.arch) { + switch (target.result.cpu.arch) { .x86 => lib.root_module.addCMacro("CURL_OS", "i386-pc-win32"), .x86_64 => lib.root_module.addCMacro("CURL_OS", "x86_64-pc-win32"), .thumb => lib.root_module.addCMacro("CURL_OS", "thumbv7a-pc-win32"), .aarch64 => lib.root_module.addCMacro("CURL_OS", "aarch64-pc-win32"), - else => lib.root_module.addCMacro("CURL_OS", "unknown-pc-win32") + else => lib.root_module.addCMacro("CURL_OS", "unknown-pc-win32"), } }, .linux => { - switch(target.result.cpu.arch) { + switch (target.result.cpu.arch) { .x86_64 => lib.root_module.addCMacro("CURL_OS", "x86_64-pc-linux-gnu"), .aarch64 => lib.root_module.addCMacro("CURL_OS", "aarch64-pc-linux-gnu"), - else => lib.root_module.addCMacro("CURL_OS", "Linux") + else => lib.root_module.addCMacro("CURL_OS", "Linux"), } }, .macos => lib.root_module.addCMacro("CURL_OS", "mac"), @@ -228,7 +228,7 @@ pub fn create(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.bui const system_name = std.fmt.allocPrint(b.allocator, "{s}-pc-{s}", .{ arch, os }) catch "unknown-pc-unknown"; lib.root_module.addCMacro("CURL_OS", system_name); - } + }, } return lib; From d1f68439513a6bce558679e9c8280253ff0e0401 Mon Sep 17 00:00:00 2001 From: Dan Liebault Date: Thu, 19 Feb 2026 09:58:08 +0100 Subject: [PATCH 06/18] macro is text litteral and needs to be escaped --- libs/curl.zig | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/libs/curl.zig b/libs/curl.zig index cdd848f..b850c9d 100644 --- a/libs/curl.zig +++ b/libs/curl.zig @@ -206,27 +206,27 @@ pub fn create(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.bui switch (target.result.os.tag) { .windows => { switch (target.result.cpu.arch) { - .x86 => lib.root_module.addCMacro("CURL_OS", "i386-pc-win32"), - .x86_64 => lib.root_module.addCMacro("CURL_OS", "x86_64-pc-win32"), - .thumb => lib.root_module.addCMacro("CURL_OS", "thumbv7a-pc-win32"), - .aarch64 => lib.root_module.addCMacro("CURL_OS", "aarch64-pc-win32"), - else => lib.root_module.addCMacro("CURL_OS", "unknown-pc-win32"), + .x86 => lib.root_module.addCMacro("CURL_OS", "\"i386-pc-win32\""), + .x86_64 => lib.root_module.addCMacro("CURL_OS", "\"x86_64-pc-win32\""), + .thumb => lib.root_module.addCMacro("CURL_OS", "\"thumbv7a-pc-win32\""), + .aarch64 => lib.root_module.addCMacro("CURL_OS", "\"aarch64-pc-win32\""), + else => lib.root_module.addCMacro("CURL_OS", "\"unknown-pc-win32\""), } }, .linux => { switch (target.result.cpu.arch) { - .x86_64 => lib.root_module.addCMacro("CURL_OS", "x86_64-pc-linux-gnu"), - .aarch64 => lib.root_module.addCMacro("CURL_OS", "aarch64-pc-linux-gnu"), - else => lib.root_module.addCMacro("CURL_OS", "Linux"), + .x86_64 => lib.root_module.addCMacro("CURL_OS", "\"x86_64-pc-linux-gnu\""), + .aarch64 => lib.root_module.addCMacro("CURL_OS", "\"aarch64-pc-linux-gnu\""), + else => lib.root_module.addCMacro("CURL_OS", "\"Linux\""), } }, - .macos => lib.root_module.addCMacro("CURL_OS", "mac"), - .freebsd => lib.root_module.addCMacro("CURL_OS", "freebsd"), + .macos => lib.root_module.addCMacro("CURL_OS", "\"mac\""), + .freebsd => lib.root_module.addCMacro("CURL_OS", "\"freebsd\""), else => { const arch = @tagName(target.result.cpu.arch); const os = @tagName(target.result.os.tag); - const system_name = std.fmt.allocPrint(b.allocator, "{s}-pc-{s}", .{ arch, os }) catch "unknown-pc-unknown"; + const system_name = std.fmt.allocPrint(b.allocator, "\"{s}-pc-{s}\"", .{ arch, os }) catch "\"unknown-pc-unknown\""; lib.root_module.addCMacro("CURL_OS", system_name); }, } From 58f3e6f1538c834120b8b8888ed3f35b2d0d9fb1 Mon Sep 17 00:00:00 2001 From: Dan Liebault Date: Fri, 20 Feb 2026 15:14:56 +0100 Subject: [PATCH 07/18] update curl deps --- build.zig.zon | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/build.zig.zon b/build.zig.zon index 12d2f6b..d10c06d 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -11,6 +11,11 @@ "LICENSE", }, .dependencies = .{ + // https://github.com/curl/curl/releases/tag/curl-8_18_0 + .curl = .{ + .url = "https://github.com/curl/curl/releases/download/curl-8_18_0/curl-8.18.0.tar.gz", + .hash = "N-V-__8AALp9QAGn6CCHZ6fK_FfMyGtG824LSHYHHasM3w-y", + }, // https://github.com/madler/zlib/releases/tag/v1.3.1 .zlib = .{ .url = "https://github.com/madler/zlib/releases/download/v1.3.1/zlib-1.3.1.tar.gz", @@ -22,9 +27,5 @@ .hash = "N-V-__8AAFrtpQI1j9eOv7aN3lt3eH1TJfH4npAdRIrg2gGH", .lazy = true, }, - .curl = .{ - .url = "https://github.com/curl/curl/releases/download/curl-8_18_0/curl-8.18.0.tar.gz", - .hash = "N-V-__8AALp9QAGn6CCHZ6fK_FfMyGtG824LSHYHHasM3w-y", - }, }, } From 90ec2a0180b237ad96d1dd370011022a7b0242b0 Mon Sep 17 00:00:00 2001 From: Dan Liebault Date: Fri, 20 Feb 2026 15:23:03 +0100 Subject: [PATCH 08/18] CURL_OS resolve is now a function --- libs/curl.zig | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/libs/curl.zig b/libs/curl.zig index b850c9d..7d74445 100644 --- a/libs/curl.zig +++ b/libs/curl.zig @@ -201,37 +201,44 @@ pub fn create(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.bui lib.root_module.addCMacro("USE_UNIX_SOCKETS", "1"); lib.root_module.addCMacro("_FILE_OFFSET_BITS", "64"); - // define CURL_OS based on target platform - // current insupported platform : Itanium, RiscOS, OS/400 + const system_name = getCurlOS(b.allocator, target); + const curl_os = std.fmt.allocPrint(b.allocator, "\"{s}\"", .{ system_name }) catch "\"unknown-pc-unknown\""; + + lib.root_module.addCMacro("CURL_OS", curl_os); + + return lib; +} + +// define CURL_OS based on target platform +// current insupported platform : Itanium, RiscOS, OS/400 +fn getCurlOS(allocator: std.mem.Allocator, target: std.Build.ResolvedTarget) []const u8 { switch (target.result.os.tag) { .windows => { switch (target.result.cpu.arch) { - .x86 => lib.root_module.addCMacro("CURL_OS", "\"i386-pc-win32\""), - .x86_64 => lib.root_module.addCMacro("CURL_OS", "\"x86_64-pc-win32\""), - .thumb => lib.root_module.addCMacro("CURL_OS", "\"thumbv7a-pc-win32\""), - .aarch64 => lib.root_module.addCMacro("CURL_OS", "\"aarch64-pc-win32\""), - else => lib.root_module.addCMacro("CURL_OS", "\"unknown-pc-win32\""), + .x86 => return "i386-pc-win32", + .x86_64 => return "x86_64-pc-win32", + .thumb => return "thumbv7a-pc-win32", + .aarch64 => return "aarch64-pc-win32", + else => return "unknown-pc-win32", } }, .linux => { switch (target.result.cpu.arch) { - .x86_64 => lib.root_module.addCMacro("CURL_OS", "\"x86_64-pc-linux-gnu\""), - .aarch64 => lib.root_module.addCMacro("CURL_OS", "\"aarch64-pc-linux-gnu\""), - else => lib.root_module.addCMacro("CURL_OS", "\"Linux\""), + .x86_64 => return "x86_64-pc-linux-gnu", + .aarch64 => return "aarch64-pc-linux-gnu", + else => return "Linux", } }, - .macos => lib.root_module.addCMacro("CURL_OS", "\"mac\""), - .freebsd => lib.root_module.addCMacro("CURL_OS", "\"freebsd\""), + .macos => return "mac", + .freebsd => return "freebsd", else => { const arch = @tagName(target.result.cpu.arch); const os = @tagName(target.result.os.tag); - const system_name = std.fmt.allocPrint(b.allocator, "\"{s}-pc-{s}\"", .{ arch, os }) catch "\"unknown-pc-unknown\""; - lib.root_module.addCMacro("CURL_OS", system_name); + const system_name = std.fmt.allocPrint(allocator, "\"{s}-pc-{s}\"", .{ arch, os }) catch "\"unknown-pc-unknown\""; + return system_name; }, } - - return lib; } const srcs = &.{ From 077ec3a3b39e89badf817470037355589a5d90da Mon Sep 17 00:00:00 2001 From: Dan Liebault Date: Fri, 20 Feb 2026 15:25:47 +0100 Subject: [PATCH 09/18] zig fmt --- libs/curl.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/curl.zig b/libs/curl.zig index 7d74445..75e8ec5 100644 --- a/libs/curl.zig +++ b/libs/curl.zig @@ -202,7 +202,7 @@ pub fn create(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.bui lib.root_module.addCMacro("_FILE_OFFSET_BITS", "64"); const system_name = getCurlOS(b.allocator, target); - const curl_os = std.fmt.allocPrint(b.allocator, "\"{s}\"", .{ system_name }) catch "\"unknown-pc-unknown\""; + const curl_os = std.fmt.allocPrint(b.allocator, "\"{s}\"", .{system_name}) catch "\"unknown-pc-unknown\""; lib.root_module.addCMacro("CURL_OS", curl_os); From b14947c27de782f8f33dd5ae6a3487a798299996 Mon Sep 17 00:00:00 2001 From: Dan Liebault Date: Fri, 20 Feb 2026 15:26:47 +0100 Subject: [PATCH 10/18] enable windows ci --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index d782cab..73641ad 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -20,7 +20,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@v4 - uses: mlugg/setup-zig@v2 From aaf0a453cbdcd88d92a52fd4e7b8472bea27246e Mon Sep 17 00:00:00 2001 From: Dan Liebault Date: Fri, 20 Feb 2026 15:30:54 +0100 Subject: [PATCH 11/18] disable windows ci --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 73641ad..d782cab 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -20,7 +20,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + os: [ubuntu-latest, macos-latest] steps: - uses: actions/checkout@v4 - uses: mlugg/setup-zig@v2 From 3e4f91bced95ffa3e78d9157b8f84e0942c86110 Mon Sep 17 00:00:00 2001 From: Dan Liebault Date: Sat, 21 Feb 2026 12:27:42 +0100 Subject: [PATCH 12/18] set curl deps to lazy --- build.zig.zon | 1 + 1 file changed, 1 insertion(+) diff --git a/build.zig.zon b/build.zig.zon index d10c06d..3adae2e 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -15,6 +15,7 @@ .curl = .{ .url = "https://github.com/curl/curl/releases/download/curl-8_18_0/curl-8.18.0.tar.gz", .hash = "N-V-__8AALp9QAGn6CCHZ6fK_FfMyGtG824LSHYHHasM3w-y", + .lazy = true, }, // https://github.com/madler/zlib/releases/tag/v1.3.1 .zlib = .{ From ff6a8c98d183b7e33c4b26e4c6058e5e3c07d383 Mon Sep 17 00:00:00 2001 From: Dan Liebault Date: Sat, 21 Feb 2026 12:30:24 +0100 Subject: [PATCH 13/18] windows ci test --- .github/workflows/CI.yml | 15 ++++++++++++++- Makefile | 6 +++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index d782cab..b79384c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -14,13 +14,26 @@ on: - '**.yml' jobs: + fmt: + timeout-minutes: 10 + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + steps: + - uses: actions/checkout@v4 + - uses: mlugg/setup-zig@v2 + - name: Run fmt + run: | + zig fmt --check . test-vendor: timeout-minutes: 10 runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@v4 - uses: mlugg/setup-zig@v2 diff --git a/Makefile b/Makefile index d9c34ff..466ac1d 100644 --- a/Makefile +++ b/Makefile @@ -14,10 +14,10 @@ run: zig build run-multi -freference-trace $(ARGS) zig build run-header -freference-trace $(ARGS) -lint: - zig fmt --check . +# lint: +# zig fmt --check . -test: lint +test: zig build test $(ARGS) docs: From 3a5c64f658b2bcd8c6481a58021c4df4ded09ee6 Mon Sep 17 00:00:00 2001 From: Dan Liebault Date: Sat, 21 Feb 2026 12:37:02 +0100 Subject: [PATCH 14/18] use makefile for linting --- .github/workflows/CI.yml | 4 ++-- Makefile | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index b79384c..c485d09 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -24,9 +24,9 @@ jobs: steps: - uses: actions/checkout@v4 - uses: mlugg/setup-zig@v2 - - name: Run fmt + - name: Run linter run: | - zig fmt --check . + make lint test-vendor: timeout-minutes: 10 runs-on: ${{ matrix.os }} diff --git a/Makefile b/Makefile index 466ac1d..723d85c 100644 --- a/Makefile +++ b/Makefile @@ -14,8 +14,8 @@ run: zig build run-multi -freference-trace $(ARGS) zig build run-header -freference-trace $(ARGS) -# lint: -# zig fmt --check . +lint: + zig fmt --check . test: zig build test $(ARGS) From 7328a1fe06f7de437c5ddb595080a43786f38385 Mon Sep 17 00:00:00 2001 From: jiacai2050 Date: Sun, 22 Feb 2026 15:00:10 +0800 Subject: [PATCH 15/18] Refactor: Integrate linting into CI and add `make fix` command --- .github/workflows/CI.yml | 17 ++++------------- Makefile | 5 ++++- libs/curl.zig | 3 +-- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index c485d09..4003515 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -14,19 +14,6 @@ on: - '**.yml' jobs: - fmt: - timeout-minutes: 10 - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - steps: - - uses: actions/checkout@v4 - - uses: mlugg/setup-zig@v2 - - name: Run linter - run: | - make lint test-vendor: timeout-minutes: 10 runs-on: ${{ matrix.os }} @@ -37,6 +24,10 @@ jobs: steps: - uses: actions/checkout@v4 - uses: mlugg/setup-zig@v2 + - name: Run lint + if: matrix.os == 'ubuntu-latest' + run: | + make lint - name: Run tests run: | make test run diff --git a/Makefile b/Makefile index 723d85c..561de7a 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,9 @@ run: zig build run-multi -freference-trace $(ARGS) zig build run-header -freference-trace $(ARGS) +fix: + zig fmt . + lint: zig fmt --check . @@ -30,4 +33,4 @@ clean: serve: cd server && go run main.go -.PHONY: run lint test docs clean serve +.PHONY: run fix lint test docs clean serve diff --git a/libs/curl.zig b/libs/curl.zig index 75e8ec5..d018453 100644 --- a/libs/curl.zig +++ b/libs/curl.zig @@ -202,8 +202,7 @@ pub fn create(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.bui lib.root_module.addCMacro("_FILE_OFFSET_BITS", "64"); const system_name = getCurlOS(b.allocator, target); - const curl_os = std.fmt.allocPrint(b.allocator, "\"{s}\"", .{system_name}) catch "\"unknown-pc-unknown\""; - + const curl_os = std.fmt.allocPrint(b.allocator, "\"{s}\"", .{system_name}) catch unreachable; lib.root_module.addCMacro("CURL_OS", curl_os); return lib; From 630c71a2b9b583b66391df9a95a5da21e9ca9168 Mon Sep 17 00:00:00 2001 From: Jiacai Liu Date: Sun, 22 Feb 2026 17:57:08 +0800 Subject: [PATCH 16/18] Update MultiPart.zig Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/MultiPart.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MultiPart.zig b/src/MultiPart.zig index 9b7f06b..495da38 100644 --- a/src/MultiPart.zig +++ b/src/MultiPart.zig @@ -78,7 +78,7 @@ pub const NonCopyingData = struct { } pub fn seek(user_data: ?*anyopaque, offset: c_longlong, origin: c_int) callconv(.c) c_int { - var source: *DataWithOffset = @ptrCast(@alignCast(user_data orelse return c.CURL_READFUNC_ABORT)); + var source: *DataWithOffset = @ptrCast(@alignCast(user_data orelse return c.CURL_SEEKFUNC_FAIL)); const new_pos = switch (origin) { c.SEEK_SET => offset, c.SEEK_CUR => offset + @as(c_long, @intCast(source.offset)), From 274036df6b2918040b15ef1f4f21e61e9ecdf172 Mon Sep 17 00:00:00 2001 From: Jiacai Liu Date: Sun, 22 Feb 2026 17:58:04 +0800 Subject: [PATCH 17/18] Update curl.zig Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- libs/curl.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/curl.zig b/libs/curl.zig index d018453..80fbe52 100644 --- a/libs/curl.zig +++ b/libs/curl.zig @@ -209,7 +209,7 @@ pub fn create(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.bui } // define CURL_OS based on target platform -// current insupported platform : Itanium, RiscOS, OS/400 +// current unsupported platform : Itanium, RiscOS, OS/400 fn getCurlOS(allocator: std.mem.Allocator, target: std.Build.ResolvedTarget) []const u8 { switch (target.result.os.tag) { .windows => { From 039f624792b2ef4eb05ec6e120d245589be5b614 Mon Sep 17 00:00:00 2001 From: jiacai2050 Date: Sun, 22 Feb 2026 18:13:59 +0800 Subject: [PATCH 18/18] refactor(curl): improve OS detection and type safety - `libs/curl.zig`: Refactor `getCurlOS` to return an optional `[]const u8`. The logic for constructing the generic "arch-pc-os" system name for unknown platforms is now handled directly in the `create` function, rather than within `getCurlOS`. This makes `getCurlOS` responsible solely for identifying specific, known operating system names. - `src/MultiPart.zig`: Update the `offset` parameter in the `NonCopyingData.seek` callback to use `c.curl_off_t`. This improves type safety and aligns with the `curl` library's defined types for file offsets. --- libs/curl.zig | 14 +++++++------- src/MultiPart.zig | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libs/curl.zig b/libs/curl.zig index 80fbe52..8d29b51 100644 --- a/libs/curl.zig +++ b/libs/curl.zig @@ -201,7 +201,11 @@ pub fn create(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.bui lib.root_module.addCMacro("USE_UNIX_SOCKETS", "1"); lib.root_module.addCMacro("_FILE_OFFSET_BITS", "64"); - const system_name = getCurlOS(b.allocator, target); + const system_name = getCurlOS(target) orelse blk: { + const arch = @tagName(target.result.cpu.arch); + const os = @tagName(target.result.os.tag); + break :blk std.fmt.allocPrint(b.allocator, "{s}-pc-{s}", .{ arch, os }) catch unreachable; + }; const curl_os = std.fmt.allocPrint(b.allocator, "\"{s}\"", .{system_name}) catch unreachable; lib.root_module.addCMacro("CURL_OS", curl_os); @@ -210,7 +214,7 @@ pub fn create(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.bui // define CURL_OS based on target platform // current unsupported platform : Itanium, RiscOS, OS/400 -fn getCurlOS(allocator: std.mem.Allocator, target: std.Build.ResolvedTarget) []const u8 { +fn getCurlOS(target: std.Build.ResolvedTarget) ?[]const u8 { switch (target.result.os.tag) { .windows => { switch (target.result.cpu.arch) { @@ -231,11 +235,7 @@ fn getCurlOS(allocator: std.mem.Allocator, target: std.Build.ResolvedTarget) []c .macos => return "mac", .freebsd => return "freebsd", else => { - const arch = @tagName(target.result.cpu.arch); - const os = @tagName(target.result.os.tag); - - const system_name = std.fmt.allocPrint(allocator, "\"{s}-pc-{s}\"", .{ arch, os }) catch "\"unknown-pc-unknown\""; - return system_name; + return null; }, } } diff --git a/src/MultiPart.zig b/src/MultiPart.zig index 495da38..64b6d39 100644 --- a/src/MultiPart.zig +++ b/src/MultiPart.zig @@ -77,11 +77,11 @@ pub const NonCopyingData = struct { return to_read; } - pub fn seek(user_data: ?*anyopaque, offset: c_longlong, origin: c_int) callconv(.c) c_int { + pub fn seek(user_data: ?*anyopaque, offset: c.curl_off_t, origin: c_int) callconv(.c) c_int { var source: *DataWithOffset = @ptrCast(@alignCast(user_data orelse return c.CURL_SEEKFUNC_FAIL)); const new_pos = switch (origin) { c.SEEK_SET => offset, - c.SEEK_CUR => offset + @as(c_long, @intCast(source.offset)), + c.SEEK_CUR => offset + @as(c.curl_off_t, @intCast(source.offset)), else => return c.CURL_SEEKFUNC_FAIL, }; if (new_pos < 0) {