From 5a70defcff073dd34056346d3c98791c4e338f64 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Thu, 21 Dec 2023 15:43:37 +0900 Subject: [PATCH] update readme --- README.org | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/README.org b/README.org index 9857aea..10bcdc2 100644 --- a/README.org +++ b/README.org @@ -16,14 +16,21 @@ This package is in its early stage, although the core functionality works right * Usage #+begin_src zig -const Easy = @import("curl").Easy; +const curl = @import("curl"); pub fn main() !void { + try curl.global_init(); + defer curl.global_deinit(); + + // Use zig's std.crypto.Certificate.Bundle + // Required if using builtin libcurl if TLS connections are required + try curl.refresh_ca_bundle(); + var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); defer arena.deinit(); const allocator = arena.allocator(); - const easy = try Easy.init(allocator); + const easy = try curl.Easy.init(allocator); defer easy.deinit(); const resp = try easy.get("http://httpbin.org/anything"); @@ -66,8 +73,9 @@ const curl = b.dependency("curl", .{}); // add curl module to an executable. exe.addModule("curl", curl.module("curl")); -// Note: since this package doesn't bundle static libcurl, -// so users need to link to system-wide libcurl. +// For builtin libcurl +exe.linkLibrary(curl.artifact("curl")); +// For system-wide libcurl exe.linkSystemLibrary("curl"); exe.linkLibC(); #+end_src