aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/allocators.zig24
-rw-r--r--src/allocators/mimalloc.zig45
-rw-r--r--src/analytics/analytics_thread.zig48
-rw-r--r--src/api/schema.peechy2
-rw-r--r--src/bindgen.zig3
-rw-r--r--src/builder.zig33
-rw-r--r--src/bun_js.zig5
-rw-r--r--src/bundler.zig10
-rw-r--r--src/cli.zig237
-rw-r--r--src/cli/add_command.zig8
-rw-r--r--src/cli/create_command.zig164
-rw-r--r--src/cli/install_command.zig8
-rw-r--r--src/cli/install_completions_command.zig1
-rw-r--r--src/cli/package_manager_command.zig24
-rw-r--r--src/cli/remove_command.zig8
-rw-r--r--src/cli/upgrade_command.zig48
m---------src/deps/boringssl0
-rw-r--r--src/deps/boringssl.translated.zig18877
-rw-r--r--src/deps/boringssl.zig47
m---------src/deps/mimalloc0
m---------src/deps/s2n-tls0
-rw-r--r--src/env.zig4
-rw-r--r--src/fallback.version2
-rw-r--r--src/fs.zig19
-rw-r--r--src/global.zig83
-rw-r--r--src/http.zig44
-rw-r--r--src/http/network_thread.zig82
-rw-r--r--src/http_client.zig870
-rw-r--r--src/http_client_async.zig2190
-rw-r--r--src/identity_context.zig23
-rw-r--r--src/install/bin.zig287
-rw-r--r--src/install/bit_set.zig1296
-rw-r--r--src/install/dependency.zig617
-rw-r--r--src/install/extract_tarball.zig281
-rw-r--r--src/install/install-scripts-allowlist.txt4
-rw-r--r--src/install/install.zig6707
-rw-r--r--src/install/integrity.zig203
-rw-r--r--src/install/npm.zig1383
-rw-r--r--src/install/repository.zig67
-rw-r--r--src/install/resolution.zig296
-rw-r--r--src/install/semver.zig1962
-rw-r--r--src/io/fifo.zig104
-rw-r--r--src/io/io_darwin.zig781
-rw-r--r--src/io/io_linux.zig937
-rw-r--r--src/io/time.zig64
-rw-r--r--src/javascript/jsc/JavascriptCore.zig2
-rw-r--r--src/javascript/jsc/api/router.zig4
-rw-r--r--src/javascript/jsc/base.zig2
-rw-r--r--src/javascript/jsc/bindings/ZigGlobalObject.cpp15
-rw-r--r--src/javascript/jsc/bindings/ZigGlobalObject.h28
-rw-r--r--src/javascript/jsc/bindings/bindings.cpp6
-rw-r--r--src/javascript/jsc/bindings/bindings.zig20
-rw-r--r--src/javascript/jsc/bindings/exports.zig9
-rw-r--r--src/javascript/jsc/bindings/headers-cpp.h2
-rw-r--r--src/javascript/jsc/bindings/headers-handwritten.h1
-rw-r--r--src/javascript/jsc/bindings/headers.h8
-rw-r--r--src/javascript/jsc/bindings/headers.zig2
-rw-r--r--src/javascript/jsc/javascript.zig94
-rw-r--r--src/javascript/jsc/webcore/response.zig341
-rw-r--r--src/js_ast.zig93
-rw-r--r--src/js_lexer_tables.zig4
-rw-r--r--src/json_parser.zig198
-rw-r--r--src/libarchive/libarchive.zig17
-rw-r--r--src/lock.zig4
-rw-r--r--src/main.zig2
-rw-r--r--src/memory_allocator.zig3
-rw-r--r--src/pool.zig39
-rw-r--r--src/resolver/package_json.zig1
-rw-r--r--src/runtime.version2
-rw-r--r--src/s2n.zig793
-rw-r--r--src/string_immutable.zig66
-rw-r--r--src/string_mutable.zig4
-rw-r--r--src/tagged_pointer.zig2
-rw-r--r--src/thread_pool.zig827
-rw-r--r--src/which_npm_client.zig93
-rw-r--r--src/zlib.zig12
76 files changed, 38396 insertions, 2196 deletions
diff --git a/src/allocators.zig b/src/allocators.zig
index 8d1788f51..c365e273c 100644
--- a/src/allocators.zig
+++ b/src/allocators.zig
@@ -247,6 +247,10 @@ pub fn BSSStringList(comptime _count: usize, comptime _item_length: usize) type
// only need the mutex on append
var mutex: Mutex = undefined;
+ const EmptyType = struct {
+ len: usize = 0,
+ };
+
pub fn init(allocator: *std.mem.Allocator) *Self {
if (!loaded) {
instance = Self{
@@ -277,6 +281,20 @@ pub fn BSSStringList(comptime _count: usize, comptime _item_length: usize) type
return constStrToU8(appended);
}
+ pub fn getMutable(self: *Self, len: usize) ![]u8 {
+ return try self.appendMutable(EmptyType, EmptyType{ .len = len });
+ }
+
+ pub fn printWithType(self: *Self, comptime fmt: []const u8, comptime Args: type, args: Args) ![]const u8 {
+ var buf = try self.appendMutable(EmptyType, EmptyType{ .len = std.fmt.count(fmt, args) + 1 });
+ buf[buf.len - 1] = 0;
+ return std.fmt.bufPrint(buf.ptr[0 .. buf.len - 1], fmt, args) catch unreachable;
+ }
+
+ pub fn print(self: *Self, comptime fmt: []const u8, args: anytype) ![]const u8 {
+ return try printWithType(self, fmt, @TypeOf(args), args);
+ }
+
pub fn append(self: *Self, comptime AppendType: type, _value: AppendType) ![]const u8 {
mutex.lock();
defer mutex.unlock();
@@ -307,7 +325,7 @@ pub fn BSSStringList(comptime _count: usize, comptime _item_length: usize) type
) ![]const u8 {
const value_len: usize = brk: {
switch (comptime AppendType) {
- []const u8, []u8, [:0]const u8, [:0]u8 => {
+ EmptyType, []const u8, []u8, [:0]const u8, [:0]u8 => {
break :brk _value.len;
},
else => {
@@ -327,6 +345,9 @@ pub fn BSSStringList(comptime _count: usize, comptime _item_length: usize) type
backing_buf_used += value_len;
switch (AppendType) {
+ EmptyType => {
+ backing_buf[backing_buf_used - 1] = 0;
+ },
[]const u8, []u8, [:0]const u8, [:0]u8 => {
std.mem.copy(u8, backing_buf[start .. backing_buf_used - 1], _value);
backing_buf[backing_buf_used - 1] = 0;
@@ -346,6 +367,7 @@ pub fn BSSStringList(comptime _count: usize, comptime _item_length: usize) type
var value_buf = try self.allocator.alloc(u8, value_len);
switch (comptime AppendType) {
+ EmptyType => {},
[]const u8, []u8, [:0]const u8, [:0]u8 => {
std.mem.copy(u8, value_buf, _value);
},
diff --git a/src/allocators/mimalloc.zig b/src/allocators/mimalloc.zig
index ed0a64907..f3e994c78 100644
--- a/src/allocators/mimalloc.zig
+++ b/src/allocators/mimalloc.zig
@@ -103,29 +103,28 @@ pub extern fn mi_reserve_huge_os_pages_at(pages: usize, numa_node: c_int, timeou
pub extern fn mi_reserve_os_memory(size: usize, commit: bool, allow_large: bool) c_int;
pub extern fn mi_manage_os_memory(start: ?*c_void, size: usize, is_committed: bool, is_large: bool, is_zero: bool, numa_node: c_int) bool;
pub extern fn mi_reserve_huge_os_pages(pages: usize, max_secs: f64, pages_reserved: [*c]usize) c_int;
-pub const mi_option_show_errors: c_int = 0;
-pub const mi_option_show_stats: c_int = 1;
-pub const mi_option_verbose: c_int = 2;
-pub const mi_option_eager_commit: c_int = 3;
-pub const mi_option_eager_region_commit: c_int = 4;
-pub const mi_option_reset_decommits: c_int = 5;
-pub const mi_option_large_os_pages: c_int = 6;
-pub const mi_option_reserve_huge_os_pages: c_int = 7;
-pub const mi_option_reserve_os_memory: c_int = 8;
-pub const mi_option_segment_cache: c_int = 9;
-pub const mi_option_page_reset: c_int = 10;
-pub const mi_option_abandoned_page_reset: c_int = 11;
-pub const mi_option_segment_reset: c_int = 12;
-pub const mi_option_eager_commit_delay: c_int = 13;
-pub const mi_option_reset_delay: c_int = 14;
-pub const mi_option_use_numa_nodes: c_int = 15;
-pub const mi_option_limit_os_alloc: c_int = 16;
-pub const mi_option_os_tag: c_int = 17;
-pub const mi_option_max_errors: c_int = 18;
-pub const mi_option_max_warnings: c_int = 19;
-pub const _mi_option_last: c_int = 20;
-pub const enum_mi_option_e = c_uint;
-pub const mi_option_t = enum_mi_option_e;
+pub const mi_option_t = enum(c_uint) {
+ show_errors = 0,
+ show_stats = 1,
+ verbose = 2,
+ eager_commit = 3,
+ eager_region_commit = 4,
+ reset_decommits = 5,
+ large_os_pages = 6,
+ reserve_huge_os_pages = 7,
+ reserve_os_memory = 8,
+ segment_cache = 9,
+ page_reset = 10,
+ abandoned_page_reset = 11,
+ segment_reset = 12,
+ eager_commit_delay = 13,
+ reset_delay = 14,
+ use_numa_nodes = 15,
+ limit_os_alloc = 16,
+ os_tag = 17,
+ max_errors = 18,
+ max_warnings = 19,
+};
pub extern fn mi_option_is_enabled(option: mi_option_t) bool;
pub extern fn mi_option_enable(option: mi_option_t) void;
pub extern fn mi_option_disable(option: mi_option_t) void;
diff --git a/src/analytics/analytics_thread.zig b/src/analytics/analytics_thread.zig
index e45359ddb..870dec5a5 100644
--- a/src/analytics/analytics_thread.zig
+++ b/src/analytics/analytics_thread.zig
@@ -2,7 +2,8 @@ usingnamespace @import("../global.zig");
const sync = @import("../sync.zig");
const std = @import("std");
-const HTTPClient = @import("../http_client.zig");
+const HTTP = @import("http");
+const NetworkThread = @import("network_thread");
const URL = @import("../query_string_map.zig").URL;
const Fs = @import("../fs.zig");
const Analytics = @import("./analytics_schema.zig").analytics;
@@ -349,11 +350,24 @@ fn readloop() anyerror!void {
defer Output.flush();
thread.setName("Analytics") catch {};
- var event_list = EventList.init();
- event_list.client.verbose = FeatureFlags.verbose_analytics;
- event_list.client.header_entries.append(default_allocator, header_entry) catch unreachable;
- event_list.client.header_buf = headers_buf;
-
+ var event_list = try default_allocator.create(EventList);
+ event_list.* = EventList.init();
+
+ var headers_entries: Headers.Entries = Headers.Entries{};
+ headers_entries.append(default_allocator, header_entry) catch unreachable;
+ event_list.async_http = HTTP.AsyncHTTP.init(
+ default_allocator,
+ .POST,
+ URL.parse(Environment.analytics_url),
+ headers_entries,
+ headers_buf,
+ &event_list.out_buffer,
+ &event_list.in_buffer,
+ std.time.ns_per_ms * 10000,
+ ) catch return;
+
+ event_list.async_http.client.verbose = FeatureFlags.verbose_analytics;
+ NetworkThread.init() catch unreachable;
// everybody's random should be random
while (true) {
// Wait for the next event by blocking
@@ -372,24 +386,18 @@ fn readloop() anyerror!void {
pub const EventList = struct {
header: Analytics.EventListHeader,
events: std.ArrayList(Event),
- client: HTTPClient,
+ async_http: HTTP.AsyncHTTP,
out_buffer: MutableString,
- in_buffer: std.ArrayList(u8),
+ in_buffer: MutableString,
pub fn init() EventList {
random = std.rand.DefaultPrng.init(@intCast(u64, std.time.milliTimestamp()));
return EventList{
.header = GenerateHeader.generate(),
.events = std.ArrayList(Event).init(default_allocator),
- .in_buffer = std.ArrayList(u8).init(default_allocator),
- .client = HTTPClient.init(
- default_allocator,
- .POST,
- URL.parse(Environment.analytics_url),
- Headers.Entries{},
- "",
- ),
+ .in_buffer = MutableString.init(default_allocator, 1024) catch unreachable,
+ .async_http = undefined,
.out_buffer = MutableString.init(default_allocator, 0) catch unreachable,
};
}
@@ -408,9 +416,9 @@ pub const EventList = struct {
pub var is_stuck = false;
var stuck_count: u8 = 0;
fn _flush(this: *EventList) !void {
- this.in_buffer.clearRetainingCapacity();
+ this.in_buffer.reset();
- const AnalyticsWriter = Writer(*std.ArrayList(u8).Writer);
+ const AnalyticsWriter = Writer(*MutableString.Writer);
var in_buffer = &this.in_buffer;
var buffer_writer = in_buffer.writer();
@@ -456,7 +464,7 @@ pub const EventList = struct {
var retry_remaining: usize = 10;
retry: while (retry_remaining > 0) {
- const response = this.client.send(this.in_buffer.items, &this.out_buffer) catch |err| {
+ const response = this.async_http.sendSync() catch |err| {
if (FeatureFlags.verbose_analytics) {
Output.prettyErrorln("[Analytics] failed due to error {s} ({d} retries remain)", .{ @errorName(err), retry_remaining });
}
@@ -490,7 +498,7 @@ pub const EventList = struct {
stuck_count *= @intCast(u8, @boolToInt(retry_remaining == 0));
disabled = disabled or stuck_count > 4;
- this.in_buffer.clearRetainingCapacity();
+ this.in_buffer.reset();
this.out_buffer.reset();
if (comptime FeatureFlags.verbose_analytics) {
diff --git a/src/api/schema.peechy b/src/api/schema.peechy
index 2cc78504a..8afb0f30a 100644
--- a/src/api/schema.peechy
+++ b/src/api/schema.peechy
@@ -536,5 +536,3 @@ struct WebsocketMessageManifestFailure {
Loader loader;
Log log;
}
-
-
diff --git a/src/bindgen.zig b/src/bindgen.zig
new file mode 100644
index 000000000..e76a1ce6d
--- /dev/null
+++ b/src/bindgen.zig
@@ -0,0 +1,3 @@
+pub const bindgen = true;
+
+pub const main = @import("./javascript/jsc/bindings/bindings-generator.zig").main;
diff --git a/src/builder.zig b/src/builder.zig
new file mode 100644
index 000000000..19daa0a20
--- /dev/null
+++ b/src/builder.zig
@@ -0,0 +1,33 @@
+const Allocator = @import("std").mem.Allocator;
+const assert = @import("std").debug.assert;
+const copy = @import("std").mem.copy;
+const io = @import("io");
+pub fn Builder(comptime Type: type) type {
+ return struct {
+ const This = @This();
+
+ len: usize = 0,
+ cap: usize = 0,
+ ptr: ?[*]Type = null,
+
+ pub fn count(this: *This, slice: Type) void {
+ this.cap += slice.len;
+ }
+
+ pub fn allocate(this: *This, allocator: *Allocator) !void {
+ var slice = try allocator.alloc(Type, this.cap);
+ this.ptr = slice.ptr;
+ this.len = 0;
+ }
+
+ pub fn append(this: *This, item: Type) *const Type {
+ assert(this.len <= this.cap); // didn't count everything
+ assert(this.ptr != null); // must call allocate first
+ var result = &this.ptr.?[this.len];
+ result.* = item;
+ this.len += 1;
+ assert(this.len <= this.cap);
+ return result;
+ }
+ };
+}
diff --git a/src/bun_js.zig b/src/bun_js.zig
index e5fb2bcd7..cb1d6c219 100644
--- a/src/bun_js.zig
+++ b/src/bun_js.zig
@@ -68,11 +68,10 @@ pub const Run = struct {
pub fn start(this: *Run) !void {
var promise = try this.vm.loadEntryPoint(this.entry_path);
-
- this.vm.global.vm().drainMicrotasks();
+ this.vm.tick();
while (promise.status(this.vm.global.vm()) == .Pending) {
- this.vm.global.vm().drainMicrotasks();
+ this.vm.tick();
}
if (promise.status(this.vm.global.vm()) == .Rejected) {
diff --git a/src/bundler.zig b/src/bundler.zig
index 9d074366a..54b007c06 100644
--- a/src/bundler.zig
+++ b/src/bundler.zig
@@ -255,10 +255,12 @@ pub const Bundler = struct {
}
}
- if (this.env.map.get("CI")) |IS_CI| {
- if (strings.eqlComptime(IS_CI, "true")) {
- Analytics.is_ci = true;
- }
+ if (this.env.map.get("CI") orelse
+ this.env.map.get("TDDIUM") orelse
+ this.env.map.get("JENKINS_URL") orelse
+ this.env.map.get("bamboo.buildKey")) |IS_CI|
+ {
+ Analytics.is_ci = true;
}
Analytics.disabled = Analytics.disabled or this.env.map.get("HYPERFINE_RANDOMIZED_ENVIRONMENT_OFFSET") != null;
diff --git a/src/cli.zig b/src/cli.zig
index 77a110fab..f876bbf41 100644
--- a/src/cli.zig
+++ b/src/cli.zig
@@ -20,6 +20,7 @@ const resolve_path = @import("./resolver/resolve_path.zig");
const configureTransformOptionsForBun = @import("./javascript/jsc/config.zig").configureTransformOptionsForBun;
const clap = @import("clap");
+const Install = @import("./install/install.zig");
const bundler = @import("bundler.zig");
const DotEnv = @import("./env_loader.zig");
@@ -36,8 +37,13 @@ const CreateCommand = @import("./cli/create_command.zig").CreateCommand;
const CreateListExamplesCommand = @import("./cli/create_command.zig").CreateListExamplesCommand;
const RunCommand = @import("./cli/run_command.zig").RunCommand;
const UpgradeCommand = @import("./cli/upgrade_command.zig").UpgradeCommand;
+const InstallCommand = @import("./cli/install_command.zig").InstallCommand;
+const AddCommand = @import("./cli/add_command.zig").AddCommand;
+const RemoveCommand = @import("./cli/remove_command.zig").RemoveCommand;
+const PackageManagerCommand = @import("./cli/package_manager_command.zig").PackageManagerCommand;
const InstallCompletionsCommand = @import("./cli/install_completions_command.zig").InstallCompletionsCommand;
const ShellCompletions = @import("./cli/shell_completions.zig");
+
var start_time: i128 = undefined;
pub const Cli = struct {
@@ -150,11 +156,6 @@ pub const Arguments = struct {
clap.parseParam("-u, --origin <STR> Rewrite import URLs to start with --origin. Default: \"\"") catch unreachable,
clap.parseParam("-p, --port <STR> Port to serve Bun's dev server on. Default: \"3000\"") catch unreachable,
clap.parseParam("--silent Don't repeat the command for bun run") catch unreachable,
-
- // clap.parseParam("-o, --outdir <STR> Save output to directory (default: \"out\" if none provided and multiple entry points passed)") catch unreachable,
- // clap.parseParam("-r, --resolve <STR> Determine import/require behavior. \"disable\" ignores. \"dev\" bundles node_modules and builds everything else as independent entry points") catch unreachable,
- // clap.parseParam("-r, --resolve <STR> Determine import/require behavior. \"disable\" ignores. \"dev\" bundles node_modules and builds everything else as independent entry points") catch unreachable,
-
clap.parseParam("<POS>... ") catch unreachable,
};
@@ -454,45 +455,69 @@ const HelpCommand = struct {
invalid_command,
};
+ // someone will get mad at me for this
+ pub const packages_to_remove_filler = [_]string{
+ "moment",
+ "underscore",
+ "jquery",
+ "backbone",
+ "redux",
+ "browserify",
+ "webpack",
+ "babel-core",
+ };
+
+ pub const packages_to_add_filler = [_]string{
+ "astro",
+ "react",
+ "next@^12",
+ "tailwindcss",
+ "wrangler@beta",
+ "@compiled/react",
+ "@remix-run/dev",
+ };
+
pub fn printWithReason(comptime reason: Reason) void {
var cwd_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
const cwd = std.os.getcwd(&cwd_buf) catch unreachable;
const dirname = std.fs.path.basename(cwd);
- if (FeatureFlags.dev_only) {
- const fmt =
- \\> <r> <b><green>dev <r><d> ./a.ts ./b.jsx<r> Start a Bun Dev Server
- \\> <r> <b><magenta>bun <r><d> ./a.ts ./b.jsx<r> Bundle dependencies of input files into a <r><magenta>.bun<r>
- \\> <r> <b><green>run <r><d> test <r> Run a package.json script or executable<r>
- \\> <r> <b><cyan>create <r><d>next ./app<r> Start a new project from a template <d>(shorthand: c)<r>
- \\> <r> <b><blue>upgrade <r> Get the latest version of Bun
- \\> <r> <b><d>completions<r> Install shell completions for tab-completion
- \\> <r> <b><d>discord <r> Open Bun's Discord server
- \\> <r> <b><d>help <r> Print this help menu
- \\
- ;
-
- switch (reason) {
- .explicit => Output.pretty("<r><b><magenta>Bun<r>: a fast bundler, transpiler and task runner for web software.\n\n" ++ fmt, .{}),
- .invalid_command => Output.prettyError("<r><red>Uh-oh<r> not sure what to do with that command.\n\n" ++ fmt, .{}),
- }
- } else {
- const fmt =
- \\> <r> <b><white>init<r> Setup Bun in \"{s}\"
- \\> <r> <b><green>dev <r><d> ./a.ts ./b.jsx<r> Start a Bun Dev Server
- \\<d>*<r> <b><cyan>build <r><d> ./a.ts ./b.jsx<r> Make JavaScript-like code runnable & bundle CSS
- \\> <r> <b><cyan>create<r><d> next ./app<r> Start a new project from a template<r>
- \\> <r> <b><magenta>bun <r><d> ./a.ts ./b.jsx<r> Bundle dependencies of input files into a <r><magenta>.bun<r>
- \\> <r> <green>run <r><d> ./a.ts <r> Run a JavaScript-like file with Bun.js
- \\> <r> <b><blue>discord<r> Open Bun's Discord server
- \\> <r> <b><blue>upgrade <r> Get the latest version of Bun
- \\> <r> <b><d>help <r> Print this help menu
- \\
- ;
-
- switch (reason) {
- .explicit => Output.pretty("<r><b><magenta>Bun<r>: a fast bundler, transpiler and task runner for web software.\n\n" ++ fmt, .{dirname}),
- .invalid_command => Output.prettyError("<r><red>Uh-oh<r> not sure what to do with that command.\n\n" ++ fmt, .{dirname}),
- }
+
+ const fmt =
+ \\> <r> <b><green>dev <r><d> ./a.ts ./b.jsx<r> Start a Bun Dev Server
+ \\> <r> <b><magenta>bun <r><d> ./a.ts ./b.jsx<r> Bundle dependencies of input files into a <r><magenta>.bun<r>
+ \\
+ \\> <r> <b><cyan>create <r><d>next ./app<r> Start a new project from a template <d>(bun c)<r>
+ \\> <r> <b><magenta>run <r><d> test <r> Run a package.json script or executable<r>
+ \\> <r> <b><green>install<r> Install dependencies for a package.json <d>(bun i)<r>
+ \\> <r> <b><blue>add <r><d> {s:<16}<r> Add a dependency to package.json <d>(bun a)<r>
+ \\> <r> remove <r><d> {s:<16}<r> Remove a dependency from package.json <d>(bun rm)<r>
+ \\> <r> pm <r> More package manager-related subcommands
+ \\
+ \\> <r> <b><blue>upgrade <r> Get the latest version of Bun
+ \\> <r> <b><d>completions<r> Install shell completions for tab-completion
+ \\> <r> <b><d>discord <r> Open Bun's Discord server
+ \\> <r> <b><d>help <r> Print this help menu
+ \\
+ ;
+
+ var rand = std.rand.DefaultPrng.init(@intCast(u64, @maximum(std.time.milliTimestamp(), 0)));
+ const package_add_i = rand.random.uintAtMost(usize, packages_to_add_filler.len - 1);
+ const package_remove_i = rand.random.uintAtMost(usize, packages_to_remove_filler.len - 1);
+
+ const args = .{
+ packages_to_add_filler[package_add_i],
+ packages_to_remove_filler[package_remove_i],
+ };
+
+ switch (reason) {
+ .explicit => Output.pretty(
+ "<r><b><magenta>Bun<r>: a fast bundler, transpiler, JavaScript Runtime and package manager for web software.\n\n" ++ fmt,
+ args,
+ ),
+ .invalid_command => Output.prettyError(
+ "<r><red>Uh-oh<r> not sure what to do with that command.\n\n" ++ fmt,
+ args,
+ ),
}
Output.flush();
@@ -556,7 +581,7 @@ pub const Command = struct {
.allocator = allocator,
};
- if (comptime command != Command.Tag.CreateCommand) {
+ if (comptime Command.Tag.uses_global_options.get(command)) {
ctx.args = try Arguments.parse(allocator, &ctx, command);
}
@@ -581,42 +606,39 @@ pub const Command = struct {
const first_arg_name = std.mem.span(next_arg);
const RootCommandMatcher = strings.ExactSizeMatcher(16);
- if (comptime FeatureFlags.dev_only) {
- return switch (RootCommandMatcher.match(first_arg_name)) {
- RootCommandMatcher.case("init") => .InitCommand,
- RootCommandMatcher.case("bun") => .BunCommand,
- RootCommandMatcher.case("discord") => .DiscordCommand,
- RootCommandMatcher.case("upgrade") => .UpgradeCommand,
- RootCommandMatcher.case("completions") => .InstallCompletionsCommand,
- RootCommandMatcher.case("getcompletes") => .GetCompletionsCommand,
- RootCommandMatcher.case("c"), RootCommandMatcher.case("create") => .CreateCommand,
-
- RootCommandMatcher.case("b"), RootCommandMatcher.case("build") => .BuildCommand,
- RootCommandMatcher.case("r"), RootCommandMatcher.case("run") => .RunCommand,
- RootCommandMatcher.case("d"), RootCommandMatcher.case("dev") => .DevCommand,
-
- RootCommandMatcher.case("help") => .HelpCommand,
- else => .AutoCommand,
- };
- } else {
- return switch (RootCommandMatcher.match(first_arg_name)) {
- RootCommandMatcher.case("init") => .InitCommand,
- RootCommandMatcher.case("bun") => .BunCommand,
- RootCommandMatcher.case("discord") => .DiscordCommand,
- RootCommandMatcher.case("d"), RootCommandMatcher.case("dev") => .DevCommand,
- RootCommandMatcher.case("c"), RootCommandMatcher.case("create") => .CreateCommand,
- RootCommandMatcher.case("upgrade") => .UpgradeCommand,
-
- RootCommandMatcher.case("help") => .HelpCommand,
- else => .AutoCommand,
- };
- }
+ return switch (RootCommandMatcher.match(first_arg_name)) {
+ RootCommandMatcher.case("init") => .InitCommand,
+ RootCommandMatcher.case("bun") => .BunCommand,
+ RootCommandMatcher.case("discord") => .DiscordCommand,
+ RootCommandMatcher.case("upgrade") => .UpgradeCommand,
+ RootCommandMatcher.case("completions") => .InstallCompletionsCommand,
+ RootCommandMatcher.case("getcompletes") => .GetCompletionsCommand,
+
+ RootCommandMatcher.case("i"), RootCommandMatcher.case("install") => .InstallCommand,
+ RootCommandMatcher.case("c"), RootCommandMatcher.case("create") => .CreateCommand,
+
+ RootCommandMatcher.case("pm") => .PackageManagerCommand,
+
+ RootCommandMatcher.case("add"), RootCommandMatcher.case("update"), RootCommandMatcher.case("a") => .AddCommand,
+ RootCommandMatcher.case("remove"), RootCommandMatcher.case("rm") => .RemoveCommand,
+
+ RootCommandMatcher.case("b"), RootCommandMatcher.case("build") => .BuildCommand,
+ RootCommandMatcher.case("run") => .RunCommand,
+ RootCommandMatcher.case("d"), RootCommandMatcher.case("dev") => .DevCommand,
+
+ RootCommandMatcher.case("help") => .HelpCommand,
+ else => .AutoCommand,
+ };
}
const default_completions_list = [_]string{
// "build",
+ "install",
+ "add",
+ "remove",
"run",
"dev",
+ "install",
"create",
"bun",
"upgrade",
@@ -658,6 +680,30 @@ pub const Command = struct {
try InstallCompletionsCommand.exec(allocator);
return;
},
+ .InstallCommand => {
+ const ctx = try Command.Context.create(allocator, log, .InstallCommand);
+
+ try InstallCommand.exec(ctx);
+ return;
+ },
+ .AddCommand => {
+ const ctx = try Command.Context.create(allocator, log, .AddCommand);
+
+ try AddCommand.exec(ctx);
+ return;
+ },
+ .RemoveCommand => {
+ const ctx = try Command.Context.create(allocator, log, .RemoveCommand);
+
+ try RemoveCommand.exec(ctx);
+ return;
+ },
+ .PackageManagerCommand => {
+ const ctx = try Command.Context.create(allocator, log, .PackageManagerCommand);
+
+ try PackageManagerCommand.exec(ctx);
+ return;
+ },
.GetCompletionsCommand => {
const ctx = try Command.Context.create(allocator, log, .GetCompletionsCommand);
var filter = ctx.positionals;
@@ -746,11 +792,24 @@ pub const Command = struct {
}
};
- if (ctx.args.entry_points.len == 1 and
- std.mem.endsWith(u8, ctx.args.entry_points[0], ".bun"))
- {
- try PrintBundleCommand.exec(ctx);
- return;
+ // KEYWORDS: open file argv argv0
+ if (ctx.args.entry_points.len == 1) {
+ const extension = std.fs.path.extension(ctx.args.entry_points[0]);
+
+ if (strings.eqlComptime(extension, ".bun")) {
+ try PrintBundleCommand.exec(ctx);
+ return;
+ }
+
+ if (strings.eqlComptime(extension, ".lockb")) {
+ try Install.Lockfile.Printer.print(
+ ctx.allocator,
+ ctx.log,
+ ctx.args.entry_points[0],
+ .yarn,
+ );
+ return;
+ }
}
if (ctx.positionals.len > 0 and (std.fs.path.extension(ctx.positionals[0]).len == 0)) {
@@ -770,17 +829,29 @@ pub const Command = struct {
}
pub const Tag = enum {
- InitCommand,
+ AutoCommand,
+ BuildCommand,
BunCommand,
+ CreateCommand,
DevCommand,
DiscordCommand,
- BuildCommand,
- RunCommand,
- AutoCommand,
+ GetCompletionsCommand,
HelpCommand,
- CreateCommand,
- UpgradeCommand,
+ InitCommand,
+ InstallCommand,
+ AddCommand,
+ RemoveCommand,
InstallCompletionsCommand,
- GetCompletionsCommand,
+ RunCommand,
+ UpgradeCommand,
+ PackageManagerCommand,
+
+ pub const uses_global_options: std.EnumArray(Tag, bool) = std.EnumArray(Tag, bool).initDefault(true, .{
+ .CreateCommand = false,
+ .InstallCommand = false,
+ .AddCommand = false,
+ .RemoveCommand = false,
+ .PackageManagerCommand = false,
+ });
};
};
diff --git a/src/cli/add_command.zig b/src/cli/add_command.zig
new file mode 100644
index 000000000..f16b6cca1
--- /dev/null
+++ b/src/cli/add_command.zig
@@ -0,0 +1,8 @@
+const Command = @import("../cli.zig").Command;
+const PackageManager = @import("../install/install.zig").PackageManager;
+
+pub const AddCommand = struct {
+ pub fn exec(ctx: Command.Context) !void {
+ try PackageManager.add(ctx);
+ }
+};
diff --git a/src/cli/create_command.zig b/src/cli/create_command.zig
index e48745f69..096fe5ab7 100644
--- a/src/cli/create_command.zig
+++ b/src/cli/create_command.zig
@@ -21,7 +21,8 @@ const bundler = @import("../bundler.zig");
const NodeModuleBundle = @import("../node_module_bundle.zig").NodeModuleBundle;
const fs = @import("../fs.zig");
const URL = @import("../query_string_map.zig").URL;
-const HTTPClient = @import("../http_client.zig");
+const HTTP = @import("http");
+const NetworkThread = @import("network_thread");
const ParseJSON = @import("../json_parser.zig").ParseJSON;
const Archive = @import("../libarchive/libarchive.zig").Archive;
const Zlib = @import("../zlib.zig");
@@ -186,9 +187,6 @@ const CreateOptions = struct {
const params = [_]clap.Param(clap.Help){
clap.parseParam("--help Print this menu") catch unreachable,
- clap.parseParam("--npm Use npm for tasks & install") catch unreachable,
- clap.parseParam("--yarn Use yarn for tasks & install") catch unreachable,
- clap.parseParam("--pnpm Use pnpm for tasks & install") catch unreachable,
clap.parseParam("--force Overwrite existing files") catch unreachable,
clap.parseParam("--no-install Don't install node_modules") catch unreachable,
clap.parseParam("--no-git Don't create a git repository") catch unreachable,
@@ -232,18 +230,6 @@ const CreateOptions = struct {
opts.positionals = opts.positionals[1..];
}
- if (args.flag("--npm")) {
- opts.npm_client = NPMClient.Tag.npm;
- }
-
- if (args.flag("--yarn")) {
- opts.npm_client = NPMClient.Tag.yarn;
- }
-
- if (args.flag("--pnpm")) {
- opts.npm_client = NPMClient.Tag.pnpm;
- }
-
opts.skip_package_json = args.flag("--no-package-json");
opts.verbose = args.flag("--verbose");
@@ -259,10 +245,9 @@ const CreateOptions = struct {
const BUN_CREATE_DIR = ".bun-create";
var home_dir_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
pub const CreateCommand = struct {
- var client: HTTPClient = undefined;
-
pub fn exec(ctx: Command.Context, positionals_: []const []const u8) !void {
Global.configureAllocator(.{ .long_running = false });
+ try NetworkThread.init();
var create_options = try CreateOptions.parse(ctx, false);
const positionals = create_options.positionals;
@@ -785,11 +770,8 @@ pub const CreateCommand = struct {
.{ "@parcel/core", void{} },
.{ "@swc/cli", void{} },
.{ "@swc/core", void{} },
- .{ "@vitejs/plugin-react", void{} },
.{ "@webpack/cli", void{} },
.{ "react-scripts", void{} },
- .{ "swc", void{} },
- .{ "vite", void{} },
.{ "webpack-cli", void{} },
.{ "webpack", void{} },
@@ -1504,22 +1486,10 @@ pub const CreateCommand = struct {
}
if (!create_options.skip_install) {
- if (env_loader.map.get("NPM_CLIENT")) |npm_client_bin| {
- npm_client_ = NPMClient{ .tag = .npm, .bin = npm_client_bin };
- } else if (PATH.len > 0) {
- var realpath_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
-
- if (create_options.npm_client) |tag| {
- if (which(&realpath_buf, PATH, destination, @tagName(tag))) |bin| {
- npm_client_ = NPMClient{ .tag = tag, .bin = try ctx.allocator.dupe(u8, bin) };
- }
- } else if (try NPMClient.detect(ctx.allocator, &realpath_buf, PATH, destination, true)) |npmclient| {
- npm_client_ = NPMClient{
- .bin = try ctx.allocator.dupe(u8, npmclient.bin),
- .tag = npmclient.tag,
- };
- }
- }
+ npm_client_ = NPMClient{
+ .tag = .bun,
+ .bin = try std.fs.selfExePathAlloc(ctx.allocator),
+ };
}
if (npm_client_ != null and preinstall_tasks.items.len > 0) {
@@ -1530,13 +1500,7 @@ pub const CreateCommand = struct {
if (npm_client_) |npm_client| {
const start_time = std.time.nanoTimestamp();
- const install_args_ = [_]string{ npm_client.bin, "install", "--loglevel=error", "--no-fund", "--no-audit" };
- const len: usize = switch (npm_client.tag) {
- .npm => install_args_.len,
- else => 2,
- };
-
- const install_args = install_args_[0..len];
+ const install_args = &[_]string{ npm_client.bin, "install" };
Output.flush();
Output.pretty("\n<r><d>$ <b><cyan>{s}<r><d> install", .{@tagName(npm_client.tag)});
var writer = Output.writer();
@@ -1568,8 +1532,6 @@ pub const CreateCommand = struct {
var term = try process.spawnAndWait();
_ = process.kill() catch undefined;
- } else if (!create_options.skip_install) {
- progress.log("Failed to detect npm client. Tried pnpm, yarn, and npm.\n", .{});
}
if (postinstall_tasks.items.len > 0) {
@@ -1709,43 +1671,6 @@ const Commands = .{
};
const picohttp = @import("picohttp");
-const PackageDownloadThread = struct {
- thread: std.Thread,
- client: HTTPClient,
- tarball_url: string,
- allocator: *std.mem.Allocator,
- buffer: MutableString,
- done: std.atomic.Atomic(u32),
- response: picohttp.Response = undefined,
-
- pub fn threadHandler(this: *PackageDownloadThread) !void {
- this.done.store(0, .Release);
- this.response = try this.client.send("", &this.buffer);
- this.done.store(1, .Release);
- Futex.wake(&this.done, 1);
- }
-
- pub fn spawn(allocator: *std.mem.Allocator, tarball_url: string, progress_node: *std.Progress.Node) !*PackageDownloadThread {
- var download = try allocator.create(PackageDownloadThread);
- download.* = PackageDownloadThread{
- .allocator = allocator,
- .client = HTTPClient.init(allocator, .GET, URL.parse(tarball_url), .{}, ""),
- .tarball_url = tarball_url,
- .buffer = try MutableString.init(allocator, 1024),
- .done = std.atomic.Atomic(u32).init(0),
- .thread = undefined,
- };
-
- if (Output.enable_ansi_colors) {
- download.client.progress_node = progress_node;
- }
-
- download.thread = try std.Thread.spawn(.{}, threadHandler, .{download});
-
- return download;
- }
-};
-
pub const DownloadedExample = struct {
tarball_bytes: MutableString,
example: Example,
@@ -1764,7 +1689,6 @@ pub const Example = struct {
local_folder,
};
- var client: HTTPClient = undefined;
const examples_url: string = "https://registry.npmjs.org/bun-examples-all/latest";
var url: URL = undefined;
pub const timeout: u32 = 6000;
@@ -1873,7 +1797,6 @@ pub const Example = struct {
var owner_i = std.mem.indexOfScalar(u8, name, '/').?;
var owner = name[0..owner_i];
var repository = name[owner_i + 1 ..];
- var mutable = try MutableString.init(ctx.allocator, 8096);
if (std.mem.indexOfScalar(u8, repository, '/')) |i| {
repository = repository[0..i];
@@ -1919,17 +1842,16 @@ pub const Example = struct {
}
}
- client = HTTPClient.init(
- ctx.allocator,
- .GET,
- api_url,
- header_entries,
- headers_buf,
- );
- client.timeout = timeout;
- client.progress_node = progress;
+ var mutable = try ctx.allocator.create(MutableString);
+ mutable.* = try MutableString.init(ctx.allocator, 8096);
- var response = try client.send("", &mutable);
+ var request_body = try MutableString.init(ctx.allocator, 0);
+
+ // ensure very stable memory address
+ var async_http: *HTTP.AsyncHTTP = ctx.allocator.create(HTTP.AsyncHTTP) catch unreachable;
+ async_http.* = try HTTP.AsyncHTTP.init(ctx.allocator, .GET, api_url, header_entries, headers_buf, mutable, &request_body, 60 * std.time.ns_per_min);
+ async_http.client.progress_node = progress;
+ const response = try async_http.sendSync();
switch (response.status_code) {
404 => return error.GitHubRepositoryNotFound,
@@ -1977,7 +1899,7 @@ pub const Example = struct {
Global.crash();
}
- return mutable;
+ return mutable.*;
}
pub fn fetch(ctx: Command.Context, name: string, refresher: *std.Progress, progress: *std.Progress.Node) !MutableString {
@@ -1986,13 +1908,17 @@ pub const Example = struct {
const example_start = std.time.nanoTimestamp();
var url_buf: [1024]u8 = undefined;
- var mutable = try MutableString.init(ctx.allocator, 2048);
+ var mutable = try ctx.allocator.create(MutableString);
+ mutable.* = try MutableString.init(ctx.allocator, 2048);
+ var request_body = try MutableString.init(ctx.allocator, 0);
url = URL.parse(try std.fmt.bufPrint(&url_buf, "https://registry.npmjs.org/@bun-examples/{s}/latest", .{name}));
- client = HTTPClient.init(ctx.allocator, .GET, url, .{}, "");
- client.timeout = timeout;
- client.progress_node = progress;
- var response = try client.send("", &mutable);
+
+ // ensure very stable memory address
+ var async_http: *HTTP.AsyncHTTP = ctx.allocator.create(HTTP.AsyncHTTP) catch unreachable;
+ async_http.* = try HTTP.AsyncHTTP.init(ctx.allocator, .GET, url, .{}, "", mutable, &request_body, 60 * std.time.ns_per_min);
+ async_http.client.progress_node = progress;
+ var response = try async_http.sendSync();
switch (response.status_code) {
404 => return error.ExampleNotFound,
@@ -2044,7 +1970,7 @@ pub const Example = struct {
if (q.expr.asProperty("tarball")) |p| {
if (p.expr.asString(ctx.allocator)) |s| {
if (s.len > 0 and (strings.startsWith(s, "https://") or strings.startsWith(s, "http://"))) {
- break :brk s;
+ break :brk ctx.allocator.dupe(u8, s) catch unreachable;
}
}
}
@@ -2061,40 +1987,48 @@ pub const Example = struct {
progress.name = "Downloading tarball";
refresher.refresh();
- var thread: *PackageDownloadThread = try PackageDownloadThread.spawn(ctx.allocator, tarball_url, progress);
+ // reuse mutable buffer
+ // safe because the only thing we care about is the tarball url
+ mutable.reset();
+
+ // ensure very stable memory address
+ async_http.* = try HTTP.AsyncHTTP.init(ctx.allocator, .GET, URL.parse(tarball_url), .{}, "", mutable, &request_body, 60 * std.time.ns_per_min);
+ async_http.client.progress_node = progress;
+
refresher.maybeRefresh();
- while (thread.done.load(.Acquire) == 0) {
- Futex.wait(&thread.done, 1, std.time.ns_per_ms * 10000) catch {};
- }
+ response = try async_http.sendSync();
refresher.maybeRefresh();
- if (thread.response.status_code != 200) {
+ if (response.status_code != 200) {
progress.end();
refresher.refresh();
- Output.prettyErrorln("Error fetching tarball: <r><red>{d}<r>", .{thread.response.status_code});
+ Output.prettyErrorln("Error fetching tarball: <r><red>{d}<r>", .{response.status_code});
Output.flush();
std.os.exit(1);
}
refresher.refresh();
- thread.thread.join();
- return thread.buffer;
+ return mutable.*;
}
pub fn fetchAll(ctx: Command.Context, progress_node: ?*std.Progress.Node) ![]Example {
url = URL.parse(examples_url);
- client = HTTPClient.init(ctx.allocator, .GET, url, .{}, "");
- client.timeout = timeout;
+
+ var async_http: *HTTP.AsyncHTTP = ctx.allocator.create(HTTP.AsyncHTTP) catch unreachable;
+ var request_body = try MutableString.init(ctx.allocator, 0);
+ var mutable = try ctx.allocator.create(MutableString);
+ mutable.* = try MutableString.init(ctx.allocator, 2048);
+
+ async_http.* = try HTTP.AsyncHTTP.init(ctx.allocator, .GET, url, .{}, "", mutable, &request_body, 60 * std.time.ns_per_min);
if (Output.enable_ansi_colors) {
- client.progress_node = progress_node;
+ async_http.client.progress_node = progress_node;
}
- var mutable: MutableString = try MutableString.init(ctx.allocator, 1024);
- var response = client.send("", &mutable) catch |err| {
+ const response = async_http.sendSync() catch |err| {
switch (err) {
error.WouldBlock => {
Output.prettyErrorln("Request timed out while trying to fetch examples list. Please try again", .{});
diff --git a/src/cli/install_command.zig b/src/cli/install_command.zig
new file mode 100644
index 000000000..6c441b859
--- /dev/null
+++ b/src/cli/install_command.zig
@@ -0,0 +1,8 @@
+const Command = @import("../cli.zig").Command;
+const PackageManager = @import("../install/install.zig").PackageManager;
+
+pub const InstallCommand = struct {
+ pub fn exec(ctx: Command.Context) !void {
+ try PackageManager.install(ctx);
+ }
+};
diff --git a/src/cli/install_completions_command.zig b/src/cli/install_completions_command.zig
index 8d4de60fa..d4e9fc5b9 100644
--- a/src/cli/install_completions_command.zig
+++ b/src/cli/install_completions_command.zig
@@ -21,7 +21,6 @@ const bundler = @import("../bundler.zig");
const NodeModuleBundle = @import("../node_module_bundle.zig").NodeModuleBundle;
const fs = @import("../fs.zig");
const URL = @import("../query_string_map.zig").URL;
-const HTTPClient = @import("../http_client.zig");
const ParseJSON = @import("../json_parser.zig").ParseJSON;
const Archive = @import("../libarchive/libarchive.zig").Archive;
const Zlib = @import("../zlib.zig");
diff --git a/src/cli/package_manager_command.zig b/src/cli/package_manager_command.zig
new file mode 100644
index 000000000..31064948a
--- /dev/null
+++ b/src/cli/package_manager_command.zig
@@ -0,0 +1,24 @@
+const Command = @import("../cli.zig").Command;
+const PackageManager = @import("../install/install.zig").PackageManager;
+const std = @import("std");
+const strings = @import("strings");
+
+pub const PackageManagerCommand = struct {
+ pub fn printHelp(allocator: *std.mem.Allocator) void {}
+ pub fn exec(ctx: Command.Context) !void {
+ var args = try std.process.argsAlloc(ctx.allocator);
+ args = args[1..];
+
+ var first = std.mem.span(args[0]);
+ if (strings.eqlComptime(first, "pm")) {
+ args = args[1..];
+ }
+
+ if (args.len == 0) {
+ printHelp(ctx.allocator);
+ std.os.exit(0);
+ }
+
+ first = std.mem.span(args[0]);
+ }
+};
diff --git a/src/cli/remove_command.zig b/src/cli/remove_command.zig
new file mode 100644
index 000000000..eec924d8d
--- /dev/null
+++ b/src/cli/remove_command.zig
@@ -0,0 +1,8 @@
+const Command = @import("../cli.zig").Command;
+const PackageManager = @import("../install/install.zig").PackageManager;
+
+pub const RemoveCommand = struct {
+ pub fn exec(ctx: Command.Context) !void {
+ try PackageManager.remove(ctx);
+ }
+};
diff --git a/src/cli/upgrade_command.zig b/src/cli/upgrade_command.zig
index f2a12c145..345876b55 100644
--- a/src/cli/upgrade_command.zig
+++ b/src/cli/upgrade_command.zig
@@ -21,18 +21,18 @@ const bundler = @import("../bundler.zig");
const NodeModuleBundle = @import("../node_module_bundle.zig").NodeModuleBundle;
const fs = @import("../fs.zig");
const URL = @import("../query_string_map.zig").URL;
-const HTTPClient = @import("../http_client.zig");
+const HTTP = @import("http");
const ParseJSON = @import("../json_parser.zig").ParseJSON;
const Archive = @import("../libarchive/libarchive.zig").Archive;
const Zlib = @import("../zlib.zig");
const JSPrinter = @import("../js_printer.zig");
const DotEnv = @import("../env_loader.zig");
-const NPMClient = @import("../which_npm_client.zig").NPMClient;
const which = @import("../which.zig").which;
const clap = @import("clap");
const Lock = @import("../lock.zig").Lock;
const Headers = @import("../javascript/jsc/webcore/response.zig").Headers;
const CopyFile = @import("../copy_file.zig");
+const NetworkThread = @import("network_thread");
pub var initialized_store = false;
pub fn initializeStore() void {
@@ -83,6 +83,7 @@ pub const UpgradeCheckerThread = struct {
std.time.sleep(std.time.ns_per_ms * delay);
Output.Source.configureThread();
+ NetworkThread.init() catch unreachable;
const version = (try UpgradeCommand.getLatestVersion(default_allocator, env_loader, undefined, undefined, true)) orelse return;
@@ -145,18 +146,6 @@ pub const UpgradeCommand = struct {
),
);
- var client = HTTPClient.init(
- allocator,
- .GET,
- api_url,
- header_entries,
- headers_buf,
- );
- client.timeout = timeout;
- if (!silent) {
- client.progress_node = progress;
- }
-
if (env_loader.map.get("GITHUB_ACCESS_TOKEN")) |access_token| {
if (access_token.len > 0) {
headers_buf = try std.fmt.allocPrint(allocator, default_github_headers ++ "Access-TokenBearer {s}", .{access_token});
@@ -177,7 +166,13 @@ pub const UpgradeCommand = struct {
}
var metadata_body = try MutableString.init(allocator, 2048);
- var response = try client.send("", &metadata_body);
+ var request_body = try MutableString.init(allocator, 0);
+
+ // ensure very stable memory address
+ var async_http: *HTTP.AsyncHTTP = allocator.create(HTTP.AsyncHTTP) catch unreachable;
+ async_http.* = try HTTP.AsyncHTTP.init(allocator, .GET, api_url, header_entries, headers_buf, &metadata_body, &request_body, 60 * std.time.ns_per_min);
+ if (!silent) async_http.client.progress_node = progress;
+ const response = try async_http.sendSync();
switch (response.status_code) {
404 => return error.HTTP404,
@@ -326,6 +321,8 @@ pub const UpgradeCommand = struct {
const exe_subpath = Version.folder_name ++ std.fs.path.sep_str ++ "bun";
pub fn exec(ctx: Command.Context) !void {
+ try NetworkThread.init();
+
var filesystem = try fs.FileSystem.init1(ctx.allocator, null);
var env_loader: DotEnv.Loader = brk: {
var map = try ctx.allocator.create(DotEnv.Map);
@@ -375,21 +372,24 @@ pub const UpgradeCommand = struct {
var refresher = std.Progress{};
var progress = try refresher.start("Downloading", version.size);
refresher.refresh();
+ var async_http = ctx.allocator.create(HTTP.AsyncHTTP) catch unreachable;
+ var zip_file_buffer = try ctx.allocator.create(MutableString);
+ zip_file_buffer.* = try MutableString.init(ctx.allocator, @maximum(version.size, 1024));
+ var request_buffer = try MutableString.init(ctx.allocator, 0);
- var client = HTTPClient.init(
+ async_http.* = try HTTP.AsyncHTTP.init(
ctx.allocator,
.GET,
URL.parse(version.zip_url),
.{},
"",
+ zip_file_buffer,
+ &request_buffer,
+ timeout,
);
- client.timeout = timeout;
- client.progress_node = progress;
- var zip_file_buffer = try MutableString.init(ctx.allocator, @maximum(version.size, 1024));
- var response = try client.send(
- "",
- &zip_file_buffer,
- );
+ async_http.client.timeout = timeout;
+ async_http.client.progress_node = progress;
+ const response = try async_http.sendSync();
switch (response.status_code) {
404 => return error.HTTP404,
@@ -400,7 +400,7 @@ pub const UpgradeCommand = struct {
else => return error.HTTPError,
}
- var bytes = zip_file_buffer.toOwnedSliceLeaky();
+ const bytes = zip_file_buffer.toOwnedSliceLeaky();
progress.end();
refresher.refresh();
diff --git a/src/deps/boringssl b/src/deps/boringssl
new file mode 160000
+Subproject b3ed071ecc4efb77afd0a025ea1078da19578bf
diff --git a/src/deps/boringssl.translated.zig b/src/deps/boringssl.translated.zig
new file mode 100644
index 000000000..7e2bb77e5
--- /dev/null
+++ b/src/deps/boringssl.translated.zig
@@ -0,0 +1,18877 @@
+const std = @import("std");
+pub usingnamespace @import("std").zig.c_builtins;
+pub const CRYPTO_THREADID = c_int;
+pub const struct_asn1_null_st = opaque {};
+pub const ASN1_NULL = struct_asn1_null_st;
+pub const ASN1_BOOLEAN = c_int;
+pub const struct_ASN1_ITEM_st = opaque {};
+pub const ASN1_ITEM = struct_ASN1_ITEM_st;
+pub const struct_asn1_object_st = opaque {};
+pub const ASN1_OBJECT = struct_asn1_object_st;
+pub const struct_asn1_pctx_st = opaque {};
+pub const ASN1_PCTX = struct_asn1_pctx_st;
+pub const struct_asn1_string_st = extern struct {
+ length: c_int,
+ type: c_int,
+ data: [*c]u8,
+ flags: c_long,
+};
+pub const ASN1_BIT_STRING = struct_asn1_string_st;
+pub const ASN1_BMPSTRING = struct_asn1_string_st;
+pub const ASN1_ENUMERATED = struct_asn1_string_st;
+pub const ASN1_GENERALIZEDTIME = struct_asn1_string_st;
+pub const ASN1_GENERALSTRING = struct_asn1_string_st;
+pub const ASN1_IA5STRING = struct_asn1_string_st;
+pub const ASN1_INTEGER = struct_asn1_string_st;
+pub const ASN1_OCTET_STRING = struct_asn1_string_st;
+pub const ASN1_PRINTABLESTRING = struct_asn1_string_st;
+pub const ASN1_STRING = struct_asn1_string_st;
+pub const ASN1_T61STRING = struct_asn1_string_st;
+pub const ASN1_TIME = struct_asn1_string_st;
+pub const ASN1_UNIVERSALSTRING = struct_asn1_string_st;
+pub const ASN1_UTCTIME = struct_asn1_string_st;
+pub const ASN1_UTF8STRING = struct_asn1_string_st;
+pub const ASN1_VISIBLESTRING = struct_asn1_string_st;
+pub const struct_ASN1_VALUE_st = opaque {};
+pub const ASN1_VALUE = struct_ASN1_VALUE_st;
+const union_unnamed_1 = extern union {
+ ptr: [*c]u8,
+ boolean: ASN1_BOOLEAN,
+ asn1_string: [*c]ASN1_STRING,
+ object: ?*ASN1_OBJECT,
+ integer: [*c]ASN1_INTEGER,
+ enumerated: [*c]ASN1_ENUMERATED,
+ bit_string: [*c]ASN1_BIT_STRING,
+ octet_string: [*c]ASN1_OCTET_STRING,
+ printablestring: [*c]ASN1_PRINTABLESTRING,
+ t61string: [*c]ASN1_T61STRING,
+ ia5string: [*c]ASN1_IA5STRING,
+ generalstring: [*c]ASN1_GENERALSTRING,
+ bmpstring: [*c]ASN1_BMPSTRING,
+ universalstring: [*c]ASN1_UNIVERSALSTRING,
+ utctime: [*c]ASN1_UTCTIME,
+ generalizedtime: [*c]ASN1_GENERALIZEDTIME,
+ visiblestring: [*c]ASN1_VISIBLESTRING,
+ utf8string: [*c]ASN1_UTF8STRING,
+ set: [*c]ASN1_STRING,
+ sequence: [*c]ASN1_STRING,
+ asn1_value: ?*ASN1_VALUE,
+};
+pub const struct_asn1_type_st = extern struct {
+ type: c_int,
+ value: union_unnamed_1,
+};
+pub const ASN1_TYPE = struct_asn1_type_st;
+pub const struct_AUTHORITY_KEYID_st = opaque {};
+pub const AUTHORITY_KEYID = struct_AUTHORITY_KEYID_st;
+pub const struct_BASIC_CONSTRAINTS_st = opaque {};
+pub const BASIC_CONSTRAINTS = struct_BASIC_CONSTRAINTS_st;
+pub const struct_DIST_POINT_st = opaque {};
+pub const DIST_POINT = struct_DIST_POINT_st;
+pub const struct_bignum_st = extern struct {
+ d: [*c]u64,
+ width: c_int,
+ dmax: c_int,
+ neg: c_int,
+ flags: c_int,
+};
+pub const BIGNUM = struct_bignum_st;
+pub const struct_DSA_SIG_st = extern struct {
+ r: [*c]BIGNUM,
+ s: [*c]BIGNUM,
+};
+pub const DSA_SIG = struct_DSA_SIG_st;
+pub const struct_ISSUING_DIST_POINT_st = opaque {};
+pub const ISSUING_DIST_POINT = struct_ISSUING_DIST_POINT_st;
+pub const struct_NAME_CONSTRAINTS_st = opaque {};
+pub const NAME_CONSTRAINTS = struct_NAME_CONSTRAINTS_st;
+pub const struct_X509_pubkey_st = opaque {};
+pub const X509_PUBKEY = struct_X509_pubkey_st;
+pub const struct_Netscape_spkac_st = extern struct {
+ pubkey: ?*X509_PUBKEY,
+ challenge: [*c]ASN1_IA5STRING,
+};
+pub const NETSCAPE_SPKAC = struct_Netscape_spkac_st;
+pub const struct_X509_algor_st = extern struct {
+ algorithm: ?*ASN1_OBJECT,
+ parameter: [*c]ASN1_TYPE,
+};
+pub const X509_ALGOR = struct_X509_algor_st;
+pub const struct_Netscape_spki_st = extern struct {
+ spkac: [*c]NETSCAPE_SPKAC,
+ sig_algor: [*c]X509_ALGOR,
+ signature: [*c]ASN1_BIT_STRING,
+};
+pub const NETSCAPE_SPKI = struct_Netscape_spki_st;
+pub const struct_RIPEMD160state_st = opaque {};
+pub const RIPEMD160_CTX = struct_RIPEMD160state_st;
+pub const struct_X509_POLICY_CACHE_st = opaque {};
+pub const X509_POLICY_CACHE = struct_X509_POLICY_CACHE_st;
+pub const struct_X509_POLICY_LEVEL_st = opaque {};
+pub const X509_POLICY_LEVEL = struct_X509_POLICY_LEVEL_st;
+pub const struct_X509_POLICY_NODE_st = opaque {};
+pub const X509_POLICY_NODE = struct_X509_POLICY_NODE_st;
+pub const struct_X509_POLICY_TREE_st = opaque {};
+pub const X509_POLICY_TREE = struct_X509_POLICY_TREE_st;
+pub const struct_X509_VERIFY_PARAM_st = opaque {};
+pub const X509_VERIFY_PARAM = struct_X509_VERIFY_PARAM_st;
+pub const struct_X509_crl_st = opaque {};
+pub const X509_CRL = struct_X509_crl_st;
+pub const struct_X509_extension_st = opaque {};
+pub const X509_EXTENSION = struct_X509_extension_st;
+pub const struct_x509_st = opaque {};
+pub const X509 = struct_x509_st;
+pub const CRYPTO_refcount_t = u32;
+pub const struct_openssl_method_common_st = extern struct {
+ references: c_int,
+ is_static: u8,
+};
+pub const struct_rsa_meth_st = extern struct {
+ common: struct_openssl_method_common_st,
+ app_data: ?*c_void,
+ init: ?fn (?*RSA) callconv(.C) c_int,
+ finish: ?fn (?*RSA) callconv(.C) c_int,
+ size: ?fn (?*const RSA) callconv(.C) usize,
+ sign: ?fn (c_int, [*c]const u8, c_uint, [*c]u8, [*c]c_uint, ?*const RSA) callconv(.C) c_int,
+ sign_raw: ?fn (?*RSA, [*c]usize, [*c]u8, usize, [*c]const u8, usize, c_int) callconv(.C) c_int,
+ decrypt: ?fn (?*RSA, [*c]usize, [*c]u8, usize, [*c]const u8, usize, c_int) callconv(.C) c_int,
+ private_transform: ?fn (?*RSA, [*c]u8, [*c]const u8, usize) callconv(.C) c_int,
+ flags: c_int,
+};
+pub const RSA_METHOD = struct_rsa_meth_st;
+pub const struct_stack_st_void = opaque {};
+pub const struct_crypto_ex_data_st = extern struct {
+ sk: ?*struct_stack_st_void,
+};
+pub const CRYPTO_EX_DATA = struct_crypto_ex_data_st;
+pub const CRYPTO_MUTEX = pthread_rwlock_t;
+pub const struct_bn_mont_ctx_st = extern struct {
+ RR: BIGNUM,
+ N: BIGNUM,
+ n0: [2]u64,
+};
+pub const BN_MONT_CTX = struct_bn_mont_ctx_st;
+pub const struct_bn_blinding_st = opaque {};
+pub const BN_BLINDING = struct_bn_blinding_st; // /Users/jarred/Code/bun/src/deps/boringssl/include/openssl/rsa.h:785:12: warning: struct demoted to opaque type - has bitfield
+pub const struct_rsa_st = opaque {};
+pub const RSA = struct_rsa_st;
+pub const struct_dsa_st = extern struct {
+ version: c_long,
+ p: [*c]BIGNUM,
+ q: [*c]BIGNUM,
+ g: [*c]BIGNUM,
+ pub_key: [*c]BIGNUM,
+ priv_key: [*c]BIGNUM,
+ flags: c_int,
+ method_mont_lock: CRYPTO_MUTEX,
+ method_mont_p: [*c]BN_MONT_CTX,
+ method_mont_q: [*c]BN_MONT_CTX,
+ references: CRYPTO_refcount_t,
+ ex_data: CRYPTO_EX_DATA,
+};
+pub const DSA = struct_dsa_st;
+pub const struct_dh_st = extern struct {
+ p: [*c]BIGNUM,
+ g: [*c]BIGNUM,
+ pub_key: [*c]BIGNUM,
+ priv_key: [*c]BIGNUM,
+ priv_length: c_uint,
+ method_mont_p_lock: CRYPTO_MUTEX,
+ method_mont_p: [*c]BN_MONT_CTX,
+ q: [*c]BIGNUM,
+ j: [*c]BIGNUM,
+ seed: [*c]u8,
+ seedlen: c_int,
+ counter: [*c]BIGNUM,
+ flags: c_int,
+ references: CRYPTO_refcount_t,
+};
+pub const DH = struct_dh_st;
+pub const struct_ec_key_st = opaque {};
+pub const EC_KEY = struct_ec_key_st;
+const union_unnamed_2 = extern union {
+ ptr: ?*c_void,
+ rsa: ?*RSA,
+ dsa: [*c]DSA,
+ dh: [*c]DH,
+ ec: ?*EC_KEY,
+};
+pub const struct_evp_pkey_asn1_method_st = opaque {};
+pub const EVP_PKEY_ASN1_METHOD = struct_evp_pkey_asn1_method_st;
+pub const struct_evp_pkey_st = extern struct {
+ references: CRYPTO_refcount_t,
+ type: c_int,
+ pkey: union_unnamed_2,
+ ameth: ?*const EVP_PKEY_ASN1_METHOD,
+};
+pub const EVP_PKEY = struct_evp_pkey_st;
+pub const struct_evp_cipher_ctx_st = extern struct {
+ cipher: [*c]const EVP_CIPHER,
+ app_data: ?*c_void,
+ cipher_data: ?*c_void,
+ key_len: c_uint,
+ encrypt: c_int,
+ flags: u32,
+ oiv: [16]u8,
+ iv: [16]u8,
+ buf: [32]u8,
+ buf_len: c_int,
+ num: c_uint,
+ final_used: c_int,
+ final: [32]u8,
+};
+pub const EVP_CIPHER_CTX = struct_evp_cipher_ctx_st;
+pub const struct_evp_cipher_st = extern struct {
+ nid: c_int,
+ block_size: c_uint,
+ key_len: c_uint,
+ iv_len: c_uint,
+ ctx_size: c_uint,
+ flags: u32,
+ app_data: ?*c_void,
+ init: ?fn ([*c]EVP_CIPHER_CTX, [*c]const u8, [*c]const u8, c_int) callconv(.C) c_int,
+ cipher: ?fn ([*c]EVP_CIPHER_CTX, [*c]u8, [*c]const u8, usize) callconv(.C) c_int,
+ cleanup: ?fn ([*c]EVP_CIPHER_CTX) callconv(.C) void,
+ ctrl: ?fn ([*c]EVP_CIPHER_CTX, c_int, c_int, ?*c_void) callconv(.C) c_int,
+};
+pub const EVP_CIPHER = struct_evp_cipher_st;
+pub const struct_evp_cipher_info_st = extern struct {
+ cipher: [*c]const EVP_CIPHER,
+ iv: [16]u8,
+};
+pub const EVP_CIPHER_INFO = struct_evp_cipher_info_st;
+pub const struct_private_key_st = extern struct {
+ version: c_int,
+ enc_algor: [*c]X509_ALGOR,
+ enc_pkey: [*c]ASN1_OCTET_STRING,
+ dec_pkey: [*c]EVP_PKEY,
+ key_length: c_int,
+ key_data: [*c]u8,
+ key_free: c_int,
+ cipher: EVP_CIPHER_INFO,
+};
+pub const X509_PKEY = struct_private_key_st;
+pub const struct_X509_info_st = extern struct {
+ x509: ?*X509,
+ crl: ?*X509_CRL,
+ x_pkey: [*c]X509_PKEY,
+ enc_cipher: EVP_CIPHER_INFO,
+ enc_len: c_int,
+ enc_data: [*c]u8,
+};
+pub const X509_INFO = struct_X509_info_st;
+pub const struct_X509_name_entry_st = opaque {};
+pub const X509_NAME_ENTRY = struct_X509_name_entry_st;
+pub const struct_X509_name_st = opaque {};
+pub const X509_NAME = struct_X509_name_st;
+pub const struct_X509_req_st = opaque {};
+pub const X509_REQ = struct_X509_req_st;
+pub const struct_X509_sig_st = opaque {};
+pub const X509_SIG = struct_X509_sig_st;
+pub const struct_bignum_ctx = opaque {};
+pub const BN_CTX = struct_bignum_ctx;
+pub const BIO_METHOD = struct_bio_method_st;
+pub const BIO = struct_bio_st;
+pub const bio_info_cb = ?fn ([*c]BIO, c_int, [*c]const u8, c_int, c_long, c_long) callconv(.C) c_long;
+pub const struct_bio_method_st = extern struct {
+ @"type": c_int,
+ name: [*c]const u8,
+ bwrite: ?fn ([*c]BIO, [*c]const u8, c_int) callconv(.C) c_int,
+ bread: ?fn ([*c]BIO, [*c]u8, c_int) callconv(.C) c_int,
+ bputs: ?fn ([*c]BIO, [*c]const u8) callconv(.C) c_int,
+ bgets: ?fn ([*c]BIO, [*c]u8, c_int) callconv(.C) c_int,
+ ctrl: ?fn ([*c]BIO, c_int, c_long, ?*c_void) callconv(.C) c_long,
+ create: ?fn ([*c]BIO) callconv(.C) c_int,
+ destroy: ?fn ([*c]BIO) callconv(.C) c_int,
+ callback_ctrl: ?fn ([*c]BIO, c_int, bio_info_cb) callconv(.C) c_long,
+};
+pub const struct_blake2b_state_st = opaque {};
+pub const BLAKE2B_CTX = struct_blake2b_state_st;
+pub const struct_bn_gencb_st = extern struct {
+ arg: ?*c_void,
+ callback: ?fn (c_int, c_int, [*c]struct_bn_gencb_st) callconv(.C) c_int,
+};
+pub const BN_GENCB = struct_bn_gencb_st;
+pub const struct_buf_mem_st = extern struct {
+ length: usize,
+ data: [*c]u8,
+ max: usize,
+};
+pub const BUF_MEM = struct_buf_mem_st;
+pub const struct_cbb_buffer_st = extern struct {
+ buf: [*c]u8,
+ len: usize,
+ cap: usize,
+ can_resize: u8,
+ @"error": u8,
+};
+pub const CBB = struct_cbb_st;
+pub const struct_cbb_st = extern struct {
+ base: [*c]struct_cbb_buffer_st,
+ child: [*c]CBB,
+ offset: usize,
+ pending_len_len: u8,
+ pending_is_asn1: u8,
+ is_child: u8,
+};
+pub const struct_cbs_st = extern struct {
+ data: [*c]const u8,
+ len: usize,
+};
+pub const CBS = struct_cbs_st;
+pub const struct_cmac_ctx_st = opaque {};
+pub const CMAC_CTX = struct_cmac_ctx_st;
+pub const struct_conf_st = opaque {};
+pub const CONF = struct_conf_st;
+pub const struct_conf_value_st = opaque {};
+pub const CONF_VALUE = struct_conf_value_st;
+pub const struct_crypto_buffer_pool_st = opaque {};
+pub const CRYPTO_BUFFER_POOL = struct_crypto_buffer_pool_st;
+pub const struct_crypto_buffer_st = opaque {};
+pub const CRYPTO_BUFFER = struct_crypto_buffer_st;
+pub const struct_ec_group_st = opaque {};
+pub const EC_GROUP = struct_ec_group_st;
+pub const struct_ec_point_st = opaque {};
+pub const EC_POINT = struct_ec_point_st;
+pub const struct_ecdsa_method_st = extern struct {
+ common: struct_openssl_method_common_st,
+ app_data: ?*c_void,
+ init: ?fn (?*EC_KEY) callconv(.C) c_int,
+ finish: ?fn (?*EC_KEY) callconv(.C) c_int,
+ group_order_size: ?fn (?*const EC_KEY) callconv(.C) usize,
+ sign: ?fn ([*c]const u8, usize, [*c]u8, [*c]c_uint, ?*EC_KEY) callconv(.C) c_int,
+ flags: c_int,
+};
+pub const ECDSA_METHOD = struct_ecdsa_method_st;
+pub const struct_ecdsa_sig_st = extern struct {
+ r: [*c]BIGNUM,
+ s: [*c]BIGNUM,
+};
+pub const ECDSA_SIG = struct_ecdsa_sig_st;
+pub const struct_engine_st = opaque {};
+pub const ENGINE = struct_engine_st;
+pub const struct_env_md_st = opaque {};
+pub const EVP_MD = struct_env_md_st;
+pub const struct_evp_pkey_ctx_st = opaque {};
+pub const EVP_PKEY_CTX = struct_evp_pkey_ctx_st;
+pub const struct_evp_md_pctx_ops = opaque {};
+pub const struct_env_md_ctx_st = extern struct {
+ digest: ?*const EVP_MD,
+ md_data: ?*c_void,
+ pctx: ?*EVP_PKEY_CTX,
+ pctx_ops: ?*const struct_evp_md_pctx_ops,
+};
+pub const EVP_MD_CTX = struct_env_md_ctx_st;
+pub const struct_evp_aead_st = opaque {};
+pub const EVP_AEAD = struct_evp_aead_st;
+pub const struct_evp_encode_ctx_st = extern struct {
+ data_used: c_uint,
+ data: [48]u8,
+ eof_seen: u8,
+ error_encountered: u8,
+};
+pub const EVP_ENCODE_CTX = struct_evp_encode_ctx_st;
+pub const struct_evp_hpke_aead_st = opaque {};
+pub const EVP_HPKE_AEAD = struct_evp_hpke_aead_st;
+pub const struct_evp_hpke_ctx_st = opaque {};
+pub const EVP_HPKE_CTX = struct_evp_hpke_ctx_st;
+pub const struct_evp_hpke_kdf_st = opaque {};
+pub const EVP_HPKE_KDF = struct_evp_hpke_kdf_st;
+pub const struct_evp_hpke_kem_st = opaque {};
+pub const EVP_HPKE_KEM = struct_evp_hpke_kem_st;
+pub const struct_evp_hpke_key_st = opaque {};
+pub const EVP_HPKE_KEY = struct_evp_hpke_key_st;
+pub const struct_evp_pkey_method_st = opaque {};
+pub const EVP_PKEY_METHOD = struct_evp_pkey_method_st;
+pub const struct_hmac_ctx_st = extern struct {
+ md: ?*const EVP_MD,
+ md_ctx: EVP_MD_CTX,
+ i_ctx: EVP_MD_CTX,
+ o_ctx: EVP_MD_CTX,
+};
+pub const HMAC_CTX = struct_hmac_ctx_st;
+pub const struct_md4_state_st = opaque {};
+pub const MD4_CTX = struct_md4_state_st;
+pub const struct_md5_state_st = opaque {};
+pub const MD5_CTX = struct_md5_state_st;
+pub const struct_ossl_init_settings_st = opaque {};
+pub const OPENSSL_INIT_SETTINGS = struct_ossl_init_settings_st;
+pub const struct_pkcs12_st = opaque {};
+pub const PKCS12 = struct_pkcs12_st;
+pub const struct_pkcs8_priv_key_info_st = opaque {};
+pub const PKCS8_PRIV_KEY_INFO = struct_pkcs8_priv_key_info_st;
+pub const struct_rand_meth_st = opaque {};
+pub const RAND_METHOD = struct_rand_meth_st;
+pub const struct_rc4_key_st = opaque {};
+pub const RC4_KEY = struct_rc4_key_st;
+pub const struct_rsa_pss_params_st = extern struct {
+ hashAlgorithm: [*c]X509_ALGOR,
+ maskGenAlgorithm: [*c]X509_ALGOR,
+ saltLength: [*c]ASN1_INTEGER,
+ trailerField: [*c]ASN1_INTEGER,
+ maskHash: [*c]X509_ALGOR,
+};
+pub const RSA_PSS_PARAMS = struct_rsa_pss_params_st;
+pub const struct_sha256_state_st = extern struct {
+ h: [8]u32,
+ Nl: u32,
+ Nh: u32,
+ data: [64]u8,
+ num: c_uint,
+ md_len: c_uint,
+};
+pub const SHA256_CTX = struct_sha256_state_st;
+pub const struct_sha512_state_st = extern struct {
+ h: [8]u64,
+ Nl: u64,
+ Nh: u64,
+ p: [128]u8,
+ num: c_uint,
+ md_len: c_uint,
+};
+pub const SHA512_CTX = struct_sha512_state_st;
+const struct_unnamed_4 = extern struct {
+ h0: u32,
+ h1: u32,
+ h2: u32,
+ h3: u32,
+ h4: u32,
+};
+const union_unnamed_3 = extern union {
+ h: [5]u32,
+ unnamed_0: struct_unnamed_4,
+};
+pub const struct_sha_state_st = extern struct {
+ unnamed_0: union_unnamed_3,
+ Nl: u32,
+ Nh: u32,
+ data: [64]u8,
+ num: c_uint,
+};
+pub const SHA_CTX = struct_sha_state_st;
+pub const struct_spake2_ctx_st = opaque {};
+pub const SPAKE2_CTX = struct_spake2_ctx_st;
+pub const struct_srtp_protection_profile_st = extern struct {
+ name: [*c]const u8,
+ id: c_ulong,
+};
+pub const SRTP_PROTECTION_PROFILE = struct_srtp_protection_profile_st;
+pub const struct_ssl_cipher_st = opaque {};
+pub const SSL_CIPHER = struct_ssl_cipher_st;
+
+pub const struct_ssl_early_callback_ctx = extern struct {
+ ssl: ?*SSL,
+ client_hello: [*c]const u8,
+ client_hello_len: usize,
+ version: u16,
+ random: [*c]const u8,
+ random_len: usize,
+ session_id: [*c]const u8,
+ session_id_len: usize,
+ cipher_suites: [*c]const u8,
+ cipher_suites_len: usize,
+ compression_methods: [*c]const u8,
+ compression_methods_len: usize,
+ extensions: [*c]const u8,
+ extensions_len: usize,
+};
+pub const SSL_CLIENT_HELLO = struct_ssl_early_callback_ctx;
+pub const struct_ssl_ech_keys_st = opaque {};
+pub const SSL_ECH_KEYS = struct_ssl_ech_keys_st;
+pub const struct_ssl_method_st = opaque {};
+pub const SSL_METHOD = struct_ssl_method_st;
+pub const ssl_private_key_success: c_int = 0;
+pub const ssl_private_key_retry: c_int = 1;
+pub const ssl_private_key_failure: c_int = 2;
+pub const enum_ssl_private_key_result_t = c_uint;
+pub const struct_ssl_private_key_method_st = extern struct {
+ sign: ?fn (?*SSL, [*c]u8, [*c]usize, usize, u16, [*c]const u8, usize) callconv(.C) enum_ssl_private_key_result_t,
+ decrypt: ?fn (?*SSL, [*c]u8, [*c]usize, usize, [*c]const u8, usize) callconv(.C) enum_ssl_private_key_result_t,
+ complete: ?fn (?*SSL, [*c]u8, [*c]usize, usize) callconv(.C) enum_ssl_private_key_result_t,
+};
+pub const SSL_PRIVATE_KEY_METHOD = struct_ssl_private_key_method_st;
+pub const ssl_encryption_initial: c_int = 0;
+pub const ssl_encryption_early_data: c_int = 1;
+pub const ssl_encryption_handshake: c_int = 2;
+pub const ssl_encryption_application: c_int = 3;
+pub const enum_ssl_encryption_level_t = c_uint;
+pub const struct_ssl_quic_method_st = extern struct {
+ set_read_secret: ?fn (?*SSL, enum_ssl_encryption_level_t, ?*const SSL_CIPHER, [*c]const u8, usize) callconv(.C) c_int,
+ set_write_secret: ?fn (?*SSL, enum_ssl_encryption_level_t, ?*const SSL_CIPHER, [*c]const u8, usize) callconv(.C) c_int,
+ add_handshake_data: ?fn (?*SSL, enum_ssl_encryption_level_t, [*c]const u8, usize) callconv(.C) c_int,
+ flush_flight: ?fn (?*SSL) callconv(.C) c_int,
+ send_alert: ?fn (?*SSL, enum_ssl_encryption_level_t, u8) callconv(.C) c_int,
+};
+pub const SSL_QUIC_METHOD = struct_ssl_quic_method_st;
+pub const struct_ssl_session_st = opaque {};
+pub const SSL_SESSION = struct_ssl_session_st;
+pub const ssl_ticket_aead_success: c_int = 0;
+pub const ssl_ticket_aead_retry: c_int = 1;
+pub const ssl_ticket_aead_ignore_ticket: c_int = 2;
+pub const ssl_ticket_aead_error: c_int = 3;
+pub const enum_ssl_ticket_aead_result_t = c_uint;
+pub const struct_ssl_ticket_aead_method_st = extern struct {
+ max_overhead: ?fn (?*SSL) callconv(.C) usize,
+ seal: ?fn (?*SSL, [*c]u8, [*c]usize, usize, [*c]const u8, usize) callconv(.C) c_int,
+ open: ?fn (?*SSL, [*c]u8, [*c]usize, usize, [*c]const u8, usize) callconv(.C) enum_ssl_ticket_aead_result_t,
+};
+pub const SSL_TICKET_AEAD_METHOD = struct_ssl_ticket_aead_method_st;
+pub const struct_st_ERR_FNS = opaque {};
+pub const ERR_FNS = struct_st_ERR_FNS;
+pub const struct_trust_token_st = opaque {};
+pub const TRUST_TOKEN = struct_trust_token_st;
+pub const struct_trust_token_client_st = opaque {};
+pub const TRUST_TOKEN_CLIENT = struct_trust_token_client_st;
+pub const struct_trust_token_issuer_st = opaque {};
+pub const TRUST_TOKEN_ISSUER = struct_trust_token_issuer_st;
+pub const struct_trust_token_method_st = opaque {};
+pub const TRUST_TOKEN_METHOD = struct_trust_token_method_st;
+pub const struct_v3_ext_ctx = opaque {};
+pub const X509V3_CTX = struct_v3_ext_ctx;
+pub const struct_x509_attributes_st = opaque {};
+pub const X509_ATTRIBUTE = struct_x509_attributes_st;
+pub const struct_x509_cert_aux_st = opaque {};
+pub const X509_CERT_AUX = struct_x509_cert_aux_st;
+pub const struct_x509_crl_method_st = opaque {};
+pub const X509_CRL_METHOD = struct_x509_crl_method_st;
+pub const struct_x509_lookup_st = opaque {};
+pub const X509_LOOKUP = struct_x509_lookup_st;
+pub const struct_x509_lookup_method_st = opaque {};
+pub const X509_LOOKUP_METHOD = struct_x509_lookup_method_st;
+pub const struct_x509_object_st = opaque {};
+pub const X509_OBJECT = struct_x509_object_st;
+pub const struct_stack_st_X509_EXTENSION = opaque {};
+pub const struct_stack_st_GENERAL_NAME = opaque {};
+pub const struct_x509_revoked_st = extern struct {
+ serialNumber: [*c]ASN1_INTEGER,
+ revocationDate: [*c]ASN1_TIME,
+ extensions: ?*struct_stack_st_X509_EXTENSION,
+ issuer: ?*struct_stack_st_GENERAL_NAME,
+ reason: c_int,
+ sequence: c_int,
+};
+pub const X509_REVOKED = struct_x509_revoked_st;
+pub const struct_x509_store_ctx_st = opaque {};
+pub const X509_STORE_CTX = struct_x509_store_ctx_st;
+pub const struct_x509_store_st = opaque {};
+pub const X509_STORE = struct_x509_store_st;
+pub const struct_x509_trust_st = extern struct {
+ trust: c_int,
+ flags: c_int,
+ check_trust: ?fn ([*c]struct_x509_trust_st, ?*X509, c_int) callconv(.C) c_int,
+ name: [*c]u8,
+ arg1: c_int,
+ arg2: ?*c_void,
+};
+pub const X509_TRUST = struct_x509_trust_st;
+pub const OPENSSL_BLOCK = ?*c_void;
+pub const fpos_t = isize;
+pub const struct___sbuf = extern struct {
+ _base: [*c]u8,
+ _size: c_int,
+};
+pub const struct___sFILEX = opaque {};
+pub const struct___sFILE = extern struct {
+ _p: [*c]u8,
+ _r: c_int,
+ _w: c_int,
+ _flags: c_short,
+ _file: c_short,
+ _bf: struct___sbuf,
+ _lbfsize: c_int,
+ _cookie: ?*c_void,
+ _close: ?fn (?*c_void) callconv(.C) c_int,
+ _read: ?fn (?*c_void, [*c]u8, c_int) callconv(.C) c_int,
+ _seek: ?fn (?*c_void, fpos_t, c_int) callconv(.C) fpos_t,
+ _write: ?fn (?*c_void, [*c]const u8, c_int) callconv(.C) c_int,
+ _ub: struct___sbuf,
+ _extra: ?*struct___sFILEX,
+ _ur: c_int,
+ _ubuf: [3]u8,
+ _nbuf: [1]u8,
+ _lb: struct___sbuf,
+ _blksize: c_int,
+ _offset: fpos_t,
+};
+pub const FILE = struct___sFILE;
+pub extern const sys_nerr: c_int;
+pub extern const sys_errlist: [*c]const [*c]const u8;
+pub extern fn BUF_MEM_new() [*c]BUF_MEM;
+pub extern fn BUF_MEM_free(buf: [*c]BUF_MEM) void;
+pub extern fn BUF_MEM_reserve(buf: [*c]BUF_MEM, cap: usize) c_int;
+pub extern fn BUF_MEM_grow(buf: [*c]BUF_MEM, len: usize) usize;
+pub extern fn BUF_MEM_grow_clean(buf: [*c]BUF_MEM, len: usize) usize;
+pub extern fn BUF_MEM_append(buf: [*c]BUF_MEM, in: ?*const c_void, len: usize) c_int;
+pub extern fn BUF_strdup(str: [*c]const u8) [*c]u8;
+pub extern fn BUF_strnlen(str: [*c]const u8, max_len: usize) usize;
+pub extern fn BUF_strndup(str: [*c]const u8, size: usize) [*c]u8;
+pub extern fn BUF_memdup(data: ?*const c_void, size: usize) ?*c_void;
+pub extern fn BUF_strlcpy(dst: [*c]u8, src: [*c]const u8, dst_size: usize) usize;
+pub extern fn BUF_strlcat(dst: [*c]u8, src: [*c]const u8, dst_size: usize) usize;
+pub extern fn ERR_load_BIO_strings() void;
+pub extern fn ERR_load_ERR_strings() void;
+pub extern fn ERR_load_crypto_strings() void;
+pub extern fn ERR_load_RAND_strings() void;
+pub extern fn ERR_free_strings() void;
+pub extern fn ERR_get_error() u32;
+pub extern fn ERR_get_error_line(file: [*c][*c]const u8, line: [*c]c_int) u32;
+pub extern fn ERR_get_error_line_data(file: [*c][*c]const u8, line: [*c]c_int, data: [*c][*c]const u8, flags: [*c]c_int) u32;
+pub extern fn ERR_peek_error() u32;
+pub extern fn ERR_peek_error_line(file: [*c][*c]const u8, line: [*c]c_int) u32;
+pub extern fn ERR_peek_error_line_data(file: [*c][*c]const u8, line: [*c]c_int, data: [*c][*c]const u8, flags: [*c]c_int) u32;
+pub extern fn ERR_peek_last_error() u32;
+pub extern fn ERR_peek_last_error_line(file: [*c][*c]const u8, line: [*c]c_int) u32;
+pub extern fn ERR_peek_last_error_line_data(file: [*c][*c]const u8, line: [*c]c_int, data: [*c][*c]const u8, flags: [*c]c_int) u32;
+pub extern fn ERR_error_string_n(packed_error: u32, buf: [*c]u8, len: usize) [*c]u8;
+pub extern fn ERR_lib_error_string(packed_error: u32) [*c]const u8;
+pub extern fn ERR_reason_error_string(packed_error: u32) [*c]const u8;
+pub const ERR_print_errors_callback_t = ?fn ([*c]const u8, usize, ?*c_void) callconv(.C) c_int;
+pub extern fn ERR_print_errors_cb(callback: ERR_print_errors_callback_t, ctx: ?*c_void) void;
+pub extern fn ERR_print_errors_fp(file: [*c]FILE) void;
+pub extern fn ERR_clear_error() void;
+pub extern fn ERR_set_mark() c_int;
+pub extern fn ERR_pop_to_mark() c_int;
+pub extern fn ERR_get_next_error_library() c_int;
+pub const ERR_LIB_NONE: c_int = 1;
+pub const ERR_LIB_SYS: c_int = 2;
+pub const ERR_LIB_BN: c_int = 3;
+pub const ERR_LIB_RSA: c_int = 4;
+pub const ERR_LIB_DH: c_int = 5;
+pub const ERR_LIB_EVP: c_int = 6;
+pub const ERR_LIB_BUF: c_int = 7;
+pub const ERR_LIB_OBJ: c_int = 8;
+pub const ERR_LIB_PEM: c_int = 9;
+pub const ERR_LIB_DSA: c_int = 10;
+pub const ERR_LIB_X509: c_int = 11;
+pub const ERR_LIB_ASN1: c_int = 12;
+pub const ERR_LIB_CONF: c_int = 13;
+pub const ERR_LIB_CRYPTO: c_int = 14;
+pub const ERR_LIB_EC: c_int = 15;
+pub const ERR_LIB_SSL: c_int = 16;
+pub const ERR_LIB_BIO: c_int = 17;
+pub const ERR_LIB_PKCS7: c_int = 18;
+pub const ERR_LIB_PKCS8: c_int = 19;
+pub const ERR_LIB_X509V3: c_int = 20;
+pub const ERR_LIB_RAND: c_int = 21;
+pub const ERR_LIB_ENGINE: c_int = 22;
+pub const ERR_LIB_OCSP: c_int = 23;
+pub const ERR_LIB_UI: c_int = 24;
+pub const ERR_LIB_COMP: c_int = 25;
+pub const ERR_LIB_ECDSA: c_int = 26;
+pub const ERR_LIB_ECDH: c_int = 27;
+pub const ERR_LIB_HMAC: c_int = 28;
+pub const ERR_LIB_DIGEST: c_int = 29;
+pub const ERR_LIB_CIPHER: c_int = 30;
+pub const ERR_LIB_HKDF: c_int = 31;
+pub const ERR_LIB_TRUST_TOKEN: c_int = 32;
+pub const ERR_LIB_USER: c_int = 33;
+pub const ERR_NUM_LIBS: c_int = 34;
+const enum_unnamed_5 = c_uint;
+pub extern fn ERR_remove_state(pid: c_ulong) void;
+pub extern fn ERR_remove_thread_state(tid: [*c]const CRYPTO_THREADID) void;
+pub extern fn ERR_func_error_string(packed_error: u32) [*c]const u8;
+pub extern fn ERR_error_string(packed_error: u32, buf: [*c]u8) [*c]u8;
+pub extern fn ERR_clear_system_error() void;
+pub extern fn ERR_put_error(library: c_int, unused: c_int, reason: c_int, file: [*c]const u8, line: c_uint) void;
+pub extern fn ERR_add_error_data(count: c_uint, ...) void;
+pub extern fn ERR_add_error_dataf(format: [*c]const u8, ...) void;
+pub const stack_free_func = ?fn (?*c_void) callconv(.C) void;
+pub const stack_copy_func = ?fn (?*c_void) callconv(.C) ?*c_void;
+pub const stack_cmp_func = ?fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int;
+pub const struct_stack_st = extern struct {
+ num: usize,
+ data: [*c]?*c_void,
+ sorted: c_int,
+ num_alloc: usize,
+ comp: stack_cmp_func,
+};
+pub const _STACK = struct_stack_st;
+pub extern fn sk_new(comp: stack_cmp_func) [*c]_STACK;
+pub extern fn sk_new_null() [*c]_STACK;
+pub extern fn sk_num(sk: [*c]const _STACK) usize;
+pub extern fn sk_zero(sk: [*c]_STACK) void;
+pub extern fn sk_value(sk: [*c]const _STACK, i: usize) ?*c_void;
+pub extern fn sk_set(sk: [*c]_STACK, i: usize, p: ?*c_void) ?*c_void;
+pub extern fn sk_free(sk: [*c]_STACK) void;
+pub extern fn sk_pop_free_ex(sk: [*c]_STACK, call_free_func: ?fn (stack_free_func, ?*c_void) callconv(.C) void, free_func: stack_free_func) void;
+pub extern fn sk_insert(sk: [*c]_STACK, p: ?*c_void, where: usize) usize;
+pub extern fn sk_delete(sk: [*c]_STACK, where: usize) ?*c_void;
+pub extern fn sk_delete_ptr(sk: [*c]_STACK, p: ?*const c_void) ?*c_void;
+pub extern fn sk_find(sk: [*c]const _STACK, out_index: [*c]usize, p: ?*const c_void, call_cmp_func: ?fn (stack_cmp_func, [*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int) c_int;
+pub extern fn sk_shift(sk: [*c]_STACK) ?*c_void;
+pub extern fn sk_push(sk: [*c]_STACK, p: ?*c_void) usize;
+pub extern fn sk_pop(sk: [*c]_STACK) ?*c_void;
+pub extern fn sk_dup(sk: [*c]const _STACK) [*c]_STACK;
+pub extern fn sk_sort(sk: [*c]_STACK) void;
+pub extern fn sk_is_sorted(sk: [*c]const _STACK) c_int;
+pub extern fn sk_set_cmp_func(sk: [*c]_STACK, comp: stack_cmp_func) stack_cmp_func;
+pub extern fn sk_deep_copy(sk: [*c]const _STACK, call_copy_func: ?fn (stack_copy_func, ?*c_void) callconv(.C) ?*c_void, copy_func: stack_copy_func, call_free_func: ?fn (stack_free_func, ?*c_void) callconv(.C) void, free_func: stack_free_func) [*c]_STACK;
+pub extern fn sk_pop_free(sk: [*c]_STACK, free_func: stack_free_func) void;
+pub const OPENSSL_STRING = [*c]u8;
+pub const stack_void_free_func = ?fn (?*c_void) callconv(.C) void;
+pub const stack_void_copy_func = ?fn (?*c_void) callconv(.C) ?*c_void;
+pub const stack_void_cmp_func = ?fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int;
+pub fn sk_void_call_free_func(arg_free_func: stack_free_func, arg_ptr: ?*c_void) callconv(.C) void {
+ var free_func = arg_free_func;
+ var ptr = arg_ptr;
+ @ptrCast(stack_void_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func)).?(ptr);
+}
+pub fn sk_void_call_copy_func(arg_copy_func: stack_copy_func, arg_ptr: ?*c_void) callconv(.C) ?*c_void {
+ var copy_func = arg_copy_func;
+ var ptr = arg_ptr;
+ return @ptrCast(stack_void_copy_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) ?*c_void), copy_func)).?(ptr);
+}
+pub fn sk_void_call_cmp_func(arg_cmp_func: stack_cmp_func, arg_a: [*c]?*const c_void, arg_b: [*c]?*const c_void) callconv(.C) c_int {
+ var cmp_func = arg_cmp_func;
+ var a = arg_a;
+ var b = arg_b;
+ var a_ptr: ?*const c_void = a.*;
+ var b_ptr: ?*const c_void = b.*;
+ return @ptrCast(stack_void_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), cmp_func)).?(&a_ptr, &b_ptr);
+}
+pub fn sk_void_new(arg_comp: stack_void_cmp_func) callconv(.C) ?*struct_stack_st_void {
+ var comp = arg_comp;
+ return @ptrCast(?*struct_stack_st_void, sk_new(@ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp))));
+}
+pub fn sk_void_new_null() callconv(.C) ?*struct_stack_st_void {
+ return @ptrCast(?*struct_stack_st_void, sk_new_null());
+}
+pub fn sk_void_num(arg_sk: ?*const struct_stack_st_void) callconv(.C) usize {
+ var sk = arg_sk;
+ return sk_num(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_void_zero(arg_sk: ?*struct_stack_st_void) callconv(.C) void {
+ var sk = arg_sk;
+ sk_zero(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_void_value(arg_sk: ?*const struct_stack_st_void, arg_i: usize) callconv(.C) ?*c_void {
+ var sk = arg_sk;
+ var i = arg_i;
+ return sk_value(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i);
+}
+pub fn sk_void_set(arg_sk: ?*struct_stack_st_void, arg_i: usize, arg_p: ?*c_void) callconv(.C) ?*c_void {
+ var sk = arg_sk;
+ var i = arg_i;
+ var p = arg_p;
+ return sk_set(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i, p);
+}
+pub fn sk_void_free(arg_sk: ?*struct_stack_st_void) callconv(.C) void {
+ var sk = arg_sk;
+ sk_free(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_void_pop_free(arg_sk: ?*struct_stack_st_void, arg_free_func: stack_void_free_func) callconv(.C) void {
+ var sk = arg_sk;
+ var free_func = arg_free_func;
+ sk_pop_free_ex(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_void_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func)));
+}
+pub fn sk_void_insert(arg_sk: ?*struct_stack_st_void, arg_p: ?*c_void, arg_where: usize) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ var where = arg_where;
+ return sk_insert(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), p, where);
+}
+pub fn sk_void_delete(arg_sk: ?*struct_stack_st_void, arg_where: usize) callconv(.C) ?*c_void {
+ var sk = arg_sk;
+ var where = arg_where;
+ return sk_delete(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), where);
+}
+pub fn sk_void_delete_ptr(arg_sk: ?*struct_stack_st_void, arg_p: ?*const c_void) callconv(.C) ?*c_void {
+ var sk = arg_sk;
+ var p = arg_p;
+ return sk_delete_ptr(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), p);
+}
+pub fn sk_void_find(arg_sk: ?*const struct_stack_st_void, arg_out_index: [*c]usize, arg_p: ?*const c_void) callconv(.C) c_int {
+ var sk = arg_sk;
+ var out_index = arg_out_index;
+ var p = arg_p;
+ return sk_find(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), out_index, p, sk_void_call_cmp_func);
+}
+pub fn sk_void_shift(arg_sk: ?*struct_stack_st_void) callconv(.C) ?*c_void {
+ var sk = arg_sk;
+ return sk_shift(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_void_push(arg_sk: ?*struct_stack_st_void, arg_p: ?*c_void) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ return sk_push(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), p);
+}
+pub fn sk_void_pop(arg_sk: ?*struct_stack_st_void) callconv(.C) ?*c_void {
+ var sk = arg_sk;
+ return sk_pop(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_void_dup(arg_sk: ?*const struct_stack_st_void) callconv(.C) ?*struct_stack_st_void {
+ var sk = arg_sk;
+ return @ptrCast(?*struct_stack_st_void, sk_dup(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_void_sort(arg_sk: ?*struct_stack_st_void) callconv(.C) void {
+ var sk = arg_sk;
+ sk_sort(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_void_is_sorted(arg_sk: ?*const struct_stack_st_void) callconv(.C) c_int {
+ var sk = arg_sk;
+ return sk_is_sorted(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_void_set_cmp_func(arg_sk: ?*struct_stack_st_void, arg_comp: stack_void_cmp_func) callconv(.C) stack_void_cmp_func {
+ var sk = arg_sk;
+ var comp = arg_comp;
+ return @ptrCast(stack_void_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), sk_set_cmp_func(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp)))));
+}
+pub fn sk_void_deep_copy(arg_sk: ?*const struct_stack_st_void, arg_copy_func: ?fn (?*c_void) callconv(.C) ?*c_void, arg_free_func: ?fn (?*c_void) callconv(.C) void) callconv(.C) ?*struct_stack_st_void {
+ var sk = arg_sk;
+ var copy_func = arg_copy_func;
+ var free_func = arg_free_func;
+ return @ptrCast(?*struct_stack_st_void, sk_deep_copy(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_void_call_copy_func, @ptrCast(stack_copy_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) ?*c_void), copy_func)), sk_void_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func))));
+} // /Users/jarred/Code/bun/src/deps/boringssl/include/openssl/type_check.h:75:42: warning: ignoring StaticAssert declaration
+pub const struct_stack_st_OPENSSL_STRING = opaque {};
+pub const stack_OPENSSL_STRING_free_func = ?fn (OPENSSL_STRING) callconv(.C) void;
+pub const stack_OPENSSL_STRING_copy_func = ?fn (OPENSSL_STRING) callconv(.C) OPENSSL_STRING;
+pub const stack_OPENSSL_STRING_cmp_func = ?fn ([*c]const OPENSSL_STRING, [*c]const OPENSSL_STRING) callconv(.C) c_int;
+pub fn sk_OPENSSL_STRING_call_free_func(arg_free_func: stack_free_func, arg_ptr: ?*c_void) callconv(.C) void {
+ var free_func = arg_free_func;
+ var ptr = arg_ptr;
+ @ptrCast(stack_OPENSSL_STRING_free_func, @alignCast(@import("std").meta.alignment(fn (OPENSSL_STRING) callconv(.C) void), free_func)).?(@ptrCast(OPENSSL_STRING, @alignCast(@import("std").meta.alignment(u8), ptr)));
+}
+pub fn sk_OPENSSL_STRING_call_copy_func(arg_copy_func: stack_copy_func, arg_ptr: ?*c_void) callconv(.C) ?*c_void {
+ var copy_func = arg_copy_func;
+ var ptr = arg_ptr;
+ return @ptrCast(?*c_void, @ptrCast(stack_OPENSSL_STRING_copy_func, @alignCast(@import("std").meta.alignment(fn (OPENSSL_STRING) callconv(.C) OPENSSL_STRING), copy_func)).?(@ptrCast(OPENSSL_STRING, @alignCast(@import("std").meta.alignment(u8), ptr))));
+}
+pub fn sk_OPENSSL_STRING_call_cmp_func(arg_cmp_func: stack_cmp_func, arg_a: [*c]?*const c_void, arg_b: [*c]?*const c_void) callconv(.C) c_int {
+ var cmp_func = arg_cmp_func;
+ var a = arg_a;
+ var b = arg_b;
+ const a_ptr: OPENSSL_STRING = @intToPtr(OPENSSL_STRING, @ptrToInt(a.*));
+ const b_ptr: OPENSSL_STRING = @intToPtr(OPENSSL_STRING, @ptrToInt(b.*));
+ return @ptrCast(stack_OPENSSL_STRING_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]const OPENSSL_STRING, [*c]const OPENSSL_STRING) callconv(.C) c_int), cmp_func)).?(&a_ptr, &b_ptr);
+}
+pub fn sk_OPENSSL_STRING_new(arg_comp: stack_OPENSSL_STRING_cmp_func) callconv(.C) ?*struct_stack_st_OPENSSL_STRING {
+ var comp = arg_comp;
+ return @ptrCast(?*struct_stack_st_OPENSSL_STRING, sk_new(@ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp))));
+}
+pub fn sk_OPENSSL_STRING_new_null() callconv(.C) ?*struct_stack_st_OPENSSL_STRING {
+ return @ptrCast(?*struct_stack_st_OPENSSL_STRING, sk_new_null());
+}
+pub fn sk_OPENSSL_STRING_num(arg_sk: ?*const struct_stack_st_OPENSSL_STRING) callconv(.C) usize {
+ var sk = arg_sk;
+ return sk_num(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_OPENSSL_STRING_zero(arg_sk: ?*struct_stack_st_OPENSSL_STRING) callconv(.C) void {
+ var sk = arg_sk;
+ sk_zero(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_OPENSSL_STRING_value(arg_sk: ?*const struct_stack_st_OPENSSL_STRING, arg_i: usize) callconv(.C) OPENSSL_STRING {
+ var sk = arg_sk;
+ var i = arg_i;
+ return @ptrCast(OPENSSL_STRING, @alignCast(@import("std").meta.alignment(u8), sk_value(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i)));
+}
+pub fn sk_OPENSSL_STRING_set(arg_sk: ?*struct_stack_st_OPENSSL_STRING, arg_i: usize, arg_p: OPENSSL_STRING) callconv(.C) OPENSSL_STRING {
+ var sk = arg_sk;
+ var i = arg_i;
+ var p = arg_p;
+ return @ptrCast(OPENSSL_STRING, @alignCast(@import("std").meta.alignment(u8), sk_set(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i, @ptrCast(?*c_void, p))));
+}
+pub fn sk_OPENSSL_STRING_free(arg_sk: ?*struct_stack_st_OPENSSL_STRING) callconv(.C) void {
+ var sk = arg_sk;
+ sk_free(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_OPENSSL_STRING_pop_free(arg_sk: ?*struct_stack_st_OPENSSL_STRING, arg_free_func: stack_OPENSSL_STRING_free_func) callconv(.C) void {
+ var sk = arg_sk;
+ var free_func = arg_free_func;
+ sk_pop_free_ex(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_OPENSSL_STRING_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func)));
+}
+pub fn sk_OPENSSL_STRING_insert(arg_sk: ?*struct_stack_st_OPENSSL_STRING, arg_p: OPENSSL_STRING, arg_where: usize) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ var where = arg_where;
+ return sk_insert(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p), where);
+}
+pub fn sk_OPENSSL_STRING_delete(arg_sk: ?*struct_stack_st_OPENSSL_STRING, arg_where: usize) callconv(.C) OPENSSL_STRING {
+ var sk = arg_sk;
+ var where = arg_where;
+ return @ptrCast(OPENSSL_STRING, @alignCast(@import("std").meta.alignment(u8), sk_delete(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), where)));
+}
+pub fn sk_OPENSSL_STRING_delete_ptr(arg_sk: ?*struct_stack_st_OPENSSL_STRING, p: OPENSSL_STRING) callconv(.C) OPENSSL_STRING {
+ var sk = arg_sk;
+ return @ptrCast(OPENSSL_STRING, @alignCast(@import("std").meta.alignment(u8), sk_delete_ptr(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*const c_void, p))));
+}
+pub fn sk_OPENSSL_STRING_find(arg_sk: ?*const struct_stack_st_OPENSSL_STRING, arg_out_index: [*c]usize, p: OPENSSL_STRING) callconv(.C) c_int {
+ var sk = arg_sk;
+ var out_index = arg_out_index;
+ return sk_find(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), out_index, @ptrCast(?*const c_void, p), sk_OPENSSL_STRING_call_cmp_func);
+}
+pub fn sk_OPENSSL_STRING_shift(arg_sk: ?*struct_stack_st_OPENSSL_STRING) callconv(.C) OPENSSL_STRING {
+ var sk = arg_sk;
+ return @ptrCast(OPENSSL_STRING, @alignCast(@import("std").meta.alignment(u8), sk_shift(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)))));
+}
+pub fn sk_OPENSSL_STRING_push(arg_sk: ?*struct_stack_st_OPENSSL_STRING, arg_p: OPENSSL_STRING) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ return sk_push(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p));
+}
+pub fn sk_OPENSSL_STRING_pop(arg_sk: ?*struct_stack_st_OPENSSL_STRING) callconv(.C) OPENSSL_STRING {
+ var sk = arg_sk;
+ return @ptrCast(OPENSSL_STRING, @alignCast(@import("std").meta.alignment(u8), sk_pop(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)))));
+}
+pub fn sk_OPENSSL_STRING_dup(arg_sk: ?*const struct_stack_st_OPENSSL_STRING) callconv(.C) ?*struct_stack_st_OPENSSL_STRING {
+ var sk = arg_sk;
+ return @ptrCast(?*struct_stack_st_OPENSSL_STRING, sk_dup(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_OPENSSL_STRING_sort(arg_sk: ?*struct_stack_st_OPENSSL_STRING) callconv(.C) void {
+ var sk = arg_sk;
+ sk_sort(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_OPENSSL_STRING_is_sorted(arg_sk: ?*const struct_stack_st_OPENSSL_STRING) callconv(.C) c_int {
+ var sk = arg_sk;
+ return sk_is_sorted(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_OPENSSL_STRING_set_cmp_func(arg_sk: ?*struct_stack_st_OPENSSL_STRING, arg_comp: stack_OPENSSL_STRING_cmp_func) callconv(.C) stack_OPENSSL_STRING_cmp_func {
+ var sk = arg_sk;
+ var comp = arg_comp;
+ return @ptrCast(stack_OPENSSL_STRING_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]const OPENSSL_STRING, [*c]const OPENSSL_STRING) callconv(.C) c_int), sk_set_cmp_func(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp)))));
+}
+pub fn sk_OPENSSL_STRING_deep_copy(arg_sk: ?*const struct_stack_st_OPENSSL_STRING, arg_copy_func: ?fn (OPENSSL_STRING) callconv(.C) OPENSSL_STRING, arg_free_func: ?fn (OPENSSL_STRING) callconv(.C) void) callconv(.C) ?*struct_stack_st_OPENSSL_STRING {
+ var sk = arg_sk;
+ var copy_func = arg_copy_func;
+ var free_func = arg_free_func;
+ return @ptrCast(?*struct_stack_st_OPENSSL_STRING, sk_deep_copy(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_OPENSSL_STRING_call_copy_func, @ptrCast(stack_copy_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) ?*c_void), copy_func)), sk_OPENSSL_STRING_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func))));
+}
+pub const CRYPTO_EX_free = fn (?*c_void, ?*c_void, [*c]CRYPTO_EX_DATA, c_int, c_long, ?*c_void) callconv(.C) void;
+pub extern fn CRYPTO_cleanup_all_ex_data() void;
+pub const CRYPTO_EX_dup = fn ([*c]CRYPTO_EX_DATA, [*c]const CRYPTO_EX_DATA, [*c]?*c_void, c_int, c_long, ?*c_void) callconv(.C) c_int;
+pub const CRYPTO_EX_unused = c_int;
+pub extern fn CRYPTO_num_locks() c_int;
+pub extern fn CRYPTO_set_locking_callback(func: ?fn (c_int, c_int, [*c]const u8, c_int) callconv(.C) void) void;
+pub extern fn CRYPTO_set_add_lock_callback(func: ?fn ([*c]c_int, c_int, c_int, [*c]const u8, c_int) callconv(.C) c_int) void;
+pub extern fn CRYPTO_get_locking_callback() ?fn (c_int, c_int, [*c]const u8, c_int) callconv(.C) void;
+pub extern fn CRYPTO_get_lock_name(lock_num: c_int) [*c]const u8;
+pub extern fn CRYPTO_THREADID_set_callback(threadid_func: ?fn ([*c]CRYPTO_THREADID) callconv(.C) void) c_int;
+pub extern fn CRYPTO_THREADID_set_numeric(id: [*c]CRYPTO_THREADID, val: c_ulong) void;
+pub extern fn CRYPTO_THREADID_set_pointer(id: [*c]CRYPTO_THREADID, ptr: ?*c_void) void;
+pub extern fn CRYPTO_THREADID_current(id: [*c]CRYPTO_THREADID) void;
+pub extern fn CRYPTO_set_id_callback(func: ?fn () callconv(.C) c_ulong) void;
+pub const struct_CRYPTO_dynlock_value = opaque {};
+pub const CRYPTO_dynlock = extern struct {
+ references: c_int,
+ data: ?*struct_CRYPTO_dynlock_value,
+};
+pub extern fn CRYPTO_set_dynlock_create_callback(dyn_create_function: ?fn ([*c]const u8, c_int) callconv(.C) ?*struct_CRYPTO_dynlock_value) void;
+pub extern fn CRYPTO_set_dynlock_lock_callback(dyn_lock_function: ?fn (c_int, ?*struct_CRYPTO_dynlock_value, [*c]const u8, c_int) callconv(.C) void) void;
+pub extern fn CRYPTO_set_dynlock_destroy_callback(dyn_destroy_function: ?fn (?*struct_CRYPTO_dynlock_value, [*c]const u8, c_int) callconv(.C) void) void;
+pub extern fn CRYPTO_get_dynlock_create_callback() ?fn ([*c]const u8, c_int) callconv(.C) ?*struct_CRYPTO_dynlock_value;
+pub extern fn CRYPTO_get_dynlock_lock_callback() ?fn (c_int, ?*struct_CRYPTO_dynlock_value, [*c]const u8, c_int) callconv(.C) void;
+pub extern fn CRYPTO_get_dynlock_destroy_callback() ?fn (?*struct_CRYPTO_dynlock_value, [*c]const u8, c_int) callconv(.C) void;
+pub const struct_stack_st_BIO = opaque {};
+pub const stack_BIO_free_func = ?fn ([*c]BIO) callconv(.C) void;
+pub const stack_BIO_copy_func = ?fn ([*c]BIO) callconv(.C) [*c]BIO;
+pub const stack_BIO_cmp_func = ?fn ([*c][*c]const BIO, [*c][*c]const BIO) callconv(.C) c_int;
+pub fn sk_BIO_call_free_func(arg_free_func: stack_free_func, arg_ptr: ?*c_void) callconv(.C) void {
+ var free_func = arg_free_func;
+ var ptr = arg_ptr;
+ @ptrCast(stack_BIO_free_func, @alignCast(@import("std").meta.alignment(fn ([*c]BIO) callconv(.C) void), free_func)).?(@ptrCast([*c]BIO, @alignCast(@import("std").meta.alignment(BIO), ptr)));
+}
+pub fn sk_BIO_call_copy_func(arg_copy_func: stack_copy_func, arg_ptr: ?*c_void) callconv(.C) ?*c_void {
+ var copy_func = arg_copy_func;
+ var ptr = arg_ptr;
+ return @ptrCast(?*c_void, @ptrCast(stack_BIO_copy_func, @alignCast(@import("std").meta.alignment(fn ([*c]BIO) callconv(.C) [*c]BIO), copy_func)).?(@ptrCast([*c]BIO, @alignCast(@import("std").meta.alignment(BIO), ptr))));
+}
+pub fn sk_BIO_call_cmp_func(arg_cmp_func: stack_cmp_func, arg_a: [*c]?*const c_void, arg_b: [*c]?*const c_void) callconv(.C) c_int {
+ var cmp_func = arg_cmp_func;
+ var a = arg_a;
+ var b = arg_b;
+ var a_ptr: [*c]const BIO = @ptrCast([*c]const BIO, @alignCast(@import("std").meta.alignment(BIO), a.*));
+ var b_ptr: [*c]const BIO = @ptrCast([*c]const BIO, @alignCast(@import("std").meta.alignment(BIO), b.*));
+ return @ptrCast(stack_BIO_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c][*c]const BIO, [*c][*c]const BIO) callconv(.C) c_int), cmp_func)).?(&a_ptr, &b_ptr);
+}
+pub fn sk_BIO_new(arg_comp: stack_BIO_cmp_func) callconv(.C) ?*struct_stack_st_BIO {
+ var comp = arg_comp;
+ return @ptrCast(?*struct_stack_st_BIO, sk_new(@ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp))));
+}
+pub fn sk_BIO_new_null() callconv(.C) ?*struct_stack_st_BIO {
+ return @ptrCast(?*struct_stack_st_BIO, sk_new_null());
+}
+pub fn sk_BIO_num(arg_sk: ?*const struct_stack_st_BIO) callconv(.C) usize {
+ var sk = arg_sk;
+ return sk_num(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_BIO_zero(arg_sk: ?*struct_stack_st_BIO) callconv(.C) void {
+ var sk = arg_sk;
+ sk_zero(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_BIO_value(arg_sk: ?*const struct_stack_st_BIO, arg_i: usize) callconv(.C) [*c]BIO {
+ var sk = arg_sk;
+ var i = arg_i;
+ return @ptrCast([*c]BIO, @alignCast(@import("std").meta.alignment(BIO), sk_value(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i)));
+}
+pub fn sk_BIO_set(arg_sk: ?*struct_stack_st_BIO, arg_i: usize, arg_p: [*c]BIO) callconv(.C) [*c]BIO {
+ var sk = arg_sk;
+ var i = arg_i;
+ var p = arg_p;
+ return @ptrCast([*c]BIO, @alignCast(@import("std").meta.alignment(BIO), sk_set(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i, @ptrCast(?*c_void, p))));
+}
+pub fn sk_BIO_free(arg_sk: ?*struct_stack_st_BIO) callconv(.C) void {
+ var sk = arg_sk;
+ sk_free(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_BIO_pop_free(arg_sk: ?*struct_stack_st_BIO, arg_free_func: stack_BIO_free_func) callconv(.C) void {
+ var sk = arg_sk;
+ var free_func = arg_free_func;
+ sk_pop_free_ex(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_BIO_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func)));
+}
+pub fn sk_BIO_insert(arg_sk: ?*struct_stack_st_BIO, arg_p: [*c]BIO, arg_where: usize) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ var where = arg_where;
+ return sk_insert(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p), where);
+}
+pub fn sk_BIO_delete(arg_sk: ?*struct_stack_st_BIO, arg_where: usize) callconv(.C) [*c]BIO {
+ var sk = arg_sk;
+ var where = arg_where;
+ return @ptrCast([*c]BIO, @alignCast(@import("std").meta.alignment(BIO), sk_delete(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), where)));
+}
+pub fn sk_BIO_delete_ptr(arg_sk: ?*struct_stack_st_BIO, arg_p: [*c]const BIO) callconv(.C) [*c]BIO {
+ var sk = arg_sk;
+ var p = arg_p;
+ return @ptrCast([*c]BIO, @alignCast(@import("std").meta.alignment(BIO), sk_delete_ptr(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*const c_void, p))));
+}
+pub fn sk_BIO_find(arg_sk: ?*const struct_stack_st_BIO, arg_out_index: [*c]usize, arg_p: [*c]const BIO) callconv(.C) c_int {
+ var sk = arg_sk;
+ var out_index = arg_out_index;
+ var p = arg_p;
+ return sk_find(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), out_index, @ptrCast(?*const c_void, p), sk_BIO_call_cmp_func);
+}
+pub fn sk_BIO_shift(arg_sk: ?*struct_stack_st_BIO) callconv(.C) [*c]BIO {
+ var sk = arg_sk;
+ return @ptrCast([*c]BIO, @alignCast(@import("std").meta.alignment(BIO), sk_shift(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)))));
+}
+pub fn sk_BIO_push(arg_sk: ?*struct_stack_st_BIO, arg_p: [*c]BIO) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ return sk_push(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p));
+}
+pub fn sk_BIO_pop(arg_sk: ?*struct_stack_st_BIO) callconv(.C) [*c]BIO {
+ var sk = arg_sk;
+ return @ptrCast([*c]BIO, @alignCast(@import("std").meta.alignment(BIO), sk_pop(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)))));
+}
+pub fn sk_BIO_dup(arg_sk: ?*const struct_stack_st_BIO) callconv(.C) ?*struct_stack_st_BIO {
+ var sk = arg_sk;
+ return @ptrCast(?*struct_stack_st_BIO, sk_dup(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_BIO_sort(arg_sk: ?*struct_stack_st_BIO) callconv(.C) void {
+ var sk = arg_sk;
+ sk_sort(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_BIO_is_sorted(arg_sk: ?*const struct_stack_st_BIO) callconv(.C) c_int {
+ var sk = arg_sk;
+ return sk_is_sorted(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_BIO_set_cmp_func(arg_sk: ?*struct_stack_st_BIO, arg_comp: stack_BIO_cmp_func) callconv(.C) stack_BIO_cmp_func {
+ var sk = arg_sk;
+ var comp = arg_comp;
+ return @ptrCast(stack_BIO_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c][*c]const BIO, [*c][*c]const BIO) callconv(.C) c_int), sk_set_cmp_func(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp)))));
+}
+pub fn sk_BIO_deep_copy(arg_sk: ?*const struct_stack_st_BIO, arg_copy_func: ?fn ([*c]BIO) callconv(.C) [*c]BIO, arg_free_func: ?fn ([*c]BIO) callconv(.C) void) callconv(.C) ?*struct_stack_st_BIO {
+ var sk = arg_sk;
+ var copy_func = arg_copy_func;
+ var free_func = arg_free_func;
+ return @ptrCast(?*struct_stack_st_BIO, sk_deep_copy(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_BIO_call_copy_func, @ptrCast(stack_copy_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) ?*c_void), copy_func)), sk_BIO_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func))));
+}
+pub extern fn BIO_new(method: *const BIO_METHOD) ?*BIO;
+pub extern fn BIO_free(bio: *BIO) c_int;
+pub extern fn BIO_vfree(bio: *BIO) void;
+pub extern fn BIO_up_ref(bio: *BIO) c_int;
+pub extern fn BIO_read(bio: *BIO, data: ?*c_void, len: c_int) c_int;
+pub extern fn BIO_gets(bio: *BIO, buf: [*c]u8, size: c_int) c_int;
+pub extern fn BIO_write(bio: *BIO, data: ?*const c_void, len: c_int) c_int;
+pub extern fn BIO_write_all(bio: *BIO, data: ?*const c_void, len: usize) c_int;
+pub extern fn BIO_puts(bio: *BIO, buf: [*c]const u8) c_int;
+pub extern fn BIO_flush(bio: *BIO) c_int;
+pub extern fn BIO_ctrl(bio: *BIO, cmd: c_int, larg: c_long, parg: ?*c_void) c_long;
+pub extern fn BIO_ptr_ctrl(bp: *BIO, cmd: c_int, larg: c_long) [*c]u8;
+pub extern fn BIO_int_ctrl(bp: *BIO, cmd: c_int, larg: c_long, iarg: c_int) c_long;
+pub extern fn BIO_reset(bio: *BIO) c_int;
+pub extern fn BIO_eof(bio: *BIO) c_int;
+pub extern fn BIO_set_flags(bio: *BIO, flags: c_int) void;
+pub extern fn BIO_test_flags(bio: *const BIO, flags: c_int) c_int;
+pub extern fn BIO_should_read(bio: *const BIO) c_int;
+pub extern fn BIO_should_write(bio: *const BIO) c_int;
+pub extern fn BIO_should_retry(bio: *const BIO) c_int;
+pub extern fn BIO_should_io_special(bio: *const BIO) c_int;
+pub extern fn BIO_get_retry_reason(bio: *const BIO) c_int;
+pub extern fn BIO_set_retry_reason(bio: *BIO, reason: c_int) void;
+pub extern fn BIO_clear_flags(bio: *BIO, flags: c_int) void;
+pub extern fn BIO_set_retry_read(bio: *BIO) void;
+pub extern fn BIO_set_retry_write(bio: *BIO) void;
+pub extern fn BIO_get_retry_flags(bio: *BIO) c_int;
+pub extern fn BIO_clear_retry_flags(bio: *BIO) void;
+pub extern fn BIO_method_type(bio: *const BIO) c_int;
+pub extern fn BIO_callback_ctrl(bio: *BIO, cmd: c_int, fp: bio_info_cb) c_long;
+pub extern fn BIO_pending(bio: *const BIO) usize;
+pub extern fn BIO_ctrl_pending(bio: *const BIO) usize;
+pub extern fn BIO_wpending(bio: *const BIO) usize;
+pub extern fn BIO_set_close(bio: *BIO, close_flag: c_int) c_int;
+pub extern fn BIO_number_read(bio: *const BIO) usize;
+pub extern fn BIO_number_written(bio: *const BIO) usize;
+pub extern fn BIO_push(bio: *BIO, appended_bio: [*c]BIO) [*c]BIO;
+pub extern fn BIO_pop(bio: *BIO) [*c]BIO;
+pub extern fn BIO_next(bio: *BIO) [*c]BIO;
+pub extern fn BIO_free_all(bio: [*c]BIO) void;
+pub extern fn BIO_find_type(bio: [*c]BIO, @"type": c_int) [*c]BIO;
+pub extern fn BIO_copy_next_retry(bio: [*c]BIO) void;
+pub extern fn BIO_printf(bio: [*c]BIO, format: [*c]const u8, ...) c_int;
+pub extern fn BIO_indent(bio: [*c]BIO, indent: c_uint, max_indent: c_uint) c_int;
+pub extern fn BIO_hexdump(bio: [*c]BIO, data: [*c]const u8, len: usize, indent: c_uint) c_int;
+pub extern fn ERR_print_errors(bio: [*c]BIO) void;
+pub extern fn BIO_read_asn1(bio: [*c]BIO, out: [*c][*c]u8, out_len: [*c]usize, max_len: usize) c_int;
+pub extern fn BIO_s_mem() [*c]const BIO_METHOD;
+pub extern fn BIO_new_mem_buf(buf: ?*const c_void, len: c_int) *BIO;
+pub extern fn BIO_mem_contents(bio: [*c]const BIO, out_contents: [*c][*c]const u8, out_len: [*c]usize) c_int;
+pub extern fn BIO_get_mem_data(bio: [*c]BIO, contents: [*c][*c]u8) c_long;
+pub extern fn BIO_get_mem_ptr(bio: [*c]BIO, out: [*c][*c]BUF_MEM) c_int;
+pub extern fn BIO_set_mem_buf(bio: [*c]BIO, b: [*c]BUF_MEM, take_ownership: c_int) c_int;
+pub extern fn BIO_set_mem_eof_return(bio: [*c]BIO, eof_value: c_int) c_int;
+pub extern fn BIO_s_fd() [*c]const BIO_METHOD;
+pub extern fn BIO_new_fd(fd: c_int, close_flag: c_int) [*c]BIO;
+pub extern fn BIO_set_fd(bio: [*c]BIO, fd: c_int, close_flag: c_int) c_int;
+pub extern fn BIO_get_fd(bio: [*c]BIO, out_fd: [*c]c_int) c_int;
+pub extern fn BIO_s_file() [*c]const BIO_METHOD;
+pub extern fn BIO_new_file(filename: [*c]const u8, mode: [*c]const u8) [*c]BIO;
+pub extern fn BIO_new_fp(stream: [*c]FILE, close_flag: c_int) [*c]BIO;
+pub extern fn BIO_get_fp(bio: [*c]BIO, out_file: [*c][*c]FILE) c_int;
+pub extern fn BIO_set_fp(bio: [*c]BIO, file: [*c]FILE, close_flag: c_int) c_int;
+pub extern fn BIO_read_filename(bio: [*c]BIO, filename: [*c]const u8) c_int;
+pub extern fn BIO_write_filename(bio: [*c]BIO, filename: [*c]const u8) c_int;
+pub extern fn BIO_append_filename(bio: [*c]BIO, filename: [*c]const u8) c_int;
+pub extern fn BIO_rw_filename(bio: [*c]BIO, filename: [*c]const u8) c_int;
+pub extern fn BIO_s_socket() [*c]const BIO_METHOD;
+pub extern fn BIO_new_socket(fd: c_int, close_flag: c_int) [*c]BIO;
+pub extern fn BIO_s_connect() [*c]const BIO_METHOD;
+pub extern fn BIO_new_connect(host_and_optional_port: [*c]const u8) [*c]BIO;
+pub extern fn BIO_set_conn_hostname(bio: [*c]BIO, host_and_optional_port: [*c]const u8) c_int;
+pub extern fn BIO_set_conn_port(bio: [*c]BIO, port_str: [*c]const u8) c_int;
+pub extern fn BIO_set_conn_int_port(bio: [*c]BIO, port: [*c]const c_int) c_int;
+pub extern fn BIO_set_nbio(bio: [*c]BIO, on: c_int) c_int;
+pub extern fn BIO_do_connect(bio: [*c]BIO) c_int;
+pub extern fn BIO_new_bio_pair(out1: [*c][*c]BIO, writebuf1: usize, out2: [*c][*c]BIO, writebuf2: usize) c_int;
+pub extern fn BIO_ctrl_get_read_request(bio: [*c]BIO) usize;
+pub extern fn BIO_ctrl_get_write_guarantee(bio: [*c]BIO) usize;
+pub extern fn BIO_shutdown_wr(bio: [*c]BIO) c_int;
+pub extern fn BIO_get_new_index() c_int;
+pub extern fn BIO_meth_new(@"type": c_int, name: [*c]const u8) *BIO_METHOD;
+pub extern fn BIO_meth_free(method: *BIO_METHOD) void;
+pub extern fn BIO_meth_set_create(method: *BIO_METHOD, create: ?BIOMethod.create) c_int;
+pub extern fn BIO_meth_set_destroy(method: *BIO_METHOD, destroy: ?BIOMethod.destroy) c_int;
+pub extern fn BIO_meth_set_write(method: *BIO_METHOD, write: ?BIOMethod.write) c_int;
+pub extern fn BIO_meth_set_read(method: *BIO_METHOD, read: ?BIOMethod.read) c_int;
+pub extern fn BIO_meth_set_gets(method: *BIO_METHOD, gets: ?BIOMethod.gets) c_int;
+pub extern fn BIO_meth_set_ctrl(method: *BIO_METHOD, ctrl: ?BIOMethod.ctrl) c_int;
+pub extern fn BIO_set_data(bio: [*c]BIO, ptr: ?*c_void) void;
+pub extern fn BIO_get_data(bio: [*c]BIO) ?*c_void;
+pub extern fn BIO_set_init(bio: [*c]BIO, init: c_int) void;
+pub extern fn BIO_get_init(bio: [*c]BIO) c_int;
+pub extern fn BIO_f_base64() [*c]const BIO_METHOD;
+pub extern fn BIO_set_retry_special(bio: [*c]BIO) void;
+pub extern fn BIO_set_write_buffer_size(bio: [*c]BIO, buffer_size: c_int) c_int;
+pub extern fn BIO_set_shutdown(bio: [*c]BIO, shutdown: c_int) void;
+pub extern fn BIO_get_shutdown(bio: [*c]BIO) c_int;
+pub extern fn BIO_meth_set_puts(method: *BIO_METHOD, puts: ?fn ([*c]BIO, [*c]const u8) callconv(.C) c_int) c_int;
+pub extern fn EVP_EncodeBlock(dst: [*c]u8, src: [*c]const u8, src_len: usize) usize;
+pub extern fn EVP_EncodedLength(out_len: [*c]usize, len: usize) c_int;
+pub extern fn EVP_DecodedLength(out_len: [*c]usize, len: usize) c_int;
+pub extern fn EVP_DecodeBase64(out: [*c]u8, out_len: [*c]usize, max_out: usize, in: [*c]const u8, in_len: usize) c_int;
+pub extern fn EVP_ENCODE_CTX_new() [*c]EVP_ENCODE_CTX;
+pub extern fn EVP_ENCODE_CTX_free(ctx: [*c]EVP_ENCODE_CTX) void;
+pub extern fn EVP_EncodeInit(ctx: [*c]EVP_ENCODE_CTX) void;
+pub extern fn EVP_EncodeUpdate(ctx: [*c]EVP_ENCODE_CTX, out: [*c]u8, out_len: [*c]c_int, in: [*c]const u8, in_len: usize) void;
+pub extern fn EVP_EncodeFinal(ctx: [*c]EVP_ENCODE_CTX, out: [*c]u8, out_len: [*c]c_int) void;
+pub extern fn EVP_DecodeInit(ctx: [*c]EVP_ENCODE_CTX) void;
+pub extern fn EVP_DecodeUpdate(ctx: [*c]EVP_ENCODE_CTX, out: [*c]u8, out_len: [*c]c_int, in: [*c]const u8, in_len: usize) c_int;
+pub extern fn EVP_DecodeFinal(ctx: [*c]EVP_ENCODE_CTX, out: [*c]u8, out_len: [*c]c_int) c_int;
+pub extern fn EVP_DecodeBlock(dst: [*c]u8, src: [*c]const u8, src_len: usize) c_int;
+pub extern fn EVP_rc4() [*c]const EVP_CIPHER;
+pub extern fn EVP_des_cbc() [*c]const EVP_CIPHER;
+pub extern fn EVP_des_ecb() [*c]const EVP_CIPHER;
+pub extern fn EVP_des_ede() [*c]const EVP_CIPHER;
+pub extern fn EVP_des_ede3() [*c]const EVP_CIPHER;
+pub extern fn EVP_des_ede_cbc() [*c]const EVP_CIPHER;
+pub extern fn EVP_des_ede3_cbc() [*c]const EVP_CIPHER;
+pub extern fn EVP_aes_128_ecb() [*c]const EVP_CIPHER;
+pub extern fn EVP_aes_128_cbc() [*c]const EVP_CIPHER;
+pub extern fn EVP_aes_128_ctr() [*c]const EVP_CIPHER;
+pub extern fn EVP_aes_128_ofb() [*c]const EVP_CIPHER;
+pub extern fn EVP_aes_256_ecb() [*c]const EVP_CIPHER;
+pub extern fn EVP_aes_256_cbc() [*c]const EVP_CIPHER;
+pub extern fn EVP_aes_256_ctr() [*c]const EVP_CIPHER;
+pub extern fn EVP_aes_256_ofb() [*c]const EVP_CIPHER;
+pub extern fn EVP_aes_256_xts() [*c]const EVP_CIPHER;
+pub extern fn EVP_enc_null() [*c]const EVP_CIPHER;
+pub extern fn EVP_rc2_cbc() [*c]const EVP_CIPHER;
+pub extern fn EVP_rc2_40_cbc() [*c]const EVP_CIPHER;
+pub extern fn EVP_get_cipherbynid(nid: c_int) [*c]const EVP_CIPHER;
+pub extern fn EVP_CIPHER_CTX_init(ctx: [*c]EVP_CIPHER_CTX) void;
+pub extern fn EVP_CIPHER_CTX_new() [*c]EVP_CIPHER_CTX;
+pub extern fn EVP_CIPHER_CTX_cleanup(ctx: [*c]EVP_CIPHER_CTX) c_int;
+pub extern fn EVP_CIPHER_CTX_free(ctx: [*c]EVP_CIPHER_CTX) void;
+pub extern fn EVP_CIPHER_CTX_copy(out: [*c]EVP_CIPHER_CTX, in: [*c]const EVP_CIPHER_CTX) c_int;
+pub extern fn EVP_CIPHER_CTX_reset(ctx: [*c]EVP_CIPHER_CTX) c_int;
+pub extern fn EVP_CipherInit_ex(ctx: [*c]EVP_CIPHER_CTX, cipher: [*c]const EVP_CIPHER, engine: ?*ENGINE, key: [*c]const u8, iv: [*c]const u8, enc: c_int) c_int;
+pub extern fn EVP_EncryptInit_ex(ctx: [*c]EVP_CIPHER_CTX, cipher: [*c]const EVP_CIPHER, impl: ?*ENGINE, key: [*c]const u8, iv: [*c]const u8) c_int;
+pub extern fn EVP_DecryptInit_ex(ctx: [*c]EVP_CIPHER_CTX, cipher: [*c]const EVP_CIPHER, impl: ?*ENGINE, key: [*c]const u8, iv: [*c]const u8) c_int;
+pub extern fn EVP_EncryptUpdate(ctx: [*c]EVP_CIPHER_CTX, out: [*c]u8, out_len: [*c]c_int, in: [*c]const u8, in_len: c_int) c_int;
+pub extern fn EVP_EncryptFinal_ex(ctx: [*c]EVP_CIPHER_CTX, out: [*c]u8, out_len: [*c]c_int) c_int;
+pub extern fn EVP_DecryptUpdate(ctx: [*c]EVP_CIPHER_CTX, out: [*c]u8, out_len: [*c]c_int, in: [*c]const u8, in_len: c_int) c_int;
+pub extern fn EVP_DecryptFinal_ex(ctx: [*c]EVP_CIPHER_CTX, out: [*c]u8, out_len: [*c]c_int) c_int;
+pub extern fn EVP_Cipher(ctx: [*c]EVP_CIPHER_CTX, out: [*c]u8, in: [*c]const u8, in_len: usize) c_int;
+pub extern fn EVP_CipherUpdate(ctx: [*c]EVP_CIPHER_CTX, out: [*c]u8, out_len: [*c]c_int, in: [*c]const u8, in_len: c_int) c_int;
+pub extern fn EVP_CipherFinal_ex(ctx: [*c]EVP_CIPHER_CTX, out: [*c]u8, out_len: [*c]c_int) c_int;
+pub extern fn EVP_CIPHER_CTX_cipher(ctx: [*c]const EVP_CIPHER_CTX) [*c]const EVP_CIPHER;
+pub extern fn EVP_CIPHER_CTX_nid(ctx: [*c]const EVP_CIPHER_CTX) c_int;
+pub extern fn EVP_CIPHER_CTX_encrypting(ctx: [*c]const EVP_CIPHER_CTX) c_int;
+pub extern fn EVP_CIPHER_CTX_block_size(ctx: [*c]const EVP_CIPHER_CTX) c_uint;
+pub extern fn EVP_CIPHER_CTX_key_length(ctx: [*c]const EVP_CIPHER_CTX) c_uint;
+pub extern fn EVP_CIPHER_CTX_iv_length(ctx: [*c]const EVP_CIPHER_CTX) c_uint;
+pub extern fn EVP_CIPHER_CTX_get_app_data(ctx: [*c]const EVP_CIPHER_CTX) ?*c_void;
+pub extern fn EVP_CIPHER_CTX_set_app_data(ctx: [*c]EVP_CIPHER_CTX, data: ?*c_void) void;
+pub extern fn EVP_CIPHER_CTX_flags(ctx: [*c]const EVP_CIPHER_CTX) u32;
+pub extern fn EVP_CIPHER_CTX_mode(ctx: [*c]const EVP_CIPHER_CTX) u32;
+pub extern fn EVP_CIPHER_CTX_ctrl(ctx: [*c]EVP_CIPHER_CTX, command: c_int, arg: c_int, ptr: ?*c_void) c_int;
+pub extern fn EVP_CIPHER_CTX_set_padding(ctx: [*c]EVP_CIPHER_CTX, pad: c_int) c_int;
+pub extern fn EVP_CIPHER_CTX_set_key_length(ctx: [*c]EVP_CIPHER_CTX, key_len: c_uint) c_int;
+pub extern fn EVP_CIPHER_nid(cipher: [*c]const EVP_CIPHER) c_int;
+pub extern fn EVP_CIPHER_block_size(cipher: [*c]const EVP_CIPHER) c_uint;
+pub extern fn EVP_CIPHER_key_length(cipher: [*c]const EVP_CIPHER) c_uint;
+pub extern fn EVP_CIPHER_iv_length(cipher: [*c]const EVP_CIPHER) c_uint;
+pub extern fn EVP_CIPHER_flags(cipher: [*c]const EVP_CIPHER) u32;
+pub extern fn EVP_CIPHER_mode(cipher: [*c]const EVP_CIPHER) u32;
+pub extern fn EVP_BytesToKey(@"type": [*c]const EVP_CIPHER, md: ?*const EVP_MD, salt: [*c]const u8, data: [*c]const u8, data_len: usize, count: c_uint, key: [*c]u8, iv: [*c]u8) c_int;
+pub extern fn EVP_CipherInit(ctx: [*c]EVP_CIPHER_CTX, cipher: [*c]const EVP_CIPHER, key: [*c]const u8, iv: [*c]const u8, enc: c_int) c_int;
+pub extern fn EVP_EncryptInit(ctx: [*c]EVP_CIPHER_CTX, cipher: [*c]const EVP_CIPHER, key: [*c]const u8, iv: [*c]const u8) c_int;
+pub extern fn EVP_DecryptInit(ctx: [*c]EVP_CIPHER_CTX, cipher: [*c]const EVP_CIPHER, key: [*c]const u8, iv: [*c]const u8) c_int;
+pub extern fn EVP_CipherFinal(ctx: [*c]EVP_CIPHER_CTX, out: [*c]u8, out_len: [*c]c_int) c_int;
+pub extern fn EVP_EncryptFinal(ctx: [*c]EVP_CIPHER_CTX, out: [*c]u8, out_len: [*c]c_int) c_int;
+pub extern fn EVP_DecryptFinal(ctx: [*c]EVP_CIPHER_CTX, out: [*c]u8, out_len: [*c]c_int) c_int;
+pub extern fn EVP_add_cipher_alias(a: [*c]const u8, b: [*c]const u8) c_int;
+pub extern fn EVP_get_cipherbyname(name: [*c]const u8) [*c]const EVP_CIPHER;
+pub extern fn EVP_aes_128_gcm() [*c]const EVP_CIPHER;
+pub extern fn EVP_aes_256_gcm() [*c]const EVP_CIPHER;
+pub extern fn EVP_aes_192_ecb() [*c]const EVP_CIPHER;
+pub extern fn EVP_aes_192_cbc() [*c]const EVP_CIPHER;
+pub extern fn EVP_aes_192_ctr() [*c]const EVP_CIPHER;
+pub extern fn EVP_aes_192_gcm() [*c]const EVP_CIPHER;
+pub extern fn EVP_aes_192_ofb() [*c]const EVP_CIPHER;
+pub extern fn EVP_des_ede3_ecb() [*c]const EVP_CIPHER;
+pub extern fn EVP_aes_128_cfb128() [*c]const EVP_CIPHER;
+pub extern fn EVP_aes_128_cfb() [*c]const EVP_CIPHER;
+pub extern fn EVP_aes_192_cfb128() [*c]const EVP_CIPHER;
+pub extern fn EVP_aes_192_cfb() [*c]const EVP_CIPHER;
+pub extern fn EVP_aes_256_cfb128() [*c]const EVP_CIPHER;
+pub extern fn EVP_aes_256_cfb() [*c]const EVP_CIPHER;
+pub extern fn EVP_bf_ecb() [*c]const EVP_CIPHER;
+pub extern fn EVP_bf_cbc() [*c]const EVP_CIPHER;
+pub extern fn EVP_bf_cfb() [*c]const EVP_CIPHER;
+pub extern fn EVP_cast5_ecb() [*c]const EVP_CIPHER;
+pub extern fn EVP_cast5_cbc() [*c]const EVP_CIPHER;
+pub extern fn EVP_CIPHER_CTX_set_flags(ctx: [*c]const EVP_CIPHER_CTX, flags: u32) void;
+pub extern fn EVP_md4() ?*const EVP_MD;
+pub extern fn EVP_md5() ?*const EVP_MD;
+pub extern fn EVP_sha1() ?*const EVP_MD;
+pub extern fn EVP_sha224() ?*const EVP_MD;
+pub extern fn EVP_sha256() ?*const EVP_MD;
+pub extern fn EVP_sha384() ?*const EVP_MD;
+pub extern fn EVP_sha512() ?*const EVP_MD;
+pub extern fn EVP_sha512_256() ?*const EVP_MD;
+pub extern fn EVP_blake2b256() ?*const EVP_MD;
+pub extern fn EVP_md5_sha1() ?*const EVP_MD;
+pub extern fn EVP_get_digestbynid(nid: c_int) ?*const EVP_MD;
+pub extern fn EVP_get_digestbyobj(obj: ?*const ASN1_OBJECT) ?*const EVP_MD;
+pub extern fn EVP_MD_CTX_init(ctx: [*c]EVP_MD_CTX) void;
+pub extern fn EVP_MD_CTX_new() [*c]EVP_MD_CTX;
+pub extern fn EVP_MD_CTX_cleanup(ctx: [*c]EVP_MD_CTX) c_int;
+pub extern fn EVP_MD_CTX_free(ctx: [*c]EVP_MD_CTX) void;
+pub extern fn EVP_MD_CTX_copy_ex(out: [*c]EVP_MD_CTX, in: [*c]const EVP_MD_CTX) c_int;
+pub extern fn EVP_MD_CTX_move(out: [*c]EVP_MD_CTX, in: [*c]EVP_MD_CTX) void;
+pub extern fn EVP_MD_CTX_reset(ctx: [*c]EVP_MD_CTX) c_int;
+pub extern fn EVP_DigestInit_ex(ctx: [*c]EVP_MD_CTX, @"type": ?*const EVP_MD, engine: ?*ENGINE) c_int;
+pub extern fn EVP_DigestInit(ctx: [*c]EVP_MD_CTX, @"type": ?*const EVP_MD) c_int;
+pub extern fn EVP_DigestUpdate(ctx: [*c]EVP_MD_CTX, data: ?*const c_void, len: usize) c_int;
+pub extern fn EVP_DigestFinal_ex(ctx: [*c]EVP_MD_CTX, md_out: [*c]u8, out_size: [*c]c_uint) c_int;
+pub extern fn EVP_DigestFinal(ctx: [*c]EVP_MD_CTX, md_out: [*c]u8, out_size: [*c]c_uint) c_int;
+pub extern fn EVP_Digest(data: ?*const c_void, len: usize, md_out: [*c]u8, md_out_size: [*c]c_uint, @"type": ?*const EVP_MD, impl: ?*ENGINE) c_int;
+pub extern fn EVP_MD_type(md: ?*const EVP_MD) c_int;
+pub extern fn EVP_MD_flags(md: ?*const EVP_MD) u32;
+pub extern fn EVP_MD_size(md: ?*const EVP_MD) usize;
+pub extern fn EVP_MD_block_size(md: ?*const EVP_MD) usize;
+pub extern fn EVP_MD_CTX_md(ctx: [*c]const EVP_MD_CTX) ?*const EVP_MD;
+pub extern fn EVP_MD_CTX_size(ctx: [*c]const EVP_MD_CTX) usize;
+pub extern fn EVP_MD_CTX_block_size(ctx: [*c]const EVP_MD_CTX) usize;
+pub extern fn EVP_MD_CTX_type(ctx: [*c]const EVP_MD_CTX) c_int;
+pub extern fn EVP_parse_digest_algorithm(cbs: [*c]CBS) ?*const EVP_MD;
+pub extern fn EVP_marshal_digest_algorithm(cbb: [*c]CBB, md: ?*const EVP_MD) c_int;
+pub extern fn EVP_MD_CTX_copy(out: [*c]EVP_MD_CTX, in: [*c]const EVP_MD_CTX) c_int;
+pub extern fn EVP_add_digest(digest: ?*const EVP_MD) c_int;
+pub extern fn EVP_get_digestbyname([*c]const u8) ?*const EVP_MD;
+pub extern fn EVP_dss1() ?*const EVP_MD;
+pub extern fn EVP_MD_CTX_create() [*c]EVP_MD_CTX;
+pub extern fn EVP_MD_CTX_destroy(ctx: [*c]EVP_MD_CTX) void;
+pub extern fn EVP_DigestFinalXOF(ctx: [*c]EVP_MD_CTX, out: [*c]u8, len: usize) c_int;
+pub extern fn EVP_MD_meth_get_flags(md: ?*const EVP_MD) u32;
+pub extern fn EVP_MD_CTX_set_flags(ctx: [*c]EVP_MD_CTX, flags: c_int) void;
+pub extern fn EVP_MD_nid(md: ?*const EVP_MD) c_int;
+pub extern fn EVP_aead_aes_128_gcm() ?*const EVP_AEAD;
+pub extern fn EVP_aead_aes_192_gcm() ?*const EVP_AEAD;
+pub extern fn EVP_aead_aes_256_gcm() ?*const EVP_AEAD;
+pub extern fn EVP_aead_chacha20_poly1305() ?*const EVP_AEAD;
+pub extern fn EVP_aead_xchacha20_poly1305() ?*const EVP_AEAD;
+pub extern fn EVP_aead_aes_128_ctr_hmac_sha256() ?*const EVP_AEAD;
+pub extern fn EVP_aead_aes_256_ctr_hmac_sha256() ?*const EVP_AEAD;
+pub extern fn EVP_aead_aes_128_gcm_siv() ?*const EVP_AEAD;
+pub extern fn EVP_aead_aes_256_gcm_siv() ?*const EVP_AEAD;
+pub extern fn EVP_aead_aes_128_gcm_randnonce() ?*const EVP_AEAD;
+pub extern fn EVP_aead_aes_256_gcm_randnonce() ?*const EVP_AEAD;
+pub extern fn EVP_aead_aes_128_ccm_bluetooth() ?*const EVP_AEAD;
+pub extern fn EVP_aead_aes_128_ccm_bluetooth_8() ?*const EVP_AEAD;
+pub extern fn EVP_has_aes_hardware() c_int;
+pub extern fn EVP_AEAD_key_length(aead: ?*const EVP_AEAD) usize;
+pub extern fn EVP_AEAD_nonce_length(aead: ?*const EVP_AEAD) usize;
+pub extern fn EVP_AEAD_max_overhead(aead: ?*const EVP_AEAD) usize;
+pub extern fn EVP_AEAD_max_tag_len(aead: ?*const EVP_AEAD) usize;
+pub const union_evp_aead_ctx_st_state = extern union {
+ @"opaque": [580]u8,
+ alignment: u64,
+};
+pub const struct_evp_aead_ctx_st = extern struct {
+ aead: ?*const EVP_AEAD,
+ state: union_evp_aead_ctx_st_state,
+ tag_len: u8,
+};
+pub const EVP_AEAD_CTX = struct_evp_aead_ctx_st;
+pub extern fn EVP_AEAD_CTX_zero(ctx: [*c]EVP_AEAD_CTX) void;
+pub extern fn EVP_AEAD_CTX_new(aead: ?*const EVP_AEAD, key: [*c]const u8, key_len: usize, tag_len: usize) [*c]EVP_AEAD_CTX;
+pub extern fn EVP_AEAD_CTX_free(ctx: [*c]EVP_AEAD_CTX) void;
+pub extern fn EVP_AEAD_CTX_init(ctx: [*c]EVP_AEAD_CTX, aead: ?*const EVP_AEAD, key: [*c]const u8, key_len: usize, tag_len: usize, impl: ?*ENGINE) c_int;
+pub extern fn EVP_AEAD_CTX_cleanup(ctx: [*c]EVP_AEAD_CTX) void;
+pub extern fn EVP_AEAD_CTX_seal(ctx: [*c]const EVP_AEAD_CTX, out: [*c]u8, out_len: [*c]usize, max_out_len: usize, nonce: [*c]const u8, nonce_len: usize, in: [*c]const u8, in_len: usize, ad: [*c]const u8, ad_len: usize) c_int;
+pub extern fn EVP_AEAD_CTX_open(ctx: [*c]const EVP_AEAD_CTX, out: [*c]u8, out_len: [*c]usize, max_out_len: usize, nonce: [*c]const u8, nonce_len: usize, in: [*c]const u8, in_len: usize, ad: [*c]const u8, ad_len: usize) c_int;
+pub extern fn EVP_AEAD_CTX_seal_scatter(ctx: [*c]const EVP_AEAD_CTX, out: [*c]u8, out_tag: [*c]u8, out_tag_len: [*c]usize, max_out_tag_len: usize, nonce: [*c]const u8, nonce_len: usize, in: [*c]const u8, in_len: usize, extra_in: [*c]const u8, extra_in_len: usize, ad: [*c]const u8, ad_len: usize) c_int;
+pub extern fn EVP_AEAD_CTX_open_gather(ctx: [*c]const EVP_AEAD_CTX, out: [*c]u8, nonce: [*c]const u8, nonce_len: usize, in: [*c]const u8, in_len: usize, in_tag: [*c]const u8, in_tag_len: usize, ad: [*c]const u8, ad_len: usize) c_int;
+pub extern fn EVP_AEAD_CTX_aead(ctx: [*c]const EVP_AEAD_CTX) ?*const EVP_AEAD;
+pub extern fn EVP_aead_aes_128_cbc_sha1_tls() ?*const EVP_AEAD;
+pub extern fn EVP_aead_aes_128_cbc_sha1_tls_implicit_iv() ?*const EVP_AEAD;
+pub extern fn EVP_aead_aes_256_cbc_sha1_tls() ?*const EVP_AEAD;
+pub extern fn EVP_aead_aes_256_cbc_sha1_tls_implicit_iv() ?*const EVP_AEAD;
+pub extern fn EVP_aead_des_ede3_cbc_sha1_tls() ?*const EVP_AEAD;
+pub extern fn EVP_aead_des_ede3_cbc_sha1_tls_implicit_iv() ?*const EVP_AEAD;
+pub extern fn EVP_aead_null_sha1_tls() ?*const EVP_AEAD;
+pub extern fn EVP_aead_aes_128_gcm_tls12() ?*const EVP_AEAD;
+pub extern fn EVP_aead_aes_256_gcm_tls12() ?*const EVP_AEAD;
+pub extern fn EVP_aead_aes_128_gcm_tls13() ?*const EVP_AEAD;
+pub extern fn EVP_aead_aes_256_gcm_tls13() ?*const EVP_AEAD;
+pub const evp_aead_open: c_int = 0;
+pub const evp_aead_seal: c_int = 1;
+pub const enum_evp_aead_direction_t = c_uint;
+pub extern fn EVP_AEAD_CTX_init_with_direction(ctx: [*c]EVP_AEAD_CTX, aead: ?*const EVP_AEAD, key: [*c]const u8, key_len: usize, tag_len: usize, dir: enum_evp_aead_direction_t) c_int;
+pub extern fn EVP_AEAD_CTX_get_iv(ctx: [*c]const EVP_AEAD_CTX, out_iv: [*c][*c]const u8, out_len: [*c]usize) c_int;
+pub extern fn EVP_AEAD_CTX_tag_len(ctx: [*c]const EVP_AEAD_CTX, out_tag_len: [*c]usize, in_len: usize, extra_in_len: usize) c_int;
+pub extern fn EVP_PKEY_new() [*c]EVP_PKEY;
+pub extern fn EVP_PKEY_free(pkey: [*c]EVP_PKEY) void;
+pub extern fn EVP_PKEY_up_ref(pkey: [*c]EVP_PKEY) c_int;
+pub extern fn EVP_PKEY_is_opaque(pkey: [*c]const EVP_PKEY) c_int;
+pub extern fn EVP_PKEY_cmp(a: [*c]const EVP_PKEY, b: [*c]const EVP_PKEY) c_int;
+pub extern fn EVP_PKEY_copy_parameters(to: [*c]EVP_PKEY, from: [*c]const EVP_PKEY) c_int;
+pub extern fn EVP_PKEY_missing_parameters(pkey: [*c]const EVP_PKEY) c_int;
+pub extern fn EVP_PKEY_size(pkey: [*c]const EVP_PKEY) c_int;
+pub extern fn EVP_PKEY_bits(pkey: [*c]const EVP_PKEY) c_int;
+pub extern fn EVP_PKEY_id(pkey: [*c]const EVP_PKEY) c_int;
+pub extern fn EVP_PKEY_type(nid: c_int) c_int;
+pub extern fn EVP_PKEY_set1_RSA(pkey: [*c]EVP_PKEY, key: ?*RSA) c_int;
+pub extern fn EVP_PKEY_assign_RSA(pkey: [*c]EVP_PKEY, key: ?*RSA) c_int;
+pub extern fn EVP_PKEY_get0_RSA(pkey: [*c]const EVP_PKEY) ?*RSA;
+pub extern fn EVP_PKEY_get1_RSA(pkey: [*c]const EVP_PKEY) ?*RSA;
+pub extern fn EVP_PKEY_set1_DSA(pkey: [*c]EVP_PKEY, key: [*c]DSA) c_int;
+pub extern fn EVP_PKEY_assign_DSA(pkey: [*c]EVP_PKEY, key: [*c]DSA) c_int;
+pub extern fn EVP_PKEY_get0_DSA(pkey: [*c]const EVP_PKEY) [*c]DSA;
+pub extern fn EVP_PKEY_get1_DSA(pkey: [*c]const EVP_PKEY) [*c]DSA;
+pub extern fn EVP_PKEY_set1_EC_KEY(pkey: [*c]EVP_PKEY, key: ?*EC_KEY) c_int;
+pub extern fn EVP_PKEY_assign_EC_KEY(pkey: [*c]EVP_PKEY, key: ?*EC_KEY) c_int;
+pub extern fn EVP_PKEY_get0_EC_KEY(pkey: [*c]const EVP_PKEY) ?*EC_KEY;
+pub extern fn EVP_PKEY_get1_EC_KEY(pkey: [*c]const EVP_PKEY) ?*EC_KEY;
+pub extern fn EVP_PKEY_assign(pkey: [*c]EVP_PKEY, @"type": c_int, key: ?*c_void) c_int;
+pub extern fn EVP_PKEY_set_type(pkey: [*c]EVP_PKEY, @"type": c_int) c_int;
+pub extern fn EVP_PKEY_cmp_parameters(a: [*c]const EVP_PKEY, b: [*c]const EVP_PKEY) c_int;
+pub extern fn EVP_parse_public_key(cbs: [*c]CBS) [*c]EVP_PKEY;
+pub extern fn EVP_marshal_public_key(cbb: [*c]CBB, key: [*c]const EVP_PKEY) c_int;
+pub extern fn EVP_parse_private_key(cbs: [*c]CBS) [*c]EVP_PKEY;
+pub extern fn EVP_marshal_private_key(cbb: [*c]CBB, key: [*c]const EVP_PKEY) c_int;
+pub extern fn EVP_PKEY_new_raw_private_key(@"type": c_int, unused: ?*ENGINE, in: [*c]const u8, len: usize) [*c]EVP_PKEY;
+pub extern fn EVP_PKEY_new_raw_public_key(@"type": c_int, unused: ?*ENGINE, in: [*c]const u8, len: usize) [*c]EVP_PKEY;
+pub extern fn EVP_PKEY_get_raw_private_key(pkey: [*c]const EVP_PKEY, out: [*c]u8, out_len: [*c]usize) c_int;
+pub extern fn EVP_PKEY_get_raw_public_key(pkey: [*c]const EVP_PKEY, out: [*c]u8, out_len: [*c]usize) c_int;
+pub extern fn EVP_DigestSignInit(ctx: [*c]EVP_MD_CTX, pctx: [*c]?*EVP_PKEY_CTX, @"type": ?*const EVP_MD, e: ?*ENGINE, pkey: [*c]EVP_PKEY) c_int;
+pub extern fn EVP_DigestSignUpdate(ctx: [*c]EVP_MD_CTX, data: ?*const c_void, len: usize) c_int;
+pub extern fn EVP_DigestSignFinal(ctx: [*c]EVP_MD_CTX, out_sig: [*c]u8, out_sig_len: [*c]usize) c_int;
+pub extern fn EVP_DigestSign(ctx: [*c]EVP_MD_CTX, out_sig: [*c]u8, out_sig_len: [*c]usize, data: [*c]const u8, data_len: usize) c_int;
+pub extern fn EVP_DigestVerifyInit(ctx: [*c]EVP_MD_CTX, pctx: [*c]?*EVP_PKEY_CTX, @"type": ?*const EVP_MD, e: ?*ENGINE, pkey: [*c]EVP_PKEY) c_int;
+pub extern fn EVP_DigestVerifyUpdate(ctx: [*c]EVP_MD_CTX, data: ?*const c_void, len: usize) c_int;
+pub extern fn EVP_DigestVerifyFinal(ctx: [*c]EVP_MD_CTX, sig: [*c]const u8, sig_len: usize) c_int;
+pub extern fn EVP_DigestVerify(ctx: [*c]EVP_MD_CTX, sig: [*c]const u8, sig_len: usize, data: [*c]const u8, len: usize) c_int;
+pub extern fn EVP_SignInit_ex(ctx: [*c]EVP_MD_CTX, @"type": ?*const EVP_MD, impl: ?*ENGINE) c_int;
+pub extern fn EVP_SignInit(ctx: [*c]EVP_MD_CTX, @"type": ?*const EVP_MD) c_int;
+pub extern fn EVP_SignUpdate(ctx: [*c]EVP_MD_CTX, data: ?*const c_void, len: usize) c_int;
+pub extern fn EVP_SignFinal(ctx: [*c]const EVP_MD_CTX, sig: [*c]u8, out_sig_len: [*c]c_uint, pkey: [*c]EVP_PKEY) c_int;
+pub extern fn EVP_VerifyInit_ex(ctx: [*c]EVP_MD_CTX, @"type": ?*const EVP_MD, impl: ?*ENGINE) c_int;
+pub extern fn EVP_VerifyInit(ctx: [*c]EVP_MD_CTX, @"type": ?*const EVP_MD) c_int;
+pub extern fn EVP_VerifyUpdate(ctx: [*c]EVP_MD_CTX, data: ?*const c_void, len: usize) c_int;
+pub extern fn EVP_VerifyFinal(ctx: [*c]EVP_MD_CTX, sig: [*c]const u8, sig_len: usize, pkey: [*c]EVP_PKEY) c_int;
+pub extern fn EVP_PKEY_print_public(out: [*c]BIO, pkey: [*c]const EVP_PKEY, indent: c_int, pctx: ?*ASN1_PCTX) c_int;
+pub extern fn EVP_PKEY_print_private(out: [*c]BIO, pkey: [*c]const EVP_PKEY, indent: c_int, pctx: ?*ASN1_PCTX) c_int;
+pub extern fn EVP_PKEY_print_params(out: [*c]BIO, pkey: [*c]const EVP_PKEY, indent: c_int, pctx: ?*ASN1_PCTX) c_int;
+pub extern fn PKCS5_PBKDF2_HMAC(password: [*c]const u8, password_len: usize, salt: [*c]const u8, salt_len: usize, iterations: c_uint, digest: ?*const EVP_MD, key_len: usize, out_key: [*c]u8) c_int;
+pub extern fn PKCS5_PBKDF2_HMAC_SHA1(password: [*c]const u8, password_len: usize, salt: [*c]const u8, salt_len: usize, iterations: c_uint, key_len: usize, out_key: [*c]u8) c_int;
+pub extern fn EVP_PBE_scrypt(password: [*c]const u8, password_len: usize, salt: [*c]const u8, salt_len: usize, N: u64, r: u64, p: u64, max_mem: usize, out_key: [*c]u8, key_len: usize) c_int;
+pub extern fn EVP_PKEY_CTX_new(pkey: [*c]EVP_PKEY, e: ?*ENGINE) ?*EVP_PKEY_CTX;
+pub extern fn EVP_PKEY_CTX_new_id(id: c_int, e: ?*ENGINE) ?*EVP_PKEY_CTX;
+pub extern fn EVP_PKEY_CTX_free(ctx: ?*EVP_PKEY_CTX) void;
+pub extern fn EVP_PKEY_CTX_dup(ctx: ?*EVP_PKEY_CTX) ?*EVP_PKEY_CTX;
+pub extern fn EVP_PKEY_CTX_get0_pkey(ctx: ?*EVP_PKEY_CTX) [*c]EVP_PKEY;
+pub extern fn EVP_PKEY_sign_init(ctx: ?*EVP_PKEY_CTX) c_int;
+pub extern fn EVP_PKEY_sign(ctx: ?*EVP_PKEY_CTX, sig: [*c]u8, sig_len: [*c]usize, digest: [*c]const u8, digest_len: usize) c_int;
+pub extern fn EVP_PKEY_verify_init(ctx: ?*EVP_PKEY_CTX) c_int;
+pub extern fn EVP_PKEY_verify(ctx: ?*EVP_PKEY_CTX, sig: [*c]const u8, sig_len: usize, digest: [*c]const u8, digest_len: usize) c_int;
+pub extern fn EVP_PKEY_encrypt_init(ctx: ?*EVP_PKEY_CTX) c_int;
+pub extern fn EVP_PKEY_encrypt(ctx: ?*EVP_PKEY_CTX, out: [*c]u8, out_len: [*c]usize, in: [*c]const u8, in_len: usize) c_int;
+pub extern fn EVP_PKEY_decrypt_init(ctx: ?*EVP_PKEY_CTX) c_int;
+pub extern fn EVP_PKEY_decrypt(ctx: ?*EVP_PKEY_CTX, out: [*c]u8, out_len: [*c]usize, in: [*c]const u8, in_len: usize) c_int;
+pub extern fn EVP_PKEY_verify_recover_init(ctx: ?*EVP_PKEY_CTX) c_int;
+pub extern fn EVP_PKEY_verify_recover(ctx: ?*EVP_PKEY_CTX, out: [*c]u8, out_len: [*c]usize, sig: [*c]const u8, siglen: usize) c_int;
+pub extern fn EVP_PKEY_derive_init(ctx: ?*EVP_PKEY_CTX) c_int;
+pub extern fn EVP_PKEY_derive_set_peer(ctx: ?*EVP_PKEY_CTX, peer: [*c]EVP_PKEY) c_int;
+pub extern fn EVP_PKEY_derive(ctx: ?*EVP_PKEY_CTX, key: [*c]u8, out_key_len: [*c]usize) c_int;
+pub extern fn EVP_PKEY_keygen_init(ctx: ?*EVP_PKEY_CTX) c_int;
+pub extern fn EVP_PKEY_keygen(ctx: ?*EVP_PKEY_CTX, out_pkey: [*c][*c]EVP_PKEY) c_int;
+pub extern fn EVP_PKEY_paramgen_init(ctx: ?*EVP_PKEY_CTX) c_int;
+pub extern fn EVP_PKEY_paramgen(ctx: ?*EVP_PKEY_CTX, out_pkey: [*c][*c]EVP_PKEY) c_int;
+pub extern fn EVP_PKEY_CTX_set_signature_md(ctx: ?*EVP_PKEY_CTX, md: ?*const EVP_MD) c_int;
+pub extern fn EVP_PKEY_CTX_get_signature_md(ctx: ?*EVP_PKEY_CTX, out_md: [*c]?*const EVP_MD) c_int;
+pub extern fn EVP_PKEY_CTX_set_rsa_padding(ctx: ?*EVP_PKEY_CTX, padding: c_int) c_int;
+pub extern fn EVP_PKEY_CTX_get_rsa_padding(ctx: ?*EVP_PKEY_CTX, out_padding: [*c]c_int) c_int;
+pub extern fn EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx: ?*EVP_PKEY_CTX, salt_len: c_int) c_int;
+pub extern fn EVP_PKEY_CTX_get_rsa_pss_saltlen(ctx: ?*EVP_PKEY_CTX, out_salt_len: [*c]c_int) c_int;
+pub extern fn EVP_PKEY_CTX_set_rsa_keygen_bits(ctx: ?*EVP_PKEY_CTX, bits: c_int) c_int;
+pub extern fn EVP_PKEY_CTX_set_rsa_keygen_pubexp(ctx: ?*EVP_PKEY_CTX, e: [*c]BIGNUM) c_int;
+pub extern fn EVP_PKEY_CTX_set_rsa_oaep_md(ctx: ?*EVP_PKEY_CTX, md: ?*const EVP_MD) c_int;
+pub extern fn EVP_PKEY_CTX_get_rsa_oaep_md(ctx: ?*EVP_PKEY_CTX, out_md: [*c]?*const EVP_MD) c_int;
+pub extern fn EVP_PKEY_CTX_set_rsa_mgf1_md(ctx: ?*EVP_PKEY_CTX, md: ?*const EVP_MD) c_int;
+pub extern fn EVP_PKEY_CTX_get_rsa_mgf1_md(ctx: ?*EVP_PKEY_CTX, out_md: [*c]?*const EVP_MD) c_int;
+pub extern fn EVP_PKEY_CTX_set0_rsa_oaep_label(ctx: ?*EVP_PKEY_CTX, label: [*c]u8, label_len: usize) c_int;
+pub extern fn EVP_PKEY_CTX_get0_rsa_oaep_label(ctx: ?*EVP_PKEY_CTX, out_label: [*c][*c]const u8) c_int;
+pub extern fn EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx: ?*EVP_PKEY_CTX, nid: c_int) c_int;
+pub extern fn EVP_PKEY_get0(pkey: [*c]const EVP_PKEY) ?*c_void;
+pub extern fn OpenSSL_add_all_algorithms() void;
+pub extern fn OPENSSL_add_all_algorithms_conf() void;
+pub extern fn OpenSSL_add_all_ciphers() void;
+pub extern fn OpenSSL_add_all_digests() void;
+pub extern fn EVP_cleanup() void;
+pub extern fn EVP_CIPHER_do_all_sorted(callback: ?fn ([*c]const EVP_CIPHER, [*c]const u8, [*c]const u8, ?*c_void) callconv(.C) void, arg: ?*c_void) void;
+pub extern fn EVP_MD_do_all_sorted(callback: ?fn (?*const EVP_MD, [*c]const u8, [*c]const u8, ?*c_void) callconv(.C) void, arg: ?*c_void) void;
+pub extern fn EVP_MD_do_all(callback: ?fn (?*const EVP_MD, [*c]const u8, [*c]const u8, ?*c_void) callconv(.C) void, arg: ?*c_void) void;
+pub extern fn i2d_PrivateKey(key: [*c]const EVP_PKEY, outp: [*c][*c]u8) c_int;
+pub extern fn i2d_PublicKey(key: [*c]const EVP_PKEY, outp: [*c][*c]u8) c_int;
+pub extern fn d2i_PrivateKey(@"type": c_int, out: [*c][*c]EVP_PKEY, inp: [*c][*c]const u8, len: c_long) [*c]EVP_PKEY;
+pub extern fn d2i_AutoPrivateKey(out: [*c][*c]EVP_PKEY, inp: [*c][*c]const u8, len: c_long) [*c]EVP_PKEY;
+pub extern fn d2i_PublicKey(@"type": c_int, out: [*c][*c]EVP_PKEY, inp: [*c][*c]const u8, len: c_long) [*c]EVP_PKEY;
+pub extern fn EVP_PKEY_get0_DH(pkey: [*c]const EVP_PKEY) [*c]DH;
+pub extern fn EVP_PKEY_get1_DH(pkey: [*c]const EVP_PKEY) [*c]DH;
+pub extern fn EVP_PKEY_CTX_set_ec_param_enc(ctx: ?*EVP_PKEY_CTX, encoding: c_int) c_int;
+pub extern fn EVP_PKEY_set1_tls_encodedpoint(pkey: [*c]EVP_PKEY, in: [*c]const u8, len: usize) c_int;
+pub extern fn EVP_PKEY_get1_tls_encodedpoint(pkey: [*c]const EVP_PKEY, out_ptr: [*c][*c]u8) usize;
+pub extern fn EVP_PKEY_base_id(pkey: [*c]const EVP_PKEY) c_int;
+pub extern fn EVP_PKEY_CTX_set_rsa_pss_keygen_md(ctx: ?*EVP_PKEY_CTX, md: ?*const EVP_MD) c_int;
+pub extern fn EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen(ctx: ?*EVP_PKEY_CTX, salt_len: c_int) c_int;
+pub extern fn EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md(ctx: ?*EVP_PKEY_CTX, md: ?*const EVP_MD) c_int;
+pub extern fn i2d_PUBKEY(pkey: [*c]const EVP_PKEY, outp: [*c][*c]u8) c_int;
+pub extern fn d2i_PUBKEY(out: [*c][*c]EVP_PKEY, inp: [*c][*c]const u8, len: c_long) [*c]EVP_PKEY;
+pub extern fn i2d_RSA_PUBKEY(rsa: ?*const RSA, outp: [*c][*c]u8) c_int;
+pub extern fn d2i_RSA_PUBKEY(out: [*c]?*RSA, inp: [*c][*c]const u8, len: c_long) ?*RSA;
+pub extern fn i2d_DSA_PUBKEY(dsa: [*c]const DSA, outp: [*c][*c]u8) c_int;
+pub extern fn d2i_DSA_PUBKEY(out: [*c][*c]DSA, inp: [*c][*c]const u8, len: c_long) [*c]DSA;
+pub extern fn i2d_EC_PUBKEY(ec_key: ?*const EC_KEY, outp: [*c][*c]u8) c_int;
+pub extern fn d2i_EC_PUBKEY(out: [*c]?*EC_KEY, inp: [*c][*c]const u8, len: c_long) ?*EC_KEY;
+pub const struct_stack_st_CRYPTO_BUFFER = opaque {};
+pub const struct_stack_st_X509 = opaque {};
+pub const struct_stack_st_X509_CRL = opaque {};
+pub extern fn PKCS7_get_raw_certificates(out_certs: ?*struct_stack_st_CRYPTO_BUFFER, cbs: [*c]CBS, pool: ?*CRYPTO_BUFFER_POOL) c_int;
+pub extern fn PKCS7_get_certificates(out_certs: ?*struct_stack_st_X509, cbs: [*c]CBS) c_int;
+pub extern fn PKCS7_bundle_raw_certificates(out: [*c]CBB, certs: ?*const struct_stack_st_CRYPTO_BUFFER) c_int;
+pub extern fn PKCS7_bundle_certificates(out: [*c]CBB, certs: ?*const struct_stack_st_X509) c_int;
+pub extern fn PKCS7_get_CRLs(out_crls: ?*struct_stack_st_X509_CRL, cbs: [*c]CBS) c_int;
+pub extern fn PKCS7_bundle_CRLs(out: [*c]CBB, crls: ?*const struct_stack_st_X509_CRL) c_int;
+pub extern fn PKCS7_get_PEM_certificates(out_certs: ?*struct_stack_st_X509, pem_bio: [*c]BIO) c_int;
+pub extern fn PKCS7_get_PEM_CRLs(out_crls: ?*struct_stack_st_X509_CRL, pem_bio: [*c]BIO) c_int;
+pub const PKCS7_SIGNED = extern struct {
+ cert: ?*struct_stack_st_X509,
+ crl: ?*struct_stack_st_X509_CRL,
+};
+pub const PKCS7_SIGN_ENVELOPE = extern struct {
+ cert: ?*struct_stack_st_X509,
+ crl: ?*struct_stack_st_X509_CRL,
+};
+pub const PKCS7_ENVELOPE = c_void;
+pub const PKCS7_DIGEST = c_void;
+pub const PKCS7_ENCRYPT = c_void;
+pub const PKCS7_SIGNER_INFO = c_void;
+const union_unnamed_6 = extern union {
+ ptr: [*c]u8,
+ data: [*c]ASN1_OCTET_STRING,
+ sign: [*c]PKCS7_SIGNED,
+ enveloped: ?*PKCS7_ENVELOPE,
+ signed_and_enveloped: [*c]PKCS7_SIGN_ENVELOPE,
+ digest: ?*PKCS7_DIGEST,
+ encrypted: ?*PKCS7_ENCRYPT,
+ other: [*c]ASN1_TYPE,
+};
+pub const PKCS7 = extern struct {
+ ber_bytes: [*c]u8,
+ ber_len: usize,
+ type: ?*ASN1_OBJECT,
+ d: union_unnamed_6,
+};
+pub extern fn d2i_PKCS7(out: [*c][*c]PKCS7, inp: [*c][*c]const u8, len: usize) [*c]PKCS7;
+pub extern fn d2i_PKCS7_bio(bio: [*c]BIO, out: [*c][*c]PKCS7) [*c]PKCS7;
+pub extern fn i2d_PKCS7(p7: [*c]const PKCS7, out: [*c][*c]u8) c_int;
+pub extern fn i2d_PKCS7_bio(bio: [*c]BIO, p7: [*c]const PKCS7) c_int;
+pub extern fn PKCS7_free(p7: [*c]PKCS7) void;
+pub extern fn PKCS7_type_is_data(p7: [*c]const PKCS7) c_int;
+pub extern fn PKCS7_type_is_digest(p7: [*c]const PKCS7) c_int;
+pub extern fn PKCS7_type_is_encrypted(p7: [*c]const PKCS7) c_int;
+pub extern fn PKCS7_type_is_enveloped(p7: [*c]const PKCS7) c_int;
+pub extern fn PKCS7_type_is_signed(p7: [*c]const PKCS7) c_int;
+pub extern fn PKCS7_type_is_signedAndEnveloped(p7: [*c]const PKCS7) c_int;
+pub extern fn PKCS7_sign(sign_cert: ?*X509, pkey: [*c]EVP_PKEY, certs: ?*struct_stack_st_X509, data: [*c]BIO, flags: c_int) [*c]PKCS7;
+pub extern fn BN_new() [*c]BIGNUM;
+pub extern fn BN_init(bn: [*c]BIGNUM) void;
+pub extern fn BN_free(bn: [*c]BIGNUM) void;
+pub extern fn BN_clear_free(bn: [*c]BIGNUM) void;
+pub extern fn BN_dup(src: [*c]const BIGNUM) [*c]BIGNUM;
+pub extern fn BN_copy(dest: [*c]BIGNUM, src: [*c]const BIGNUM) [*c]BIGNUM;
+pub extern fn BN_clear(bn: [*c]BIGNUM) void;
+pub extern fn BN_value_one() [*c]const BIGNUM;
+pub extern fn BN_num_bits(bn: [*c]const BIGNUM) c_uint;
+pub extern fn BN_num_bytes(bn: [*c]const BIGNUM) c_uint;
+pub extern fn BN_zero(bn: [*c]BIGNUM) void;
+pub extern fn BN_one(bn: [*c]BIGNUM) c_int;
+pub extern fn BN_set_word(bn: [*c]BIGNUM, value: u64) c_int;
+pub extern fn BN_set_u64(bn: [*c]BIGNUM, value: u64) c_int;
+pub extern fn BN_set_negative(bn: [*c]BIGNUM, sign: c_int) void;
+pub extern fn BN_is_negative(bn: [*c]const BIGNUM) c_int;
+pub extern fn BN_bin2bn(in: [*c]const u8, len: usize, ret: [*c]BIGNUM) [*c]BIGNUM;
+pub extern fn BN_bn2bin(in: [*c]const BIGNUM, out: [*c]u8) usize;
+pub extern fn BN_le2bn(in: [*c]const u8, len: usize, ret: [*c]BIGNUM) [*c]BIGNUM;
+pub extern fn BN_bn2le_padded(out: [*c]u8, len: usize, in: [*c]const BIGNUM) c_int;
+pub extern fn BN_bn2bin_padded(out: [*c]u8, len: usize, in: [*c]const BIGNUM) c_int;
+pub extern fn BN_bn2cbb_padded(out: [*c]CBB, len: usize, in: [*c]const BIGNUM) c_int;
+pub extern fn BN_bn2hex(bn: [*c]const BIGNUM) [*c]u8;
+pub extern fn BN_hex2bn(outp: [*c][*c]BIGNUM, in: [*c]const u8) c_int;
+pub extern fn BN_bn2dec(a: [*c]const BIGNUM) [*c]u8;
+pub extern fn BN_dec2bn(outp: [*c][*c]BIGNUM, in: [*c]const u8) c_int;
+pub extern fn BN_asc2bn(outp: [*c][*c]BIGNUM, in: [*c]const u8) c_int;
+pub extern fn BN_print(bio: [*c]BIO, a: [*c]const BIGNUM) c_int;
+pub extern fn BN_print_fp(fp: [*c]FILE, a: [*c]const BIGNUM) c_int;
+pub extern fn BN_get_word(bn: [*c]const BIGNUM) u64;
+pub extern fn BN_get_u64(bn: [*c]const BIGNUM, out: [*c]u64) c_int;
+pub extern fn BN_parse_asn1_unsigned(cbs: [*c]CBS, ret: [*c]BIGNUM) c_int;
+pub extern fn BN_marshal_asn1(cbb: [*c]CBB, bn: [*c]const BIGNUM) c_int;
+pub extern fn BN_CTX_new() ?*BN_CTX;
+pub extern fn BN_CTX_free(ctx: ?*BN_CTX) void;
+pub extern fn BN_CTX_start(ctx: ?*BN_CTX) void;
+pub extern fn BN_CTX_get(ctx: ?*BN_CTX) [*c]BIGNUM;
+pub extern fn BN_CTX_end(ctx: ?*BN_CTX) void;
+pub extern fn BN_add(r: [*c]BIGNUM, a: [*c]const BIGNUM, b: [*c]const BIGNUM) c_int;
+pub extern fn BN_uadd(r: [*c]BIGNUM, a: [*c]const BIGNUM, b: [*c]const BIGNUM) c_int;
+pub extern fn BN_add_word(a: [*c]BIGNUM, w: u64) c_int;
+pub extern fn BN_sub(r: [*c]BIGNUM, a: [*c]const BIGNUM, b: [*c]const BIGNUM) c_int;
+pub extern fn BN_usub(r: [*c]BIGNUM, a: [*c]const BIGNUM, b: [*c]const BIGNUM) c_int;
+pub extern fn BN_sub_word(a: [*c]BIGNUM, w: u64) c_int;
+pub extern fn BN_mul(r: [*c]BIGNUM, a: [*c]const BIGNUM, b: [*c]const BIGNUM, ctx: ?*BN_CTX) c_int;
+pub extern fn BN_mul_word(bn: [*c]BIGNUM, w: u64) c_int;
+pub extern fn BN_sqr(r: [*c]BIGNUM, a: [*c]const BIGNUM, ctx: ?*BN_CTX) c_int;
+pub extern fn BN_div(quotient: [*c]BIGNUM, rem: [*c]BIGNUM, numerator: [*c]const BIGNUM, divisor: [*c]const BIGNUM, ctx: ?*BN_CTX) c_int;
+pub extern fn BN_div_word(numerator: [*c]BIGNUM, divisor: u64) u64;
+pub extern fn BN_sqrt(out_sqrt: [*c]BIGNUM, in: [*c]const BIGNUM, ctx: ?*BN_CTX) c_int;
+pub extern fn BN_cmp(a: [*c]const BIGNUM, b: [*c]const BIGNUM) c_int;
+pub extern fn BN_cmp_word(a: [*c]const BIGNUM, b: u64) c_int;
+pub extern fn BN_ucmp(a: [*c]const BIGNUM, b: [*c]const BIGNUM) c_int;
+pub extern fn BN_equal_consttime(a: [*c]const BIGNUM, b: [*c]const BIGNUM) c_int;
+pub extern fn BN_abs_is_word(bn: [*c]const BIGNUM, w: u64) c_int;
+pub extern fn BN_is_zero(bn: [*c]const BIGNUM) c_int;
+pub extern fn BN_is_one(bn: [*c]const BIGNUM) c_int;
+pub extern fn BN_is_word(bn: [*c]const BIGNUM, w: u64) c_int;
+pub extern fn BN_is_odd(bn: [*c]const BIGNUM) c_int;
+pub extern fn BN_is_pow2(a: [*c]const BIGNUM) c_int;
+pub extern fn BN_lshift(r: [*c]BIGNUM, a: [*c]const BIGNUM, n: c_int) c_int;
+pub extern fn BN_lshift1(r: [*c]BIGNUM, a: [*c]const BIGNUM) c_int;
+pub extern fn BN_rshift(r: [*c]BIGNUM, a: [*c]const BIGNUM, n: c_int) c_int;
+pub extern fn BN_rshift1(r: [*c]BIGNUM, a: [*c]const BIGNUM) c_int;
+pub extern fn BN_set_bit(a: [*c]BIGNUM, n: c_int) c_int;
+pub extern fn BN_clear_bit(a: [*c]BIGNUM, n: c_int) c_int;
+pub extern fn BN_is_bit_set(a: [*c]const BIGNUM, n: c_int) c_int;
+pub extern fn BN_mask_bits(a: [*c]BIGNUM, n: c_int) c_int;
+pub extern fn BN_count_low_zero_bits(bn: [*c]const BIGNUM) c_int;
+pub extern fn BN_mod_word(a: [*c]const BIGNUM, w: u64) u64;
+pub extern fn BN_mod_pow2(r: [*c]BIGNUM, a: [*c]const BIGNUM, e: usize) c_int;
+pub extern fn BN_nnmod_pow2(r: [*c]BIGNUM, a: [*c]const BIGNUM, e: usize) c_int;
+pub extern fn BN_nnmod(rem: [*c]BIGNUM, numerator: [*c]const BIGNUM, divisor: [*c]const BIGNUM, ctx: ?*BN_CTX) c_int;
+pub extern fn BN_mod_add(r: [*c]BIGNUM, a: [*c]const BIGNUM, b: [*c]const BIGNUM, m: [*c]const BIGNUM, ctx: ?*BN_CTX) c_int;
+pub extern fn BN_mod_add_quick(r: [*c]BIGNUM, a: [*c]const BIGNUM, b: [*c]const BIGNUM, m: [*c]const BIGNUM) c_int;
+pub extern fn BN_mod_sub(r: [*c]BIGNUM, a: [*c]const BIGNUM, b: [*c]const BIGNUM, m: [*c]const BIGNUM, ctx: ?*BN_CTX) c_int;
+pub extern fn BN_mod_sub_quick(r: [*c]BIGNUM, a: [*c]const BIGNUM, b: [*c]const BIGNUM, m: [*c]const BIGNUM) c_int;
+pub extern fn BN_mod_mul(r: [*c]BIGNUM, a: [*c]const BIGNUM, b: [*c]const BIGNUM, m: [*c]const BIGNUM, ctx: ?*BN_CTX) c_int;
+pub extern fn BN_mod_sqr(r: [*c]BIGNUM, a: [*c]const BIGNUM, m: [*c]const BIGNUM, ctx: ?*BN_CTX) c_int;
+pub extern fn BN_mod_lshift(r: [*c]BIGNUM, a: [*c]const BIGNUM, n: c_int, m: [*c]const BIGNUM, ctx: ?*BN_CTX) c_int;
+pub extern fn BN_mod_lshift_quick(r: [*c]BIGNUM, a: [*c]const BIGNUM, n: c_int, m: [*c]const BIGNUM) c_int;
+pub extern fn BN_mod_lshift1(r: [*c]BIGNUM, a: [*c]const BIGNUM, m: [*c]const BIGNUM, ctx: ?*BN_CTX) c_int;
+pub extern fn BN_mod_lshift1_quick(r: [*c]BIGNUM, a: [*c]const BIGNUM, m: [*c]const BIGNUM) c_int;
+pub extern fn BN_mod_sqrt(in: [*c]BIGNUM, a: [*c]const BIGNUM, p: [*c]const BIGNUM, ctx: ?*BN_CTX) [*c]BIGNUM;
+pub extern fn BN_rand(rnd: [*c]BIGNUM, bits: c_int, top: c_int, bottom: c_int) c_int;
+pub extern fn BN_pseudo_rand(rnd: [*c]BIGNUM, bits: c_int, top: c_int, bottom: c_int) c_int;
+pub extern fn BN_rand_range(rnd: [*c]BIGNUM, range: [*c]const BIGNUM) c_int;
+pub extern fn BN_rand_range_ex(r: [*c]BIGNUM, min_inclusive: u64, max_exclusive: [*c]const BIGNUM) c_int;
+pub extern fn BN_pseudo_rand_range(rnd: [*c]BIGNUM, range: [*c]const BIGNUM) c_int;
+pub extern fn BN_GENCB_set(callback: [*c]BN_GENCB, f: ?fn (c_int, c_int, [*c]BN_GENCB) callconv(.C) c_int, arg: ?*c_void) void;
+pub extern fn BN_GENCB_call(callback: [*c]BN_GENCB, event: c_int, n: c_int) c_int;
+pub extern fn BN_generate_prime_ex(ret: [*c]BIGNUM, bits: c_int, safe: c_int, add: [*c]const BIGNUM, rem: [*c]const BIGNUM, cb: [*c]BN_GENCB) c_int;
+pub const bn_probably_prime: c_int = 0;
+pub const bn_composite: c_int = 1;
+pub const bn_non_prime_power_composite: c_int = 2;
+pub const enum_bn_primality_result_t = c_uint;
+pub extern fn BN_enhanced_miller_rabin_primality_test(out_result: [*c]enum_bn_primality_result_t, w: [*c]const BIGNUM, checks: c_int, ctx: ?*BN_CTX, cb: [*c]BN_GENCB) c_int;
+pub extern fn BN_primality_test(is_probably_prime: [*c]c_int, candidate: [*c]const BIGNUM, checks: c_int, ctx: ?*BN_CTX, do_trial_division: c_int, cb: [*c]BN_GENCB) c_int;
+pub extern fn BN_is_prime_fasttest_ex(candidate: [*c]const BIGNUM, checks: c_int, ctx: ?*BN_CTX, do_trial_division: c_int, cb: [*c]BN_GENCB) c_int;
+pub extern fn BN_is_prime_ex(candidate: [*c]const BIGNUM, checks: c_int, ctx: ?*BN_CTX, cb: [*c]BN_GENCB) c_int;
+pub extern fn BN_gcd(r: [*c]BIGNUM, a: [*c]const BIGNUM, b: [*c]const BIGNUM, ctx: ?*BN_CTX) c_int;
+pub extern fn BN_mod_inverse(out: [*c]BIGNUM, a: [*c]const BIGNUM, n: [*c]const BIGNUM, ctx: ?*BN_CTX) [*c]BIGNUM;
+pub extern fn BN_mod_inverse_blinded(out: [*c]BIGNUM, out_no_inverse: [*c]c_int, a: [*c]const BIGNUM, mont: [*c]const BN_MONT_CTX, ctx: ?*BN_CTX) c_int;
+pub extern fn BN_mod_inverse_odd(out: [*c]BIGNUM, out_no_inverse: [*c]c_int, a: [*c]const BIGNUM, n: [*c]const BIGNUM, ctx: ?*BN_CTX) c_int;
+pub extern fn BN_MONT_CTX_new_for_modulus(mod: [*c]const BIGNUM, ctx: ?*BN_CTX) [*c]BN_MONT_CTX;
+pub extern fn BN_MONT_CTX_new_consttime(mod: [*c]const BIGNUM, ctx: ?*BN_CTX) [*c]BN_MONT_CTX;
+pub extern fn BN_MONT_CTX_free(mont: [*c]BN_MONT_CTX) void;
+pub extern fn BN_MONT_CTX_copy(to: [*c]BN_MONT_CTX, from: [*c]const BN_MONT_CTX) [*c]BN_MONT_CTX;
+pub extern fn BN_MONT_CTX_set_locked(pmont: [*c][*c]BN_MONT_CTX, lock: [*c]CRYPTO_MUTEX, mod: [*c]const BIGNUM, bn_ctx: ?*BN_CTX) c_int;
+pub extern fn BN_to_montgomery(ret: [*c]BIGNUM, a: [*c]const BIGNUM, mont: [*c]const BN_MONT_CTX, ctx: ?*BN_CTX) c_int;
+pub extern fn BN_from_montgomery(ret: [*c]BIGNUM, a: [*c]const BIGNUM, mont: [*c]const BN_MONT_CTX, ctx: ?*BN_CTX) c_int;
+pub extern fn BN_mod_mul_montgomery(r: [*c]BIGNUM, a: [*c]const BIGNUM, b: [*c]const BIGNUM, mont: [*c]const BN_MONT_CTX, ctx: ?*BN_CTX) c_int;
+pub extern fn BN_exp(r: [*c]BIGNUM, a: [*c]const BIGNUM, p: [*c]const BIGNUM, ctx: ?*BN_CTX) c_int;
+pub extern fn BN_mod_exp(r: [*c]BIGNUM, a: [*c]const BIGNUM, p: [*c]const BIGNUM, m: [*c]const BIGNUM, ctx: ?*BN_CTX) c_int;
+pub extern fn BN_mod_exp_mont(r: [*c]BIGNUM, a: [*c]const BIGNUM, p: [*c]const BIGNUM, m: [*c]const BIGNUM, ctx: ?*BN_CTX, mont: [*c]const BN_MONT_CTX) c_int;
+pub extern fn BN_mod_exp_mont_consttime(rr: [*c]BIGNUM, a: [*c]const BIGNUM, p: [*c]const BIGNUM, m: [*c]const BIGNUM, ctx: ?*BN_CTX, mont: [*c]const BN_MONT_CTX) c_int;
+pub extern fn BN_bn2mpi(in: [*c]const BIGNUM, out: [*c]u8) usize;
+pub extern fn BN_mpi2bn(in: [*c]const u8, len: usize, out: [*c]BIGNUM) [*c]BIGNUM;
+pub extern fn BN_mod_exp_mont_word(r: [*c]BIGNUM, a: u64, p: [*c]const BIGNUM, m: [*c]const BIGNUM, ctx: ?*BN_CTX, mont: [*c]const BN_MONT_CTX) c_int;
+pub extern fn BN_mod_exp2_mont(r: [*c]BIGNUM, a1: [*c]const BIGNUM, p1: [*c]const BIGNUM, a2: [*c]const BIGNUM, p2: [*c]const BIGNUM, m: [*c]const BIGNUM, ctx: ?*BN_CTX, mont: [*c]const BN_MONT_CTX) c_int;
+pub extern fn BN_MONT_CTX_new() [*c]BN_MONT_CTX;
+pub extern fn BN_MONT_CTX_set(mont: [*c]BN_MONT_CTX, mod: [*c]const BIGNUM, ctx: ?*BN_CTX) c_int;
+pub extern fn BN_bn2binpad(in: [*c]const BIGNUM, out: [*c]u8, len: c_int) c_int;
+pub extern fn BN_num_bits_word(l: u64) c_uint;
+pub extern fn ASN1_tag2bit(tag: c_int) c_ulong;
+pub extern fn ASN1_tag2str(tag: c_int) [*c]const u8;
+pub const d2i_of_void = fn ([*c]?*c_void, [*c][*c]const u8, c_long) callconv(.C) ?*c_void;
+pub const i2d_of_void = fn (?*const c_void, [*c][*c]u8) callconv(.C) c_int;
+pub const ASN1_ITEM_EXP = ASN1_ITEM;
+pub extern fn ASN1_item_new(it: ?*const ASN1_ITEM) ?*ASN1_VALUE;
+pub extern fn ASN1_item_free(val: ?*ASN1_VALUE, it: ?*const ASN1_ITEM) void;
+pub extern fn ASN1_item_d2i(out: [*c]?*ASN1_VALUE, inp: [*c][*c]const u8, len: c_long, it: ?*const ASN1_ITEM) ?*ASN1_VALUE;
+pub extern fn ASN1_item_i2d(val: ?*ASN1_VALUE, outp: [*c][*c]u8, it: ?*const ASN1_ITEM) c_int;
+pub extern fn ASN1_item_dup(it: ?*const ASN1_ITEM, x: ?*c_void) ?*c_void;
+pub extern fn ASN1_item_d2i_fp(it: ?*const ASN1_ITEM, in: [*c]FILE, out: ?*c_void) ?*c_void;
+pub extern fn ASN1_item_d2i_bio(it: ?*const ASN1_ITEM, in: [*c]BIO, out: ?*c_void) ?*c_void;
+pub extern fn ASN1_item_i2d_fp(it: ?*const ASN1_ITEM, out: [*c]FILE, in: ?*c_void) c_int;
+pub extern fn ASN1_item_i2d_bio(it: ?*const ASN1_ITEM, out: [*c]BIO, in: ?*c_void) c_int;
+pub extern fn ASN1_item_unpack(oct: [*c]const ASN1_STRING, it: ?*const ASN1_ITEM) ?*c_void;
+pub extern fn ASN1_item_pack(obj: ?*c_void, it: ?*const ASN1_ITEM, out: [*c][*c]ASN1_STRING) [*c]ASN1_STRING;
+pub extern fn d2i_ASN1_BOOLEAN(out: [*c]ASN1_BOOLEAN, inp: [*c][*c]const u8, len: c_long) ASN1_BOOLEAN;
+pub extern fn i2d_ASN1_BOOLEAN(a: ASN1_BOOLEAN, outp: [*c][*c]u8) c_int;
+pub extern const ASN1_BOOLEAN_it: ASN1_ITEM;
+pub extern const ASN1_TBOOLEAN_it: ASN1_ITEM;
+pub extern const ASN1_FBOOLEAN_it: ASN1_ITEM;
+pub extern fn ASN1_STRING_type_new(@"type": c_int) [*c]ASN1_STRING;
+pub extern fn ASN1_STRING_new() [*c]ASN1_STRING;
+pub extern fn ASN1_STRING_free(str: [*c]ASN1_STRING) void;
+pub extern fn ASN1_STRING_copy(dst: [*c]ASN1_STRING, str: [*c]const ASN1_STRING) c_int;
+pub extern fn ASN1_STRING_dup(str: [*c]const ASN1_STRING) [*c]ASN1_STRING;
+pub extern fn ASN1_STRING_type(str: [*c]const ASN1_STRING) c_int;
+pub extern fn ASN1_STRING_get0_data(str: [*c]const ASN1_STRING) [*c]const u8;
+pub extern fn ASN1_STRING_data(str: [*c]ASN1_STRING) [*c]u8;
+pub extern fn ASN1_STRING_length(str: [*c]const ASN1_STRING) c_int;
+pub extern fn ASN1_STRING_cmp(a: [*c]const ASN1_STRING, b: [*c]const ASN1_STRING) c_int;
+pub extern fn ASN1_STRING_set(str: [*c]ASN1_STRING, data: ?*const c_void, len: c_int) c_int;
+pub extern fn ASN1_STRING_set0(str: [*c]ASN1_STRING, data: ?*c_void, len: c_int) void;
+pub extern fn ASN1_BMPSTRING_new() [*c]ASN1_BMPSTRING;
+pub extern fn ASN1_GENERALSTRING_new() [*c]ASN1_GENERALSTRING;
+pub extern fn ASN1_IA5STRING_new() [*c]ASN1_IA5STRING;
+pub extern fn ASN1_OCTET_STRING_new() [*c]ASN1_OCTET_STRING;
+pub extern fn ASN1_PRINTABLESTRING_new() [*c]ASN1_PRINTABLESTRING;
+pub extern fn ASN1_T61STRING_new() [*c]ASN1_T61STRING;
+pub extern fn ASN1_UNIVERSALSTRING_new() [*c]ASN1_UNIVERSALSTRING;
+pub extern fn ASN1_UTF8STRING_new() [*c]ASN1_UTF8STRING;
+pub extern fn ASN1_VISIBLESTRING_new() [*c]ASN1_VISIBLESTRING;
+pub extern fn ASN1_BMPSTRING_free(str: [*c]ASN1_BMPSTRING) void;
+pub extern fn ASN1_GENERALSTRING_free(str: [*c]ASN1_GENERALSTRING) void;
+pub extern fn ASN1_IA5STRING_free(str: [*c]ASN1_IA5STRING) void;
+pub extern fn ASN1_OCTET_STRING_free(str: [*c]ASN1_OCTET_STRING) void;
+pub extern fn ASN1_PRINTABLESTRING_free(str: [*c]ASN1_PRINTABLESTRING) void;
+pub extern fn ASN1_T61STRING_free(str: [*c]ASN1_T61STRING) void;
+pub extern fn ASN1_UNIVERSALSTRING_free(str: [*c]ASN1_UNIVERSALSTRING) void;
+pub extern fn ASN1_UTF8STRING_free(str: [*c]ASN1_UTF8STRING) void;
+pub extern fn ASN1_VISIBLESTRING_free(str: [*c]ASN1_VISIBLESTRING) void;
+pub extern fn d2i_ASN1_BMPSTRING(out: [*c][*c]ASN1_BMPSTRING, inp: [*c][*c]const u8, len: c_long) [*c]ASN1_BMPSTRING;
+pub extern fn d2i_ASN1_GENERALSTRING(out: [*c][*c]ASN1_GENERALSTRING, inp: [*c][*c]const u8, len: c_long) [*c]ASN1_GENERALSTRING;
+pub extern fn d2i_ASN1_IA5STRING(out: [*c][*c]ASN1_IA5STRING, inp: [*c][*c]const u8, len: c_long) [*c]ASN1_IA5STRING;
+pub extern fn d2i_ASN1_OCTET_STRING(out: [*c][*c]ASN1_OCTET_STRING, inp: [*c][*c]const u8, len: c_long) [*c]ASN1_OCTET_STRING;
+pub extern fn d2i_ASN1_PRINTABLESTRING(out: [*c][*c]ASN1_PRINTABLESTRING, inp: [*c][*c]const u8, len: c_long) [*c]ASN1_PRINTABLESTRING;
+pub extern fn d2i_ASN1_T61STRING(out: [*c][*c]ASN1_T61STRING, inp: [*c][*c]const u8, len: c_long) [*c]ASN1_T61STRING;
+pub extern fn d2i_ASN1_UNIVERSALSTRING(out: [*c][*c]ASN1_UNIVERSALSTRING, inp: [*c][*c]const u8, len: c_long) [*c]ASN1_UNIVERSALSTRING;
+pub extern fn d2i_ASN1_UTF8STRING(out: [*c][*c]ASN1_UTF8STRING, inp: [*c][*c]const u8, len: c_long) [*c]ASN1_UTF8STRING;
+pub extern fn d2i_ASN1_VISIBLESTRING(out: [*c][*c]ASN1_VISIBLESTRING, inp: [*c][*c]const u8, len: c_long) [*c]ASN1_VISIBLESTRING;
+pub extern fn i2d_ASN1_BMPSTRING(in: [*c]const ASN1_BMPSTRING, outp: [*c][*c]u8) c_int;
+pub extern fn i2d_ASN1_GENERALSTRING(in: [*c]const ASN1_GENERALSTRING, outp: [*c][*c]u8) c_int;
+pub extern fn i2d_ASN1_IA5STRING(in: [*c]const ASN1_IA5STRING, outp: [*c][*c]u8) c_int;
+pub extern fn i2d_ASN1_OCTET_STRING(in: [*c]const ASN1_OCTET_STRING, outp: [*c][*c]u8) c_int;
+pub extern fn i2d_ASN1_PRINTABLESTRING(in: [*c]const ASN1_PRINTABLESTRING, outp: [*c][*c]u8) c_int;
+pub extern fn i2d_ASN1_T61STRING(in: [*c]const ASN1_T61STRING, outp: [*c][*c]u8) c_int;
+pub extern fn i2d_ASN1_UNIVERSALSTRING(in: [*c]const ASN1_UNIVERSALSTRING, outp: [*c][*c]u8) c_int;
+pub extern fn i2d_ASN1_UTF8STRING(in: [*c]const ASN1_UTF8STRING, outp: [*c][*c]u8) c_int;
+pub extern fn i2d_ASN1_VISIBLESTRING(in: [*c]const ASN1_VISIBLESTRING, outp: [*c][*c]u8) c_int;
+pub extern const ASN1_BMPSTRING_it: ASN1_ITEM;
+pub extern const ASN1_GENERALSTRING_it: ASN1_ITEM;
+pub extern const ASN1_IA5STRING_it: ASN1_ITEM;
+pub extern const ASN1_OCTET_STRING_it: ASN1_ITEM;
+pub extern const ASN1_PRINTABLESTRING_it: ASN1_ITEM;
+pub extern const ASN1_T61STRING_it: ASN1_ITEM;
+pub extern const ASN1_UNIVERSALSTRING_it: ASN1_ITEM;
+pub extern const ASN1_UTF8STRING_it: ASN1_ITEM;
+pub extern const ASN1_VISIBLESTRING_it: ASN1_ITEM;
+pub extern fn ASN1_OCTET_STRING_dup(a: [*c]const ASN1_OCTET_STRING) [*c]ASN1_OCTET_STRING;
+pub extern fn ASN1_OCTET_STRING_cmp(a: [*c]const ASN1_OCTET_STRING, b: [*c]const ASN1_OCTET_STRING) c_int;
+pub extern fn ASN1_OCTET_STRING_set(str: [*c]ASN1_OCTET_STRING, data: [*c]const u8, len: c_int) c_int;
+pub extern fn ASN1_STRING_to_UTF8(out: [*c][*c]u8, in: [*c]const ASN1_STRING) c_int;
+pub extern fn ASN1_mbstring_copy(out: [*c][*c]ASN1_STRING, in: [*c]const u8, len: c_int, inform: c_int, mask: c_ulong) c_int;
+pub extern fn ASN1_mbstring_ncopy(out: [*c][*c]ASN1_STRING, in: [*c]const u8, len: c_int, inform: c_int, mask: c_ulong, minsize: c_long, maxsize: c_long) c_int;
+pub extern fn ASN1_STRING_set_by_NID(out: [*c][*c]ASN1_STRING, in: [*c]const u8, len: c_int, inform: c_int, nid: c_int) [*c]ASN1_STRING;
+pub extern fn ASN1_STRING_TABLE_add(nid: c_int, minsize: c_long, maxsize: c_long, mask: c_ulong, flags: c_ulong) c_int;
+pub extern fn DIRECTORYSTRING_new() [*c]ASN1_STRING;
+pub extern fn DIRECTORYSTRING_free(str: [*c]ASN1_STRING) void;
+pub extern fn d2i_DIRECTORYSTRING(out: [*c][*c]ASN1_STRING, inp: [*c][*c]const u8, len: c_long) [*c]ASN1_STRING;
+pub extern fn i2d_DIRECTORYSTRING(in: [*c]const ASN1_STRING, outp: [*c][*c]u8) c_int;
+pub extern const DIRECTORYSTRING_it: ASN1_ITEM;
+pub extern fn DISPLAYTEXT_new() [*c]ASN1_STRING;
+pub extern fn DISPLAYTEXT_free(str: [*c]ASN1_STRING) void;
+pub extern fn d2i_DISPLAYTEXT(out: [*c][*c]ASN1_STRING, inp: [*c][*c]const u8, len: c_long) [*c]ASN1_STRING;
+pub extern fn i2d_DISPLAYTEXT(in: [*c]const ASN1_STRING, outp: [*c][*c]u8) c_int;
+pub extern const DISPLAYTEXT_it: ASN1_ITEM;
+pub extern fn ASN1_BIT_STRING_new() [*c]ASN1_BIT_STRING;
+pub extern fn ASN1_BIT_STRING_free(str: [*c]ASN1_BIT_STRING) void;
+pub extern fn d2i_ASN1_BIT_STRING(out: [*c][*c]ASN1_BIT_STRING, inp: [*c][*c]const u8, len: c_long) [*c]ASN1_BIT_STRING;
+pub extern fn i2d_ASN1_BIT_STRING(in: [*c]const ASN1_BIT_STRING, outp: [*c][*c]u8) c_int;
+pub extern fn c2i_ASN1_BIT_STRING(out: [*c][*c]ASN1_BIT_STRING, inp: [*c][*c]const u8, len: c_long) [*c]ASN1_BIT_STRING;
+pub extern fn i2c_ASN1_BIT_STRING(in: [*c]const ASN1_BIT_STRING, outp: [*c][*c]u8) c_int;
+pub extern const ASN1_BIT_STRING_it: ASN1_ITEM;
+pub extern fn ASN1_BIT_STRING_num_bytes(str: [*c]const ASN1_BIT_STRING, out: [*c]usize) c_int;
+pub extern fn ASN1_BIT_STRING_set(str: [*c]ASN1_BIT_STRING, d: [*c]const u8, length: c_int) c_int;
+pub extern fn ASN1_BIT_STRING_set_bit(str: [*c]ASN1_BIT_STRING, n: c_int, value: c_int) c_int;
+pub extern fn ASN1_BIT_STRING_get_bit(str: [*c]const ASN1_BIT_STRING, n: c_int) c_int;
+pub extern fn ASN1_BIT_STRING_check(str: [*c]const ASN1_BIT_STRING, flags: [*c]const u8, flags_len: c_int) c_int;
+pub const struct_stack_st_ASN1_INTEGER = opaque {};
+pub const stack_ASN1_INTEGER_free_func = ?fn ([*c]ASN1_INTEGER) callconv(.C) void;
+pub const stack_ASN1_INTEGER_copy_func = ?fn ([*c]ASN1_INTEGER) callconv(.C) [*c]ASN1_INTEGER;
+pub const stack_ASN1_INTEGER_cmp_func = ?fn ([*c][*c]const ASN1_INTEGER, [*c][*c]const ASN1_INTEGER) callconv(.C) c_int;
+pub fn sk_ASN1_INTEGER_call_free_func(arg_free_func: stack_free_func, arg_ptr: ?*c_void) callconv(.C) void {
+ var free_func = arg_free_func;
+ var ptr = arg_ptr;
+ @ptrCast(stack_ASN1_INTEGER_free_func, @alignCast(@import("std").meta.alignment(fn ([*c]ASN1_INTEGER) callconv(.C) void), free_func)).?(@ptrCast([*c]ASN1_INTEGER, @alignCast(@import("std").meta.alignment(ASN1_INTEGER), ptr)));
+}
+pub fn sk_ASN1_INTEGER_call_copy_func(arg_copy_func: stack_copy_func, arg_ptr: ?*c_void) callconv(.C) ?*c_void {
+ var copy_func = arg_copy_func;
+ var ptr = arg_ptr;
+ return @ptrCast(?*c_void, @ptrCast(stack_ASN1_INTEGER_copy_func, @alignCast(@import("std").meta.alignment(fn ([*c]ASN1_INTEGER) callconv(.C) [*c]ASN1_INTEGER), copy_func)).?(@ptrCast([*c]ASN1_INTEGER, @alignCast(@import("std").meta.alignment(ASN1_INTEGER), ptr))));
+}
+pub fn sk_ASN1_INTEGER_call_cmp_func(arg_cmp_func: stack_cmp_func, arg_a: [*c]?*const c_void, arg_b: [*c]?*const c_void) callconv(.C) c_int {
+ var cmp_func = arg_cmp_func;
+ var a = arg_a;
+ var b = arg_b;
+ var a_ptr: [*c]const ASN1_INTEGER = @ptrCast([*c]const ASN1_INTEGER, @alignCast(@import("std").meta.alignment(ASN1_INTEGER), a.*));
+ var b_ptr: [*c]const ASN1_INTEGER = @ptrCast([*c]const ASN1_INTEGER, @alignCast(@import("std").meta.alignment(ASN1_INTEGER), b.*));
+ return @ptrCast(stack_ASN1_INTEGER_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c][*c]const ASN1_INTEGER, [*c][*c]const ASN1_INTEGER) callconv(.C) c_int), cmp_func)).?(&a_ptr, &b_ptr);
+}
+pub fn sk_ASN1_INTEGER_new(arg_comp: stack_ASN1_INTEGER_cmp_func) callconv(.C) ?*struct_stack_st_ASN1_INTEGER {
+ var comp = arg_comp;
+ return @ptrCast(?*struct_stack_st_ASN1_INTEGER, sk_new(@ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp))));
+}
+pub fn sk_ASN1_INTEGER_new_null() callconv(.C) ?*struct_stack_st_ASN1_INTEGER {
+ return @ptrCast(?*struct_stack_st_ASN1_INTEGER, sk_new_null());
+}
+pub fn sk_ASN1_INTEGER_num(arg_sk: ?*const struct_stack_st_ASN1_INTEGER) callconv(.C) usize {
+ var sk = arg_sk;
+ return sk_num(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_ASN1_INTEGER_zero(arg_sk: ?*struct_stack_st_ASN1_INTEGER) callconv(.C) void {
+ var sk = arg_sk;
+ sk_zero(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_ASN1_INTEGER_value(arg_sk: ?*const struct_stack_st_ASN1_INTEGER, arg_i: usize) callconv(.C) [*c]ASN1_INTEGER {
+ var sk = arg_sk;
+ var i = arg_i;
+ return @ptrCast([*c]ASN1_INTEGER, @alignCast(@import("std").meta.alignment(ASN1_INTEGER), sk_value(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i)));
+}
+pub fn sk_ASN1_INTEGER_set(arg_sk: ?*struct_stack_st_ASN1_INTEGER, arg_i: usize, arg_p: [*c]ASN1_INTEGER) callconv(.C) [*c]ASN1_INTEGER {
+ var sk = arg_sk;
+ var i = arg_i;
+ var p = arg_p;
+ return @ptrCast([*c]ASN1_INTEGER, @alignCast(@import("std").meta.alignment(ASN1_INTEGER), sk_set(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i, @ptrCast(?*c_void, p))));
+}
+pub fn sk_ASN1_INTEGER_free(arg_sk: ?*struct_stack_st_ASN1_INTEGER) callconv(.C) void {
+ var sk = arg_sk;
+ sk_free(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_ASN1_INTEGER_pop_free(arg_sk: ?*struct_stack_st_ASN1_INTEGER, arg_free_func: stack_ASN1_INTEGER_free_func) callconv(.C) void {
+ var sk = arg_sk;
+ var free_func = arg_free_func;
+ sk_pop_free_ex(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_ASN1_INTEGER_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func)));
+}
+pub fn sk_ASN1_INTEGER_insert(arg_sk: ?*struct_stack_st_ASN1_INTEGER, arg_p: [*c]ASN1_INTEGER, arg_where: usize) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ var where = arg_where;
+ return sk_insert(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p), where);
+}
+pub fn sk_ASN1_INTEGER_delete(arg_sk: ?*struct_stack_st_ASN1_INTEGER, arg_where: usize) callconv(.C) [*c]ASN1_INTEGER {
+ var sk = arg_sk;
+ var where = arg_where;
+ return @ptrCast([*c]ASN1_INTEGER, @alignCast(@import("std").meta.alignment(ASN1_INTEGER), sk_delete(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), where)));
+}
+pub fn sk_ASN1_INTEGER_delete_ptr(arg_sk: ?*struct_stack_st_ASN1_INTEGER, arg_p: [*c]const ASN1_INTEGER) callconv(.C) [*c]ASN1_INTEGER {
+ var sk = arg_sk;
+ var p = arg_p;
+ return @ptrCast([*c]ASN1_INTEGER, @alignCast(@import("std").meta.alignment(ASN1_INTEGER), sk_delete_ptr(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*const c_void, p))));
+}
+pub fn sk_ASN1_INTEGER_find(arg_sk: ?*const struct_stack_st_ASN1_INTEGER, arg_out_index: [*c]usize, arg_p: [*c]const ASN1_INTEGER) callconv(.C) c_int {
+ var sk = arg_sk;
+ var out_index = arg_out_index;
+ var p = arg_p;
+ return sk_find(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), out_index, @ptrCast(?*const c_void, p), sk_ASN1_INTEGER_call_cmp_func);
+}
+pub fn sk_ASN1_INTEGER_shift(arg_sk: ?*struct_stack_st_ASN1_INTEGER) callconv(.C) [*c]ASN1_INTEGER {
+ var sk = arg_sk;
+ return @ptrCast([*c]ASN1_INTEGER, @alignCast(@import("std").meta.alignment(ASN1_INTEGER), sk_shift(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)))));
+}
+pub fn sk_ASN1_INTEGER_push(arg_sk: ?*struct_stack_st_ASN1_INTEGER, arg_p: [*c]ASN1_INTEGER) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ return sk_push(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p));
+}
+pub fn sk_ASN1_INTEGER_pop(arg_sk: ?*struct_stack_st_ASN1_INTEGER) callconv(.C) [*c]ASN1_INTEGER {
+ var sk = arg_sk;
+ return @ptrCast([*c]ASN1_INTEGER, @alignCast(@import("std").meta.alignment(ASN1_INTEGER), sk_pop(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)))));
+}
+pub fn sk_ASN1_INTEGER_dup(arg_sk: ?*const struct_stack_st_ASN1_INTEGER) callconv(.C) ?*struct_stack_st_ASN1_INTEGER {
+ var sk = arg_sk;
+ return @ptrCast(?*struct_stack_st_ASN1_INTEGER, sk_dup(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_ASN1_INTEGER_sort(arg_sk: ?*struct_stack_st_ASN1_INTEGER) callconv(.C) void {
+ var sk = arg_sk;
+ sk_sort(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_ASN1_INTEGER_is_sorted(arg_sk: ?*const struct_stack_st_ASN1_INTEGER) callconv(.C) c_int {
+ var sk = arg_sk;
+ return sk_is_sorted(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_ASN1_INTEGER_set_cmp_func(arg_sk: ?*struct_stack_st_ASN1_INTEGER, arg_comp: stack_ASN1_INTEGER_cmp_func) callconv(.C) stack_ASN1_INTEGER_cmp_func {
+ var sk = arg_sk;
+ var comp = arg_comp;
+ return @ptrCast(stack_ASN1_INTEGER_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c][*c]const ASN1_INTEGER, [*c][*c]const ASN1_INTEGER) callconv(.C) c_int), sk_set_cmp_func(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp)))));
+}
+pub fn sk_ASN1_INTEGER_deep_copy(arg_sk: ?*const struct_stack_st_ASN1_INTEGER, arg_copy_func: ?fn ([*c]ASN1_INTEGER) callconv(.C) [*c]ASN1_INTEGER, arg_free_func: ?fn ([*c]ASN1_INTEGER) callconv(.C) void) callconv(.C) ?*struct_stack_st_ASN1_INTEGER {
+ var sk = arg_sk;
+ var copy_func = arg_copy_func;
+ var free_func = arg_free_func;
+ return @ptrCast(?*struct_stack_st_ASN1_INTEGER, sk_deep_copy(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_ASN1_INTEGER_call_copy_func, @ptrCast(stack_copy_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) ?*c_void), copy_func)), sk_ASN1_INTEGER_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func))));
+}
+pub extern fn ASN1_INTEGER_new() [*c]ASN1_INTEGER;
+pub extern fn ASN1_INTEGER_free(str: [*c]ASN1_INTEGER) void;
+pub extern fn ASN1_INTEGER_dup(x: [*c]const ASN1_INTEGER) [*c]ASN1_INTEGER;
+pub extern fn d2i_ASN1_INTEGER(out: [*c][*c]ASN1_INTEGER, inp: [*c][*c]const u8, len: c_long) [*c]ASN1_INTEGER;
+pub extern fn i2d_ASN1_INTEGER(in: [*c]const ASN1_INTEGER, outp: [*c][*c]u8) c_int;
+pub extern fn c2i_ASN1_INTEGER(in: [*c][*c]ASN1_INTEGER, outp: [*c][*c]const u8, len: c_long) [*c]ASN1_INTEGER;
+pub extern fn i2c_ASN1_INTEGER(in: [*c]const ASN1_INTEGER, outp: [*c][*c]u8) c_int;
+pub extern const ASN1_INTEGER_it: ASN1_ITEM;
+pub extern fn ASN1_INTEGER_set(a: [*c]ASN1_INTEGER, v: c_long) c_int;
+pub extern fn ASN1_INTEGER_set_uint64(out: [*c]ASN1_INTEGER, v: u64) c_int;
+pub extern fn ASN1_INTEGER_get(a: [*c]const ASN1_INTEGER) c_long;
+pub extern fn BN_to_ASN1_INTEGER(bn: [*c]const BIGNUM, ai: [*c]ASN1_INTEGER) [*c]ASN1_INTEGER;
+pub extern fn ASN1_INTEGER_to_BN(ai: [*c]const ASN1_INTEGER, bn: [*c]BIGNUM) [*c]BIGNUM;
+pub extern fn ASN1_INTEGER_cmp(x: [*c]const ASN1_INTEGER, y: [*c]const ASN1_INTEGER) c_int;
+pub extern fn ASN1_ENUMERATED_new() [*c]ASN1_ENUMERATED;
+pub extern fn ASN1_ENUMERATED_free(str: [*c]ASN1_ENUMERATED) void;
+pub extern fn d2i_ASN1_ENUMERATED(out: [*c][*c]ASN1_ENUMERATED, inp: [*c][*c]const u8, len: c_long) [*c]ASN1_ENUMERATED;
+pub extern fn i2d_ASN1_ENUMERATED(in: [*c]const ASN1_ENUMERATED, outp: [*c][*c]u8) c_int;
+pub extern const ASN1_ENUMERATED_it: ASN1_ITEM;
+pub extern fn ASN1_ENUMERATED_set(a: [*c]ASN1_ENUMERATED, v: c_long) c_int;
+pub extern fn ASN1_ENUMERATED_get(a: [*c]const ASN1_ENUMERATED) c_long;
+pub extern fn BN_to_ASN1_ENUMERATED(bn: [*c]const BIGNUM, ai: [*c]ASN1_ENUMERATED) [*c]ASN1_ENUMERATED;
+pub extern fn ASN1_ENUMERATED_to_BN(ai: [*c]const ASN1_ENUMERATED, bn: [*c]BIGNUM) [*c]BIGNUM;
+pub extern fn ASN1_UTCTIME_new() [*c]ASN1_UTCTIME;
+pub extern fn ASN1_UTCTIME_free(str: [*c]ASN1_UTCTIME) void;
+pub extern fn d2i_ASN1_UTCTIME(out: [*c][*c]ASN1_UTCTIME, inp: [*c][*c]const u8, len: c_long) [*c]ASN1_UTCTIME;
+pub extern fn i2d_ASN1_UTCTIME(in: [*c]const ASN1_UTCTIME, outp: [*c][*c]u8) c_int;
+pub extern const ASN1_UTCTIME_it: ASN1_ITEM;
+pub extern fn ASN1_UTCTIME_check(a: [*c]const ASN1_UTCTIME) c_int;
+pub extern fn ASN1_UTCTIME_set(s: [*c]ASN1_UTCTIME, t: time_t) [*c]ASN1_UTCTIME;
+pub extern fn ASN1_UTCTIME_adj(s: [*c]ASN1_UTCTIME, t: time_t, offset_day: c_int, offset_sec: c_long) [*c]ASN1_UTCTIME;
+pub extern fn ASN1_UTCTIME_set_string(s: [*c]ASN1_UTCTIME, str: [*c]const u8) c_int;
+pub extern fn ASN1_UTCTIME_cmp_time_t(s: [*c]const ASN1_UTCTIME, t: time_t) c_int;
+pub extern fn ASN1_GENERALIZEDTIME_new() [*c]ASN1_GENERALIZEDTIME;
+pub extern fn ASN1_GENERALIZEDTIME_free(str: [*c]ASN1_GENERALIZEDTIME) void;
+pub extern fn d2i_ASN1_GENERALIZEDTIME(out: [*c][*c]ASN1_GENERALIZEDTIME, inp: [*c][*c]const u8, len: c_long) [*c]ASN1_GENERALIZEDTIME;
+pub extern fn i2d_ASN1_GENERALIZEDTIME(in: [*c]const ASN1_GENERALIZEDTIME, outp: [*c][*c]u8) c_int;
+pub extern const ASN1_GENERALIZEDTIME_it: ASN1_ITEM;
+pub extern fn ASN1_GENERALIZEDTIME_check(a: [*c]const ASN1_GENERALIZEDTIME) c_int;
+pub extern fn ASN1_GENERALIZEDTIME_set(s: [*c]ASN1_GENERALIZEDTIME, t: time_t) [*c]ASN1_GENERALIZEDTIME;
+pub extern fn ASN1_GENERALIZEDTIME_adj(s: [*c]ASN1_GENERALIZEDTIME, t: time_t, offset_day: c_int, offset_sec: c_long) [*c]ASN1_GENERALIZEDTIME;
+pub extern fn ASN1_GENERALIZEDTIME_set_string(s: [*c]ASN1_GENERALIZEDTIME, str: [*c]const u8) c_int;
+pub extern fn ASN1_TIME_new() [*c]ASN1_TIME;
+pub extern fn ASN1_TIME_free(str: [*c]ASN1_TIME) void;
+pub extern fn d2i_ASN1_TIME(out: [*c][*c]ASN1_TIME, inp: [*c][*c]const u8, len: c_long) [*c]ASN1_TIME;
+pub extern fn i2d_ASN1_TIME(in: [*c]const ASN1_TIME, outp: [*c][*c]u8) c_int;
+pub extern const ASN1_TIME_it: ASN1_ITEM;
+pub extern fn ASN1_TIME_diff(out_days: [*c]c_int, out_seconds: [*c]c_int, from: [*c]const ASN1_TIME, to: [*c]const ASN1_TIME) c_int;
+pub extern fn ASN1_TIME_set(s: [*c]ASN1_TIME, t: time_t) [*c]ASN1_TIME;
+pub extern fn ASN1_TIME_adj(s: [*c]ASN1_TIME, t: time_t, offset_day: c_int, offset_sec: c_long) [*c]ASN1_TIME;
+pub extern fn ASN1_TIME_check(t: [*c]const ASN1_TIME) c_int;
+pub extern fn ASN1_TIME_to_generalizedtime(t: [*c]const ASN1_TIME, out: [*c][*c]ASN1_GENERALIZEDTIME) [*c]ASN1_GENERALIZEDTIME;
+pub extern fn ASN1_TIME_set_string(s: [*c]ASN1_TIME, str: [*c]const u8) c_int;
+pub extern fn ASN1_NULL_new() ?*ASN1_NULL;
+pub extern fn ASN1_NULL_free(@"null": ?*ASN1_NULL) void;
+pub extern fn d2i_ASN1_NULL(out: [*c]?*ASN1_NULL, inp: [*c][*c]const u8, len: c_long) ?*ASN1_NULL;
+pub extern fn i2d_ASN1_NULL(in: ?*const ASN1_NULL, outp: [*c][*c]u8) c_int;
+pub extern const ASN1_NULL_it: ASN1_ITEM;
+pub const struct_stack_st_ASN1_OBJECT = opaque {};
+pub const stack_ASN1_OBJECT_free_func = ?fn (?*ASN1_OBJECT) callconv(.C) void;
+pub const stack_ASN1_OBJECT_copy_func = ?fn (?*ASN1_OBJECT) callconv(.C) ?*ASN1_OBJECT;
+pub const stack_ASN1_OBJECT_cmp_func = ?fn ([*c]?*const ASN1_OBJECT, [*c]?*const ASN1_OBJECT) callconv(.C) c_int;
+pub fn sk_ASN1_OBJECT_call_free_func(arg_free_func: stack_free_func, arg_ptr: ?*c_void) callconv(.C) void {
+ var free_func = arg_free_func;
+ var ptr = arg_ptr;
+ @ptrCast(stack_ASN1_OBJECT_free_func, @alignCast(@import("std").meta.alignment(fn (?*ASN1_OBJECT) callconv(.C) void), free_func)).?(@ptrCast(?*ASN1_OBJECT, ptr));
+}
+pub fn sk_ASN1_OBJECT_call_copy_func(arg_copy_func: stack_copy_func, arg_ptr: ?*c_void) callconv(.C) ?*c_void {
+ var copy_func = arg_copy_func;
+ var ptr = arg_ptr;
+ return @ptrCast(?*c_void, @ptrCast(stack_ASN1_OBJECT_copy_func, @alignCast(@import("std").meta.alignment(fn (?*ASN1_OBJECT) callconv(.C) ?*ASN1_OBJECT), copy_func)).?(@ptrCast(?*ASN1_OBJECT, ptr)));
+}
+pub fn sk_ASN1_OBJECT_call_cmp_func(arg_cmp_func: stack_cmp_func, arg_a: [*c]?*const c_void, arg_b: [*c]?*const c_void) callconv(.C) c_int {
+ var cmp_func = arg_cmp_func;
+ var a = arg_a;
+ var b = arg_b;
+ var a_ptr: ?*const ASN1_OBJECT = @ptrCast(?*const ASN1_OBJECT, a.*);
+ var b_ptr: ?*const ASN1_OBJECT = @ptrCast(?*const ASN1_OBJECT, b.*);
+ return @ptrCast(stack_ASN1_OBJECT_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const ASN1_OBJECT, [*c]?*const ASN1_OBJECT) callconv(.C) c_int), cmp_func)).?(&a_ptr, &b_ptr);
+}
+pub fn sk_ASN1_OBJECT_new(arg_comp: stack_ASN1_OBJECT_cmp_func) callconv(.C) ?*struct_stack_st_ASN1_OBJECT {
+ var comp = arg_comp;
+ return @ptrCast(?*struct_stack_st_ASN1_OBJECT, sk_new(@ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp))));
+}
+pub fn sk_ASN1_OBJECT_new_null() callconv(.C) ?*struct_stack_st_ASN1_OBJECT {
+ return @ptrCast(?*struct_stack_st_ASN1_OBJECT, sk_new_null());
+}
+pub fn sk_ASN1_OBJECT_num(arg_sk: ?*const struct_stack_st_ASN1_OBJECT) callconv(.C) usize {
+ var sk = arg_sk;
+ return sk_num(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_ASN1_OBJECT_zero(arg_sk: ?*struct_stack_st_ASN1_OBJECT) callconv(.C) void {
+ var sk = arg_sk;
+ sk_zero(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_ASN1_OBJECT_value(arg_sk: ?*const struct_stack_st_ASN1_OBJECT, arg_i: usize) callconv(.C) ?*ASN1_OBJECT {
+ var sk = arg_sk;
+ var i = arg_i;
+ return @ptrCast(?*ASN1_OBJECT, sk_value(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i));
+}
+pub fn sk_ASN1_OBJECT_set(arg_sk: ?*struct_stack_st_ASN1_OBJECT, arg_i: usize, arg_p: ?*ASN1_OBJECT) callconv(.C) ?*ASN1_OBJECT {
+ var sk = arg_sk;
+ var i = arg_i;
+ var p = arg_p;
+ return @ptrCast(?*ASN1_OBJECT, sk_set(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i, @ptrCast(?*c_void, p)));
+}
+pub fn sk_ASN1_OBJECT_free(arg_sk: ?*struct_stack_st_ASN1_OBJECT) callconv(.C) void {
+ var sk = arg_sk;
+ sk_free(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_ASN1_OBJECT_pop_free(arg_sk: ?*struct_stack_st_ASN1_OBJECT, arg_free_func: stack_ASN1_OBJECT_free_func) callconv(.C) void {
+ var sk = arg_sk;
+ var free_func = arg_free_func;
+ sk_pop_free_ex(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_ASN1_OBJECT_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func)));
+}
+pub fn sk_ASN1_OBJECT_insert(arg_sk: ?*struct_stack_st_ASN1_OBJECT, arg_p: ?*ASN1_OBJECT, arg_where: usize) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ var where = arg_where;
+ return sk_insert(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p), where);
+}
+pub fn sk_ASN1_OBJECT_delete(arg_sk: ?*struct_stack_st_ASN1_OBJECT, arg_where: usize) callconv(.C) ?*ASN1_OBJECT {
+ var sk = arg_sk;
+ var where = arg_where;
+ return @ptrCast(?*ASN1_OBJECT, sk_delete(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), where));
+}
+pub fn sk_ASN1_OBJECT_delete_ptr(arg_sk: ?*struct_stack_st_ASN1_OBJECT, arg_p: ?*const ASN1_OBJECT) callconv(.C) ?*ASN1_OBJECT {
+ var sk = arg_sk;
+ var p = arg_p;
+ return @ptrCast(?*ASN1_OBJECT, sk_delete_ptr(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*const c_void, p)));
+}
+pub fn sk_ASN1_OBJECT_find(arg_sk: ?*const struct_stack_st_ASN1_OBJECT, arg_out_index: [*c]usize, arg_p: ?*const ASN1_OBJECT) callconv(.C) c_int {
+ var sk = arg_sk;
+ var out_index = arg_out_index;
+ var p = arg_p;
+ return sk_find(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), out_index, @ptrCast(?*const c_void, p), sk_ASN1_OBJECT_call_cmp_func);
+}
+pub fn sk_ASN1_OBJECT_shift(arg_sk: ?*struct_stack_st_ASN1_OBJECT) callconv(.C) ?*ASN1_OBJECT {
+ var sk = arg_sk;
+ return @ptrCast(?*ASN1_OBJECT, sk_shift(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_ASN1_OBJECT_push(arg_sk: ?*struct_stack_st_ASN1_OBJECT, arg_p: ?*ASN1_OBJECT) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ return sk_push(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p));
+}
+pub fn sk_ASN1_OBJECT_pop(arg_sk: ?*struct_stack_st_ASN1_OBJECT) callconv(.C) ?*ASN1_OBJECT {
+ var sk = arg_sk;
+ return @ptrCast(?*ASN1_OBJECT, sk_pop(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_ASN1_OBJECT_dup(arg_sk: ?*const struct_stack_st_ASN1_OBJECT) callconv(.C) ?*struct_stack_st_ASN1_OBJECT {
+ var sk = arg_sk;
+ return @ptrCast(?*struct_stack_st_ASN1_OBJECT, sk_dup(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_ASN1_OBJECT_sort(arg_sk: ?*struct_stack_st_ASN1_OBJECT) callconv(.C) void {
+ var sk = arg_sk;
+ sk_sort(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_ASN1_OBJECT_is_sorted(arg_sk: ?*const struct_stack_st_ASN1_OBJECT) callconv(.C) c_int {
+ var sk = arg_sk;
+ return sk_is_sorted(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_ASN1_OBJECT_set_cmp_func(arg_sk: ?*struct_stack_st_ASN1_OBJECT, arg_comp: stack_ASN1_OBJECT_cmp_func) callconv(.C) stack_ASN1_OBJECT_cmp_func {
+ var sk = arg_sk;
+ var comp = arg_comp;
+ return @ptrCast(stack_ASN1_OBJECT_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const ASN1_OBJECT, [*c]?*const ASN1_OBJECT) callconv(.C) c_int), sk_set_cmp_func(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp)))));
+}
+pub fn sk_ASN1_OBJECT_deep_copy(arg_sk: ?*const struct_stack_st_ASN1_OBJECT, arg_copy_func: ?fn (?*ASN1_OBJECT) callconv(.C) ?*ASN1_OBJECT, arg_free_func: ?fn (?*ASN1_OBJECT) callconv(.C) void) callconv(.C) ?*struct_stack_st_ASN1_OBJECT {
+ var sk = arg_sk;
+ var copy_func = arg_copy_func;
+ var free_func = arg_free_func;
+ return @ptrCast(?*struct_stack_st_ASN1_OBJECT, sk_deep_copy(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_ASN1_OBJECT_call_copy_func, @ptrCast(stack_copy_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) ?*c_void), copy_func)), sk_ASN1_OBJECT_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func))));
+}
+pub extern fn ASN1_OBJECT_create(nid: c_int, data: [*c]const u8, len: c_int, sn: [*c]const u8, ln: [*c]const u8) ?*ASN1_OBJECT;
+pub extern fn ASN1_OBJECT_free(a: ?*ASN1_OBJECT) void;
+pub extern fn d2i_ASN1_OBJECT(out: [*c]?*ASN1_OBJECT, inp: [*c][*c]const u8, len: c_long) ?*ASN1_OBJECT;
+pub extern fn i2d_ASN1_OBJECT(a: ?*const ASN1_OBJECT, outp: [*c][*c]u8) c_int;
+pub extern fn c2i_ASN1_OBJECT(out: [*c]?*ASN1_OBJECT, inp: [*c][*c]const u8, len: c_long) ?*ASN1_OBJECT;
+pub extern const ASN1_OBJECT_it: ASN1_ITEM;
+pub const struct_stack_st_ASN1_TYPE = opaque {};
+pub const stack_ASN1_TYPE_free_func = ?fn ([*c]ASN1_TYPE) callconv(.C) void;
+pub const stack_ASN1_TYPE_copy_func = ?fn ([*c]ASN1_TYPE) callconv(.C) [*c]ASN1_TYPE;
+pub const stack_ASN1_TYPE_cmp_func = ?fn ([*c][*c]const ASN1_TYPE, [*c][*c]const ASN1_TYPE) callconv(.C) c_int;
+pub fn sk_ASN1_TYPE_call_free_func(arg_free_func: stack_free_func, arg_ptr: ?*c_void) callconv(.C) void {
+ var free_func = arg_free_func;
+ var ptr = arg_ptr;
+ @ptrCast(stack_ASN1_TYPE_free_func, @alignCast(@import("std").meta.alignment(fn ([*c]ASN1_TYPE) callconv(.C) void), free_func)).?(@ptrCast([*c]ASN1_TYPE, @alignCast(@import("std").meta.alignment(ASN1_TYPE), ptr)));
+}
+pub fn sk_ASN1_TYPE_call_copy_func(arg_copy_func: stack_copy_func, arg_ptr: ?*c_void) callconv(.C) ?*c_void {
+ var copy_func = arg_copy_func;
+ var ptr = arg_ptr;
+ return @ptrCast(?*c_void, @ptrCast(stack_ASN1_TYPE_copy_func, @alignCast(@import("std").meta.alignment(fn ([*c]ASN1_TYPE) callconv(.C) [*c]ASN1_TYPE), copy_func)).?(@ptrCast([*c]ASN1_TYPE, @alignCast(@import("std").meta.alignment(ASN1_TYPE), ptr))));
+}
+pub fn sk_ASN1_TYPE_call_cmp_func(arg_cmp_func: stack_cmp_func, arg_a: [*c]?*const c_void, arg_b: [*c]?*const c_void) callconv(.C) c_int {
+ var cmp_func = arg_cmp_func;
+ var a = arg_a;
+ var b = arg_b;
+ var a_ptr: [*c]const ASN1_TYPE = @ptrCast([*c]const ASN1_TYPE, @alignCast(@import("std").meta.alignment(ASN1_TYPE), a.*));
+ var b_ptr: [*c]const ASN1_TYPE = @ptrCast([*c]const ASN1_TYPE, @alignCast(@import("std").meta.alignment(ASN1_TYPE), b.*));
+ return @ptrCast(stack_ASN1_TYPE_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c][*c]const ASN1_TYPE, [*c][*c]const ASN1_TYPE) callconv(.C) c_int), cmp_func)).?(&a_ptr, &b_ptr);
+}
+pub fn sk_ASN1_TYPE_new(arg_comp: stack_ASN1_TYPE_cmp_func) callconv(.C) ?*struct_stack_st_ASN1_TYPE {
+ var comp = arg_comp;
+ return @ptrCast(?*struct_stack_st_ASN1_TYPE, sk_new(@ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp))));
+}
+pub fn sk_ASN1_TYPE_new_null() callconv(.C) ?*struct_stack_st_ASN1_TYPE {
+ return @ptrCast(?*struct_stack_st_ASN1_TYPE, sk_new_null());
+}
+pub fn sk_ASN1_TYPE_num(arg_sk: ?*const struct_stack_st_ASN1_TYPE) callconv(.C) usize {
+ var sk = arg_sk;
+ return sk_num(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_ASN1_TYPE_zero(arg_sk: ?*struct_stack_st_ASN1_TYPE) callconv(.C) void {
+ var sk = arg_sk;
+ sk_zero(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_ASN1_TYPE_value(arg_sk: ?*const struct_stack_st_ASN1_TYPE, arg_i: usize) callconv(.C) [*c]ASN1_TYPE {
+ var sk = arg_sk;
+ var i = arg_i;
+ return @ptrCast([*c]ASN1_TYPE, @alignCast(@import("std").meta.alignment(ASN1_TYPE), sk_value(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i)));
+}
+pub fn sk_ASN1_TYPE_set(arg_sk: ?*struct_stack_st_ASN1_TYPE, arg_i: usize, arg_p: [*c]ASN1_TYPE) callconv(.C) [*c]ASN1_TYPE {
+ var sk = arg_sk;
+ var i = arg_i;
+ var p = arg_p;
+ return @ptrCast([*c]ASN1_TYPE, @alignCast(@import("std").meta.alignment(ASN1_TYPE), sk_set(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i, @ptrCast(?*c_void, p))));
+}
+pub fn sk_ASN1_TYPE_free(arg_sk: ?*struct_stack_st_ASN1_TYPE) callconv(.C) void {
+ var sk = arg_sk;
+ sk_free(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_ASN1_TYPE_pop_free(arg_sk: ?*struct_stack_st_ASN1_TYPE, arg_free_func: stack_ASN1_TYPE_free_func) callconv(.C) void {
+ var sk = arg_sk;
+ var free_func = arg_free_func;
+ sk_pop_free_ex(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_ASN1_TYPE_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func)));
+}
+pub fn sk_ASN1_TYPE_insert(arg_sk: ?*struct_stack_st_ASN1_TYPE, arg_p: [*c]ASN1_TYPE, arg_where: usize) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ var where = arg_where;
+ return sk_insert(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p), where);
+}
+pub fn sk_ASN1_TYPE_delete(arg_sk: ?*struct_stack_st_ASN1_TYPE, arg_where: usize) callconv(.C) [*c]ASN1_TYPE {
+ var sk = arg_sk;
+ var where = arg_where;
+ return @ptrCast([*c]ASN1_TYPE, @alignCast(@import("std").meta.alignment(ASN1_TYPE), sk_delete(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), where)));
+}
+pub fn sk_ASN1_TYPE_delete_ptr(arg_sk: ?*struct_stack_st_ASN1_TYPE, arg_p: [*c]const ASN1_TYPE) callconv(.C) [*c]ASN1_TYPE {
+ var sk = arg_sk;
+ var p = arg_p;
+ return @ptrCast([*c]ASN1_TYPE, @alignCast(@import("std").meta.alignment(ASN1_TYPE), sk_delete_ptr(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*const c_void, p))));
+}
+pub fn sk_ASN1_TYPE_find(arg_sk: ?*const struct_stack_st_ASN1_TYPE, arg_out_index: [*c]usize, arg_p: [*c]const ASN1_TYPE) callconv(.C) c_int {
+ var sk = arg_sk;
+ var out_index = arg_out_index;
+ var p = arg_p;
+ return sk_find(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), out_index, @ptrCast(?*const c_void, p), sk_ASN1_TYPE_call_cmp_func);
+}
+pub fn sk_ASN1_TYPE_shift(arg_sk: ?*struct_stack_st_ASN1_TYPE) callconv(.C) [*c]ASN1_TYPE {
+ var sk = arg_sk;
+ return @ptrCast([*c]ASN1_TYPE, @alignCast(@import("std").meta.alignment(ASN1_TYPE), sk_shift(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)))));
+}
+pub fn sk_ASN1_TYPE_push(arg_sk: ?*struct_stack_st_ASN1_TYPE, arg_p: [*c]ASN1_TYPE) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ return sk_push(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p));
+}
+pub fn sk_ASN1_TYPE_pop(arg_sk: ?*struct_stack_st_ASN1_TYPE) callconv(.C) [*c]ASN1_TYPE {
+ var sk = arg_sk;
+ return @ptrCast([*c]ASN1_TYPE, @alignCast(@import("std").meta.alignment(ASN1_TYPE), sk_pop(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)))));
+}
+pub fn sk_ASN1_TYPE_dup(arg_sk: ?*const struct_stack_st_ASN1_TYPE) callconv(.C) ?*struct_stack_st_ASN1_TYPE {
+ var sk = arg_sk;
+ return @ptrCast(?*struct_stack_st_ASN1_TYPE, sk_dup(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_ASN1_TYPE_sort(arg_sk: ?*struct_stack_st_ASN1_TYPE) callconv(.C) void {
+ var sk = arg_sk;
+ sk_sort(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_ASN1_TYPE_is_sorted(arg_sk: ?*const struct_stack_st_ASN1_TYPE) callconv(.C) c_int {
+ var sk = arg_sk;
+ return sk_is_sorted(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_ASN1_TYPE_set_cmp_func(arg_sk: ?*struct_stack_st_ASN1_TYPE, arg_comp: stack_ASN1_TYPE_cmp_func) callconv(.C) stack_ASN1_TYPE_cmp_func {
+ var sk = arg_sk;
+ var comp = arg_comp;
+ return @ptrCast(stack_ASN1_TYPE_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c][*c]const ASN1_TYPE, [*c][*c]const ASN1_TYPE) callconv(.C) c_int), sk_set_cmp_func(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp)))));
+}
+pub fn sk_ASN1_TYPE_deep_copy(arg_sk: ?*const struct_stack_st_ASN1_TYPE, arg_copy_func: ?fn ([*c]ASN1_TYPE) callconv(.C) [*c]ASN1_TYPE, arg_free_func: ?fn ([*c]ASN1_TYPE) callconv(.C) void) callconv(.C) ?*struct_stack_st_ASN1_TYPE {
+ var sk = arg_sk;
+ var copy_func = arg_copy_func;
+ var free_func = arg_free_func;
+ return @ptrCast(?*struct_stack_st_ASN1_TYPE, sk_deep_copy(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_ASN1_TYPE_call_copy_func, @ptrCast(stack_copy_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) ?*c_void), copy_func)), sk_ASN1_TYPE_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func))));
+}
+pub extern fn ASN1_TYPE_new() [*c]ASN1_TYPE;
+pub extern fn ASN1_TYPE_free(a: [*c]ASN1_TYPE) void;
+pub extern fn d2i_ASN1_TYPE(out: [*c][*c]ASN1_TYPE, inp: [*c][*c]const u8, len: c_long) [*c]ASN1_TYPE;
+pub extern fn i2d_ASN1_TYPE(in: [*c]const ASN1_TYPE, outp: [*c][*c]u8) c_int;
+pub extern const ASN1_ANY_it: ASN1_ITEM;
+pub extern fn ASN1_TYPE_get(a: [*c]const ASN1_TYPE) c_int;
+pub extern fn ASN1_TYPE_set(a: [*c]ASN1_TYPE, @"type": c_int, value: ?*c_void) void;
+pub extern fn ASN1_TYPE_set1(a: [*c]ASN1_TYPE, @"type": c_int, value: ?*const c_void) c_int;
+pub extern fn ASN1_TYPE_cmp(a: [*c]const ASN1_TYPE, b: [*c]const ASN1_TYPE) c_int;
+pub const ASN1_SEQUENCE_ANY = struct_stack_st_ASN1_TYPE;
+pub extern fn d2i_ASN1_SEQUENCE_ANY(out: [*c]?*ASN1_SEQUENCE_ANY, inp: [*c][*c]const u8, len: c_long) ?*ASN1_SEQUENCE_ANY;
+pub extern fn i2d_ASN1_SEQUENCE_ANY(in: ?*const ASN1_SEQUENCE_ANY, outp: [*c][*c]u8) c_int;
+pub extern fn d2i_ASN1_SET_ANY(out: [*c]?*ASN1_SEQUENCE_ANY, inp: [*c][*c]const u8, len: c_long) ?*ASN1_SEQUENCE_ANY;
+pub extern fn i2d_ASN1_SET_ANY(in: ?*const ASN1_SEQUENCE_ANY, outp: [*c][*c]u8) c_int;
+pub extern fn ASN1_UTCTIME_print(out: [*c]BIO, a: [*c]const ASN1_UTCTIME) c_int;
+pub extern fn ASN1_GENERALIZEDTIME_print(out: [*c]BIO, a: [*c]const ASN1_GENERALIZEDTIME) c_int;
+pub extern fn ASN1_TIME_print(out: [*c]BIO, a: [*c]const ASN1_TIME) c_int;
+pub extern fn ASN1_STRING_print(out: [*c]BIO, str: [*c]const ASN1_STRING) c_int;
+pub extern fn ASN1_STRING_print_ex(out: [*c]BIO, str: [*c]const ASN1_STRING, flags: c_ulong) c_int;
+pub extern fn ASN1_STRING_print_ex_fp(fp: [*c]FILE, str: [*c]const ASN1_STRING, flags: c_ulong) c_int;
+pub extern fn i2a_ASN1_INTEGER(bp: [*c]BIO, a: [*c]const ASN1_INTEGER) c_int;
+pub extern fn i2a_ASN1_ENUMERATED(bp: [*c]BIO, a: [*c]const ASN1_ENUMERATED) c_int;
+pub extern fn i2a_ASN1_OBJECT(bp: [*c]BIO, a: ?*const ASN1_OBJECT) c_int;
+pub extern fn i2a_ASN1_STRING(bp: [*c]BIO, a: [*c]const ASN1_STRING, @"type": c_int) c_int;
+pub extern fn i2t_ASN1_OBJECT(buf: [*c]u8, buf_len: c_int, a: ?*const ASN1_OBJECT) c_int;
+pub extern fn ASN1_get_object(inp: [*c][*c]const u8, out_length: [*c]c_long, out_tag: [*c]c_int, out_class: [*c]c_int, max_len: c_long) c_int;
+pub extern fn ASN1_put_object(outp: [*c][*c]u8, constructed: c_int, length: c_int, tag: c_int, xclass: c_int) void;
+pub extern fn ASN1_put_eoc(outp: [*c][*c]u8) c_int;
+pub extern fn ASN1_object_size(constructed: c_int, length: c_int, tag: c_int) c_int;
+pub extern fn ASN1_PRINTABLE_type(s: [*c]const u8, len: c_int) c_int;
+pub extern fn ASN1_STRING_set_default_mask(mask: c_ulong) void;
+pub extern fn ASN1_STRING_set_default_mask_asc(p: [*c]const u8) c_int;
+pub extern fn ASN1_STRING_get_default_mask() c_ulong;
+pub extern fn ASN1_STRING_TABLE_cleanup() void;
+pub extern fn ASN1_PRINTABLE_new() [*c]ASN1_STRING;
+pub extern fn ASN1_PRINTABLE_free(str: [*c]ASN1_STRING) void;
+pub extern fn d2i_ASN1_PRINTABLE(out: [*c][*c]ASN1_STRING, inp: [*c][*c]const u8, len: c_long) [*c]ASN1_STRING;
+pub extern fn i2d_ASN1_PRINTABLE(in: [*c]const ASN1_STRING, outp: [*c][*c]u8) c_int;
+pub extern const ASN1_PRINTABLE_it: ASN1_ITEM;
+pub extern fn DH_new() [*c]DH;
+pub extern fn DH_free(dh: [*c]DH) void;
+pub extern fn DH_up_ref(dh: [*c]DH) c_int;
+pub extern fn DH_get0_pub_key(dh: [*c]const DH) [*c]const BIGNUM;
+pub extern fn DH_get0_priv_key(dh: [*c]const DH) [*c]const BIGNUM;
+pub extern fn DH_get0_p(dh: [*c]const DH) [*c]const BIGNUM;
+pub extern fn DH_get0_q(dh: [*c]const DH) [*c]const BIGNUM;
+pub extern fn DH_get0_g(dh: [*c]const DH) [*c]const BIGNUM;
+pub extern fn DH_get0_key(dh: [*c]const DH, out_pub_key: [*c][*c]const BIGNUM, out_priv_key: [*c][*c]const BIGNUM) void;
+pub extern fn DH_set0_key(dh: [*c]DH, pub_key: [*c]BIGNUM, priv_key: [*c]BIGNUM) c_int;
+pub extern fn DH_get0_pqg(dh: [*c]const DH, out_p: [*c][*c]const BIGNUM, out_q: [*c][*c]const BIGNUM, out_g: [*c][*c]const BIGNUM) void;
+pub extern fn DH_set0_pqg(dh: [*c]DH, p: [*c]BIGNUM, q: [*c]BIGNUM, g: [*c]BIGNUM) c_int;
+pub extern fn DH_set_length(dh: [*c]DH, priv_length: c_uint) c_int;
+pub extern fn BN_get_rfc3526_prime_1536(ret: [*c]BIGNUM) [*c]BIGNUM;
+pub extern fn DH_get_rfc7919_2048() [*c]DH;
+pub extern fn DH_generate_parameters_ex(dh: [*c]DH, prime_bits: c_int, generator: c_int, cb: [*c]BN_GENCB) c_int;
+pub extern fn DH_generate_key(dh: [*c]DH) c_int;
+pub extern fn DH_compute_key_padded(out: [*c]u8, peers_key: [*c]const BIGNUM, dh: [*c]DH) c_int;
+pub extern fn DH_compute_key_hashed(dh: [*c]DH, out: [*c]u8, out_len: [*c]usize, max_out_len: usize, peers_key: [*c]const BIGNUM, digest: ?*const EVP_MD) c_int;
+pub extern fn DH_size(dh: [*c]const DH) c_int;
+pub extern fn DH_num_bits(dh: [*c]const DH) c_uint;
+pub extern fn DH_check(dh: [*c]const DH, out_flags: [*c]c_int) c_int;
+pub extern fn DH_check_pub_key(dh: [*c]const DH, pub_key: [*c]const BIGNUM, out_flags: [*c]c_int) c_int;
+pub extern fn DHparams_dup(dh: [*c]const DH) [*c]DH;
+pub extern fn DH_parse_parameters(cbs: [*c]CBS) [*c]DH;
+pub extern fn DH_marshal_parameters(cbb: [*c]CBB, dh: [*c]const DH) c_int;
+pub extern fn DH_generate_parameters(prime_len: c_int, generator: c_int, callback: ?fn (c_int, c_int, ?*c_void) callconv(.C) void, cb_arg: ?*c_void) [*c]DH;
+pub extern fn d2i_DHparams(ret: [*c][*c]DH, inp: [*c][*c]const u8, len: c_long) [*c]DH;
+pub extern fn i2d_DHparams(in: [*c]const DH, outp: [*c][*c]u8) c_int;
+pub extern fn DH_compute_key(out: [*c]u8, peers_key: [*c]const BIGNUM, dh: [*c]DH) c_int;
+pub extern fn ENGINE_new() ?*ENGINE;
+pub extern fn ENGINE_free(engine: ?*ENGINE) c_int;
+pub extern fn ENGINE_set_RSA_method(engine: ?*ENGINE, method: [*c]const RSA_METHOD, method_size: usize) c_int;
+pub extern fn ENGINE_get_RSA_method(engine: ?*const ENGINE) [*c]RSA_METHOD;
+pub extern fn ENGINE_set_ECDSA_method(engine: ?*ENGINE, method: [*c]const ECDSA_METHOD, method_size: usize) c_int;
+pub extern fn ENGINE_get_ECDSA_method(engine: ?*const ENGINE) [*c]ECDSA_METHOD;
+pub extern fn METHOD_ref(method: ?*c_void) void;
+pub extern fn METHOD_unref(method: ?*c_void) void;
+pub extern fn DSA_new() [*c]DSA;
+pub extern fn DSA_free(dsa: [*c]DSA) void;
+pub extern fn DSA_up_ref(dsa: [*c]DSA) c_int;
+pub extern fn DSA_get0_pub_key(dsa: [*c]const DSA) [*c]const BIGNUM;
+pub extern fn DSA_get0_priv_key(dsa: [*c]const DSA) [*c]const BIGNUM;
+pub extern fn DSA_get0_p(dsa: [*c]const DSA) [*c]const BIGNUM;
+pub extern fn DSA_get0_q(dsa: [*c]const DSA) [*c]const BIGNUM;
+pub extern fn DSA_get0_g(dsa: [*c]const DSA) [*c]const BIGNUM;
+pub extern fn DSA_get0_key(dsa: [*c]const DSA, out_pub_key: [*c][*c]const BIGNUM, out_priv_key: [*c][*c]const BIGNUM) void;
+pub extern fn DSA_get0_pqg(dsa: [*c]const DSA, out_p: [*c][*c]const BIGNUM, out_q: [*c][*c]const BIGNUM, out_g: [*c][*c]const BIGNUM) void;
+pub extern fn DSA_set0_key(dsa: [*c]DSA, pub_key: [*c]BIGNUM, priv_key: [*c]BIGNUM) c_int;
+pub extern fn DSA_set0_pqg(dsa: [*c]DSA, p: [*c]BIGNUM, q: [*c]BIGNUM, g: [*c]BIGNUM) c_int;
+pub extern fn DSA_generate_parameters_ex(dsa: [*c]DSA, bits: c_uint, seed: [*c]const u8, seed_len: usize, out_counter: [*c]c_int, out_h: [*c]c_ulong, cb: [*c]BN_GENCB) c_int;
+pub extern fn DSAparams_dup(dsa: [*c]const DSA) [*c]DSA;
+pub extern fn DSA_generate_key(dsa: [*c]DSA) c_int;
+pub extern fn DSA_SIG_new() [*c]DSA_SIG;
+pub extern fn DSA_SIG_free(sig: [*c]DSA_SIG) void;
+pub extern fn DSA_SIG_get0(sig: [*c]const DSA_SIG, out_r: [*c][*c]const BIGNUM, out_s: [*c][*c]const BIGNUM) void;
+pub extern fn DSA_SIG_set0(sig: [*c]DSA_SIG, r: [*c]BIGNUM, s: [*c]BIGNUM) c_int;
+pub extern fn DSA_do_sign(digest: [*c]const u8, digest_len: usize, dsa: [*c]const DSA) [*c]DSA_SIG;
+pub extern fn DSA_do_verify(digest: [*c]const u8, digest_len: usize, sig: [*c]DSA_SIG, dsa: [*c]const DSA) c_int;
+pub extern fn DSA_do_check_signature(out_valid: [*c]c_int, digest: [*c]const u8, digest_len: usize, sig: [*c]DSA_SIG, dsa: [*c]const DSA) c_int;
+pub extern fn DSA_sign(@"type": c_int, digest: [*c]const u8, digest_len: usize, out_sig: [*c]u8, out_siglen: [*c]c_uint, dsa: [*c]const DSA) c_int;
+pub extern fn DSA_verify(@"type": c_int, digest: [*c]const u8, digest_len: usize, sig: [*c]const u8, sig_len: usize, dsa: [*c]const DSA) c_int;
+pub extern fn DSA_check_signature(out_valid: [*c]c_int, digest: [*c]const u8, digest_len: usize, sig: [*c]const u8, sig_len: usize, dsa: [*c]const DSA) c_int;
+pub extern fn DSA_size(dsa: [*c]const DSA) c_int;
+pub extern fn DSA_SIG_parse(cbs: [*c]CBS) [*c]DSA_SIG;
+pub extern fn DSA_SIG_marshal(cbb: [*c]CBB, sig: [*c]const DSA_SIG) c_int;
+pub extern fn DSA_parse_public_key(cbs: [*c]CBS) [*c]DSA;
+pub extern fn DSA_marshal_public_key(cbb: [*c]CBB, dsa: [*c]const DSA) c_int;
+pub extern fn DSA_parse_private_key(cbs: [*c]CBS) [*c]DSA;
+pub extern fn DSA_marshal_private_key(cbb: [*c]CBB, dsa: [*c]const DSA) c_int;
+pub extern fn DSA_parse_parameters(cbs: [*c]CBS) [*c]DSA;
+pub extern fn DSA_marshal_parameters(cbb: [*c]CBB, dsa: [*c]const DSA) c_int;
+pub extern fn DSA_dup_DH(dsa: [*c]const DSA) [*c]DH;
+pub extern fn DSA_get_ex_new_index(argl: c_long, argp: ?*c_void, unused: [*c]CRYPTO_EX_unused, dup_unused: ?CRYPTO_EX_dup, free_func: ?CRYPTO_EX_free) c_int;
+pub extern fn DSA_set_ex_data(dsa: [*c]DSA, idx: c_int, arg: ?*c_void) c_int;
+pub extern fn DSA_get_ex_data(dsa: [*c]const DSA, idx: c_int) ?*c_void;
+pub extern fn d2i_DSA_SIG(out_sig: [*c][*c]DSA_SIG, inp: [*c][*c]const u8, len: c_long) [*c]DSA_SIG;
+pub extern fn i2d_DSA_SIG(in: [*c]const DSA_SIG, outp: [*c][*c]u8) c_int;
+pub extern fn d2i_DSAPublicKey(out: [*c][*c]DSA, inp: [*c][*c]const u8, len: c_long) [*c]DSA;
+pub extern fn i2d_DSAPublicKey(in: [*c]const DSA, outp: [*c][*c]u8) c_int;
+pub extern fn d2i_DSAPrivateKey(out: [*c][*c]DSA, inp: [*c][*c]const u8, len: c_long) [*c]DSA;
+pub extern fn i2d_DSAPrivateKey(in: [*c]const DSA, outp: [*c][*c]u8) c_int;
+pub extern fn d2i_DSAparams(out: [*c][*c]DSA, inp: [*c][*c]const u8, len: c_long) [*c]DSA;
+pub extern fn i2d_DSAparams(in: [*c]const DSA, outp: [*c][*c]u8) c_int;
+pub extern fn DSA_generate_parameters(bits: c_int, seed: [*c]u8, seed_len: c_int, counter_ret: [*c]c_int, h_ret: [*c]c_ulong, callback: ?fn (c_int, c_int, ?*c_void) callconv(.C) void, cb_arg: ?*c_void) [*c]DSA;
+pub const POINT_CONVERSION_COMPRESSED: c_int = 2;
+pub const POINT_CONVERSION_UNCOMPRESSED: c_int = 4;
+pub const POINT_CONVERSION_HYBRID: c_int = 6;
+pub const point_conversion_form_t = c_uint;
+pub extern fn EC_GROUP_new_by_curve_name(nid: c_int) ?*EC_GROUP;
+pub extern fn EC_GROUP_free(group: ?*EC_GROUP) void;
+pub extern fn EC_GROUP_dup(a: ?*const EC_GROUP) ?*EC_GROUP;
+pub extern fn EC_GROUP_cmp(a: ?*const EC_GROUP, b: ?*const EC_GROUP, ignored: ?*BN_CTX) c_int;
+pub extern fn EC_GROUP_get0_generator(group: ?*const EC_GROUP) ?*const EC_POINT;
+pub extern fn EC_GROUP_get0_order(group: ?*const EC_GROUP) [*c]const BIGNUM;
+pub extern fn EC_GROUP_order_bits(group: ?*const EC_GROUP) c_int;
+pub extern fn EC_GROUP_get_cofactor(group: ?*const EC_GROUP, cofactor: [*c]BIGNUM, ctx: ?*BN_CTX) c_int;
+pub extern fn EC_GROUP_get_curve_GFp(group: ?*const EC_GROUP, out_p: [*c]BIGNUM, out_a: [*c]BIGNUM, out_b: [*c]BIGNUM, ctx: ?*BN_CTX) c_int;
+pub extern fn EC_GROUP_get_curve_name(group: ?*const EC_GROUP) c_int;
+pub extern fn EC_GROUP_get_degree(group: ?*const EC_GROUP) c_uint;
+pub extern fn EC_curve_nid2nist(nid: c_int) [*c]const u8;
+pub extern fn EC_curve_nist2nid(name: [*c]const u8) c_int;
+pub extern fn EC_POINT_new(group: ?*const EC_GROUP) ?*EC_POINT;
+pub extern fn EC_POINT_free(point: ?*EC_POINT) void;
+pub extern fn EC_POINT_copy(dest: ?*EC_POINT, src: ?*const EC_POINT) c_int;
+pub extern fn EC_POINT_dup(src: ?*const EC_POINT, group: ?*const EC_GROUP) ?*EC_POINT;
+pub extern fn EC_POINT_set_to_infinity(group: ?*const EC_GROUP, point: ?*EC_POINT) c_int;
+pub extern fn EC_POINT_is_at_infinity(group: ?*const EC_GROUP, point: ?*const EC_POINT) c_int;
+pub extern fn EC_POINT_is_on_curve(group: ?*const EC_GROUP, point: ?*const EC_POINT, ctx: ?*BN_CTX) c_int;
+pub extern fn EC_POINT_cmp(group: ?*const EC_GROUP, a: ?*const EC_POINT, b: ?*const EC_POINT, ctx: ?*BN_CTX) c_int;
+pub extern fn EC_POINT_get_affine_coordinates_GFp(group: ?*const EC_GROUP, point: ?*const EC_POINT, x: [*c]BIGNUM, y: [*c]BIGNUM, ctx: ?*BN_CTX) c_int;
+pub extern fn EC_POINT_get_affine_coordinates(group: ?*const EC_GROUP, point: ?*const EC_POINT, x: [*c]BIGNUM, y: [*c]BIGNUM, ctx: ?*BN_CTX) c_int;
+pub extern fn EC_POINT_set_affine_coordinates_GFp(group: ?*const EC_GROUP, point: ?*EC_POINT, x: [*c]const BIGNUM, y: [*c]const BIGNUM, ctx: ?*BN_CTX) c_int;
+pub extern fn EC_POINT_set_affine_coordinates(group: ?*const EC_GROUP, point: ?*EC_POINT, x: [*c]const BIGNUM, y: [*c]const BIGNUM, ctx: ?*BN_CTX) c_int;
+pub extern fn EC_POINT_point2oct(group: ?*const EC_GROUP, point: ?*const EC_POINT, form: point_conversion_form_t, buf: [*c]u8, len: usize, ctx: ?*BN_CTX) usize;
+pub extern fn EC_POINT_point2cbb(out: [*c]CBB, group: ?*const EC_GROUP, point: ?*const EC_POINT, form: point_conversion_form_t, ctx: ?*BN_CTX) c_int;
+pub extern fn EC_POINT_oct2point(group: ?*const EC_GROUP, point: ?*EC_POINT, buf: [*c]const u8, len: usize, ctx: ?*BN_CTX) c_int;
+pub extern fn EC_POINT_set_compressed_coordinates_GFp(group: ?*const EC_GROUP, point: ?*EC_POINT, x: [*c]const BIGNUM, y_bit: c_int, ctx: ?*BN_CTX) c_int;
+pub extern fn EC_POINT_add(group: ?*const EC_GROUP, r: ?*EC_POINT, a: ?*const EC_POINT, b: ?*const EC_POINT, ctx: ?*BN_CTX) c_int;
+pub extern fn EC_POINT_dbl(group: ?*const EC_GROUP, r: ?*EC_POINT, a: ?*const EC_POINT, ctx: ?*BN_CTX) c_int;
+pub extern fn EC_POINT_invert(group: ?*const EC_GROUP, a: ?*EC_POINT, ctx: ?*BN_CTX) c_int;
+pub extern fn EC_POINT_mul(group: ?*const EC_GROUP, r: ?*EC_POINT, n: [*c]const BIGNUM, q: ?*const EC_POINT, m: [*c]const BIGNUM, ctx: ?*BN_CTX) c_int;
+pub extern fn EC_GROUP_new_curve_GFp(p: [*c]const BIGNUM, a: [*c]const BIGNUM, b: [*c]const BIGNUM, ctx: ?*BN_CTX) ?*EC_GROUP;
+pub extern fn EC_GROUP_set_generator(group: ?*EC_GROUP, generator: ?*const EC_POINT, order: [*c]const BIGNUM, cofactor: [*c]const BIGNUM) c_int;
+pub extern fn EC_GROUP_get_order(group: ?*const EC_GROUP, order: [*c]BIGNUM, ctx: ?*BN_CTX) c_int;
+pub extern fn EC_GROUP_set_asn1_flag(group: ?*EC_GROUP, flag: c_int) void;
+pub extern fn EC_GROUP_get_asn1_flag(group: ?*const EC_GROUP) c_int;
+pub const struct_ec_method_st = opaque {};
+pub const EC_METHOD = struct_ec_method_st;
+pub extern fn EC_GROUP_method_of(group: ?*const EC_GROUP) ?*const EC_METHOD;
+pub extern fn EC_METHOD_get_field_type(meth: ?*const EC_METHOD) c_int;
+pub extern fn EC_GROUP_set_point_conversion_form(group: ?*EC_GROUP, form: point_conversion_form_t) void;
+pub const EC_builtin_curve = extern struct {
+ nid: c_int,
+ comment: [*c]const u8,
+};
+pub extern fn EC_get_builtin_curves(out_curves: [*c]EC_builtin_curve, max_num_curves: usize) usize;
+pub extern fn EC_POINT_clear_free(point: ?*EC_POINT) void;
+pub extern fn EC_KEY_new() ?*EC_KEY;
+pub extern fn EC_KEY_new_method(engine: ?*const ENGINE) ?*EC_KEY;
+pub extern fn EC_KEY_new_by_curve_name(nid: c_int) ?*EC_KEY;
+pub extern fn EC_KEY_free(key: ?*EC_KEY) void;
+pub extern fn EC_KEY_dup(src: ?*const EC_KEY) ?*EC_KEY;
+pub extern fn EC_KEY_up_ref(key: ?*EC_KEY) c_int;
+pub extern fn EC_KEY_is_opaque(key: ?*const EC_KEY) c_int;
+pub extern fn EC_KEY_get0_group(key: ?*const EC_KEY) ?*const EC_GROUP;
+pub extern fn EC_KEY_set_group(key: ?*EC_KEY, group: ?*const EC_GROUP) c_int;
+pub extern fn EC_KEY_get0_private_key(key: ?*const EC_KEY) [*c]const BIGNUM;
+pub extern fn EC_KEY_set_private_key(key: ?*EC_KEY, priv: [*c]const BIGNUM) c_int;
+pub extern fn EC_KEY_get0_public_key(key: ?*const EC_KEY) ?*const EC_POINT;
+pub extern fn EC_KEY_set_public_key(key: ?*EC_KEY, @"pub": ?*const EC_POINT) c_int;
+pub extern fn EC_KEY_get_enc_flags(key: ?*const EC_KEY) c_uint;
+pub extern fn EC_KEY_set_enc_flags(key: ?*EC_KEY, flags: c_uint) void;
+pub extern fn EC_KEY_get_conv_form(key: ?*const EC_KEY) point_conversion_form_t;
+pub extern fn EC_KEY_set_conv_form(key: ?*EC_KEY, cform: point_conversion_form_t) void;
+pub extern fn EC_KEY_check_key(key: ?*const EC_KEY) c_int;
+pub extern fn EC_KEY_check_fips(key: ?*const EC_KEY) c_int;
+pub extern fn EC_KEY_set_public_key_affine_coordinates(key: ?*EC_KEY, x: [*c]const BIGNUM, y: [*c]const BIGNUM) c_int;
+pub extern fn EC_KEY_key2buf(key: ?*const EC_KEY, form: point_conversion_form_t, out_buf: [*c][*c]u8, ctx: ?*BN_CTX) usize;
+pub extern fn EC_KEY_generate_key(key: ?*EC_KEY) c_int;
+pub extern fn EC_KEY_generate_key_fips(key: ?*EC_KEY) c_int;
+pub extern fn EC_KEY_derive_from_secret(group: ?*const EC_GROUP, secret: [*c]const u8, secret_len: usize) ?*EC_KEY;
+pub extern fn EC_KEY_parse_private_key(cbs: [*c]CBS, group: ?*const EC_GROUP) ?*EC_KEY;
+pub extern fn EC_KEY_marshal_private_key(cbb: [*c]CBB, key: ?*const EC_KEY, enc_flags: c_uint) c_int;
+pub extern fn EC_KEY_parse_curve_name(cbs: [*c]CBS) ?*EC_GROUP;
+pub extern fn EC_KEY_marshal_curve_name(cbb: [*c]CBB, group: ?*const EC_GROUP) c_int;
+pub extern fn EC_KEY_parse_parameters(cbs: [*c]CBS) ?*EC_GROUP;
+pub extern fn EC_KEY_get_ex_new_index(argl: c_long, argp: ?*c_void, unused: [*c]CRYPTO_EX_unused, dup_unused: ?CRYPTO_EX_dup, free_func: ?CRYPTO_EX_free) c_int;
+pub extern fn EC_KEY_set_ex_data(r: ?*EC_KEY, idx: c_int, arg: ?*c_void) c_int;
+pub extern fn EC_KEY_get_ex_data(r: ?*const EC_KEY, idx: c_int) ?*c_void;
+pub extern fn EC_KEY_set_asn1_flag(key: ?*EC_KEY, flag: c_int) void;
+pub extern fn d2i_ECPrivateKey(out_key: [*c]?*EC_KEY, inp: [*c][*c]const u8, len: c_long) ?*EC_KEY;
+pub extern fn i2d_ECPrivateKey(key: ?*const EC_KEY, outp: [*c][*c]u8) c_int;
+pub extern fn d2i_ECParameters(out_key: [*c]?*EC_KEY, inp: [*c][*c]const u8, len: c_long) ?*EC_KEY;
+pub extern fn i2d_ECParameters(key: ?*const EC_KEY, outp: [*c][*c]u8) c_int;
+pub extern fn o2i_ECPublicKey(out_key: [*c]?*EC_KEY, inp: [*c][*c]const u8, len: c_long) ?*EC_KEY;
+pub extern fn i2o_ECPublicKey(key: ?*const EC_KEY, outp: [*c][*c]u8) c_int;
+pub extern fn ECDH_compute_key(out: ?*c_void, outlen: usize, pub_key: ?*const EC_POINT, priv_key: ?*const EC_KEY, kdf: ?fn (?*const c_void, usize, ?*c_void, [*c]usize) callconv(.C) ?*c_void) c_int;
+pub extern fn ECDH_compute_key_fips(out: [*c]u8, out_len: usize, pub_key: ?*const EC_POINT, priv_key: ?*const EC_KEY) c_int;
+pub extern fn ECDSA_sign(@"type": c_int, digest: [*c]const u8, digest_len: usize, sig: [*c]u8, sig_len: [*c]c_uint, key: ?*const EC_KEY) c_int;
+pub extern fn ECDSA_verify(@"type": c_int, digest: [*c]const u8, digest_len: usize, sig: [*c]const u8, sig_len: usize, key: ?*const EC_KEY) c_int;
+pub extern fn ECDSA_size(key: ?*const EC_KEY) usize;
+pub extern fn ECDSA_SIG_new() [*c]ECDSA_SIG;
+pub extern fn ECDSA_SIG_free(sig: [*c]ECDSA_SIG) void;
+pub extern fn ECDSA_SIG_get0_r(sig: [*c]const ECDSA_SIG) [*c]const BIGNUM;
+pub extern fn ECDSA_SIG_get0_s(sig: [*c]const ECDSA_SIG) [*c]const BIGNUM;
+pub extern fn ECDSA_SIG_get0(sig: [*c]const ECDSA_SIG, out_r: [*c][*c]const BIGNUM, out_s: [*c][*c]const BIGNUM) void;
+pub extern fn ECDSA_SIG_set0(sig: [*c]ECDSA_SIG, r: [*c]BIGNUM, s: [*c]BIGNUM) c_int;
+pub extern fn ECDSA_do_sign(digest: [*c]const u8, digest_len: usize, key: ?*const EC_KEY) [*c]ECDSA_SIG;
+pub extern fn ECDSA_do_verify(digest: [*c]const u8, digest_len: usize, sig: [*c]const ECDSA_SIG, key: ?*const EC_KEY) c_int;
+pub extern fn ECDSA_SIG_parse(cbs: [*c]CBS) [*c]ECDSA_SIG;
+pub extern fn ECDSA_SIG_from_bytes(in: [*c]const u8, in_len: usize) [*c]ECDSA_SIG;
+pub extern fn ECDSA_SIG_marshal(cbb: [*c]CBB, sig: [*c]const ECDSA_SIG) c_int;
+pub extern fn ECDSA_SIG_to_bytes(out_bytes: [*c][*c]u8, out_len: [*c]usize, sig: [*c]const ECDSA_SIG) c_int;
+pub extern fn ECDSA_SIG_max_len(order_len: usize) usize;
+pub extern fn ECDSA_sign_with_nonce_and_leak_private_key_for_testing(digest: [*c]const u8, digest_len: usize, eckey: ?*const EC_KEY, nonce: [*c]const u8, nonce_len: usize) [*c]ECDSA_SIG;
+pub extern fn d2i_ECDSA_SIG(out: [*c][*c]ECDSA_SIG, inp: [*c][*c]const u8, len: c_long) [*c]ECDSA_SIG;
+pub extern fn i2d_ECDSA_SIG(sig: [*c]const ECDSA_SIG, outp: [*c][*c]u8) c_int;
+pub extern fn CBS_init(cbs: [*c]CBS, data: [*c]const u8, len: usize) void;
+pub extern fn CBS_skip(cbs: [*c]CBS, len: usize) c_int;
+pub extern fn CBS_data(cbs: [*c]const CBS) [*c]const u8;
+pub extern fn CBS_len(cbs: [*c]const CBS) usize;
+pub extern fn CBS_stow(cbs: [*c]const CBS, out_ptr: [*c][*c]u8, out_len: [*c]usize) c_int;
+pub extern fn CBS_strdup(cbs: [*c]const CBS, out_ptr: [*c][*c]u8) c_int;
+pub extern fn CBS_contains_zero_byte(cbs: [*c]const CBS) c_int;
+pub extern fn CBS_mem_equal(cbs: [*c]const CBS, data: [*c]const u8, len: usize) c_int;
+pub extern fn CBS_get_u8(cbs: [*c]CBS, out: [*c]u8) c_int;
+pub extern fn CBS_get_u16(cbs: [*c]CBS, out: [*c]u16) c_int;
+pub extern fn CBS_get_u16le(cbs: [*c]CBS, out: [*c]u16) c_int;
+pub extern fn CBS_get_u24(cbs: [*c]CBS, out: [*c]u32) c_int;
+pub extern fn CBS_get_u32(cbs: [*c]CBS, out: [*c]u32) c_int;
+pub extern fn CBS_get_u32le(cbs: [*c]CBS, out: [*c]u32) c_int;
+pub extern fn CBS_get_u64(cbs: [*c]CBS, out: [*c]u64) c_int;
+pub extern fn CBS_get_u64le(cbs: [*c]CBS, out: [*c]u64) c_int;
+pub extern fn CBS_get_last_u8(cbs: [*c]CBS, out: [*c]u8) c_int;
+pub extern fn CBS_get_bytes(cbs: [*c]CBS, out: [*c]CBS, len: usize) c_int;
+pub extern fn CBS_copy_bytes(cbs: [*c]CBS, out: [*c]u8, len: usize) c_int;
+pub extern fn CBS_get_u8_length_prefixed(cbs: [*c]CBS, out: [*c]CBS) c_int;
+pub extern fn CBS_get_u16_length_prefixed(cbs: [*c]CBS, out: [*c]CBS) c_int;
+pub extern fn CBS_get_u24_length_prefixed(cbs: [*c]CBS, out: [*c]CBS) c_int;
+pub extern fn CBS_get_until_first(cbs: [*c]CBS, out: [*c]CBS, c: u8) c_int;
+pub extern fn CBS_get_asn1(cbs: [*c]CBS, out: [*c]CBS, tag_value: c_uint) c_int;
+pub extern fn CBS_get_asn1_element(cbs: [*c]CBS, out: [*c]CBS, tag_value: c_uint) c_int;
+pub extern fn CBS_peek_asn1_tag(cbs: [*c]const CBS, tag_value: c_uint) c_int;
+pub extern fn CBS_get_any_asn1(cbs: [*c]CBS, out: [*c]CBS, out_tag: [*c]c_uint) c_int;
+pub extern fn CBS_get_any_asn1_element(cbs: [*c]CBS, out: [*c]CBS, out_tag: [*c]c_uint, out_header_len: [*c]usize) c_int;
+pub extern fn CBS_get_any_ber_asn1_element(cbs: [*c]CBS, out: [*c]CBS, out_tag: [*c]c_uint, out_header_len: [*c]usize, out_ber_found: [*c]c_int) c_int;
+pub extern fn CBS_get_asn1_uint64(cbs: [*c]CBS, out: [*c]u64) c_int;
+pub extern fn CBS_get_asn1_int64(cbs: [*c]CBS, out: [*c]i64) c_int;
+pub extern fn CBS_get_asn1_bool(cbs: [*c]CBS, out: [*c]c_int) c_int;
+pub extern fn CBS_get_optional_asn1(cbs: [*c]CBS, out: [*c]CBS, out_present: [*c]c_int, tag: c_uint) c_int;
+pub extern fn CBS_get_optional_asn1_octet_string(cbs: [*c]CBS, out: [*c]CBS, out_present: [*c]c_int, tag: c_uint) c_int;
+pub extern fn CBS_get_optional_asn1_uint64(cbs: [*c]CBS, out: [*c]u64, tag: c_uint, default_value: u64) c_int;
+pub extern fn CBS_get_optional_asn1_bool(cbs: [*c]CBS, out: [*c]c_int, tag: c_uint, default_value: c_int) c_int;
+pub extern fn CBS_is_valid_asn1_bitstring(cbs: [*c]const CBS) c_int;
+pub extern fn CBS_asn1_bitstring_has_bit(cbs: [*c]const CBS, bit: c_uint) c_int;
+pub extern fn CBS_is_valid_asn1_integer(cbs: [*c]const CBS, out_is_negative: [*c]c_int) c_int;
+pub extern fn CBS_is_unsigned_asn1_integer(cbs: [*c]const CBS) c_int;
+pub extern fn CBS_asn1_oid_to_text(cbs: [*c]const CBS) [*c]u8;
+pub extern fn CBB_zero(cbb: [*c]CBB) void;
+pub extern fn CBB_init(cbb: [*c]CBB, initial_capacity: usize) c_int;
+pub extern fn CBB_init_fixed(cbb: [*c]CBB, buf: [*c]u8, len: usize) c_int;
+pub extern fn CBB_cleanup(cbb: [*c]CBB) void;
+pub extern fn CBB_finish(cbb: [*c]CBB, out_data: [*c][*c]u8, out_len: [*c]usize) c_int;
+pub extern fn CBB_flush(cbb: [*c]CBB) c_int;
+pub extern fn CBB_data(cbb: [*c]const CBB) [*c]const u8;
+pub extern fn CBB_len(cbb: [*c]const CBB) usize;
+pub extern fn CBB_add_u8_length_prefixed(cbb: [*c]CBB, out_contents: [*c]CBB) c_int;
+pub extern fn CBB_add_u16_length_prefixed(cbb: [*c]CBB, out_contents: [*c]CBB) c_int;
+pub extern fn CBB_add_u24_length_prefixed(cbb: [*c]CBB, out_contents: [*c]CBB) c_int;
+pub extern fn CBB_add_asn1(cbb: [*c]CBB, out_contents: [*c]CBB, tag: c_uint) c_int;
+pub extern fn CBB_add_bytes(cbb: [*c]CBB, data: [*c]const u8, len: usize) c_int;
+pub extern fn CBB_add_zeros(cbb: [*c]CBB, len: usize) c_int;
+pub extern fn CBB_add_space(cbb: [*c]CBB, out_data: [*c][*c]u8, len: usize) c_int;
+pub extern fn CBB_reserve(cbb: [*c]CBB, out_data: [*c][*c]u8, len: usize) c_int;
+pub extern fn CBB_did_write(cbb: [*c]CBB, len: usize) c_int;
+pub extern fn CBB_add_u8(cbb: [*c]CBB, value: u8) c_int;
+pub extern fn CBB_add_u16(cbb: [*c]CBB, value: u16) c_int;
+pub extern fn CBB_add_u16le(cbb: [*c]CBB, value: u16) c_int;
+pub extern fn CBB_add_u24(cbb: [*c]CBB, value: u32) c_int;
+pub extern fn CBB_add_u32(cbb: [*c]CBB, value: u32) c_int;
+pub extern fn CBB_add_u32le(cbb: [*c]CBB, value: u32) c_int;
+pub extern fn CBB_add_u64(cbb: [*c]CBB, value: u64) c_int;
+pub extern fn CBB_add_u64le(cbb: [*c]CBB, value: u64) c_int;
+pub extern fn CBB_discard_child(cbb: [*c]CBB) void;
+pub extern fn CBB_add_asn1_uint64(cbb: [*c]CBB, value: u64) c_int;
+pub extern fn CBB_add_asn1_int64(cbb: [*c]CBB, value: i64) c_int;
+pub extern fn CBB_add_asn1_octet_string(cbb: [*c]CBB, data: [*c]const u8, data_len: usize) c_int;
+pub extern fn CBB_add_asn1_bool(cbb: [*c]CBB, value: c_int) c_int;
+pub extern fn CBB_add_asn1_oid_from_text(cbb: [*c]CBB, text: [*c]const u8, len: usize) c_int;
+pub extern fn CBB_flush_asn1_set_of(cbb: [*c]CBB) c_int;
+pub extern fn OBJ_dup(obj: ?*const ASN1_OBJECT) ?*ASN1_OBJECT;
+pub extern fn OBJ_cmp(a: ?*const ASN1_OBJECT, b: ?*const ASN1_OBJECT) c_int;
+pub extern fn OBJ_get0_data(obj: ?*const ASN1_OBJECT) [*c]const u8;
+pub extern fn OBJ_length(obj: ?*const ASN1_OBJECT) usize;
+pub extern fn OBJ_obj2nid(obj: ?*const ASN1_OBJECT) c_int;
+pub extern fn OBJ_cbs2nid(cbs: [*c]const CBS) c_int;
+pub extern fn OBJ_sn2nid(short_name: [*c]const u8) c_int;
+pub extern fn OBJ_ln2nid(long_name: [*c]const u8) c_int;
+pub extern fn OBJ_txt2nid(s: [*c]const u8) c_int;
+pub extern fn OBJ_nid2obj(nid: c_int) ?*ASN1_OBJECT;
+pub extern fn OBJ_nid2sn(nid: c_int) [*c]const u8;
+pub extern fn OBJ_nid2ln(nid: c_int) [*c]const u8;
+pub extern fn OBJ_nid2cbb(out: [*c]CBB, nid: c_int) c_int;
+pub extern fn OBJ_txt2obj(s: [*c]const u8, dont_search_names: c_int) ?*ASN1_OBJECT;
+pub extern fn OBJ_obj2txt(out: [*c]u8, out_len: c_int, obj: ?*const ASN1_OBJECT, always_return_oid: c_int) c_int;
+pub extern fn OBJ_create(oid: [*c]const u8, short_name: [*c]const u8, long_name: [*c]const u8) c_int;
+pub extern fn OBJ_find_sigid_algs(sign_nid: c_int, out_digest_nid: [*c]c_int, out_pkey_nid: [*c]c_int) c_int;
+pub extern fn OBJ_find_sigid_by_algs(out_sign_nid: [*c]c_int, digest_nid: c_int, pkey_nid: c_int) c_int;
+pub const struct_obj_name_st = extern struct {
+ type: c_int,
+ alias: c_int,
+ name: [*c]const u8,
+ data: [*c]const u8,
+};
+pub const OBJ_NAME = struct_obj_name_st;
+pub extern fn OBJ_NAME_do_all_sorted(@"type": c_int, callback: ?fn ([*c]const OBJ_NAME, ?*c_void) callconv(.C) void, arg: ?*c_void) void;
+pub extern fn OBJ_NAME_do_all(@"type": c_int, callback: ?fn ([*c]const OBJ_NAME, ?*c_void) callconv(.C) void, arg: ?*c_void) void;
+pub extern fn OBJ_cleanup() void;
+pub const stack_CRYPTO_BUFFER_free_func = ?fn (?*CRYPTO_BUFFER) callconv(.C) void;
+pub const stack_CRYPTO_BUFFER_copy_func = ?fn (?*CRYPTO_BUFFER) callconv(.C) ?*CRYPTO_BUFFER;
+pub const stack_CRYPTO_BUFFER_cmp_func = ?fn ([*c]?*const CRYPTO_BUFFER, [*c]?*const CRYPTO_BUFFER) callconv(.C) c_int;
+pub fn sk_CRYPTO_BUFFER_call_free_func(arg_free_func: stack_free_func, arg_ptr: ?*c_void) callconv(.C) void {
+ var free_func = arg_free_func;
+ var ptr = arg_ptr;
+ @ptrCast(stack_CRYPTO_BUFFER_free_func, @alignCast(@import("std").meta.alignment(fn (?*CRYPTO_BUFFER) callconv(.C) void), free_func)).?(@ptrCast(?*CRYPTO_BUFFER, ptr));
+}
+pub fn sk_CRYPTO_BUFFER_call_copy_func(arg_copy_func: stack_copy_func, arg_ptr: ?*c_void) callconv(.C) ?*c_void {
+ var copy_func = arg_copy_func;
+ var ptr = arg_ptr;
+ return @ptrCast(?*c_void, @ptrCast(stack_CRYPTO_BUFFER_copy_func, @alignCast(@import("std").meta.alignment(fn (?*CRYPTO_BUFFER) callconv(.C) ?*CRYPTO_BUFFER), copy_func)).?(@ptrCast(?*CRYPTO_BUFFER, ptr)));
+}
+pub fn sk_CRYPTO_BUFFER_call_cmp_func(arg_cmp_func: stack_cmp_func, arg_a: [*c]?*const c_void, arg_b: [*c]?*const c_void) callconv(.C) c_int {
+ var cmp_func = arg_cmp_func;
+ var a = arg_a;
+ var b = arg_b;
+ var a_ptr: ?*const CRYPTO_BUFFER = @ptrCast(?*const CRYPTO_BUFFER, a.*);
+ var b_ptr: ?*const CRYPTO_BUFFER = @ptrCast(?*const CRYPTO_BUFFER, b.*);
+ return @ptrCast(stack_CRYPTO_BUFFER_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const CRYPTO_BUFFER, [*c]?*const CRYPTO_BUFFER) callconv(.C) c_int), cmp_func)).?(&a_ptr, &b_ptr);
+}
+pub fn sk_CRYPTO_BUFFER_new(arg_comp: stack_CRYPTO_BUFFER_cmp_func) callconv(.C) ?*struct_stack_st_CRYPTO_BUFFER {
+ var comp = arg_comp;
+ return @ptrCast(?*struct_stack_st_CRYPTO_BUFFER, sk_new(@ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp))));
+}
+pub fn sk_CRYPTO_BUFFER_new_null() callconv(.C) ?*struct_stack_st_CRYPTO_BUFFER {
+ return @ptrCast(?*struct_stack_st_CRYPTO_BUFFER, sk_new_null());
+}
+pub fn sk_CRYPTO_BUFFER_num(arg_sk: ?*const struct_stack_st_CRYPTO_BUFFER) callconv(.C) usize {
+ var sk = arg_sk;
+ return sk_num(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_CRYPTO_BUFFER_zero(arg_sk: ?*struct_stack_st_CRYPTO_BUFFER) callconv(.C) void {
+ var sk = arg_sk;
+ sk_zero(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_CRYPTO_BUFFER_value(arg_sk: ?*const struct_stack_st_CRYPTO_BUFFER, arg_i: usize) callconv(.C) ?*CRYPTO_BUFFER {
+ var sk = arg_sk;
+ var i = arg_i;
+ return @ptrCast(?*CRYPTO_BUFFER, sk_value(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i));
+}
+pub fn sk_CRYPTO_BUFFER_set(arg_sk: ?*struct_stack_st_CRYPTO_BUFFER, arg_i: usize, arg_p: ?*CRYPTO_BUFFER) callconv(.C) ?*CRYPTO_BUFFER {
+ var sk = arg_sk;
+ var i = arg_i;
+ var p = arg_p;
+ return @ptrCast(?*CRYPTO_BUFFER, sk_set(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i, @ptrCast(?*c_void, p)));
+}
+pub fn sk_CRYPTO_BUFFER_free(arg_sk: ?*struct_stack_st_CRYPTO_BUFFER) callconv(.C) void {
+ var sk = arg_sk;
+ sk_free(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_CRYPTO_BUFFER_pop_free(arg_sk: ?*struct_stack_st_CRYPTO_BUFFER, arg_free_func: stack_CRYPTO_BUFFER_free_func) callconv(.C) void {
+ var sk = arg_sk;
+ var free_func = arg_free_func;
+ sk_pop_free_ex(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_CRYPTO_BUFFER_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func)));
+}
+pub fn sk_CRYPTO_BUFFER_insert(arg_sk: ?*struct_stack_st_CRYPTO_BUFFER, arg_p: ?*CRYPTO_BUFFER, arg_where: usize) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ var where = arg_where;
+ return sk_insert(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p), where);
+}
+pub fn sk_CRYPTO_BUFFER_delete(arg_sk: ?*struct_stack_st_CRYPTO_BUFFER, arg_where: usize) callconv(.C) ?*CRYPTO_BUFFER {
+ var sk = arg_sk;
+ var where = arg_where;
+ return @ptrCast(?*CRYPTO_BUFFER, sk_delete(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), where));
+}
+pub fn sk_CRYPTO_BUFFER_delete_ptr(arg_sk: ?*struct_stack_st_CRYPTO_BUFFER, arg_p: ?*const CRYPTO_BUFFER) callconv(.C) ?*CRYPTO_BUFFER {
+ var sk = arg_sk;
+ var p = arg_p;
+ return @ptrCast(?*CRYPTO_BUFFER, sk_delete_ptr(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*const c_void, p)));
+}
+pub fn sk_CRYPTO_BUFFER_find(arg_sk: ?*const struct_stack_st_CRYPTO_BUFFER, arg_out_index: [*c]usize, arg_p: ?*const CRYPTO_BUFFER) callconv(.C) c_int {
+ var sk = arg_sk;
+ var out_index = arg_out_index;
+ var p = arg_p;
+ return sk_find(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), out_index, @ptrCast(?*const c_void, p), sk_CRYPTO_BUFFER_call_cmp_func);
+}
+pub fn sk_CRYPTO_BUFFER_shift(arg_sk: ?*struct_stack_st_CRYPTO_BUFFER) callconv(.C) ?*CRYPTO_BUFFER {
+ var sk = arg_sk;
+ return @ptrCast(?*CRYPTO_BUFFER, sk_shift(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_CRYPTO_BUFFER_push(arg_sk: ?*struct_stack_st_CRYPTO_BUFFER, arg_p: ?*CRYPTO_BUFFER) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ return sk_push(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p));
+}
+pub fn sk_CRYPTO_BUFFER_pop(arg_sk: ?*struct_stack_st_CRYPTO_BUFFER) callconv(.C) ?*CRYPTO_BUFFER {
+ var sk = arg_sk;
+ return @ptrCast(?*CRYPTO_BUFFER, sk_pop(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_CRYPTO_BUFFER_dup(arg_sk: ?*const struct_stack_st_CRYPTO_BUFFER) callconv(.C) ?*struct_stack_st_CRYPTO_BUFFER {
+ var sk = arg_sk;
+ return @ptrCast(?*struct_stack_st_CRYPTO_BUFFER, sk_dup(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_CRYPTO_BUFFER_sort(arg_sk: ?*struct_stack_st_CRYPTO_BUFFER) callconv(.C) void {
+ var sk = arg_sk;
+ sk_sort(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_CRYPTO_BUFFER_is_sorted(arg_sk: ?*const struct_stack_st_CRYPTO_BUFFER) callconv(.C) c_int {
+ var sk = arg_sk;
+ return sk_is_sorted(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_CRYPTO_BUFFER_set_cmp_func(arg_sk: ?*struct_stack_st_CRYPTO_BUFFER, arg_comp: stack_CRYPTO_BUFFER_cmp_func) callconv(.C) stack_CRYPTO_BUFFER_cmp_func {
+ var sk = arg_sk;
+ var comp = arg_comp;
+ return @ptrCast(stack_CRYPTO_BUFFER_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const CRYPTO_BUFFER, [*c]?*const CRYPTO_BUFFER) callconv(.C) c_int), sk_set_cmp_func(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp)))));
+}
+pub fn sk_CRYPTO_BUFFER_deep_copy(arg_sk: ?*const struct_stack_st_CRYPTO_BUFFER, arg_copy_func: ?fn (?*CRYPTO_BUFFER) callconv(.C) ?*CRYPTO_BUFFER, arg_free_func: ?fn (?*CRYPTO_BUFFER) callconv(.C) void) callconv(.C) ?*struct_stack_st_CRYPTO_BUFFER {
+ var sk = arg_sk;
+ var copy_func = arg_copy_func;
+ var free_func = arg_free_func;
+ return @ptrCast(?*struct_stack_st_CRYPTO_BUFFER, sk_deep_copy(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_CRYPTO_BUFFER_call_copy_func, @ptrCast(stack_copy_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) ?*c_void), copy_func)), sk_CRYPTO_BUFFER_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func))));
+}
+pub extern fn CRYPTO_BUFFER_POOL_new() ?*CRYPTO_BUFFER_POOL;
+pub extern fn CRYPTO_BUFFER_POOL_free(pool: ?*CRYPTO_BUFFER_POOL) void;
+pub extern fn CRYPTO_BUFFER_new(data: [*c]const u8, len: usize, pool: ?*CRYPTO_BUFFER_POOL) ?*CRYPTO_BUFFER;
+pub extern fn CRYPTO_BUFFER_alloc(out_data: [*c][*c]u8, len: usize) ?*CRYPTO_BUFFER;
+pub extern fn CRYPTO_BUFFER_new_from_CBS(cbs: [*c]const CBS, pool: ?*CRYPTO_BUFFER_POOL) ?*CRYPTO_BUFFER;
+pub extern fn CRYPTO_BUFFER_new_from_static_data_unsafe(data: [*c]const u8, len: usize, pool: ?*CRYPTO_BUFFER_POOL) ?*CRYPTO_BUFFER;
+pub extern fn CRYPTO_BUFFER_free(buf: ?*CRYPTO_BUFFER) void;
+pub extern fn CRYPTO_BUFFER_up_ref(buf: ?*CRYPTO_BUFFER) c_int;
+pub extern fn CRYPTO_BUFFER_data(buf: ?*const CRYPTO_BUFFER) [*c]const u8;
+pub extern fn CRYPTO_BUFFER_len(buf: ?*const CRYPTO_BUFFER) usize;
+pub extern fn CRYPTO_BUFFER_init_CBS(buf: ?*const CRYPTO_BUFFER, out: [*c]CBS) void;
+pub extern fn RSA_new() ?*RSA;
+pub extern fn RSA_new_method(engine: ?*const ENGINE) ?*RSA;
+pub extern fn RSA_free(rsa: ?*RSA) void;
+pub extern fn RSA_up_ref(rsa: ?*RSA) c_int;
+pub extern fn RSA_bits(rsa: ?*const RSA) c_uint;
+pub extern fn RSA_get0_n(rsa: ?*const RSA) [*c]const BIGNUM;
+pub extern fn RSA_get0_e(rsa: ?*const RSA) [*c]const BIGNUM;
+pub extern fn RSA_get0_d(rsa: ?*const RSA) [*c]const BIGNUM;
+pub extern fn RSA_get0_p(rsa: ?*const RSA) [*c]const BIGNUM;
+pub extern fn RSA_get0_q(rsa: ?*const RSA) [*c]const BIGNUM;
+pub extern fn RSA_get0_dmp1(rsa: ?*const RSA) [*c]const BIGNUM;
+pub extern fn RSA_get0_dmq1(rsa: ?*const RSA) [*c]const BIGNUM;
+pub extern fn RSA_get0_iqmp(rsa: ?*const RSA) [*c]const BIGNUM;
+pub extern fn RSA_get0_key(rsa: ?*const RSA, out_n: [*c][*c]const BIGNUM, out_e: [*c][*c]const BIGNUM, out_d: [*c][*c]const BIGNUM) void;
+pub extern fn RSA_get0_factors(rsa: ?*const RSA, out_p: [*c][*c]const BIGNUM, out_q: [*c][*c]const BIGNUM) void;
+pub extern fn RSA_get0_crt_params(rsa: ?*const RSA, out_dmp1: [*c][*c]const BIGNUM, out_dmq1: [*c][*c]const BIGNUM, out_iqmp: [*c][*c]const BIGNUM) void;
+pub extern fn RSA_set0_key(rsa: ?*RSA, n: [*c]BIGNUM, e: [*c]BIGNUM, d: [*c]BIGNUM) c_int;
+pub extern fn RSA_set0_factors(rsa: ?*RSA, p: [*c]BIGNUM, q: [*c]BIGNUM) c_int;
+pub extern fn RSA_set0_crt_params(rsa: ?*RSA, dmp1: [*c]BIGNUM, dmq1: [*c]BIGNUM, iqmp: [*c]BIGNUM) c_int;
+pub extern fn RSA_generate_key_ex(rsa: ?*RSA, bits: c_int, e: [*c]const BIGNUM, cb: [*c]BN_GENCB) c_int;
+pub extern fn RSA_generate_key_fips(rsa: ?*RSA, bits: c_int, cb: [*c]BN_GENCB) c_int;
+pub extern fn RSA_encrypt(rsa: ?*RSA, out_len: [*c]usize, out: [*c]u8, max_out: usize, in: [*c]const u8, in_len: usize, padding: c_int) c_int;
+pub extern fn RSA_decrypt(rsa: ?*RSA, out_len: [*c]usize, out: [*c]u8, max_out: usize, in: [*c]const u8, in_len: usize, padding: c_int) c_int;
+pub extern fn RSA_public_encrypt(flen: usize, from: [*c]const u8, to: [*c]u8, rsa: ?*RSA, padding: c_int) c_int;
+pub extern fn RSA_private_decrypt(flen: usize, from: [*c]const u8, to: [*c]u8, rsa: ?*RSA, padding: c_int) c_int;
+pub extern fn RSA_sign(hash_nid: c_int, digest: [*c]const u8, digest_len: c_uint, out: [*c]u8, out_len: [*c]c_uint, rsa: ?*RSA) c_int;
+pub extern fn RSA_sign_pss_mgf1(rsa: ?*RSA, out_len: [*c]usize, out: [*c]u8, max_out: usize, digest: [*c]const u8, digest_len: usize, md: ?*const EVP_MD, mgf1_md: ?*const EVP_MD, salt_len: c_int) c_int;
+pub extern fn RSA_sign_raw(rsa: ?*RSA, out_len: [*c]usize, out: [*c]u8, max_out: usize, in: [*c]const u8, in_len: usize, padding: c_int) c_int;
+pub extern fn RSA_verify(hash_nid: c_int, digest: [*c]const u8, digest_len: usize, sig: [*c]const u8, sig_len: usize, rsa: ?*RSA) c_int;
+pub extern fn RSA_verify_pss_mgf1(rsa: ?*RSA, digest: [*c]const u8, digest_len: usize, md: ?*const EVP_MD, mgf1_md: ?*const EVP_MD, salt_len: c_int, sig: [*c]const u8, sig_len: usize) c_int;
+pub extern fn RSA_verify_raw(rsa: ?*RSA, out_len: [*c]usize, out: [*c]u8, max_out: usize, in: [*c]const u8, in_len: usize, padding: c_int) c_int;
+pub extern fn RSA_private_encrypt(flen: usize, from: [*c]const u8, to: [*c]u8, rsa: ?*RSA, padding: c_int) c_int;
+pub extern fn RSA_public_decrypt(flen: usize, from: [*c]const u8, to: [*c]u8, rsa: ?*RSA, padding: c_int) c_int;
+pub extern fn RSA_size(rsa: ?*const RSA) c_uint;
+pub extern fn RSA_is_opaque(rsa: ?*const RSA) c_int;
+pub extern fn RSAPublicKey_dup(rsa: ?*const RSA) ?*RSA;
+pub extern fn RSAPrivateKey_dup(rsa: ?*const RSA) ?*RSA;
+pub extern fn RSA_check_key(rsa: ?*const RSA) c_int;
+pub extern fn RSA_check_fips(key: ?*RSA) c_int;
+pub extern fn RSA_verify_PKCS1_PSS_mgf1(rsa: ?*const RSA, mHash: [*c]const u8, Hash: ?*const EVP_MD, mgf1Hash: ?*const EVP_MD, EM: [*c]const u8, sLen: c_int) c_int;
+pub extern fn RSA_padding_add_PKCS1_PSS_mgf1(rsa: ?*const RSA, EM: [*c]u8, mHash: [*c]const u8, Hash: ?*const EVP_MD, mgf1Hash: ?*const EVP_MD, sLen: c_int) c_int;
+pub extern fn RSA_padding_add_PKCS1_OAEP_mgf1(to: [*c]u8, to_len: usize, from: [*c]const u8, from_len: usize, param: [*c]const u8, param_len: usize, md: ?*const EVP_MD, mgf1md: ?*const EVP_MD) c_int;
+pub extern fn RSA_add_pkcs1_prefix(out_msg: [*c][*c]u8, out_msg_len: [*c]usize, is_alloced: [*c]c_int, hash_nid: c_int, digest: [*c]const u8, digest_len: usize) c_int;
+pub extern fn RSA_parse_public_key(cbs: [*c]CBS) ?*RSA;
+pub extern fn RSA_public_key_from_bytes(in: [*c]const u8, in_len: usize) ?*RSA;
+pub extern fn RSA_marshal_public_key(cbb: [*c]CBB, rsa: ?*const RSA) c_int;
+pub extern fn RSA_public_key_to_bytes(out_bytes: [*c][*c]u8, out_len: [*c]usize, rsa: ?*const RSA) c_int;
+pub extern fn RSA_parse_private_key(cbs: [*c]CBS) ?*RSA;
+pub extern fn RSA_private_key_from_bytes(in: [*c]const u8, in_len: usize) ?*RSA;
+pub extern fn RSA_marshal_private_key(cbb: [*c]CBB, rsa: ?*const RSA) c_int;
+pub extern fn RSA_private_key_to_bytes(out_bytes: [*c][*c]u8, out_len: [*c]usize, rsa: ?*const RSA) c_int;
+pub extern fn RSA_get_ex_new_index(argl: c_long, argp: ?*c_void, unused: [*c]CRYPTO_EX_unused, dup_unused: ?CRYPTO_EX_dup, free_func: ?CRYPTO_EX_free) c_int;
+pub extern fn RSA_set_ex_data(rsa: ?*RSA, idx: c_int, arg: ?*c_void) c_int;
+pub extern fn RSA_get_ex_data(rsa: ?*const RSA, idx: c_int) ?*c_void;
+pub extern fn RSA_flags(rsa: ?*const RSA) c_int;
+pub extern fn RSA_blinding_on(rsa: ?*RSA, ctx: ?*BN_CTX) c_int;
+pub extern fn RSA_generate_key(bits: c_int, e: c_ulong, callback: ?*c_void, cb_arg: ?*c_void) ?*RSA;
+pub extern fn d2i_RSAPublicKey(out: [*c]?*RSA, inp: [*c][*c]const u8, len: c_long) ?*RSA;
+pub extern fn i2d_RSAPublicKey(in: ?*const RSA, outp: [*c][*c]u8) c_int;
+pub extern fn d2i_RSAPrivateKey(out: [*c]?*RSA, inp: [*c][*c]const u8, len: c_long) ?*RSA;
+pub extern fn i2d_RSAPrivateKey(in: ?*const RSA, outp: [*c][*c]u8) c_int;
+pub extern fn RSA_padding_add_PKCS1_PSS(rsa: ?*const RSA, EM: [*c]u8, mHash: [*c]const u8, Hash: ?*const EVP_MD, sLen: c_int) c_int;
+pub extern fn RSA_verify_PKCS1_PSS(rsa: ?*const RSA, mHash: [*c]const u8, Hash: ?*const EVP_MD, EM: [*c]const u8, sLen: c_int) c_int;
+pub extern fn RSA_padding_add_PKCS1_OAEP(to: [*c]u8, to_len: usize, from: [*c]const u8, from_len: usize, param: [*c]const u8, param_len: usize) c_int;
+pub extern fn RSA_print(bio: [*c]BIO, rsa: ?*const RSA, indent: c_int) c_int;
+pub extern fn RSA_get0_pss_params(rsa: ?*const RSA) [*c]const RSA_PSS_PARAMS;
+pub extern fn SHA1_Init(sha: [*c]SHA_CTX) c_int;
+pub extern fn SHA1_Update(sha: [*c]SHA_CTX, data: ?*const c_void, len: usize) c_int;
+pub extern fn SHA1_Final(out: [*c]u8, sha: [*c]SHA_CTX) c_int;
+pub extern fn SHA1(data: [*c]const u8, len: usize, out: [*c]u8) [*c]u8;
+pub extern fn SHA1_Transform(sha: [*c]SHA_CTX, block: [*c]const u8) void;
+pub extern fn SHA224_Init(sha: [*c]SHA256_CTX) c_int;
+pub extern fn SHA224_Update(sha: [*c]SHA256_CTX, data: ?*const c_void, len: usize) c_int;
+pub extern fn SHA224_Final(out: [*c]u8, sha: [*c]SHA256_CTX) c_int;
+pub extern fn SHA224(data: [*c]const u8, len: usize, out: [*c]u8) [*c]u8;
+pub extern fn SHA256_Init(sha: [*c]SHA256_CTX) c_int;
+pub extern fn SHA256_Update(sha: [*c]SHA256_CTX, data: ?*const c_void, len: usize) c_int;
+pub extern fn SHA256_Final(out: [*c]u8, sha: [*c]SHA256_CTX) c_int;
+pub extern fn SHA256(data: [*c]const u8, len: usize, out: [*c]u8) [*c]u8;
+pub extern fn SHA256_Transform(sha: [*c]SHA256_CTX, block: [*c]const u8) void;
+pub extern fn SHA256_TransformBlocks(state: [*c]u32, data: [*c]const u8, num_blocks: usize) void;
+pub extern fn SHA384_Init(sha: [*c]SHA512_CTX) c_int;
+pub extern fn SHA384_Update(sha: [*c]SHA512_CTX, data: ?*const c_void, len: usize) c_int;
+pub extern fn SHA384_Final(out: [*c]u8, sha: [*c]SHA512_CTX) c_int;
+pub extern fn SHA384(data: [*c]const u8, len: usize, out: [*c]u8) [*c]u8;
+pub extern fn SHA512_Init(sha: [*c]SHA512_CTX) c_int;
+pub extern fn SHA512_Update(sha: [*c]SHA512_CTX, data: ?*const c_void, len: usize) c_int;
+pub extern fn SHA512_Final(out: [*c]u8, sha: [*c]SHA512_CTX) c_int;
+pub extern fn SHA512(data: [*c]const u8, len: usize, out: [*c]u8) [*c]u8;
+pub extern fn SHA512_Transform(sha: [*c]SHA512_CTX, block: [*c]const u8) void;
+pub extern fn SHA512_256_Init(sha: [*c]SHA512_CTX) c_int;
+pub extern fn SHA512_256_Update(sha: [*c]SHA512_CTX, data: ?*const c_void, len: usize) c_int;
+pub extern fn SHA512_256_Final(out: [*c]u8, sha: [*c]SHA512_CTX) c_int;
+pub extern fn SHA512_256(data: [*c]const u8, len: usize, out: [*c]u8) [*c]u8;
+pub extern fn X509_ALGOR_new() [*c]X509_ALGOR;
+pub extern fn X509_ALGOR_free(a: [*c]X509_ALGOR) void;
+pub extern fn d2i_X509_ALGOR(a: [*c][*c]X509_ALGOR, in: [*c][*c]const u8, len: c_long) [*c]X509_ALGOR;
+pub extern fn i2d_X509_ALGOR(a: [*c]X509_ALGOR, out: [*c][*c]u8) c_int;
+pub extern const X509_ALGOR_it: ASN1_ITEM;
+pub const struct_stack_st_X509_ALGOR = opaque {};
+pub const stack_X509_ALGOR_free_func = ?fn ([*c]X509_ALGOR) callconv(.C) void;
+pub const stack_X509_ALGOR_copy_func = ?fn ([*c]X509_ALGOR) callconv(.C) [*c]X509_ALGOR;
+pub const stack_X509_ALGOR_cmp_func = ?fn ([*c][*c]const X509_ALGOR, [*c][*c]const X509_ALGOR) callconv(.C) c_int;
+pub fn sk_X509_ALGOR_call_free_func(arg_free_func: stack_free_func, arg_ptr: ?*c_void) callconv(.C) void {
+ var free_func = arg_free_func;
+ var ptr = arg_ptr;
+ @ptrCast(stack_X509_ALGOR_free_func, @alignCast(@import("std").meta.alignment(fn ([*c]X509_ALGOR) callconv(.C) void), free_func)).?(@ptrCast([*c]X509_ALGOR, @alignCast(@import("std").meta.alignment(X509_ALGOR), ptr)));
+}
+pub fn sk_X509_ALGOR_call_copy_func(arg_copy_func: stack_copy_func, arg_ptr: ?*c_void) callconv(.C) ?*c_void {
+ var copy_func = arg_copy_func;
+ var ptr = arg_ptr;
+ return @ptrCast(?*c_void, @ptrCast(stack_X509_ALGOR_copy_func, @alignCast(@import("std").meta.alignment(fn ([*c]X509_ALGOR) callconv(.C) [*c]X509_ALGOR), copy_func)).?(@ptrCast([*c]X509_ALGOR, @alignCast(@import("std").meta.alignment(X509_ALGOR), ptr))));
+}
+pub fn sk_X509_ALGOR_call_cmp_func(arg_cmp_func: stack_cmp_func, arg_a: [*c]?*const c_void, arg_b: [*c]?*const c_void) callconv(.C) c_int {
+ var cmp_func = arg_cmp_func;
+ var a = arg_a;
+ var b = arg_b;
+ var a_ptr: [*c]const X509_ALGOR = @ptrCast([*c]const X509_ALGOR, @alignCast(@import("std").meta.alignment(X509_ALGOR), a.*));
+ var b_ptr: [*c]const X509_ALGOR = @ptrCast([*c]const X509_ALGOR, @alignCast(@import("std").meta.alignment(X509_ALGOR), b.*));
+ return @ptrCast(stack_X509_ALGOR_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c][*c]const X509_ALGOR, [*c][*c]const X509_ALGOR) callconv(.C) c_int), cmp_func)).?(&a_ptr, &b_ptr);
+}
+pub fn sk_X509_ALGOR_new(arg_comp: stack_X509_ALGOR_cmp_func) callconv(.C) ?*struct_stack_st_X509_ALGOR {
+ var comp = arg_comp;
+ return @ptrCast(?*struct_stack_st_X509_ALGOR, sk_new(@ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp))));
+}
+pub fn sk_X509_ALGOR_new_null() callconv(.C) ?*struct_stack_st_X509_ALGOR {
+ return @ptrCast(?*struct_stack_st_X509_ALGOR, sk_new_null());
+}
+pub fn sk_X509_ALGOR_num(arg_sk: ?*const struct_stack_st_X509_ALGOR) callconv(.C) usize {
+ var sk = arg_sk;
+ return sk_num(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_ALGOR_zero(arg_sk: ?*struct_stack_st_X509_ALGOR) callconv(.C) void {
+ var sk = arg_sk;
+ sk_zero(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_ALGOR_value(arg_sk: ?*const struct_stack_st_X509_ALGOR, arg_i: usize) callconv(.C) [*c]X509_ALGOR {
+ var sk = arg_sk;
+ var i = arg_i;
+ return @ptrCast([*c]X509_ALGOR, @alignCast(@import("std").meta.alignment(X509_ALGOR), sk_value(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i)));
+}
+pub fn sk_X509_ALGOR_set(arg_sk: ?*struct_stack_st_X509_ALGOR, arg_i: usize, arg_p: [*c]X509_ALGOR) callconv(.C) [*c]X509_ALGOR {
+ var sk = arg_sk;
+ var i = arg_i;
+ var p = arg_p;
+ return @ptrCast([*c]X509_ALGOR, @alignCast(@import("std").meta.alignment(X509_ALGOR), sk_set(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i, @ptrCast(?*c_void, p))));
+}
+pub fn sk_X509_ALGOR_free(arg_sk: ?*struct_stack_st_X509_ALGOR) callconv(.C) void {
+ var sk = arg_sk;
+ sk_free(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_ALGOR_pop_free(arg_sk: ?*struct_stack_st_X509_ALGOR, arg_free_func: stack_X509_ALGOR_free_func) callconv(.C) void {
+ var sk = arg_sk;
+ var free_func = arg_free_func;
+ sk_pop_free_ex(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_X509_ALGOR_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func)));
+}
+pub fn sk_X509_ALGOR_insert(arg_sk: ?*struct_stack_st_X509_ALGOR, arg_p: [*c]X509_ALGOR, arg_where: usize) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ var where = arg_where;
+ return sk_insert(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p), where);
+}
+pub fn sk_X509_ALGOR_delete(arg_sk: ?*struct_stack_st_X509_ALGOR, arg_where: usize) callconv(.C) [*c]X509_ALGOR {
+ var sk = arg_sk;
+ var where = arg_where;
+ return @ptrCast([*c]X509_ALGOR, @alignCast(@import("std").meta.alignment(X509_ALGOR), sk_delete(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), where)));
+}
+pub fn sk_X509_ALGOR_delete_ptr(arg_sk: ?*struct_stack_st_X509_ALGOR, arg_p: [*c]const X509_ALGOR) callconv(.C) [*c]X509_ALGOR {
+ var sk = arg_sk;
+ var p = arg_p;
+ return @ptrCast([*c]X509_ALGOR, @alignCast(@import("std").meta.alignment(X509_ALGOR), sk_delete_ptr(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*const c_void, p))));
+}
+pub fn sk_X509_ALGOR_find(arg_sk: ?*const struct_stack_st_X509_ALGOR, arg_out_index: [*c]usize, arg_p: [*c]const X509_ALGOR) callconv(.C) c_int {
+ var sk = arg_sk;
+ var out_index = arg_out_index;
+ var p = arg_p;
+ return sk_find(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), out_index, @ptrCast(?*const c_void, p), sk_X509_ALGOR_call_cmp_func);
+}
+pub fn sk_X509_ALGOR_shift(arg_sk: ?*struct_stack_st_X509_ALGOR) callconv(.C) [*c]X509_ALGOR {
+ var sk = arg_sk;
+ return @ptrCast([*c]X509_ALGOR, @alignCast(@import("std").meta.alignment(X509_ALGOR), sk_shift(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)))));
+}
+pub fn sk_X509_ALGOR_push(arg_sk: ?*struct_stack_st_X509_ALGOR, arg_p: [*c]X509_ALGOR) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ return sk_push(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p));
+}
+pub fn sk_X509_ALGOR_pop(arg_sk: ?*struct_stack_st_X509_ALGOR) callconv(.C) [*c]X509_ALGOR {
+ var sk = arg_sk;
+ return @ptrCast([*c]X509_ALGOR, @alignCast(@import("std").meta.alignment(X509_ALGOR), sk_pop(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)))));
+}
+pub fn sk_X509_ALGOR_dup(arg_sk: ?*const struct_stack_st_X509_ALGOR) callconv(.C) ?*struct_stack_st_X509_ALGOR {
+ var sk = arg_sk;
+ return @ptrCast(?*struct_stack_st_X509_ALGOR, sk_dup(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_ALGOR_sort(arg_sk: ?*struct_stack_st_X509_ALGOR) callconv(.C) void {
+ var sk = arg_sk;
+ sk_sort(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_ALGOR_is_sorted(arg_sk: ?*const struct_stack_st_X509_ALGOR) callconv(.C) c_int {
+ var sk = arg_sk;
+ return sk_is_sorted(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_ALGOR_set_cmp_func(arg_sk: ?*struct_stack_st_X509_ALGOR, arg_comp: stack_X509_ALGOR_cmp_func) callconv(.C) stack_X509_ALGOR_cmp_func {
+ var sk = arg_sk;
+ var comp = arg_comp;
+ return @ptrCast(stack_X509_ALGOR_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c][*c]const X509_ALGOR, [*c][*c]const X509_ALGOR) callconv(.C) c_int), sk_set_cmp_func(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp)))));
+}
+pub fn sk_X509_ALGOR_deep_copy(arg_sk: ?*const struct_stack_st_X509_ALGOR, arg_copy_func: ?fn ([*c]X509_ALGOR) callconv(.C) [*c]X509_ALGOR, arg_free_func: ?fn ([*c]X509_ALGOR) callconv(.C) void) callconv(.C) ?*struct_stack_st_X509_ALGOR {
+ var sk = arg_sk;
+ var copy_func = arg_copy_func;
+ var free_func = arg_free_func;
+ return @ptrCast(?*struct_stack_st_X509_ALGOR, sk_deep_copy(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_X509_ALGOR_call_copy_func, @ptrCast(stack_copy_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) ?*c_void), copy_func)), sk_X509_ALGOR_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func))));
+}
+pub const X509_ALGORS = struct_stack_st_X509_ALGOR;
+pub const struct_stack_st_X509_NAME_ENTRY = opaque {};
+pub const stack_X509_NAME_ENTRY_free_func = ?fn (?*X509_NAME_ENTRY) callconv(.C) void;
+pub const stack_X509_NAME_ENTRY_copy_func = ?fn (?*X509_NAME_ENTRY) callconv(.C) ?*X509_NAME_ENTRY;
+pub const stack_X509_NAME_ENTRY_cmp_func = ?fn ([*c]?*const X509_NAME_ENTRY, [*c]?*const X509_NAME_ENTRY) callconv(.C) c_int;
+pub fn sk_X509_NAME_ENTRY_call_free_func(arg_free_func: stack_free_func, arg_ptr: ?*c_void) callconv(.C) void {
+ var free_func = arg_free_func;
+ var ptr = arg_ptr;
+ @ptrCast(stack_X509_NAME_ENTRY_free_func, @alignCast(@import("std").meta.alignment(fn (?*X509_NAME_ENTRY) callconv(.C) void), free_func)).?(@ptrCast(?*X509_NAME_ENTRY, ptr));
+}
+pub fn sk_X509_NAME_ENTRY_call_copy_func(arg_copy_func: stack_copy_func, arg_ptr: ?*c_void) callconv(.C) ?*c_void {
+ var copy_func = arg_copy_func;
+ var ptr = arg_ptr;
+ return @ptrCast(?*c_void, @ptrCast(stack_X509_NAME_ENTRY_copy_func, @alignCast(@import("std").meta.alignment(fn (?*X509_NAME_ENTRY) callconv(.C) ?*X509_NAME_ENTRY), copy_func)).?(@ptrCast(?*X509_NAME_ENTRY, ptr)));
+}
+pub fn sk_X509_NAME_ENTRY_call_cmp_func(arg_cmp_func: stack_cmp_func, arg_a: [*c]?*const c_void, arg_b: [*c]?*const c_void) callconv(.C) c_int {
+ var cmp_func = arg_cmp_func;
+ var a = arg_a;
+ var b = arg_b;
+ var a_ptr: ?*const X509_NAME_ENTRY = @ptrCast(?*const X509_NAME_ENTRY, a.*);
+ var b_ptr: ?*const X509_NAME_ENTRY = @ptrCast(?*const X509_NAME_ENTRY, b.*);
+ return @ptrCast(stack_X509_NAME_ENTRY_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const X509_NAME_ENTRY, [*c]?*const X509_NAME_ENTRY) callconv(.C) c_int), cmp_func)).?(&a_ptr, &b_ptr);
+}
+pub fn sk_X509_NAME_ENTRY_new(arg_comp: stack_X509_NAME_ENTRY_cmp_func) callconv(.C) ?*struct_stack_st_X509_NAME_ENTRY {
+ var comp = arg_comp;
+ return @ptrCast(?*struct_stack_st_X509_NAME_ENTRY, sk_new(@ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp))));
+}
+pub fn sk_X509_NAME_ENTRY_new_null() callconv(.C) ?*struct_stack_st_X509_NAME_ENTRY {
+ return @ptrCast(?*struct_stack_st_X509_NAME_ENTRY, sk_new_null());
+}
+pub fn sk_X509_NAME_ENTRY_num(arg_sk: ?*const struct_stack_st_X509_NAME_ENTRY) callconv(.C) usize {
+ var sk = arg_sk;
+ return sk_num(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_NAME_ENTRY_zero(arg_sk: ?*struct_stack_st_X509_NAME_ENTRY) callconv(.C) void {
+ var sk = arg_sk;
+ sk_zero(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_NAME_ENTRY_value(arg_sk: ?*const struct_stack_st_X509_NAME_ENTRY, arg_i: usize) callconv(.C) ?*X509_NAME_ENTRY {
+ var sk = arg_sk;
+ var i = arg_i;
+ return @ptrCast(?*X509_NAME_ENTRY, sk_value(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i));
+}
+pub fn sk_X509_NAME_ENTRY_set(arg_sk: ?*struct_stack_st_X509_NAME_ENTRY, arg_i: usize, arg_p: ?*X509_NAME_ENTRY) callconv(.C) ?*X509_NAME_ENTRY {
+ var sk = arg_sk;
+ var i = arg_i;
+ var p = arg_p;
+ return @ptrCast(?*X509_NAME_ENTRY, sk_set(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i, @ptrCast(?*c_void, p)));
+}
+pub fn sk_X509_NAME_ENTRY_free(arg_sk: ?*struct_stack_st_X509_NAME_ENTRY) callconv(.C) void {
+ var sk = arg_sk;
+ sk_free(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_NAME_ENTRY_pop_free(arg_sk: ?*struct_stack_st_X509_NAME_ENTRY, arg_free_func: stack_X509_NAME_ENTRY_free_func) callconv(.C) void {
+ var sk = arg_sk;
+ var free_func = arg_free_func;
+ sk_pop_free_ex(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_X509_NAME_ENTRY_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func)));
+}
+pub fn sk_X509_NAME_ENTRY_insert(arg_sk: ?*struct_stack_st_X509_NAME_ENTRY, arg_p: ?*X509_NAME_ENTRY, arg_where: usize) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ var where = arg_where;
+ return sk_insert(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p), where);
+}
+pub fn sk_X509_NAME_ENTRY_delete(arg_sk: ?*struct_stack_st_X509_NAME_ENTRY, arg_where: usize) callconv(.C) ?*X509_NAME_ENTRY {
+ var sk = arg_sk;
+ var where = arg_where;
+ return @ptrCast(?*X509_NAME_ENTRY, sk_delete(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), where));
+}
+pub fn sk_X509_NAME_ENTRY_delete_ptr(arg_sk: ?*struct_stack_st_X509_NAME_ENTRY, arg_p: ?*const X509_NAME_ENTRY) callconv(.C) ?*X509_NAME_ENTRY {
+ var sk = arg_sk;
+ var p = arg_p;
+ return @ptrCast(?*X509_NAME_ENTRY, sk_delete_ptr(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*const c_void, p)));
+}
+pub fn sk_X509_NAME_ENTRY_find(arg_sk: ?*const struct_stack_st_X509_NAME_ENTRY, arg_out_index: [*c]usize, arg_p: ?*const X509_NAME_ENTRY) callconv(.C) c_int {
+ var sk = arg_sk;
+ var out_index = arg_out_index;
+ var p = arg_p;
+ return sk_find(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), out_index, @ptrCast(?*const c_void, p), sk_X509_NAME_ENTRY_call_cmp_func);
+}
+pub fn sk_X509_NAME_ENTRY_shift(arg_sk: ?*struct_stack_st_X509_NAME_ENTRY) callconv(.C) ?*X509_NAME_ENTRY {
+ var sk = arg_sk;
+ return @ptrCast(?*X509_NAME_ENTRY, sk_shift(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_NAME_ENTRY_push(arg_sk: ?*struct_stack_st_X509_NAME_ENTRY, arg_p: ?*X509_NAME_ENTRY) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ return sk_push(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p));
+}
+pub fn sk_X509_NAME_ENTRY_pop(arg_sk: ?*struct_stack_st_X509_NAME_ENTRY) callconv(.C) ?*X509_NAME_ENTRY {
+ var sk = arg_sk;
+ return @ptrCast(?*X509_NAME_ENTRY, sk_pop(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_NAME_ENTRY_dup(arg_sk: ?*const struct_stack_st_X509_NAME_ENTRY) callconv(.C) ?*struct_stack_st_X509_NAME_ENTRY {
+ var sk = arg_sk;
+ return @ptrCast(?*struct_stack_st_X509_NAME_ENTRY, sk_dup(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_NAME_ENTRY_sort(arg_sk: ?*struct_stack_st_X509_NAME_ENTRY) callconv(.C) void {
+ var sk = arg_sk;
+ sk_sort(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_NAME_ENTRY_is_sorted(arg_sk: ?*const struct_stack_st_X509_NAME_ENTRY) callconv(.C) c_int {
+ var sk = arg_sk;
+ return sk_is_sorted(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_NAME_ENTRY_set_cmp_func(arg_sk: ?*struct_stack_st_X509_NAME_ENTRY, arg_comp: stack_X509_NAME_ENTRY_cmp_func) callconv(.C) stack_X509_NAME_ENTRY_cmp_func {
+ var sk = arg_sk;
+ var comp = arg_comp;
+ return @ptrCast(stack_X509_NAME_ENTRY_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const X509_NAME_ENTRY, [*c]?*const X509_NAME_ENTRY) callconv(.C) c_int), sk_set_cmp_func(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp)))));
+}
+pub fn sk_X509_NAME_ENTRY_deep_copy(arg_sk: ?*const struct_stack_st_X509_NAME_ENTRY, arg_copy_func: ?fn (?*X509_NAME_ENTRY) callconv(.C) ?*X509_NAME_ENTRY, arg_free_func: ?fn (?*X509_NAME_ENTRY) callconv(.C) void) callconv(.C) ?*struct_stack_st_X509_NAME_ENTRY {
+ var sk = arg_sk;
+ var copy_func = arg_copy_func;
+ var free_func = arg_free_func;
+ return @ptrCast(?*struct_stack_st_X509_NAME_ENTRY, sk_deep_copy(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_X509_NAME_ENTRY_call_copy_func, @ptrCast(stack_copy_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) ?*c_void), copy_func)), sk_X509_NAME_ENTRY_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func))));
+}
+pub const struct_stack_st_X509_NAME = opaque {};
+pub const stack_X509_NAME_free_func = ?fn (?*X509_NAME) callconv(.C) void;
+pub const stack_X509_NAME_copy_func = ?fn (?*X509_NAME) callconv(.C) ?*X509_NAME;
+pub const stack_X509_NAME_cmp_func = ?fn ([*c]?*const X509_NAME, [*c]?*const X509_NAME) callconv(.C) c_int;
+pub fn sk_X509_NAME_call_free_func(arg_free_func: stack_free_func, arg_ptr: ?*c_void) callconv(.C) void {
+ var free_func = arg_free_func;
+ var ptr = arg_ptr;
+ @ptrCast(stack_X509_NAME_free_func, @alignCast(@import("std").meta.alignment(fn (?*X509_NAME) callconv(.C) void), free_func)).?(@ptrCast(?*X509_NAME, ptr));
+}
+pub fn sk_X509_NAME_call_copy_func(arg_copy_func: stack_copy_func, arg_ptr: ?*c_void) callconv(.C) ?*c_void {
+ var copy_func = arg_copy_func;
+ var ptr = arg_ptr;
+ return @ptrCast(?*c_void, @ptrCast(stack_X509_NAME_copy_func, @alignCast(@import("std").meta.alignment(fn (?*X509_NAME) callconv(.C) ?*X509_NAME), copy_func)).?(@ptrCast(?*X509_NAME, ptr)));
+}
+pub fn sk_X509_NAME_call_cmp_func(arg_cmp_func: stack_cmp_func, arg_a: [*c]?*const c_void, arg_b: [*c]?*const c_void) callconv(.C) c_int {
+ var cmp_func = arg_cmp_func;
+ var a = arg_a;
+ var b = arg_b;
+ var a_ptr: ?*const X509_NAME = @ptrCast(?*const X509_NAME, a.*);
+ var b_ptr: ?*const X509_NAME = @ptrCast(?*const X509_NAME, b.*);
+ return @ptrCast(stack_X509_NAME_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const X509_NAME, [*c]?*const X509_NAME) callconv(.C) c_int), cmp_func)).?(&a_ptr, &b_ptr);
+}
+pub fn sk_X509_NAME_new(arg_comp: stack_X509_NAME_cmp_func) callconv(.C) ?*struct_stack_st_X509_NAME {
+ var comp = arg_comp;
+ return @ptrCast(?*struct_stack_st_X509_NAME, sk_new(@ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp))));
+}
+pub fn sk_X509_NAME_new_null() callconv(.C) ?*struct_stack_st_X509_NAME {
+ return @ptrCast(?*struct_stack_st_X509_NAME, sk_new_null());
+}
+pub fn sk_X509_NAME_num(arg_sk: ?*const struct_stack_st_X509_NAME) callconv(.C) usize {
+ var sk = arg_sk;
+ return sk_num(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_NAME_zero(arg_sk: ?*struct_stack_st_X509_NAME) callconv(.C) void {
+ var sk = arg_sk;
+ sk_zero(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_NAME_value(arg_sk: ?*const struct_stack_st_X509_NAME, arg_i: usize) callconv(.C) ?*X509_NAME {
+ var sk = arg_sk;
+ var i = arg_i;
+ return @ptrCast(?*X509_NAME, sk_value(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i));
+}
+pub fn sk_X509_NAME_set(arg_sk: ?*struct_stack_st_X509_NAME, arg_i: usize, arg_p: ?*X509_NAME) callconv(.C) ?*X509_NAME {
+ var sk = arg_sk;
+ var i = arg_i;
+ var p = arg_p;
+ return @ptrCast(?*X509_NAME, sk_set(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i, @ptrCast(?*c_void, p)));
+}
+pub fn sk_X509_NAME_free(arg_sk: ?*struct_stack_st_X509_NAME) callconv(.C) void {
+ var sk = arg_sk;
+ sk_free(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_NAME_pop_free(arg_sk: ?*struct_stack_st_X509_NAME, arg_free_func: stack_X509_NAME_free_func) callconv(.C) void {
+ var sk = arg_sk;
+ var free_func = arg_free_func;
+ sk_pop_free_ex(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_X509_NAME_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func)));
+}
+pub fn sk_X509_NAME_insert(arg_sk: ?*struct_stack_st_X509_NAME, arg_p: ?*X509_NAME, arg_where: usize) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ var where = arg_where;
+ return sk_insert(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p), where);
+}
+pub fn sk_X509_NAME_delete(arg_sk: ?*struct_stack_st_X509_NAME, arg_where: usize) callconv(.C) ?*X509_NAME {
+ var sk = arg_sk;
+ var where = arg_where;
+ return @ptrCast(?*X509_NAME, sk_delete(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), where));
+}
+pub fn sk_X509_NAME_delete_ptr(arg_sk: ?*struct_stack_st_X509_NAME, arg_p: ?*const X509_NAME) callconv(.C) ?*X509_NAME {
+ var sk = arg_sk;
+ var p = arg_p;
+ return @ptrCast(?*X509_NAME, sk_delete_ptr(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*const c_void, p)));
+}
+pub fn sk_X509_NAME_find(arg_sk: ?*const struct_stack_st_X509_NAME, arg_out_index: [*c]usize, arg_p: ?*const X509_NAME) callconv(.C) c_int {
+ var sk = arg_sk;
+ var out_index = arg_out_index;
+ var p = arg_p;
+ return sk_find(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), out_index, @ptrCast(?*const c_void, p), sk_X509_NAME_call_cmp_func);
+}
+pub fn sk_X509_NAME_shift(arg_sk: ?*struct_stack_st_X509_NAME) callconv(.C) ?*X509_NAME {
+ var sk = arg_sk;
+ return @ptrCast(?*X509_NAME, sk_shift(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_NAME_push(arg_sk: ?*struct_stack_st_X509_NAME, arg_p: ?*X509_NAME) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ return sk_push(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p));
+}
+pub fn sk_X509_NAME_pop(arg_sk: ?*struct_stack_st_X509_NAME) callconv(.C) ?*X509_NAME {
+ var sk = arg_sk;
+ return @ptrCast(?*X509_NAME, sk_pop(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_NAME_dup(arg_sk: ?*const struct_stack_st_X509_NAME) callconv(.C) ?*struct_stack_st_X509_NAME {
+ var sk = arg_sk;
+ return @ptrCast(?*struct_stack_st_X509_NAME, sk_dup(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_NAME_sort(arg_sk: ?*struct_stack_st_X509_NAME) callconv(.C) void {
+ var sk = arg_sk;
+ sk_sort(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_NAME_is_sorted(arg_sk: ?*const struct_stack_st_X509_NAME) callconv(.C) c_int {
+ var sk = arg_sk;
+ return sk_is_sorted(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_NAME_set_cmp_func(arg_sk: ?*struct_stack_st_X509_NAME, arg_comp: stack_X509_NAME_cmp_func) callconv(.C) stack_X509_NAME_cmp_func {
+ var sk = arg_sk;
+ var comp = arg_comp;
+ return @ptrCast(stack_X509_NAME_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const X509_NAME, [*c]?*const X509_NAME) callconv(.C) c_int), sk_set_cmp_func(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp)))));
+}
+pub fn sk_X509_NAME_deep_copy(arg_sk: ?*const struct_stack_st_X509_NAME, arg_copy_func: ?fn (?*X509_NAME) callconv(.C) ?*X509_NAME, arg_free_func: ?fn (?*X509_NAME) callconv(.C) void) callconv(.C) ?*struct_stack_st_X509_NAME {
+ var sk = arg_sk;
+ var copy_func = arg_copy_func;
+ var free_func = arg_free_func;
+ return @ptrCast(?*struct_stack_st_X509_NAME, sk_deep_copy(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_X509_NAME_call_copy_func, @ptrCast(stack_copy_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) ?*c_void), copy_func)), sk_X509_NAME_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func))));
+}
+pub const X509_EXTENSIONS = struct_stack_st_X509_EXTENSION;
+pub const stack_X509_EXTENSION_free_func = ?fn (?*X509_EXTENSION) callconv(.C) void;
+pub const stack_X509_EXTENSION_copy_func = ?fn (?*X509_EXTENSION) callconv(.C) ?*X509_EXTENSION;
+pub const stack_X509_EXTENSION_cmp_func = ?fn ([*c]?*const X509_EXTENSION, [*c]?*const X509_EXTENSION) callconv(.C) c_int;
+pub fn sk_X509_EXTENSION_call_free_func(arg_free_func: stack_free_func, arg_ptr: ?*c_void) callconv(.C) void {
+ var free_func = arg_free_func;
+ var ptr = arg_ptr;
+ @ptrCast(stack_X509_EXTENSION_free_func, @alignCast(@import("std").meta.alignment(fn (?*X509_EXTENSION) callconv(.C) void), free_func)).?(@ptrCast(?*X509_EXTENSION, ptr));
+}
+pub fn sk_X509_EXTENSION_call_copy_func(arg_copy_func: stack_copy_func, arg_ptr: ?*c_void) callconv(.C) ?*c_void {
+ var copy_func = arg_copy_func;
+ var ptr = arg_ptr;
+ return @ptrCast(?*c_void, @ptrCast(stack_X509_EXTENSION_copy_func, @alignCast(@import("std").meta.alignment(fn (?*X509_EXTENSION) callconv(.C) ?*X509_EXTENSION), copy_func)).?(@ptrCast(?*X509_EXTENSION, ptr)));
+}
+pub fn sk_X509_EXTENSION_call_cmp_func(arg_cmp_func: stack_cmp_func, arg_a: [*c]?*const c_void, arg_b: [*c]?*const c_void) callconv(.C) c_int {
+ var cmp_func = arg_cmp_func;
+ var a = arg_a;
+ var b = arg_b;
+ var a_ptr: ?*const X509_EXTENSION = @ptrCast(?*const X509_EXTENSION, a.*);
+ var b_ptr: ?*const X509_EXTENSION = @ptrCast(?*const X509_EXTENSION, b.*);
+ return @ptrCast(stack_X509_EXTENSION_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const X509_EXTENSION, [*c]?*const X509_EXTENSION) callconv(.C) c_int), cmp_func)).?(&a_ptr, &b_ptr);
+}
+pub fn sk_X509_EXTENSION_new(arg_comp: stack_X509_EXTENSION_cmp_func) callconv(.C) ?*struct_stack_st_X509_EXTENSION {
+ var comp = arg_comp;
+ return @ptrCast(?*struct_stack_st_X509_EXTENSION, sk_new(@ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp))));
+}
+pub fn sk_X509_EXTENSION_new_null() callconv(.C) ?*struct_stack_st_X509_EXTENSION {
+ return @ptrCast(?*struct_stack_st_X509_EXTENSION, sk_new_null());
+}
+pub fn sk_X509_EXTENSION_num(arg_sk: ?*const struct_stack_st_X509_EXTENSION) callconv(.C) usize {
+ var sk = arg_sk;
+ return sk_num(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_EXTENSION_zero(arg_sk: ?*struct_stack_st_X509_EXTENSION) callconv(.C) void {
+ var sk = arg_sk;
+ sk_zero(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_EXTENSION_value(arg_sk: ?*const struct_stack_st_X509_EXTENSION, arg_i: usize) callconv(.C) ?*X509_EXTENSION {
+ var sk = arg_sk;
+ var i = arg_i;
+ return @ptrCast(?*X509_EXTENSION, sk_value(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i));
+}
+pub fn sk_X509_EXTENSION_set(arg_sk: ?*struct_stack_st_X509_EXTENSION, arg_i: usize, arg_p: ?*X509_EXTENSION) callconv(.C) ?*X509_EXTENSION {
+ var sk = arg_sk;
+ var i = arg_i;
+ var p = arg_p;
+ return @ptrCast(?*X509_EXTENSION, sk_set(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i, @ptrCast(?*c_void, p)));
+}
+pub fn sk_X509_EXTENSION_free(arg_sk: ?*struct_stack_st_X509_EXTENSION) callconv(.C) void {
+ var sk = arg_sk;
+ sk_free(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_EXTENSION_pop_free(arg_sk: ?*struct_stack_st_X509_EXTENSION, arg_free_func: stack_X509_EXTENSION_free_func) callconv(.C) void {
+ var sk = arg_sk;
+ var free_func = arg_free_func;
+ sk_pop_free_ex(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_X509_EXTENSION_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func)));
+}
+pub fn sk_X509_EXTENSION_insert(arg_sk: ?*struct_stack_st_X509_EXTENSION, arg_p: ?*X509_EXTENSION, arg_where: usize) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ var where = arg_where;
+ return sk_insert(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p), where);
+}
+pub fn sk_X509_EXTENSION_delete(arg_sk: ?*struct_stack_st_X509_EXTENSION, arg_where: usize) callconv(.C) ?*X509_EXTENSION {
+ var sk = arg_sk;
+ var where = arg_where;
+ return @ptrCast(?*X509_EXTENSION, sk_delete(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), where));
+}
+pub fn sk_X509_EXTENSION_delete_ptr(arg_sk: ?*struct_stack_st_X509_EXTENSION, arg_p: ?*const X509_EXTENSION) callconv(.C) ?*X509_EXTENSION {
+ var sk = arg_sk;
+ var p = arg_p;
+ return @ptrCast(?*X509_EXTENSION, sk_delete_ptr(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*const c_void, p)));
+}
+pub fn sk_X509_EXTENSION_find(arg_sk: ?*const struct_stack_st_X509_EXTENSION, arg_out_index: [*c]usize, arg_p: ?*const X509_EXTENSION) callconv(.C) c_int {
+ var sk = arg_sk;
+ var out_index = arg_out_index;
+ var p = arg_p;
+ return sk_find(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), out_index, @ptrCast(?*const c_void, p), sk_X509_EXTENSION_call_cmp_func);
+}
+pub fn sk_X509_EXTENSION_shift(arg_sk: ?*struct_stack_st_X509_EXTENSION) callconv(.C) ?*X509_EXTENSION {
+ var sk = arg_sk;
+ return @ptrCast(?*X509_EXTENSION, sk_shift(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_EXTENSION_push(arg_sk: ?*struct_stack_st_X509_EXTENSION, arg_p: ?*X509_EXTENSION) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ return sk_push(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p));
+}
+pub fn sk_X509_EXTENSION_pop(arg_sk: ?*struct_stack_st_X509_EXTENSION) callconv(.C) ?*X509_EXTENSION {
+ var sk = arg_sk;
+ return @ptrCast(?*X509_EXTENSION, sk_pop(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_EXTENSION_dup(arg_sk: ?*const struct_stack_st_X509_EXTENSION) callconv(.C) ?*struct_stack_st_X509_EXTENSION {
+ var sk = arg_sk;
+ return @ptrCast(?*struct_stack_st_X509_EXTENSION, sk_dup(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_EXTENSION_sort(arg_sk: ?*struct_stack_st_X509_EXTENSION) callconv(.C) void {
+ var sk = arg_sk;
+ sk_sort(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_EXTENSION_is_sorted(arg_sk: ?*const struct_stack_st_X509_EXTENSION) callconv(.C) c_int {
+ var sk = arg_sk;
+ return sk_is_sorted(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_EXTENSION_set_cmp_func(arg_sk: ?*struct_stack_st_X509_EXTENSION, arg_comp: stack_X509_EXTENSION_cmp_func) callconv(.C) stack_X509_EXTENSION_cmp_func {
+ var sk = arg_sk;
+ var comp = arg_comp;
+ return @ptrCast(stack_X509_EXTENSION_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const X509_EXTENSION, [*c]?*const X509_EXTENSION) callconv(.C) c_int), sk_set_cmp_func(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp)))));
+}
+pub fn sk_X509_EXTENSION_deep_copy(arg_sk: ?*const struct_stack_st_X509_EXTENSION, arg_copy_func: ?fn (?*X509_EXTENSION) callconv(.C) ?*X509_EXTENSION, arg_free_func: ?fn (?*X509_EXTENSION) callconv(.C) void) callconv(.C) ?*struct_stack_st_X509_EXTENSION {
+ var sk = arg_sk;
+ var copy_func = arg_copy_func;
+ var free_func = arg_free_func;
+ return @ptrCast(?*struct_stack_st_X509_EXTENSION, sk_deep_copy(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_X509_EXTENSION_call_copy_func, @ptrCast(stack_copy_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) ?*c_void), copy_func)), sk_X509_EXTENSION_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func))));
+}
+pub const struct_stack_st_X509_ATTRIBUTE = opaque {};
+pub const stack_X509_ATTRIBUTE_free_func = ?fn (?*X509_ATTRIBUTE) callconv(.C) void;
+pub const stack_X509_ATTRIBUTE_copy_func = ?fn (?*X509_ATTRIBUTE) callconv(.C) ?*X509_ATTRIBUTE;
+pub const stack_X509_ATTRIBUTE_cmp_func = ?fn ([*c]?*const X509_ATTRIBUTE, [*c]?*const X509_ATTRIBUTE) callconv(.C) c_int;
+pub fn sk_X509_ATTRIBUTE_call_free_func(arg_free_func: stack_free_func, arg_ptr: ?*c_void) callconv(.C) void {
+ var free_func = arg_free_func;
+ var ptr = arg_ptr;
+ @ptrCast(stack_X509_ATTRIBUTE_free_func, @alignCast(@import("std").meta.alignment(fn (?*X509_ATTRIBUTE) callconv(.C) void), free_func)).?(@ptrCast(?*X509_ATTRIBUTE, ptr));
+}
+pub fn sk_X509_ATTRIBUTE_call_copy_func(arg_copy_func: stack_copy_func, arg_ptr: ?*c_void) callconv(.C) ?*c_void {
+ var copy_func = arg_copy_func;
+ var ptr = arg_ptr;
+ return @ptrCast(?*c_void, @ptrCast(stack_X509_ATTRIBUTE_copy_func, @alignCast(@import("std").meta.alignment(fn (?*X509_ATTRIBUTE) callconv(.C) ?*X509_ATTRIBUTE), copy_func)).?(@ptrCast(?*X509_ATTRIBUTE, ptr)));
+}
+pub fn sk_X509_ATTRIBUTE_call_cmp_func(arg_cmp_func: stack_cmp_func, arg_a: [*c]?*const c_void, arg_b: [*c]?*const c_void) callconv(.C) c_int {
+ var cmp_func = arg_cmp_func;
+ var a = arg_a;
+ var b = arg_b;
+ var a_ptr: ?*const X509_ATTRIBUTE = @ptrCast(?*const X509_ATTRIBUTE, a.*);
+ var b_ptr: ?*const X509_ATTRIBUTE = @ptrCast(?*const X509_ATTRIBUTE, b.*);
+ return @ptrCast(stack_X509_ATTRIBUTE_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const X509_ATTRIBUTE, [*c]?*const X509_ATTRIBUTE) callconv(.C) c_int), cmp_func)).?(&a_ptr, &b_ptr);
+}
+pub fn sk_X509_ATTRIBUTE_new(arg_comp: stack_X509_ATTRIBUTE_cmp_func) callconv(.C) ?*struct_stack_st_X509_ATTRIBUTE {
+ var comp = arg_comp;
+ return @ptrCast(?*struct_stack_st_X509_ATTRIBUTE, sk_new(@ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp))));
+}
+pub fn sk_X509_ATTRIBUTE_new_null() callconv(.C) ?*struct_stack_st_X509_ATTRIBUTE {
+ return @ptrCast(?*struct_stack_st_X509_ATTRIBUTE, sk_new_null());
+}
+pub fn sk_X509_ATTRIBUTE_num(arg_sk: ?*const struct_stack_st_X509_ATTRIBUTE) callconv(.C) usize {
+ var sk = arg_sk;
+ return sk_num(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_ATTRIBUTE_zero(arg_sk: ?*struct_stack_st_X509_ATTRIBUTE) callconv(.C) void {
+ var sk = arg_sk;
+ sk_zero(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_ATTRIBUTE_value(arg_sk: ?*const struct_stack_st_X509_ATTRIBUTE, arg_i: usize) callconv(.C) ?*X509_ATTRIBUTE {
+ var sk = arg_sk;
+ var i = arg_i;
+ return @ptrCast(?*X509_ATTRIBUTE, sk_value(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i));
+}
+pub fn sk_X509_ATTRIBUTE_set(arg_sk: ?*struct_stack_st_X509_ATTRIBUTE, arg_i: usize, arg_p: ?*X509_ATTRIBUTE) callconv(.C) ?*X509_ATTRIBUTE {
+ var sk = arg_sk;
+ var i = arg_i;
+ var p = arg_p;
+ return @ptrCast(?*X509_ATTRIBUTE, sk_set(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i, @ptrCast(?*c_void, p)));
+}
+pub fn sk_X509_ATTRIBUTE_free(arg_sk: ?*struct_stack_st_X509_ATTRIBUTE) callconv(.C) void {
+ var sk = arg_sk;
+ sk_free(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_ATTRIBUTE_pop_free(arg_sk: ?*struct_stack_st_X509_ATTRIBUTE, arg_free_func: stack_X509_ATTRIBUTE_free_func) callconv(.C) void {
+ var sk = arg_sk;
+ var free_func = arg_free_func;
+ sk_pop_free_ex(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_X509_ATTRIBUTE_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func)));
+}
+pub fn sk_X509_ATTRIBUTE_insert(arg_sk: ?*struct_stack_st_X509_ATTRIBUTE, arg_p: ?*X509_ATTRIBUTE, arg_where: usize) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ var where = arg_where;
+ return sk_insert(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p), where);
+}
+pub fn sk_X509_ATTRIBUTE_delete(arg_sk: ?*struct_stack_st_X509_ATTRIBUTE, arg_where: usize) callconv(.C) ?*X509_ATTRIBUTE {
+ var sk = arg_sk;
+ var where = arg_where;
+ return @ptrCast(?*X509_ATTRIBUTE, sk_delete(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), where));
+}
+pub fn sk_X509_ATTRIBUTE_delete_ptr(arg_sk: ?*struct_stack_st_X509_ATTRIBUTE, arg_p: ?*const X509_ATTRIBUTE) callconv(.C) ?*X509_ATTRIBUTE {
+ var sk = arg_sk;
+ var p = arg_p;
+ return @ptrCast(?*X509_ATTRIBUTE, sk_delete_ptr(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*const c_void, p)));
+}
+pub fn sk_X509_ATTRIBUTE_find(arg_sk: ?*const struct_stack_st_X509_ATTRIBUTE, arg_out_index: [*c]usize, arg_p: ?*const X509_ATTRIBUTE) callconv(.C) c_int {
+ var sk = arg_sk;
+ var out_index = arg_out_index;
+ var p = arg_p;
+ return sk_find(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), out_index, @ptrCast(?*const c_void, p), sk_X509_ATTRIBUTE_call_cmp_func);
+}
+pub fn sk_X509_ATTRIBUTE_shift(arg_sk: ?*struct_stack_st_X509_ATTRIBUTE) callconv(.C) ?*X509_ATTRIBUTE {
+ var sk = arg_sk;
+ return @ptrCast(?*X509_ATTRIBUTE, sk_shift(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_ATTRIBUTE_push(arg_sk: ?*struct_stack_st_X509_ATTRIBUTE, arg_p: ?*X509_ATTRIBUTE) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ return sk_push(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p));
+}
+pub fn sk_X509_ATTRIBUTE_pop(arg_sk: ?*struct_stack_st_X509_ATTRIBUTE) callconv(.C) ?*X509_ATTRIBUTE {
+ var sk = arg_sk;
+ return @ptrCast(?*X509_ATTRIBUTE, sk_pop(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_ATTRIBUTE_dup(arg_sk: ?*const struct_stack_st_X509_ATTRIBUTE) callconv(.C) ?*struct_stack_st_X509_ATTRIBUTE {
+ var sk = arg_sk;
+ return @ptrCast(?*struct_stack_st_X509_ATTRIBUTE, sk_dup(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_ATTRIBUTE_sort(arg_sk: ?*struct_stack_st_X509_ATTRIBUTE) callconv(.C) void {
+ var sk = arg_sk;
+ sk_sort(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_ATTRIBUTE_is_sorted(arg_sk: ?*const struct_stack_st_X509_ATTRIBUTE) callconv(.C) c_int {
+ var sk = arg_sk;
+ return sk_is_sorted(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_ATTRIBUTE_set_cmp_func(arg_sk: ?*struct_stack_st_X509_ATTRIBUTE, arg_comp: stack_X509_ATTRIBUTE_cmp_func) callconv(.C) stack_X509_ATTRIBUTE_cmp_func {
+ var sk = arg_sk;
+ var comp = arg_comp;
+ return @ptrCast(stack_X509_ATTRIBUTE_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const X509_ATTRIBUTE, [*c]?*const X509_ATTRIBUTE) callconv(.C) c_int), sk_set_cmp_func(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp)))));
+}
+pub fn sk_X509_ATTRIBUTE_deep_copy(arg_sk: ?*const struct_stack_st_X509_ATTRIBUTE, arg_copy_func: ?fn (?*X509_ATTRIBUTE) callconv(.C) ?*X509_ATTRIBUTE, arg_free_func: ?fn (?*X509_ATTRIBUTE) callconv(.C) void) callconv(.C) ?*struct_stack_st_X509_ATTRIBUTE {
+ var sk = arg_sk;
+ var copy_func = arg_copy_func;
+ var free_func = arg_free_func;
+ return @ptrCast(?*struct_stack_st_X509_ATTRIBUTE, sk_deep_copy(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_X509_ATTRIBUTE_call_copy_func, @ptrCast(stack_copy_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) ?*c_void), copy_func)), sk_X509_ATTRIBUTE_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func))));
+}
+pub const struct_stack_st_DIST_POINT = opaque {};
+pub const stack_X509_free_func = ?fn (?*X509) callconv(.C) void;
+pub const stack_X509_copy_func = ?fn (?*X509) callconv(.C) ?*X509;
+pub const stack_X509_cmp_func = ?fn ([*c]?*const X509, [*c]?*const X509) callconv(.C) c_int;
+pub fn sk_X509_call_free_func(arg_free_func: stack_free_func, arg_ptr: ?*c_void) callconv(.C) void {
+ var free_func = arg_free_func;
+ var ptr = arg_ptr;
+ @ptrCast(stack_X509_free_func, @alignCast(@import("std").meta.alignment(fn (?*X509) callconv(.C) void), free_func)).?(@ptrCast(?*X509, ptr));
+}
+pub fn sk_X509_call_copy_func(arg_copy_func: stack_copy_func, arg_ptr: ?*c_void) callconv(.C) ?*c_void {
+ var copy_func = arg_copy_func;
+ var ptr = arg_ptr;
+ return @ptrCast(?*c_void, @ptrCast(stack_X509_copy_func, @alignCast(@import("std").meta.alignment(fn (?*X509) callconv(.C) ?*X509), copy_func)).?(@ptrCast(?*X509, ptr)));
+}
+pub fn sk_X509_call_cmp_func(arg_cmp_func: stack_cmp_func, arg_a: [*c]?*const c_void, arg_b: [*c]?*const c_void) callconv(.C) c_int {
+ var cmp_func = arg_cmp_func;
+ var a = arg_a;
+ var b = arg_b;
+ var a_ptr: ?*const X509 = @ptrCast(?*const X509, a.*);
+ var b_ptr: ?*const X509 = @ptrCast(?*const X509, b.*);
+ return @ptrCast(stack_X509_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const X509, [*c]?*const X509) callconv(.C) c_int), cmp_func)).?(&a_ptr, &b_ptr);
+}
+pub fn sk_X509_new(arg_comp: stack_X509_cmp_func) callconv(.C) ?*struct_stack_st_X509 {
+ var comp = arg_comp;
+ return @ptrCast(?*struct_stack_st_X509, sk_new(@ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp))));
+}
+pub fn sk_X509_new_null() callconv(.C) ?*struct_stack_st_X509 {
+ return @ptrCast(?*struct_stack_st_X509, sk_new_null());
+}
+pub fn sk_X509_num(arg_sk: ?*const struct_stack_st_X509) callconv(.C) usize {
+ var sk = arg_sk;
+ return sk_num(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_zero(arg_sk: ?*struct_stack_st_X509) callconv(.C) void {
+ var sk = arg_sk;
+ sk_zero(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_value(arg_sk: ?*const struct_stack_st_X509, arg_i: usize) callconv(.C) ?*X509 {
+ var sk = arg_sk;
+ var i = arg_i;
+ return @ptrCast(?*X509, sk_value(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i));
+}
+pub fn sk_X509_set(arg_sk: ?*struct_stack_st_X509, arg_i: usize, arg_p: ?*X509) callconv(.C) ?*X509 {
+ var sk = arg_sk;
+ var i = arg_i;
+ var p = arg_p;
+ return @ptrCast(?*X509, sk_set(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i, @ptrCast(?*c_void, p)));
+}
+pub fn sk_X509_free(arg_sk: ?*struct_stack_st_X509) callconv(.C) void {
+ var sk = arg_sk;
+ sk_free(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_pop_free(arg_sk: ?*struct_stack_st_X509, arg_free_func: stack_X509_free_func) callconv(.C) void {
+ var sk = arg_sk;
+ var free_func = arg_free_func;
+ sk_pop_free_ex(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_X509_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func)));
+}
+pub fn sk_X509_insert(arg_sk: ?*struct_stack_st_X509, arg_p: ?*X509, arg_where: usize) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ var where = arg_where;
+ return sk_insert(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p), where);
+}
+pub fn sk_X509_delete(arg_sk: ?*struct_stack_st_X509, arg_where: usize) callconv(.C) ?*X509 {
+ var sk = arg_sk;
+ var where = arg_where;
+ return @ptrCast(?*X509, sk_delete(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), where));
+}
+pub fn sk_X509_delete_ptr(arg_sk: ?*struct_stack_st_X509, arg_p: ?*const X509) callconv(.C) ?*X509 {
+ var sk = arg_sk;
+ var p = arg_p;
+ return @ptrCast(?*X509, sk_delete_ptr(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*const c_void, p)));
+}
+pub fn sk_X509_find(arg_sk: ?*const struct_stack_st_X509, arg_out_index: [*c]usize, arg_p: ?*const X509) callconv(.C) c_int {
+ var sk = arg_sk;
+ var out_index = arg_out_index;
+ var p = arg_p;
+ return sk_find(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), out_index, @ptrCast(?*const c_void, p), sk_X509_call_cmp_func);
+}
+pub fn sk_X509_shift(arg_sk: ?*struct_stack_st_X509) callconv(.C) ?*X509 {
+ var sk = arg_sk;
+ return @ptrCast(?*X509, sk_shift(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_push(arg_sk: ?*struct_stack_st_X509, arg_p: ?*X509) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ return sk_push(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p));
+}
+pub fn sk_X509_pop(arg_sk: ?*struct_stack_st_X509) callconv(.C) ?*X509 {
+ var sk = arg_sk;
+ return @ptrCast(?*X509, sk_pop(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_dup(arg_sk: ?*const struct_stack_st_X509) callconv(.C) ?*struct_stack_st_X509 {
+ var sk = arg_sk;
+ return @ptrCast(?*struct_stack_st_X509, sk_dup(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_sort(arg_sk: ?*struct_stack_st_X509) callconv(.C) void {
+ var sk = arg_sk;
+ sk_sort(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_is_sorted(arg_sk: ?*const struct_stack_st_X509) callconv(.C) c_int {
+ var sk = arg_sk;
+ return sk_is_sorted(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_set_cmp_func(arg_sk: ?*struct_stack_st_X509, arg_comp: stack_X509_cmp_func) callconv(.C) stack_X509_cmp_func {
+ var sk = arg_sk;
+ var comp = arg_comp;
+ return @ptrCast(stack_X509_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const X509, [*c]?*const X509) callconv(.C) c_int), sk_set_cmp_func(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp)))));
+}
+pub fn sk_X509_deep_copy(arg_sk: ?*const struct_stack_st_X509, arg_copy_func: ?fn (?*X509) callconv(.C) ?*X509, arg_free_func: ?fn (?*X509) callconv(.C) void) callconv(.C) ?*struct_stack_st_X509 {
+ var sk = arg_sk;
+ var copy_func = arg_copy_func;
+ var free_func = arg_free_func;
+ return @ptrCast(?*struct_stack_st_X509, sk_deep_copy(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_X509_call_copy_func, @ptrCast(stack_copy_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) ?*c_void), copy_func)), sk_X509_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func))));
+}
+pub const struct_stack_st_X509_TRUST = opaque {};
+pub const stack_X509_TRUST_free_func = ?fn ([*c]X509_TRUST) callconv(.C) void;
+pub const stack_X509_TRUST_copy_func = ?fn ([*c]X509_TRUST) callconv(.C) [*c]X509_TRUST;
+pub const stack_X509_TRUST_cmp_func = ?fn ([*c][*c]const X509_TRUST, [*c][*c]const X509_TRUST) callconv(.C) c_int;
+pub fn sk_X509_TRUST_call_free_func(arg_free_func: stack_free_func, arg_ptr: ?*c_void) callconv(.C) void {
+ var free_func = arg_free_func;
+ var ptr = arg_ptr;
+ @ptrCast(stack_X509_TRUST_free_func, @alignCast(@import("std").meta.alignment(fn ([*c]X509_TRUST) callconv(.C) void), free_func)).?(@ptrCast([*c]X509_TRUST, @alignCast(@import("std").meta.alignment(X509_TRUST), ptr)));
+}
+pub fn sk_X509_TRUST_call_copy_func(arg_copy_func: stack_copy_func, arg_ptr: ?*c_void) callconv(.C) ?*c_void {
+ var copy_func = arg_copy_func;
+ var ptr = arg_ptr;
+ return @ptrCast(?*c_void, @ptrCast(stack_X509_TRUST_copy_func, @alignCast(@import("std").meta.alignment(fn ([*c]X509_TRUST) callconv(.C) [*c]X509_TRUST), copy_func)).?(@ptrCast([*c]X509_TRUST, @alignCast(@import("std").meta.alignment(X509_TRUST), ptr))));
+}
+pub fn sk_X509_TRUST_call_cmp_func(arg_cmp_func: stack_cmp_func, arg_a: [*c]?*const c_void, arg_b: [*c]?*const c_void) callconv(.C) c_int {
+ var cmp_func = arg_cmp_func;
+ var a = arg_a;
+ var b = arg_b;
+ var a_ptr: [*c]const X509_TRUST = @ptrCast([*c]const X509_TRUST, @alignCast(@import("std").meta.alignment(X509_TRUST), a.*));
+ var b_ptr: [*c]const X509_TRUST = @ptrCast([*c]const X509_TRUST, @alignCast(@import("std").meta.alignment(X509_TRUST), b.*));
+ return @ptrCast(stack_X509_TRUST_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c][*c]const X509_TRUST, [*c][*c]const X509_TRUST) callconv(.C) c_int), cmp_func)).?(&a_ptr, &b_ptr);
+}
+pub fn sk_X509_TRUST_new(arg_comp: stack_X509_TRUST_cmp_func) callconv(.C) ?*struct_stack_st_X509_TRUST {
+ var comp = arg_comp;
+ return @ptrCast(?*struct_stack_st_X509_TRUST, sk_new(@ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp))));
+}
+pub fn sk_X509_TRUST_new_null() callconv(.C) ?*struct_stack_st_X509_TRUST {
+ return @ptrCast(?*struct_stack_st_X509_TRUST, sk_new_null());
+}
+pub fn sk_X509_TRUST_num(arg_sk: ?*const struct_stack_st_X509_TRUST) callconv(.C) usize {
+ var sk = arg_sk;
+ return sk_num(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_TRUST_zero(arg_sk: ?*struct_stack_st_X509_TRUST) callconv(.C) void {
+ var sk = arg_sk;
+ sk_zero(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_TRUST_value(arg_sk: ?*const struct_stack_st_X509_TRUST, arg_i: usize) callconv(.C) [*c]X509_TRUST {
+ var sk = arg_sk;
+ var i = arg_i;
+ return @ptrCast([*c]X509_TRUST, @alignCast(@import("std").meta.alignment(X509_TRUST), sk_value(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i)));
+}
+pub fn sk_X509_TRUST_set(arg_sk: ?*struct_stack_st_X509_TRUST, arg_i: usize, arg_p: [*c]X509_TRUST) callconv(.C) [*c]X509_TRUST {
+ var sk = arg_sk;
+ var i = arg_i;
+ var p = arg_p;
+ return @ptrCast([*c]X509_TRUST, @alignCast(@import("std").meta.alignment(X509_TRUST), sk_set(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i, @ptrCast(?*c_void, p))));
+}
+pub fn sk_X509_TRUST_free(arg_sk: ?*struct_stack_st_X509_TRUST) callconv(.C) void {
+ var sk = arg_sk;
+ sk_free(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_TRUST_pop_free(arg_sk: ?*struct_stack_st_X509_TRUST, arg_free_func: stack_X509_TRUST_free_func) callconv(.C) void {
+ var sk = arg_sk;
+ var free_func = arg_free_func;
+ sk_pop_free_ex(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_X509_TRUST_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func)));
+}
+pub fn sk_X509_TRUST_insert(arg_sk: ?*struct_stack_st_X509_TRUST, arg_p: [*c]X509_TRUST, arg_where: usize) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ var where = arg_where;
+ return sk_insert(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p), where);
+}
+pub fn sk_X509_TRUST_delete(arg_sk: ?*struct_stack_st_X509_TRUST, arg_where: usize) callconv(.C) [*c]X509_TRUST {
+ var sk = arg_sk;
+ var where = arg_where;
+ return @ptrCast([*c]X509_TRUST, @alignCast(@import("std").meta.alignment(X509_TRUST), sk_delete(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), where)));
+}
+pub fn sk_X509_TRUST_delete_ptr(arg_sk: ?*struct_stack_st_X509_TRUST, arg_p: [*c]const X509_TRUST) callconv(.C) [*c]X509_TRUST {
+ var sk = arg_sk;
+ var p = arg_p;
+ return @ptrCast([*c]X509_TRUST, @alignCast(@import("std").meta.alignment(X509_TRUST), sk_delete_ptr(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*const c_void, p))));
+}
+pub fn sk_X509_TRUST_find(arg_sk: ?*const struct_stack_st_X509_TRUST, arg_out_index: [*c]usize, arg_p: [*c]const X509_TRUST) callconv(.C) c_int {
+ var sk = arg_sk;
+ var out_index = arg_out_index;
+ var p = arg_p;
+ return sk_find(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), out_index, @ptrCast(?*const c_void, p), sk_X509_TRUST_call_cmp_func);
+}
+pub fn sk_X509_TRUST_shift(arg_sk: ?*struct_stack_st_X509_TRUST) callconv(.C) [*c]X509_TRUST {
+ var sk = arg_sk;
+ return @ptrCast([*c]X509_TRUST, @alignCast(@import("std").meta.alignment(X509_TRUST), sk_shift(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)))));
+}
+pub fn sk_X509_TRUST_push(arg_sk: ?*struct_stack_st_X509_TRUST, arg_p: [*c]X509_TRUST) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ return sk_push(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p));
+}
+pub fn sk_X509_TRUST_pop(arg_sk: ?*struct_stack_st_X509_TRUST) callconv(.C) [*c]X509_TRUST {
+ var sk = arg_sk;
+ return @ptrCast([*c]X509_TRUST, @alignCast(@import("std").meta.alignment(X509_TRUST), sk_pop(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)))));
+}
+pub fn sk_X509_TRUST_dup(arg_sk: ?*const struct_stack_st_X509_TRUST) callconv(.C) ?*struct_stack_st_X509_TRUST {
+ var sk = arg_sk;
+ return @ptrCast(?*struct_stack_st_X509_TRUST, sk_dup(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_TRUST_sort(arg_sk: ?*struct_stack_st_X509_TRUST) callconv(.C) void {
+ var sk = arg_sk;
+ sk_sort(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_TRUST_is_sorted(arg_sk: ?*const struct_stack_st_X509_TRUST) callconv(.C) c_int {
+ var sk = arg_sk;
+ return sk_is_sorted(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_TRUST_set_cmp_func(arg_sk: ?*struct_stack_st_X509_TRUST, arg_comp: stack_X509_TRUST_cmp_func) callconv(.C) stack_X509_TRUST_cmp_func {
+ var sk = arg_sk;
+ var comp = arg_comp;
+ return @ptrCast(stack_X509_TRUST_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c][*c]const X509_TRUST, [*c][*c]const X509_TRUST) callconv(.C) c_int), sk_set_cmp_func(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp)))));
+}
+pub fn sk_X509_TRUST_deep_copy(arg_sk: ?*const struct_stack_st_X509_TRUST, arg_copy_func: ?fn ([*c]X509_TRUST) callconv(.C) [*c]X509_TRUST, arg_free_func: ?fn ([*c]X509_TRUST) callconv(.C) void) callconv(.C) ?*struct_stack_st_X509_TRUST {
+ var sk = arg_sk;
+ var copy_func = arg_copy_func;
+ var free_func = arg_free_func;
+ return @ptrCast(?*struct_stack_st_X509_TRUST, sk_deep_copy(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_X509_TRUST_call_copy_func, @ptrCast(stack_copy_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) ?*c_void), copy_func)), sk_X509_TRUST_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func))));
+}
+pub const struct_stack_st_X509_REVOKED = opaque {};
+pub const stack_X509_REVOKED_free_func = ?fn ([*c]X509_REVOKED) callconv(.C) void;
+pub const stack_X509_REVOKED_copy_func = ?fn ([*c]X509_REVOKED) callconv(.C) [*c]X509_REVOKED;
+pub const stack_X509_REVOKED_cmp_func = ?fn ([*c][*c]const X509_REVOKED, [*c][*c]const X509_REVOKED) callconv(.C) c_int;
+pub fn sk_X509_REVOKED_call_free_func(arg_free_func: stack_free_func, arg_ptr: ?*c_void) callconv(.C) void {
+ var free_func = arg_free_func;
+ var ptr = arg_ptr;
+ @ptrCast(stack_X509_REVOKED_free_func, @alignCast(@import("std").meta.alignment(fn ([*c]X509_REVOKED) callconv(.C) void), free_func)).?(@ptrCast([*c]X509_REVOKED, @alignCast(@import("std").meta.alignment(X509_REVOKED), ptr)));
+}
+pub fn sk_X509_REVOKED_call_copy_func(arg_copy_func: stack_copy_func, arg_ptr: ?*c_void) callconv(.C) ?*c_void {
+ var copy_func = arg_copy_func;
+ var ptr = arg_ptr;
+ return @ptrCast(?*c_void, @ptrCast(stack_X509_REVOKED_copy_func, @alignCast(@import("std").meta.alignment(fn ([*c]X509_REVOKED) callconv(.C) [*c]X509_REVOKED), copy_func)).?(@ptrCast([*c]X509_REVOKED, @alignCast(@import("std").meta.alignment(X509_REVOKED), ptr))));
+}
+pub fn sk_X509_REVOKED_call_cmp_func(arg_cmp_func: stack_cmp_func, arg_a: [*c]?*const c_void, arg_b: [*c]?*const c_void) callconv(.C) c_int {
+ var cmp_func = arg_cmp_func;
+ var a = arg_a;
+ var b = arg_b;
+ var a_ptr: [*c]const X509_REVOKED = @ptrCast([*c]const X509_REVOKED, @alignCast(@import("std").meta.alignment(X509_REVOKED), a.*));
+ var b_ptr: [*c]const X509_REVOKED = @ptrCast([*c]const X509_REVOKED, @alignCast(@import("std").meta.alignment(X509_REVOKED), b.*));
+ return @ptrCast(stack_X509_REVOKED_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c][*c]const X509_REVOKED, [*c][*c]const X509_REVOKED) callconv(.C) c_int), cmp_func)).?(&a_ptr, &b_ptr);
+}
+pub fn sk_X509_REVOKED_new(arg_comp: stack_X509_REVOKED_cmp_func) callconv(.C) ?*struct_stack_st_X509_REVOKED {
+ var comp = arg_comp;
+ return @ptrCast(?*struct_stack_st_X509_REVOKED, sk_new(@ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp))));
+}
+pub fn sk_X509_REVOKED_new_null() callconv(.C) ?*struct_stack_st_X509_REVOKED {
+ return @ptrCast(?*struct_stack_st_X509_REVOKED, sk_new_null());
+}
+pub fn sk_X509_REVOKED_num(arg_sk: ?*const struct_stack_st_X509_REVOKED) callconv(.C) usize {
+ var sk = arg_sk;
+ return sk_num(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_REVOKED_zero(arg_sk: ?*struct_stack_st_X509_REVOKED) callconv(.C) void {
+ var sk = arg_sk;
+ sk_zero(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_REVOKED_value(arg_sk: ?*const struct_stack_st_X509_REVOKED, arg_i: usize) callconv(.C) [*c]X509_REVOKED {
+ var sk = arg_sk;
+ var i = arg_i;
+ return @ptrCast([*c]X509_REVOKED, @alignCast(@import("std").meta.alignment(X509_REVOKED), sk_value(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i)));
+}
+pub fn sk_X509_REVOKED_set(arg_sk: ?*struct_stack_st_X509_REVOKED, arg_i: usize, arg_p: [*c]X509_REVOKED) callconv(.C) [*c]X509_REVOKED {
+ var sk = arg_sk;
+ var i = arg_i;
+ var p = arg_p;
+ return @ptrCast([*c]X509_REVOKED, @alignCast(@import("std").meta.alignment(X509_REVOKED), sk_set(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i, @ptrCast(?*c_void, p))));
+}
+pub fn sk_X509_REVOKED_free(arg_sk: ?*struct_stack_st_X509_REVOKED) callconv(.C) void {
+ var sk = arg_sk;
+ sk_free(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_REVOKED_pop_free(arg_sk: ?*struct_stack_st_X509_REVOKED, arg_free_func: stack_X509_REVOKED_free_func) callconv(.C) void {
+ var sk = arg_sk;
+ var free_func = arg_free_func;
+ sk_pop_free_ex(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_X509_REVOKED_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func)));
+}
+pub fn sk_X509_REVOKED_insert(arg_sk: ?*struct_stack_st_X509_REVOKED, arg_p: [*c]X509_REVOKED, arg_where: usize) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ var where = arg_where;
+ return sk_insert(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p), where);
+}
+pub fn sk_X509_REVOKED_delete(arg_sk: ?*struct_stack_st_X509_REVOKED, arg_where: usize) callconv(.C) [*c]X509_REVOKED {
+ var sk = arg_sk;
+ var where = arg_where;
+ return @ptrCast([*c]X509_REVOKED, @alignCast(@import("std").meta.alignment(X509_REVOKED), sk_delete(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), where)));
+}
+pub fn sk_X509_REVOKED_delete_ptr(arg_sk: ?*struct_stack_st_X509_REVOKED, arg_p: [*c]const X509_REVOKED) callconv(.C) [*c]X509_REVOKED {
+ var sk = arg_sk;
+ var p = arg_p;
+ return @ptrCast([*c]X509_REVOKED, @alignCast(@import("std").meta.alignment(X509_REVOKED), sk_delete_ptr(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*const c_void, p))));
+}
+pub fn sk_X509_REVOKED_find(arg_sk: ?*const struct_stack_st_X509_REVOKED, arg_out_index: [*c]usize, arg_p: [*c]const X509_REVOKED) callconv(.C) c_int {
+ var sk = arg_sk;
+ var out_index = arg_out_index;
+ var p = arg_p;
+ return sk_find(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), out_index, @ptrCast(?*const c_void, p), sk_X509_REVOKED_call_cmp_func);
+}
+pub fn sk_X509_REVOKED_shift(arg_sk: ?*struct_stack_st_X509_REVOKED) callconv(.C) [*c]X509_REVOKED {
+ var sk = arg_sk;
+ return @ptrCast([*c]X509_REVOKED, @alignCast(@import("std").meta.alignment(X509_REVOKED), sk_shift(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)))));
+}
+pub fn sk_X509_REVOKED_push(arg_sk: ?*struct_stack_st_X509_REVOKED, arg_p: [*c]X509_REVOKED) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ return sk_push(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p));
+}
+pub fn sk_X509_REVOKED_pop(arg_sk: ?*struct_stack_st_X509_REVOKED) callconv(.C) [*c]X509_REVOKED {
+ var sk = arg_sk;
+ return @ptrCast([*c]X509_REVOKED, @alignCast(@import("std").meta.alignment(X509_REVOKED), sk_pop(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)))));
+}
+pub fn sk_X509_REVOKED_dup(arg_sk: ?*const struct_stack_st_X509_REVOKED) callconv(.C) ?*struct_stack_st_X509_REVOKED {
+ var sk = arg_sk;
+ return @ptrCast(?*struct_stack_st_X509_REVOKED, sk_dup(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_REVOKED_sort(arg_sk: ?*struct_stack_st_X509_REVOKED) callconv(.C) void {
+ var sk = arg_sk;
+ sk_sort(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_REVOKED_is_sorted(arg_sk: ?*const struct_stack_st_X509_REVOKED) callconv(.C) c_int {
+ var sk = arg_sk;
+ return sk_is_sorted(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_REVOKED_set_cmp_func(arg_sk: ?*struct_stack_st_X509_REVOKED, arg_comp: stack_X509_REVOKED_cmp_func) callconv(.C) stack_X509_REVOKED_cmp_func {
+ var sk = arg_sk;
+ var comp = arg_comp;
+ return @ptrCast(stack_X509_REVOKED_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c][*c]const X509_REVOKED, [*c][*c]const X509_REVOKED) callconv(.C) c_int), sk_set_cmp_func(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp)))));
+}
+pub fn sk_X509_REVOKED_deep_copy(arg_sk: ?*const struct_stack_st_X509_REVOKED, arg_copy_func: ?fn ([*c]X509_REVOKED) callconv(.C) [*c]X509_REVOKED, arg_free_func: ?fn ([*c]X509_REVOKED) callconv(.C) void) callconv(.C) ?*struct_stack_st_X509_REVOKED {
+ var sk = arg_sk;
+ var copy_func = arg_copy_func;
+ var free_func = arg_free_func;
+ return @ptrCast(?*struct_stack_st_X509_REVOKED, sk_deep_copy(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_X509_REVOKED_call_copy_func, @ptrCast(stack_copy_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) ?*c_void), copy_func)), sk_X509_REVOKED_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func))));
+}
+pub const struct_stack_st_GENERAL_NAMES = opaque {};
+pub const stack_X509_CRL_free_func = ?fn (?*X509_CRL) callconv(.C) void;
+pub const stack_X509_CRL_copy_func = ?fn (?*X509_CRL) callconv(.C) ?*X509_CRL;
+pub const stack_X509_CRL_cmp_func = ?fn ([*c]?*const X509_CRL, [*c]?*const X509_CRL) callconv(.C) c_int;
+pub fn sk_X509_CRL_call_free_func(arg_free_func: stack_free_func, arg_ptr: ?*c_void) callconv(.C) void {
+ var free_func = arg_free_func;
+ var ptr = arg_ptr;
+ @ptrCast(stack_X509_CRL_free_func, @alignCast(@import("std").meta.alignment(fn (?*X509_CRL) callconv(.C) void), free_func)).?(@ptrCast(?*X509_CRL, ptr));
+}
+pub fn sk_X509_CRL_call_copy_func(arg_copy_func: stack_copy_func, arg_ptr: ?*c_void) callconv(.C) ?*c_void {
+ var copy_func = arg_copy_func;
+ var ptr = arg_ptr;
+ return @ptrCast(?*c_void, @ptrCast(stack_X509_CRL_copy_func, @alignCast(@import("std").meta.alignment(fn (?*X509_CRL) callconv(.C) ?*X509_CRL), copy_func)).?(@ptrCast(?*X509_CRL, ptr)));
+}
+pub fn sk_X509_CRL_call_cmp_func(arg_cmp_func: stack_cmp_func, arg_a: [*c]?*const c_void, arg_b: [*c]?*const c_void) callconv(.C) c_int {
+ var cmp_func = arg_cmp_func;
+ var a = arg_a;
+ var b = arg_b;
+ var a_ptr: ?*const X509_CRL = @ptrCast(?*const X509_CRL, a.*);
+ var b_ptr: ?*const X509_CRL = @ptrCast(?*const X509_CRL, b.*);
+ return @ptrCast(stack_X509_CRL_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const X509_CRL, [*c]?*const X509_CRL) callconv(.C) c_int), cmp_func)).?(&a_ptr, &b_ptr);
+}
+pub fn sk_X509_CRL_new(arg_comp: stack_X509_CRL_cmp_func) callconv(.C) ?*struct_stack_st_X509_CRL {
+ var comp = arg_comp;
+ return @ptrCast(?*struct_stack_st_X509_CRL, sk_new(@ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp))));
+}
+pub fn sk_X509_CRL_new_null() callconv(.C) ?*struct_stack_st_X509_CRL {
+ return @ptrCast(?*struct_stack_st_X509_CRL, sk_new_null());
+}
+pub fn sk_X509_CRL_num(arg_sk: ?*const struct_stack_st_X509_CRL) callconv(.C) usize {
+ var sk = arg_sk;
+ return sk_num(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_CRL_zero(arg_sk: ?*struct_stack_st_X509_CRL) callconv(.C) void {
+ var sk = arg_sk;
+ sk_zero(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_CRL_value(arg_sk: ?*const struct_stack_st_X509_CRL, arg_i: usize) callconv(.C) ?*X509_CRL {
+ var sk = arg_sk;
+ var i = arg_i;
+ return @ptrCast(?*X509_CRL, sk_value(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i));
+}
+pub fn sk_X509_CRL_set(arg_sk: ?*struct_stack_st_X509_CRL, arg_i: usize, arg_p: ?*X509_CRL) callconv(.C) ?*X509_CRL {
+ var sk = arg_sk;
+ var i = arg_i;
+ var p = arg_p;
+ return @ptrCast(?*X509_CRL, sk_set(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i, @ptrCast(?*c_void, p)));
+}
+pub fn sk_X509_CRL_free(arg_sk: ?*struct_stack_st_X509_CRL) callconv(.C) void {
+ var sk = arg_sk;
+ sk_free(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_CRL_pop_free(arg_sk: ?*struct_stack_st_X509_CRL, arg_free_func: stack_X509_CRL_free_func) callconv(.C) void {
+ var sk = arg_sk;
+ var free_func = arg_free_func;
+ sk_pop_free_ex(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_X509_CRL_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func)));
+}
+pub fn sk_X509_CRL_insert(arg_sk: ?*struct_stack_st_X509_CRL, arg_p: ?*X509_CRL, arg_where: usize) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ var where = arg_where;
+ return sk_insert(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p), where);
+}
+pub fn sk_X509_CRL_delete(arg_sk: ?*struct_stack_st_X509_CRL, arg_where: usize) callconv(.C) ?*X509_CRL {
+ var sk = arg_sk;
+ var where = arg_where;
+ return @ptrCast(?*X509_CRL, sk_delete(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), where));
+}
+pub fn sk_X509_CRL_delete_ptr(arg_sk: ?*struct_stack_st_X509_CRL, arg_p: ?*const X509_CRL) callconv(.C) ?*X509_CRL {
+ var sk = arg_sk;
+ var p = arg_p;
+ return @ptrCast(?*X509_CRL, sk_delete_ptr(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*const c_void, p)));
+}
+pub fn sk_X509_CRL_find(arg_sk: ?*const struct_stack_st_X509_CRL, arg_out_index: [*c]usize, arg_p: ?*const X509_CRL) callconv(.C) c_int {
+ var sk = arg_sk;
+ var out_index = arg_out_index;
+ var p = arg_p;
+ return sk_find(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), out_index, @ptrCast(?*const c_void, p), sk_X509_CRL_call_cmp_func);
+}
+pub fn sk_X509_CRL_shift(arg_sk: ?*struct_stack_st_X509_CRL) callconv(.C) ?*X509_CRL {
+ var sk = arg_sk;
+ return @ptrCast(?*X509_CRL, sk_shift(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_CRL_push(arg_sk: ?*struct_stack_st_X509_CRL, arg_p: ?*X509_CRL) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ return sk_push(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p));
+}
+pub fn sk_X509_CRL_pop(arg_sk: ?*struct_stack_st_X509_CRL) callconv(.C) ?*X509_CRL {
+ var sk = arg_sk;
+ return @ptrCast(?*X509_CRL, sk_pop(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_CRL_dup(arg_sk: ?*const struct_stack_st_X509_CRL) callconv(.C) ?*struct_stack_st_X509_CRL {
+ var sk = arg_sk;
+ return @ptrCast(?*struct_stack_st_X509_CRL, sk_dup(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_CRL_sort(arg_sk: ?*struct_stack_st_X509_CRL) callconv(.C) void {
+ var sk = arg_sk;
+ sk_sort(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_CRL_is_sorted(arg_sk: ?*const struct_stack_st_X509_CRL) callconv(.C) c_int {
+ var sk = arg_sk;
+ return sk_is_sorted(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_CRL_set_cmp_func(arg_sk: ?*struct_stack_st_X509_CRL, arg_comp: stack_X509_CRL_cmp_func) callconv(.C) stack_X509_CRL_cmp_func {
+ var sk = arg_sk;
+ var comp = arg_comp;
+ return @ptrCast(stack_X509_CRL_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const X509_CRL, [*c]?*const X509_CRL) callconv(.C) c_int), sk_set_cmp_func(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp)))));
+}
+pub fn sk_X509_CRL_deep_copy(arg_sk: ?*const struct_stack_st_X509_CRL, arg_copy_func: ?fn (?*X509_CRL) callconv(.C) ?*X509_CRL, arg_free_func: ?fn (?*X509_CRL) callconv(.C) void) callconv(.C) ?*struct_stack_st_X509_CRL {
+ var sk = arg_sk;
+ var copy_func = arg_copy_func;
+ var free_func = arg_free_func;
+ return @ptrCast(?*struct_stack_st_X509_CRL, sk_deep_copy(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_X509_CRL_call_copy_func, @ptrCast(stack_copy_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) ?*c_void), copy_func)), sk_X509_CRL_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func))));
+}
+pub const struct_stack_st_X509_INFO = opaque {};
+pub const stack_X509_INFO_free_func = ?fn ([*c]X509_INFO) callconv(.C) void;
+pub const stack_X509_INFO_copy_func = ?fn ([*c]X509_INFO) callconv(.C) [*c]X509_INFO;
+pub const stack_X509_INFO_cmp_func = ?fn ([*c][*c]const X509_INFO, [*c][*c]const X509_INFO) callconv(.C) c_int;
+pub fn sk_X509_INFO_call_free_func(arg_free_func: stack_free_func, arg_ptr: ?*c_void) callconv(.C) void {
+ var free_func = arg_free_func;
+ var ptr = arg_ptr;
+ @ptrCast(stack_X509_INFO_free_func, @alignCast(@import("std").meta.alignment(fn ([*c]X509_INFO) callconv(.C) void), free_func)).?(@ptrCast([*c]X509_INFO, @alignCast(@import("std").meta.alignment(X509_INFO), ptr)));
+}
+pub fn sk_X509_INFO_call_copy_func(arg_copy_func: stack_copy_func, arg_ptr: ?*c_void) callconv(.C) ?*c_void {
+ var copy_func = arg_copy_func;
+ var ptr = arg_ptr;
+ return @ptrCast(?*c_void, @ptrCast(stack_X509_INFO_copy_func, @alignCast(@import("std").meta.alignment(fn ([*c]X509_INFO) callconv(.C) [*c]X509_INFO), copy_func)).?(@ptrCast([*c]X509_INFO, @alignCast(@import("std").meta.alignment(X509_INFO), ptr))));
+}
+pub fn sk_X509_INFO_call_cmp_func(arg_cmp_func: stack_cmp_func, arg_a: [*c]?*const c_void, arg_b: [*c]?*const c_void) callconv(.C) c_int {
+ var cmp_func = arg_cmp_func;
+ var a = arg_a;
+ var b = arg_b;
+ var a_ptr: [*c]const X509_INFO = @ptrCast([*c]const X509_INFO, @alignCast(@import("std").meta.alignment(X509_INFO), a.*));
+ var b_ptr: [*c]const X509_INFO = @ptrCast([*c]const X509_INFO, @alignCast(@import("std").meta.alignment(X509_INFO), b.*));
+ return @ptrCast(stack_X509_INFO_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c][*c]const X509_INFO, [*c][*c]const X509_INFO) callconv(.C) c_int), cmp_func)).?(&a_ptr, &b_ptr);
+}
+pub fn sk_X509_INFO_new(arg_comp: stack_X509_INFO_cmp_func) callconv(.C) ?*struct_stack_st_X509_INFO {
+ var comp = arg_comp;
+ return @ptrCast(?*struct_stack_st_X509_INFO, sk_new(@ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp))));
+}
+pub fn sk_X509_INFO_new_null() callconv(.C) ?*struct_stack_st_X509_INFO {
+ return @ptrCast(?*struct_stack_st_X509_INFO, sk_new_null());
+}
+pub fn sk_X509_INFO_num(arg_sk: ?*const struct_stack_st_X509_INFO) callconv(.C) usize {
+ var sk = arg_sk;
+ return sk_num(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_INFO_zero(arg_sk: ?*struct_stack_st_X509_INFO) callconv(.C) void {
+ var sk = arg_sk;
+ sk_zero(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_INFO_value(arg_sk: ?*const struct_stack_st_X509_INFO, arg_i: usize) callconv(.C) [*c]X509_INFO {
+ var sk = arg_sk;
+ var i = arg_i;
+ return @ptrCast([*c]X509_INFO, @alignCast(@import("std").meta.alignment(X509_INFO), sk_value(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i)));
+}
+pub fn sk_X509_INFO_set(arg_sk: ?*struct_stack_st_X509_INFO, arg_i: usize, arg_p: [*c]X509_INFO) callconv(.C) [*c]X509_INFO {
+ var sk = arg_sk;
+ var i = arg_i;
+ var p = arg_p;
+ return @ptrCast([*c]X509_INFO, @alignCast(@import("std").meta.alignment(X509_INFO), sk_set(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i, @ptrCast(?*c_void, p))));
+}
+pub fn sk_X509_INFO_free(arg_sk: ?*struct_stack_st_X509_INFO) callconv(.C) void {
+ var sk = arg_sk;
+ sk_free(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_INFO_pop_free(arg_sk: ?*struct_stack_st_X509_INFO, arg_free_func: stack_X509_INFO_free_func) callconv(.C) void {
+ var sk = arg_sk;
+ var free_func = arg_free_func;
+ sk_pop_free_ex(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_X509_INFO_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func)));
+}
+pub fn sk_X509_INFO_insert(arg_sk: ?*struct_stack_st_X509_INFO, arg_p: [*c]X509_INFO, arg_where: usize) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ var where = arg_where;
+ return sk_insert(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p), where);
+}
+pub fn sk_X509_INFO_delete(arg_sk: ?*struct_stack_st_X509_INFO, arg_where: usize) callconv(.C) [*c]X509_INFO {
+ var sk = arg_sk;
+ var where = arg_where;
+ return @ptrCast([*c]X509_INFO, @alignCast(@import("std").meta.alignment(X509_INFO), sk_delete(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), where)));
+}
+pub fn sk_X509_INFO_delete_ptr(arg_sk: ?*struct_stack_st_X509_INFO, arg_p: [*c]const X509_INFO) callconv(.C) [*c]X509_INFO {
+ var sk = arg_sk;
+ var p = arg_p;
+ return @ptrCast([*c]X509_INFO, @alignCast(@import("std").meta.alignment(X509_INFO), sk_delete_ptr(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*const c_void, p))));
+}
+pub fn sk_X509_INFO_find(arg_sk: ?*const struct_stack_st_X509_INFO, arg_out_index: [*c]usize, arg_p: [*c]const X509_INFO) callconv(.C) c_int {
+ var sk = arg_sk;
+ var out_index = arg_out_index;
+ var p = arg_p;
+ return sk_find(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), out_index, @ptrCast(?*const c_void, p), sk_X509_INFO_call_cmp_func);
+}
+pub fn sk_X509_INFO_shift(arg_sk: ?*struct_stack_st_X509_INFO) callconv(.C) [*c]X509_INFO {
+ var sk = arg_sk;
+ return @ptrCast([*c]X509_INFO, @alignCast(@import("std").meta.alignment(X509_INFO), sk_shift(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)))));
+}
+pub fn sk_X509_INFO_push(arg_sk: ?*struct_stack_st_X509_INFO, arg_p: [*c]X509_INFO) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ return sk_push(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p));
+}
+pub fn sk_X509_INFO_pop(arg_sk: ?*struct_stack_st_X509_INFO) callconv(.C) [*c]X509_INFO {
+ var sk = arg_sk;
+ return @ptrCast([*c]X509_INFO, @alignCast(@import("std").meta.alignment(X509_INFO), sk_pop(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)))));
+}
+pub fn sk_X509_INFO_dup(arg_sk: ?*const struct_stack_st_X509_INFO) callconv(.C) ?*struct_stack_st_X509_INFO {
+ var sk = arg_sk;
+ return @ptrCast(?*struct_stack_st_X509_INFO, sk_dup(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_INFO_sort(arg_sk: ?*struct_stack_st_X509_INFO) callconv(.C) void {
+ var sk = arg_sk;
+ sk_sort(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_INFO_is_sorted(arg_sk: ?*const struct_stack_st_X509_INFO) callconv(.C) c_int {
+ var sk = arg_sk;
+ return sk_is_sorted(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_INFO_set_cmp_func(arg_sk: ?*struct_stack_st_X509_INFO, arg_comp: stack_X509_INFO_cmp_func) callconv(.C) stack_X509_INFO_cmp_func {
+ var sk = arg_sk;
+ var comp = arg_comp;
+ return @ptrCast(stack_X509_INFO_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c][*c]const X509_INFO, [*c][*c]const X509_INFO) callconv(.C) c_int), sk_set_cmp_func(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp)))));
+}
+pub fn sk_X509_INFO_deep_copy(arg_sk: ?*const struct_stack_st_X509_INFO, arg_copy_func: ?fn ([*c]X509_INFO) callconv(.C) [*c]X509_INFO, arg_free_func: ?fn ([*c]X509_INFO) callconv(.C) void) callconv(.C) ?*struct_stack_st_X509_INFO {
+ var sk = arg_sk;
+ var copy_func = arg_copy_func;
+ var free_func = arg_free_func;
+ return @ptrCast(?*struct_stack_st_X509_INFO, sk_deep_copy(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_X509_INFO_call_copy_func, @ptrCast(stack_copy_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) ?*c_void), copy_func)), sk_X509_INFO_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func))));
+}
+pub extern fn X509_get_version(x509: ?*const X509) c_long;
+pub extern fn X509_set_version(x509: ?*X509, version: c_long) c_int;
+pub extern fn X509_get0_serialNumber(x509: ?*const X509) [*c]const ASN1_INTEGER;
+pub extern fn X509_set_serialNumber(x509: ?*X509, serial: [*c]const ASN1_INTEGER) c_int;
+pub extern fn X509_get0_notBefore(x509: ?*const X509) [*c]const ASN1_TIME;
+pub extern fn X509_get0_notAfter(x509: ?*const X509) [*c]const ASN1_TIME;
+pub extern fn X509_set1_notBefore(x509: ?*X509, tm: [*c]const ASN1_TIME) c_int;
+pub extern fn X509_set1_notAfter(x509: ?*X509, tm: [*c]const ASN1_TIME) c_int;
+pub extern fn X509_getm_notBefore(x509: ?*X509) [*c]ASN1_TIME;
+pub extern fn X509_getm_notAfter(x: ?*X509) [*c]ASN1_TIME;
+pub extern fn X509_get_notBefore(x509: ?*const X509) [*c]ASN1_TIME;
+pub extern fn X509_get_notAfter(x509: ?*const X509) [*c]ASN1_TIME;
+pub extern fn X509_set_notBefore(x509: ?*X509, tm: [*c]const ASN1_TIME) c_int;
+pub extern fn X509_set_notAfter(x509: ?*X509, tm: [*c]const ASN1_TIME) c_int;
+pub extern fn X509_get0_uids(x509: ?*const X509, out_issuer_uid: [*c][*c]const ASN1_BIT_STRING, out_subject_uid: [*c][*c]const ASN1_BIT_STRING) void;
+pub extern fn X509_get_pathlen(x509: ?*X509) c_long;
+pub extern fn X509_REQ_get_version(req: ?*const X509_REQ) c_long;
+pub extern fn X509_REQ_get_subject_name(req: ?*const X509_REQ) ?*X509_NAME;
+pub extern fn X509_CRL_get_version(crl: ?*const X509_CRL) c_long;
+pub extern fn X509_CRL_get0_lastUpdate(crl: ?*const X509_CRL) [*c]const ASN1_TIME;
+pub extern fn X509_CRL_get0_nextUpdate(crl: ?*const X509_CRL) [*c]const ASN1_TIME;
+pub extern fn X509_CRL_set1_lastUpdate(crl: ?*X509_CRL, tm: [*c]const ASN1_TIME) c_int;
+pub extern fn X509_CRL_set1_nextUpdate(crl: ?*X509_CRL, tm: [*c]const ASN1_TIME) c_int;
+pub extern fn X509_CRL_get_lastUpdate(crl: ?*X509_CRL) [*c]ASN1_TIME;
+pub extern fn X509_CRL_get_nextUpdate(crl: ?*X509_CRL) [*c]ASN1_TIME;
+pub extern fn X509_CRL_get_issuer(crl: ?*const X509_CRL) ?*X509_NAME;
+pub extern fn X509_CRL_get_REVOKED(crl: ?*X509_CRL) ?*struct_stack_st_X509_REVOKED;
+pub extern fn X509_CRL_get0_extensions(crl: ?*const X509_CRL) ?*const struct_stack_st_X509_EXTENSION;
+pub extern fn X509_SIG_get0(sig: ?*const X509_SIG, out_alg: [*c][*c]const X509_ALGOR, out_digest: [*c][*c]const ASN1_OCTET_STRING) void;
+pub extern fn X509_SIG_getm(sig: ?*X509_SIG, out_alg: [*c][*c]X509_ALGOR, out_digest: [*c][*c]ASN1_OCTET_STRING) void;
+pub extern fn X509_CRL_set_default_method(meth: ?*const X509_CRL_METHOD) void;
+pub extern fn X509_CRL_METHOD_new(crl_init: ?fn (?*X509_CRL) callconv(.C) c_int, crl_free: ?fn (?*X509_CRL) callconv(.C) c_int, crl_lookup: ?fn (?*X509_CRL, [*c][*c]X509_REVOKED, [*c]ASN1_INTEGER, ?*X509_NAME) callconv(.C) c_int, crl_verify: ?fn (?*X509_CRL, [*c]EVP_PKEY) callconv(.C) c_int) ?*X509_CRL_METHOD;
+pub extern fn X509_CRL_METHOD_free(m: ?*X509_CRL_METHOD) void;
+pub extern fn X509_CRL_set_meth_data(crl: ?*X509_CRL, dat: ?*c_void) void;
+pub extern fn X509_CRL_get_meth_data(crl: ?*X509_CRL) ?*c_void;
+pub extern fn X509_get_X509_PUBKEY(x509: ?*const X509) ?*X509_PUBKEY;
+pub extern fn X509_verify_cert_error_string(err: c_long) [*c]const u8;
+pub extern fn X509_verify(x509: ?*X509, pkey: [*c]EVP_PKEY) c_int;
+pub extern fn X509_REQ_verify(req: ?*X509_REQ, pkey: [*c]EVP_PKEY) c_int;
+pub extern fn X509_CRL_verify(crl: ?*X509_CRL, pkey: [*c]EVP_PKEY) c_int;
+pub extern fn NETSCAPE_SPKI_verify(spki: [*c]NETSCAPE_SPKI, pkey: [*c]EVP_PKEY) c_int;
+pub extern fn NETSCAPE_SPKI_b64_decode(str: [*c]const u8, len: c_int) [*c]NETSCAPE_SPKI;
+pub extern fn NETSCAPE_SPKI_b64_encode(spki: [*c]NETSCAPE_SPKI) [*c]u8;
+pub extern fn NETSCAPE_SPKI_get_pubkey(spki: [*c]NETSCAPE_SPKI) [*c]EVP_PKEY;
+pub extern fn NETSCAPE_SPKI_set_pubkey(spki: [*c]NETSCAPE_SPKI, pkey: [*c]EVP_PKEY) c_int;
+pub extern fn X509_signature_dump(bio: [*c]BIO, sig: [*c]const ASN1_STRING, indent: c_int) c_int;
+pub extern fn X509_signature_print(bio: [*c]BIO, alg: [*c]const X509_ALGOR, sig: [*c]const ASN1_STRING) c_int;
+pub extern fn X509_sign(x509: ?*X509, pkey: [*c]EVP_PKEY, md: ?*const EVP_MD) c_int;
+pub extern fn X509_sign_ctx(x509: ?*X509, ctx: [*c]EVP_MD_CTX) c_int;
+pub extern fn X509_REQ_sign(req: ?*X509_REQ, pkey: [*c]EVP_PKEY, md: ?*const EVP_MD) c_int;
+pub extern fn X509_REQ_sign_ctx(req: ?*X509_REQ, ctx: [*c]EVP_MD_CTX) c_int;
+pub extern fn X509_CRL_sign(crl: ?*X509_CRL, pkey: [*c]EVP_PKEY, md: ?*const EVP_MD) c_int;
+pub extern fn X509_CRL_sign_ctx(crl: ?*X509_CRL, ctx: [*c]EVP_MD_CTX) c_int;
+pub extern fn NETSCAPE_SPKI_sign(spki: [*c]NETSCAPE_SPKI, pkey: [*c]EVP_PKEY, md: ?*const EVP_MD) c_int;
+pub extern fn X509_pubkey_digest(x509: ?*const X509, md: ?*const EVP_MD, out: [*c]u8, out_len: [*c]c_uint) c_int;
+pub extern fn X509_digest(x509: ?*const X509, md: ?*const EVP_MD, out: [*c]u8, out_len: [*c]c_uint) c_int;
+pub extern fn X509_CRL_digest(crl: ?*const X509_CRL, md: ?*const EVP_MD, out: [*c]u8, out_len: [*c]c_uint) c_int;
+pub extern fn X509_REQ_digest(req: ?*const X509_REQ, md: ?*const EVP_MD, out: [*c]u8, out_len: [*c]c_uint) c_int;
+pub extern fn X509_NAME_digest(name: ?*const X509_NAME, md: ?*const EVP_MD, out: [*c]u8, out_len: [*c]c_uint) c_int;
+pub extern fn X509_parse_from_buffer(buf: ?*CRYPTO_BUFFER) ?*X509;
+pub extern fn d2i_X509_fp(fp: [*c]FILE, x509: [*c]?*X509) ?*X509;
+pub extern fn i2d_X509_fp(fp: [*c]FILE, x509: ?*X509) c_int;
+pub extern fn d2i_X509_CRL_fp(fp: [*c]FILE, crl: [*c]?*X509_CRL) ?*X509_CRL;
+pub extern fn i2d_X509_CRL_fp(fp: [*c]FILE, crl: ?*X509_CRL) c_int;
+pub extern fn d2i_X509_REQ_fp(fp: [*c]FILE, req: [*c]?*X509_REQ) ?*X509_REQ;
+pub extern fn i2d_X509_REQ_fp(fp: [*c]FILE, req: ?*X509_REQ) c_int;
+pub extern fn d2i_RSAPrivateKey_fp(fp: [*c]FILE, rsa: [*c]?*RSA) ?*RSA;
+pub extern fn i2d_RSAPrivateKey_fp(fp: [*c]FILE, rsa: ?*RSA) c_int;
+pub extern fn d2i_RSAPublicKey_fp(fp: [*c]FILE, rsa: [*c]?*RSA) ?*RSA;
+pub extern fn i2d_RSAPublicKey_fp(fp: [*c]FILE, rsa: ?*RSA) c_int;
+pub extern fn d2i_RSA_PUBKEY_fp(fp: [*c]FILE, rsa: [*c]?*RSA) ?*RSA;
+pub extern fn i2d_RSA_PUBKEY_fp(fp: [*c]FILE, rsa: ?*RSA) c_int;
+pub extern fn d2i_DSA_PUBKEY_fp(fp: [*c]FILE, dsa: [*c][*c]DSA) [*c]DSA;
+pub extern fn i2d_DSA_PUBKEY_fp(fp: [*c]FILE, dsa: [*c]DSA) c_int;
+pub extern fn d2i_DSAPrivateKey_fp(fp: [*c]FILE, dsa: [*c][*c]DSA) [*c]DSA;
+pub extern fn i2d_DSAPrivateKey_fp(fp: [*c]FILE, dsa: [*c]DSA) c_int;
+pub extern fn d2i_EC_PUBKEY_fp(fp: [*c]FILE, eckey: [*c]?*EC_KEY) ?*EC_KEY;
+pub extern fn i2d_EC_PUBKEY_fp(fp: [*c]FILE, eckey: ?*EC_KEY) c_int;
+pub extern fn d2i_ECPrivateKey_fp(fp: [*c]FILE, eckey: [*c]?*EC_KEY) ?*EC_KEY;
+pub extern fn i2d_ECPrivateKey_fp(fp: [*c]FILE, eckey: ?*EC_KEY) c_int;
+pub extern fn d2i_PKCS8_fp(fp: [*c]FILE, p8: [*c]?*X509_SIG) ?*X509_SIG;
+pub extern fn i2d_PKCS8_fp(fp: [*c]FILE, p8: ?*X509_SIG) c_int;
+pub extern fn d2i_PKCS8_PRIV_KEY_INFO_fp(fp: [*c]FILE, p8inf: [*c]?*PKCS8_PRIV_KEY_INFO) ?*PKCS8_PRIV_KEY_INFO;
+pub extern fn i2d_PKCS8_PRIV_KEY_INFO_fp(fp: [*c]FILE, p8inf: ?*PKCS8_PRIV_KEY_INFO) c_int;
+pub extern fn i2d_PKCS8PrivateKeyInfo_fp(fp: [*c]FILE, key: [*c]EVP_PKEY) c_int;
+pub extern fn i2d_PrivateKey_fp(fp: [*c]FILE, pkey: [*c]EVP_PKEY) c_int;
+pub extern fn d2i_PrivateKey_fp(fp: [*c]FILE, a: [*c][*c]EVP_PKEY) [*c]EVP_PKEY;
+pub extern fn i2d_PUBKEY_fp(fp: [*c]FILE, pkey: [*c]EVP_PKEY) c_int;
+pub extern fn d2i_PUBKEY_fp(fp: [*c]FILE, a: [*c][*c]EVP_PKEY) [*c]EVP_PKEY;
+pub extern fn d2i_X509_bio(bp: [*c]BIO, x509: [*c]?*X509) ?*X509;
+pub extern fn i2d_X509_bio(bp: [*c]BIO, x509: ?*X509) c_int;
+pub extern fn d2i_X509_CRL_bio(bp: [*c]BIO, crl: [*c]?*X509_CRL) ?*X509_CRL;
+pub extern fn i2d_X509_CRL_bio(bp: [*c]BIO, crl: ?*X509_CRL) c_int;
+pub extern fn d2i_X509_REQ_bio(bp: [*c]BIO, req: [*c]?*X509_REQ) ?*X509_REQ;
+pub extern fn i2d_X509_REQ_bio(bp: [*c]BIO, req: ?*X509_REQ) c_int;
+pub extern fn d2i_RSAPrivateKey_bio(bp: [*c]BIO, rsa: [*c]?*RSA) ?*RSA;
+pub extern fn i2d_RSAPrivateKey_bio(bp: [*c]BIO, rsa: ?*RSA) c_int;
+pub extern fn d2i_RSAPublicKey_bio(bp: [*c]BIO, rsa: [*c]?*RSA) ?*RSA;
+pub extern fn i2d_RSAPublicKey_bio(bp: [*c]BIO, rsa: ?*RSA) c_int;
+pub extern fn d2i_RSA_PUBKEY_bio(bp: [*c]BIO, rsa: [*c]?*RSA) ?*RSA;
+pub extern fn i2d_RSA_PUBKEY_bio(bp: [*c]BIO, rsa: ?*RSA) c_int;
+pub extern fn d2i_DSA_PUBKEY_bio(bp: [*c]BIO, dsa: [*c][*c]DSA) [*c]DSA;
+pub extern fn i2d_DSA_PUBKEY_bio(bp: [*c]BIO, dsa: [*c]DSA) c_int;
+pub extern fn d2i_DSAPrivateKey_bio(bp: [*c]BIO, dsa: [*c][*c]DSA) [*c]DSA;
+pub extern fn i2d_DSAPrivateKey_bio(bp: [*c]BIO, dsa: [*c]DSA) c_int;
+pub extern fn d2i_EC_PUBKEY_bio(bp: [*c]BIO, eckey: [*c]?*EC_KEY) ?*EC_KEY;
+pub extern fn i2d_EC_PUBKEY_bio(bp: [*c]BIO, eckey: ?*EC_KEY) c_int;
+pub extern fn d2i_ECPrivateKey_bio(bp: [*c]BIO, eckey: [*c]?*EC_KEY) ?*EC_KEY;
+pub extern fn i2d_ECPrivateKey_bio(bp: [*c]BIO, eckey: ?*EC_KEY) c_int;
+pub extern fn d2i_PKCS8_bio(bp: [*c]BIO, p8: [*c]?*X509_SIG) ?*X509_SIG;
+pub extern fn i2d_PKCS8_bio(bp: [*c]BIO, p8: ?*X509_SIG) c_int;
+pub extern fn d2i_PKCS8_PRIV_KEY_INFO_bio(bp: [*c]BIO, p8inf: [*c]?*PKCS8_PRIV_KEY_INFO) ?*PKCS8_PRIV_KEY_INFO;
+pub extern fn i2d_PKCS8_PRIV_KEY_INFO_bio(bp: [*c]BIO, p8inf: ?*PKCS8_PRIV_KEY_INFO) c_int;
+pub extern fn i2d_PKCS8PrivateKeyInfo_bio(bp: [*c]BIO, key: [*c]EVP_PKEY) c_int;
+pub extern fn i2d_PrivateKey_bio(bp: [*c]BIO, pkey: [*c]EVP_PKEY) c_int;
+pub extern fn d2i_PrivateKey_bio(bp: [*c]BIO, a: [*c][*c]EVP_PKEY) [*c]EVP_PKEY;
+pub extern fn i2d_PUBKEY_bio(bp: [*c]BIO, pkey: [*c]EVP_PKEY) c_int;
+pub extern fn d2i_PUBKEY_bio(bp: [*c]BIO, a: [*c][*c]EVP_PKEY) [*c]EVP_PKEY;
+pub extern fn d2i_DHparams_bio(bp: [*c]BIO, dh: [*c][*c]DH) [*c]DH;
+pub extern fn i2d_DHparams_bio(bp: [*c]BIO, dh: [*c]const DH) c_int;
+pub extern fn X509_dup(x509: ?*X509) ?*X509;
+pub extern fn X509_ATTRIBUTE_dup(xa: ?*X509_ATTRIBUTE) ?*X509_ATTRIBUTE;
+pub extern fn X509_EXTENSION_dup(ex: ?*X509_EXTENSION) ?*X509_EXTENSION;
+pub extern fn X509_CRL_dup(crl: ?*X509_CRL) ?*X509_CRL;
+pub extern fn X509_REVOKED_dup(rev: [*c]X509_REVOKED) [*c]X509_REVOKED;
+pub extern fn X509_REQ_dup(req: ?*X509_REQ) ?*X509_REQ;
+pub extern fn X509_ALGOR_dup(xn: [*c]X509_ALGOR) [*c]X509_ALGOR;
+pub extern fn X509_ALGOR_set0(alg: [*c]X509_ALGOR, obj: ?*ASN1_OBJECT, param_type: c_int, param_value: ?*c_void) c_int;
+pub extern fn X509_ALGOR_get0(out_obj: [*c]?*const ASN1_OBJECT, out_param_type: [*c]c_int, out_param_value: [*c]?*const c_void, alg: [*c]const X509_ALGOR) void;
+pub extern fn X509_ALGOR_set_md(alg: [*c]X509_ALGOR, md: ?*const EVP_MD) void;
+pub extern fn X509_ALGOR_cmp(a: [*c]const X509_ALGOR, b: [*c]const X509_ALGOR) c_int;
+pub extern fn X509_NAME_dup(xn: ?*X509_NAME) ?*X509_NAME;
+pub extern fn X509_NAME_ENTRY_dup(ne: ?*X509_NAME_ENTRY) ?*X509_NAME_ENTRY;
+pub extern fn X509_NAME_ENTRY_set(ne: ?*const X509_NAME_ENTRY) c_int;
+pub extern fn X509_NAME_get0_der(nm: ?*X509_NAME, pder: [*c][*c]const u8, pderlen: [*c]usize) c_int;
+pub extern fn X509_cmp_time(s: [*c]const ASN1_TIME, t: [*c]time_t) c_int;
+pub extern fn X509_cmp_current_time(s: [*c]const ASN1_TIME) c_int;
+pub extern fn X509_time_adj(s: [*c]ASN1_TIME, offset_sec: c_long, t: [*c]time_t) [*c]ASN1_TIME;
+pub extern fn X509_time_adj_ex(s: [*c]ASN1_TIME, offset_day: c_int, offset_sec: c_long, t: [*c]time_t) [*c]ASN1_TIME;
+pub extern fn X509_gmtime_adj(s: [*c]ASN1_TIME, offset_sec: c_long) [*c]ASN1_TIME;
+pub extern fn X509_get_default_cert_area() [*c]const u8;
+pub extern fn X509_get_default_cert_dir() [*c]const u8;
+pub extern fn X509_get_default_cert_file() [*c]const u8;
+pub extern fn X509_get_default_cert_dir_env() [*c]const u8;
+pub extern fn X509_get_default_cert_file_env() [*c]const u8;
+pub extern fn X509_get_default_private_dir() [*c]const u8;
+pub extern fn X509_to_X509_REQ(x: ?*X509, pkey: [*c]EVP_PKEY, md: ?*const EVP_MD) ?*X509_REQ;
+pub extern fn d2i_X509_ALGORS(a: [*c]?*X509_ALGORS, in: [*c][*c]const u8, len: c_long) ?*X509_ALGORS;
+pub extern fn i2d_X509_ALGORS(a: ?*X509_ALGORS, out: [*c][*c]u8) c_int;
+pub extern const X509_ALGORS_it: ASN1_ITEM;
+pub extern fn X509_PUBKEY_new() ?*X509_PUBKEY;
+pub extern fn X509_PUBKEY_free(a: ?*X509_PUBKEY) void;
+pub extern fn d2i_X509_PUBKEY(a: [*c]?*X509_PUBKEY, in: [*c][*c]const u8, len: c_long) ?*X509_PUBKEY;
+pub extern fn i2d_X509_PUBKEY(a: ?*X509_PUBKEY, out: [*c][*c]u8) c_int;
+pub extern const X509_PUBKEY_it: ASN1_ITEM;
+pub extern fn X509_PUBKEY_set(x: [*c]?*X509_PUBKEY, pkey: [*c]EVP_PKEY) c_int;
+pub extern fn X509_PUBKEY_get(key: ?*X509_PUBKEY) [*c]EVP_PKEY;
+pub extern fn X509_SIG_new() ?*X509_SIG;
+pub extern fn X509_SIG_free(a: ?*X509_SIG) void;
+pub extern fn d2i_X509_SIG(a: [*c]?*X509_SIG, in: [*c][*c]const u8, len: c_long) ?*X509_SIG;
+pub extern fn i2d_X509_SIG(a: ?*X509_SIG, out: [*c][*c]u8) c_int;
+pub extern const X509_SIG_it: ASN1_ITEM;
+pub extern fn X509_REQ_new() ?*X509_REQ;
+pub extern fn X509_REQ_free(a: ?*X509_REQ) void;
+pub extern fn d2i_X509_REQ(a: [*c]?*X509_REQ, in: [*c][*c]const u8, len: c_long) ?*X509_REQ;
+pub extern fn i2d_X509_REQ(a: ?*X509_REQ, out: [*c][*c]u8) c_int;
+pub extern const X509_REQ_it: ASN1_ITEM;
+pub extern fn X509_ATTRIBUTE_new() ?*X509_ATTRIBUTE;
+pub extern fn X509_ATTRIBUTE_free(a: ?*X509_ATTRIBUTE) void;
+pub extern fn d2i_X509_ATTRIBUTE(a: [*c]?*X509_ATTRIBUTE, in: [*c][*c]const u8, len: c_long) ?*X509_ATTRIBUTE;
+pub extern fn i2d_X509_ATTRIBUTE(a: ?*X509_ATTRIBUTE, out: [*c][*c]u8) c_int;
+pub extern const X509_ATTRIBUTE_it: ASN1_ITEM;
+pub extern fn X509_ATTRIBUTE_create(nid: c_int, attrtype: c_int, value: ?*c_void) ?*X509_ATTRIBUTE;
+pub extern fn X509_EXTENSION_new() ?*X509_EXTENSION;
+pub extern fn X509_EXTENSION_free(a: ?*X509_EXTENSION) void;
+pub extern fn d2i_X509_EXTENSION(a: [*c]?*X509_EXTENSION, in: [*c][*c]const u8, len: c_long) ?*X509_EXTENSION;
+pub extern fn i2d_X509_EXTENSION(a: ?*X509_EXTENSION, out: [*c][*c]u8) c_int;
+pub extern const X509_EXTENSION_it: ASN1_ITEM;
+pub extern fn d2i_X509_EXTENSIONS(a: [*c]?*X509_EXTENSIONS, in: [*c][*c]const u8, len: c_long) ?*X509_EXTENSIONS;
+pub extern fn i2d_X509_EXTENSIONS(a: ?*X509_EXTENSIONS, out: [*c][*c]u8) c_int;
+pub extern const X509_EXTENSIONS_it: ASN1_ITEM;
+pub extern fn X509_NAME_ENTRY_new() ?*X509_NAME_ENTRY;
+pub extern fn X509_NAME_ENTRY_free(a: ?*X509_NAME_ENTRY) void;
+pub extern fn d2i_X509_NAME_ENTRY(a: [*c]?*X509_NAME_ENTRY, in: [*c][*c]const u8, len: c_long) ?*X509_NAME_ENTRY;
+pub extern fn i2d_X509_NAME_ENTRY(a: ?*X509_NAME_ENTRY, out: [*c][*c]u8) c_int;
+pub extern const X509_NAME_ENTRY_it: ASN1_ITEM;
+pub extern fn X509_NAME_new() ?*X509_NAME;
+pub extern fn X509_NAME_free(a: ?*X509_NAME) void;
+pub extern fn d2i_X509_NAME(a: [*c]?*X509_NAME, in: [*c][*c]const u8, len: c_long) ?*X509_NAME;
+pub extern fn i2d_X509_NAME(a: ?*X509_NAME, out: [*c][*c]u8) c_int;
+pub extern const X509_NAME_it: ASN1_ITEM;
+pub extern fn X509_NAME_set(xn: [*c]?*X509_NAME, name: ?*X509_NAME) c_int;
+pub extern fn X509_new() ?*X509;
+pub extern fn X509_free(a: ?*X509) void;
+pub extern fn d2i_X509(a: [*c]?*X509, in: [*c][*c]const u8, len: c_long) ?*X509;
+pub extern fn i2d_X509(a: ?*X509, out: [*c][*c]u8) c_int;
+pub extern const X509_it: ASN1_ITEM;
+pub extern fn X509_CERT_AUX_new() ?*X509_CERT_AUX;
+pub extern fn X509_CERT_AUX_free(a: ?*X509_CERT_AUX) void;
+pub extern fn d2i_X509_CERT_AUX(a: [*c]?*X509_CERT_AUX, in: [*c][*c]const u8, len: c_long) ?*X509_CERT_AUX;
+pub extern fn i2d_X509_CERT_AUX(a: ?*X509_CERT_AUX, out: [*c][*c]u8) c_int;
+pub extern const X509_CERT_AUX_it: ASN1_ITEM;
+pub extern fn X509_up_ref(x509: ?*X509) c_int;
+pub extern fn X509_get_ex_new_index(argl: c_long, argp: ?*c_void, unused: [*c]CRYPTO_EX_unused, dup_unused: ?CRYPTO_EX_dup, free_func: ?CRYPTO_EX_free) c_int;
+pub extern fn X509_set_ex_data(r: ?*X509, idx: c_int, arg: ?*c_void) c_int;
+pub extern fn X509_get_ex_data(r: ?*X509, idx: c_int) ?*c_void;
+pub extern fn i2d_X509_AUX(a: ?*X509, pp: [*c][*c]u8) c_int;
+pub extern fn d2i_X509_AUX(a: [*c]?*X509, pp: [*c][*c]const u8, length: c_long) ?*X509;
+pub extern fn i2d_re_X509_tbs(x509: ?*X509, outp: [*c][*c]u8) c_int;
+pub extern fn i2d_X509_tbs(x509: ?*X509, outp: [*c][*c]u8) c_int;
+pub extern fn X509_set1_signature_algo(x509: ?*X509, algo: [*c]const X509_ALGOR) c_int;
+pub extern fn X509_set1_signature_value(x509: ?*X509, sig: [*c]const u8, sig_len: usize) c_int;
+pub extern fn X509_get0_signature(out_sig: [*c][*c]const ASN1_BIT_STRING, out_alg: [*c][*c]const X509_ALGOR, x509: ?*const X509) void;
+pub extern fn X509_get_signature_nid(x509: ?*const X509) c_int;
+pub extern fn X509_alias_set1(x: ?*X509, name: [*c]const u8, len: c_int) c_int;
+pub extern fn X509_keyid_set1(x: ?*X509, id: [*c]const u8, len: c_int) c_int;
+pub extern fn X509_alias_get0(x: ?*X509, len: [*c]c_int) [*c]u8;
+pub extern fn X509_keyid_get0(x: ?*X509, len: [*c]c_int) [*c]u8;
+pub extern fn X509_TRUST_set_default(trust: ?fn (c_int, ?*X509, c_int) callconv(.C) c_int) ?fn (c_int, ?*X509, c_int) callconv(.C) c_int;
+pub extern fn X509_TRUST_set(t: [*c]c_int, trust: c_int) c_int;
+pub extern fn X509_add1_trust_object(x: ?*X509, obj: ?*ASN1_OBJECT) c_int;
+pub extern fn X509_add1_reject_object(x: ?*X509, obj: ?*ASN1_OBJECT) c_int;
+pub extern fn X509_trust_clear(x: ?*X509) void;
+pub extern fn X509_reject_clear(x: ?*X509) void;
+pub extern fn X509_REVOKED_new() [*c]X509_REVOKED;
+pub extern fn X509_REVOKED_free(a: [*c]X509_REVOKED) void;
+pub extern fn d2i_X509_REVOKED(a: [*c][*c]X509_REVOKED, in: [*c][*c]const u8, len: c_long) [*c]X509_REVOKED;
+pub extern fn i2d_X509_REVOKED(a: [*c]X509_REVOKED, out: [*c][*c]u8) c_int;
+pub extern const X509_REVOKED_it: ASN1_ITEM;
+pub extern fn X509_CRL_new() ?*X509_CRL;
+pub extern fn X509_CRL_free(a: ?*X509_CRL) void;
+pub extern fn d2i_X509_CRL(a: [*c]?*X509_CRL, in: [*c][*c]const u8, len: c_long) ?*X509_CRL;
+pub extern fn i2d_X509_CRL(a: ?*X509_CRL, out: [*c][*c]u8) c_int;
+pub extern const X509_CRL_it: ASN1_ITEM;
+pub extern fn X509_CRL_add0_revoked(crl: ?*X509_CRL, rev: [*c]X509_REVOKED) c_int;
+pub extern fn X509_CRL_get0_by_serial(crl: ?*X509_CRL, ret: [*c][*c]X509_REVOKED, serial: [*c]ASN1_INTEGER) c_int;
+pub extern fn X509_CRL_get0_by_cert(crl: ?*X509_CRL, ret: [*c][*c]X509_REVOKED, x: ?*X509) c_int;
+pub extern fn X509_PKEY_new() [*c]X509_PKEY;
+pub extern fn X509_PKEY_free(a: [*c]X509_PKEY) void;
+pub extern fn NETSCAPE_SPKI_new() [*c]NETSCAPE_SPKI;
+pub extern fn NETSCAPE_SPKI_free(a: [*c]NETSCAPE_SPKI) void;
+pub extern fn d2i_NETSCAPE_SPKI(a: [*c][*c]NETSCAPE_SPKI, in: [*c][*c]const u8, len: c_long) [*c]NETSCAPE_SPKI;
+pub extern fn i2d_NETSCAPE_SPKI(a: [*c]NETSCAPE_SPKI, out: [*c][*c]u8) c_int;
+pub extern const NETSCAPE_SPKI_it: ASN1_ITEM;
+pub extern fn NETSCAPE_SPKAC_new() [*c]NETSCAPE_SPKAC;
+pub extern fn NETSCAPE_SPKAC_free(a: [*c]NETSCAPE_SPKAC) void;
+pub extern fn d2i_NETSCAPE_SPKAC(a: [*c][*c]NETSCAPE_SPKAC, in: [*c][*c]const u8, len: c_long) [*c]NETSCAPE_SPKAC;
+pub extern fn i2d_NETSCAPE_SPKAC(a: [*c]NETSCAPE_SPKAC, out: [*c][*c]u8) c_int;
+pub extern const NETSCAPE_SPKAC_it: ASN1_ITEM;
+pub extern fn X509_INFO_new() [*c]X509_INFO;
+pub extern fn X509_INFO_free(a: [*c]X509_INFO) void;
+pub extern fn X509_NAME_oneline(a: ?*const X509_NAME, buf: [*c]u8, size: c_int) [*c]u8;
+pub extern fn ASN1_digest(i2d: ?i2d_of_void, @"type": ?*const EVP_MD, data: [*c]u8, md: [*c]u8, len: [*c]c_uint) c_int;
+pub extern fn ASN1_item_digest(it: ?*const ASN1_ITEM, @"type": ?*const EVP_MD, data: ?*c_void, md: [*c]u8, len: [*c]c_uint) c_int;
+pub extern fn ASN1_item_verify(it: ?*const ASN1_ITEM, algor1: [*c]const X509_ALGOR, signature: [*c]const ASN1_BIT_STRING, data: ?*c_void, pkey: [*c]EVP_PKEY) c_int;
+pub extern fn ASN1_item_sign(it: ?*const ASN1_ITEM, algor1: [*c]X509_ALGOR, algor2: [*c]X509_ALGOR, signature: [*c]ASN1_BIT_STRING, data: ?*c_void, pkey: [*c]EVP_PKEY, @"type": ?*const EVP_MD) c_int;
+pub extern fn ASN1_item_sign_ctx(it: ?*const ASN1_ITEM, algor1: [*c]X509_ALGOR, algor2: [*c]X509_ALGOR, signature: [*c]ASN1_BIT_STRING, asn: ?*c_void, ctx: [*c]EVP_MD_CTX) c_int;
+pub extern fn X509_get_serialNumber(x509: ?*X509) [*c]ASN1_INTEGER;
+pub extern fn X509_set_issuer_name(x509: ?*X509, name: ?*X509_NAME) c_int;
+pub extern fn X509_get_issuer_name(x509: ?*const X509) ?*X509_NAME;
+pub extern fn X509_set_subject_name(x509: ?*X509, name: ?*X509_NAME) c_int;
+pub extern fn X509_get_subject_name(x509: ?*const X509) ?*X509_NAME;
+pub extern fn X509_set_pubkey(x509: ?*X509, pkey: [*c]EVP_PKEY) c_int;
+pub extern fn X509_get_pubkey(x509: ?*X509) [*c]EVP_PKEY;
+pub extern fn X509_get0_pubkey_bitstr(x509: ?*const X509) [*c]ASN1_BIT_STRING;
+pub extern fn X509_get0_extensions(x509: ?*const X509) ?*const struct_stack_st_X509_EXTENSION;
+pub extern fn X509_get0_tbs_sigalg(x509: ?*const X509) [*c]const X509_ALGOR;
+pub extern fn X509_REQ_set_version(req: ?*X509_REQ, version: c_long) c_int;
+pub extern fn X509_REQ_set_subject_name(req: ?*X509_REQ, name: ?*X509_NAME) c_int;
+pub extern fn X509_REQ_get0_signature(req: ?*const X509_REQ, out_sig: [*c][*c]const ASN1_BIT_STRING, out_alg: [*c][*c]const X509_ALGOR) void;
+pub extern fn X509_REQ_get_signature_nid(req: ?*const X509_REQ) c_int;
+pub extern fn i2d_re_X509_REQ_tbs(req: ?*X509_REQ, outp: [*c][*c]u8) c_int;
+pub extern fn X509_REQ_set_pubkey(req: ?*X509_REQ, pkey: [*c]EVP_PKEY) c_int;
+pub extern fn X509_REQ_get_pubkey(req: ?*X509_REQ) [*c]EVP_PKEY;
+pub extern fn X509_REQ_extension_nid(nid: c_int) c_int;
+pub extern fn X509_REQ_get_extensions(req: ?*X509_REQ) ?*struct_stack_st_X509_EXTENSION;
+pub extern fn X509_REQ_add_extensions_nid(req: ?*X509_REQ, exts: ?*const struct_stack_st_X509_EXTENSION, nid: c_int) c_int;
+pub extern fn X509_REQ_add_extensions(req: ?*X509_REQ, exts: ?*const struct_stack_st_X509_EXTENSION) c_int;
+pub extern fn X509_REQ_get_attr_count(req: ?*const X509_REQ) c_int;
+pub extern fn X509_REQ_get_attr_by_NID(req: ?*const X509_REQ, nid: c_int, lastpos: c_int) c_int;
+pub extern fn X509_REQ_get_attr_by_OBJ(req: ?*const X509_REQ, obj: ?*const ASN1_OBJECT, lastpos: c_int) c_int;
+pub extern fn X509_REQ_get_attr(req: ?*const X509_REQ, loc: c_int) ?*X509_ATTRIBUTE;
+pub extern fn X509_REQ_delete_attr(req: ?*X509_REQ, loc: c_int) ?*X509_ATTRIBUTE;
+pub extern fn X509_REQ_add1_attr(req: ?*X509_REQ, attr: ?*X509_ATTRIBUTE) c_int;
+pub extern fn X509_REQ_add1_attr_by_OBJ(req: ?*X509_REQ, obj: ?*const ASN1_OBJECT, attrtype: c_int, data: [*c]const u8, len: c_int) c_int;
+pub extern fn X509_REQ_add1_attr_by_NID(req: ?*X509_REQ, nid: c_int, attrtype: c_int, data: [*c]const u8, len: c_int) c_int;
+pub extern fn X509_REQ_add1_attr_by_txt(req: ?*X509_REQ, attrname: [*c]const u8, attrtype: c_int, data: [*c]const u8, len: c_int) c_int;
+pub extern fn X509_CRL_set_version(crl: ?*X509_CRL, version: c_long) c_int;
+pub extern fn X509_CRL_set_issuer_name(crl: ?*X509_CRL, name: ?*X509_NAME) c_int;
+pub extern fn X509_CRL_sort(crl: ?*X509_CRL) c_int;
+pub extern fn X509_CRL_up_ref(crl: ?*X509_CRL) c_int;
+pub extern fn X509_CRL_get0_signature(crl: ?*const X509_CRL, out_sig: [*c][*c]const ASN1_BIT_STRING, out_alg: [*c][*c]const X509_ALGOR) void;
+pub extern fn X509_CRL_get_signature_nid(crl: ?*const X509_CRL) c_int;
+pub extern fn i2d_re_X509_CRL_tbs(crl: ?*X509_CRL, outp: [*c][*c]u8) c_int;
+pub extern fn i2d_X509_CRL_tbs(crl: ?*X509_CRL, outp: [*c][*c]u8) c_int;
+pub extern fn X509_CRL_set1_signature_algo(crl: ?*X509_CRL, algo: [*c]const X509_ALGOR) c_int;
+pub extern fn X509_CRL_set1_signature_value(crl: ?*X509_CRL, sig: [*c]const u8, sig_len: usize) c_int;
+pub extern fn X509_REVOKED_get0_serialNumber(revoked: [*c]const X509_REVOKED) [*c]const ASN1_INTEGER;
+pub extern fn X509_REVOKED_set_serialNumber(revoked: [*c]X509_REVOKED, serial: [*c]const ASN1_INTEGER) c_int;
+pub extern fn X509_REVOKED_get0_revocationDate(revoked: [*c]const X509_REVOKED) [*c]const ASN1_TIME;
+pub extern fn X509_REVOKED_set_revocationDate(revoked: [*c]X509_REVOKED, tm: [*c]const ASN1_TIME) c_int;
+pub extern fn X509_REVOKED_get0_extensions(r: [*c]const X509_REVOKED) ?*const struct_stack_st_X509_EXTENSION;
+pub extern fn X509_CRL_diff(base: ?*X509_CRL, newer: ?*X509_CRL, skey: [*c]EVP_PKEY, md: ?*const EVP_MD, flags: c_uint) ?*X509_CRL;
+pub extern fn X509_REQ_check_private_key(x509: ?*X509_REQ, pkey: [*c]EVP_PKEY) c_int;
+pub extern fn X509_check_private_key(x509: ?*X509, pkey: [*c]const EVP_PKEY) c_int;
+pub extern fn X509_chain_check_suiteb(perror_depth: [*c]c_int, x: ?*X509, chain: ?*struct_stack_st_X509, flags: c_ulong) c_int;
+pub extern fn X509_CRL_check_suiteb(crl: ?*X509_CRL, pk: [*c]EVP_PKEY, flags: c_ulong) c_int;
+pub extern fn X509_chain_up_ref(chain: ?*struct_stack_st_X509) ?*struct_stack_st_X509;
+pub extern fn X509_issuer_and_serial_cmp(a: ?*const X509, b: ?*const X509) c_int;
+pub extern fn X509_issuer_name_cmp(a: ?*const X509, b: ?*const X509) c_int;
+pub extern fn X509_issuer_name_hash(a: ?*X509) c_ulong;
+pub extern fn X509_subject_name_cmp(a: ?*const X509, b: ?*const X509) c_int;
+pub extern fn X509_subject_name_hash(x: ?*X509) c_ulong;
+pub extern fn X509_issuer_name_hash_old(a: ?*X509) c_ulong;
+pub extern fn X509_subject_name_hash_old(x: ?*X509) c_ulong;
+pub extern fn X509_cmp(a: ?*const X509, b: ?*const X509) c_int;
+pub extern fn X509_NAME_cmp(a: ?*const X509_NAME, b: ?*const X509_NAME) c_int;
+pub extern fn X509_NAME_hash(x: ?*X509_NAME) c_ulong;
+pub extern fn X509_NAME_hash_old(x: ?*X509_NAME) c_ulong;
+pub extern fn X509_CRL_cmp(a: ?*const X509_CRL, b: ?*const X509_CRL) c_int;
+pub extern fn X509_CRL_match(a: ?*const X509_CRL, b: ?*const X509_CRL) c_int;
+pub extern fn X509_print_ex_fp(bp: [*c]FILE, x: ?*X509, nmflag: c_ulong, cflag: c_ulong) c_int;
+pub extern fn X509_print_fp(bp: [*c]FILE, x: ?*X509) c_int;
+pub extern fn X509_CRL_print_fp(bp: [*c]FILE, x: ?*X509_CRL) c_int;
+pub extern fn X509_REQ_print_fp(bp: [*c]FILE, req: ?*X509_REQ) c_int;
+pub extern fn X509_NAME_print_ex_fp(fp: [*c]FILE, nm: ?*const X509_NAME, indent: c_int, flags: c_ulong) c_int;
+pub extern fn X509_NAME_print(bp: [*c]BIO, name: ?*const X509_NAME, obase: c_int) c_int;
+pub extern fn X509_NAME_print_ex(out: [*c]BIO, nm: ?*const X509_NAME, indent: c_int, flags: c_ulong) c_int;
+pub extern fn X509_print_ex(bp: [*c]BIO, x: ?*X509, nmflag: c_ulong, cflag: c_ulong) c_int;
+pub extern fn X509_print(bp: [*c]BIO, x: ?*X509) c_int;
+pub extern fn X509_ocspid_print(bp: [*c]BIO, x: ?*X509) c_int;
+pub extern fn X509_CERT_AUX_print(bp: [*c]BIO, x: ?*X509_CERT_AUX, indent: c_int) c_int;
+pub extern fn X509_CRL_print(bp: [*c]BIO, x: ?*X509_CRL) c_int;
+pub extern fn X509_REQ_print_ex(bp: [*c]BIO, x: ?*X509_REQ, nmflag: c_ulong, cflag: c_ulong) c_int;
+pub extern fn X509_REQ_print(bp: [*c]BIO, req: ?*X509_REQ) c_int;
+pub extern fn X509_NAME_entry_count(name: ?*const X509_NAME) c_int;
+pub extern fn X509_NAME_get_text_by_NID(name: ?*const X509_NAME, nid: c_int, buf: [*c]u8, len: c_int) c_int;
+pub extern fn X509_NAME_get_text_by_OBJ(name: ?*const X509_NAME, obj: ?*const ASN1_OBJECT, buf: [*c]u8, len: c_int) c_int;
+pub extern fn X509_NAME_get_index_by_NID(name: ?*const X509_NAME, nid: c_int, lastpos: c_int) c_int;
+pub extern fn X509_NAME_get_index_by_OBJ(name: ?*const X509_NAME, obj: ?*const ASN1_OBJECT, lastpos: c_int) c_int;
+pub extern fn X509_NAME_get_entry(name: ?*const X509_NAME, loc: c_int) ?*X509_NAME_ENTRY;
+pub extern fn X509_NAME_delete_entry(name: ?*X509_NAME, loc: c_int) ?*X509_NAME_ENTRY;
+pub extern fn X509_NAME_add_entry(name: ?*X509_NAME, ne: ?*X509_NAME_ENTRY, loc: c_int, set: c_int) c_int;
+pub extern fn X509_NAME_add_entry_by_OBJ(name: ?*X509_NAME, obj: ?*ASN1_OBJECT, @"type": c_int, bytes: [*c]const u8, len: c_int, loc: c_int, set: c_int) c_int;
+pub extern fn X509_NAME_add_entry_by_NID(name: ?*X509_NAME, nid: c_int, @"type": c_int, bytes: [*c]const u8, len: c_int, loc: c_int, set: c_int) c_int;
+pub extern fn X509_NAME_ENTRY_create_by_txt(ne: [*c]?*X509_NAME_ENTRY, field: [*c]const u8, @"type": c_int, bytes: [*c]const u8, len: c_int) ?*X509_NAME_ENTRY;
+pub extern fn X509_NAME_ENTRY_create_by_NID(ne: [*c]?*X509_NAME_ENTRY, nid: c_int, @"type": c_int, bytes: [*c]const u8, len: c_int) ?*X509_NAME_ENTRY;
+pub extern fn X509_NAME_add_entry_by_txt(name: ?*X509_NAME, field: [*c]const u8, @"type": c_int, bytes: [*c]const u8, len: c_int, loc: c_int, set: c_int) c_int;
+pub extern fn X509_NAME_ENTRY_create_by_OBJ(ne: [*c]?*X509_NAME_ENTRY, obj: ?*const ASN1_OBJECT, @"type": c_int, bytes: [*c]const u8, len: c_int) ?*X509_NAME_ENTRY;
+pub extern fn X509_NAME_ENTRY_set_object(ne: ?*X509_NAME_ENTRY, obj: ?*const ASN1_OBJECT) c_int;
+pub extern fn X509_NAME_ENTRY_set_data(ne: ?*X509_NAME_ENTRY, @"type": c_int, bytes: [*c]const u8, len: c_int) c_int;
+pub extern fn X509_NAME_ENTRY_get_object(ne: ?*const X509_NAME_ENTRY) ?*ASN1_OBJECT;
+pub extern fn X509_NAME_ENTRY_get_data(ne: ?*const X509_NAME_ENTRY) [*c]ASN1_STRING;
+pub extern fn X509v3_get_ext_count(x: ?*const struct_stack_st_X509_EXTENSION) c_int;
+pub extern fn X509v3_get_ext_by_NID(x: ?*const struct_stack_st_X509_EXTENSION, nid: c_int, lastpos: c_int) c_int;
+pub extern fn X509v3_get_ext_by_OBJ(x: ?*const struct_stack_st_X509_EXTENSION, obj: ?*const ASN1_OBJECT, lastpos: c_int) c_int;
+pub extern fn X509v3_get_ext_by_critical(x: ?*const struct_stack_st_X509_EXTENSION, crit: c_int, lastpos: c_int) c_int;
+pub extern fn X509v3_get_ext(x: ?*const struct_stack_st_X509_EXTENSION, loc: c_int) ?*X509_EXTENSION;
+pub extern fn X509v3_delete_ext(x: ?*struct_stack_st_X509_EXTENSION, loc: c_int) ?*X509_EXTENSION;
+pub extern fn X509v3_add_ext(x: [*c]?*struct_stack_st_X509_EXTENSION, ex: ?*X509_EXTENSION, loc: c_int) ?*struct_stack_st_X509_EXTENSION;
+pub extern fn X509_get_ext_count(x: ?*const X509) c_int;
+pub extern fn X509_get_ext_by_NID(x: ?*const X509, nid: c_int, lastpos: c_int) c_int;
+pub extern fn X509_get_ext_by_OBJ(x: ?*const X509, obj: ?*const ASN1_OBJECT, lastpos: c_int) c_int;
+pub extern fn X509_get_ext_by_critical(x: ?*const X509, crit: c_int, lastpos: c_int) c_int;
+pub extern fn X509_get_ext(x: ?*const X509, loc: c_int) ?*X509_EXTENSION;
+pub extern fn X509_delete_ext(x: ?*X509, loc: c_int) ?*X509_EXTENSION;
+pub extern fn X509_add_ext(x: ?*X509, ex: ?*X509_EXTENSION, loc: c_int) c_int;
+pub extern fn X509_get_ext_d2i(x509: ?*const X509, nid: c_int, out_critical: [*c]c_int, out_idx: [*c]c_int) ?*c_void;
+pub extern fn X509_add1_ext_i2d(x: ?*X509, nid: c_int, value: ?*c_void, crit: c_int, flags: c_ulong) c_int;
+pub extern fn X509_CRL_get_ext_count(x: ?*const X509_CRL) c_int;
+pub extern fn X509_CRL_get_ext_by_NID(x: ?*const X509_CRL, nid: c_int, lastpos: c_int) c_int;
+pub extern fn X509_CRL_get_ext_by_OBJ(x: ?*const X509_CRL, obj: ?*const ASN1_OBJECT, lastpos: c_int) c_int;
+pub extern fn X509_CRL_get_ext_by_critical(x: ?*const X509_CRL, crit: c_int, lastpos: c_int) c_int;
+pub extern fn X509_CRL_get_ext(x: ?*const X509_CRL, loc: c_int) ?*X509_EXTENSION;
+pub extern fn X509_CRL_delete_ext(x: ?*X509_CRL, loc: c_int) ?*X509_EXTENSION;
+pub extern fn X509_CRL_add_ext(x: ?*X509_CRL, ex: ?*X509_EXTENSION, loc: c_int) c_int;
+pub extern fn X509_CRL_get_ext_d2i(crl: ?*const X509_CRL, nid: c_int, out_critical: [*c]c_int, out_idx: [*c]c_int) ?*c_void;
+pub extern fn X509_CRL_add1_ext_i2d(x: ?*X509_CRL, nid: c_int, value: ?*c_void, crit: c_int, flags: c_ulong) c_int;
+pub extern fn X509_REVOKED_get_ext_count(x: [*c]const X509_REVOKED) c_int;
+pub extern fn X509_REVOKED_get_ext_by_NID(x: [*c]const X509_REVOKED, nid: c_int, lastpos: c_int) c_int;
+pub extern fn X509_REVOKED_get_ext_by_OBJ(x: [*c]const X509_REVOKED, obj: ?*const ASN1_OBJECT, lastpos: c_int) c_int;
+pub extern fn X509_REVOKED_get_ext_by_critical(x: [*c]const X509_REVOKED, crit: c_int, lastpos: c_int) c_int;
+pub extern fn X509_REVOKED_get_ext(x: [*c]const X509_REVOKED, loc: c_int) ?*X509_EXTENSION;
+pub extern fn X509_REVOKED_delete_ext(x: [*c]X509_REVOKED, loc: c_int) ?*X509_EXTENSION;
+pub extern fn X509_REVOKED_add_ext(x: [*c]X509_REVOKED, ex: ?*X509_EXTENSION, loc: c_int) c_int;
+pub extern fn X509_REVOKED_get_ext_d2i(revoked: [*c]const X509_REVOKED, nid: c_int, out_critical: [*c]c_int, out_idx: [*c]c_int) ?*c_void;
+pub extern fn X509_REVOKED_add1_ext_i2d(x: [*c]X509_REVOKED, nid: c_int, value: ?*c_void, crit: c_int, flags: c_ulong) c_int;
+pub extern fn X509_EXTENSION_create_by_NID(ex: [*c]?*X509_EXTENSION, nid: c_int, crit: c_int, data: [*c]const ASN1_OCTET_STRING) ?*X509_EXTENSION;
+pub extern fn X509_EXTENSION_create_by_OBJ(ex: [*c]?*X509_EXTENSION, obj: ?*const ASN1_OBJECT, crit: c_int, data: [*c]const ASN1_OCTET_STRING) ?*X509_EXTENSION;
+pub extern fn X509_EXTENSION_set_object(ex: ?*X509_EXTENSION, obj: ?*const ASN1_OBJECT) c_int;
+pub extern fn X509_EXTENSION_set_critical(ex: ?*X509_EXTENSION, crit: c_int) c_int;
+pub extern fn X509_EXTENSION_set_data(ex: ?*X509_EXTENSION, data: [*c]const ASN1_OCTET_STRING) c_int;
+pub extern fn X509_EXTENSION_get_object(ex: ?*X509_EXTENSION) ?*ASN1_OBJECT;
+pub extern fn X509_EXTENSION_get_data(ne: ?*X509_EXTENSION) [*c]ASN1_OCTET_STRING;
+pub extern fn X509_EXTENSION_get_critical(ex: ?*const X509_EXTENSION) c_int;
+pub extern fn X509at_get_attr_count(x: ?*const struct_stack_st_X509_ATTRIBUTE) c_int;
+pub extern fn X509at_get_attr_by_NID(x: ?*const struct_stack_st_X509_ATTRIBUTE, nid: c_int, lastpos: c_int) c_int;
+pub extern fn X509at_get_attr_by_OBJ(sk: ?*const struct_stack_st_X509_ATTRIBUTE, obj: ?*const ASN1_OBJECT, lastpos: c_int) c_int;
+pub extern fn X509at_get_attr(x: ?*const struct_stack_st_X509_ATTRIBUTE, loc: c_int) ?*X509_ATTRIBUTE;
+pub extern fn X509at_delete_attr(x: ?*struct_stack_st_X509_ATTRIBUTE, loc: c_int) ?*X509_ATTRIBUTE;
+pub extern fn X509at_add1_attr(x: [*c]?*struct_stack_st_X509_ATTRIBUTE, attr: ?*X509_ATTRIBUTE) ?*struct_stack_st_X509_ATTRIBUTE;
+pub extern fn X509at_add1_attr_by_OBJ(x: [*c]?*struct_stack_st_X509_ATTRIBUTE, obj: ?*const ASN1_OBJECT, @"type": c_int, bytes: [*c]const u8, len: c_int) ?*struct_stack_st_X509_ATTRIBUTE;
+pub extern fn X509at_add1_attr_by_NID(x: [*c]?*struct_stack_st_X509_ATTRIBUTE, nid: c_int, @"type": c_int, bytes: [*c]const u8, len: c_int) ?*struct_stack_st_X509_ATTRIBUTE;
+pub extern fn X509at_add1_attr_by_txt(x: [*c]?*struct_stack_st_X509_ATTRIBUTE, attrname: [*c]const u8, @"type": c_int, bytes: [*c]const u8, len: c_int) ?*struct_stack_st_X509_ATTRIBUTE;
+pub extern fn X509_ATTRIBUTE_create_by_NID(attr: [*c]?*X509_ATTRIBUTE, nid: c_int, attrtype: c_int, data: ?*const c_void, len: c_int) ?*X509_ATTRIBUTE;
+pub extern fn X509_ATTRIBUTE_create_by_OBJ(attr: [*c]?*X509_ATTRIBUTE, obj: ?*const ASN1_OBJECT, attrtype: c_int, data: ?*const c_void, len: c_int) ?*X509_ATTRIBUTE;
+pub extern fn X509_ATTRIBUTE_create_by_txt(attr: [*c]?*X509_ATTRIBUTE, attrname: [*c]const u8, @"type": c_int, bytes: [*c]const u8, len: c_int) ?*X509_ATTRIBUTE;
+pub extern fn X509_ATTRIBUTE_set1_object(attr: ?*X509_ATTRIBUTE, obj: ?*const ASN1_OBJECT) c_int;
+pub extern fn X509_ATTRIBUTE_set1_data(attr: ?*X509_ATTRIBUTE, attrtype: c_int, data: ?*const c_void, len: c_int) c_int;
+pub extern fn X509_ATTRIBUTE_get0_data(attr: ?*X509_ATTRIBUTE, idx: c_int, attrtype: c_int, unused: ?*c_void) ?*c_void;
+pub extern fn X509_ATTRIBUTE_count(attr: ?*const X509_ATTRIBUTE) c_int;
+pub extern fn X509_ATTRIBUTE_get0_object(attr: ?*X509_ATTRIBUTE) ?*ASN1_OBJECT;
+pub extern fn X509_ATTRIBUTE_get0_type(attr: ?*X509_ATTRIBUTE, idx: c_int) [*c]ASN1_TYPE;
+pub extern fn X509_verify_cert(ctx: ?*X509_STORE_CTX) c_int;
+pub extern fn X509_find_by_issuer_and_serial(sk: ?*struct_stack_st_X509, name: ?*X509_NAME, serial: [*c]ASN1_INTEGER) ?*X509;
+pub extern fn X509_find_by_subject(sk: ?*struct_stack_st_X509, name: ?*X509_NAME) ?*X509;
+pub extern fn PKCS8_PRIV_KEY_INFO_new() ?*PKCS8_PRIV_KEY_INFO;
+pub extern fn PKCS8_PRIV_KEY_INFO_free(a: ?*PKCS8_PRIV_KEY_INFO) void;
+pub extern fn d2i_PKCS8_PRIV_KEY_INFO(a: [*c]?*PKCS8_PRIV_KEY_INFO, in: [*c][*c]const u8, len: c_long) ?*PKCS8_PRIV_KEY_INFO;
+pub extern fn i2d_PKCS8_PRIV_KEY_INFO(a: ?*PKCS8_PRIV_KEY_INFO, out: [*c][*c]u8) c_int;
+pub extern const PKCS8_PRIV_KEY_INFO_it: ASN1_ITEM;
+pub extern fn EVP_PKCS82PKEY(p8: ?*PKCS8_PRIV_KEY_INFO) [*c]EVP_PKEY;
+pub extern fn EVP_PKEY2PKCS8(pkey: [*c]EVP_PKEY) ?*PKCS8_PRIV_KEY_INFO;
+pub extern fn PKCS8_pkey_set0(priv: ?*PKCS8_PRIV_KEY_INFO, aobj: ?*ASN1_OBJECT, version: c_int, ptype: c_int, pval: ?*c_void, penc: [*c]u8, penclen: c_int) c_int;
+pub extern fn PKCS8_pkey_get0(ppkalg: [*c]?*ASN1_OBJECT, pk: [*c][*c]const u8, ppklen: [*c]c_int, pa: [*c][*c]X509_ALGOR, p8: ?*PKCS8_PRIV_KEY_INFO) c_int;
+pub extern fn X509_PUBKEY_set0_param(@"pub": ?*X509_PUBKEY, obj: ?*ASN1_OBJECT, param_type: c_int, param_value: ?*c_void, key: [*c]u8, key_len: c_int) c_int;
+pub extern fn X509_PUBKEY_get0_param(out_obj: [*c]?*ASN1_OBJECT, out_key: [*c][*c]const u8, out_key_len: [*c]c_int, out_alg: [*c][*c]X509_ALGOR, @"pub": ?*X509_PUBKEY) c_int;
+pub extern fn X509_PUBKEY_get0_public_key(@"pub": ?*const X509_PUBKEY) [*c]const ASN1_BIT_STRING;
+pub extern fn X509_check_trust(x: ?*X509, id: c_int, flags: c_int) c_int;
+pub extern fn X509_TRUST_get_count() c_int;
+pub extern fn X509_TRUST_get0(idx: c_int) [*c]X509_TRUST;
+pub extern fn X509_TRUST_get_by_id(id: c_int) c_int;
+pub extern fn X509_TRUST_add(id: c_int, flags: c_int, ck: ?fn ([*c]X509_TRUST, ?*X509, c_int) callconv(.C) c_int, name: [*c]u8, arg1: c_int, arg2: ?*c_void) c_int;
+pub extern fn X509_TRUST_cleanup() void;
+pub extern fn X509_TRUST_get_flags(xp: [*c]const X509_TRUST) c_int;
+pub extern fn X509_TRUST_get0_name(xp: [*c]const X509_TRUST) [*c]u8;
+pub extern fn X509_TRUST_get_trust(xp: [*c]const X509_TRUST) c_int;
+pub extern fn RSA_PSS_PARAMS_new() [*c]RSA_PSS_PARAMS;
+pub extern fn RSA_PSS_PARAMS_free(a: [*c]RSA_PSS_PARAMS) void;
+pub extern fn d2i_RSA_PSS_PARAMS(a: [*c][*c]RSA_PSS_PARAMS, in: [*c][*c]const u8, len: c_long) [*c]RSA_PSS_PARAMS;
+pub extern fn i2d_RSA_PSS_PARAMS(a: [*c]RSA_PSS_PARAMS, out: [*c][*c]u8) c_int;
+pub extern const RSA_PSS_PARAMS_it: ASN1_ITEM;
+pub const struct_stack_st_X509_LOOKUP = opaque {};
+pub const stack_X509_LOOKUP_free_func = ?fn (?*X509_LOOKUP) callconv(.C) void;
+pub const stack_X509_LOOKUP_copy_func = ?fn (?*X509_LOOKUP) callconv(.C) ?*X509_LOOKUP;
+pub const stack_X509_LOOKUP_cmp_func = ?fn ([*c]?*const X509_LOOKUP, [*c]?*const X509_LOOKUP) callconv(.C) c_int;
+pub fn sk_X509_LOOKUP_call_free_func(arg_free_func: stack_free_func, arg_ptr: ?*c_void) callconv(.C) void {
+ var free_func = arg_free_func;
+ var ptr = arg_ptr;
+ @ptrCast(stack_X509_LOOKUP_free_func, @alignCast(@import("std").meta.alignment(fn (?*X509_LOOKUP) callconv(.C) void), free_func)).?(@ptrCast(?*X509_LOOKUP, ptr));
+}
+pub fn sk_X509_LOOKUP_call_copy_func(arg_copy_func: stack_copy_func, arg_ptr: ?*c_void) callconv(.C) ?*c_void {
+ var copy_func = arg_copy_func;
+ var ptr = arg_ptr;
+ return @ptrCast(?*c_void, @ptrCast(stack_X509_LOOKUP_copy_func, @alignCast(@import("std").meta.alignment(fn (?*X509_LOOKUP) callconv(.C) ?*X509_LOOKUP), copy_func)).?(@ptrCast(?*X509_LOOKUP, ptr)));
+}
+pub fn sk_X509_LOOKUP_call_cmp_func(arg_cmp_func: stack_cmp_func, arg_a: [*c]?*const c_void, arg_b: [*c]?*const c_void) callconv(.C) c_int {
+ var cmp_func = arg_cmp_func;
+ var a = arg_a;
+ var b = arg_b;
+ var a_ptr: ?*const X509_LOOKUP = @ptrCast(?*const X509_LOOKUP, a.*);
+ var b_ptr: ?*const X509_LOOKUP = @ptrCast(?*const X509_LOOKUP, b.*);
+ return @ptrCast(stack_X509_LOOKUP_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const X509_LOOKUP, [*c]?*const X509_LOOKUP) callconv(.C) c_int), cmp_func)).?(&a_ptr, &b_ptr);
+}
+pub fn sk_X509_LOOKUP_new(arg_comp: stack_X509_LOOKUP_cmp_func) callconv(.C) ?*struct_stack_st_X509_LOOKUP {
+ var comp = arg_comp;
+ return @ptrCast(?*struct_stack_st_X509_LOOKUP, sk_new(@ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp))));
+}
+pub fn sk_X509_LOOKUP_new_null() callconv(.C) ?*struct_stack_st_X509_LOOKUP {
+ return @ptrCast(?*struct_stack_st_X509_LOOKUP, sk_new_null());
+}
+pub fn sk_X509_LOOKUP_num(arg_sk: ?*const struct_stack_st_X509_LOOKUP) callconv(.C) usize {
+ var sk = arg_sk;
+ return sk_num(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_LOOKUP_zero(arg_sk: ?*struct_stack_st_X509_LOOKUP) callconv(.C) void {
+ var sk = arg_sk;
+ sk_zero(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_LOOKUP_value(arg_sk: ?*const struct_stack_st_X509_LOOKUP, arg_i: usize) callconv(.C) ?*X509_LOOKUP {
+ var sk = arg_sk;
+ var i = arg_i;
+ return @ptrCast(?*X509_LOOKUP, sk_value(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i));
+}
+pub fn sk_X509_LOOKUP_set(arg_sk: ?*struct_stack_st_X509_LOOKUP, arg_i: usize, arg_p: ?*X509_LOOKUP) callconv(.C) ?*X509_LOOKUP {
+ var sk = arg_sk;
+ var i = arg_i;
+ var p = arg_p;
+ return @ptrCast(?*X509_LOOKUP, sk_set(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i, @ptrCast(?*c_void, p)));
+}
+pub fn sk_X509_LOOKUP_free(arg_sk: ?*struct_stack_st_X509_LOOKUP) callconv(.C) void {
+ var sk = arg_sk;
+ sk_free(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_LOOKUP_pop_free(arg_sk: ?*struct_stack_st_X509_LOOKUP, arg_free_func: stack_X509_LOOKUP_free_func) callconv(.C) void {
+ var sk = arg_sk;
+ var free_func = arg_free_func;
+ sk_pop_free_ex(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_X509_LOOKUP_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func)));
+}
+pub fn sk_X509_LOOKUP_insert(arg_sk: ?*struct_stack_st_X509_LOOKUP, arg_p: ?*X509_LOOKUP, arg_where: usize) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ var where = arg_where;
+ return sk_insert(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p), where);
+}
+pub fn sk_X509_LOOKUP_delete(arg_sk: ?*struct_stack_st_X509_LOOKUP, arg_where: usize) callconv(.C) ?*X509_LOOKUP {
+ var sk = arg_sk;
+ var where = arg_where;
+ return @ptrCast(?*X509_LOOKUP, sk_delete(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), where));
+}
+pub fn sk_X509_LOOKUP_delete_ptr(arg_sk: ?*struct_stack_st_X509_LOOKUP, arg_p: ?*const X509_LOOKUP) callconv(.C) ?*X509_LOOKUP {
+ var sk = arg_sk;
+ var p = arg_p;
+ return @ptrCast(?*X509_LOOKUP, sk_delete_ptr(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*const c_void, p)));
+}
+pub fn sk_X509_LOOKUP_find(arg_sk: ?*const struct_stack_st_X509_LOOKUP, arg_out_index: [*c]usize, arg_p: ?*const X509_LOOKUP) callconv(.C) c_int {
+ var sk = arg_sk;
+ var out_index = arg_out_index;
+ var p = arg_p;
+ return sk_find(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), out_index, @ptrCast(?*const c_void, p), sk_X509_LOOKUP_call_cmp_func);
+}
+pub fn sk_X509_LOOKUP_shift(arg_sk: ?*struct_stack_st_X509_LOOKUP) callconv(.C) ?*X509_LOOKUP {
+ var sk = arg_sk;
+ return @ptrCast(?*X509_LOOKUP, sk_shift(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_LOOKUP_push(arg_sk: ?*struct_stack_st_X509_LOOKUP, arg_p: ?*X509_LOOKUP) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ return sk_push(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p));
+}
+pub fn sk_X509_LOOKUP_pop(arg_sk: ?*struct_stack_st_X509_LOOKUP) callconv(.C) ?*X509_LOOKUP {
+ var sk = arg_sk;
+ return @ptrCast(?*X509_LOOKUP, sk_pop(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_LOOKUP_dup(arg_sk: ?*const struct_stack_st_X509_LOOKUP) callconv(.C) ?*struct_stack_st_X509_LOOKUP {
+ var sk = arg_sk;
+ return @ptrCast(?*struct_stack_st_X509_LOOKUP, sk_dup(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_LOOKUP_sort(arg_sk: ?*struct_stack_st_X509_LOOKUP) callconv(.C) void {
+ var sk = arg_sk;
+ sk_sort(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_LOOKUP_is_sorted(arg_sk: ?*const struct_stack_st_X509_LOOKUP) callconv(.C) c_int {
+ var sk = arg_sk;
+ return sk_is_sorted(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_LOOKUP_set_cmp_func(arg_sk: ?*struct_stack_st_X509_LOOKUP, arg_comp: stack_X509_LOOKUP_cmp_func) callconv(.C) stack_X509_LOOKUP_cmp_func {
+ var sk = arg_sk;
+ var comp = arg_comp;
+ return @ptrCast(stack_X509_LOOKUP_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const X509_LOOKUP, [*c]?*const X509_LOOKUP) callconv(.C) c_int), sk_set_cmp_func(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp)))));
+}
+pub fn sk_X509_LOOKUP_deep_copy(arg_sk: ?*const struct_stack_st_X509_LOOKUP, arg_copy_func: ?fn (?*X509_LOOKUP) callconv(.C) ?*X509_LOOKUP, arg_free_func: ?fn (?*X509_LOOKUP) callconv(.C) void) callconv(.C) ?*struct_stack_st_X509_LOOKUP {
+ var sk = arg_sk;
+ var copy_func = arg_copy_func;
+ var free_func = arg_free_func;
+ return @ptrCast(?*struct_stack_st_X509_LOOKUP, sk_deep_copy(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_X509_LOOKUP_call_copy_func, @ptrCast(stack_copy_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) ?*c_void), copy_func)), sk_X509_LOOKUP_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func))));
+}
+pub const struct_stack_st_X509_OBJECT = opaque {};
+pub const stack_X509_OBJECT_free_func = ?fn (?*X509_OBJECT) callconv(.C) void;
+pub const stack_X509_OBJECT_copy_func = ?fn (?*X509_OBJECT) callconv(.C) ?*X509_OBJECT;
+pub const stack_X509_OBJECT_cmp_func = ?fn ([*c]?*const X509_OBJECT, [*c]?*const X509_OBJECT) callconv(.C) c_int;
+pub fn sk_X509_OBJECT_call_free_func(arg_free_func: stack_free_func, arg_ptr: ?*c_void) callconv(.C) void {
+ var free_func = arg_free_func;
+ var ptr = arg_ptr;
+ @ptrCast(stack_X509_OBJECT_free_func, @alignCast(@import("std").meta.alignment(fn (?*X509_OBJECT) callconv(.C) void), free_func)).?(@ptrCast(?*X509_OBJECT, ptr));
+}
+pub fn sk_X509_OBJECT_call_copy_func(arg_copy_func: stack_copy_func, arg_ptr: ?*c_void) callconv(.C) ?*c_void {
+ var copy_func = arg_copy_func;
+ var ptr = arg_ptr;
+ return @ptrCast(?*c_void, @ptrCast(stack_X509_OBJECT_copy_func, @alignCast(@import("std").meta.alignment(fn (?*X509_OBJECT) callconv(.C) ?*X509_OBJECT), copy_func)).?(@ptrCast(?*X509_OBJECT, ptr)));
+}
+pub fn sk_X509_OBJECT_call_cmp_func(arg_cmp_func: stack_cmp_func, arg_a: [*c]?*const c_void, arg_b: [*c]?*const c_void) callconv(.C) c_int {
+ var cmp_func = arg_cmp_func;
+ var a = arg_a;
+ var b = arg_b;
+ var a_ptr: ?*const X509_OBJECT = @ptrCast(?*const X509_OBJECT, a.*);
+ var b_ptr: ?*const X509_OBJECT = @ptrCast(?*const X509_OBJECT, b.*);
+ return @ptrCast(stack_X509_OBJECT_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const X509_OBJECT, [*c]?*const X509_OBJECT) callconv(.C) c_int), cmp_func)).?(&a_ptr, &b_ptr);
+}
+pub fn sk_X509_OBJECT_new(arg_comp: stack_X509_OBJECT_cmp_func) callconv(.C) ?*struct_stack_st_X509_OBJECT {
+ var comp = arg_comp;
+ return @ptrCast(?*struct_stack_st_X509_OBJECT, sk_new(@ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp))));
+}
+pub fn sk_X509_OBJECT_new_null() callconv(.C) ?*struct_stack_st_X509_OBJECT {
+ return @ptrCast(?*struct_stack_st_X509_OBJECT, sk_new_null());
+}
+pub fn sk_X509_OBJECT_num(arg_sk: ?*const struct_stack_st_X509_OBJECT) callconv(.C) usize {
+ var sk = arg_sk;
+ return sk_num(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_OBJECT_zero(arg_sk: ?*struct_stack_st_X509_OBJECT) callconv(.C) void {
+ var sk = arg_sk;
+ sk_zero(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_OBJECT_value(arg_sk: ?*const struct_stack_st_X509_OBJECT, arg_i: usize) callconv(.C) ?*X509_OBJECT {
+ var sk = arg_sk;
+ var i = arg_i;
+ return @ptrCast(?*X509_OBJECT, sk_value(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i));
+}
+pub fn sk_X509_OBJECT_set(arg_sk: ?*struct_stack_st_X509_OBJECT, arg_i: usize, arg_p: ?*X509_OBJECT) callconv(.C) ?*X509_OBJECT {
+ var sk = arg_sk;
+ var i = arg_i;
+ var p = arg_p;
+ return @ptrCast(?*X509_OBJECT, sk_set(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i, @ptrCast(?*c_void, p)));
+}
+pub fn sk_X509_OBJECT_free(arg_sk: ?*struct_stack_st_X509_OBJECT) callconv(.C) void {
+ var sk = arg_sk;
+ sk_free(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_OBJECT_pop_free(arg_sk: ?*struct_stack_st_X509_OBJECT, arg_free_func: stack_X509_OBJECT_free_func) callconv(.C) void {
+ var sk = arg_sk;
+ var free_func = arg_free_func;
+ sk_pop_free_ex(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_X509_OBJECT_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func)));
+}
+pub fn sk_X509_OBJECT_insert(arg_sk: ?*struct_stack_st_X509_OBJECT, arg_p: ?*X509_OBJECT, arg_where: usize) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ var where = arg_where;
+ return sk_insert(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p), where);
+}
+pub fn sk_X509_OBJECT_delete(arg_sk: ?*struct_stack_st_X509_OBJECT, arg_where: usize) callconv(.C) ?*X509_OBJECT {
+ var sk = arg_sk;
+ var where = arg_where;
+ return @ptrCast(?*X509_OBJECT, sk_delete(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), where));
+}
+pub fn sk_X509_OBJECT_delete_ptr(arg_sk: ?*struct_stack_st_X509_OBJECT, arg_p: ?*const X509_OBJECT) callconv(.C) ?*X509_OBJECT {
+ var sk = arg_sk;
+ var p = arg_p;
+ return @ptrCast(?*X509_OBJECT, sk_delete_ptr(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*const c_void, p)));
+}
+pub fn sk_X509_OBJECT_find(arg_sk: ?*const struct_stack_st_X509_OBJECT, arg_out_index: [*c]usize, arg_p: ?*const X509_OBJECT) callconv(.C) c_int {
+ var sk = arg_sk;
+ var out_index = arg_out_index;
+ var p = arg_p;
+ return sk_find(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), out_index, @ptrCast(?*const c_void, p), sk_X509_OBJECT_call_cmp_func);
+}
+pub fn sk_X509_OBJECT_shift(arg_sk: ?*struct_stack_st_X509_OBJECT) callconv(.C) ?*X509_OBJECT {
+ var sk = arg_sk;
+ return @ptrCast(?*X509_OBJECT, sk_shift(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_OBJECT_push(arg_sk: ?*struct_stack_st_X509_OBJECT, arg_p: ?*X509_OBJECT) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ return sk_push(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p));
+}
+pub fn sk_X509_OBJECT_pop(arg_sk: ?*struct_stack_st_X509_OBJECT) callconv(.C) ?*X509_OBJECT {
+ var sk = arg_sk;
+ return @ptrCast(?*X509_OBJECT, sk_pop(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_OBJECT_dup(arg_sk: ?*const struct_stack_st_X509_OBJECT) callconv(.C) ?*struct_stack_st_X509_OBJECT {
+ var sk = arg_sk;
+ return @ptrCast(?*struct_stack_st_X509_OBJECT, sk_dup(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_OBJECT_sort(arg_sk: ?*struct_stack_st_X509_OBJECT) callconv(.C) void {
+ var sk = arg_sk;
+ sk_sort(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_OBJECT_is_sorted(arg_sk: ?*const struct_stack_st_X509_OBJECT) callconv(.C) c_int {
+ var sk = arg_sk;
+ return sk_is_sorted(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_OBJECT_set_cmp_func(arg_sk: ?*struct_stack_st_X509_OBJECT, arg_comp: stack_X509_OBJECT_cmp_func) callconv(.C) stack_X509_OBJECT_cmp_func {
+ var sk = arg_sk;
+ var comp = arg_comp;
+ return @ptrCast(stack_X509_OBJECT_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const X509_OBJECT, [*c]?*const X509_OBJECT) callconv(.C) c_int), sk_set_cmp_func(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp)))));
+}
+pub fn sk_X509_OBJECT_deep_copy(arg_sk: ?*const struct_stack_st_X509_OBJECT, arg_copy_func: ?fn (?*X509_OBJECT) callconv(.C) ?*X509_OBJECT, arg_free_func: ?fn (?*X509_OBJECT) callconv(.C) void) callconv(.C) ?*struct_stack_st_X509_OBJECT {
+ var sk = arg_sk;
+ var copy_func = arg_copy_func;
+ var free_func = arg_free_func;
+ return @ptrCast(?*struct_stack_st_X509_OBJECT, sk_deep_copy(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_X509_OBJECT_call_copy_func, @ptrCast(stack_copy_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) ?*c_void), copy_func)), sk_X509_OBJECT_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func))));
+}
+pub const struct_stack_st_X509_VERIFY_PARAM = opaque {};
+pub const stack_X509_VERIFY_PARAM_free_func = ?fn (?*X509_VERIFY_PARAM) callconv(.C) void;
+pub const stack_X509_VERIFY_PARAM_copy_func = ?fn (?*X509_VERIFY_PARAM) callconv(.C) ?*X509_VERIFY_PARAM;
+pub const stack_X509_VERIFY_PARAM_cmp_func = ?fn ([*c]?*const X509_VERIFY_PARAM, [*c]?*const X509_VERIFY_PARAM) callconv(.C) c_int;
+pub fn sk_X509_VERIFY_PARAM_call_free_func(arg_free_func: stack_free_func, arg_ptr: ?*c_void) callconv(.C) void {
+ var free_func = arg_free_func;
+ var ptr = arg_ptr;
+ @ptrCast(stack_X509_VERIFY_PARAM_free_func, @alignCast(@import("std").meta.alignment(fn (?*X509_VERIFY_PARAM) callconv(.C) void), free_func)).?(@ptrCast(?*X509_VERIFY_PARAM, ptr));
+}
+pub fn sk_X509_VERIFY_PARAM_call_copy_func(arg_copy_func: stack_copy_func, arg_ptr: ?*c_void) callconv(.C) ?*c_void {
+ var copy_func = arg_copy_func;
+ var ptr = arg_ptr;
+ return @ptrCast(?*c_void, @ptrCast(stack_X509_VERIFY_PARAM_copy_func, @alignCast(@import("std").meta.alignment(fn (?*X509_VERIFY_PARAM) callconv(.C) ?*X509_VERIFY_PARAM), copy_func)).?(@ptrCast(?*X509_VERIFY_PARAM, ptr)));
+}
+pub fn sk_X509_VERIFY_PARAM_call_cmp_func(arg_cmp_func: stack_cmp_func, arg_a: [*c]?*const c_void, arg_b: [*c]?*const c_void) callconv(.C) c_int {
+ var cmp_func = arg_cmp_func;
+ var a = arg_a;
+ var b = arg_b;
+ var a_ptr: ?*const X509_VERIFY_PARAM = @ptrCast(?*const X509_VERIFY_PARAM, a.*);
+ var b_ptr: ?*const X509_VERIFY_PARAM = @ptrCast(?*const X509_VERIFY_PARAM, b.*);
+ return @ptrCast(stack_X509_VERIFY_PARAM_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const X509_VERIFY_PARAM, [*c]?*const X509_VERIFY_PARAM) callconv(.C) c_int), cmp_func)).?(&a_ptr, &b_ptr);
+}
+pub fn sk_X509_VERIFY_PARAM_new(arg_comp: stack_X509_VERIFY_PARAM_cmp_func) callconv(.C) ?*struct_stack_st_X509_VERIFY_PARAM {
+ var comp = arg_comp;
+ return @ptrCast(?*struct_stack_st_X509_VERIFY_PARAM, sk_new(@ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp))));
+}
+pub fn sk_X509_VERIFY_PARAM_new_null() callconv(.C) ?*struct_stack_st_X509_VERIFY_PARAM {
+ return @ptrCast(?*struct_stack_st_X509_VERIFY_PARAM, sk_new_null());
+}
+pub fn sk_X509_VERIFY_PARAM_num(arg_sk: ?*const struct_stack_st_X509_VERIFY_PARAM) callconv(.C) usize {
+ var sk = arg_sk;
+ return sk_num(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_VERIFY_PARAM_zero(arg_sk: ?*struct_stack_st_X509_VERIFY_PARAM) callconv(.C) void {
+ var sk = arg_sk;
+ sk_zero(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_VERIFY_PARAM_value(arg_sk: ?*const struct_stack_st_X509_VERIFY_PARAM, arg_i: usize) callconv(.C) ?*X509_VERIFY_PARAM {
+ var sk = arg_sk;
+ var i = arg_i;
+ return @ptrCast(?*X509_VERIFY_PARAM, sk_value(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i));
+}
+pub fn sk_X509_VERIFY_PARAM_set(arg_sk: ?*struct_stack_st_X509_VERIFY_PARAM, arg_i: usize, arg_p: ?*X509_VERIFY_PARAM) callconv(.C) ?*X509_VERIFY_PARAM {
+ var sk = arg_sk;
+ var i = arg_i;
+ var p = arg_p;
+ return @ptrCast(?*X509_VERIFY_PARAM, sk_set(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i, @ptrCast(?*c_void, p)));
+}
+pub fn sk_X509_VERIFY_PARAM_free(arg_sk: ?*struct_stack_st_X509_VERIFY_PARAM) callconv(.C) void {
+ var sk = arg_sk;
+ sk_free(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_VERIFY_PARAM_pop_free(arg_sk: ?*struct_stack_st_X509_VERIFY_PARAM, arg_free_func: stack_X509_VERIFY_PARAM_free_func) callconv(.C) void {
+ var sk = arg_sk;
+ var free_func = arg_free_func;
+ sk_pop_free_ex(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_X509_VERIFY_PARAM_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func)));
+}
+pub fn sk_X509_VERIFY_PARAM_insert(arg_sk: ?*struct_stack_st_X509_VERIFY_PARAM, arg_p: ?*X509_VERIFY_PARAM, arg_where: usize) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ var where = arg_where;
+ return sk_insert(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p), where);
+}
+pub fn sk_X509_VERIFY_PARAM_delete(arg_sk: ?*struct_stack_st_X509_VERIFY_PARAM, arg_where: usize) callconv(.C) ?*X509_VERIFY_PARAM {
+ var sk = arg_sk;
+ var where = arg_where;
+ return @ptrCast(?*X509_VERIFY_PARAM, sk_delete(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), where));
+}
+pub fn sk_X509_VERIFY_PARAM_delete_ptr(arg_sk: ?*struct_stack_st_X509_VERIFY_PARAM, arg_p: ?*const X509_VERIFY_PARAM) callconv(.C) ?*X509_VERIFY_PARAM {
+ var sk = arg_sk;
+ var p = arg_p;
+ return @ptrCast(?*X509_VERIFY_PARAM, sk_delete_ptr(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*const c_void, p)));
+}
+pub fn sk_X509_VERIFY_PARAM_find(arg_sk: ?*const struct_stack_st_X509_VERIFY_PARAM, arg_out_index: [*c]usize, arg_p: ?*const X509_VERIFY_PARAM) callconv(.C) c_int {
+ var sk = arg_sk;
+ var out_index = arg_out_index;
+ var p = arg_p;
+ return sk_find(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), out_index, @ptrCast(?*const c_void, p), sk_X509_VERIFY_PARAM_call_cmp_func);
+}
+pub fn sk_X509_VERIFY_PARAM_shift(arg_sk: ?*struct_stack_st_X509_VERIFY_PARAM) callconv(.C) ?*X509_VERIFY_PARAM {
+ var sk = arg_sk;
+ return @ptrCast(?*X509_VERIFY_PARAM, sk_shift(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_VERIFY_PARAM_push(arg_sk: ?*struct_stack_st_X509_VERIFY_PARAM, arg_p: ?*X509_VERIFY_PARAM) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ return sk_push(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p));
+}
+pub fn sk_X509_VERIFY_PARAM_pop(arg_sk: ?*struct_stack_st_X509_VERIFY_PARAM) callconv(.C) ?*X509_VERIFY_PARAM {
+ var sk = arg_sk;
+ return @ptrCast(?*X509_VERIFY_PARAM, sk_pop(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_VERIFY_PARAM_dup(arg_sk: ?*const struct_stack_st_X509_VERIFY_PARAM) callconv(.C) ?*struct_stack_st_X509_VERIFY_PARAM {
+ var sk = arg_sk;
+ return @ptrCast(?*struct_stack_st_X509_VERIFY_PARAM, sk_dup(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_X509_VERIFY_PARAM_sort(arg_sk: ?*struct_stack_st_X509_VERIFY_PARAM) callconv(.C) void {
+ var sk = arg_sk;
+ sk_sort(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_VERIFY_PARAM_is_sorted(arg_sk: ?*const struct_stack_st_X509_VERIFY_PARAM) callconv(.C) c_int {
+ var sk = arg_sk;
+ return sk_is_sorted(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_X509_VERIFY_PARAM_set_cmp_func(arg_sk: ?*struct_stack_st_X509_VERIFY_PARAM, arg_comp: stack_X509_VERIFY_PARAM_cmp_func) callconv(.C) stack_X509_VERIFY_PARAM_cmp_func {
+ var sk = arg_sk;
+ var comp = arg_comp;
+ return @ptrCast(stack_X509_VERIFY_PARAM_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const X509_VERIFY_PARAM, [*c]?*const X509_VERIFY_PARAM) callconv(.C) c_int), sk_set_cmp_func(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp)))));
+}
+pub fn sk_X509_VERIFY_PARAM_deep_copy(arg_sk: ?*const struct_stack_st_X509_VERIFY_PARAM, arg_copy_func: ?fn (?*X509_VERIFY_PARAM) callconv(.C) ?*X509_VERIFY_PARAM, arg_free_func: ?fn (?*X509_VERIFY_PARAM) callconv(.C) void) callconv(.C) ?*struct_stack_st_X509_VERIFY_PARAM {
+ var sk = arg_sk;
+ var copy_func = arg_copy_func;
+ var free_func = arg_free_func;
+ return @ptrCast(?*struct_stack_st_X509_VERIFY_PARAM, sk_deep_copy(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_X509_VERIFY_PARAM_call_copy_func, @ptrCast(stack_copy_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) ?*c_void), copy_func)), sk_X509_VERIFY_PARAM_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func))));
+}
+pub const X509_STORE_CTX_verify_cb = ?fn (c_int, ?*X509_STORE_CTX) callconv(.C) c_int;
+pub const X509_STORE_CTX_verify_fn = ?fn (?*X509_STORE_CTX) callconv(.C) c_int;
+pub const X509_STORE_CTX_get_issuer_fn = ?fn ([*c]?*X509, ?*X509_STORE_CTX, ?*X509) callconv(.C) c_int;
+pub const X509_STORE_CTX_check_issued_fn = ?fn (?*X509_STORE_CTX, ?*X509, ?*X509) callconv(.C) c_int;
+pub const X509_STORE_CTX_check_revocation_fn = ?fn (?*X509_STORE_CTX) callconv(.C) c_int;
+pub const X509_STORE_CTX_get_crl_fn = ?fn (?*X509_STORE_CTX, [*c]?*X509_CRL, ?*X509) callconv(.C) c_int;
+pub const X509_STORE_CTX_check_crl_fn = ?fn (?*X509_STORE_CTX, ?*X509_CRL) callconv(.C) c_int;
+pub const X509_STORE_CTX_cert_crl_fn = ?fn (?*X509_STORE_CTX, ?*X509_CRL, ?*X509) callconv(.C) c_int;
+pub const X509_STORE_CTX_check_policy_fn = ?fn (?*X509_STORE_CTX) callconv(.C) c_int;
+pub const X509_STORE_CTX_lookup_certs_fn = ?fn (?*X509_STORE_CTX, ?*X509_NAME) callconv(.C) ?*struct_stack_st_X509;
+pub const X509_STORE_CTX_lookup_crls_fn = ?fn (?*X509_STORE_CTX, ?*X509_NAME) callconv(.C) ?*struct_stack_st_X509_CRL;
+pub const X509_STORE_CTX_cleanup_fn = ?fn (?*X509_STORE_CTX) callconv(.C) c_int;
+pub extern fn X509_STORE_set_depth(store: ?*X509_STORE, depth: c_int) c_int;
+pub extern fn X509_STORE_CTX_set_depth(ctx: ?*X509_STORE_CTX, depth: c_int) void;
+pub extern fn X509_OBJECT_idx_by_subject(h: ?*struct_stack_st_X509_OBJECT, @"type": c_int, name: ?*X509_NAME) c_int;
+pub extern fn X509_OBJECT_retrieve_by_subject(h: ?*struct_stack_st_X509_OBJECT, @"type": c_int, name: ?*X509_NAME) ?*X509_OBJECT;
+pub extern fn X509_OBJECT_retrieve_match(h: ?*struct_stack_st_X509_OBJECT, x: ?*X509_OBJECT) ?*X509_OBJECT;
+pub extern fn X509_OBJECT_up_ref_count(a: ?*X509_OBJECT) c_int;
+pub extern fn X509_OBJECT_free_contents(a: ?*X509_OBJECT) void;
+pub extern fn X509_OBJECT_get_type(a: ?*const X509_OBJECT) c_int;
+pub extern fn X509_OBJECT_get0_X509(a: ?*const X509_OBJECT) ?*X509;
+pub extern fn X509_STORE_new() ?*X509_STORE;
+pub extern fn X509_STORE_up_ref(store: ?*X509_STORE) c_int;
+pub extern fn X509_STORE_free(v: ?*X509_STORE) void;
+pub extern fn X509_STORE_get0_objects(st: ?*X509_STORE) ?*struct_stack_st_X509_OBJECT;
+pub extern fn X509_STORE_get1_certs(st: ?*X509_STORE_CTX, nm: ?*X509_NAME) ?*struct_stack_st_X509;
+pub extern fn X509_STORE_get1_crls(st: ?*X509_STORE_CTX, nm: ?*X509_NAME) ?*struct_stack_st_X509_CRL;
+pub extern fn X509_STORE_set_flags(ctx: ?*X509_STORE, flags: c_ulong) c_int;
+pub extern fn X509_STORE_set_purpose(ctx: ?*X509_STORE, purpose: c_int) c_int;
+pub extern fn X509_STORE_set_trust(ctx: ?*X509_STORE, trust: c_int) c_int;
+pub extern fn X509_STORE_set1_param(ctx: ?*X509_STORE, pm: ?*X509_VERIFY_PARAM) c_int;
+pub extern fn X509_STORE_get0_param(ctx: ?*X509_STORE) ?*X509_VERIFY_PARAM;
+pub extern fn X509_STORE_set_verify(ctx: ?*X509_STORE, verify: X509_STORE_CTX_verify_fn) void;
+pub extern fn X509_STORE_CTX_set_verify(ctx: ?*X509_STORE_CTX, verify: X509_STORE_CTX_verify_fn) void;
+pub extern fn X509_STORE_get_verify(ctx: ?*X509_STORE) X509_STORE_CTX_verify_fn;
+pub extern fn X509_STORE_set_verify_cb(ctx: ?*X509_STORE, verify_cb: X509_STORE_CTX_verify_cb) void;
+pub extern fn X509_STORE_get_verify_cb(ctx: ?*X509_STORE) X509_STORE_CTX_verify_cb;
+pub extern fn X509_STORE_set_get_issuer(ctx: ?*X509_STORE, get_issuer: X509_STORE_CTX_get_issuer_fn) void;
+pub extern fn X509_STORE_get_get_issuer(ctx: ?*X509_STORE) X509_STORE_CTX_get_issuer_fn;
+pub extern fn X509_STORE_set_check_issued(ctx: ?*X509_STORE, check_issued: X509_STORE_CTX_check_issued_fn) void;
+pub extern fn X509_STORE_get_check_issued(ctx: ?*X509_STORE) X509_STORE_CTX_check_issued_fn;
+pub extern fn X509_STORE_set_check_revocation(ctx: ?*X509_STORE, check_revocation: X509_STORE_CTX_check_revocation_fn) void;
+pub extern fn X509_STORE_get_check_revocation(ctx: ?*X509_STORE) X509_STORE_CTX_check_revocation_fn;
+pub extern fn X509_STORE_set_get_crl(ctx: ?*X509_STORE, get_crl: X509_STORE_CTX_get_crl_fn) void;
+pub extern fn X509_STORE_get_get_crl(ctx: ?*X509_STORE) X509_STORE_CTX_get_crl_fn;
+pub extern fn X509_STORE_set_check_crl(ctx: ?*X509_STORE, check_crl: X509_STORE_CTX_check_crl_fn) void;
+pub extern fn X509_STORE_get_check_crl(ctx: ?*X509_STORE) X509_STORE_CTX_check_crl_fn;
+pub extern fn X509_STORE_set_cert_crl(ctx: ?*X509_STORE, cert_crl: X509_STORE_CTX_cert_crl_fn) void;
+pub extern fn X509_STORE_get_cert_crl(ctx: ?*X509_STORE) X509_STORE_CTX_cert_crl_fn;
+pub extern fn X509_STORE_set_lookup_certs(ctx: ?*X509_STORE, lookup_certs: X509_STORE_CTX_lookup_certs_fn) void;
+pub extern fn X509_STORE_get_lookup_certs(ctx: ?*X509_STORE) X509_STORE_CTX_lookup_certs_fn;
+pub extern fn X509_STORE_set_lookup_crls(ctx: ?*X509_STORE, lookup_crls: X509_STORE_CTX_lookup_crls_fn) void;
+pub extern fn X509_STORE_get_lookup_crls(ctx: ?*X509_STORE) X509_STORE_CTX_lookup_crls_fn;
+pub extern fn X509_STORE_set_cleanup(ctx: ?*X509_STORE, cleanup: X509_STORE_CTX_cleanup_fn) void;
+pub extern fn X509_STORE_get_cleanup(ctx: ?*X509_STORE) X509_STORE_CTX_cleanup_fn;
+pub extern fn X509_STORE_CTX_new() ?*X509_STORE_CTX;
+pub extern fn X509_STORE_CTX_get1_issuer(issuer: [*c]?*X509, ctx: ?*X509_STORE_CTX, x: ?*X509) c_int;
+pub extern fn X509_STORE_CTX_zero(ctx: ?*X509_STORE_CTX) void;
+pub extern fn X509_STORE_CTX_free(ctx: ?*X509_STORE_CTX) void;
+pub extern fn X509_STORE_CTX_init(ctx: ?*X509_STORE_CTX, store: ?*X509_STORE, x509: ?*X509, chain: ?*struct_stack_st_X509) c_int;
+pub extern fn X509_STORE_CTX_trusted_stack(ctx: ?*X509_STORE_CTX, sk: ?*struct_stack_st_X509) void;
+pub extern fn X509_STORE_CTX_cleanup(ctx: ?*X509_STORE_CTX) void;
+pub extern fn X509_STORE_CTX_get0_store(ctx: ?*X509_STORE_CTX) ?*X509_STORE;
+pub extern fn X509_STORE_CTX_get0_cert(ctx: ?*X509_STORE_CTX) ?*X509;
+pub extern fn X509_STORE_add_lookup(v: ?*X509_STORE, m: ?*X509_LOOKUP_METHOD) ?*X509_LOOKUP;
+pub extern fn X509_LOOKUP_hash_dir() ?*X509_LOOKUP_METHOD;
+pub extern fn X509_LOOKUP_file() ?*X509_LOOKUP_METHOD;
+pub extern fn X509_STORE_add_cert(ctx: ?*X509_STORE, x: ?*X509) c_int;
+pub extern fn X509_STORE_add_crl(ctx: ?*X509_STORE, x: ?*X509_CRL) c_int;
+pub extern fn X509_STORE_get_by_subject(vs: ?*X509_STORE_CTX, @"type": c_int, name: ?*X509_NAME, ret: ?*X509_OBJECT) c_int;
+pub extern fn X509_LOOKUP_ctrl(ctx: ?*X509_LOOKUP, cmd: c_int, argc: [*c]const u8, argl: c_long, ret: [*c][*c]u8) c_int;
+pub extern fn X509_load_cert_file(ctx: ?*X509_LOOKUP, file: [*c]const u8, @"type": c_int) c_int;
+pub extern fn X509_load_crl_file(ctx: ?*X509_LOOKUP, file: [*c]const u8, @"type": c_int) c_int;
+pub extern fn X509_load_cert_crl_file(ctx: ?*X509_LOOKUP, file: [*c]const u8, @"type": c_int) c_int;
+pub extern fn X509_LOOKUP_new(method: ?*X509_LOOKUP_METHOD) ?*X509_LOOKUP;
+pub extern fn X509_LOOKUP_free(ctx: ?*X509_LOOKUP) void;
+pub extern fn X509_LOOKUP_init(ctx: ?*X509_LOOKUP) c_int;
+pub extern fn X509_LOOKUP_by_subject(ctx: ?*X509_LOOKUP, @"type": c_int, name: ?*X509_NAME, ret: ?*X509_OBJECT) c_int;
+pub extern fn X509_LOOKUP_by_issuer_serial(ctx: ?*X509_LOOKUP, @"type": c_int, name: ?*X509_NAME, serial: [*c]ASN1_INTEGER, ret: ?*X509_OBJECT) c_int;
+pub extern fn X509_LOOKUP_by_fingerprint(ctx: ?*X509_LOOKUP, @"type": c_int, bytes: [*c]u8, len: c_int, ret: ?*X509_OBJECT) c_int;
+pub extern fn X509_LOOKUP_by_alias(ctx: ?*X509_LOOKUP, @"type": c_int, str: [*c]u8, len: c_int, ret: ?*X509_OBJECT) c_int;
+pub extern fn X509_LOOKUP_shutdown(ctx: ?*X509_LOOKUP) c_int;
+pub extern fn X509_STORE_load_locations(ctx: ?*X509_STORE, file: [*c]const u8, dir: [*c]const u8) c_int;
+pub extern fn X509_STORE_set_default_paths(ctx: ?*X509_STORE) c_int;
+pub extern fn X509_STORE_CTX_get_ex_new_index(argl: c_long, argp: ?*c_void, unused: [*c]CRYPTO_EX_unused, dup_unused: ?CRYPTO_EX_dup, free_func: ?CRYPTO_EX_free) c_int;
+pub extern fn X509_STORE_CTX_set_ex_data(ctx: ?*X509_STORE_CTX, idx: c_int, data: ?*c_void) c_int;
+pub extern fn X509_STORE_CTX_get_ex_data(ctx: ?*X509_STORE_CTX, idx: c_int) ?*c_void;
+pub extern fn X509_STORE_CTX_get_error(ctx: ?*X509_STORE_CTX) c_int;
+pub extern fn X509_STORE_CTX_set_error(ctx: ?*X509_STORE_CTX, s: c_int) void;
+pub extern fn X509_STORE_CTX_get_error_depth(ctx: ?*X509_STORE_CTX) c_int;
+pub extern fn X509_STORE_CTX_get_current_cert(ctx: ?*X509_STORE_CTX) ?*X509;
+pub extern fn X509_STORE_CTX_get0_current_issuer(ctx: ?*X509_STORE_CTX) ?*X509;
+pub extern fn X509_STORE_CTX_get0_current_crl(ctx: ?*X509_STORE_CTX) ?*X509_CRL;
+pub extern fn X509_STORE_CTX_get0_parent_ctx(ctx: ?*X509_STORE_CTX) ?*X509_STORE_CTX;
+pub extern fn X509_STORE_CTX_get_chain(ctx: ?*X509_STORE_CTX) ?*struct_stack_st_X509;
+pub extern fn X509_STORE_CTX_get0_chain(ctx: ?*X509_STORE_CTX) ?*struct_stack_st_X509;
+pub extern fn X509_STORE_CTX_get1_chain(ctx: ?*X509_STORE_CTX) ?*struct_stack_st_X509;
+pub extern fn X509_STORE_CTX_set_cert(c: ?*X509_STORE_CTX, x: ?*X509) void;
+pub extern fn X509_STORE_CTX_set_chain(c: ?*X509_STORE_CTX, sk: ?*struct_stack_st_X509) void;
+pub extern fn X509_STORE_CTX_get0_untrusted(ctx: ?*X509_STORE_CTX) ?*struct_stack_st_X509;
+pub extern fn X509_STORE_CTX_set0_crls(c: ?*X509_STORE_CTX, sk: ?*struct_stack_st_X509_CRL) void;
+pub extern fn X509_STORE_CTX_set_purpose(ctx: ?*X509_STORE_CTX, purpose: c_int) c_int;
+pub extern fn X509_STORE_CTX_set_trust(ctx: ?*X509_STORE_CTX, trust: c_int) c_int;
+pub extern fn X509_STORE_CTX_purpose_inherit(ctx: ?*X509_STORE_CTX, def_purpose: c_int, purpose: c_int, trust: c_int) c_int;
+pub extern fn X509_STORE_CTX_set_flags(ctx: ?*X509_STORE_CTX, flags: c_ulong) void;
+pub extern fn X509_STORE_CTX_set_time(ctx: ?*X509_STORE_CTX, flags: c_ulong, t: time_t) void;
+pub extern fn X509_STORE_CTX_set_verify_cb(ctx: ?*X509_STORE_CTX, verify_cb: ?fn (c_int, ?*X509_STORE_CTX) callconv(.C) c_int) void;
+pub extern fn X509_STORE_CTX_get0_policy_tree(ctx: ?*X509_STORE_CTX) ?*X509_POLICY_TREE;
+pub extern fn X509_STORE_CTX_get_explicit_policy(ctx: ?*X509_STORE_CTX) c_int;
+pub extern fn X509_STORE_CTX_get0_param(ctx: ?*X509_STORE_CTX) ?*X509_VERIFY_PARAM;
+pub extern fn X509_STORE_CTX_set0_param(ctx: ?*X509_STORE_CTX, param: ?*X509_VERIFY_PARAM) void;
+pub extern fn X509_STORE_CTX_set_default(ctx: ?*X509_STORE_CTX, name: [*c]const u8) c_int;
+pub extern fn X509_VERIFY_PARAM_new() ?*X509_VERIFY_PARAM;
+pub extern fn X509_VERIFY_PARAM_free(param: ?*X509_VERIFY_PARAM) void;
+pub extern fn X509_VERIFY_PARAM_inherit(to: ?*X509_VERIFY_PARAM, from: ?*const X509_VERIFY_PARAM) c_int;
+pub extern fn X509_VERIFY_PARAM_set1(to: ?*X509_VERIFY_PARAM, from: ?*const X509_VERIFY_PARAM) c_int;
+pub extern fn X509_VERIFY_PARAM_set1_name(param: ?*X509_VERIFY_PARAM, name: [*c]const u8) c_int;
+pub extern fn X509_VERIFY_PARAM_set_flags(param: ?*X509_VERIFY_PARAM, flags: c_ulong) c_int;
+pub extern fn X509_VERIFY_PARAM_clear_flags(param: ?*X509_VERIFY_PARAM, flags: c_ulong) c_int;
+pub extern fn X509_VERIFY_PARAM_get_flags(param: ?*X509_VERIFY_PARAM) c_ulong;
+pub extern fn X509_VERIFY_PARAM_set_purpose(param: ?*X509_VERIFY_PARAM, purpose: c_int) c_int;
+pub extern fn X509_VERIFY_PARAM_set_trust(param: ?*X509_VERIFY_PARAM, trust: c_int) c_int;
+pub extern fn X509_VERIFY_PARAM_set_depth(param: ?*X509_VERIFY_PARAM, depth: c_int) void;
+pub extern fn X509_VERIFY_PARAM_set_time(param: ?*X509_VERIFY_PARAM, t: time_t) void;
+pub extern fn X509_VERIFY_PARAM_add0_policy(param: ?*X509_VERIFY_PARAM, policy: ?*ASN1_OBJECT) c_int;
+pub extern fn X509_VERIFY_PARAM_set1_policies(param: ?*X509_VERIFY_PARAM, policies: ?*struct_stack_st_ASN1_OBJECT) c_int;
+pub extern fn X509_VERIFY_PARAM_set1_host(param: ?*X509_VERIFY_PARAM, name: [*c]const u8, namelen: usize) c_int;
+pub extern fn X509_VERIFY_PARAM_add1_host(param: ?*X509_VERIFY_PARAM, name: [*c]const u8, namelen: usize) c_int;
+pub extern fn X509_VERIFY_PARAM_set_hostflags(param: ?*X509_VERIFY_PARAM, flags: c_uint) void;
+pub extern fn X509_VERIFY_PARAM_get0_peername(?*X509_VERIFY_PARAM) [*c]u8;
+pub extern fn X509_VERIFY_PARAM_set1_email(param: ?*X509_VERIFY_PARAM, email: [*c]const u8, emaillen: usize) c_int;
+pub extern fn X509_VERIFY_PARAM_set1_ip(param: ?*X509_VERIFY_PARAM, ip: [*c]const u8, iplen: usize) c_int;
+pub extern fn X509_VERIFY_PARAM_set1_ip_asc(param: ?*X509_VERIFY_PARAM, ipasc: [*c]const u8) c_int;
+pub extern fn X509_VERIFY_PARAM_get_depth(param: ?*const X509_VERIFY_PARAM) c_int;
+pub extern fn X509_VERIFY_PARAM_get0_name(param: ?*const X509_VERIFY_PARAM) [*c]const u8;
+pub extern fn X509_VERIFY_PARAM_add0_table(param: ?*X509_VERIFY_PARAM) c_int;
+pub extern fn X509_VERIFY_PARAM_get_count() c_int;
+pub extern fn X509_VERIFY_PARAM_get0(id: c_int) ?*const X509_VERIFY_PARAM;
+pub extern fn X509_VERIFY_PARAM_lookup(name: [*c]const u8) ?*const X509_VERIFY_PARAM;
+pub extern fn X509_VERIFY_PARAM_table_cleanup() void;
+pub extern fn X509_policy_check(ptree: [*c]?*X509_POLICY_TREE, pexplicit_policy: [*c]c_int, certs: ?*struct_stack_st_X509, policy_oids: ?*struct_stack_st_ASN1_OBJECT, flags: c_uint) c_int;
+pub extern fn X509_policy_tree_free(tree: ?*X509_POLICY_TREE) void;
+pub extern fn X509_policy_tree_level_count(tree: ?*const X509_POLICY_TREE) c_int;
+pub extern fn X509_policy_tree_get0_level(tree: ?*const X509_POLICY_TREE, i: c_int) ?*X509_POLICY_LEVEL;
+pub const struct_stack_st_X509_POLICY_NODE = opaque {};
+pub extern fn X509_policy_tree_get0_policies(tree: ?*const X509_POLICY_TREE) ?*struct_stack_st_X509_POLICY_NODE;
+pub extern fn X509_policy_tree_get0_user_policies(tree: ?*const X509_POLICY_TREE) ?*struct_stack_st_X509_POLICY_NODE;
+pub extern fn X509_policy_level_node_count(level: ?*X509_POLICY_LEVEL) c_int;
+pub extern fn X509_policy_level_get0_node(level: ?*X509_POLICY_LEVEL, i: c_int) ?*X509_POLICY_NODE;
+pub extern fn X509_policy_node_get0_policy(node: ?*const X509_POLICY_NODE) ?*const ASN1_OBJECT;
+pub const struct_stack_st_POLICYQUALINFO = opaque {};
+pub extern fn X509_policy_node_get0_qualifiers(node: ?*const X509_POLICY_NODE) ?*struct_stack_st_POLICYQUALINFO;
+pub extern fn X509_policy_node_get0_parent(node: ?*const X509_POLICY_NODE) ?*const X509_POLICY_NODE;
+
+pub extern fn OPENSSL_malloc(size: usize) ?*c_void;
+pub extern fn OPENSSL_free(ptr: ?*c_void) void;
+pub extern fn OPENSSL_realloc(ptr: ?*c_void, new_size: usize) ?*c_void;
+pub extern fn OPENSSL_cleanse(ptr: ?*c_void, len: usize) void;
+pub extern fn CRYPTO_memcmp(a: ?*const c_void, b: ?*const c_void, len: usize) c_int;
+pub extern fn OPENSSL_hash32(ptr: ?*const c_void, len: usize) u32;
+pub extern fn OPENSSL_strhash(s: [*c]const u8) u32;
+pub extern fn OPENSSL_strdup(s: [*c]const u8) [*c]u8;
+pub extern fn OPENSSL_strnlen(s: [*c]const u8, len: usize) usize;
+pub extern fn OPENSSL_tolower(c: c_int) c_int;
+pub extern fn OPENSSL_strcasecmp(a: [*c]const u8, b: [*c]const u8) c_int;
+pub extern fn OPENSSL_strncasecmp(a: [*c]const u8, b: [*c]const u8, n: usize) c_int;
+pub extern fn BIO_snprintf(buf: [*c]u8, n: usize, format: [*c]const u8, ...) c_int;
+pub extern fn BIO_vsnprintf(buf: [*c]u8, n: usize, format: [*c]const u8, args: va_list) c_int;
+pub extern fn OPENSSL_strndup(str: [*c]const u8, size: usize) [*c]u8;
+pub extern fn OPENSSL_memdup(data: ?*const c_void, size: usize) ?*c_void;
+pub extern fn OPENSSL_strlcpy(dst: [*c]u8, src: [*c]const u8, dst_size: usize) usize;
+pub extern fn OPENSSL_strlcat(dst: [*c]u8, src: [*c]const u8, dst_size: usize) usize;
+pub extern fn CRYPTO_malloc(size: usize, file: [*c]const u8, line: c_int) ?*c_void;
+pub extern fn CRYPTO_realloc(ptr: ?*c_void, new_size: usize, file: [*c]const u8, line: c_int) ?*c_void;
+pub extern fn CRYPTO_free(ptr: ?*c_void, file: [*c]const u8, line: c_int) void;
+pub extern fn OPENSSL_clear_free(ptr: ?*c_void, len: usize) void;
+pub extern fn CRYPTO_library_init() void;
+pub extern fn CRYPTO_is_confidential_build() c_int;
+pub extern fn CRYPTO_has_asm() c_int;
+pub extern fn BORINGSSL_self_test() c_int;
+pub extern fn CRYPTO_pre_sandbox_init() void;
+pub extern fn FIPS_mode() c_int;
+pub const fips_counter_evp_aes_128_gcm: c_int = 0;
+pub const fips_counter_evp_aes_256_gcm: c_int = 1;
+pub const fips_counter_evp_aes_128_ctr: c_int = 2;
+pub const fips_counter_evp_aes_256_ctr: c_int = 3;
+pub const fips_counter_max: c_int = 3;
+pub const enum_fips_counter_t = c_uint;
+pub extern fn FIPS_read_counter(counter: enum_fips_counter_t) usize;
+pub extern fn OpenSSL_version(which: c_int) [*c]const u8;
+pub extern fn SSLeay_version(which: c_int) [*c]const u8;
+pub extern fn SSLeay() c_ulong;
+pub extern fn OpenSSL_version_num() c_ulong;
+pub extern fn CRYPTO_malloc_init() c_int;
+pub extern fn OPENSSL_malloc_init() c_int;
+pub extern fn ENGINE_load_builtin_engines() void;
+pub extern fn ENGINE_register_all_complete() c_int;
+pub extern fn OPENSSL_load_builtin_modules() void;
+pub extern fn OPENSSL_init_crypto(opts: u64, settings: ?*const OPENSSL_INIT_SETTINGS) c_int;
+pub extern fn OPENSSL_cleanup() void;
+pub extern fn FIPS_mode_set(on: c_int) c_int;
+pub const pem_password_cb = fn ([*c]u8, c_int, c_int, ?*c_void) callconv(.C) c_int;
+pub extern fn PEM_get_EVP_CIPHER_INFO(header: [*c]u8, cipher: [*c]EVP_CIPHER_INFO) c_int;
+pub extern fn PEM_do_header(cipher: [*c]EVP_CIPHER_INFO, data: [*c]u8, len: [*c]c_long, callback: ?pem_password_cb, u: ?*c_void) c_int;
+pub extern fn PEM_read_bio(bp: [*c]BIO, name: [*c][*c]u8, header: [*c][*c]u8, data: [*c][*c]u8, len: [*c]c_long) c_int;
+pub extern fn PEM_write_bio(bp: [*c]BIO, name: [*c]const u8, hdr: [*c]const u8, data: [*c]const u8, len: c_long) c_int;
+pub extern fn PEM_bytes_read_bio(pdata: [*c][*c]u8, plen: [*c]c_long, pnm: [*c][*c]u8, name: [*c]const u8, bp: [*c]BIO, cb: ?pem_password_cb, u: ?*c_void) c_int;
+pub extern fn PEM_ASN1_read_bio(d2i: ?d2i_of_void, name: [*c]const u8, bp: [*c]BIO, x: [*c]?*c_void, cb: ?pem_password_cb, u: ?*c_void) ?*c_void;
+pub extern fn PEM_ASN1_write_bio(i2d: ?i2d_of_void, name: [*c]const u8, bp: [*c]BIO, x: ?*c_void, enc: [*c]const EVP_CIPHER, kstr: [*c]u8, klen: c_int, cb: ?pem_password_cb, u: ?*c_void) c_int;
+pub extern fn PEM_X509_INFO_read_bio(bp: [*c]BIO, sk: ?*struct_stack_st_X509_INFO, cb: ?pem_password_cb, u: ?*c_void) ?*struct_stack_st_X509_INFO;
+pub extern fn PEM_X509_INFO_write_bio(bp: [*c]BIO, xi: [*c]X509_INFO, enc: [*c]EVP_CIPHER, kstr: [*c]u8, klen: c_int, cd: ?pem_password_cb, u: ?*c_void) c_int;
+pub extern fn PEM_read(fp: [*c]FILE, name: [*c][*c]u8, header: [*c][*c]u8, data: [*c][*c]u8, len: [*c]c_long) c_int;
+pub extern fn PEM_write(fp: [*c]FILE, name: [*c]const u8, hdr: [*c]const u8, data: [*c]const u8, len: c_long) c_int;
+pub extern fn PEM_ASN1_read(d2i: ?d2i_of_void, name: [*c]const u8, fp: [*c]FILE, x: [*c]?*c_void, cb: ?pem_password_cb, u: ?*c_void) ?*c_void;
+pub extern fn PEM_ASN1_write(i2d: ?i2d_of_void, name: [*c]const u8, fp: [*c]FILE, x: ?*c_void, enc: [*c]const EVP_CIPHER, kstr: [*c]u8, klen: c_int, callback: ?pem_password_cb, u: ?*c_void) c_int;
+pub extern fn PEM_X509_INFO_read(fp: [*c]FILE, sk: ?*struct_stack_st_X509_INFO, cb: ?pem_password_cb, u: ?*c_void) ?*struct_stack_st_X509_INFO;
+pub extern fn PEM_def_callback(buf: [*c]u8, size: c_int, rwflag: c_int, userdata: ?*c_void) c_int;
+pub extern fn PEM_proc_type(buf: [*c]u8, @"type": c_int) void;
+pub extern fn PEM_dek_info(buf: [*c]u8, @"type": [*c]const u8, len: c_int, str: [*c]u8) void;
+pub extern fn PEM_read_bio_X509(bp: [*c]BIO, x: [*c]?*X509, cb: ?pem_password_cb, u: ?*c_void) ?*X509;
+pub extern fn PEM_read_X509(fp: [*c]FILE, x: [*c]?*X509, cb: ?pem_password_cb, u: ?*c_void) ?*X509;
+pub extern fn PEM_write_bio_X509(bp: [*c]BIO, x: ?*X509) c_int;
+pub extern fn PEM_write_X509(fp: [*c]FILE, x: ?*X509) c_int;
+pub extern fn PEM_read_bio_X509_AUX(bp: [*c]BIO, x: [*c]?*X509, cb: ?pem_password_cb, u: ?*c_void) ?*X509;
+pub extern fn PEM_read_X509_AUX(fp: [*c]FILE, x: [*c]?*X509, cb: ?pem_password_cb, u: ?*c_void) ?*X509;
+pub extern fn PEM_write_bio_X509_AUX(bp: [*c]BIO, x: ?*X509) c_int;
+pub extern fn PEM_write_X509_AUX(fp: [*c]FILE, x: ?*X509) c_int;
+pub extern fn PEM_read_bio_X509_REQ(bp: [*c]BIO, x: [*c]?*X509_REQ, cb: ?pem_password_cb, u: ?*c_void) ?*X509_REQ;
+pub extern fn PEM_read_X509_REQ(fp: [*c]FILE, x: [*c]?*X509_REQ, cb: ?pem_password_cb, u: ?*c_void) ?*X509_REQ;
+pub extern fn PEM_write_bio_X509_REQ(bp: [*c]BIO, x: ?*X509_REQ) c_int;
+pub extern fn PEM_write_X509_REQ(fp: [*c]FILE, x: ?*X509_REQ) c_int;
+pub extern fn PEM_write_bio_X509_REQ_NEW(bp: [*c]BIO, x: ?*X509_REQ) c_int;
+pub extern fn PEM_write_X509_REQ_NEW(fp: [*c]FILE, x: ?*X509_REQ) c_int;
+pub extern fn PEM_read_bio_X509_CRL(bp: [*c]BIO, x: [*c]?*X509_CRL, cb: ?pem_password_cb, u: ?*c_void) ?*X509_CRL;
+pub extern fn PEM_read_X509_CRL(fp: [*c]FILE, x: [*c]?*X509_CRL, cb: ?pem_password_cb, u: ?*c_void) ?*X509_CRL;
+pub extern fn PEM_write_bio_X509_CRL(bp: [*c]BIO, x: ?*X509_CRL) c_int;
+pub extern fn PEM_write_X509_CRL(fp: [*c]FILE, x: ?*X509_CRL) c_int;
+pub extern fn PEM_read_bio_PKCS7(bp: [*c]BIO, x: [*c][*c]PKCS7, cb: ?pem_password_cb, u: ?*c_void) [*c]PKCS7;
+pub extern fn PEM_read_PKCS7(fp: [*c]FILE, x: [*c][*c]PKCS7, cb: ?pem_password_cb, u: ?*c_void) [*c]PKCS7;
+pub extern fn PEM_write_bio_PKCS7(bp: [*c]BIO, x: [*c]PKCS7) c_int;
+pub extern fn PEM_write_PKCS7(fp: [*c]FILE, x: [*c]PKCS7) c_int;
+pub extern fn PEM_read_bio_PKCS8(bp: [*c]BIO, x: [*c]?*X509_SIG, cb: ?pem_password_cb, u: ?*c_void) ?*X509_SIG;
+pub extern fn PEM_read_PKCS8(fp: [*c]FILE, x: [*c]?*X509_SIG, cb: ?pem_password_cb, u: ?*c_void) ?*X509_SIG;
+pub extern fn PEM_write_bio_PKCS8(bp: [*c]BIO, x: ?*X509_SIG) c_int;
+pub extern fn PEM_write_PKCS8(fp: [*c]FILE, x: ?*X509_SIG) c_int;
+pub extern fn PEM_read_bio_PKCS8_PRIV_KEY_INFO(bp: [*c]BIO, x: [*c]?*PKCS8_PRIV_KEY_INFO, cb: ?pem_password_cb, u: ?*c_void) ?*PKCS8_PRIV_KEY_INFO;
+pub extern fn PEM_read_PKCS8_PRIV_KEY_INFO(fp: [*c]FILE, x: [*c]?*PKCS8_PRIV_KEY_INFO, cb: ?pem_password_cb, u: ?*c_void) ?*PKCS8_PRIV_KEY_INFO;
+pub extern fn PEM_write_bio_PKCS8_PRIV_KEY_INFO(bp: [*c]BIO, x: ?*PKCS8_PRIV_KEY_INFO) c_int;
+pub extern fn PEM_write_PKCS8_PRIV_KEY_INFO(fp: [*c]FILE, x: ?*PKCS8_PRIV_KEY_INFO) c_int;
+pub extern fn PEM_read_bio_RSAPrivateKey(bp: [*c]BIO, x: [*c]?*RSA, cb: ?pem_password_cb, u: ?*c_void) ?*RSA;
+pub extern fn PEM_read_RSAPrivateKey(fp: [*c]FILE, x: [*c]?*RSA, cb: ?pem_password_cb, u: ?*c_void) ?*RSA;
+pub extern fn PEM_write_bio_RSAPrivateKey(bp: [*c]BIO, x: ?*RSA, enc: [*c]const EVP_CIPHER, kstr: [*c]u8, klen: c_int, cb: ?pem_password_cb, u: ?*c_void) c_int;
+pub extern fn PEM_write_RSAPrivateKey(fp: [*c]FILE, x: ?*RSA, enc: [*c]const EVP_CIPHER, kstr: [*c]u8, klen: c_int, cb: ?pem_password_cb, u: ?*c_void) c_int;
+pub extern fn PEM_read_bio_RSAPublicKey(bp: [*c]BIO, x: [*c]?*RSA, cb: ?pem_password_cb, u: ?*c_void) ?*RSA;
+pub extern fn PEM_read_RSAPublicKey(fp: [*c]FILE, x: [*c]?*RSA, cb: ?pem_password_cb, u: ?*c_void) ?*RSA;
+pub extern fn PEM_write_bio_RSAPublicKey(bp: [*c]BIO, x: ?*const RSA) c_int;
+pub extern fn PEM_write_RSAPublicKey(fp: [*c]FILE, x: ?*const RSA) c_int;
+pub extern fn PEM_read_bio_RSA_PUBKEY(bp: [*c]BIO, x: [*c]?*RSA, cb: ?pem_password_cb, u: ?*c_void) ?*RSA;
+pub extern fn PEM_read_RSA_PUBKEY(fp: [*c]FILE, x: [*c]?*RSA, cb: ?pem_password_cb, u: ?*c_void) ?*RSA;
+pub extern fn PEM_write_bio_RSA_PUBKEY(bp: [*c]BIO, x: ?*RSA) c_int;
+pub extern fn PEM_write_RSA_PUBKEY(fp: [*c]FILE, x: ?*RSA) c_int;
+pub extern fn PEM_read_bio_DSAPrivateKey(bp: [*c]BIO, x: [*c][*c]DSA, cb: ?pem_password_cb, u: ?*c_void) [*c]DSA;
+pub extern fn PEM_read_DSAPrivateKey(fp: [*c]FILE, x: [*c][*c]DSA, cb: ?pem_password_cb, u: ?*c_void) [*c]DSA;
+pub extern fn PEM_write_bio_DSAPrivateKey(bp: [*c]BIO, x: [*c]DSA, enc: [*c]const EVP_CIPHER, kstr: [*c]u8, klen: c_int, cb: ?pem_password_cb, u: ?*c_void) c_int;
+pub extern fn PEM_write_DSAPrivateKey(fp: [*c]FILE, x: [*c]DSA, enc: [*c]const EVP_CIPHER, kstr: [*c]u8, klen: c_int, cb: ?pem_password_cb, u: ?*c_void) c_int;
+pub extern fn PEM_read_bio_DSA_PUBKEY(bp: [*c]BIO, x: [*c][*c]DSA, cb: ?pem_password_cb, u: ?*c_void) [*c]DSA;
+pub extern fn PEM_read_DSA_PUBKEY(fp: [*c]FILE, x: [*c][*c]DSA, cb: ?pem_password_cb, u: ?*c_void) [*c]DSA;
+pub extern fn PEM_write_bio_DSA_PUBKEY(bp: [*c]BIO, x: [*c]DSA) c_int;
+pub extern fn PEM_write_DSA_PUBKEY(fp: [*c]FILE, x: [*c]DSA) c_int;
+pub extern fn PEM_read_bio_DSAparams(bp: [*c]BIO, x: [*c][*c]DSA, cb: ?pem_password_cb, u: ?*c_void) [*c]DSA;
+pub extern fn PEM_read_DSAparams(fp: [*c]FILE, x: [*c][*c]DSA, cb: ?pem_password_cb, u: ?*c_void) [*c]DSA;
+pub extern fn PEM_write_bio_DSAparams(bp: [*c]BIO, x: [*c]const DSA) c_int;
+pub extern fn PEM_write_DSAparams(fp: [*c]FILE, x: [*c]const DSA) c_int;
+pub extern fn PEM_read_bio_ECPrivateKey(bp: [*c]BIO, x: [*c]?*EC_KEY, cb: ?pem_password_cb, u: ?*c_void) ?*EC_KEY;
+pub extern fn PEM_read_ECPrivateKey(fp: [*c]FILE, x: [*c]?*EC_KEY, cb: ?pem_password_cb, u: ?*c_void) ?*EC_KEY;
+pub extern fn PEM_write_bio_ECPrivateKey(bp: [*c]BIO, x: ?*EC_KEY, enc: [*c]const EVP_CIPHER, kstr: [*c]u8, klen: c_int, cb: ?pem_password_cb, u: ?*c_void) c_int;
+pub extern fn PEM_write_ECPrivateKey(fp: [*c]FILE, x: ?*EC_KEY, enc: [*c]const EVP_CIPHER, kstr: [*c]u8, klen: c_int, cb: ?pem_password_cb, u: ?*c_void) c_int;
+pub extern fn PEM_read_bio_EC_PUBKEY(bp: [*c]BIO, x: [*c]?*EC_KEY, cb: ?pem_password_cb, u: ?*c_void) ?*EC_KEY;
+pub extern fn PEM_read_EC_PUBKEY(fp: [*c]FILE, x: [*c]?*EC_KEY, cb: ?pem_password_cb, u: ?*c_void) ?*EC_KEY;
+pub extern fn PEM_write_bio_EC_PUBKEY(bp: [*c]BIO, x: ?*EC_KEY) c_int;
+pub extern fn PEM_write_EC_PUBKEY(fp: [*c]FILE, x: ?*EC_KEY) c_int;
+pub extern fn PEM_read_bio_DHparams(bp: [*c]BIO, x: [*c][*c]DH, cb: ?pem_password_cb, u: ?*c_void) [*c]DH;
+pub extern fn PEM_read_DHparams(fp: [*c]FILE, x: [*c][*c]DH, cb: ?pem_password_cb, u: ?*c_void) [*c]DH;
+pub extern fn PEM_write_bio_DHparams(bp: [*c]BIO, x: [*c]const DH) c_int;
+pub extern fn PEM_write_DHparams(fp: [*c]FILE, x: [*c]const DH) c_int;
+pub extern fn PEM_read_bio_PrivateKey(bp: [*c]BIO, x: [*c][*c]EVP_PKEY, cb: ?pem_password_cb, u: ?*c_void) [*c]EVP_PKEY;
+pub extern fn PEM_read_PrivateKey(fp: [*c]FILE, x: [*c][*c]EVP_PKEY, cb: ?pem_password_cb, u: ?*c_void) [*c]EVP_PKEY;
+pub extern fn PEM_write_bio_PrivateKey(bp: [*c]BIO, x: [*c]EVP_PKEY, enc: [*c]const EVP_CIPHER, kstr: [*c]u8, klen: c_int, cb: ?pem_password_cb, u: ?*c_void) c_int;
+pub extern fn PEM_write_PrivateKey(fp: [*c]FILE, x: [*c]EVP_PKEY, enc: [*c]const EVP_CIPHER, kstr: [*c]u8, klen: c_int, cb: ?pem_password_cb, u: ?*c_void) c_int;
+pub extern fn PEM_read_bio_PUBKEY(bp: [*c]BIO, x: [*c][*c]EVP_PKEY, cb: ?pem_password_cb, u: ?*c_void) [*c]EVP_PKEY;
+pub extern fn PEM_read_PUBKEY(fp: [*c]FILE, x: [*c][*c]EVP_PKEY, cb: ?pem_password_cb, u: ?*c_void) [*c]EVP_PKEY;
+pub extern fn PEM_write_bio_PUBKEY(bp: [*c]BIO, x: [*c]EVP_PKEY) c_int;
+pub extern fn PEM_write_PUBKEY(fp: [*c]FILE, x: [*c]EVP_PKEY) c_int;
+pub extern fn PEM_write_bio_PKCS8PrivateKey_nid(bp: [*c]BIO, x: [*c]EVP_PKEY, nid: c_int, kstr: [*c]u8, klen: c_int, cb: ?pem_password_cb, u: ?*c_void) c_int;
+pub extern fn PEM_write_bio_PKCS8PrivateKey([*c]BIO, [*c]EVP_PKEY, [*c]const EVP_CIPHER, [*c]u8, c_int, ?pem_password_cb, ?*c_void) c_int;
+pub extern fn i2d_PKCS8PrivateKey_bio(bp: [*c]BIO, x: [*c]EVP_PKEY, enc: [*c]const EVP_CIPHER, kstr: [*c]u8, klen: c_int, cb: ?pem_password_cb, u: ?*c_void) c_int;
+pub extern fn i2d_PKCS8PrivateKey_nid_bio(bp: [*c]BIO, x: [*c]EVP_PKEY, nid: c_int, kstr: [*c]u8, klen: c_int, cb: ?pem_password_cb, u: ?*c_void) c_int;
+pub extern fn d2i_PKCS8PrivateKey_bio(bp: [*c]BIO, x: [*c][*c]EVP_PKEY, cb: ?pem_password_cb, u: ?*c_void) [*c]EVP_PKEY;
+pub extern fn i2d_PKCS8PrivateKey_fp(fp: [*c]FILE, x: [*c]EVP_PKEY, enc: [*c]const EVP_CIPHER, kstr: [*c]u8, klen: c_int, cb: ?pem_password_cb, u: ?*c_void) c_int;
+pub extern fn i2d_PKCS8PrivateKey_nid_fp(fp: [*c]FILE, x: [*c]EVP_PKEY, nid: c_int, kstr: [*c]u8, klen: c_int, cb: ?pem_password_cb, u: ?*c_void) c_int;
+pub extern fn PEM_write_PKCS8PrivateKey_nid(fp: [*c]FILE, x: [*c]EVP_PKEY, nid: c_int, kstr: [*c]u8, klen: c_int, cb: ?pem_password_cb, u: ?*c_void) c_int;
+pub extern fn d2i_PKCS8PrivateKey_fp(fp: [*c]FILE, x: [*c][*c]EVP_PKEY, cb: ?pem_password_cb, u: ?*c_void) [*c]EVP_PKEY;
+pub extern fn PEM_write_PKCS8PrivateKey(fp: [*c]FILE, x: [*c]EVP_PKEY, enc: [*c]const EVP_CIPHER, kstr: [*c]u8, klen: c_int, cd: ?pem_password_cb, u: ?*c_void) c_int; // /Users/jarred/Code/bun/src/deps/boringssl/include/openssl/type_check.h:75:42: warning: ignoring StaticAssert declaration
+
+pub extern fn HMAC(evp_md: ?*const EVP_MD, key: ?*const c_void, key_len: usize, data: [*c]const u8, data_len: usize, out: [*c]u8, out_len: [*c]c_uint) [*c]u8;
+pub extern fn HMAC_CTX_init(ctx: [*c]HMAC_CTX) void;
+pub extern fn HMAC_CTX_new() [*c]HMAC_CTX;
+pub extern fn HMAC_CTX_cleanup(ctx: [*c]HMAC_CTX) void;
+pub extern fn HMAC_CTX_free(ctx: [*c]HMAC_CTX) void;
+pub extern fn HMAC_Init_ex(ctx: [*c]HMAC_CTX, key: ?*const c_void, key_len: usize, md: ?*const EVP_MD, impl: ?*ENGINE) c_int;
+pub extern fn HMAC_Update(ctx: [*c]HMAC_CTX, data: [*c]const u8, data_len: usize) c_int;
+pub extern fn HMAC_Final(ctx: [*c]HMAC_CTX, out: [*c]u8, out_len: [*c]c_uint) c_int;
+pub extern fn HMAC_size(ctx: [*c]const HMAC_CTX) usize;
+pub extern fn HMAC_CTX_copy_ex(dest: [*c]HMAC_CTX, src: [*c]const HMAC_CTX) c_int;
+pub extern fn HMAC_CTX_reset(ctx: [*c]HMAC_CTX) void;
+pub extern fn HMAC_Init(ctx: [*c]HMAC_CTX, key: ?*const c_void, key_len: c_int, md: ?*const EVP_MD) c_int;
+pub extern fn HMAC_CTX_copy(dest: [*c]HMAC_CTX, src: [*c]const HMAC_CTX) c_int;
+pub extern fn TLS_method() ?*const SSL_METHOD;
+pub extern fn DTLS_method() ?*const SSL_METHOD;
+pub extern fn TLS_with_buffers_method() ?*const SSL_METHOD;
+pub extern fn DTLS_with_buffers_method() ?*const SSL_METHOD;
+pub extern fn SSL_CTX_new(method: ?*const SSL_METHOD) ?*SSL_CTX;
+pub extern fn SSL_CTX_up_ref(ctx: ?*SSL_CTX) c_int;
+pub extern fn SSL_CTX_free(ctx: ?*SSL_CTX) void;
+pub extern fn SSL_new(ctx: ?*SSL_CTX) *SSL;
+pub extern fn SSL_free(ssl: ?*SSL) void;
+pub extern fn SSL_get_SSL_CTX(ssl: ?*const SSL) ?*SSL_CTX;
+pub extern fn SSL_set_connect_state(ssl: ?*SSL) void;
+pub extern fn SSL_set_accept_state(ssl: ?*SSL) void;
+pub extern fn SSL_is_server(ssl: ?*const SSL) c_int;
+pub extern fn SSL_is_dtls(ssl: ?*const SSL) c_int;
+pub extern fn SSL_set_bio(ssl: ?*SSL, rbio: [*c]BIO, wbio: [*c]BIO) void;
+pub extern fn SSL_set0_rbio(ssl: ?*SSL, rbio: [*c]BIO) void;
+pub extern fn SSL_set0_wbio(ssl: ?*SSL, wbio: [*c]BIO) void;
+pub extern fn SSL_get_rbio(ssl: ?*const SSL) *BIO;
+pub extern fn SSL_get_wbio(ssl: ?*const SSL) *BIO;
+pub extern fn SSL_get_fd(ssl: ?*const SSL) c_int;
+pub extern fn SSL_get_rfd(ssl: ?*const SSL) c_int;
+pub extern fn SSL_get_wfd(ssl: ?*const SSL) c_int;
+pub extern fn SSL_set_fd(ssl: ?*SSL, fd: c_int) c_int;
+pub extern fn SSL_set_rfd(ssl: ?*SSL, fd: c_int) c_int;
+pub extern fn SSL_set_wfd(ssl: ?*SSL, fd: c_int) c_int;
+pub extern fn SSL_do_handshake(ssl: ?*SSL) c_int;
+pub extern fn SSL_connect(ssl: ?*SSL) c_int;
+pub extern fn SSL_accept(ssl: ?*SSL) c_int;
+pub extern fn SSL_read(ssl: ?*SSL, buf: ?*c_void, num: c_int) c_int;
+pub extern fn SSL_peek(ssl: ?*SSL, buf: ?*c_void, num: c_int) c_int;
+pub extern fn SSL_pending(ssl: ?*const SSL) c_int;
+pub extern fn SSL_has_pending(ssl: ?*const SSL) c_int;
+pub extern fn SSL_write(ssl: ?*SSL, buf: ?*const c_void, num: c_int) c_int;
+pub extern fn SSL_key_update(ssl: ?*SSL, request_type: c_int) c_int;
+pub extern fn SSL_shutdown(ssl: ?*SSL) c_int;
+pub extern fn SSL_CTX_set_quiet_shutdown(ctx: ?*SSL_CTX, mode: c_int) void;
+pub extern fn SSL_CTX_get_quiet_shutdown(ctx: ?*const SSL_CTX) c_int;
+pub extern fn SSL_set_quiet_shutdown(ssl: ?*SSL, mode: c_int) void;
+pub extern fn SSL_get_quiet_shutdown(ssl: ?*const SSL) c_int;
+pub extern fn SSL_get_error(ssl: ?*const SSL, ret_code: c_int) c_int;
+pub extern fn SSL_error_description(err: c_int) [*c]const u8;
+pub extern fn SSL_set_mtu(ssl: ?*SSL, mtu: c_uint) c_int;
+pub extern fn DTLSv1_set_initial_timeout_duration(ssl: ?*SSL, duration_ms: c_uint) void;
+pub extern fn DTLSv1_get_timeout(ssl: ?*const SSL, out: [*c]struct_timeval) c_int;
+pub extern fn DTLSv1_handle_timeout(ssl: ?*SSL) c_int;
+pub extern fn SSL_CTX_set_min_proto_version(ctx: ?*SSL_CTX, version: u16) c_int;
+pub extern fn SSL_CTX_set_max_proto_version(ctx: ?*SSL_CTX, version: u16) c_int;
+pub extern fn SSL_CTX_get_min_proto_version(ctx: ?*const SSL_CTX) u16;
+pub extern fn SSL_CTX_get_max_proto_version(ctx: ?*const SSL_CTX) u16;
+pub extern fn SSL_set_min_proto_version(ssl: ?*SSL, version: u16) c_int;
+pub extern fn SSL_set_max_proto_version(ssl: ?*SSL, version: u16) c_int;
+pub extern fn SSL_get_min_proto_version(ssl: ?*const SSL) u16;
+pub extern fn SSL_get_max_proto_version(ssl: ?*const SSL) u16;
+pub extern fn SSL_version(ssl: ?*const SSL) c_int;
+pub extern fn SSL_CTX_set_options(ctx: ?*SSL_CTX, options: u32) u32;
+pub extern fn SSL_CTX_clear_options(ctx: ?*SSL_CTX, options: u32) u32;
+pub extern fn SSL_CTX_get_options(ctx: ?*const SSL_CTX) u32;
+pub extern fn SSL_set_options(ssl: ?*SSL, options: u32) u32;
+pub extern fn SSL_clear_options(ssl: ?*SSL, options: u32) u32;
+pub extern fn SSL_get_options(ssl: ?*const SSL) u32;
+pub extern fn SSL_CTX_set_mode(ctx: ?*SSL_CTX, mode: u32) u32;
+pub extern fn SSL_CTX_clear_mode(ctx: ?*SSL_CTX, mode: u32) u32;
+pub extern fn SSL_CTX_get_mode(ctx: ?*const SSL_CTX) u32;
+pub extern fn SSL_set_mode(ssl: ?*SSL, mode: u32) u32;
+pub extern fn SSL_clear_mode(ssl: ?*SSL, mode: u32) u32;
+pub extern fn SSL_get_mode(ssl: ?*const SSL) u32;
+pub extern fn SSL_CTX_set0_buffer_pool(ctx: ?*SSL_CTX, pool: ?*CRYPTO_BUFFER_POOL) void;
+pub extern fn SSL_CTX_use_certificate(ctx: ?*SSL_CTX, x509: ?*X509) c_int;
+pub extern fn SSL_use_certificate(ssl: ?*SSL, x509: ?*X509) c_int;
+pub extern fn SSL_CTX_use_PrivateKey(ctx: ?*SSL_CTX, pkey: [*c]EVP_PKEY) c_int;
+pub extern fn SSL_use_PrivateKey(ssl: ?*SSL, pkey: [*c]EVP_PKEY) c_int;
+pub extern fn SSL_CTX_set0_chain(ctx: ?*SSL_CTX, chain: ?*struct_stack_st_X509) c_int;
+pub extern fn SSL_CTX_set1_chain(ctx: ?*SSL_CTX, chain: ?*struct_stack_st_X509) c_int;
+pub extern fn SSL_set0_chain(ssl: ?*SSL, chain: ?*struct_stack_st_X509) c_int;
+pub extern fn SSL_set1_chain(ssl: ?*SSL, chain: ?*struct_stack_st_X509) c_int;
+pub extern fn SSL_CTX_add0_chain_cert(ctx: ?*SSL_CTX, x509: ?*X509) c_int;
+pub extern fn SSL_CTX_add1_chain_cert(ctx: ?*SSL_CTX, x509: ?*X509) c_int;
+pub extern fn SSL_add0_chain_cert(ssl: ?*SSL, x509: ?*X509) c_int;
+pub extern fn SSL_CTX_add_extra_chain_cert(ctx: ?*SSL_CTX, x509: ?*X509) c_int;
+pub extern fn SSL_add1_chain_cert(ssl: ?*SSL, x509: ?*X509) c_int;
+pub extern fn SSL_CTX_clear_chain_certs(ctx: ?*SSL_CTX) c_int;
+pub extern fn SSL_CTX_clear_extra_chain_certs(ctx: ?*SSL_CTX) c_int;
+pub extern fn SSL_clear_chain_certs(ssl: ?*SSL) c_int;
+pub extern fn SSL_CTX_set_cert_cb(ctx: ?*SSL_CTX, cb: ?fn (?*SSL, ?*c_void) callconv(.C) c_int, arg: ?*c_void) void;
+pub extern fn SSL_set_cert_cb(ssl: ?*SSL, cb: ?fn (?*SSL, ?*c_void) callconv(.C) c_int, arg: ?*c_void) void;
+pub extern fn SSL_get0_certificate_types(ssl: ?*const SSL, out_types: [*c][*c]const u8) usize;
+pub extern fn SSL_get0_peer_verify_algorithms(ssl: ?*const SSL, out_sigalgs: [*c][*c]const u16) usize;
+pub extern fn SSL_get0_peer_delegation_algorithms(ssl: ?*const SSL, out_sigalgs: [*c][*c]const u16) usize;
+pub extern fn SSL_certs_clear(ssl: ?*SSL) void;
+pub extern fn SSL_CTX_check_private_key(ctx: ?*const SSL_CTX) c_int;
+pub extern fn SSL_check_private_key(ssl: ?*const SSL) c_int;
+pub extern fn SSL_CTX_get0_certificate(ctx: ?*const SSL_CTX) ?*X509;
+pub extern fn SSL_get_certificate(ssl: ?*const SSL) ?*X509;
+pub extern fn SSL_CTX_get0_privatekey(ctx: ?*const SSL_CTX) [*c]EVP_PKEY;
+pub extern fn SSL_get_privatekey(ssl: ?*const SSL) [*c]EVP_PKEY;
+pub extern fn SSL_CTX_get0_chain_certs(ctx: ?*const SSL_CTX, out_chain: [*c]?*struct_stack_st_X509) c_int;
+pub extern fn SSL_CTX_get_extra_chain_certs(ctx: ?*const SSL_CTX, out_chain: [*c]?*struct_stack_st_X509) c_int;
+pub extern fn SSL_get0_chain_certs(ssl: ?*const SSL, out_chain: [*c]?*struct_stack_st_X509) c_int;
+pub extern fn SSL_CTX_set_signed_cert_timestamp_list(ctx: ?*SSL_CTX, list: [*c]const u8, list_len: usize) c_int;
+pub extern fn SSL_set_signed_cert_timestamp_list(ctx: ?*SSL, list: [*c]const u8, list_len: usize) c_int;
+pub extern fn SSL_CTX_set_ocsp_response(ctx: ?*SSL_CTX, response: [*c]const u8, response_len: usize) c_int;
+pub extern fn SSL_set_ocsp_response(ssl: ?*SSL, response: [*c]const u8, response_len: usize) c_int;
+pub extern fn SSL_get_signature_algorithm_name(sigalg: u16, include_curve: c_int) [*c]const u8;
+pub extern fn SSL_get_signature_algorithm_key_type(sigalg: u16) c_int;
+pub extern fn SSL_get_signature_algorithm_digest(sigalg: u16) ?*const EVP_MD;
+pub extern fn SSL_is_signature_algorithm_rsa_pss(sigalg: u16) c_int;
+pub extern fn SSL_CTX_set_signing_algorithm_prefs(ctx: ?*SSL_CTX, prefs: [*c]const u16, num_prefs: usize) c_int;
+pub extern fn SSL_set_signing_algorithm_prefs(ssl: ?*SSL, prefs: [*c]const u16, num_prefs: usize) c_int;
+pub extern fn SSL_CTX_set_chain_and_key(ctx: ?*SSL_CTX, certs: [*c]const ?*CRYPTO_BUFFER, num_certs: usize, privkey: [*c]EVP_PKEY, privkey_method: [*c]const SSL_PRIVATE_KEY_METHOD) c_int;
+pub extern fn SSL_set_chain_and_key(ssl: ?*SSL, certs: [*c]const ?*CRYPTO_BUFFER, num_certs: usize, privkey: [*c]EVP_PKEY, privkey_method: [*c]const SSL_PRIVATE_KEY_METHOD) c_int;
+pub extern fn SSL_CTX_get0_chain(ctx: ?*const SSL_CTX) ?*const struct_stack_st_CRYPTO_BUFFER;
+pub extern fn SSL_CTX_use_RSAPrivateKey(ctx: ?*SSL_CTX, rsa: ?*RSA) c_int;
+pub extern fn SSL_use_RSAPrivateKey(ssl: ?*SSL, rsa: ?*RSA) c_int;
+pub extern fn SSL_CTX_use_certificate_ASN1(ctx: ?*SSL_CTX, der_len: usize, der: [*c]const u8) c_int;
+pub extern fn SSL_use_certificate_ASN1(ssl: ?*SSL, der: [*c]const u8, der_len: usize) c_int;
+pub extern fn SSL_CTX_use_PrivateKey_ASN1(pk: c_int, ctx: ?*SSL_CTX, der: [*c]const u8, der_len: usize) c_int;
+pub extern fn SSL_use_PrivateKey_ASN1(@"type": c_int, ssl: ?*SSL, der: [*c]const u8, der_len: usize) c_int;
+pub extern fn SSL_CTX_use_RSAPrivateKey_ASN1(ctx: ?*SSL_CTX, der: [*c]const u8, der_len: usize) c_int;
+pub extern fn SSL_use_RSAPrivateKey_ASN1(ssl: ?*SSL, der: [*c]const u8, der_len: usize) c_int;
+pub extern fn SSL_CTX_use_RSAPrivateKey_file(ctx: ?*SSL_CTX, file: [*c]const u8, @"type": c_int) c_int;
+pub extern fn SSL_use_RSAPrivateKey_file(ssl: ?*SSL, file: [*c]const u8, @"type": c_int) c_int;
+pub extern fn SSL_CTX_use_certificate_file(ctx: ?*SSL_CTX, file: [*c]const u8, @"type": c_int) c_int;
+pub extern fn SSL_use_certificate_file(ssl: ?*SSL, file: [*c]const u8, @"type": c_int) c_int;
+pub extern fn SSL_CTX_use_PrivateKey_file(ctx: ?*SSL_CTX, file: [*c]const u8, @"type": c_int) c_int;
+pub extern fn SSL_use_PrivateKey_file(ssl: ?*SSL, file: [*c]const u8, @"type": c_int) c_int;
+pub extern fn SSL_CTX_use_certificate_chain_file(ctx: ?*SSL_CTX, file: [*c]const u8) c_int;
+pub extern fn SSL_CTX_set_default_passwd_cb(ctx: ?*SSL_CTX, cb: ?pem_password_cb) void;
+pub extern fn SSL_CTX_get_default_passwd_cb(ctx: ?*const SSL_CTX) ?pem_password_cb;
+pub extern fn SSL_CTX_set_default_passwd_cb_userdata(ctx: ?*SSL_CTX, data: ?*c_void) void;
+pub extern fn SSL_CTX_get_default_passwd_cb_userdata(ctx: ?*const SSL_CTX) ?*c_void;
+pub extern fn SSL_set_private_key_method(ssl: ?*SSL, key_method: [*c]const SSL_PRIVATE_KEY_METHOD) void;
+pub extern fn SSL_CTX_set_private_key_method(ctx: ?*SSL_CTX, key_method: [*c]const SSL_PRIVATE_KEY_METHOD) void;
+pub extern fn SSL_can_release_private_key(ssl: ?*const SSL) c_int;
+pub const struct_stack_st_SSL_CIPHER = opaque {};
+pub const stack_SSL_CIPHER_free_func = ?fn (?*const SSL_CIPHER) callconv(.C) void;
+pub const stack_SSL_CIPHER_copy_func = ?fn (?*const SSL_CIPHER) callconv(.C) ?*const SSL_CIPHER;
+pub const stack_SSL_CIPHER_cmp_func = ?fn ([*c]?*const SSL_CIPHER, [*c]?*const SSL_CIPHER) callconv(.C) c_int;
+pub fn sk_SSL_CIPHER_call_free_func(arg_free_func: stack_free_func, arg_ptr: ?*c_void) callconv(.C) void {
+ var free_func = arg_free_func;
+ var ptr = arg_ptr;
+ @ptrCast(stack_SSL_CIPHER_free_func, @alignCast(@import("std").meta.alignment(fn (?*const SSL_CIPHER) callconv(.C) void), free_func)).?(@ptrCast(?*const SSL_CIPHER, ptr));
+}
+pub fn sk_SSL_CIPHER_call_copy_func(arg_copy_func: stack_copy_func, arg_ptr: ?*c_void) callconv(.C) ?*c_void {
+ var copy_func = arg_copy_func;
+ var ptr = arg_ptr;
+ return @intToPtr(?*c_void, @ptrToInt(@ptrCast(stack_SSL_CIPHER_copy_func, @alignCast(@import("std").meta.alignment(fn (?*const SSL_CIPHER) callconv(.C) ?*const SSL_CIPHER), copy_func)).?(@ptrCast(?*const SSL_CIPHER, ptr))));
+}
+pub fn sk_SSL_CIPHER_call_cmp_func(arg_cmp_func: stack_cmp_func, arg_a: [*c]?*const c_void, arg_b: [*c]?*const c_void) callconv(.C) c_int {
+ var cmp_func = arg_cmp_func;
+ var a = arg_a;
+ var b = arg_b;
+ var a_ptr: ?*const SSL_CIPHER = @ptrCast(?*const SSL_CIPHER, a.*);
+ var b_ptr: ?*const SSL_CIPHER = @ptrCast(?*const SSL_CIPHER, b.*);
+ return @ptrCast(stack_SSL_CIPHER_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const SSL_CIPHER, [*c]?*const SSL_CIPHER) callconv(.C) c_int), cmp_func)).?(&a_ptr, &b_ptr);
+}
+pub fn sk_SSL_CIPHER_new(arg_comp: stack_SSL_CIPHER_cmp_func) callconv(.C) ?*struct_stack_st_SSL_CIPHER {
+ var comp = arg_comp;
+ return @ptrCast(?*struct_stack_st_SSL_CIPHER, sk_new(@ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp))));
+}
+pub fn sk_SSL_CIPHER_new_null() callconv(.C) ?*struct_stack_st_SSL_CIPHER {
+ return @ptrCast(?*struct_stack_st_SSL_CIPHER, sk_new_null());
+}
+pub fn sk_SSL_CIPHER_num(arg_sk: ?*const struct_stack_st_SSL_CIPHER) callconv(.C) usize {
+ var sk = arg_sk;
+ return sk_num(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_SSL_CIPHER_zero(arg_sk: ?*struct_stack_st_SSL_CIPHER) callconv(.C) void {
+ var sk = arg_sk;
+ sk_zero(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_SSL_CIPHER_value(arg_sk: ?*const struct_stack_st_SSL_CIPHER, arg_i: usize) callconv(.C) ?*const SSL_CIPHER {
+ var sk = arg_sk;
+ var i = arg_i;
+ return @ptrCast(?*const SSL_CIPHER, sk_value(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i));
+}
+pub fn sk_SSL_CIPHER_set(arg_sk: ?*struct_stack_st_SSL_CIPHER, arg_i: usize, arg_p: ?*const SSL_CIPHER) callconv(.C) ?*const SSL_CIPHER {
+ var sk = arg_sk;
+ var i = arg_i;
+ var p = arg_p;
+ return @ptrCast(?*const SSL_CIPHER, sk_set(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i, @intToPtr(?*c_void, @ptrToInt(p))));
+}
+pub fn sk_SSL_CIPHER_free(arg_sk: ?*struct_stack_st_SSL_CIPHER) callconv(.C) void {
+ var sk = arg_sk;
+ sk_free(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_SSL_CIPHER_pop_free(arg_sk: ?*struct_stack_st_SSL_CIPHER, arg_free_func: stack_SSL_CIPHER_free_func) callconv(.C) void {
+ var sk = arg_sk;
+ var free_func = arg_free_func;
+ sk_pop_free_ex(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_SSL_CIPHER_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func)));
+}
+pub fn sk_SSL_CIPHER_insert(arg_sk: ?*struct_stack_st_SSL_CIPHER, arg_p: ?*const SSL_CIPHER, arg_where: usize) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ var where = arg_where;
+ return sk_insert(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @intToPtr(?*c_void, @ptrToInt(p)), where);
+}
+pub fn sk_SSL_CIPHER_delete(arg_sk: ?*struct_stack_st_SSL_CIPHER, arg_where: usize) callconv(.C) ?*const SSL_CIPHER {
+ var sk = arg_sk;
+ var where = arg_where;
+ return @ptrCast(?*const SSL_CIPHER, sk_delete(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), where));
+}
+pub fn sk_SSL_CIPHER_delete_ptr(arg_sk: ?*struct_stack_st_SSL_CIPHER, arg_p: ?*const SSL_CIPHER) callconv(.C) ?*const SSL_CIPHER {
+ var sk = arg_sk;
+ var p = arg_p;
+ return @ptrCast(?*const SSL_CIPHER, sk_delete_ptr(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*const c_void, p)));
+}
+pub fn sk_SSL_CIPHER_find(arg_sk: ?*const struct_stack_st_SSL_CIPHER, arg_out_index: [*c]usize, arg_p: ?*const SSL_CIPHER) callconv(.C) c_int {
+ var sk = arg_sk;
+ var out_index = arg_out_index;
+ var p = arg_p;
+ return sk_find(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), out_index, @ptrCast(?*const c_void, p), sk_SSL_CIPHER_call_cmp_func);
+}
+pub fn sk_SSL_CIPHER_shift(arg_sk: ?*struct_stack_st_SSL_CIPHER) callconv(.C) ?*const SSL_CIPHER {
+ var sk = arg_sk;
+ return @ptrCast(?*const SSL_CIPHER, sk_shift(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_SSL_CIPHER_push(arg_sk: ?*struct_stack_st_SSL_CIPHER, arg_p: ?*const SSL_CIPHER) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ return sk_push(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @intToPtr(?*c_void, @ptrToInt(p)));
+}
+pub fn sk_SSL_CIPHER_pop(arg_sk: ?*struct_stack_st_SSL_CIPHER) callconv(.C) ?*const SSL_CIPHER {
+ var sk = arg_sk;
+ return @ptrCast(?*const SSL_CIPHER, sk_pop(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_SSL_CIPHER_dup(arg_sk: ?*const struct_stack_st_SSL_CIPHER) callconv(.C) ?*struct_stack_st_SSL_CIPHER {
+ var sk = arg_sk;
+ return @ptrCast(?*struct_stack_st_SSL_CIPHER, sk_dup(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_SSL_CIPHER_sort(arg_sk: ?*struct_stack_st_SSL_CIPHER) callconv(.C) void {
+ var sk = arg_sk;
+ sk_sort(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_SSL_CIPHER_is_sorted(arg_sk: ?*const struct_stack_st_SSL_CIPHER) callconv(.C) c_int {
+ var sk = arg_sk;
+ return sk_is_sorted(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_SSL_CIPHER_set_cmp_func(arg_sk: ?*struct_stack_st_SSL_CIPHER, arg_comp: stack_SSL_CIPHER_cmp_func) callconv(.C) stack_SSL_CIPHER_cmp_func {
+ var sk = arg_sk;
+ var comp = arg_comp;
+ return @ptrCast(stack_SSL_CIPHER_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const SSL_CIPHER, [*c]?*const SSL_CIPHER) callconv(.C) c_int), sk_set_cmp_func(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp)))));
+}
+pub fn sk_SSL_CIPHER_deep_copy(arg_sk: ?*const struct_stack_st_SSL_CIPHER, arg_copy_func: ?fn (?*const SSL_CIPHER) callconv(.C) ?*const SSL_CIPHER, arg_free_func: ?fn (?*const SSL_CIPHER) callconv(.C) void) callconv(.C) ?*struct_stack_st_SSL_CIPHER {
+ var sk = arg_sk;
+ var copy_func = arg_copy_func;
+ var free_func = arg_free_func;
+ return @ptrCast(?*struct_stack_st_SSL_CIPHER, sk_deep_copy(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_SSL_CIPHER_call_copy_func, @ptrCast(stack_copy_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) ?*c_void), copy_func)), sk_SSL_CIPHER_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func))));
+}
+pub extern fn SSL_get_cipher_by_value(value: u16) ?*const SSL_CIPHER;
+pub extern fn SSL_CIPHER_get_id(cipher: ?*const SSL_CIPHER) u32;
+pub extern fn SSL_CIPHER_get_protocol_id(cipher: ?*const SSL_CIPHER) u16;
+pub extern fn SSL_CIPHER_is_aead(cipher: ?*const SSL_CIPHER) c_int;
+pub extern fn SSL_CIPHER_is_block_cipher(cipher: ?*const SSL_CIPHER) c_int;
+pub extern fn SSL_CIPHER_get_cipher_nid(cipher: ?*const SSL_CIPHER) c_int;
+pub extern fn SSL_CIPHER_get_digest_nid(cipher: ?*const SSL_CIPHER) c_int;
+pub extern fn SSL_CIPHER_get_kx_nid(cipher: ?*const SSL_CIPHER) c_int;
+pub extern fn SSL_CIPHER_get_auth_nid(cipher: ?*const SSL_CIPHER) c_int;
+pub extern fn SSL_CIPHER_get_prf_nid(cipher: ?*const SSL_CIPHER) c_int;
+pub extern fn SSL_CIPHER_get_min_version(cipher: ?*const SSL_CIPHER) u16;
+pub extern fn SSL_CIPHER_get_max_version(cipher: ?*const SSL_CIPHER) u16;
+pub extern fn SSL_CIPHER_standard_name(cipher: ?*const SSL_CIPHER) [*c]const u8;
+pub extern fn SSL_CIPHER_get_name(cipher: ?*const SSL_CIPHER) [*c]const u8;
+pub extern fn SSL_CIPHER_get_kx_name(cipher: ?*const SSL_CIPHER) [*c]const u8;
+pub extern fn SSL_CIPHER_get_bits(cipher: ?*const SSL_CIPHER, out_alg_bits: [*c]c_int) c_int;
+pub extern fn SSL_CTX_set_strict_cipher_list(ctx: ?*SSL_CTX, str: [*c]const u8) c_int;
+pub extern fn SSL_CTX_set_cipher_list(ctx: ?*SSL_CTX, str: [*c]const u8) c_int;
+pub extern fn SSL_set_strict_cipher_list(ssl: ?*SSL, str: [*c]const u8) c_int;
+pub extern fn SSL_set_cipher_list(ssl: ?*SSL, str: [*c]const u8) c_int;
+pub extern fn SSL_CTX_get_ciphers(ctx: ?*const SSL_CTX) ?*struct_stack_st_SSL_CIPHER;
+pub extern fn SSL_CTX_cipher_in_group(ctx: ?*const SSL_CTX, i: usize) c_int;
+pub extern fn SSL_get_ciphers(ssl: ?*const SSL) ?*struct_stack_st_SSL_CIPHER;
+pub extern fn SSL_is_init_finished(ssl: ?*const SSL) c_int;
+pub extern fn SSL_in_init(ssl: ?*const SSL) c_int;
+pub extern fn SSL_in_false_start(ssl: ?*const SSL) c_int;
+pub extern fn SSL_get_peer_certificate(ssl: ?*const SSL) ?*X509;
+pub extern fn SSL_get_peer_cert_chain(ssl: ?*const SSL) ?*struct_stack_st_X509;
+pub extern fn SSL_get_peer_full_cert_chain(ssl: ?*const SSL) ?*struct_stack_st_X509;
+pub extern fn SSL_get0_peer_certificates(ssl: ?*const SSL) ?*const struct_stack_st_CRYPTO_BUFFER;
+pub extern fn SSL_get0_signed_cert_timestamp_list(ssl: ?*const SSL, out: [*c][*c]const u8, out_len: [*c]usize) void;
+pub extern fn SSL_get0_ocsp_response(ssl: ?*const SSL, out: [*c][*c]const u8, out_len: [*c]usize) void;
+pub extern fn SSL_get_tls_unique(ssl: ?*const SSL, out: [*c]u8, out_len: [*c]usize, max_out: usize) c_int;
+pub extern fn SSL_get_extms_support(ssl: ?*const SSL) c_int;
+pub extern fn SSL_get_current_cipher(ssl: ?*const SSL) ?*const SSL_CIPHER;
+pub extern fn SSL_session_reused(ssl: ?*const SSL) c_int;
+pub extern fn SSL_get_secure_renegotiation_support(ssl: ?*const SSL) c_int;
+pub extern fn SSL_export_keying_material(ssl: ?*SSL, out: [*c]u8, out_len: usize, label: [*c]const u8, label_len: usize, context: [*c]const u8, context_len: usize, use_context: c_int) c_int;
+pub extern fn PEM_read_bio_SSL_SESSION(bp: [*c]BIO, x: [*c]?*SSL_SESSION, cb: ?pem_password_cb, u: ?*c_void) ?*SSL_SESSION;
+pub extern fn PEM_read_SSL_SESSION(fp: [*c]FILE, x: [*c]?*SSL_SESSION, cb: ?pem_password_cb, u: ?*c_void) ?*SSL_SESSION;
+pub extern fn PEM_write_bio_SSL_SESSION(bp: [*c]BIO, x: ?*SSL_SESSION) c_int;
+pub extern fn PEM_write_SSL_SESSION(fp: [*c]FILE, x: ?*SSL_SESSION) c_int;
+pub extern fn SSL_SESSION_new(ctx: ?*const SSL_CTX) ?*SSL_SESSION;
+pub extern fn SSL_SESSION_up_ref(session: ?*SSL_SESSION) c_int;
+pub extern fn SSL_SESSION_free(session: ?*SSL_SESSION) void;
+pub extern fn SSL_SESSION_to_bytes(in: ?*const SSL_SESSION, out_data: [*c][*c]u8, out_len: [*c]usize) c_int;
+pub extern fn SSL_SESSION_to_bytes_for_ticket(in: ?*const SSL_SESSION, out_data: [*c][*c]u8, out_len: [*c]usize) c_int;
+pub extern fn SSL_SESSION_from_bytes(in: [*c]const u8, in_len: usize, ctx: ?*const SSL_CTX) ?*SSL_SESSION;
+pub extern fn SSL_SESSION_get_version(session: ?*const SSL_SESSION) [*c]const u8;
+pub extern fn SSL_SESSION_get_protocol_version(session: ?*const SSL_SESSION) u16;
+pub extern fn SSL_SESSION_set_protocol_version(session: ?*SSL_SESSION, version: u16) c_int;
+pub extern fn SSL_SESSION_get_id(session: ?*const SSL_SESSION, out_len: [*c]c_uint) [*c]const u8;
+pub extern fn SSL_SESSION_set1_id(session: ?*SSL_SESSION, sid: [*c]const u8, sid_len: usize) c_int;
+pub extern fn SSL_SESSION_get_time(session: ?*const SSL_SESSION) u64;
+pub extern fn SSL_SESSION_get_timeout(session: ?*const SSL_SESSION) u32;
+pub extern fn SSL_SESSION_get0_peer(session: ?*const SSL_SESSION) ?*X509;
+pub extern fn SSL_SESSION_get0_peer_certificates(session: ?*const SSL_SESSION) ?*const struct_stack_st_CRYPTO_BUFFER;
+pub extern fn SSL_SESSION_get0_signed_cert_timestamp_list(session: ?*const SSL_SESSION, out: [*c][*c]const u8, out_len: [*c]usize) void;
+pub extern fn SSL_SESSION_get0_ocsp_response(session: ?*const SSL_SESSION, out: [*c][*c]const u8, out_len: [*c]usize) void;
+pub extern fn SSL_SESSION_get_master_key(session: ?*const SSL_SESSION, out: [*c]u8, max_out: usize) usize;
+pub extern fn SSL_SESSION_set_time(session: ?*SSL_SESSION, time: u64) u64;
+pub extern fn SSL_SESSION_set_timeout(session: ?*SSL_SESSION, timeout: u32) u32;
+pub extern fn SSL_SESSION_get0_id_context(session: ?*const SSL_SESSION, out_len: [*c]c_uint) [*c]const u8;
+pub extern fn SSL_SESSION_set1_id_context(session: ?*SSL_SESSION, sid_ctx: [*c]const u8, sid_ctx_len: usize) c_int;
+pub extern fn SSL_SESSION_should_be_single_use(session: ?*const SSL_SESSION) c_int;
+pub extern fn SSL_SESSION_is_resumable(session: ?*const SSL_SESSION) c_int;
+pub extern fn SSL_SESSION_has_ticket(session: ?*const SSL_SESSION) c_int;
+pub extern fn SSL_SESSION_get0_ticket(session: ?*const SSL_SESSION, out_ticket: [*c][*c]const u8, out_len: [*c]usize) void;
+pub extern fn SSL_SESSION_set_ticket(session: ?*SSL_SESSION, ticket: [*c]const u8, ticket_len: usize) c_int;
+pub extern fn SSL_SESSION_get_ticket_lifetime_hint(session: ?*const SSL_SESSION) u32;
+pub extern fn SSL_SESSION_get0_cipher(session: ?*const SSL_SESSION) ?*const SSL_CIPHER;
+pub extern fn SSL_SESSION_has_peer_sha256(session: ?*const SSL_SESSION) c_int;
+pub extern fn SSL_SESSION_get0_peer_sha256(session: ?*const SSL_SESSION, out_ptr: [*c][*c]const u8, out_len: [*c]usize) void;
+pub extern fn SSL_CTX_set_session_cache_mode(ctx: ?*SSL_CTX, mode: c_int) c_int;
+pub extern fn SSL_CTX_get_session_cache_mode(ctx: ?*const SSL_CTX) c_int;
+pub extern fn SSL_set_session(ssl: ?*SSL, session: ?*SSL_SESSION) c_int;
+pub extern fn SSL_CTX_set_timeout(ctx: ?*SSL_CTX, timeout: u32) u32;
+pub extern fn SSL_CTX_set_session_psk_dhe_timeout(ctx: ?*SSL_CTX, timeout: u32) void;
+pub extern fn SSL_CTX_get_timeout(ctx: ?*const SSL_CTX) u32;
+pub extern fn SSL_CTX_set_session_id_context(ctx: ?*SSL_CTX, sid_ctx: [*c]const u8, sid_ctx_len: usize) c_int;
+pub extern fn SSL_set_session_id_context(ssl: ?*SSL, sid_ctx: [*c]const u8, sid_ctx_len: usize) c_int;
+pub extern fn SSL_get0_session_id_context(ssl: ?*const SSL, out_len: [*c]usize) [*c]const u8;
+pub extern fn SSL_CTX_sess_set_cache_size(ctx: ?*SSL_CTX, size: c_ulong) c_ulong;
+pub extern fn SSL_CTX_sess_get_cache_size(ctx: ?*const SSL_CTX) c_ulong;
+pub extern fn SSL_CTX_sess_number(ctx: ?*const SSL_CTX) usize;
+pub extern fn SSL_CTX_add_session(ctx: ?*SSL_CTX, session: ?*SSL_SESSION) c_int;
+pub extern fn SSL_CTX_remove_session(ctx: ?*SSL_CTX, session: ?*SSL_SESSION) c_int;
+pub extern fn SSL_CTX_flush_sessions(ctx: ?*SSL_CTX, time: u64) void;
+pub extern fn SSL_CTX_sess_set_new_cb(ctx: ?*SSL_CTX, new_session_cb: ?fn (?*SSL, ?*SSL_SESSION) callconv(.C) c_int) void;
+pub extern fn SSL_CTX_sess_get_new_cb(ctx: ?*SSL_CTX) ?fn (?*SSL, ?*SSL_SESSION) callconv(.C) c_int;
+pub extern fn SSL_CTX_sess_set_remove_cb(ctx: ?*SSL_CTX, remove_session_cb: ?fn (?*SSL_CTX, ?*SSL_SESSION) callconv(.C) void) void;
+pub extern fn SSL_CTX_sess_get_remove_cb(ctx: ?*SSL_CTX) ?fn (?*SSL_CTX, ?*SSL_SESSION) callconv(.C) void;
+pub extern fn SSL_CTX_sess_set_get_cb(ctx: ?*SSL_CTX, get_session_cb: ?fn (?*SSL, [*c]const u8, c_int, [*c]c_int) callconv(.C) ?*SSL_SESSION) void;
+pub extern fn SSL_CTX_sess_get_get_cb(ctx: ?*SSL_CTX) ?fn (?*SSL, [*c]const u8, c_int, [*c]c_int) callconv(.C) ?*SSL_SESSION;
+pub extern fn SSL_magic_pending_session_ptr() ?*SSL_SESSION;
+pub extern fn SSL_CTX_get_tlsext_ticket_keys(ctx: ?*SSL_CTX, out: ?*c_void, len: usize) c_int;
+pub extern fn SSL_CTX_set_tlsext_ticket_keys(ctx: ?*SSL_CTX, in: ?*const c_void, len: usize) c_int;
+pub extern fn SSL_CTX_set_tlsext_ticket_key_cb(ctx: ?*SSL_CTX, callback: ?fn (?*SSL, [*c]u8, [*c]u8, [*c]EVP_CIPHER_CTX, [*c]HMAC_CTX, c_int) callconv(.C) c_int) c_int;
+pub extern fn SSL_CTX_set_ticket_aead_method(ctx: ?*SSL_CTX, aead_method: [*c]const SSL_TICKET_AEAD_METHOD) void;
+pub extern fn SSL_process_tls13_new_session_ticket(ssl: ?*SSL, buf: [*c]const u8, buf_len: usize) ?*SSL_SESSION;
+pub extern fn SSL_CTX_set1_curves(ctx: ?*SSL_CTX, curves: [*c]const c_int, curves_len: usize) c_int;
+pub extern fn SSL_set1_curves(ssl: ?*SSL, curves: [*c]const c_int, curves_len: usize) c_int;
+pub extern fn SSL_CTX_set1_curves_list(ctx: ?*SSL_CTX, curves: [*c]const u8) c_int;
+pub extern fn SSL_set1_curves_list(ssl: ?*SSL, curves: [*c]const u8) c_int;
+pub extern fn SSL_get_curve_id(ssl: ?*const SSL) u16;
+pub extern fn SSL_get_curve_name(curve_id: u16) [*c]const u8;
+pub extern fn SSL_CTX_set_verify(ctx: ?*SSL_CTX, mode: c_int, callback: ?fn (c_int, ?*X509_STORE_CTX) callconv(.C) c_int) void;
+pub extern fn SSL_set_verify(ssl: ?*SSL, mode: c_int, callback: ?fn (c_int, ?*X509_STORE_CTX) callconv(.C) c_int) void;
+// pub const ssl_verify_ok: c_int = 0;
+// pub const ssl_verify_invalid: c_int = 1;
+// pub const ssl_verify_retry: c_int = 2;
+// pub const enum_ssl_verify_result_t = c_uint;
+pub const VerifyResult = enum(c_int) {
+ ok = 0,
+ invalid = 1,
+ retry = 2,
+};
+pub const VerifyCallback = fn (*SSL, [*c]u8) callconv(.C) VerifyResult;
+
+pub extern fn SSL_CTX_set_custom_verify(ctx: ?*SSL_CTX, mode: c_int, callback: ?VerifyCallback) void;
+pub extern fn SSL_set_custom_verify(ssl: ?*SSL, mode: c_int, callback: ?VerifyCallback) void;
+pub extern fn SSL_CTX_get_verify_mode(ctx: ?*const SSL_CTX) c_int;
+pub extern fn SSL_get_verify_mode(ssl: ?*const SSL) c_int;
+pub extern fn SSL_CTX_get_verify_callback(ctx: ?*const SSL_CTX) ?fn (c_int, ?*X509_STORE_CTX) callconv(.C) c_int;
+pub extern fn SSL_get_verify_callback(ssl: ?*const SSL) ?fn (c_int, ?*X509_STORE_CTX) callconv(.C) c_int;
+pub extern fn SSL_CTX_set_verify_depth(ctx: ?*SSL_CTX, depth: c_int) void;
+pub extern fn SSL_set_verify_depth(ssl: ?*SSL, depth: c_int) void;
+pub extern fn SSL_CTX_get_verify_depth(ctx: ?*const SSL_CTX) c_int;
+pub extern fn SSL_get_verify_depth(ssl: ?*const SSL) c_int;
+pub extern fn SSL_CTX_set1_param(ctx: ?*SSL_CTX, param: ?*const X509_VERIFY_PARAM) c_int;
+pub extern fn SSL_set1_param(ssl: ?*SSL, param: ?*const X509_VERIFY_PARAM) c_int;
+pub extern fn SSL_CTX_get0_param(ctx: ?*SSL_CTX) ?*X509_VERIFY_PARAM;
+pub extern fn SSL_get0_param(ssl: ?*SSL) ?*X509_VERIFY_PARAM;
+pub extern fn SSL_CTX_set_purpose(ctx: ?*SSL_CTX, purpose: c_int) c_int;
+pub extern fn SSL_set_purpose(ssl: ?*SSL, purpose: c_int) c_int;
+pub extern fn SSL_CTX_set_trust(ctx: ?*SSL_CTX, trust: c_int) c_int;
+pub extern fn SSL_set_trust(ssl: ?*SSL, trust: c_int) c_int;
+pub extern fn SSL_CTX_set_cert_store(ctx: ?*SSL_CTX, store: ?*X509_STORE) void;
+pub extern fn SSL_CTX_get_cert_store(ctx: ?*const SSL_CTX) ?*X509_STORE;
+pub extern fn SSL_CTX_set_default_verify_paths(ctx: ?*SSL_CTX) c_int;
+pub extern fn SSL_CTX_load_verify_locations(ctx: ?*SSL_CTX, ca_file: [*c]const u8, ca_dir: [*c]const u8) c_int;
+pub extern fn SSL_get_verify_result(ssl: ?*const SSL) c_long;
+pub extern fn SSL_alert_from_verify_result(result: c_long) c_int;
+pub extern fn SSL_get_ex_data_X509_STORE_CTX_idx() c_int;
+pub extern fn SSL_CTX_set_cert_verify_callback(ctx: ?*SSL_CTX, callback: ?fn (?*X509_STORE_CTX, ?*c_void) callconv(.C) c_int, arg: ?*c_void) void;
+pub extern fn SSL_enable_signed_cert_timestamps(ssl: ?*SSL) void;
+pub extern fn SSL_CTX_enable_signed_cert_timestamps(ctx: ?*SSL_CTX) void;
+pub extern fn SSL_enable_ocsp_stapling(ssl: ?*SSL) void;
+pub extern fn SSL_CTX_enable_ocsp_stapling(ctx: ?*SSL_CTX) void;
+pub extern fn SSL_CTX_set0_verify_cert_store(ctx: ?*SSL_CTX, store: ?*X509_STORE) c_int;
+pub extern fn SSL_CTX_set1_verify_cert_store(ctx: ?*SSL_CTX, store: ?*X509_STORE) c_int;
+pub extern fn SSL_set0_verify_cert_store(ssl: ?*SSL, store: ?*X509_STORE) c_int;
+pub extern fn SSL_set1_verify_cert_store(ssl: ?*SSL, store: ?*X509_STORE) c_int;
+pub extern fn SSL_CTX_set_verify_algorithm_prefs(ctx: ?*SSL_CTX, prefs: [*c]const u16, num_prefs: usize) c_int;
+pub extern fn SSL_set_verify_algorithm_prefs(ssl: ?*SSL, prefs: [*c]const u16, num_prefs: usize) c_int;
+pub extern fn SSL_set_client_CA_list(ssl: ?*SSL, name_list: ?*struct_stack_st_X509_NAME) void;
+pub extern fn SSL_CTX_set_client_CA_list(ctx: ?*SSL_CTX, name_list: ?*struct_stack_st_X509_NAME) void;
+pub extern fn SSL_set0_client_CAs(ssl: ?*SSL, name_list: ?*struct_stack_st_CRYPTO_BUFFER) void;
+pub extern fn SSL_CTX_set0_client_CAs(ctx: ?*SSL_CTX, name_list: ?*struct_stack_st_CRYPTO_BUFFER) void;
+pub extern fn SSL_get_client_CA_list(ssl: ?*const SSL) ?*struct_stack_st_X509_NAME;
+pub extern fn SSL_get0_server_requested_CAs(ssl: ?*const SSL) ?*const struct_stack_st_CRYPTO_BUFFER;
+pub extern fn SSL_CTX_get_client_CA_list(ctx: ?*const SSL_CTX) ?*struct_stack_st_X509_NAME;
+pub extern fn SSL_add_client_CA(ssl: ?*SSL, x509: ?*X509) c_int;
+pub extern fn SSL_CTX_add_client_CA(ctx: ?*SSL_CTX, x509: ?*X509) c_int;
+pub extern fn SSL_load_client_CA_file(file: [*c]const u8) ?*struct_stack_st_X509_NAME;
+pub extern fn SSL_dup_CA_list(list: ?*struct_stack_st_X509_NAME) ?*struct_stack_st_X509_NAME;
+pub extern fn SSL_add_file_cert_subjects_to_stack(out: ?*struct_stack_st_X509_NAME, file: [*c]const u8) c_int;
+pub extern fn SSL_set_tlsext_host_name(ssl: ?*SSL, name: [*c]const u8) c_int;
+pub extern fn SSL_get_servername(ssl: ?*const SSL, @"type": c_int) [*c]const u8;
+pub extern fn SSL_get_servername_type(ssl: ?*const SSL) c_int;
+pub extern fn SSL_CTX_set_tlsext_servername_callback(ctx: ?*SSL_CTX, callback: ?fn (?*SSL, [*c]c_int, ?*c_void) callconv(.C) c_int) c_int;
+pub extern fn SSL_CTX_set_tlsext_servername_arg(ctx: ?*SSL_CTX, arg: ?*c_void) c_int;
+pub extern fn SSL_set_SSL_CTX(ssl: ?*SSL, ctx: ?*SSL_CTX) ?*SSL_CTX;
+pub extern fn SSL_CTX_set_alpn_protos(ctx: ?*SSL_CTX, protos: [*c]const u8, protos_len: c_uint) c_int;
+pub extern fn SSL_set_alpn_protos(ssl: ?*SSL, protos: [*c]const u8, protos_len: c_uint) c_int;
+pub extern fn SSL_CTX_set_alpn_select_cb(ctx: ?*SSL_CTX, cb: ?fn (?*SSL, [*c][*c]const u8, [*c]u8, [*c]const u8, c_uint, ?*c_void) callconv(.C) c_int, arg: ?*c_void) void;
+pub extern fn SSL_get0_alpn_selected(ssl: ?*const SSL, out_data: [*c][*c]const u8, out_len: [*c]c_uint) void;
+pub extern fn SSL_CTX_set_allow_unknown_alpn_protos(ctx: ?*SSL_CTX, enabled: c_int) void;
+pub extern fn SSL_add_application_settings(ssl: ?*SSL, proto: [*c]const u8, proto_len: usize, settings: [*c]const u8, settings_len: usize) c_int;
+pub extern fn SSL_get0_peer_application_settings(ssl: ?*const SSL, out_data: [*c][*c]const u8, out_len: [*c]usize) void;
+pub extern fn SSL_has_application_settings(ssl: ?*const SSL) c_int;
+pub const ssl_cert_compression_func_t = ?fn (?*SSL, [*c]CBB, [*c]const u8, usize) callconv(.C) c_int;
+pub const ssl_cert_decompression_func_t = ?fn (?*SSL, [*c]?*CRYPTO_BUFFER, usize, [*c]const u8, usize) callconv(.C) c_int;
+pub extern fn SSL_CTX_add_cert_compression_alg(ctx: ?*SSL_CTX, alg_id: u16, compress: ssl_cert_compression_func_t, decompress: ssl_cert_decompression_func_t) c_int;
+pub extern fn SSL_CTX_set_next_protos_advertised_cb(ctx: ?*SSL_CTX, cb: ?fn (?*SSL, [*c][*c]const u8, [*c]c_uint, ?*c_void) callconv(.C) c_int, arg: ?*c_void) void;
+pub extern fn SSL_CTX_set_next_proto_select_cb(ctx: ?*SSL_CTX, cb: ?fn (?*SSL, [*c][*c]u8, [*c]u8, [*c]const u8, c_uint, ?*c_void) callconv(.C) c_int, arg: ?*c_void) void;
+pub extern fn SSL_get0_next_proto_negotiated(ssl: ?*const SSL, out_data: [*c][*c]const u8, out_len: [*c]c_uint) void;
+pub extern fn SSL_select_next_proto(out: [*c][*c]u8, out_len: [*c]u8, peer: [*c]const u8, peer_len: c_uint, supported: [*c]const u8, supported_len: c_uint) c_int;
+pub extern fn SSL_CTX_set_tls_channel_id_enabled(ctx: ?*SSL_CTX, enabled: c_int) void;
+pub extern fn SSL_set_tls_channel_id_enabled(ssl: ?*SSL, enabled: c_int) void;
+pub extern fn SSL_CTX_set1_tls_channel_id(ctx: ?*SSL_CTX, private_key: [*c]EVP_PKEY) c_int;
+pub extern fn SSL_set1_tls_channel_id(ssl: ?*SSL, private_key: [*c]EVP_PKEY) c_int;
+pub extern fn SSL_get_tls_channel_id(ssl: ?*SSL, out: [*c]u8, max_out: usize) usize;
+pub const struct_stack_st_SRTP_PROTECTION_PROFILE = opaque {};
+pub const stack_SRTP_PROTECTION_PROFILE_free_func = ?fn ([*c]const SRTP_PROTECTION_PROFILE) callconv(.C) void;
+pub const stack_SRTP_PROTECTION_PROFILE_copy_func = ?fn ([*c]const SRTP_PROTECTION_PROFILE) callconv(.C) [*c]const SRTP_PROTECTION_PROFILE;
+pub const stack_SRTP_PROTECTION_PROFILE_cmp_func = ?fn ([*c][*c]const SRTP_PROTECTION_PROFILE, [*c][*c]const SRTP_PROTECTION_PROFILE) callconv(.C) c_int;
+pub fn sk_SRTP_PROTECTION_PROFILE_call_free_func(arg_free_func: stack_free_func, arg_ptr: ?*c_void) callconv(.C) void {
+ var free_func = arg_free_func;
+ var ptr = arg_ptr;
+ @ptrCast(stack_SRTP_PROTECTION_PROFILE_free_func, @alignCast(@import("std").meta.alignment(fn ([*c]const SRTP_PROTECTION_PROFILE) callconv(.C) void), free_func)).?(@ptrCast([*c]const SRTP_PROTECTION_PROFILE, @alignCast(@import("std").meta.alignment(SRTP_PROTECTION_PROFILE), ptr)));
+}
+pub fn sk_SRTP_PROTECTION_PROFILE_call_copy_func(arg_copy_func: stack_copy_func, arg_ptr: ?*c_void) callconv(.C) ?*c_void {
+ var copy_func = arg_copy_func;
+ var ptr = arg_ptr;
+ return @intToPtr(?*c_void, @ptrToInt(@ptrCast(stack_SRTP_PROTECTION_PROFILE_copy_func, @alignCast(@import("std").meta.alignment(fn ([*c]const SRTP_PROTECTION_PROFILE) callconv(.C) [*c]const SRTP_PROTECTION_PROFILE), copy_func)).?(@ptrCast([*c]const SRTP_PROTECTION_PROFILE, @alignCast(@import("std").meta.alignment(SRTP_PROTECTION_PROFILE), ptr)))));
+}
+pub fn sk_SRTP_PROTECTION_PROFILE_call_cmp_func(arg_cmp_func: stack_cmp_func, arg_a: [*c]?*const c_void, arg_b: [*c]?*const c_void) callconv(.C) c_int {
+ var cmp_func = arg_cmp_func;
+ var a = arg_a;
+ var b = arg_b;
+ var a_ptr: [*c]const SRTP_PROTECTION_PROFILE = @ptrCast([*c]const SRTP_PROTECTION_PROFILE, @alignCast(@import("std").meta.alignment(SRTP_PROTECTION_PROFILE), a.*));
+ var b_ptr: [*c]const SRTP_PROTECTION_PROFILE = @ptrCast([*c]const SRTP_PROTECTION_PROFILE, @alignCast(@import("std").meta.alignment(SRTP_PROTECTION_PROFILE), b.*));
+ return @ptrCast(stack_SRTP_PROTECTION_PROFILE_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c][*c]const SRTP_PROTECTION_PROFILE, [*c][*c]const SRTP_PROTECTION_PROFILE) callconv(.C) c_int), cmp_func)).?(&a_ptr, &b_ptr);
+}
+pub fn sk_SRTP_PROTECTION_PROFILE_new(arg_comp: stack_SRTP_PROTECTION_PROFILE_cmp_func) callconv(.C) ?*struct_stack_st_SRTP_PROTECTION_PROFILE {
+ var comp = arg_comp;
+ return @ptrCast(?*struct_stack_st_SRTP_PROTECTION_PROFILE, sk_new(@ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp))));
+}
+pub fn sk_SRTP_PROTECTION_PROFILE_new_null() callconv(.C) ?*struct_stack_st_SRTP_PROTECTION_PROFILE {
+ return @ptrCast(?*struct_stack_st_SRTP_PROTECTION_PROFILE, sk_new_null());
+}
+pub fn sk_SRTP_PROTECTION_PROFILE_num(arg_sk: ?*const struct_stack_st_SRTP_PROTECTION_PROFILE) callconv(.C) usize {
+ var sk = arg_sk;
+ return sk_num(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_SRTP_PROTECTION_PROFILE_zero(arg_sk: ?*struct_stack_st_SRTP_PROTECTION_PROFILE) callconv(.C) void {
+ var sk = arg_sk;
+ sk_zero(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_SRTP_PROTECTION_PROFILE_value(arg_sk: ?*const struct_stack_st_SRTP_PROTECTION_PROFILE, arg_i: usize) callconv(.C) [*c]const SRTP_PROTECTION_PROFILE {
+ var sk = arg_sk;
+ var i = arg_i;
+ return @ptrCast([*c]const SRTP_PROTECTION_PROFILE, @alignCast(@import("std").meta.alignment(SRTP_PROTECTION_PROFILE), sk_value(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i)));
+}
+pub fn sk_SRTP_PROTECTION_PROFILE_set(arg_sk: ?*struct_stack_st_SRTP_PROTECTION_PROFILE, arg_i: usize, arg_p: [*c]const SRTP_PROTECTION_PROFILE) callconv(.C) [*c]const SRTP_PROTECTION_PROFILE {
+ var sk = arg_sk;
+ var i = arg_i;
+ var p = arg_p;
+ return @ptrCast([*c]const SRTP_PROTECTION_PROFILE, @alignCast(@import("std").meta.alignment(SRTP_PROTECTION_PROFILE), sk_set(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i, @intToPtr(?*c_void, @ptrToInt(p)))));
+}
+pub fn sk_SRTP_PROTECTION_PROFILE_free(arg_sk: ?*struct_stack_st_SRTP_PROTECTION_PROFILE) callconv(.C) void {
+ var sk = arg_sk;
+ sk_free(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_SRTP_PROTECTION_PROFILE_pop_free(arg_sk: ?*struct_stack_st_SRTP_PROTECTION_PROFILE, arg_free_func: stack_SRTP_PROTECTION_PROFILE_free_func) callconv(.C) void {
+ var sk = arg_sk;
+ var free_func = arg_free_func;
+ sk_pop_free_ex(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_SRTP_PROTECTION_PROFILE_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func)));
+}
+pub fn sk_SRTP_PROTECTION_PROFILE_insert(arg_sk: ?*struct_stack_st_SRTP_PROTECTION_PROFILE, arg_p: [*c]const SRTP_PROTECTION_PROFILE, arg_where: usize) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ var where = arg_where;
+ return sk_insert(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @intToPtr(?*c_void, @ptrToInt(p)), where);
+}
+pub fn sk_SRTP_PROTECTION_PROFILE_delete(arg_sk: ?*struct_stack_st_SRTP_PROTECTION_PROFILE, arg_where: usize) callconv(.C) [*c]const SRTP_PROTECTION_PROFILE {
+ var sk = arg_sk;
+ var where = arg_where;
+ return @ptrCast([*c]const SRTP_PROTECTION_PROFILE, @alignCast(@import("std").meta.alignment(SRTP_PROTECTION_PROFILE), sk_delete(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), where)));
+}
+pub fn sk_SRTP_PROTECTION_PROFILE_delete_ptr(arg_sk: ?*struct_stack_st_SRTP_PROTECTION_PROFILE, arg_p: [*c]const SRTP_PROTECTION_PROFILE) callconv(.C) [*c]const SRTP_PROTECTION_PROFILE {
+ var sk = arg_sk;
+ var p = arg_p;
+ return @ptrCast([*c]const SRTP_PROTECTION_PROFILE, @alignCast(@import("std").meta.alignment(SRTP_PROTECTION_PROFILE), sk_delete_ptr(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*const c_void, p))));
+}
+pub fn sk_SRTP_PROTECTION_PROFILE_find(arg_sk: ?*const struct_stack_st_SRTP_PROTECTION_PROFILE, arg_out_index: [*c]usize, arg_p: [*c]const SRTP_PROTECTION_PROFILE) callconv(.C) c_int {
+ var sk = arg_sk;
+ var out_index = arg_out_index;
+ var p = arg_p;
+ return sk_find(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), out_index, @ptrCast(?*const c_void, p), sk_SRTP_PROTECTION_PROFILE_call_cmp_func);
+}
+pub fn sk_SRTP_PROTECTION_PROFILE_shift(arg_sk: ?*struct_stack_st_SRTP_PROTECTION_PROFILE) callconv(.C) [*c]const SRTP_PROTECTION_PROFILE {
+ var sk = arg_sk;
+ return @ptrCast([*c]const SRTP_PROTECTION_PROFILE, @alignCast(@import("std").meta.alignment(SRTP_PROTECTION_PROFILE), sk_shift(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)))));
+}
+pub fn sk_SRTP_PROTECTION_PROFILE_push(arg_sk: ?*struct_stack_st_SRTP_PROTECTION_PROFILE, arg_p: [*c]const SRTP_PROTECTION_PROFILE) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ return sk_push(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @intToPtr(?*c_void, @ptrToInt(p)));
+}
+pub fn sk_SRTP_PROTECTION_PROFILE_pop(arg_sk: ?*struct_stack_st_SRTP_PROTECTION_PROFILE) callconv(.C) [*c]const SRTP_PROTECTION_PROFILE {
+ var sk = arg_sk;
+ return @ptrCast([*c]const SRTP_PROTECTION_PROFILE, @alignCast(@import("std").meta.alignment(SRTP_PROTECTION_PROFILE), sk_pop(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)))));
+}
+pub fn sk_SRTP_PROTECTION_PROFILE_dup(arg_sk: ?*const struct_stack_st_SRTP_PROTECTION_PROFILE) callconv(.C) ?*struct_stack_st_SRTP_PROTECTION_PROFILE {
+ var sk = arg_sk;
+ return @ptrCast(?*struct_stack_st_SRTP_PROTECTION_PROFILE, sk_dup(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_SRTP_PROTECTION_PROFILE_sort(arg_sk: ?*struct_stack_st_SRTP_PROTECTION_PROFILE) callconv(.C) void {
+ var sk = arg_sk;
+ sk_sort(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_SRTP_PROTECTION_PROFILE_is_sorted(arg_sk: ?*const struct_stack_st_SRTP_PROTECTION_PROFILE) callconv(.C) c_int {
+ var sk = arg_sk;
+ return sk_is_sorted(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_SRTP_PROTECTION_PROFILE_set_cmp_func(arg_sk: ?*struct_stack_st_SRTP_PROTECTION_PROFILE, arg_comp: stack_SRTP_PROTECTION_PROFILE_cmp_func) callconv(.C) stack_SRTP_PROTECTION_PROFILE_cmp_func {
+ var sk = arg_sk;
+ var comp = arg_comp;
+ return @ptrCast(stack_SRTP_PROTECTION_PROFILE_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c][*c]const SRTP_PROTECTION_PROFILE, [*c][*c]const SRTP_PROTECTION_PROFILE) callconv(.C) c_int), sk_set_cmp_func(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp)))));
+}
+pub fn sk_SRTP_PROTECTION_PROFILE_deep_copy(arg_sk: ?*const struct_stack_st_SRTP_PROTECTION_PROFILE, arg_copy_func: ?fn ([*c]const SRTP_PROTECTION_PROFILE) callconv(.C) [*c]const SRTP_PROTECTION_PROFILE, arg_free_func: ?fn ([*c]const SRTP_PROTECTION_PROFILE) callconv(.C) void) callconv(.C) ?*struct_stack_st_SRTP_PROTECTION_PROFILE {
+ var sk = arg_sk;
+ var copy_func = arg_copy_func;
+ var free_func = arg_free_func;
+ return @ptrCast(?*struct_stack_st_SRTP_PROTECTION_PROFILE, sk_deep_copy(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_SRTP_PROTECTION_PROFILE_call_copy_func, @ptrCast(stack_copy_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) ?*c_void), copy_func)), sk_SRTP_PROTECTION_PROFILE_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func))));
+}
+pub extern fn SSL_CTX_set_srtp_profiles(ctx: ?*SSL_CTX, profiles: [*c]const u8) c_int;
+pub extern fn SSL_set_srtp_profiles(ssl: ?*SSL, profiles: [*c]const u8) c_int;
+pub extern fn SSL_get_srtp_profiles(ssl: ?*const SSL) ?*const struct_stack_st_SRTP_PROTECTION_PROFILE;
+pub extern fn SSL_get_selected_srtp_profile(ssl: ?*SSL) [*c]const SRTP_PROTECTION_PROFILE;
+pub extern fn SSL_CTX_set_psk_client_callback(ctx: ?*SSL_CTX, cb: ?fn (?*SSL, [*c]const u8, [*c]u8, c_uint, [*c]u8, c_uint) callconv(.C) c_uint) void;
+pub extern fn SSL_set_psk_client_callback(ssl: ?*SSL, cb: ?fn (?*SSL, [*c]const u8, [*c]u8, c_uint, [*c]u8, c_uint) callconv(.C) c_uint) void;
+pub extern fn SSL_CTX_set_psk_server_callback(ctx: ?*SSL_CTX, cb: ?fn (?*SSL, [*c]const u8, [*c]u8, c_uint) callconv(.C) c_uint) void;
+pub extern fn SSL_set_psk_server_callback(ssl: ?*SSL, cb: ?fn (?*SSL, [*c]const u8, [*c]u8, c_uint) callconv(.C) c_uint) void;
+pub extern fn SSL_CTX_use_psk_identity_hint(ctx: ?*SSL_CTX, identity_hint: [*c]const u8) c_int;
+pub extern fn SSL_use_psk_identity_hint(ssl: ?*SSL, identity_hint: [*c]const u8) c_int;
+pub extern fn SSL_get_psk_identity_hint(ssl: ?*const SSL) [*c]const u8;
+pub extern fn SSL_get_psk_identity(ssl: ?*const SSL) [*c]const u8;
+pub extern fn SSL_set1_delegated_credential(ssl: ?*SSL, dc: ?*CRYPTO_BUFFER, pkey: [*c]EVP_PKEY, key_method: [*c]const SSL_PRIVATE_KEY_METHOD) c_int;
+pub extern fn SSL_delegated_credential_used(ssl: ?*const SSL) c_int;
+pub extern fn SSL_quic_max_handshake_flight_len(ssl: ?*const SSL, level: enum_ssl_encryption_level_t) usize;
+pub extern fn SSL_quic_read_level(ssl: ?*const SSL) enum_ssl_encryption_level_t;
+pub extern fn SSL_quic_write_level(ssl: ?*const SSL) enum_ssl_encryption_level_t;
+pub extern fn SSL_provide_quic_data(ssl: ?*SSL, level: enum_ssl_encryption_level_t, data: [*c]const u8, len: usize) c_int;
+pub extern fn SSL_process_quic_post_handshake(ssl: ?*SSL) c_int;
+pub extern fn SSL_CTX_set_quic_method(ctx: ?*SSL_CTX, quic_method: [*c]const SSL_QUIC_METHOD) c_int;
+pub extern fn SSL_set_quic_method(ssl: ?*SSL, quic_method: [*c]const SSL_QUIC_METHOD) c_int;
+pub extern fn SSL_set_quic_transport_params(ssl: ?*SSL, params: [*c]const u8, params_len: usize) c_int;
+pub extern fn SSL_get_peer_quic_transport_params(ssl: ?*const SSL, out_params: [*c][*c]const u8, out_params_len: [*c]usize) void;
+pub extern fn SSL_set_quic_use_legacy_codepoint(ssl: ?*SSL, use_legacy: c_int) void;
+pub extern fn SSL_set_quic_early_data_context(ssl: ?*SSL, context: [*c]const u8, context_len: usize) c_int;
+pub extern fn SSL_CTX_set_early_data_enabled(ctx: ?*SSL_CTX, enabled: c_int) void;
+pub extern fn SSL_set_early_data_enabled(ssl: ?*SSL, enabled: c_int) void;
+pub extern fn SSL_in_early_data(ssl: ?*const SSL) c_int;
+pub extern fn SSL_SESSION_early_data_capable(session: ?*const SSL_SESSION) c_int;
+pub extern fn SSL_SESSION_copy_without_early_data(session: ?*SSL_SESSION) ?*SSL_SESSION;
+pub extern fn SSL_early_data_accepted(ssl: ?*const SSL) c_int;
+pub extern fn SSL_reset_early_data_reject(ssl: ?*SSL) void;
+pub extern fn SSL_get_ticket_age_skew(ssl: ?*const SSL) i32;
+pub const ssl_early_data_unknown: c_int = 0;
+pub const ssl_early_data_disabled: c_int = 1;
+pub const ssl_early_data_accepted: c_int = 2;
+pub const ssl_early_data_protocol_version: c_int = 3;
+pub const ssl_early_data_peer_declined: c_int = 4;
+pub const ssl_early_data_no_session_offered: c_int = 5;
+pub const ssl_early_data_session_not_resumed: c_int = 6;
+pub const ssl_early_data_unsupported_for_session: c_int = 7;
+pub const ssl_early_data_hello_retry_request: c_int = 8;
+pub const ssl_early_data_alpn_mismatch: c_int = 9;
+pub const ssl_early_data_channel_id: c_int = 10;
+pub const ssl_early_data_ticket_age_skew: c_int = 12;
+pub const ssl_early_data_quic_parameter_mismatch: c_int = 13;
+pub const ssl_early_data_alps_mismatch: c_int = 14;
+pub const ssl_early_data_reason_max_value: c_int = 14;
+pub const enum_ssl_early_data_reason_t = c_uint;
+pub extern fn SSL_get_early_data_reason(ssl: ?*const SSL) enum_ssl_early_data_reason_t;
+pub extern fn SSL_early_data_reason_string(reason: enum_ssl_early_data_reason_t) [*c]const u8;
+pub extern fn SSL_set_enable_ech_grease(ssl: ?*SSL, enable: c_int) void;
+pub extern fn SSL_set1_ech_config_list(ssl: ?*SSL, ech_config_list: [*c]const u8, ech_config_list_len: usize) c_int;
+pub extern fn SSL_get0_ech_name_override(ssl: ?*const SSL, out_name: [*c][*c]const u8, out_name_len: [*c]usize) void;
+pub extern fn SSL_get0_ech_retry_configs(ssl: ?*const SSL, out_retry_configs: [*c][*c]const u8, out_retry_configs_len: [*c]usize) void;
+pub extern fn SSL_marshal_ech_config(out: [*c][*c]u8, out_len: [*c]usize, config_id: u8, key: ?*const EVP_HPKE_KEY, public_name: [*c]const u8, max_name_len: usize) c_int;
+pub extern fn SSL_ECH_KEYS_new() ?*SSL_ECH_KEYS;
+pub extern fn SSL_ECH_KEYS_up_ref(keys: ?*SSL_ECH_KEYS) void;
+pub extern fn SSL_ECH_KEYS_free(keys: ?*SSL_ECH_KEYS) void;
+pub extern fn SSL_ECH_KEYS_add(keys: ?*SSL_ECH_KEYS, is_retry_config: c_int, ech_config: [*c]const u8, ech_config_len: usize, key: ?*const EVP_HPKE_KEY) c_int;
+pub extern fn SSL_ECH_KEYS_has_duplicate_config_id(keys: ?*const SSL_ECH_KEYS) c_int;
+pub extern fn SSL_ECH_KEYS_marshal_retry_configs(keys: ?*const SSL_ECH_KEYS, out: [*c][*c]u8, out_len: [*c]usize) c_int;
+pub extern fn SSL_CTX_set1_ech_keys(ctx: ?*SSL_CTX, keys: ?*SSL_ECH_KEYS) c_int;
+pub extern fn SSL_ech_accepted(ssl: ?*const SSL) c_int;
+pub extern fn SSL_alert_type_string_long(value: c_int) [*c]const u8;
+pub extern fn SSL_alert_desc_string_long(value: c_int) [*c]const u8;
+pub extern fn SSL_send_fatal_alert(ssl: ?*SSL, alert: u8) c_int;
+pub extern fn SSL_set_ex_data(ssl: ?*SSL, idx: c_int, data: ?*c_void) c_int;
+pub extern fn SSL_get_ex_data(ssl: ?*const SSL, idx: c_int) ?*c_void;
+pub extern fn SSL_get_ex_new_index(argl: c_long, argp: ?*c_void, unused: [*c]CRYPTO_EX_unused, dup_unused: ?CRYPTO_EX_dup, free_func: ?CRYPTO_EX_free) c_int;
+pub extern fn SSL_SESSION_set_ex_data(session: ?*SSL_SESSION, idx: c_int, data: ?*c_void) c_int;
+pub extern fn SSL_SESSION_get_ex_data(session: ?*const SSL_SESSION, idx: c_int) ?*c_void;
+pub extern fn SSL_SESSION_get_ex_new_index(argl: c_long, argp: ?*c_void, unused: [*c]CRYPTO_EX_unused, dup_unused: ?CRYPTO_EX_dup, free_func: ?CRYPTO_EX_free) c_int;
+pub extern fn SSL_CTX_set_ex_data(ctx: ?*SSL_CTX, idx: c_int, data: ?*c_void) c_int;
+pub extern fn SSL_CTX_get_ex_data(ctx: ?*const SSL_CTX, idx: c_int) ?*c_void;
+pub extern fn SSL_CTX_get_ex_new_index(argl: c_long, argp: ?*c_void, unused: [*c]CRYPTO_EX_unused, dup_unused: ?CRYPTO_EX_dup, free_func: ?CRYPTO_EX_free) c_int;
+pub extern fn SSL_get_ivs(ssl: ?*const SSL, out_read_iv: [*c][*c]const u8, out_write_iv: [*c][*c]const u8, out_iv_len: [*c]usize) c_int;
+pub extern fn SSL_get_key_block_len(ssl: ?*const SSL) usize;
+pub extern fn SSL_generate_key_block(ssl: ?*const SSL, out: [*c]u8, out_len: usize) c_int;
+pub extern fn SSL_get_read_sequence(ssl: ?*const SSL) u64;
+pub extern fn SSL_get_write_sequence(ssl: ?*const SSL) u64;
+pub extern fn SSL_CTX_set_record_protocol_version(ctx: ?*SSL_CTX, version: c_int) c_int;
+pub extern fn SSL_serialize_capabilities(ssl: ?*const SSL, out: [*c]CBB) c_int;
+pub extern fn SSL_request_handshake_hints(ssl: ?*SSL, client_hello: [*c]const u8, client_hello_len: usize, capabilities: [*c]const u8, capabilities_len: usize) c_int;
+pub extern fn SSL_serialize_handshake_hints(ssl: ?*const SSL, out: [*c]CBB) c_int;
+pub extern fn SSL_set_handshake_hints(ssl: ?*SSL, hints: [*c]const u8, hints_len: usize) c_int;
+pub extern fn SSL_CTX_set_msg_callback(ctx: ?*SSL_CTX, cb: ?fn (c_int, c_int, c_int, ?*const c_void, usize, ?*SSL, ?*c_void) callconv(.C) void) void;
+pub extern fn SSL_CTX_set_msg_callback_arg(ctx: ?*SSL_CTX, arg: ?*c_void) void;
+pub extern fn SSL_set_msg_callback(ssl: ?*SSL, cb: ?fn (c_int, c_int, c_int, ?*const c_void, usize, ?*SSL, ?*c_void) callconv(.C) void) void;
+pub extern fn SSL_set_msg_callback_arg(ssl: ?*SSL, arg: ?*c_void) void;
+pub extern fn SSL_CTX_set_keylog_callback(ctx: ?*SSL_CTX, cb: ?fn (?*const SSL, [*c]const u8) callconv(.C) void) void;
+pub extern fn SSL_CTX_get_keylog_callback(ctx: ?*const SSL_CTX) ?fn (?*const SSL, [*c]const u8) callconv(.C) void;
+pub extern fn SSL_CTX_set_current_time_cb(ctx: ?*SSL_CTX, cb: ?fn (?*const SSL, [*c]struct_timeval) callconv(.C) void) void;
+pub extern fn SSL_set_shed_handshake_config(ssl: ?*SSL, enable: c_int) void;
+pub const ssl_renegotiate_never: c_int = 0;
+pub const ssl_renegotiate_once: c_int = 1;
+pub const ssl_renegotiate_freely: c_int = 2;
+pub const ssl_renegotiate_ignore: c_int = 3;
+pub const ssl_renegotiate_explicit: c_int = 4;
+pub const enum_ssl_renegotiate_mode_t = c_uint;
+pub extern fn SSL_set_renegotiate_mode(ssl: ?*SSL, mode: enum_ssl_renegotiate_mode_t) void;
+pub extern fn SSL_renegotiate(ssl: ?*SSL) c_int;
+pub extern fn SSL_renegotiate_pending(ssl: ?*SSL) c_int;
+pub extern fn SSL_total_renegotiations(ssl: ?*const SSL) c_int;
+pub extern fn SSL_CTX_get_max_cert_list(ctx: ?*const SSL_CTX) usize;
+pub extern fn SSL_CTX_set_max_cert_list(ctx: ?*SSL_CTX, max_cert_list: usize) void;
+pub extern fn SSL_get_max_cert_list(ssl: ?*const SSL) usize;
+pub extern fn SSL_set_max_cert_list(ssl: ?*SSL, max_cert_list: usize) void;
+pub extern fn SSL_CTX_set_max_send_fragment(ctx: ?*SSL_CTX, max_send_fragment: usize) c_int;
+pub extern fn SSL_set_max_send_fragment(ssl: ?*SSL, max_send_fragment: usize) c_int;
+pub const ssl_select_cert_success: c_int = 1;
+pub const ssl_select_cert_retry: c_int = 0;
+pub const ssl_select_cert_error: c_int = -1;
+pub const enum_ssl_select_cert_result_t = c_int;
+pub extern fn SSL_early_callback_ctx_extension_get(client_hello: [*c]const SSL_CLIENT_HELLO, extension_type: u16, out_data: [*c][*c]const u8, out_len: [*c]usize) c_int;
+pub extern fn SSL_CTX_set_select_certificate_cb(ctx: ?*SSL_CTX, cb: ?fn ([*c]const SSL_CLIENT_HELLO) callconv(.C) enum_ssl_select_cert_result_t) void;
+pub extern fn SSL_CTX_set_dos_protection_cb(ctx: ?*SSL_CTX, cb: ?fn ([*c]const SSL_CLIENT_HELLO) callconv(.C) c_int) void;
+pub extern fn SSL_CTX_set_reverify_on_resume(ctx: ?*SSL_CTX, enabled: c_int) void;
+pub extern fn SSL_set_enforce_rsa_key_usage(ssl: ?*SSL, enabled: c_int) void;
+pub extern fn SSL_CTX_set_info_callback(ctx: ?*SSL_CTX, cb: ?fn (?*const SSL, c_int, c_int) callconv(.C) void) void;
+pub extern fn SSL_CTX_get_info_callback(ctx: ?*SSL_CTX) ?fn (?*const SSL, c_int, c_int) callconv(.C) void;
+pub extern fn SSL_set_info_callback(ssl: ?*SSL, cb: ?fn (?*const SSL, c_int, c_int) callconv(.C) void) void;
+pub extern fn SSL_get_info_callback(ssl: ?*const SSL) ?fn (?*const SSL, c_int, c_int) callconv(.C) void;
+pub extern fn SSL_state_string_long(ssl: ?*const SSL) [*c]const u8;
+pub extern fn SSL_get_shutdown(ssl: ?*const SSL) c_int;
+pub extern fn SSL_get_peer_signature_algorithm(ssl: ?*const SSL) u16;
+pub extern fn SSL_get_client_random(ssl: ?*const SSL, out: [*c]u8, max_out: usize) usize;
+pub extern fn SSL_get_server_random(ssl: ?*const SSL, out: [*c]u8, max_out: usize) usize;
+pub extern fn SSL_get_pending_cipher(ssl: ?*const SSL) ?*const SSL_CIPHER;
+pub extern fn SSL_set_retain_only_sha256_of_client_certs(ssl: ?*SSL, enable: c_int) void;
+pub extern fn SSL_CTX_set_retain_only_sha256_of_client_certs(ctx: ?*SSL_CTX, enable: c_int) void;
+pub extern fn SSL_CTX_set_grease_enabled(ctx: ?*SSL_CTX, enabled: c_int) void;
+pub extern fn SSL_CTX_set_permute_extensions(ctx: ?*SSL_CTX, enabled: c_int) void;
+pub extern fn SSL_set_permute_extensions(ssl: ?*SSL, enabled: c_int) void;
+pub extern fn SSL_max_seal_overhead(ssl: ?*const SSL) usize;
+pub extern fn SSL_CTX_set_false_start_allowed_without_alpn(ctx: ?*SSL_CTX, allowed: c_int) void;
+pub extern fn SSL_used_hello_retry_request(ssl: ?*const SSL) c_int;
+pub extern fn SSL_set_jdk11_workaround(ssl: ?*SSL, enable: c_int) void;
+pub extern fn SSL_library_init() c_int;
+pub extern fn SSL_CIPHER_description(cipher: ?*const SSL_CIPHER, buf: [*c]u8, len: c_int) [*c]const u8;
+pub extern fn SSL_CIPHER_get_version(cipher: ?*const SSL_CIPHER) [*c]const u8;
+pub extern fn SSL_CIPHER_get_rfc_name(cipher: ?*const SSL_CIPHER) [*c]u8;
+pub const COMP_METHOD = c_void;
+pub const struct_ssl_comp_st = extern struct {
+ id: c_int,
+ name: [*c]const u8,
+ method: [*c]u8,
+};
+pub const SSL_COMP = struct_ssl_comp_st;
+pub const struct_stack_st_SSL_COMP = opaque {};
+pub extern fn SSL_COMP_get_compression_methods() ?*struct_stack_st_SSL_COMP;
+pub extern fn SSL_COMP_add_compression_method(id: c_int, cm: ?*COMP_METHOD) c_int;
+pub extern fn SSL_COMP_get_name(comp: ?*const COMP_METHOD) [*c]const u8;
+pub extern fn SSL_COMP_get0_name(comp: [*c]const SSL_COMP) [*c]const u8;
+pub extern fn SSL_COMP_get_id(comp: [*c]const SSL_COMP) c_int;
+pub extern fn SSL_COMP_free_compression_methods() void;
+pub extern fn SSLv23_method() ?*const SSL_METHOD;
+pub extern fn TLSv1_method() ?*const SSL_METHOD;
+pub extern fn TLSv1_1_method() ?*const SSL_METHOD;
+pub extern fn TLSv1_2_method() ?*const SSL_METHOD;
+pub extern fn DTLSv1_method() ?*const SSL_METHOD;
+pub extern fn DTLSv1_2_method() ?*const SSL_METHOD;
+pub extern fn TLS_server_method() ?*const SSL_METHOD;
+pub extern fn TLS_client_method() ?*const SSL_METHOD;
+pub extern fn SSLv23_server_method() ?*const SSL_METHOD;
+pub extern fn SSLv23_client_method() ?*const SSL_METHOD;
+pub extern fn TLSv1_server_method() ?*const SSL_METHOD;
+pub extern fn TLSv1_client_method() ?*const SSL_METHOD;
+pub extern fn TLSv1_1_server_method() ?*const SSL_METHOD;
+pub extern fn TLSv1_1_client_method() ?*const SSL_METHOD;
+pub extern fn TLSv1_2_server_method() ?*const SSL_METHOD;
+pub extern fn TLSv1_2_client_method() ?*const SSL_METHOD;
+pub extern fn DTLS_server_method() ?*const SSL_METHOD;
+pub extern fn DTLS_client_method() ?*const SSL_METHOD;
+pub extern fn DTLSv1_server_method() ?*const SSL_METHOD;
+pub extern fn DTLSv1_client_method() ?*const SSL_METHOD;
+pub extern fn DTLSv1_2_server_method() ?*const SSL_METHOD;
+pub extern fn DTLSv1_2_client_method() ?*const SSL_METHOD;
+pub extern fn SSL_clear(ssl: ?*SSL) c_int;
+pub extern fn SSL_CTX_set_tmp_rsa_callback(ctx: ?*SSL_CTX, cb: ?fn (?*SSL, c_int, c_int) callconv(.C) ?*RSA) void;
+pub extern fn SSL_set_tmp_rsa_callback(ssl: ?*SSL, cb: ?fn (?*SSL, c_int, c_int) callconv(.C) ?*RSA) void;
+pub extern fn SSL_CTX_sess_connect(ctx: ?*const SSL_CTX) c_int;
+pub extern fn SSL_CTX_sess_connect_good(ctx: ?*const SSL_CTX) c_int;
+pub extern fn SSL_CTX_sess_connect_renegotiate(ctx: ?*const SSL_CTX) c_int;
+pub extern fn SSL_CTX_sess_accept(ctx: ?*const SSL_CTX) c_int;
+pub extern fn SSL_CTX_sess_accept_renegotiate(ctx: ?*const SSL_CTX) c_int;
+pub extern fn SSL_CTX_sess_accept_good(ctx: ?*const SSL_CTX) c_int;
+pub extern fn SSL_CTX_sess_hits(ctx: ?*const SSL_CTX) c_int;
+pub extern fn SSL_CTX_sess_cb_hits(ctx: ?*const SSL_CTX) c_int;
+pub extern fn SSL_CTX_sess_misses(ctx: ?*const SSL_CTX) c_int;
+pub extern fn SSL_CTX_sess_timeouts(ctx: ?*const SSL_CTX) c_int;
+pub extern fn SSL_CTX_sess_cache_full(ctx: ?*const SSL_CTX) c_int;
+pub extern fn SSL_cutthrough_complete(ssl: ?*const SSL) c_int;
+pub extern fn SSL_num_renegotiations(ssl: ?*const SSL) c_int;
+pub extern fn SSL_CTX_need_tmp_RSA(ctx: ?*const SSL_CTX) c_int;
+pub extern fn SSL_need_tmp_RSA(ssl: ?*const SSL) c_int;
+pub extern fn SSL_CTX_set_tmp_rsa(ctx: ?*SSL_CTX, rsa: ?*const RSA) c_int;
+pub extern fn SSL_set_tmp_rsa(ssl: ?*SSL, rsa: ?*const RSA) c_int;
+pub extern fn SSL_CTX_get_read_ahead(ctx: ?*const SSL_CTX) c_int;
+pub extern fn SSL_CTX_set_read_ahead(ctx: ?*SSL_CTX, yes: c_int) c_int;
+pub extern fn SSL_get_read_ahead(ssl: ?*const SSL) c_int;
+pub extern fn SSL_set_read_ahead(ssl: ?*SSL, yes: c_int) c_int;
+pub extern fn SSL_set_state(ssl: ?*SSL, state: c_int) void;
+pub extern fn SSL_get_shared_ciphers(ssl: ?*const SSL, buf: [*c]u8, len: c_int) [*c]u8;
+pub extern fn SSL_get_shared_sigalgs(ssl: ?*SSL, idx: c_int, psign: [*c]c_int, phash: [*c]c_int, psignandhash: [*c]c_int, rsig: [*c]u8, rhash: [*c]u8) c_int;
+pub extern fn i2d_SSL_SESSION(in: ?*SSL_SESSION, pp: [*c][*c]u8) c_int;
+pub extern fn d2i_SSL_SESSION(a: [*c]?*SSL_SESSION, pp: [*c][*c]const u8, length: c_long) ?*SSL_SESSION;
+pub extern fn i2d_SSL_SESSION_bio(bio: [*c]BIO, session: ?*const SSL_SESSION) c_int;
+pub extern fn d2i_SSL_SESSION_bio(bio: [*c]BIO, out: [*c]?*SSL_SESSION) ?*SSL_SESSION;
+pub extern fn ERR_load_SSL_strings() void;
+pub extern fn SSL_load_error_strings() void;
+pub extern fn SSL_CTX_set_tlsext_use_srtp(ctx: ?*SSL_CTX, profiles: [*c]const u8) c_int;
+pub extern fn SSL_set_tlsext_use_srtp(ssl: ?*SSL, profiles: [*c]const u8) c_int;
+pub extern fn SSL_get_current_compression(ssl: ?*SSL) ?*const COMP_METHOD;
+pub extern fn SSL_get_current_expansion(ssl: ?*SSL) ?*const COMP_METHOD;
+pub extern fn SSL_get_server_tmp_key(ssl: ?*SSL, out_key: [*c][*c]EVP_PKEY) c_int;
+pub extern fn SSL_CTX_set_tmp_dh(ctx: ?*SSL_CTX, dh: [*c]const DH) c_int;
+pub extern fn SSL_set_tmp_dh(ssl: ?*SSL, dh: [*c]const DH) c_int;
+pub extern fn SSL_CTX_set_tmp_dh_callback(ctx: ?*SSL_CTX, cb: ?fn (?*SSL, c_int, c_int) callconv(.C) [*c]DH) void;
+pub extern fn SSL_set_tmp_dh_callback(ssl: ?*SSL, cb: ?fn (?*SSL, c_int, c_int) callconv(.C) [*c]DH) void;
+pub extern fn SSL_CTX_set1_sigalgs(ctx: ?*SSL_CTX, values: [*c]const c_int, num_values: usize) c_int;
+pub extern fn SSL_set1_sigalgs(ssl: ?*SSL, values: [*c]const c_int, num_values: usize) c_int;
+pub extern fn SSL_CTX_set1_sigalgs_list(ctx: ?*SSL_CTX, str: [*c]const u8) c_int;
+pub extern fn SSL_set1_sigalgs_list(ssl: ?*SSL, str: [*c]const u8) c_int;
+pub const stack_SSL_COMP_free_func = ?fn ([*c]SSL_COMP) callconv(.C) void;
+pub const stack_SSL_COMP_copy_func = ?fn ([*c]SSL_COMP) callconv(.C) [*c]SSL_COMP;
+pub const stack_SSL_COMP_cmp_func = ?fn ([*c][*c]const SSL_COMP, [*c][*c]const SSL_COMP) callconv(.C) c_int;
+pub fn sk_SSL_COMP_call_free_func(arg_free_func: stack_free_func, arg_ptr: ?*c_void) callconv(.C) void {
+ var free_func = arg_free_func;
+ var ptr = arg_ptr;
+ @ptrCast(stack_SSL_COMP_free_func, @alignCast(@import("std").meta.alignment(fn ([*c]SSL_COMP) callconv(.C) void), free_func)).?(@ptrCast([*c]SSL_COMP, @alignCast(@import("std").meta.alignment(SSL_COMP), ptr)));
+}
+pub fn sk_SSL_COMP_call_copy_func(arg_copy_func: stack_copy_func, arg_ptr: ?*c_void) callconv(.C) ?*c_void {
+ var copy_func = arg_copy_func;
+ var ptr = arg_ptr;
+ return @ptrCast(?*c_void, @ptrCast(stack_SSL_COMP_copy_func, @alignCast(@import("std").meta.alignment(fn ([*c]SSL_COMP) callconv(.C) [*c]SSL_COMP), copy_func)).?(@ptrCast([*c]SSL_COMP, @alignCast(@import("std").meta.alignment(SSL_COMP), ptr))));
+}
+pub fn sk_SSL_COMP_call_cmp_func(arg_cmp_func: stack_cmp_func, arg_a: [*c]?*const c_void, arg_b: [*c]?*const c_void) callconv(.C) c_int {
+ var cmp_func = arg_cmp_func;
+ var a = arg_a;
+ var b = arg_b;
+ var a_ptr: [*c]const SSL_COMP = @ptrCast([*c]const SSL_COMP, @alignCast(@import("std").meta.alignment(SSL_COMP), a.*));
+ var b_ptr: [*c]const SSL_COMP = @ptrCast([*c]const SSL_COMP, @alignCast(@import("std").meta.alignment(SSL_COMP), b.*));
+ return @ptrCast(stack_SSL_COMP_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c][*c]const SSL_COMP, [*c][*c]const SSL_COMP) callconv(.C) c_int), cmp_func)).?(&a_ptr, &b_ptr);
+}
+pub fn sk_SSL_COMP_new(arg_comp: stack_SSL_COMP_cmp_func) callconv(.C) ?*struct_stack_st_SSL_COMP {
+ var comp = arg_comp;
+ return @ptrCast(?*struct_stack_st_SSL_COMP, sk_new(@ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp))));
+}
+pub fn sk_SSL_COMP_new_null() callconv(.C) ?*struct_stack_st_SSL_COMP {
+ return @ptrCast(?*struct_stack_st_SSL_COMP, sk_new_null());
+}
+pub fn sk_SSL_COMP_num(arg_sk: ?*const struct_stack_st_SSL_COMP) callconv(.C) usize {
+ var sk = arg_sk;
+ return sk_num(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_SSL_COMP_zero(arg_sk: ?*struct_stack_st_SSL_COMP) callconv(.C) void {
+ var sk = arg_sk;
+ sk_zero(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_SSL_COMP_value(arg_sk: ?*const struct_stack_st_SSL_COMP, arg_i: usize) callconv(.C) [*c]SSL_COMP {
+ var sk = arg_sk;
+ var i = arg_i;
+ return @ptrCast([*c]SSL_COMP, @alignCast(@import("std").meta.alignment(SSL_COMP), sk_value(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i)));
+}
+pub fn sk_SSL_COMP_set(arg_sk: ?*struct_stack_st_SSL_COMP, arg_i: usize, arg_p: [*c]SSL_COMP) callconv(.C) [*c]SSL_COMP {
+ var sk = arg_sk;
+ var i = arg_i;
+ var p = arg_p;
+ return @ptrCast([*c]SSL_COMP, @alignCast(@import("std").meta.alignment(SSL_COMP), sk_set(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i, @ptrCast(?*c_void, p))));
+}
+pub fn sk_SSL_COMP_free(arg_sk: ?*struct_stack_st_SSL_COMP) callconv(.C) void {
+ var sk = arg_sk;
+ sk_free(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_SSL_COMP_pop_free(arg_sk: ?*struct_stack_st_SSL_COMP, arg_free_func: stack_SSL_COMP_free_func) callconv(.C) void {
+ var sk = arg_sk;
+ var free_func = arg_free_func;
+ sk_pop_free_ex(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_SSL_COMP_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func)));
+}
+pub fn sk_SSL_COMP_insert(arg_sk: ?*struct_stack_st_SSL_COMP, arg_p: [*c]SSL_COMP, arg_where: usize) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ var where = arg_where;
+ return sk_insert(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p), where);
+}
+pub fn sk_SSL_COMP_delete(arg_sk: ?*struct_stack_st_SSL_COMP, arg_where: usize) callconv(.C) [*c]SSL_COMP {
+ var sk = arg_sk;
+ var where = arg_where;
+ return @ptrCast([*c]SSL_COMP, @alignCast(@import("std").meta.alignment(SSL_COMP), sk_delete(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), where)));
+}
+pub fn sk_SSL_COMP_delete_ptr(arg_sk: ?*struct_stack_st_SSL_COMP, arg_p: [*c]const SSL_COMP) callconv(.C) [*c]SSL_COMP {
+ var sk = arg_sk;
+ var p = arg_p;
+ return @ptrCast([*c]SSL_COMP, @alignCast(@import("std").meta.alignment(SSL_COMP), sk_delete_ptr(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*const c_void, p))));
+}
+pub fn sk_SSL_COMP_find(arg_sk: ?*const struct_stack_st_SSL_COMP, arg_out_index: [*c]usize, arg_p: [*c]const SSL_COMP) callconv(.C) c_int {
+ var sk = arg_sk;
+ var out_index = arg_out_index;
+ var p = arg_p;
+ return sk_find(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), out_index, @ptrCast(?*const c_void, p), sk_SSL_COMP_call_cmp_func);
+}
+pub fn sk_SSL_COMP_shift(arg_sk: ?*struct_stack_st_SSL_COMP) callconv(.C) [*c]SSL_COMP {
+ var sk = arg_sk;
+ return @ptrCast([*c]SSL_COMP, @alignCast(@import("std").meta.alignment(SSL_COMP), sk_shift(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)))));
+}
+pub fn sk_SSL_COMP_push(arg_sk: ?*struct_stack_st_SSL_COMP, arg_p: [*c]SSL_COMP) callconv(.C) usize {
+ var sk = arg_sk;
+ var p = arg_p;
+ return sk_push(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(?*c_void, p));
+}
+pub fn sk_SSL_COMP_pop(arg_sk: ?*struct_stack_st_SSL_COMP) callconv(.C) [*c]SSL_COMP {
+ var sk = arg_sk;
+ return @ptrCast([*c]SSL_COMP, @alignCast(@import("std").meta.alignment(SSL_COMP), sk_pop(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)))));
+}
+pub fn sk_SSL_COMP_dup(arg_sk: ?*const struct_stack_st_SSL_COMP) callconv(.C) ?*struct_stack_st_SSL_COMP {
+ var sk = arg_sk;
+ return @ptrCast(?*struct_stack_st_SSL_COMP, sk_dup(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk))));
+}
+pub fn sk_SSL_COMP_sort(arg_sk: ?*struct_stack_st_SSL_COMP) callconv(.C) void {
+ var sk = arg_sk;
+ sk_sort(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_SSL_COMP_is_sorted(arg_sk: ?*const struct_stack_st_SSL_COMP) callconv(.C) c_int {
+ var sk = arg_sk;
+ return sk_is_sorted(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)));
+}
+pub fn sk_SSL_COMP_set_cmp_func(arg_sk: ?*struct_stack_st_SSL_COMP, arg_comp: stack_SSL_COMP_cmp_func) callconv(.C) stack_SSL_COMP_cmp_func {
+ var sk = arg_sk;
+ var comp = arg_comp;
+ return @ptrCast(stack_SSL_COMP_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c][*c]const SSL_COMP, [*c][*c]const SSL_COMP) callconv(.C) c_int), sk_set_cmp_func(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrCast(stack_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]?*const c_void, [*c]?*const c_void) callconv(.C) c_int), comp)))));
+}
+pub fn sk_SSL_COMP_deep_copy(arg_sk: ?*const struct_stack_st_SSL_COMP, arg_copy_func: ?fn ([*c]SSL_COMP) callconv(.C) [*c]SSL_COMP, arg_free_func: ?fn ([*c]SSL_COMP) callconv(.C) void) callconv(.C) ?*struct_stack_st_SSL_COMP {
+ var sk = arg_sk;
+ var copy_func = arg_copy_func;
+ var free_func = arg_free_func;
+ return @ptrCast(?*struct_stack_st_SSL_COMP, sk_deep_copy(@ptrCast([*c]const _STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), sk_SSL_COMP_call_copy_func, @ptrCast(stack_copy_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) ?*c_void), copy_func)), sk_SSL_COMP_call_free_func, @ptrCast(stack_free_func, @alignCast(@import("std").meta.alignment(fn (?*c_void) callconv(.C) void), free_func))));
+}
+pub extern fn SSL_cache_hit(ssl: ?*SSL) c_int;
+pub extern fn SSL_get_default_timeout(ssl: ?*const SSL) c_long;
+pub extern fn SSL_get_version(ssl: ?*const SSL) [*c]const u8;
+pub extern fn SSL_get_cipher_list(ssl: ?*const SSL, n: c_int) [*c]const u8;
+pub extern fn SSL_CTX_set_client_cert_cb(ctx: ?*SSL_CTX, cb: ?fn (?*SSL, [*c]?*X509, [*c][*c]EVP_PKEY) callconv(.C) c_int) void;
+pub extern fn SSL_want(ssl: ?*const SSL) c_int;
+pub extern fn SSL_get_finished(ssl: ?*const SSL, buf: ?*c_void, count: usize) usize;
+pub extern fn SSL_get_peer_finished(ssl: ?*const SSL, buf: ?*c_void, count: usize) usize;
+pub extern fn SSL_alert_type_string(value: c_int) [*c]const u8;
+pub extern fn SSL_alert_desc_string(value: c_int) [*c]const u8;
+pub extern fn SSL_state_string(ssl: ?*const SSL) [*c]const u8;
+pub const struct_ssl_conf_ctx_st = opaque {};
+pub const SSL_CONF_CTX = struct_ssl_conf_ctx_st;
+pub extern fn SSL_state(ssl: ?*const SSL) c_int;
+pub extern fn SSL_set_shutdown(ssl: ?*SSL, mode: c_int) void;
+pub extern fn SSL_CTX_set_tmp_ecdh(ctx: ?*SSL_CTX, ec_key: ?*const EC_KEY) c_int;
+pub extern fn SSL_set_tmp_ecdh(ssl: ?*SSL, ec_key: ?*const EC_KEY) c_int;
+pub extern fn SSL_add_dir_cert_subjects_to_stack(out: ?*struct_stack_st_X509_NAME, dir: [*c]const u8) c_int;
+pub extern fn SSL_CTX_enable_tls_channel_id(ctx: ?*SSL_CTX) c_int;
+pub extern fn SSL_enable_tls_channel_id(ssl: ?*SSL) c_int;
+pub extern fn BIO_f_ssl() [*c]const BIO_METHOD;
+pub extern fn BIO_set_ssl(bio: [*c]BIO, ssl: ?*SSL, take_owership: c_int) c_long;
+pub extern fn SSL_get_session(ssl: ?*const SSL) ?*SSL_SESSION;
+pub extern fn SSL_get1_session(ssl: ?*SSL) ?*SSL_SESSION;
+pub extern fn OPENSSL_init_ssl(opts: u64, settings: ?*const OPENSSL_INIT_SETTINGS) c_int;
+pub extern fn SSL_set_tlsext_status_type(ssl: ?*SSL, @"type": c_int) c_int;
+pub extern fn SSL_get_tlsext_status_type(ssl: ?*const SSL) c_int;
+pub extern fn SSL_set_tlsext_status_ocsp_resp(ssl: ?*SSL, resp: [*c]u8, resp_len: usize) c_int;
+pub extern fn SSL_get_tlsext_status_ocsp_resp(ssl: ?*const SSL, out: [*c][*c]const u8) usize;
+pub extern fn SSL_CTX_set_tlsext_status_cb(ctx: ?*SSL_CTX, callback: ?fn (?*SSL, ?*c_void) callconv(.C) c_int) c_int;
+pub extern fn SSL_CTX_set_tlsext_status_arg(ctx: ?*SSL_CTX, arg: ?*c_void) c_int;
+pub extern fn SSL_CIPHER_get_value(cipher: ?*const SSL_CIPHER) u16;
+pub const OPENSSL_VERSION_NUMBER = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x1010107f, .hexadecimal);
+pub const SSLEAY_VERSION_NUMBER = OPENSSL_VERSION_NUMBER;
+pub const BORINGSSL_API_VERSION = @as(c_int, 16);
+pub inline fn OPENSSL_PRINTF_FORMAT_FUNC(string_index: anytype, first_to_check: anytype) @TypeOf(__attribute__(__format__(__printf__, string_index, first_to_check))) {
+ return __attribute__(__format__(__printf__, string_index, first_to_check));
+}
+pub const OPENSSL_UNUSED = __attribute__(unused);
+pub inline fn ERR_GET_LIB(packed_error: anytype) c_int {
+ return @import("std").zig.c_translation.cast(c_int, (packed_error >> @as(c_int, 24)) & @as(c_int, 0xff));
+}
+pub inline fn ERR_GET_REASON(packed_error: anytype) c_int {
+ return @import("std").zig.c_translation.cast(c_int, packed_error & @as(c_int, 0xfff));
+}
+pub const ERR_FLAG_STRING = @as(c_int, 1);
+pub const ERR_R_SYS_LIB = ERR_LIB_SYS;
+pub const ERR_R_BN_LIB = ERR_LIB_BN;
+pub const ERR_R_RSA_LIB = ERR_LIB_RSA;
+pub const ERR_R_DH_LIB = ERR_LIB_DH;
+pub const ERR_R_EVP_LIB = ERR_LIB_EVP;
+pub const ERR_R_BUF_LIB = ERR_LIB_BUF;
+pub const ERR_R_OBJ_LIB = ERR_LIB_OBJ;
+pub const ERR_R_PEM_LIB = ERR_LIB_PEM;
+pub const ERR_R_DSA_LIB = ERR_LIB_DSA;
+pub const ERR_R_X509_LIB = ERR_LIB_X509;
+pub const ERR_R_ASN1_LIB = ERR_LIB_ASN1;
+pub const ERR_R_CONF_LIB = ERR_LIB_CONF;
+pub const ERR_R_CRYPTO_LIB = ERR_LIB_CRYPTO;
+pub const ERR_R_EC_LIB = ERR_LIB_EC;
+pub const ERR_R_SSL_LIB = ERR_LIB_SSL;
+pub const ERR_R_BIO_LIB = ERR_LIB_BIO;
+pub const ERR_R_PKCS7_LIB = ERR_LIB_PKCS7;
+pub const ERR_R_PKCS8_LIB = ERR_LIB_PKCS8;
+pub const ERR_R_X509V3_LIB = ERR_LIB_X509V3;
+pub const ERR_R_RAND_LIB = ERR_LIB_RAND;
+pub const ERR_R_DSO_LIB = ERR_LIB_DSO;
+pub const ERR_R_ENGINE_LIB = ERR_LIB_ENGINE;
+pub const ERR_R_OCSP_LIB = ERR_LIB_OCSP;
+pub const ERR_R_UI_LIB = ERR_LIB_UI;
+pub const ERR_R_COMP_LIB = ERR_LIB_COMP;
+pub const ERR_R_ECDSA_LIB = ERR_LIB_ECDSA;
+pub const ERR_R_ECDH_LIB = ERR_LIB_ECDH;
+pub const ERR_R_STORE_LIB = ERR_LIB_STORE;
+pub const ERR_R_FIPS_LIB = ERR_LIB_FIPS;
+pub const ERR_R_CMS_LIB = ERR_LIB_CMS;
+pub const ERR_R_TS_LIB = ERR_LIB_TS;
+pub const ERR_R_HMAC_LIB = ERR_LIB_HMAC;
+pub const ERR_R_JPAKE_LIB = ERR_LIB_JPAKE;
+pub const ERR_R_USER_LIB = ERR_LIB_USER;
+pub const ERR_R_DIGEST_LIB = ERR_LIB_DIGEST;
+pub const ERR_R_CIPHER_LIB = ERR_LIB_CIPHER;
+pub const ERR_R_HKDF_LIB = ERR_LIB_HKDF;
+pub const ERR_R_TRUST_TOKEN_LIB = ERR_LIB_TRUST_TOKEN;
+pub const ERR_R_FATAL = @as(c_int, 64);
+pub const ERR_R_MALLOC_FAILURE = @as(c_int, 1) | ERR_R_FATAL;
+pub const ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED = @as(c_int, 2) | ERR_R_FATAL;
+pub const ERR_R_PASSED_NULL_PARAMETER = @as(c_int, 3) | ERR_R_FATAL;
+pub const ERR_R_INTERNAL_ERROR = @as(c_int, 4) | ERR_R_FATAL;
+pub const ERR_R_OVERFLOW = @as(c_int, 5) | ERR_R_FATAL;
+pub const ERR_ERROR_STRING_BUF_LEN = @as(c_int, 120);
+pub inline fn ERR_GET_FUNC(packed_error: anytype) @TypeOf(@as(c_int, 0)) {
+ _ = packed_error;
+ return @as(c_int, 0);
+}
+pub const ERR_TXT_STRING = ERR_FLAG_STRING;
+pub const ERR_NUM_ERRORS = @as(c_int, 16);
+pub inline fn ERR_PACK(lib: anytype, reason: anytype) @TypeOf(((@import("std").zig.c_translation.cast(u32, lib) & @as(c_int, 0xff)) << @as(c_int, 24)) | (@import("std").zig.c_translation.cast(u32, reason) & @as(c_int, 0xfff))) {
+ return ((@import("std").zig.c_translation.cast(u32, lib) & @as(c_int, 0xff)) << @as(c_int, 24)) | (@import("std").zig.c_translation.cast(u32, reason) & @as(c_int, 0xfff));
+}
+pub inline fn DEFINE_STACK_OF(@"type": anytype) @TypeOf(DEFINE_NAMED_STACK_OF(@"type", @"type")) {
+ return DEFINE_NAMED_STACK_OF(@"type", @"type");
+}
+pub const CRYPTO_LOCK = @as(c_int, 1);
+pub const CRYPTO_UNLOCK = @as(c_int, 2);
+pub const CRYPTO_READ = @as(c_int, 4);
+pub const CRYPTO_WRITE = @as(c_int, 8);
+pub const BIO_RR_CONNECT = @as(c_int, 0x02);
+pub const BIO_RR_ACCEPT = @as(c_int, 0x03);
+pub const BIO_CB_FREE = @as(c_int, 0x01);
+pub const BIO_CB_READ = @as(c_int, 0x02);
+pub const BIO_CB_WRITE = @as(c_int, 0x03);
+pub const BIO_CB_PUTS = @as(c_int, 0x04);
+pub const BIO_CB_GETS = @as(c_int, 0x05);
+pub const BIO_CB_CTRL = @as(c_int, 0x06);
+pub const BIO_CB_RETURN = @as(c_int, 0x80);
+pub const BIO_NOCLOSE = @as(c_int, 0);
+pub const BIO_CLOSE = @as(c_int, 1);
+pub const BIO_CTRL_DGRAM_QUERY_MTU = @as(c_int, 40);
+pub const BIO_CTRL_DGRAM_SET_MTU = @as(c_int, 42);
+pub const BIO_CTRL_DGRAM_MTU_EXCEEDED = @as(c_int, 43);
+pub const BIO_CTRL_DGRAM_GET_PEER = @as(c_int, 46);
+pub const BIO_CTRL_DGRAM_GET_FALLBACK_MTU = @as(c_int, 47);
+pub const BIO_CTRL_RESET = @as(c_int, 1);
+pub const BIO_CTRL_EOF = @as(c_int, 2);
+pub const BIO_CTRL_INFO = @as(c_int, 3);
+pub const BIO_CTRL_GET_CLOSE = @as(c_int, 8);
+pub const BIO_CTRL_SET_CLOSE = @as(c_int, 9);
+pub const BIO_CTRL_PENDING = @as(c_int, 10);
+pub const BIO_CTRL_FLUSH = @as(c_int, 11);
+pub const BIO_CTRL_WPENDING = @as(c_int, 13);
+pub const BIO_CTRL_SET_CALLBACK = @as(c_int, 14);
+pub const BIO_CTRL_GET_CALLBACK = @as(c_int, 15);
+pub const BIO_CTRL_SET = @as(c_int, 4);
+pub const BIO_CTRL_GET = @as(c_int, 5);
+pub const BIO_CTRL_PUSH = @as(c_int, 6);
+pub const BIO_CTRL_POP = @as(c_int, 7);
+pub const BIO_CTRL_DUP = @as(c_int, 12);
+pub const BIO_CTRL_SET_FILENAME = @as(c_int, 30);
+pub const BIO_FLAGS_READ = @as(c_int, 0x01);
+pub const BIO_FLAGS_WRITE = @as(c_int, 0x02);
+pub const BIO_FLAGS_IO_SPECIAL = @as(c_int, 0x04);
+pub const BIO_FLAGS_RWS = (BIO_FLAGS_READ | BIO_FLAGS_WRITE) | BIO_FLAGS_IO_SPECIAL;
+pub const BIO_FLAGS_SHOULD_RETRY = @as(c_int, 0x08);
+pub const BIO_FLAGS_BASE64_NO_NL = @as(c_int, 0x100);
+pub const BIO_FLAGS_MEM_RDONLY = @as(c_int, 0x200);
+pub const BIO_TYPE_NONE = @as(c_int, 0);
+pub const BIO_TYPE_MEM = @as(c_int, 1) | @as(c_int, 0x0400);
+pub const BIO_TYPE_FILE = @as(c_int, 2) | @as(c_int, 0x0400);
+pub const BIO_TYPE_FD = (@as(c_int, 4) | @as(c_int, 0x0400)) | @as(c_int, 0x0100);
+pub const BIO_TYPE_SOCKET = (@as(c_int, 5) | @as(c_int, 0x0400)) | @as(c_int, 0x0100);
+pub const BIO_TYPE_NULL = @as(c_int, 6) | @as(c_int, 0x0400);
+pub const BIO_TYPE_SSL = @as(c_int, 7) | @as(c_int, 0x0200);
+pub const BIO_TYPE_MD = @as(c_int, 8) | @as(c_int, 0x0200);
+pub const BIO_TYPE_BUFFER = @as(c_int, 9) | @as(c_int, 0x0200);
+pub const BIO_TYPE_CIPHER = @as(c_int, 10) | @as(c_int, 0x0200);
+pub const BIO_TYPE_BASE64 = @as(c_int, 11) | @as(c_int, 0x0200);
+pub const BIO_TYPE_CONNECT = (@as(c_int, 12) | @as(c_int, 0x0400)) | @as(c_int, 0x0100);
+pub const BIO_TYPE_ACCEPT = (@as(c_int, 13) | @as(c_int, 0x0400)) | @as(c_int, 0x0100);
+pub const BIO_TYPE_PROXY_CLIENT = @as(c_int, 14) | @as(c_int, 0x0200);
+pub const BIO_TYPE_PROXY_SERVER = @as(c_int, 15) | @as(c_int, 0x0200);
+pub const BIO_TYPE_NBIO_TEST = @as(c_int, 16) | @as(c_int, 0x0200);
+pub const BIO_TYPE_NULL_FILTER = @as(c_int, 17) | @as(c_int, 0x0200);
+pub const BIO_TYPE_BER = @as(c_int, 18) | @as(c_int, 0x0200);
+pub const BIO_TYPE_BIO = @as(c_int, 19) | @as(c_int, 0x0400);
+pub const BIO_TYPE_LINEBUFFER = @as(c_int, 20) | @as(c_int, 0x0200);
+pub const BIO_TYPE_DGRAM = (@as(c_int, 21) | @as(c_int, 0x0400)) | @as(c_int, 0x0100);
+pub const BIO_TYPE_ASN1 = @as(c_int, 22) | @as(c_int, 0x0200);
+pub const BIO_TYPE_COMP = @as(c_int, 23) | @as(c_int, 0x0200);
+pub const BIO_TYPE_DESCRIPTOR = @as(c_int, 0x0100);
+pub const BIO_TYPE_FILTER = @as(c_int, 0x0200);
+pub const BIO_TYPE_SOURCE_SINK = @as(c_int, 0x0400);
+pub const BIO_TYPE_START = @as(c_int, 128);
+pub const BIO_C_SET_CONNECT = @as(c_int, 100);
+pub const BIO_C_DO_STATE_MACHINE = @as(c_int, 101);
+pub const BIO_C_SET_NBIO = @as(c_int, 102);
+pub const BIO_C_SET_PROXY_PARAM = @as(c_int, 103);
+pub const BIO_C_SET_FD = @as(c_int, 104);
+pub const BIO_C_GET_FD = @as(c_int, 105);
+pub const BIO_C_SET_FILE_PTR = @as(c_int, 106);
+pub const BIO_C_GET_FILE_PTR = @as(c_int, 107);
+pub const BIO_C_SET_FILENAME = @as(c_int, 108);
+pub const BIO_C_SET_SSL = @as(c_int, 109);
+pub const BIO_C_GET_SSL = @as(c_int, 110);
+pub const BIO_C_SET_MD = @as(c_int, 111);
+pub const BIO_C_GET_MD = @as(c_int, 112);
+pub const BIO_C_GET_CIPHER_STATUS = @as(c_int, 113);
+pub const BIO_C_SET_BUF_MEM = @as(c_int, 114);
+pub const BIO_C_GET_BUF_MEM_PTR = @as(c_int, 115);
+pub const BIO_C_GET_BUFF_NUM_LINES = @as(c_int, 116);
+pub const BIO_C_SET_BUFF_SIZE = @as(c_int, 117);
+pub const BIO_C_SET_ACCEPT = @as(c_int, 118);
+pub const BIO_C_SSL_MODE = @as(c_int, 119);
+pub const BIO_C_GET_MD_CTX = @as(c_int, 120);
+pub const BIO_C_GET_PROXY_PARAM = @as(c_int, 121);
+pub const BIO_C_SET_BUFF_READ_DATA = @as(c_int, 122);
+pub const BIO_C_GET_ACCEPT = @as(c_int, 124);
+pub const BIO_C_SET_SSL_RENEGOTIATE_BYTES = @as(c_int, 125);
+pub const BIO_C_GET_SSL_NUM_RENEGOTIATES = @as(c_int, 126);
+pub const BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT = @as(c_int, 127);
+pub const BIO_C_FILE_SEEK = @as(c_int, 128);
+pub const BIO_C_GET_CIPHER_CTX = @as(c_int, 129);
+pub const BIO_C_SET_BUF_MEM_EOF_RETURN = @as(c_int, 130);
+pub const BIO_C_SET_BIND_MODE = @as(c_int, 131);
+pub const BIO_C_GET_BIND_MODE = @as(c_int, 132);
+pub const BIO_C_FILE_TELL = @as(c_int, 133);
+pub const BIO_C_GET_SOCKS = @as(c_int, 134);
+pub const BIO_C_SET_SOCKS = @as(c_int, 135);
+pub const BIO_C_SET_WRITE_BUF_SIZE = @as(c_int, 136);
+pub const BIO_C_GET_WRITE_BUF_SIZE = @as(c_int, 137);
+pub const BIO_C_GET_WRITE_GUARANTEE = @as(c_int, 140);
+pub const BIO_C_GET_READ_REQUEST = @as(c_int, 141);
+pub const BIO_C_SHUTDOWN_WR = @as(c_int, 142);
+pub const BIO_C_NREAD0 = @as(c_int, 143);
+pub const BIO_C_NREAD = @as(c_int, 144);
+pub const BIO_C_NWRITE0 = @as(c_int, 145);
+pub const BIO_C_NWRITE = @as(c_int, 146);
+pub const BIO_C_RESET_READ_REQUEST = @as(c_int, 147);
+pub const BIO_C_SET_MD_CTX = @as(c_int, 148);
+pub const BIO_C_SET_PREFIX = @as(c_int, 149);
+pub const BIO_C_GET_PREFIX = @as(c_int, 150);
+pub const BIO_C_SET_SUFFIX = @as(c_int, 151);
+pub const BIO_C_GET_SUFFIX = @as(c_int, 152);
+pub const BIO_C_SET_EX_ARG = @as(c_int, 153);
+pub const BIO_C_GET_EX_ARG = @as(c_int, 154);
+pub const BIO_R_BAD_FOPEN_MODE = @as(c_int, 100);
+pub const BIO_R_BROKEN_PIPE = @as(c_int, 101);
+pub const BIO_R_CONNECT_ERROR = @as(c_int, 102);
+pub const BIO_R_ERROR_SETTING_NBIO = @as(c_int, 103);
+pub const BIO_R_INVALID_ARGUMENT = @as(c_int, 104);
+pub const BIO_R_IN_USE = @as(c_int, 105);
+pub const BIO_R_KEEPALIVE = @as(c_int, 106);
+pub const BIO_R_NBIO_CONNECT_ERROR = @as(c_int, 107);
+pub const BIO_R_NO_HOSTNAME_SPECIFIED = @as(c_int, 108);
+pub const BIO_R_NO_PORT_SPECIFIED = @as(c_int, 109);
+pub const BIO_R_NO_SUCH_FILE = @as(c_int, 110);
+pub const BIO_R_NULL_PARAMETER = @as(c_int, 111);
+pub const BIO_R_SYS_LIB = @as(c_int, 112);
+pub const BIO_R_UNABLE_TO_CREATE_SOCKET = @as(c_int, 113);
+pub const BIO_R_UNINITIALIZED = @as(c_int, 114);
+pub const BIO_R_UNSUPPORTED_METHOD = @as(c_int, 115);
+pub const BIO_R_WRITE_TO_READ_ONLY_BIO = @as(c_int, 116);
+pub const EVP_CIPH_STREAM_CIPHER = @as(c_int, 0x0);
+pub const EVP_CIPH_ECB_MODE = @as(c_int, 0x1);
+pub const EVP_CIPH_CBC_MODE = @as(c_int, 0x2);
+pub const EVP_CIPH_CFB_MODE = @as(c_int, 0x3);
+pub const EVP_CIPH_OFB_MODE = @as(c_int, 0x4);
+pub const EVP_CIPH_CTR_MODE = @as(c_int, 0x5);
+pub const EVP_CIPH_GCM_MODE = @as(c_int, 0x6);
+pub const EVP_CIPH_XTS_MODE = @as(c_int, 0x7);
+pub const EVP_CIPH_VARIABLE_LENGTH = @as(c_int, 0x40);
+pub const EVP_CIPH_ALWAYS_CALL_INIT = @as(c_int, 0x80);
+pub const EVP_CIPH_CUSTOM_IV = @as(c_int, 0x100);
+pub const EVP_CIPH_CTRL_INIT = @as(c_int, 0x200);
+pub const EVP_CIPH_FLAG_CUSTOM_CIPHER = @as(c_int, 0x400);
+pub const EVP_CIPH_FLAG_AEAD_CIPHER = @as(c_int, 0x800);
+pub const EVP_CIPH_CUSTOM_COPY = @as(c_int, 0x1000);
+pub const EVP_CIPH_FLAG_NON_FIPS_ALLOW = @as(c_int, 0);
+pub const EVP_CIPH_CCM_MODE = -@as(c_int, 1);
+pub const EVP_CIPH_OCB_MODE = -@as(c_int, 2);
+pub const EVP_CIPH_WRAP_MODE = -@as(c_int, 3);
+pub const EVP_CIPHER_CTX_FLAG_WRAP_ALLOW = @as(c_int, 0);
+pub const EVP_CIPH_NO_PADDING = @as(c_int, 0x800);
+pub const EVP_CTRL_INIT = @as(c_int, 0x0);
+pub const EVP_CTRL_SET_KEY_LENGTH = @as(c_int, 0x1);
+pub const EVP_CTRL_GET_RC2_KEY_BITS = @as(c_int, 0x2);
+pub const EVP_CTRL_SET_RC2_KEY_BITS = @as(c_int, 0x3);
+pub const EVP_CTRL_GET_RC5_ROUNDS = @as(c_int, 0x4);
+pub const EVP_CTRL_SET_RC5_ROUNDS = @as(c_int, 0x5);
+pub const EVP_CTRL_RAND_KEY = @as(c_int, 0x6);
+pub const EVP_CTRL_PBE_PRF_NID = @as(c_int, 0x7);
+pub const EVP_CTRL_COPY = @as(c_int, 0x8);
+pub const EVP_CTRL_AEAD_SET_IVLEN = @as(c_int, 0x9);
+pub const EVP_CTRL_AEAD_GET_TAG = @as(c_int, 0x10);
+pub const EVP_CTRL_AEAD_SET_TAG = @as(c_int, 0x11);
+pub const EVP_CTRL_AEAD_SET_IV_FIXED = @as(c_int, 0x12);
+pub const EVP_CTRL_GCM_IV_GEN = @as(c_int, 0x13);
+pub const EVP_CTRL_AEAD_SET_MAC_KEY = @as(c_int, 0x17);
+pub const EVP_CTRL_GCM_SET_IV_INV = @as(c_int, 0x18);
+pub const EVP_GCM_TLS_FIXED_IV_LEN = @as(c_int, 4);
+pub const EVP_GCM_TLS_EXPLICIT_IV_LEN = @as(c_int, 8);
+pub const EVP_GCM_TLS_TAG_LEN = @as(c_int, 16);
+pub const EVP_CTRL_GCM_SET_IVLEN = EVP_CTRL_AEAD_SET_IVLEN;
+pub const EVP_CTRL_GCM_GET_TAG = EVP_CTRL_AEAD_GET_TAG;
+pub const EVP_CTRL_GCM_SET_TAG = EVP_CTRL_AEAD_SET_TAG;
+pub const EVP_CTRL_GCM_SET_IV_FIXED = EVP_CTRL_AEAD_SET_IV_FIXED;
+pub const EVP_MAX_KEY_LENGTH = @as(c_int, 64);
+pub const EVP_MAX_IV_LENGTH = @as(c_int, 16);
+pub const EVP_MAX_BLOCK_LENGTH = @as(c_int, 32);
+pub const CIPHER_R_AES_KEY_SETUP_FAILED = @as(c_int, 100);
+pub const CIPHER_R_BAD_DECRYPT = @as(c_int, 101);
+pub const CIPHER_R_BAD_KEY_LENGTH = @as(c_int, 102);
+pub const CIPHER_R_BUFFER_TOO_SMALL = @as(c_int, 103);
+pub const CIPHER_R_CTRL_NOT_IMPLEMENTED = @as(c_int, 104);
+pub const CIPHER_R_CTRL_OPERATION_NOT_IMPLEMENTED = @as(c_int, 105);
+pub const CIPHER_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH = @as(c_int, 106);
+pub const CIPHER_R_INITIALIZATION_ERROR = @as(c_int, 107);
+pub const CIPHER_R_INPUT_NOT_INITIALIZED = @as(c_int, 108);
+pub const CIPHER_R_INVALID_AD_SIZE = @as(c_int, 109);
+pub const CIPHER_R_INVALID_KEY_LENGTH = @as(c_int, 110);
+pub const CIPHER_R_INVALID_NONCE_SIZE = @as(c_int, 111);
+pub const CIPHER_R_INVALID_OPERATION = @as(c_int, 112);
+pub const CIPHER_R_IV_TOO_LARGE = @as(c_int, 113);
+pub const CIPHER_R_NO_CIPHER_SET = @as(c_int, 114);
+pub const CIPHER_R_OUTPUT_ALIASES_INPUT = @as(c_int, 115);
+pub const CIPHER_R_TAG_TOO_LARGE = @as(c_int, 116);
+pub const CIPHER_R_TOO_LARGE = @as(c_int, 117);
+pub const CIPHER_R_UNSUPPORTED_AD_SIZE = @as(c_int, 118);
+pub const CIPHER_R_UNSUPPORTED_INPUT_SIZE = @as(c_int, 119);
+pub const CIPHER_R_UNSUPPORTED_KEY_SIZE = @as(c_int, 120);
+pub const CIPHER_R_UNSUPPORTED_NONCE_SIZE = @as(c_int, 121);
+pub const CIPHER_R_UNSUPPORTED_TAG_SIZE = @as(c_int, 122);
+pub const CIPHER_R_WRONG_FINAL_BLOCK_LENGTH = @as(c_int, 123);
+pub const CIPHER_R_NO_DIRECTION_SET = @as(c_int, 124);
+pub const CIPHER_R_INVALID_NONCE = @as(c_int, 125);
+pub const EVP_MAX_MD_SIZE = @as(c_int, 64);
+pub const EVP_MAX_MD_BLOCK_SIZE = @as(c_int, 128);
+pub const EVP_MD_FLAG_PKEY_DIGEST = @as(c_int, 1);
+pub const EVP_MD_FLAG_DIGALGID_ABSENT = @as(c_int, 2);
+pub const EVP_MD_FLAG_XOF = @as(c_int, 4);
+pub const EVP_MD_CTX_FLAG_NON_FIPS_ALLOW = @as(c_int, 0);
+pub const DIGEST_R_INPUT_NOT_INITIALIZED = @as(c_int, 100);
+pub const DIGEST_R_DECODE_ERROR = @as(c_int, 101);
+pub const DIGEST_R_UNKNOWN_HASH = @as(c_int, 102);
+pub const EVP_R_BUFFER_TOO_SMALL = @as(c_int, 100);
+pub const EVP_R_COMMAND_NOT_SUPPORTED = @as(c_int, 101);
+pub const EVP_R_DECODE_ERROR = @as(c_int, 102);
+pub const EVP_R_DIFFERENT_KEY_TYPES = @as(c_int, 103);
+pub const EVP_R_DIFFERENT_PARAMETERS = @as(c_int, 104);
+pub const EVP_R_ENCODE_ERROR = @as(c_int, 105);
+pub const EVP_R_EXPECTING_AN_EC_KEY_KEY = @as(c_int, 106);
+pub const EVP_R_EXPECTING_AN_RSA_KEY = @as(c_int, 107);
+pub const EVP_R_EXPECTING_A_DSA_KEY = @as(c_int, 108);
+pub const EVP_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE = @as(c_int, 109);
+pub const EVP_R_INVALID_DIGEST_LENGTH = @as(c_int, 110);
+pub const EVP_R_INVALID_DIGEST_TYPE = @as(c_int, 111);
+pub const EVP_R_INVALID_KEYBITS = @as(c_int, 112);
+pub const EVP_R_INVALID_MGF1_MD = @as(c_int, 113);
+pub const EVP_R_INVALID_OPERATION = @as(c_int, 114);
+pub const EVP_R_INVALID_PADDING_MODE = @as(c_int, 115);
+pub const EVP_R_INVALID_PSS_SALTLEN = @as(c_int, 116);
+pub const EVP_R_KEYS_NOT_SET = @as(c_int, 117);
+pub const EVP_R_MISSING_PARAMETERS = @as(c_int, 118);
+pub const EVP_R_NO_DEFAULT_DIGEST = @as(c_int, 119);
+pub const EVP_R_NO_KEY_SET = @as(c_int, 120);
+pub const EVP_R_NO_MDC2_SUPPORT = @as(c_int, 121);
+pub const EVP_R_NO_NID_FOR_CURVE = @as(c_int, 122);
+pub const EVP_R_NO_OPERATION_SET = @as(c_int, 123);
+pub const EVP_R_NO_PARAMETERS_SET = @as(c_int, 124);
+pub const EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE = @as(c_int, 125);
+pub const EVP_R_OPERATON_NOT_INITIALIZED = @as(c_int, 126);
+pub const EVP_R_UNKNOWN_PUBLIC_KEY_TYPE = @as(c_int, 127);
+pub const EVP_R_UNSUPPORTED_ALGORITHM = @as(c_int, 128);
+pub const EVP_R_UNSUPPORTED_PUBLIC_KEY_TYPE = @as(c_int, 129);
+pub const EVP_R_NOT_A_PRIVATE_KEY = @as(c_int, 130);
+pub const EVP_R_INVALID_SIGNATURE = @as(c_int, 131);
+pub const EVP_R_MEMORY_LIMIT_EXCEEDED = @as(c_int, 132);
+pub const EVP_R_INVALID_PARAMETERS = @as(c_int, 133);
+pub const EVP_R_INVALID_PEER_KEY = @as(c_int, 134);
+pub const EVP_R_NOT_XOF_OR_INVALID_LENGTH = @as(c_int, 135);
+pub const EVP_R_EMPTY_PSK = @as(c_int, 136);
+pub const EVP_R_INVALID_BUFFER_SIZE = @as(c_int, 137);
+pub const EVP_AEAD_MAX_KEY_LENGTH = @as(c_int, 80);
+pub const EVP_AEAD_MAX_NONCE_LENGTH = @as(c_int, 24);
+pub const EVP_AEAD_MAX_OVERHEAD = @as(c_int, 64);
+pub const EVP_AEAD_DEFAULT_TAG_LENGTH = @as(c_int, 0);
+pub const SN_undef = "UNDEF";
+pub const LN_undef = "undefined";
+pub const NID_undef = @as(c_int, 0);
+pub const OBJ_undef = @as(c_long, 0);
+pub const SN_rsadsi = "rsadsi";
+pub const LN_rsadsi = "RSA Data Security, Inc.";
+pub const NID_rsadsi = @as(c_int, 1);
+pub const OBJ_rsadsi = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ break :blk @as(c_long, 113549);
+};
+pub const SN_pkcs = "pkcs";
+pub const LN_pkcs = "RSA Data Security, Inc. PKCS";
+pub const NID_pkcs = @as(c_int, 2);
+pub const OBJ_pkcs = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ break :blk @as(c_long, 1);
+};
+pub const SN_md2 = "MD2";
+pub const LN_md2 = "md2";
+pub const NID_md2 = @as(c_int, 3);
+pub const OBJ_md2 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 2);
+};
+pub const SN_md5 = "MD5";
+pub const LN_md5 = "md5";
+pub const NID_md5 = @as(c_int, 4);
+pub const OBJ_md5 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 5);
+};
+pub const SN_rc4 = "RC4";
+pub const LN_rc4 = "rc4";
+pub const NID_rc4 = @as(c_int, 5);
+pub const OBJ_rc4 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 4);
+};
+pub const LN_rsaEncryption = "rsaEncryption";
+pub const NID_rsaEncryption = @as(c_int, 6);
+pub const OBJ_rsaEncryption = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 1);
+};
+pub const SN_md2WithRSAEncryption = "RSA-MD2";
+pub const LN_md2WithRSAEncryption = "md2WithRSAEncryption";
+pub const NID_md2WithRSAEncryption = @as(c_int, 7);
+pub const OBJ_md2WithRSAEncryption = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 2);
+};
+pub const SN_md5WithRSAEncryption = "RSA-MD5";
+pub const LN_md5WithRSAEncryption = "md5WithRSAEncryption";
+pub const NID_md5WithRSAEncryption = @as(c_int, 8);
+pub const OBJ_md5WithRSAEncryption = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 4);
+};
+pub const SN_pbeWithMD2AndDES_CBC = "PBE-MD2-DES";
+pub const LN_pbeWithMD2AndDES_CBC = "pbeWithMD2AndDES-CBC";
+pub const NID_pbeWithMD2AndDES_CBC = @as(c_int, 9);
+pub const OBJ_pbeWithMD2AndDES_CBC = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ break :blk @as(c_long, 1);
+};
+pub const SN_pbeWithMD5AndDES_CBC = "PBE-MD5-DES";
+pub const LN_pbeWithMD5AndDES_CBC = "pbeWithMD5AndDES-CBC";
+pub const NID_pbeWithMD5AndDES_CBC = @as(c_int, 10);
+pub const OBJ_pbeWithMD5AndDES_CBC = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ break :blk @as(c_long, 3);
+};
+pub const SN_X500 = "X500";
+pub const LN_X500 = "directory services (X.500)";
+pub const NID_X500 = @as(c_int, 11);
+pub const OBJ_X500 = blk: {
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 5);
+};
+pub const SN_X509 = "X509";
+pub const NID_X509 = @as(c_int, 12);
+pub const OBJ_X509 = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ break :blk @as(c_long, 4);
+};
+pub const SN_commonName = "CN";
+pub const LN_commonName = "commonName";
+pub const NID_commonName = @as(c_int, 13);
+pub const OBJ_commonName = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 3);
+};
+pub const SN_countryName = "C";
+pub const LN_countryName = "countryName";
+pub const NID_countryName = @as(c_int, 14);
+pub const OBJ_countryName = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 6);
+};
+pub const SN_localityName = "L";
+pub const LN_localityName = "localityName";
+pub const NID_localityName = @as(c_int, 15);
+pub const OBJ_localityName = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 7);
+};
+pub const SN_stateOrProvinceName = "ST";
+pub const LN_stateOrProvinceName = "stateOrProvinceName";
+pub const NID_stateOrProvinceName = @as(c_int, 16);
+pub const OBJ_stateOrProvinceName = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 8);
+};
+pub const SN_organizationName = "O";
+pub const LN_organizationName = "organizationName";
+pub const NID_organizationName = @as(c_int, 17);
+pub const OBJ_organizationName = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 10);
+};
+pub const SN_organizationalUnitName = "OU";
+pub const LN_organizationalUnitName = "organizationalUnitName";
+pub const NID_organizationalUnitName = @as(c_int, 18);
+pub const OBJ_organizationalUnitName = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 11);
+};
+pub const SN_rsa = "RSA";
+pub const LN_rsa = "rsa";
+pub const NID_rsa = @as(c_int, 19);
+pub const OBJ_rsa = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 8);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 1);
+};
+pub const SN_pkcs7 = "pkcs7";
+pub const NID_pkcs7 = @as(c_int, 20);
+pub const OBJ_pkcs7 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 7);
+};
+pub const LN_pkcs7_data = "pkcs7-data";
+pub const NID_pkcs7_data = @as(c_int, 21);
+pub const OBJ_pkcs7_data = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 1);
+};
+pub const LN_pkcs7_signed = "pkcs7-signedData";
+pub const NID_pkcs7_signed = @as(c_int, 22);
+pub const OBJ_pkcs7_signed = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 2);
+};
+pub const LN_pkcs7_enveloped = "pkcs7-envelopedData";
+pub const NID_pkcs7_enveloped = @as(c_int, 23);
+pub const OBJ_pkcs7_enveloped = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 3);
+};
+pub const LN_pkcs7_signedAndEnveloped = "pkcs7-signedAndEnvelopedData";
+pub const NID_pkcs7_signedAndEnveloped = @as(c_int, 24);
+pub const OBJ_pkcs7_signedAndEnveloped = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 4);
+};
+pub const LN_pkcs7_digest = "pkcs7-digestData";
+pub const NID_pkcs7_digest = @as(c_int, 25);
+pub const OBJ_pkcs7_digest = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 5);
+};
+pub const LN_pkcs7_encrypted = "pkcs7-encryptedData";
+pub const NID_pkcs7_encrypted = @as(c_int, 26);
+pub const OBJ_pkcs7_encrypted = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 6);
+};
+pub const SN_pkcs3 = "pkcs3";
+pub const NID_pkcs3 = @as(c_int, 27);
+pub const OBJ_pkcs3 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 3);
+};
+pub const LN_dhKeyAgreement = "dhKeyAgreement";
+pub const NID_dhKeyAgreement = @as(c_int, 28);
+pub const OBJ_dhKeyAgreement = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 1);
+};
+pub const SN_des_ecb = "DES-ECB";
+pub const LN_des_ecb = "des-ecb";
+pub const NID_des_ecb = @as(c_int, 29);
+pub const OBJ_des_ecb = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 14);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 6);
+};
+pub const SN_des_cfb64 = "DES-CFB";
+pub const LN_des_cfb64 = "des-cfb";
+pub const NID_des_cfb64 = @as(c_int, 30);
+pub const OBJ_des_cfb64 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 14);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 9);
+};
+pub const SN_des_cbc = "DES-CBC";
+pub const LN_des_cbc = "des-cbc";
+pub const NID_des_cbc = @as(c_int, 31);
+pub const OBJ_des_cbc = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 14);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 7);
+};
+pub const SN_des_ede_ecb = "DES-EDE";
+pub const LN_des_ede_ecb = "des-ede";
+pub const NID_des_ede_ecb = @as(c_int, 32);
+pub const OBJ_des_ede_ecb = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 14);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 17);
+};
+pub const SN_des_ede3_ecb = "DES-EDE3";
+pub const LN_des_ede3_ecb = "des-ede3";
+pub const NID_des_ede3_ecb = @as(c_int, 33);
+pub const SN_idea_cbc = "IDEA-CBC";
+pub const LN_idea_cbc = "idea-cbc";
+pub const NID_idea_cbc = @as(c_int, 34);
+pub const OBJ_idea_cbc = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 188);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 2);
+};
+pub const SN_idea_cfb64 = "IDEA-CFB";
+pub const LN_idea_cfb64 = "idea-cfb";
+pub const NID_idea_cfb64 = @as(c_int, 35);
+pub const SN_idea_ecb = "IDEA-ECB";
+pub const LN_idea_ecb = "idea-ecb";
+pub const NID_idea_ecb = @as(c_int, 36);
+pub const SN_rc2_cbc = "RC2-CBC";
+pub const LN_rc2_cbc = "rc2-cbc";
+pub const NID_rc2_cbc = @as(c_int, 37);
+pub const OBJ_rc2_cbc = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 2);
+};
+pub const SN_rc2_ecb = "RC2-ECB";
+pub const LN_rc2_ecb = "rc2-ecb";
+pub const NID_rc2_ecb = @as(c_int, 38);
+pub const SN_rc2_cfb64 = "RC2-CFB";
+pub const LN_rc2_cfb64 = "rc2-cfb";
+pub const NID_rc2_cfb64 = @as(c_int, 39);
+pub const SN_rc2_ofb64 = "RC2-OFB";
+pub const LN_rc2_ofb64 = "rc2-ofb";
+pub const NID_rc2_ofb64 = @as(c_int, 40);
+pub const SN_sha = "SHA";
+pub const LN_sha = "sha";
+pub const NID_sha = @as(c_int, 41);
+pub const OBJ_sha = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 14);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 18);
+};
+pub const SN_shaWithRSAEncryption = "RSA-SHA";
+pub const LN_shaWithRSAEncryption = "shaWithRSAEncryption";
+pub const NID_shaWithRSAEncryption = @as(c_int, 42);
+pub const OBJ_shaWithRSAEncryption = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 14);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 15);
+};
+pub const SN_des_ede_cbc = "DES-EDE-CBC";
+pub const LN_des_ede_cbc = "des-ede-cbc";
+pub const NID_des_ede_cbc = @as(c_int, 43);
+pub const SN_des_ede3_cbc = "DES-EDE3-CBC";
+pub const LN_des_ede3_cbc = "des-ede3-cbc";
+pub const NID_des_ede3_cbc = @as(c_int, 44);
+pub const OBJ_des_ede3_cbc = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 7);
+};
+pub const SN_des_ofb64 = "DES-OFB";
+pub const LN_des_ofb64 = "des-ofb";
+pub const NID_des_ofb64 = @as(c_int, 45);
+pub const OBJ_des_ofb64 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 14);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 8);
+};
+pub const SN_idea_ofb64 = "IDEA-OFB";
+pub const LN_idea_ofb64 = "idea-ofb";
+pub const NID_idea_ofb64 = @as(c_int, 46);
+pub const SN_pkcs9 = "pkcs9";
+pub const NID_pkcs9 = @as(c_int, 47);
+pub const OBJ_pkcs9 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 9);
+};
+pub const LN_pkcs9_emailAddress = "emailAddress";
+pub const NID_pkcs9_emailAddress = @as(c_int, 48);
+pub const OBJ_pkcs9_emailAddress = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ break :blk @as(c_long, 1);
+};
+pub const LN_pkcs9_unstructuredName = "unstructuredName";
+pub const NID_pkcs9_unstructuredName = @as(c_int, 49);
+pub const OBJ_pkcs9_unstructuredName = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ break :blk @as(c_long, 2);
+};
+pub const LN_pkcs9_contentType = "contentType";
+pub const NID_pkcs9_contentType = @as(c_int, 50);
+pub const OBJ_pkcs9_contentType = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ break :blk @as(c_long, 3);
+};
+pub const LN_pkcs9_messageDigest = "messageDigest";
+pub const NID_pkcs9_messageDigest = @as(c_int, 51);
+pub const OBJ_pkcs9_messageDigest = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ break :blk @as(c_long, 4);
+};
+pub const LN_pkcs9_signingTime = "signingTime";
+pub const NID_pkcs9_signingTime = @as(c_int, 52);
+pub const OBJ_pkcs9_signingTime = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ break :blk @as(c_long, 5);
+};
+pub const LN_pkcs9_countersignature = "countersignature";
+pub const NID_pkcs9_countersignature = @as(c_int, 53);
+pub const OBJ_pkcs9_countersignature = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ break :blk @as(c_long, 6);
+};
+pub const LN_pkcs9_challengePassword = "challengePassword";
+pub const NID_pkcs9_challengePassword = @as(c_int, 54);
+pub const OBJ_pkcs9_challengePassword = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ break :blk @as(c_long, 7);
+};
+pub const LN_pkcs9_unstructuredAddress = "unstructuredAddress";
+pub const NID_pkcs9_unstructuredAddress = @as(c_int, 55);
+pub const OBJ_pkcs9_unstructuredAddress = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ break :blk @as(c_long, 8);
+};
+pub const LN_pkcs9_extCertAttributes = "extendedCertificateAttributes";
+pub const NID_pkcs9_extCertAttributes = @as(c_int, 56);
+pub const OBJ_pkcs9_extCertAttributes = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ break :blk @as(c_long, 9);
+};
+pub const SN_netscape = "Netscape";
+pub const LN_netscape = "Netscape Communications Corp.";
+pub const NID_netscape = @as(c_int, 57);
+pub const OBJ_netscape = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 113730);
+};
+pub const SN_netscape_cert_extension = "nsCertExt";
+pub const LN_netscape_cert_extension = "Netscape Certificate Extension";
+pub const NID_netscape_cert_extension = @as(c_int, 58);
+pub const OBJ_netscape_cert_extension = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 113730);
+ break :blk @as(c_long, 1);
+};
+pub const SN_netscape_data_type = "nsDataType";
+pub const LN_netscape_data_type = "Netscape Data Type";
+pub const NID_netscape_data_type = @as(c_int, 59);
+pub const OBJ_netscape_data_type = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 113730);
+ break :blk @as(c_long, 2);
+};
+pub const SN_des_ede_cfb64 = "DES-EDE-CFB";
+pub const LN_des_ede_cfb64 = "des-ede-cfb";
+pub const NID_des_ede_cfb64 = @as(c_int, 60);
+pub const SN_des_ede3_cfb64 = "DES-EDE3-CFB";
+pub const LN_des_ede3_cfb64 = "des-ede3-cfb";
+pub const NID_des_ede3_cfb64 = @as(c_int, 61);
+pub const SN_des_ede_ofb64 = "DES-EDE-OFB";
+pub const LN_des_ede_ofb64 = "des-ede-ofb";
+pub const NID_des_ede_ofb64 = @as(c_int, 62);
+pub const SN_des_ede3_ofb64 = "DES-EDE3-OFB";
+pub const LN_des_ede3_ofb64 = "des-ede3-ofb";
+pub const NID_des_ede3_ofb64 = @as(c_int, 63);
+pub const SN_sha1 = "SHA1";
+pub const LN_sha1 = "sha1";
+pub const NID_sha1 = @as(c_int, 64);
+pub const OBJ_sha1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 14);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 26);
+};
+pub const SN_sha1WithRSAEncryption = "RSA-SHA1";
+pub const LN_sha1WithRSAEncryption = "sha1WithRSAEncryption";
+pub const NID_sha1WithRSAEncryption = @as(c_int, 65);
+pub const OBJ_sha1WithRSAEncryption = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 5);
+};
+pub const SN_dsaWithSHA = "DSA-SHA";
+pub const LN_dsaWithSHA = "dsaWithSHA";
+pub const NID_dsaWithSHA = @as(c_int, 66);
+pub const OBJ_dsaWithSHA = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 14);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 13);
+};
+pub const SN_dsa_2 = "DSA-old";
+pub const LN_dsa_2 = "dsaEncryption-old";
+pub const NID_dsa_2 = @as(c_int, 67);
+pub const OBJ_dsa_2 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 14);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 12);
+};
+pub const SN_pbeWithSHA1AndRC2_CBC = "PBE-SHA1-RC2-64";
+pub const LN_pbeWithSHA1AndRC2_CBC = "pbeWithSHA1AndRC2-CBC";
+pub const NID_pbeWithSHA1AndRC2_CBC = @as(c_int, 68);
+pub const OBJ_pbeWithSHA1AndRC2_CBC = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ break :blk @as(c_long, 11);
+};
+pub const LN_id_pbkdf2 = "PBKDF2";
+pub const NID_id_pbkdf2 = @as(c_int, 69);
+pub const OBJ_id_pbkdf2 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ break :blk @as(c_long, 12);
+};
+pub const SN_dsaWithSHA1_2 = "DSA-SHA1-old";
+pub const LN_dsaWithSHA1_2 = "dsaWithSHA1-old";
+pub const NID_dsaWithSHA1_2 = @as(c_int, 70);
+pub const OBJ_dsaWithSHA1_2 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 14);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 27);
+};
+pub const SN_netscape_cert_type = "nsCertType";
+pub const LN_netscape_cert_type = "Netscape Cert Type";
+pub const NID_netscape_cert_type = @as(c_int, 71);
+pub const OBJ_netscape_cert_type = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 113730);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 1);
+};
+pub const SN_netscape_base_url = "nsBaseUrl";
+pub const LN_netscape_base_url = "Netscape Base Url";
+pub const NID_netscape_base_url = @as(c_int, 72);
+pub const OBJ_netscape_base_url = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 113730);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 2);
+};
+pub const SN_netscape_revocation_url = "nsRevocationUrl";
+pub const LN_netscape_revocation_url = "Netscape Revocation Url";
+pub const NID_netscape_revocation_url = @as(c_int, 73);
+pub const OBJ_netscape_revocation_url = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 113730);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 3);
+};
+pub const SN_netscape_ca_revocation_url = "nsCaRevocationUrl";
+pub const LN_netscape_ca_revocation_url = "Netscape CA Revocation Url";
+pub const NID_netscape_ca_revocation_url = @as(c_int, 74);
+pub const OBJ_netscape_ca_revocation_url = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 113730);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 4);
+};
+pub const SN_netscape_renewal_url = "nsRenewalUrl";
+pub const LN_netscape_renewal_url = "Netscape Renewal Url";
+pub const NID_netscape_renewal_url = @as(c_int, 75);
+pub const OBJ_netscape_renewal_url = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 113730);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 7);
+};
+pub const SN_netscape_ca_policy_url = "nsCaPolicyUrl";
+pub const LN_netscape_ca_policy_url = "Netscape CA Policy Url";
+pub const NID_netscape_ca_policy_url = @as(c_int, 76);
+pub const OBJ_netscape_ca_policy_url = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 113730);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 8);
+};
+pub const SN_netscape_ssl_server_name = "nsSslServerName";
+pub const LN_netscape_ssl_server_name = "Netscape SSL Server Name";
+pub const NID_netscape_ssl_server_name = @as(c_int, 77);
+pub const OBJ_netscape_ssl_server_name = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 113730);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 12);
+};
+pub const SN_netscape_comment = "nsComment";
+pub const LN_netscape_comment = "Netscape Comment";
+pub const NID_netscape_comment = @as(c_int, 78);
+pub const OBJ_netscape_comment = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 113730);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 13);
+};
+pub const SN_netscape_cert_sequence = "nsCertSequence";
+pub const LN_netscape_cert_sequence = "Netscape Certificate Sequence";
+pub const NID_netscape_cert_sequence = @as(c_int, 79);
+pub const OBJ_netscape_cert_sequence = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 113730);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 5);
+};
+pub const SN_desx_cbc = "DESX-CBC";
+pub const LN_desx_cbc = "desx-cbc";
+pub const NID_desx_cbc = @as(c_int, 80);
+pub const SN_id_ce = "id-ce";
+pub const NID_id_ce = @as(c_int, 81);
+pub const OBJ_id_ce = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ break :blk @as(c_long, 29);
+};
+pub const SN_subject_key_identifier = "subjectKeyIdentifier";
+pub const LN_subject_key_identifier = "X509v3 Subject Key Identifier";
+pub const NID_subject_key_identifier = @as(c_int, 82);
+pub const OBJ_subject_key_identifier = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 29);
+ break :blk @as(c_long, 14);
+};
+pub const SN_key_usage = "keyUsage";
+pub const LN_key_usage = "X509v3 Key Usage";
+pub const NID_key_usage = @as(c_int, 83);
+pub const OBJ_key_usage = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 29);
+ break :blk @as(c_long, 15);
+};
+pub const SN_private_key_usage_period = "privateKeyUsagePeriod";
+pub const LN_private_key_usage_period = "X509v3 Private Key Usage Period";
+pub const NID_private_key_usage_period = @as(c_int, 84);
+pub const OBJ_private_key_usage_period = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 29);
+ break :blk @as(c_long, 16);
+};
+pub const SN_subject_alt_name = "subjectAltName";
+pub const LN_subject_alt_name = "X509v3 Subject Alternative Name";
+pub const NID_subject_alt_name = @as(c_int, 85);
+pub const OBJ_subject_alt_name = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 29);
+ break :blk @as(c_long, 17);
+};
+pub const SN_issuer_alt_name = "issuerAltName";
+pub const LN_issuer_alt_name = "X509v3 Issuer Alternative Name";
+pub const NID_issuer_alt_name = @as(c_int, 86);
+pub const OBJ_issuer_alt_name = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 29);
+ break :blk @as(c_long, 18);
+};
+pub const SN_basic_constraints = "basicConstraints";
+pub const LN_basic_constraints = "X509v3 Basic Constraints";
+pub const NID_basic_constraints = @as(c_int, 87);
+pub const OBJ_basic_constraints = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 29);
+ break :blk @as(c_long, 19);
+};
+pub const SN_crl_number = "crlNumber";
+pub const LN_crl_number = "X509v3 CRL Number";
+pub const NID_crl_number = @as(c_int, 88);
+pub const OBJ_crl_number = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 29);
+ break :blk @as(c_long, 20);
+};
+pub const SN_certificate_policies = "certificatePolicies";
+pub const LN_certificate_policies = "X509v3 Certificate Policies";
+pub const NID_certificate_policies = @as(c_int, 89);
+pub const OBJ_certificate_policies = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 29);
+ break :blk @as(c_long, 32);
+};
+pub const SN_authority_key_identifier = "authorityKeyIdentifier";
+pub const LN_authority_key_identifier = "X509v3 Authority Key Identifier";
+pub const NID_authority_key_identifier = @as(c_int, 90);
+pub const OBJ_authority_key_identifier = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 29);
+ break :blk @as(c_long, 35);
+};
+pub const SN_bf_cbc = "BF-CBC";
+pub const LN_bf_cbc = "bf-cbc";
+pub const NID_bf_cbc = @as(c_int, 91);
+pub const OBJ_bf_cbc = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3029);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 2);
+};
+pub const SN_bf_ecb = "BF-ECB";
+pub const LN_bf_ecb = "bf-ecb";
+pub const NID_bf_ecb = @as(c_int, 92);
+pub const SN_bf_cfb64 = "BF-CFB";
+pub const LN_bf_cfb64 = "bf-cfb";
+pub const NID_bf_cfb64 = @as(c_int, 93);
+pub const SN_bf_ofb64 = "BF-OFB";
+pub const LN_bf_ofb64 = "bf-ofb";
+pub const NID_bf_ofb64 = @as(c_int, 94);
+pub const SN_mdc2 = "MDC2";
+pub const LN_mdc2 = "mdc2";
+pub const NID_mdc2 = @as(c_int, 95);
+pub const OBJ_mdc2 = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 8);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 101);
+};
+pub const SN_mdc2WithRSA = "RSA-MDC2";
+pub const LN_mdc2WithRSA = "mdc2WithRSA";
+pub const NID_mdc2WithRSA = @as(c_int, 96);
+pub const OBJ_mdc2WithRSA = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 8);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 100);
+};
+pub const SN_rc4_40 = "RC4-40";
+pub const LN_rc4_40 = "rc4-40";
+pub const NID_rc4_40 = @as(c_int, 97);
+pub const SN_rc2_40_cbc = "RC2-40-CBC";
+pub const LN_rc2_40_cbc = "rc2-40-cbc";
+pub const NID_rc2_40_cbc = @as(c_int, 98);
+pub const SN_givenName = "GN";
+pub const LN_givenName = "givenName";
+pub const NID_givenName = @as(c_int, 99);
+pub const OBJ_givenName = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 42);
+};
+pub const SN_surname = "SN";
+pub const LN_surname = "surname";
+pub const NID_surname = @as(c_int, 100);
+pub const OBJ_surname = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 4);
+};
+pub const SN_initials = "initials";
+pub const LN_initials = "initials";
+pub const NID_initials = @as(c_int, 101);
+pub const OBJ_initials = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 43);
+};
+pub const SN_crl_distribution_points = "crlDistributionPoints";
+pub const LN_crl_distribution_points = "X509v3 CRL Distribution Points";
+pub const NID_crl_distribution_points = @as(c_int, 103);
+pub const OBJ_crl_distribution_points = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 29);
+ break :blk @as(c_long, 31);
+};
+pub const SN_md5WithRSA = "RSA-NP-MD5";
+pub const LN_md5WithRSA = "md5WithRSA";
+pub const NID_md5WithRSA = @as(c_int, 104);
+pub const OBJ_md5WithRSA = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 14);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 3);
+};
+pub const LN_serialNumber = "serialNumber";
+pub const NID_serialNumber = @as(c_int, 105);
+pub const OBJ_serialNumber = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 5);
+};
+pub const SN_title = "title";
+pub const LN_title = "title";
+pub const NID_title = @as(c_int, 106);
+pub const OBJ_title = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 12);
+};
+pub const LN_description = "description";
+pub const NID_description = @as(c_int, 107);
+pub const OBJ_description = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 13);
+};
+pub const SN_cast5_cbc = "CAST5-CBC";
+pub const LN_cast5_cbc = "cast5-cbc";
+pub const NID_cast5_cbc = @as(c_int, 108);
+pub const OBJ_cast5_cbc = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113533);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 66);
+ break :blk @as(c_long, 10);
+};
+pub const SN_cast5_ecb = "CAST5-ECB";
+pub const LN_cast5_ecb = "cast5-ecb";
+pub const NID_cast5_ecb = @as(c_int, 109);
+pub const SN_cast5_cfb64 = "CAST5-CFB";
+pub const LN_cast5_cfb64 = "cast5-cfb";
+pub const NID_cast5_cfb64 = @as(c_int, 110);
+pub const SN_cast5_ofb64 = "CAST5-OFB";
+pub const LN_cast5_ofb64 = "cast5-ofb";
+pub const NID_cast5_ofb64 = @as(c_int, 111);
+pub const LN_pbeWithMD5AndCast5_CBC = "pbeWithMD5AndCast5CBC";
+pub const NID_pbeWithMD5AndCast5_CBC = @as(c_int, 112);
+pub const OBJ_pbeWithMD5AndCast5_CBC = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113533);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 66);
+ break :blk @as(c_long, 12);
+};
+pub const SN_dsaWithSHA1 = "DSA-SHA1";
+pub const LN_dsaWithSHA1 = "dsaWithSHA1";
+pub const NID_dsaWithSHA1 = @as(c_int, 113);
+pub const OBJ_dsaWithSHA1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10040);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 3);
+};
+pub const SN_md5_sha1 = "MD5-SHA1";
+pub const LN_md5_sha1 = "md5-sha1";
+pub const NID_md5_sha1 = @as(c_int, 114);
+pub const SN_sha1WithRSA = "RSA-SHA1-2";
+pub const LN_sha1WithRSA = "sha1WithRSA";
+pub const NID_sha1WithRSA = @as(c_int, 115);
+pub const OBJ_sha1WithRSA = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 14);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 29);
+};
+pub const SN_dsa = "DSA";
+pub const LN_dsa = "dsaEncryption";
+pub const NID_dsa = @as(c_int, 116);
+pub const OBJ_dsa = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10040);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 1);
+};
+pub const SN_ripemd160 = "RIPEMD160";
+pub const LN_ripemd160 = "ripemd160";
+pub const NID_ripemd160 = @as(c_int, 117);
+pub const OBJ_ripemd160 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 36);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 1);
+};
+pub const SN_ripemd160WithRSA = "RSA-RIPEMD160";
+pub const LN_ripemd160WithRSA = "ripemd160WithRSA";
+pub const NID_ripemd160WithRSA = @as(c_int, 119);
+pub const OBJ_ripemd160WithRSA = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 36);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 2);
+};
+pub const SN_rc5_cbc = "RC5-CBC";
+pub const LN_rc5_cbc = "rc5-cbc";
+pub const NID_rc5_cbc = @as(c_int, 120);
+pub const OBJ_rc5_cbc = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 8);
+};
+pub const SN_rc5_ecb = "RC5-ECB";
+pub const LN_rc5_ecb = "rc5-ecb";
+pub const NID_rc5_ecb = @as(c_int, 121);
+pub const SN_rc5_cfb64 = "RC5-CFB";
+pub const LN_rc5_cfb64 = "rc5-cfb";
+pub const NID_rc5_cfb64 = @as(c_int, 122);
+pub const SN_rc5_ofb64 = "RC5-OFB";
+pub const LN_rc5_ofb64 = "rc5-ofb";
+pub const NID_rc5_ofb64 = @as(c_int, 123);
+pub const SN_zlib_compression = "ZLIB";
+pub const LN_zlib_compression = "zlib compression";
+pub const NID_zlib_compression = @as(c_int, 125);
+pub const OBJ_zlib_compression = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 8);
+};
+pub const SN_ext_key_usage = "extendedKeyUsage";
+pub const LN_ext_key_usage = "X509v3 Extended Key Usage";
+pub const NID_ext_key_usage = @as(c_int, 126);
+pub const OBJ_ext_key_usage = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 29);
+ break :blk @as(c_long, 37);
+};
+pub const SN_id_pkix = "PKIX";
+pub const NID_id_pkix = @as(c_int, 127);
+pub const OBJ_id_pkix = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ break :blk @as(c_long, 7);
+};
+pub const SN_id_kp = "id-kp";
+pub const NID_id_kp = @as(c_int, 128);
+pub const OBJ_id_kp = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 3);
+};
+pub const SN_server_auth = "serverAuth";
+pub const LN_server_auth = "TLS Web Server Authentication";
+pub const NID_server_auth = @as(c_int, 129);
+pub const OBJ_server_auth = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 1);
+};
+pub const SN_client_auth = "clientAuth";
+pub const LN_client_auth = "TLS Web Client Authentication";
+pub const NID_client_auth = @as(c_int, 130);
+pub const OBJ_client_auth = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 2);
+};
+pub const SN_code_sign = "codeSigning";
+pub const LN_code_sign = "Code Signing";
+pub const NID_code_sign = @as(c_int, 131);
+pub const OBJ_code_sign = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 3);
+};
+pub const SN_email_protect = "emailProtection";
+pub const LN_email_protect = "E-mail Protection";
+pub const NID_email_protect = @as(c_int, 132);
+pub const OBJ_email_protect = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 4);
+};
+pub const SN_time_stamp = "timeStamping";
+pub const LN_time_stamp = "Time Stamping";
+pub const NID_time_stamp = @as(c_int, 133);
+pub const OBJ_time_stamp = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 8);
+};
+pub const SN_ms_code_ind = "msCodeInd";
+pub const LN_ms_code_ind = "Microsoft Individual Code Signing";
+pub const NID_ms_code_ind = @as(c_int, 134);
+pub const OBJ_ms_code_ind = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 311);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 21);
+};
+pub const SN_ms_code_com = "msCodeCom";
+pub const LN_ms_code_com = "Microsoft Commercial Code Signing";
+pub const NID_ms_code_com = @as(c_int, 135);
+pub const OBJ_ms_code_com = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 311);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 22);
+};
+pub const SN_ms_ctl_sign = "msCTLSign";
+pub const LN_ms_ctl_sign = "Microsoft Trust List Signing";
+pub const NID_ms_ctl_sign = @as(c_int, 136);
+pub const OBJ_ms_ctl_sign = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 311);
+ _ = @as(c_long, 10);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 1);
+};
+pub const SN_ms_sgc = "msSGC";
+pub const LN_ms_sgc = "Microsoft Server Gated Crypto";
+pub const NID_ms_sgc = @as(c_int, 137);
+pub const OBJ_ms_sgc = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 311);
+ _ = @as(c_long, 10);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 3);
+};
+pub const SN_ms_efs = "msEFS";
+pub const LN_ms_efs = "Microsoft Encrypted File System";
+pub const NID_ms_efs = @as(c_int, 138);
+pub const OBJ_ms_efs = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 311);
+ _ = @as(c_long, 10);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 4);
+};
+pub const SN_ns_sgc = "nsSGC";
+pub const LN_ns_sgc = "Netscape Server Gated Crypto";
+pub const NID_ns_sgc = @as(c_int, 139);
+pub const OBJ_ns_sgc = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 113730);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 1);
+};
+pub const SN_delta_crl = "deltaCRL";
+pub const LN_delta_crl = "X509v3 Delta CRL Indicator";
+pub const NID_delta_crl = @as(c_int, 140);
+pub const OBJ_delta_crl = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 29);
+ break :blk @as(c_long, 27);
+};
+pub const SN_crl_reason = "CRLReason";
+pub const LN_crl_reason = "X509v3 CRL Reason Code";
+pub const NID_crl_reason = @as(c_int, 141);
+pub const OBJ_crl_reason = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 29);
+ break :blk @as(c_long, 21);
+};
+pub const SN_invalidity_date = "invalidityDate";
+pub const LN_invalidity_date = "Invalidity Date";
+pub const NID_invalidity_date = @as(c_int, 142);
+pub const OBJ_invalidity_date = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 29);
+ break :blk @as(c_long, 24);
+};
+pub const SN_sxnet = "SXNetID";
+pub const LN_sxnet = "Strong Extranet ID";
+pub const NID_sxnet = @as(c_int, 143);
+pub const OBJ_sxnet = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 1);
+};
+pub const SN_pbe_WithSHA1And128BitRC4 = "PBE-SHA1-RC4-128";
+pub const LN_pbe_WithSHA1And128BitRC4 = "pbeWithSHA1And128BitRC4";
+pub const NID_pbe_WithSHA1And128BitRC4 = @as(c_int, 144);
+pub const OBJ_pbe_WithSHA1And128BitRC4 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 12);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 1);
+};
+pub const SN_pbe_WithSHA1And40BitRC4 = "PBE-SHA1-RC4-40";
+pub const LN_pbe_WithSHA1And40BitRC4 = "pbeWithSHA1And40BitRC4";
+pub const NID_pbe_WithSHA1And40BitRC4 = @as(c_int, 145);
+pub const OBJ_pbe_WithSHA1And40BitRC4 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 12);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 2);
+};
+pub const SN_pbe_WithSHA1And3_Key_TripleDES_CBC = "PBE-SHA1-3DES";
+pub const LN_pbe_WithSHA1And3_Key_TripleDES_CBC = "pbeWithSHA1And3-KeyTripleDES-CBC";
+pub const NID_pbe_WithSHA1And3_Key_TripleDES_CBC = @as(c_int, 146);
+pub const OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 12);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 3);
+};
+pub const SN_pbe_WithSHA1And2_Key_TripleDES_CBC = "PBE-SHA1-2DES";
+pub const LN_pbe_WithSHA1And2_Key_TripleDES_CBC = "pbeWithSHA1And2-KeyTripleDES-CBC";
+pub const NID_pbe_WithSHA1And2_Key_TripleDES_CBC = @as(c_int, 147);
+pub const OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 12);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 4);
+};
+pub const SN_pbe_WithSHA1And128BitRC2_CBC = "PBE-SHA1-RC2-128";
+pub const LN_pbe_WithSHA1And128BitRC2_CBC = "pbeWithSHA1And128BitRC2-CBC";
+pub const NID_pbe_WithSHA1And128BitRC2_CBC = @as(c_int, 148);
+pub const OBJ_pbe_WithSHA1And128BitRC2_CBC = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 12);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 5);
+};
+pub const SN_pbe_WithSHA1And40BitRC2_CBC = "PBE-SHA1-RC2-40";
+pub const LN_pbe_WithSHA1And40BitRC2_CBC = "pbeWithSHA1And40BitRC2-CBC";
+pub const NID_pbe_WithSHA1And40BitRC2_CBC = @as(c_int, 149);
+pub const OBJ_pbe_WithSHA1And40BitRC2_CBC = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 12);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 6);
+};
+pub const LN_keyBag = "keyBag";
+pub const NID_keyBag = @as(c_int, 150);
+pub const OBJ_keyBag = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 12);
+ _ = @as(c_long, 10);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 1);
+};
+pub const LN_pkcs8ShroudedKeyBag = "pkcs8ShroudedKeyBag";
+pub const NID_pkcs8ShroudedKeyBag = @as(c_int, 151);
+pub const OBJ_pkcs8ShroudedKeyBag = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 12);
+ _ = @as(c_long, 10);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 2);
+};
+pub const LN_certBag = "certBag";
+pub const NID_certBag = @as(c_int, 152);
+pub const OBJ_certBag = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 12);
+ _ = @as(c_long, 10);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 3);
+};
+pub const LN_crlBag = "crlBag";
+pub const NID_crlBag = @as(c_int, 153);
+pub const OBJ_crlBag = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 12);
+ _ = @as(c_long, 10);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 4);
+};
+pub const LN_secretBag = "secretBag";
+pub const NID_secretBag = @as(c_int, 154);
+pub const OBJ_secretBag = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 12);
+ _ = @as(c_long, 10);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 5);
+};
+pub const LN_safeContentsBag = "safeContentsBag";
+pub const NID_safeContentsBag = @as(c_int, 155);
+pub const OBJ_safeContentsBag = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 12);
+ _ = @as(c_long, 10);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 6);
+};
+pub const LN_friendlyName = "friendlyName";
+pub const NID_friendlyName = @as(c_int, 156);
+pub const OBJ_friendlyName = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ break :blk @as(c_long, 20);
+};
+pub const LN_localKeyID = "localKeyID";
+pub const NID_localKeyID = @as(c_int, 157);
+pub const OBJ_localKeyID = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ break :blk @as(c_long, 21);
+};
+pub const LN_x509Certificate = "x509Certificate";
+pub const NID_x509Certificate = @as(c_int, 158);
+pub const OBJ_x509Certificate = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 22);
+ break :blk @as(c_long, 1);
+};
+pub const LN_sdsiCertificate = "sdsiCertificate";
+pub const NID_sdsiCertificate = @as(c_int, 159);
+pub const OBJ_sdsiCertificate = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 22);
+ break :blk @as(c_long, 2);
+};
+pub const LN_x509Crl = "x509Crl";
+pub const NID_x509Crl = @as(c_int, 160);
+pub const OBJ_x509Crl = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 23);
+ break :blk @as(c_long, 1);
+};
+pub const LN_pbes2 = "PBES2";
+pub const NID_pbes2 = @as(c_int, 161);
+pub const OBJ_pbes2 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ break :blk @as(c_long, 13);
+};
+pub const LN_pbmac1 = "PBMAC1";
+pub const NID_pbmac1 = @as(c_int, 162);
+pub const OBJ_pbmac1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ break :blk @as(c_long, 14);
+};
+pub const LN_hmacWithSHA1 = "hmacWithSHA1";
+pub const NID_hmacWithSHA1 = @as(c_int, 163);
+pub const OBJ_hmacWithSHA1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 7);
+};
+pub const SN_id_qt_cps = "id-qt-cps";
+pub const LN_id_qt_cps = "Policy Qualifier CPS";
+pub const NID_id_qt_cps = @as(c_int, 164);
+pub const OBJ_id_qt_cps = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_qt_unotice = "id-qt-unotice";
+pub const LN_id_qt_unotice = "Policy Qualifier User Notice";
+pub const NID_id_qt_unotice = @as(c_int, 165);
+pub const OBJ_id_qt_unotice = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 2);
+};
+pub const SN_rc2_64_cbc = "RC2-64-CBC";
+pub const LN_rc2_64_cbc = "rc2-64-cbc";
+pub const NID_rc2_64_cbc = @as(c_int, 166);
+pub const SN_SMIMECapabilities = "SMIME-CAPS";
+pub const LN_SMIMECapabilities = "S/MIME Capabilities";
+pub const NID_SMIMECapabilities = @as(c_int, 167);
+pub const OBJ_SMIMECapabilities = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ break :blk @as(c_long, 15);
+};
+pub const SN_pbeWithMD2AndRC2_CBC = "PBE-MD2-RC2-64";
+pub const LN_pbeWithMD2AndRC2_CBC = "pbeWithMD2AndRC2-CBC";
+pub const NID_pbeWithMD2AndRC2_CBC = @as(c_int, 168);
+pub const OBJ_pbeWithMD2AndRC2_CBC = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ break :blk @as(c_long, 4);
+};
+pub const SN_pbeWithMD5AndRC2_CBC = "PBE-MD5-RC2-64";
+pub const LN_pbeWithMD5AndRC2_CBC = "pbeWithMD5AndRC2-CBC";
+pub const NID_pbeWithMD5AndRC2_CBC = @as(c_int, 169);
+pub const OBJ_pbeWithMD5AndRC2_CBC = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ break :blk @as(c_long, 6);
+};
+pub const SN_pbeWithSHA1AndDES_CBC = "PBE-SHA1-DES";
+pub const LN_pbeWithSHA1AndDES_CBC = "pbeWithSHA1AndDES-CBC";
+pub const NID_pbeWithSHA1AndDES_CBC = @as(c_int, 170);
+pub const OBJ_pbeWithSHA1AndDES_CBC = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ break :blk @as(c_long, 10);
+};
+pub const SN_ms_ext_req = "msExtReq";
+pub const LN_ms_ext_req = "Microsoft Extension Request";
+pub const NID_ms_ext_req = @as(c_int, 171);
+pub const OBJ_ms_ext_req = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 311);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 14);
+};
+pub const SN_ext_req = "extReq";
+pub const LN_ext_req = "Extension Request";
+pub const NID_ext_req = @as(c_int, 172);
+pub const OBJ_ext_req = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ break :blk @as(c_long, 14);
+};
+pub const SN_name = "name";
+pub const LN_name = "name";
+pub const NID_name = @as(c_int, 173);
+pub const OBJ_name = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 41);
+};
+pub const SN_dnQualifier = "dnQualifier";
+pub const LN_dnQualifier = "dnQualifier";
+pub const NID_dnQualifier = @as(c_int, 174);
+pub const OBJ_dnQualifier = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 46);
+};
+pub const SN_id_pe = "id-pe";
+pub const NID_id_pe = @as(c_int, 175);
+pub const OBJ_id_pe = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_ad = "id-ad";
+pub const NID_id_ad = @as(c_int, 176);
+pub const OBJ_id_ad = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 48);
+};
+pub const SN_info_access = "authorityInfoAccess";
+pub const LN_info_access = "Authority Information Access";
+pub const NID_info_access = @as(c_int, 177);
+pub const OBJ_info_access = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 1);
+};
+pub const SN_ad_OCSP = "OCSP";
+pub const LN_ad_OCSP = "OCSP";
+pub const NID_ad_OCSP = @as(c_int, 178);
+pub const OBJ_ad_OCSP = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 48);
+ break :blk @as(c_long, 1);
+};
+pub const SN_ad_ca_issuers = "caIssuers";
+pub const LN_ad_ca_issuers = "CA Issuers";
+pub const NID_ad_ca_issuers = @as(c_int, 179);
+pub const OBJ_ad_ca_issuers = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 48);
+ break :blk @as(c_long, 2);
+};
+pub const SN_OCSP_sign = "OCSPSigning";
+pub const LN_OCSP_sign = "OCSP Signing";
+pub const NID_OCSP_sign = @as(c_int, 180);
+pub const OBJ_OCSP_sign = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 9);
+};
+pub const SN_iso = "ISO";
+pub const LN_iso = "iso";
+pub const NID_iso = @as(c_int, 181);
+pub const OBJ_iso = @as(c_long, 1);
+pub const SN_member_body = "member-body";
+pub const LN_member_body = "ISO Member Body";
+pub const NID_member_body = @as(c_int, 182);
+pub const OBJ_member_body = blk: {
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 2);
+};
+pub const SN_ISO_US = "ISO-US";
+pub const LN_ISO_US = "ISO US Member Body";
+pub const NID_ISO_US = @as(c_int, 183);
+pub const OBJ_ISO_US = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 840);
+};
+pub const SN_X9_57 = "X9-57";
+pub const LN_X9_57 = "X9.57";
+pub const NID_X9_57 = @as(c_int, 184);
+pub const OBJ_X9_57 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ break :blk @as(c_long, 10040);
+};
+pub const SN_X9cm = "X9cm";
+pub const LN_X9cm = "X9.57 CM ?";
+pub const NID_X9cm = @as(c_int, 185);
+pub const OBJ_X9cm = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10040);
+ break :blk @as(c_long, 4);
+};
+pub const SN_pkcs1 = "pkcs1";
+pub const NID_pkcs1 = @as(c_int, 186);
+pub const OBJ_pkcs1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 1);
+};
+pub const SN_pkcs5 = "pkcs5";
+pub const NID_pkcs5 = @as(c_int, 187);
+pub const OBJ_pkcs5 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 5);
+};
+pub const SN_SMIME = "SMIME";
+pub const LN_SMIME = "S/MIME";
+pub const NID_SMIME = @as(c_int, 188);
+pub const OBJ_SMIME = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ break :blk @as(c_long, 16);
+};
+pub const SN_id_smime_mod = "id-smime-mod";
+pub const NID_id_smime_mod = @as(c_int, 189);
+pub const OBJ_id_smime_mod = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ break :blk @as(c_long, 0);
+};
+pub const SN_id_smime_ct = "id-smime-ct";
+pub const NID_id_smime_ct = @as(c_int, 190);
+pub const OBJ_id_smime_ct = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_smime_aa = "id-smime-aa";
+pub const NID_id_smime_aa = @as(c_int, 191);
+pub const OBJ_id_smime_aa = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ break :blk @as(c_long, 2);
+};
+pub const SN_id_smime_alg = "id-smime-alg";
+pub const NID_id_smime_alg = @as(c_int, 192);
+pub const OBJ_id_smime_alg = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ break :blk @as(c_long, 3);
+};
+pub const SN_id_smime_cd = "id-smime-cd";
+pub const NID_id_smime_cd = @as(c_int, 193);
+pub const OBJ_id_smime_cd = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ break :blk @as(c_long, 4);
+};
+pub const SN_id_smime_spq = "id-smime-spq";
+pub const NID_id_smime_spq = @as(c_int, 194);
+pub const OBJ_id_smime_spq = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ break :blk @as(c_long, 5);
+};
+pub const SN_id_smime_cti = "id-smime-cti";
+pub const NID_id_smime_cti = @as(c_int, 195);
+pub const OBJ_id_smime_cti = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ break :blk @as(c_long, 6);
+};
+pub const SN_id_smime_mod_cms = "id-smime-mod-cms";
+pub const NID_id_smime_mod_cms = @as(c_int, 196);
+pub const OBJ_id_smime_mod_cms = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_smime_mod_ess = "id-smime-mod-ess";
+pub const NID_id_smime_mod_ess = @as(c_int, 197);
+pub const OBJ_id_smime_mod_ess = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 2);
+};
+pub const SN_id_smime_mod_oid = "id-smime-mod-oid";
+pub const NID_id_smime_mod_oid = @as(c_int, 198);
+pub const OBJ_id_smime_mod_oid = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 3);
+};
+pub const SN_id_smime_mod_msg_v3 = "id-smime-mod-msg-v3";
+pub const NID_id_smime_mod_msg_v3 = @as(c_int, 199);
+pub const OBJ_id_smime_mod_msg_v3 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 4);
+};
+pub const SN_id_smime_mod_ets_eSignature_88 = "id-smime-mod-ets-eSignature-88";
+pub const NID_id_smime_mod_ets_eSignature_88 = @as(c_int, 200);
+pub const OBJ_id_smime_mod_ets_eSignature_88 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 5);
+};
+pub const SN_id_smime_mod_ets_eSignature_97 = "id-smime-mod-ets-eSignature-97";
+pub const NID_id_smime_mod_ets_eSignature_97 = @as(c_int, 201);
+pub const OBJ_id_smime_mod_ets_eSignature_97 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 6);
+};
+pub const SN_id_smime_mod_ets_eSigPolicy_88 = "id-smime-mod-ets-eSigPolicy-88";
+pub const NID_id_smime_mod_ets_eSigPolicy_88 = @as(c_int, 202);
+pub const OBJ_id_smime_mod_ets_eSigPolicy_88 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 7);
+};
+pub const SN_id_smime_mod_ets_eSigPolicy_97 = "id-smime-mod-ets-eSigPolicy-97";
+pub const NID_id_smime_mod_ets_eSigPolicy_97 = @as(c_int, 203);
+pub const OBJ_id_smime_mod_ets_eSigPolicy_97 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 8);
+};
+pub const SN_id_smime_ct_receipt = "id-smime-ct-receipt";
+pub const NID_id_smime_ct_receipt = @as(c_int, 204);
+pub const OBJ_id_smime_ct_receipt = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_smime_ct_authData = "id-smime-ct-authData";
+pub const NID_id_smime_ct_authData = @as(c_int, 205);
+pub const OBJ_id_smime_ct_authData = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 2);
+};
+pub const SN_id_smime_ct_publishCert = "id-smime-ct-publishCert";
+pub const NID_id_smime_ct_publishCert = @as(c_int, 206);
+pub const OBJ_id_smime_ct_publishCert = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 3);
+};
+pub const SN_id_smime_ct_TSTInfo = "id-smime-ct-TSTInfo";
+pub const NID_id_smime_ct_TSTInfo = @as(c_int, 207);
+pub const OBJ_id_smime_ct_TSTInfo = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 4);
+};
+pub const SN_id_smime_ct_TDTInfo = "id-smime-ct-TDTInfo";
+pub const NID_id_smime_ct_TDTInfo = @as(c_int, 208);
+pub const OBJ_id_smime_ct_TDTInfo = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 5);
+};
+pub const SN_id_smime_ct_contentInfo = "id-smime-ct-contentInfo";
+pub const NID_id_smime_ct_contentInfo = @as(c_int, 209);
+pub const OBJ_id_smime_ct_contentInfo = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 6);
+};
+pub const SN_id_smime_ct_DVCSRequestData = "id-smime-ct-DVCSRequestData";
+pub const NID_id_smime_ct_DVCSRequestData = @as(c_int, 210);
+pub const OBJ_id_smime_ct_DVCSRequestData = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 7);
+};
+pub const SN_id_smime_ct_DVCSResponseData = "id-smime-ct-DVCSResponseData";
+pub const NID_id_smime_ct_DVCSResponseData = @as(c_int, 211);
+pub const OBJ_id_smime_ct_DVCSResponseData = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 8);
+};
+pub const SN_id_smime_aa_receiptRequest = "id-smime-aa-receiptRequest";
+pub const NID_id_smime_aa_receiptRequest = @as(c_int, 212);
+pub const OBJ_id_smime_aa_receiptRequest = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_smime_aa_securityLabel = "id-smime-aa-securityLabel";
+pub const NID_id_smime_aa_securityLabel = @as(c_int, 213);
+pub const OBJ_id_smime_aa_securityLabel = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 2);
+};
+pub const SN_id_smime_aa_mlExpandHistory = "id-smime-aa-mlExpandHistory";
+pub const NID_id_smime_aa_mlExpandHistory = @as(c_int, 214);
+pub const OBJ_id_smime_aa_mlExpandHistory = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 3);
+};
+pub const SN_id_smime_aa_contentHint = "id-smime-aa-contentHint";
+pub const NID_id_smime_aa_contentHint = @as(c_int, 215);
+pub const OBJ_id_smime_aa_contentHint = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 4);
+};
+pub const SN_id_smime_aa_msgSigDigest = "id-smime-aa-msgSigDigest";
+pub const NID_id_smime_aa_msgSigDigest = @as(c_int, 216);
+pub const OBJ_id_smime_aa_msgSigDigest = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 5);
+};
+pub const SN_id_smime_aa_encapContentType = "id-smime-aa-encapContentType";
+pub const NID_id_smime_aa_encapContentType = @as(c_int, 217);
+pub const OBJ_id_smime_aa_encapContentType = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 6);
+};
+pub const SN_id_smime_aa_contentIdentifier = "id-smime-aa-contentIdentifier";
+pub const NID_id_smime_aa_contentIdentifier = @as(c_int, 218);
+pub const OBJ_id_smime_aa_contentIdentifier = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 7);
+};
+pub const SN_id_smime_aa_macValue = "id-smime-aa-macValue";
+pub const NID_id_smime_aa_macValue = @as(c_int, 219);
+pub const OBJ_id_smime_aa_macValue = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 8);
+};
+pub const SN_id_smime_aa_equivalentLabels = "id-smime-aa-equivalentLabels";
+pub const NID_id_smime_aa_equivalentLabels = @as(c_int, 220);
+pub const OBJ_id_smime_aa_equivalentLabels = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 9);
+};
+pub const SN_id_smime_aa_contentReference = "id-smime-aa-contentReference";
+pub const NID_id_smime_aa_contentReference = @as(c_int, 221);
+pub const OBJ_id_smime_aa_contentReference = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 10);
+};
+pub const SN_id_smime_aa_encrypKeyPref = "id-smime-aa-encrypKeyPref";
+pub const NID_id_smime_aa_encrypKeyPref = @as(c_int, 222);
+pub const OBJ_id_smime_aa_encrypKeyPref = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 11);
+};
+pub const SN_id_smime_aa_signingCertificate = "id-smime-aa-signingCertificate";
+pub const NID_id_smime_aa_signingCertificate = @as(c_int, 223);
+pub const OBJ_id_smime_aa_signingCertificate = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 12);
+};
+pub const SN_id_smime_aa_smimeEncryptCerts = "id-smime-aa-smimeEncryptCerts";
+pub const NID_id_smime_aa_smimeEncryptCerts = @as(c_int, 224);
+pub const OBJ_id_smime_aa_smimeEncryptCerts = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 13);
+};
+pub const SN_id_smime_aa_timeStampToken = "id-smime-aa-timeStampToken";
+pub const NID_id_smime_aa_timeStampToken = @as(c_int, 225);
+pub const OBJ_id_smime_aa_timeStampToken = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 14);
+};
+pub const SN_id_smime_aa_ets_sigPolicyId = "id-smime-aa-ets-sigPolicyId";
+pub const NID_id_smime_aa_ets_sigPolicyId = @as(c_int, 226);
+pub const OBJ_id_smime_aa_ets_sigPolicyId = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 15);
+};
+pub const SN_id_smime_aa_ets_commitmentType = "id-smime-aa-ets-commitmentType";
+pub const NID_id_smime_aa_ets_commitmentType = @as(c_int, 227);
+pub const OBJ_id_smime_aa_ets_commitmentType = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 16);
+};
+pub const SN_id_smime_aa_ets_signerLocation = "id-smime-aa-ets-signerLocation";
+pub const NID_id_smime_aa_ets_signerLocation = @as(c_int, 228);
+pub const OBJ_id_smime_aa_ets_signerLocation = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 17);
+};
+pub const SN_id_smime_aa_ets_signerAttr = "id-smime-aa-ets-signerAttr";
+pub const NID_id_smime_aa_ets_signerAttr = @as(c_int, 229);
+pub const OBJ_id_smime_aa_ets_signerAttr = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 18);
+};
+pub const SN_id_smime_aa_ets_otherSigCert = "id-smime-aa-ets-otherSigCert";
+pub const NID_id_smime_aa_ets_otherSigCert = @as(c_int, 230);
+pub const OBJ_id_smime_aa_ets_otherSigCert = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 19);
+};
+pub const SN_id_smime_aa_ets_contentTimestamp = "id-smime-aa-ets-contentTimestamp";
+pub const NID_id_smime_aa_ets_contentTimestamp = @as(c_int, 231);
+pub const OBJ_id_smime_aa_ets_contentTimestamp = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 20);
+};
+pub const SN_id_smime_aa_ets_CertificateRefs = "id-smime-aa-ets-CertificateRefs";
+pub const NID_id_smime_aa_ets_CertificateRefs = @as(c_int, 232);
+pub const OBJ_id_smime_aa_ets_CertificateRefs = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 21);
+};
+pub const SN_id_smime_aa_ets_RevocationRefs = "id-smime-aa-ets-RevocationRefs";
+pub const NID_id_smime_aa_ets_RevocationRefs = @as(c_int, 233);
+pub const OBJ_id_smime_aa_ets_RevocationRefs = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 22);
+};
+pub const SN_id_smime_aa_ets_certValues = "id-smime-aa-ets-certValues";
+pub const NID_id_smime_aa_ets_certValues = @as(c_int, 234);
+pub const OBJ_id_smime_aa_ets_certValues = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 23);
+};
+pub const SN_id_smime_aa_ets_revocationValues = "id-smime-aa-ets-revocationValues";
+pub const NID_id_smime_aa_ets_revocationValues = @as(c_int, 235);
+pub const OBJ_id_smime_aa_ets_revocationValues = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 24);
+};
+pub const SN_id_smime_aa_ets_escTimeStamp = "id-smime-aa-ets-escTimeStamp";
+pub const NID_id_smime_aa_ets_escTimeStamp = @as(c_int, 236);
+pub const OBJ_id_smime_aa_ets_escTimeStamp = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 25);
+};
+pub const SN_id_smime_aa_ets_certCRLTimestamp = "id-smime-aa-ets-certCRLTimestamp";
+pub const NID_id_smime_aa_ets_certCRLTimestamp = @as(c_int, 237);
+pub const OBJ_id_smime_aa_ets_certCRLTimestamp = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 26);
+};
+pub const SN_id_smime_aa_ets_archiveTimeStamp = "id-smime-aa-ets-archiveTimeStamp";
+pub const NID_id_smime_aa_ets_archiveTimeStamp = @as(c_int, 238);
+pub const OBJ_id_smime_aa_ets_archiveTimeStamp = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 27);
+};
+pub const SN_id_smime_aa_signatureType = "id-smime-aa-signatureType";
+pub const NID_id_smime_aa_signatureType = @as(c_int, 239);
+pub const OBJ_id_smime_aa_signatureType = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 28);
+};
+pub const SN_id_smime_aa_dvcs_dvc = "id-smime-aa-dvcs-dvc";
+pub const NID_id_smime_aa_dvcs_dvc = @as(c_int, 240);
+pub const OBJ_id_smime_aa_dvcs_dvc = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 29);
+};
+pub const SN_id_smime_alg_ESDHwith3DES = "id-smime-alg-ESDHwith3DES";
+pub const NID_id_smime_alg_ESDHwith3DES = @as(c_int, 241);
+pub const OBJ_id_smime_alg_ESDHwith3DES = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_smime_alg_ESDHwithRC2 = "id-smime-alg-ESDHwithRC2";
+pub const NID_id_smime_alg_ESDHwithRC2 = @as(c_int, 242);
+pub const OBJ_id_smime_alg_ESDHwithRC2 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 2);
+};
+pub const SN_id_smime_alg_3DESwrap = "id-smime-alg-3DESwrap";
+pub const NID_id_smime_alg_3DESwrap = @as(c_int, 243);
+pub const OBJ_id_smime_alg_3DESwrap = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 3);
+};
+pub const SN_id_smime_alg_RC2wrap = "id-smime-alg-RC2wrap";
+pub const NID_id_smime_alg_RC2wrap = @as(c_int, 244);
+pub const OBJ_id_smime_alg_RC2wrap = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 4);
+};
+pub const SN_id_smime_alg_ESDH = "id-smime-alg-ESDH";
+pub const NID_id_smime_alg_ESDH = @as(c_int, 245);
+pub const OBJ_id_smime_alg_ESDH = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 5);
+};
+pub const SN_id_smime_alg_CMS3DESwrap = "id-smime-alg-CMS3DESwrap";
+pub const NID_id_smime_alg_CMS3DESwrap = @as(c_int, 246);
+pub const OBJ_id_smime_alg_CMS3DESwrap = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 6);
+};
+pub const SN_id_smime_alg_CMSRC2wrap = "id-smime-alg-CMSRC2wrap";
+pub const NID_id_smime_alg_CMSRC2wrap = @as(c_int, 247);
+pub const OBJ_id_smime_alg_CMSRC2wrap = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 7);
+};
+pub const SN_id_smime_cd_ldap = "id-smime-cd-ldap";
+pub const NID_id_smime_cd_ldap = @as(c_int, 248);
+pub const OBJ_id_smime_cd_ldap = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_smime_spq_ets_sqt_uri = "id-smime-spq-ets-sqt-uri";
+pub const NID_id_smime_spq_ets_sqt_uri = @as(c_int, 249);
+pub const OBJ_id_smime_spq_ets_sqt_uri = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 5);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_smime_spq_ets_sqt_unotice = "id-smime-spq-ets-sqt-unotice";
+pub const NID_id_smime_spq_ets_sqt_unotice = @as(c_int, 250);
+pub const OBJ_id_smime_spq_ets_sqt_unotice = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 5);
+ break :blk @as(c_long, 2);
+};
+pub const SN_id_smime_cti_ets_proofOfOrigin = "id-smime-cti-ets-proofOfOrigin";
+pub const NID_id_smime_cti_ets_proofOfOrigin = @as(c_int, 251);
+pub const OBJ_id_smime_cti_ets_proofOfOrigin = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 6);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_smime_cti_ets_proofOfReceipt = "id-smime-cti-ets-proofOfReceipt";
+pub const NID_id_smime_cti_ets_proofOfReceipt = @as(c_int, 252);
+pub const OBJ_id_smime_cti_ets_proofOfReceipt = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 6);
+ break :blk @as(c_long, 2);
+};
+pub const SN_id_smime_cti_ets_proofOfDelivery = "id-smime-cti-ets-proofOfDelivery";
+pub const NID_id_smime_cti_ets_proofOfDelivery = @as(c_int, 253);
+pub const OBJ_id_smime_cti_ets_proofOfDelivery = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 6);
+ break :blk @as(c_long, 3);
+};
+pub const SN_id_smime_cti_ets_proofOfSender = "id-smime-cti-ets-proofOfSender";
+pub const NID_id_smime_cti_ets_proofOfSender = @as(c_int, 254);
+pub const OBJ_id_smime_cti_ets_proofOfSender = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 6);
+ break :blk @as(c_long, 4);
+};
+pub const SN_id_smime_cti_ets_proofOfApproval = "id-smime-cti-ets-proofOfApproval";
+pub const NID_id_smime_cti_ets_proofOfApproval = @as(c_int, 255);
+pub const OBJ_id_smime_cti_ets_proofOfApproval = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 6);
+ break :blk @as(c_long, 5);
+};
+pub const SN_id_smime_cti_ets_proofOfCreation = "id-smime-cti-ets-proofOfCreation";
+pub const NID_id_smime_cti_ets_proofOfCreation = @as(c_int, 256);
+pub const OBJ_id_smime_cti_ets_proofOfCreation = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 6);
+ break :blk @as(c_long, 6);
+};
+pub const SN_md4 = "MD4";
+pub const LN_md4 = "md4";
+pub const NID_md4 = @as(c_int, 257);
+pub const OBJ_md4 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 4);
+};
+pub const SN_id_pkix_mod = "id-pkix-mod";
+pub const NID_id_pkix_mod = @as(c_int, 258);
+pub const OBJ_id_pkix_mod = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 0);
+};
+pub const SN_id_qt = "id-qt";
+pub const NID_id_qt = @as(c_int, 259);
+pub const OBJ_id_qt = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 2);
+};
+pub const SN_id_it = "id-it";
+pub const NID_id_it = @as(c_int, 260);
+pub const OBJ_id_it = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 4);
+};
+pub const SN_id_pkip = "id-pkip";
+pub const NID_id_pkip = @as(c_int, 261);
+pub const OBJ_id_pkip = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 5);
+};
+pub const SN_id_alg = "id-alg";
+pub const NID_id_alg = @as(c_int, 262);
+pub const OBJ_id_alg = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 6);
+};
+pub const SN_id_cmc = "id-cmc";
+pub const NID_id_cmc = @as(c_int, 263);
+pub const OBJ_id_cmc = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 7);
+};
+pub const SN_id_on = "id-on";
+pub const NID_id_on = @as(c_int, 264);
+pub const OBJ_id_on = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 8);
+};
+pub const SN_id_pda = "id-pda";
+pub const NID_id_pda = @as(c_int, 265);
+pub const OBJ_id_pda = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 9);
+};
+pub const SN_id_aca = "id-aca";
+pub const NID_id_aca = @as(c_int, 266);
+pub const OBJ_id_aca = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 10);
+};
+pub const SN_id_qcs = "id-qcs";
+pub const NID_id_qcs = @as(c_int, 267);
+pub const OBJ_id_qcs = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 11);
+};
+pub const SN_id_cct = "id-cct";
+pub const NID_id_cct = @as(c_int, 268);
+pub const OBJ_id_cct = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 12);
+};
+pub const SN_id_pkix1_explicit_88 = "id-pkix1-explicit-88";
+pub const NID_id_pkix1_explicit_88 = @as(c_int, 269);
+pub const OBJ_id_pkix1_explicit_88 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_pkix1_implicit_88 = "id-pkix1-implicit-88";
+pub const NID_id_pkix1_implicit_88 = @as(c_int, 270);
+pub const OBJ_id_pkix1_implicit_88 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 2);
+};
+pub const SN_id_pkix1_explicit_93 = "id-pkix1-explicit-93";
+pub const NID_id_pkix1_explicit_93 = @as(c_int, 271);
+pub const OBJ_id_pkix1_explicit_93 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 3);
+};
+pub const SN_id_pkix1_implicit_93 = "id-pkix1-implicit-93";
+pub const NID_id_pkix1_implicit_93 = @as(c_int, 272);
+pub const OBJ_id_pkix1_implicit_93 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 4);
+};
+pub const SN_id_mod_crmf = "id-mod-crmf";
+pub const NID_id_mod_crmf = @as(c_int, 273);
+pub const OBJ_id_mod_crmf = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 5);
+};
+pub const SN_id_mod_cmc = "id-mod-cmc";
+pub const NID_id_mod_cmc = @as(c_int, 274);
+pub const OBJ_id_mod_cmc = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 6);
+};
+pub const SN_id_mod_kea_profile_88 = "id-mod-kea-profile-88";
+pub const NID_id_mod_kea_profile_88 = @as(c_int, 275);
+pub const OBJ_id_mod_kea_profile_88 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 7);
+};
+pub const SN_id_mod_kea_profile_93 = "id-mod-kea-profile-93";
+pub const NID_id_mod_kea_profile_93 = @as(c_int, 276);
+pub const OBJ_id_mod_kea_profile_93 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 8);
+};
+pub const SN_id_mod_cmp = "id-mod-cmp";
+pub const NID_id_mod_cmp = @as(c_int, 277);
+pub const OBJ_id_mod_cmp = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 9);
+};
+pub const SN_id_mod_qualified_cert_88 = "id-mod-qualified-cert-88";
+pub const NID_id_mod_qualified_cert_88 = @as(c_int, 278);
+pub const OBJ_id_mod_qualified_cert_88 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 10);
+};
+pub const SN_id_mod_qualified_cert_93 = "id-mod-qualified-cert-93";
+pub const NID_id_mod_qualified_cert_93 = @as(c_int, 279);
+pub const OBJ_id_mod_qualified_cert_93 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 11);
+};
+pub const SN_id_mod_attribute_cert = "id-mod-attribute-cert";
+pub const NID_id_mod_attribute_cert = @as(c_int, 280);
+pub const OBJ_id_mod_attribute_cert = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 12);
+};
+pub const SN_id_mod_timestamp_protocol = "id-mod-timestamp-protocol";
+pub const NID_id_mod_timestamp_protocol = @as(c_int, 281);
+pub const OBJ_id_mod_timestamp_protocol = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 13);
+};
+pub const SN_id_mod_ocsp = "id-mod-ocsp";
+pub const NID_id_mod_ocsp = @as(c_int, 282);
+pub const OBJ_id_mod_ocsp = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 14);
+};
+pub const SN_id_mod_dvcs = "id-mod-dvcs";
+pub const NID_id_mod_dvcs = @as(c_int, 283);
+pub const OBJ_id_mod_dvcs = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 15);
+};
+pub const SN_id_mod_cmp2000 = "id-mod-cmp2000";
+pub const NID_id_mod_cmp2000 = @as(c_int, 284);
+pub const OBJ_id_mod_cmp2000 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 16);
+};
+pub const SN_biometricInfo = "biometricInfo";
+pub const LN_biometricInfo = "Biometric Info";
+pub const NID_biometricInfo = @as(c_int, 285);
+pub const OBJ_biometricInfo = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 2);
+};
+pub const SN_qcStatements = "qcStatements";
+pub const NID_qcStatements = @as(c_int, 286);
+pub const OBJ_qcStatements = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 3);
+};
+pub const SN_ac_auditEntity = "ac-auditEntity";
+pub const NID_ac_auditEntity = @as(c_int, 287);
+pub const OBJ_ac_auditEntity = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 4);
+};
+pub const SN_ac_targeting = "ac-targeting";
+pub const NID_ac_targeting = @as(c_int, 288);
+pub const OBJ_ac_targeting = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 5);
+};
+pub const SN_aaControls = "aaControls";
+pub const NID_aaControls = @as(c_int, 289);
+pub const OBJ_aaControls = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 6);
+};
+pub const SN_sbgp_ipAddrBlock = "sbgp-ipAddrBlock";
+pub const NID_sbgp_ipAddrBlock = @as(c_int, 290);
+pub const OBJ_sbgp_ipAddrBlock = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 7);
+};
+pub const SN_sbgp_autonomousSysNum = "sbgp-autonomousSysNum";
+pub const NID_sbgp_autonomousSysNum = @as(c_int, 291);
+pub const OBJ_sbgp_autonomousSysNum = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 8);
+};
+pub const SN_sbgp_routerIdentifier = "sbgp-routerIdentifier";
+pub const NID_sbgp_routerIdentifier = @as(c_int, 292);
+pub const OBJ_sbgp_routerIdentifier = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 9);
+};
+pub const SN_textNotice = "textNotice";
+pub const NID_textNotice = @as(c_int, 293);
+pub const OBJ_textNotice = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 3);
+};
+pub const SN_ipsecEndSystem = "ipsecEndSystem";
+pub const LN_ipsecEndSystem = "IPSec End System";
+pub const NID_ipsecEndSystem = @as(c_int, 294);
+pub const OBJ_ipsecEndSystem = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 5);
+};
+pub const SN_ipsecTunnel = "ipsecTunnel";
+pub const LN_ipsecTunnel = "IPSec Tunnel";
+pub const NID_ipsecTunnel = @as(c_int, 295);
+pub const OBJ_ipsecTunnel = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 6);
+};
+pub const SN_ipsecUser = "ipsecUser";
+pub const LN_ipsecUser = "IPSec User";
+pub const NID_ipsecUser = @as(c_int, 296);
+pub const OBJ_ipsecUser = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 7);
+};
+pub const SN_dvcs = "DVCS";
+pub const LN_dvcs = "dvcs";
+pub const NID_dvcs = @as(c_int, 297);
+pub const OBJ_dvcs = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 10);
+};
+pub const SN_id_it_caProtEncCert = "id-it-caProtEncCert";
+pub const NID_id_it_caProtEncCert = @as(c_int, 298);
+pub const OBJ_id_it_caProtEncCert = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_it_signKeyPairTypes = "id-it-signKeyPairTypes";
+pub const NID_id_it_signKeyPairTypes = @as(c_int, 299);
+pub const OBJ_id_it_signKeyPairTypes = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 2);
+};
+pub const SN_id_it_encKeyPairTypes = "id-it-encKeyPairTypes";
+pub const NID_id_it_encKeyPairTypes = @as(c_int, 300);
+pub const OBJ_id_it_encKeyPairTypes = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 3);
+};
+pub const SN_id_it_preferredSymmAlg = "id-it-preferredSymmAlg";
+pub const NID_id_it_preferredSymmAlg = @as(c_int, 301);
+pub const OBJ_id_it_preferredSymmAlg = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 4);
+};
+pub const SN_id_it_caKeyUpdateInfo = "id-it-caKeyUpdateInfo";
+pub const NID_id_it_caKeyUpdateInfo = @as(c_int, 302);
+pub const OBJ_id_it_caKeyUpdateInfo = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 5);
+};
+pub const SN_id_it_currentCRL = "id-it-currentCRL";
+pub const NID_id_it_currentCRL = @as(c_int, 303);
+pub const OBJ_id_it_currentCRL = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 6);
+};
+pub const SN_id_it_unsupportedOIDs = "id-it-unsupportedOIDs";
+pub const NID_id_it_unsupportedOIDs = @as(c_int, 304);
+pub const OBJ_id_it_unsupportedOIDs = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 7);
+};
+pub const SN_id_it_subscriptionRequest = "id-it-subscriptionRequest";
+pub const NID_id_it_subscriptionRequest = @as(c_int, 305);
+pub const OBJ_id_it_subscriptionRequest = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 8);
+};
+pub const SN_id_it_subscriptionResponse = "id-it-subscriptionResponse";
+pub const NID_id_it_subscriptionResponse = @as(c_int, 306);
+pub const OBJ_id_it_subscriptionResponse = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 9);
+};
+pub const SN_id_it_keyPairParamReq = "id-it-keyPairParamReq";
+pub const NID_id_it_keyPairParamReq = @as(c_int, 307);
+pub const OBJ_id_it_keyPairParamReq = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 10);
+};
+pub const SN_id_it_keyPairParamRep = "id-it-keyPairParamRep";
+pub const NID_id_it_keyPairParamRep = @as(c_int, 308);
+pub const OBJ_id_it_keyPairParamRep = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 11);
+};
+pub const SN_id_it_revPassphrase = "id-it-revPassphrase";
+pub const NID_id_it_revPassphrase = @as(c_int, 309);
+pub const OBJ_id_it_revPassphrase = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 12);
+};
+pub const SN_id_it_implicitConfirm = "id-it-implicitConfirm";
+pub const NID_id_it_implicitConfirm = @as(c_int, 310);
+pub const OBJ_id_it_implicitConfirm = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 13);
+};
+pub const SN_id_it_confirmWaitTime = "id-it-confirmWaitTime";
+pub const NID_id_it_confirmWaitTime = @as(c_int, 311);
+pub const OBJ_id_it_confirmWaitTime = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 14);
+};
+pub const SN_id_it_origPKIMessage = "id-it-origPKIMessage";
+pub const NID_id_it_origPKIMessage = @as(c_int, 312);
+pub const OBJ_id_it_origPKIMessage = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 15);
+};
+pub const SN_id_regCtrl = "id-regCtrl";
+pub const NID_id_regCtrl = @as(c_int, 313);
+pub const OBJ_id_regCtrl = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 5);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_regInfo = "id-regInfo";
+pub const NID_id_regInfo = @as(c_int, 314);
+pub const OBJ_id_regInfo = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 5);
+ break :blk @as(c_long, 2);
+};
+pub const SN_id_regCtrl_regToken = "id-regCtrl-regToken";
+pub const NID_id_regCtrl_regToken = @as(c_int, 315);
+pub const OBJ_id_regCtrl_regToken = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_regCtrl_authenticator = "id-regCtrl-authenticator";
+pub const NID_id_regCtrl_authenticator = @as(c_int, 316);
+pub const OBJ_id_regCtrl_authenticator = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 2);
+};
+pub const SN_id_regCtrl_pkiPublicationInfo = "id-regCtrl-pkiPublicationInfo";
+pub const NID_id_regCtrl_pkiPublicationInfo = @as(c_int, 317);
+pub const OBJ_id_regCtrl_pkiPublicationInfo = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 3);
+};
+pub const SN_id_regCtrl_pkiArchiveOptions = "id-regCtrl-pkiArchiveOptions";
+pub const NID_id_regCtrl_pkiArchiveOptions = @as(c_int, 318);
+pub const OBJ_id_regCtrl_pkiArchiveOptions = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 4);
+};
+pub const SN_id_regCtrl_oldCertID = "id-regCtrl-oldCertID";
+pub const NID_id_regCtrl_oldCertID = @as(c_int, 319);
+pub const OBJ_id_regCtrl_oldCertID = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 5);
+};
+pub const SN_id_regCtrl_protocolEncrKey = "id-regCtrl-protocolEncrKey";
+pub const NID_id_regCtrl_protocolEncrKey = @as(c_int, 320);
+pub const OBJ_id_regCtrl_protocolEncrKey = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 6);
+};
+pub const SN_id_regInfo_utf8Pairs = "id-regInfo-utf8Pairs";
+pub const NID_id_regInfo_utf8Pairs = @as(c_int, 321);
+pub const OBJ_id_regInfo_utf8Pairs = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_regInfo_certReq = "id-regInfo-certReq";
+pub const NID_id_regInfo_certReq = @as(c_int, 322);
+pub const OBJ_id_regInfo_certReq = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 2);
+};
+pub const SN_id_alg_des40 = "id-alg-des40";
+pub const NID_id_alg_des40 = @as(c_int, 323);
+pub const OBJ_id_alg_des40 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 6);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_alg_noSignature = "id-alg-noSignature";
+pub const NID_id_alg_noSignature = @as(c_int, 324);
+pub const OBJ_id_alg_noSignature = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 6);
+ break :blk @as(c_long, 2);
+};
+pub const SN_id_alg_dh_sig_hmac_sha1 = "id-alg-dh-sig-hmac-sha1";
+pub const NID_id_alg_dh_sig_hmac_sha1 = @as(c_int, 325);
+pub const OBJ_id_alg_dh_sig_hmac_sha1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 6);
+ break :blk @as(c_long, 3);
+};
+pub const SN_id_alg_dh_pop = "id-alg-dh-pop";
+pub const NID_id_alg_dh_pop = @as(c_int, 326);
+pub const OBJ_id_alg_dh_pop = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 6);
+ break :blk @as(c_long, 4);
+};
+pub const SN_id_cmc_statusInfo = "id-cmc-statusInfo";
+pub const NID_id_cmc_statusInfo = @as(c_int, 327);
+pub const OBJ_id_cmc_statusInfo = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_cmc_identification = "id-cmc-identification";
+pub const NID_id_cmc_identification = @as(c_int, 328);
+pub const OBJ_id_cmc_identification = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 2);
+};
+pub const SN_id_cmc_identityProof = "id-cmc-identityProof";
+pub const NID_id_cmc_identityProof = @as(c_int, 329);
+pub const OBJ_id_cmc_identityProof = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 3);
+};
+pub const SN_id_cmc_dataReturn = "id-cmc-dataReturn";
+pub const NID_id_cmc_dataReturn = @as(c_int, 330);
+pub const OBJ_id_cmc_dataReturn = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 4);
+};
+pub const SN_id_cmc_transactionId = "id-cmc-transactionId";
+pub const NID_id_cmc_transactionId = @as(c_int, 331);
+pub const OBJ_id_cmc_transactionId = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 5);
+};
+pub const SN_id_cmc_senderNonce = "id-cmc-senderNonce";
+pub const NID_id_cmc_senderNonce = @as(c_int, 332);
+pub const OBJ_id_cmc_senderNonce = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 6);
+};
+pub const SN_id_cmc_recipientNonce = "id-cmc-recipientNonce";
+pub const NID_id_cmc_recipientNonce = @as(c_int, 333);
+pub const OBJ_id_cmc_recipientNonce = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 7);
+};
+pub const SN_id_cmc_addExtensions = "id-cmc-addExtensions";
+pub const NID_id_cmc_addExtensions = @as(c_int, 334);
+pub const OBJ_id_cmc_addExtensions = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 8);
+};
+pub const SN_id_cmc_encryptedPOP = "id-cmc-encryptedPOP";
+pub const NID_id_cmc_encryptedPOP = @as(c_int, 335);
+pub const OBJ_id_cmc_encryptedPOP = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 9);
+};
+pub const SN_id_cmc_decryptedPOP = "id-cmc-decryptedPOP";
+pub const NID_id_cmc_decryptedPOP = @as(c_int, 336);
+pub const OBJ_id_cmc_decryptedPOP = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 10);
+};
+pub const SN_id_cmc_lraPOPWitness = "id-cmc-lraPOPWitness";
+pub const NID_id_cmc_lraPOPWitness = @as(c_int, 337);
+pub const OBJ_id_cmc_lraPOPWitness = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 11);
+};
+pub const SN_id_cmc_getCert = "id-cmc-getCert";
+pub const NID_id_cmc_getCert = @as(c_int, 338);
+pub const OBJ_id_cmc_getCert = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 15);
+};
+pub const SN_id_cmc_getCRL = "id-cmc-getCRL";
+pub const NID_id_cmc_getCRL = @as(c_int, 339);
+pub const OBJ_id_cmc_getCRL = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 16);
+};
+pub const SN_id_cmc_revokeRequest = "id-cmc-revokeRequest";
+pub const NID_id_cmc_revokeRequest = @as(c_int, 340);
+pub const OBJ_id_cmc_revokeRequest = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 17);
+};
+pub const SN_id_cmc_regInfo = "id-cmc-regInfo";
+pub const NID_id_cmc_regInfo = @as(c_int, 341);
+pub const OBJ_id_cmc_regInfo = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 18);
+};
+pub const SN_id_cmc_responseInfo = "id-cmc-responseInfo";
+pub const NID_id_cmc_responseInfo = @as(c_int, 342);
+pub const OBJ_id_cmc_responseInfo = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 19);
+};
+pub const SN_id_cmc_queryPending = "id-cmc-queryPending";
+pub const NID_id_cmc_queryPending = @as(c_int, 343);
+pub const OBJ_id_cmc_queryPending = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 21);
+};
+pub const SN_id_cmc_popLinkRandom = "id-cmc-popLinkRandom";
+pub const NID_id_cmc_popLinkRandom = @as(c_int, 344);
+pub const OBJ_id_cmc_popLinkRandom = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 22);
+};
+pub const SN_id_cmc_popLinkWitness = "id-cmc-popLinkWitness";
+pub const NID_id_cmc_popLinkWitness = @as(c_int, 345);
+pub const OBJ_id_cmc_popLinkWitness = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 23);
+};
+pub const SN_id_cmc_confirmCertAcceptance = "id-cmc-confirmCertAcceptance";
+pub const NID_id_cmc_confirmCertAcceptance = @as(c_int, 346);
+pub const OBJ_id_cmc_confirmCertAcceptance = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 24);
+};
+pub const SN_id_on_personalData = "id-on-personalData";
+pub const NID_id_on_personalData = @as(c_int, 347);
+pub const OBJ_id_on_personalData = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 8);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_pda_dateOfBirth = "id-pda-dateOfBirth";
+pub const NID_id_pda_dateOfBirth = @as(c_int, 348);
+pub const OBJ_id_pda_dateOfBirth = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 9);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_pda_placeOfBirth = "id-pda-placeOfBirth";
+pub const NID_id_pda_placeOfBirth = @as(c_int, 349);
+pub const OBJ_id_pda_placeOfBirth = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 9);
+ break :blk @as(c_long, 2);
+};
+pub const SN_id_pda_gender = "id-pda-gender";
+pub const NID_id_pda_gender = @as(c_int, 351);
+pub const OBJ_id_pda_gender = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 9);
+ break :blk @as(c_long, 3);
+};
+pub const SN_id_pda_countryOfCitizenship = "id-pda-countryOfCitizenship";
+pub const NID_id_pda_countryOfCitizenship = @as(c_int, 352);
+pub const OBJ_id_pda_countryOfCitizenship = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 9);
+ break :blk @as(c_long, 4);
+};
+pub const SN_id_pda_countryOfResidence = "id-pda-countryOfResidence";
+pub const NID_id_pda_countryOfResidence = @as(c_int, 353);
+pub const OBJ_id_pda_countryOfResidence = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 9);
+ break :blk @as(c_long, 5);
+};
+pub const SN_id_aca_authenticationInfo = "id-aca-authenticationInfo";
+pub const NID_id_aca_authenticationInfo = @as(c_int, 354);
+pub const OBJ_id_aca_authenticationInfo = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 10);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_aca_accessIdentity = "id-aca-accessIdentity";
+pub const NID_id_aca_accessIdentity = @as(c_int, 355);
+pub const OBJ_id_aca_accessIdentity = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 10);
+ break :blk @as(c_long, 2);
+};
+pub const SN_id_aca_chargingIdentity = "id-aca-chargingIdentity";
+pub const NID_id_aca_chargingIdentity = @as(c_int, 356);
+pub const OBJ_id_aca_chargingIdentity = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 10);
+ break :blk @as(c_long, 3);
+};
+pub const SN_id_aca_group = "id-aca-group";
+pub const NID_id_aca_group = @as(c_int, 357);
+pub const OBJ_id_aca_group = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 10);
+ break :blk @as(c_long, 4);
+};
+pub const SN_id_aca_role = "id-aca-role";
+pub const NID_id_aca_role = @as(c_int, 358);
+pub const OBJ_id_aca_role = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 10);
+ break :blk @as(c_long, 5);
+};
+pub const SN_id_qcs_pkixQCSyntax_v1 = "id-qcs-pkixQCSyntax-v1";
+pub const NID_id_qcs_pkixQCSyntax_v1 = @as(c_int, 359);
+pub const OBJ_id_qcs_pkixQCSyntax_v1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 11);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_cct_crs = "id-cct-crs";
+pub const NID_id_cct_crs = @as(c_int, 360);
+pub const OBJ_id_cct_crs = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 12);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_cct_PKIData = "id-cct-PKIData";
+pub const NID_id_cct_PKIData = @as(c_int, 361);
+pub const OBJ_id_cct_PKIData = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 12);
+ break :blk @as(c_long, 2);
+};
+pub const SN_id_cct_PKIResponse = "id-cct-PKIResponse";
+pub const NID_id_cct_PKIResponse = @as(c_int, 362);
+pub const OBJ_id_cct_PKIResponse = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 12);
+ break :blk @as(c_long, 3);
+};
+pub const SN_ad_timeStamping = "ad_timestamping";
+pub const LN_ad_timeStamping = "AD Time Stamping";
+pub const NID_ad_timeStamping = @as(c_int, 363);
+pub const OBJ_ad_timeStamping = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 48);
+ break :blk @as(c_long, 3);
+};
+pub const SN_ad_dvcs = "AD_DVCS";
+pub const LN_ad_dvcs = "ad dvcs";
+pub const NID_ad_dvcs = @as(c_int, 364);
+pub const OBJ_ad_dvcs = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 48);
+ break :blk @as(c_long, 4);
+};
+pub const SN_id_pkix_OCSP_basic = "basicOCSPResponse";
+pub const LN_id_pkix_OCSP_basic = "Basic OCSP Response";
+pub const NID_id_pkix_OCSP_basic = @as(c_int, 365);
+pub const OBJ_id_pkix_OCSP_basic = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 48);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_pkix_OCSP_Nonce = "Nonce";
+pub const LN_id_pkix_OCSP_Nonce = "OCSP Nonce";
+pub const NID_id_pkix_OCSP_Nonce = @as(c_int, 366);
+pub const OBJ_id_pkix_OCSP_Nonce = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 48);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 2);
+};
+pub const SN_id_pkix_OCSP_CrlID = "CrlID";
+pub const LN_id_pkix_OCSP_CrlID = "OCSP CRL ID";
+pub const NID_id_pkix_OCSP_CrlID = @as(c_int, 367);
+pub const OBJ_id_pkix_OCSP_CrlID = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 48);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 3);
+};
+pub const SN_id_pkix_OCSP_acceptableResponses = "acceptableResponses";
+pub const LN_id_pkix_OCSP_acceptableResponses = "Acceptable OCSP Responses";
+pub const NID_id_pkix_OCSP_acceptableResponses = @as(c_int, 368);
+pub const OBJ_id_pkix_OCSP_acceptableResponses = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 48);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 4);
+};
+pub const SN_id_pkix_OCSP_noCheck = "noCheck";
+pub const LN_id_pkix_OCSP_noCheck = "OCSP No Check";
+pub const NID_id_pkix_OCSP_noCheck = @as(c_int, 369);
+pub const OBJ_id_pkix_OCSP_noCheck = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 48);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 5);
+};
+pub const SN_id_pkix_OCSP_archiveCutoff = "archiveCutoff";
+pub const LN_id_pkix_OCSP_archiveCutoff = "OCSP Archive Cutoff";
+pub const NID_id_pkix_OCSP_archiveCutoff = @as(c_int, 370);
+pub const OBJ_id_pkix_OCSP_archiveCutoff = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 48);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 6);
+};
+pub const SN_id_pkix_OCSP_serviceLocator = "serviceLocator";
+pub const LN_id_pkix_OCSP_serviceLocator = "OCSP Service Locator";
+pub const NID_id_pkix_OCSP_serviceLocator = @as(c_int, 371);
+pub const OBJ_id_pkix_OCSP_serviceLocator = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 48);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 7);
+};
+pub const SN_id_pkix_OCSP_extendedStatus = "extendedStatus";
+pub const LN_id_pkix_OCSP_extendedStatus = "Extended OCSP Status";
+pub const NID_id_pkix_OCSP_extendedStatus = @as(c_int, 372);
+pub const OBJ_id_pkix_OCSP_extendedStatus = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 48);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 8);
+};
+pub const SN_id_pkix_OCSP_valid = "valid";
+pub const NID_id_pkix_OCSP_valid = @as(c_int, 373);
+pub const OBJ_id_pkix_OCSP_valid = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 48);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 9);
+};
+pub const SN_id_pkix_OCSP_path = "path";
+pub const NID_id_pkix_OCSP_path = @as(c_int, 374);
+pub const OBJ_id_pkix_OCSP_path = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 48);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 10);
+};
+pub const SN_id_pkix_OCSP_trustRoot = "trustRoot";
+pub const LN_id_pkix_OCSP_trustRoot = "Trust Root";
+pub const NID_id_pkix_OCSP_trustRoot = @as(c_int, 375);
+pub const OBJ_id_pkix_OCSP_trustRoot = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 48);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 11);
+};
+pub const SN_algorithm = "algorithm";
+pub const LN_algorithm = "algorithm";
+pub const NID_algorithm = @as(c_int, 376);
+pub const OBJ_algorithm = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 14);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 2);
+};
+pub const SN_rsaSignature = "rsaSignature";
+pub const NID_rsaSignature = @as(c_int, 377);
+pub const OBJ_rsaSignature = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 14);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 11);
+};
+pub const SN_X500algorithms = "X500algorithms";
+pub const LN_X500algorithms = "directory services - algorithms";
+pub const NID_X500algorithms = @as(c_int, 378);
+pub const OBJ_X500algorithms = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ break :blk @as(c_long, 8);
+};
+pub const SN_org = "ORG";
+pub const LN_org = "org";
+pub const NID_org = @as(c_int, 379);
+pub const OBJ_org = blk: {
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 3);
+};
+pub const SN_dod = "DOD";
+pub const LN_dod = "dod";
+pub const NID_dod = @as(c_int, 380);
+pub const OBJ_dod = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 6);
+};
+pub const SN_iana = "IANA";
+pub const LN_iana = "iana";
+pub const NID_iana = @as(c_int, 381);
+pub const OBJ_iana = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ break :blk @as(c_long, 1);
+};
+pub const SN_Directory = "directory";
+pub const LN_Directory = "Directory";
+pub const NID_Directory = @as(c_int, 382);
+pub const OBJ_Directory = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 1);
+};
+pub const SN_Management = "mgmt";
+pub const LN_Management = "Management";
+pub const NID_Management = @as(c_int, 383);
+pub const OBJ_Management = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 2);
+};
+pub const SN_Experimental = "experimental";
+pub const LN_Experimental = "Experimental";
+pub const NID_Experimental = @as(c_int, 384);
+pub const OBJ_Experimental = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 3);
+};
+pub const SN_Private = "private";
+pub const LN_Private = "Private";
+pub const NID_Private = @as(c_int, 385);
+pub const OBJ_Private = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 4);
+};
+pub const SN_Security = "security";
+pub const LN_Security = "Security";
+pub const NID_Security = @as(c_int, 386);
+pub const OBJ_Security = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 5);
+};
+pub const SN_SNMPv2 = "snmpv2";
+pub const LN_SNMPv2 = "SNMPv2";
+pub const NID_SNMPv2 = @as(c_int, 387);
+pub const OBJ_SNMPv2 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 6);
+};
+pub const LN_Mail = "Mail";
+pub const NID_Mail = @as(c_int, 388);
+pub const OBJ_Mail = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 7);
+};
+pub const SN_Enterprises = "enterprises";
+pub const LN_Enterprises = "Enterprises";
+pub const NID_Enterprises = @as(c_int, 389);
+pub const OBJ_Enterprises = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 1);
+};
+pub const SN_dcObject = "dcobject";
+pub const LN_dcObject = "dcObject";
+pub const NID_dcObject = @as(c_int, 390);
+pub const OBJ_dcObject = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1466);
+ break :blk @as(c_long, 344);
+};
+pub const SN_domainComponent = "DC";
+pub const LN_domainComponent = "domainComponent";
+pub const NID_domainComponent = @as(c_int, 391);
+pub const OBJ_domainComponent = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 25);
+};
+pub const SN_Domain = "domain";
+pub const LN_Domain = "Domain";
+pub const NID_Domain = @as(c_int, 392);
+pub const OBJ_Domain = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 13);
+};
+pub const SN_selected_attribute_types = "selected-attribute-types";
+pub const LN_selected_attribute_types = "Selected Attribute Types";
+pub const NID_selected_attribute_types = @as(c_int, 394);
+pub const OBJ_selected_attribute_types = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 5);
+};
+pub const SN_clearance = "clearance";
+pub const NID_clearance = @as(c_int, 395);
+pub const OBJ_clearance = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ break :blk @as(c_long, 55);
+};
+pub const SN_md4WithRSAEncryption = "RSA-MD4";
+pub const LN_md4WithRSAEncryption = "md4WithRSAEncryption";
+pub const NID_md4WithRSAEncryption = @as(c_int, 396);
+pub const OBJ_md4WithRSAEncryption = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 3);
+};
+pub const SN_ac_proxying = "ac-proxying";
+pub const NID_ac_proxying = @as(c_int, 397);
+pub const OBJ_ac_proxying = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 10);
+};
+pub const SN_sinfo_access = "subjectInfoAccess";
+pub const LN_sinfo_access = "Subject Information Access";
+pub const NID_sinfo_access = @as(c_int, 398);
+pub const OBJ_sinfo_access = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 11);
+};
+pub const SN_id_aca_encAttrs = "id-aca-encAttrs";
+pub const NID_id_aca_encAttrs = @as(c_int, 399);
+pub const OBJ_id_aca_encAttrs = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 10);
+ break :blk @as(c_long, 6);
+};
+pub const SN_role = "role";
+pub const LN_role = "role";
+pub const NID_role = @as(c_int, 400);
+pub const OBJ_role = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 72);
+};
+pub const SN_policy_constraints = "policyConstraints";
+pub const LN_policy_constraints = "X509v3 Policy Constraints";
+pub const NID_policy_constraints = @as(c_int, 401);
+pub const OBJ_policy_constraints = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 29);
+ break :blk @as(c_long, 36);
+};
+pub const SN_target_information = "targetInformation";
+pub const LN_target_information = "X509v3 AC Targeting";
+pub const NID_target_information = @as(c_int, 402);
+pub const OBJ_target_information = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 29);
+ break :blk @as(c_long, 55);
+};
+pub const SN_no_rev_avail = "noRevAvail";
+pub const LN_no_rev_avail = "X509v3 No Revocation Available";
+pub const NID_no_rev_avail = @as(c_int, 403);
+pub const OBJ_no_rev_avail = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 29);
+ break :blk @as(c_long, 56);
+};
+pub const SN_ansi_X9_62 = "ansi-X9-62";
+pub const LN_ansi_X9_62 = "ANSI X9.62";
+pub const NID_ansi_X9_62 = @as(c_int, 405);
+pub const OBJ_ansi_X9_62 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ break :blk @as(c_long, 10045);
+};
+pub const SN_X9_62_prime_field = "prime-field";
+pub const NID_X9_62_prime_field = @as(c_int, 406);
+pub const OBJ_X9_62_prime_field = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 1);
+};
+pub const SN_X9_62_characteristic_two_field = "characteristic-two-field";
+pub const NID_X9_62_characteristic_two_field = @as(c_int, 407);
+pub const OBJ_X9_62_characteristic_two_field = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 2);
+};
+pub const SN_X9_62_id_ecPublicKey = "id-ecPublicKey";
+pub const NID_X9_62_id_ecPublicKey = @as(c_int, 408);
+pub const OBJ_X9_62_id_ecPublicKey = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 1);
+};
+pub const SN_X9_62_prime192v1 = "prime192v1";
+pub const NID_X9_62_prime192v1 = @as(c_int, 409);
+pub const OBJ_X9_62_prime192v1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 1);
+};
+pub const SN_X9_62_prime192v2 = "prime192v2";
+pub const NID_X9_62_prime192v2 = @as(c_int, 410);
+pub const OBJ_X9_62_prime192v2 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 2);
+};
+pub const SN_X9_62_prime192v3 = "prime192v3";
+pub const NID_X9_62_prime192v3 = @as(c_int, 411);
+pub const OBJ_X9_62_prime192v3 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 3);
+};
+pub const SN_X9_62_prime239v1 = "prime239v1";
+pub const NID_X9_62_prime239v1 = @as(c_int, 412);
+pub const OBJ_X9_62_prime239v1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 4);
+};
+pub const SN_X9_62_prime239v2 = "prime239v2";
+pub const NID_X9_62_prime239v2 = @as(c_int, 413);
+pub const OBJ_X9_62_prime239v2 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 5);
+};
+pub const SN_X9_62_prime239v3 = "prime239v3";
+pub const NID_X9_62_prime239v3 = @as(c_int, 414);
+pub const OBJ_X9_62_prime239v3 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 6);
+};
+pub const SN_X9_62_prime256v1 = "prime256v1";
+pub const NID_X9_62_prime256v1 = @as(c_int, 415);
+pub const OBJ_X9_62_prime256v1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 7);
+};
+pub const SN_ecdsa_with_SHA1 = "ecdsa-with-SHA1";
+pub const NID_ecdsa_with_SHA1 = @as(c_int, 416);
+pub const OBJ_ecdsa_with_SHA1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 1);
+};
+pub const SN_ms_csp_name = "CSPName";
+pub const LN_ms_csp_name = "Microsoft CSP Name";
+pub const NID_ms_csp_name = @as(c_int, 417);
+pub const OBJ_ms_csp_name = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 311);
+ _ = @as(c_long, 17);
+ break :blk @as(c_long, 1);
+};
+pub const SN_aes_128_ecb = "AES-128-ECB";
+pub const LN_aes_128_ecb = "aes-128-ecb";
+pub const NID_aes_128_ecb = @as(c_int, 418);
+pub const OBJ_aes_128_ecb = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 1);
+};
+pub const SN_aes_128_cbc = "AES-128-CBC";
+pub const LN_aes_128_cbc = "aes-128-cbc";
+pub const NID_aes_128_cbc = @as(c_int, 419);
+pub const OBJ_aes_128_cbc = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 2);
+};
+pub const SN_aes_128_ofb128 = "AES-128-OFB";
+pub const LN_aes_128_ofb128 = "aes-128-ofb";
+pub const NID_aes_128_ofb128 = @as(c_int, 420);
+pub const OBJ_aes_128_ofb128 = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 3);
+};
+pub const SN_aes_128_cfb128 = "AES-128-CFB";
+pub const LN_aes_128_cfb128 = "aes-128-cfb";
+pub const NID_aes_128_cfb128 = @as(c_int, 421);
+pub const OBJ_aes_128_cfb128 = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 4);
+};
+pub const SN_aes_192_ecb = "AES-192-ECB";
+pub const LN_aes_192_ecb = "aes-192-ecb";
+pub const NID_aes_192_ecb = @as(c_int, 422);
+pub const OBJ_aes_192_ecb = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 21);
+};
+pub const SN_aes_192_cbc = "AES-192-CBC";
+pub const LN_aes_192_cbc = "aes-192-cbc";
+pub const NID_aes_192_cbc = @as(c_int, 423);
+pub const OBJ_aes_192_cbc = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 22);
+};
+pub const SN_aes_192_ofb128 = "AES-192-OFB";
+pub const LN_aes_192_ofb128 = "aes-192-ofb";
+pub const NID_aes_192_ofb128 = @as(c_int, 424);
+pub const OBJ_aes_192_ofb128 = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 23);
+};
+pub const SN_aes_192_cfb128 = "AES-192-CFB";
+pub const LN_aes_192_cfb128 = "aes-192-cfb";
+pub const NID_aes_192_cfb128 = @as(c_int, 425);
+pub const OBJ_aes_192_cfb128 = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 24);
+};
+pub const SN_aes_256_ecb = "AES-256-ECB";
+pub const LN_aes_256_ecb = "aes-256-ecb";
+pub const NID_aes_256_ecb = @as(c_int, 426);
+pub const OBJ_aes_256_ecb = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 41);
+};
+pub const SN_aes_256_cbc = "AES-256-CBC";
+pub const LN_aes_256_cbc = "aes-256-cbc";
+pub const NID_aes_256_cbc = @as(c_int, 427);
+pub const OBJ_aes_256_cbc = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 42);
+};
+pub const SN_aes_256_ofb128 = "AES-256-OFB";
+pub const LN_aes_256_ofb128 = "aes-256-ofb";
+pub const NID_aes_256_ofb128 = @as(c_int, 428);
+pub const OBJ_aes_256_ofb128 = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 43);
+};
+pub const SN_aes_256_cfb128 = "AES-256-CFB";
+pub const LN_aes_256_cfb128 = "aes-256-cfb";
+pub const NID_aes_256_cfb128 = @as(c_int, 429);
+pub const OBJ_aes_256_cfb128 = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 44);
+};
+pub const SN_hold_instruction_code = "holdInstructionCode";
+pub const LN_hold_instruction_code = "Hold Instruction Code";
+pub const NID_hold_instruction_code = @as(c_int, 430);
+pub const OBJ_hold_instruction_code = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 29);
+ break :blk @as(c_long, 23);
+};
+pub const SN_hold_instruction_none = "holdInstructionNone";
+pub const LN_hold_instruction_none = "Hold Instruction None";
+pub const NID_hold_instruction_none = @as(c_int, 431);
+pub const OBJ_hold_instruction_none = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10040);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 1);
+};
+pub const SN_hold_instruction_call_issuer = "holdInstructionCallIssuer";
+pub const LN_hold_instruction_call_issuer = "Hold Instruction Call Issuer";
+pub const NID_hold_instruction_call_issuer = @as(c_int, 432);
+pub const OBJ_hold_instruction_call_issuer = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10040);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 2);
+};
+pub const SN_hold_instruction_reject = "holdInstructionReject";
+pub const LN_hold_instruction_reject = "Hold Instruction Reject";
+pub const NID_hold_instruction_reject = @as(c_int, 433);
+pub const OBJ_hold_instruction_reject = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10040);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 3);
+};
+pub const SN_data = "data";
+pub const NID_data = @as(c_int, 434);
+pub const OBJ_data = blk: {
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 9);
+};
+pub const SN_pss = "pss";
+pub const NID_pss = @as(c_int, 435);
+pub const OBJ_pss = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ break :blk @as(c_long, 2342);
+};
+pub const SN_ucl = "ucl";
+pub const NID_ucl = @as(c_int, 436);
+pub const OBJ_ucl = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ break :blk @as(c_long, 19200300);
+};
+pub const SN_pilot = "pilot";
+pub const NID_pilot = @as(c_int, 437);
+pub const OBJ_pilot = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ break :blk @as(c_long, 100);
+};
+pub const LN_pilotAttributeType = "pilotAttributeType";
+pub const NID_pilotAttributeType = @as(c_int, 438);
+pub const OBJ_pilotAttributeType = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ break :blk @as(c_long, 1);
+};
+pub const LN_pilotAttributeSyntax = "pilotAttributeSyntax";
+pub const NID_pilotAttributeSyntax = @as(c_int, 439);
+pub const OBJ_pilotAttributeSyntax = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ break :blk @as(c_long, 3);
+};
+pub const LN_pilotObjectClass = "pilotObjectClass";
+pub const NID_pilotObjectClass = @as(c_int, 440);
+pub const OBJ_pilotObjectClass = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ break :blk @as(c_long, 4);
+};
+pub const LN_pilotGroups = "pilotGroups";
+pub const NID_pilotGroups = @as(c_int, 441);
+pub const OBJ_pilotGroups = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ break :blk @as(c_long, 10);
+};
+pub const LN_iA5StringSyntax = "iA5StringSyntax";
+pub const NID_iA5StringSyntax = @as(c_int, 442);
+pub const OBJ_iA5StringSyntax = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 4);
+};
+pub const LN_caseIgnoreIA5StringSyntax = "caseIgnoreIA5StringSyntax";
+pub const NID_caseIgnoreIA5StringSyntax = @as(c_int, 443);
+pub const OBJ_caseIgnoreIA5StringSyntax = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 5);
+};
+pub const LN_pilotObject = "pilotObject";
+pub const NID_pilotObject = @as(c_int, 444);
+pub const OBJ_pilotObject = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 3);
+};
+pub const LN_pilotPerson = "pilotPerson";
+pub const NID_pilotPerson = @as(c_int, 445);
+pub const OBJ_pilotPerson = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 4);
+};
+pub const SN_account = "account";
+pub const NID_account = @as(c_int, 446);
+pub const OBJ_account = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 5);
+};
+pub const SN_document = "document";
+pub const NID_document = @as(c_int, 447);
+pub const OBJ_document = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 6);
+};
+pub const SN_room = "room";
+pub const NID_room = @as(c_int, 448);
+pub const OBJ_room = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 7);
+};
+pub const LN_documentSeries = "documentSeries";
+pub const NID_documentSeries = @as(c_int, 449);
+pub const OBJ_documentSeries = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 9);
+};
+pub const LN_rFC822localPart = "rFC822localPart";
+pub const NID_rFC822localPart = @as(c_int, 450);
+pub const OBJ_rFC822localPart = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 14);
+};
+pub const LN_dNSDomain = "dNSDomain";
+pub const NID_dNSDomain = @as(c_int, 451);
+pub const OBJ_dNSDomain = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 15);
+};
+pub const LN_domainRelatedObject = "domainRelatedObject";
+pub const NID_domainRelatedObject = @as(c_int, 452);
+pub const OBJ_domainRelatedObject = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 17);
+};
+pub const LN_friendlyCountry = "friendlyCountry";
+pub const NID_friendlyCountry = @as(c_int, 453);
+pub const OBJ_friendlyCountry = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 18);
+};
+pub const LN_simpleSecurityObject = "simpleSecurityObject";
+pub const NID_simpleSecurityObject = @as(c_int, 454);
+pub const OBJ_simpleSecurityObject = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 19);
+};
+pub const LN_pilotOrganization = "pilotOrganization";
+pub const NID_pilotOrganization = @as(c_int, 455);
+pub const OBJ_pilotOrganization = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 20);
+};
+pub const LN_pilotDSA = "pilotDSA";
+pub const NID_pilotDSA = @as(c_int, 456);
+pub const OBJ_pilotDSA = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 21);
+};
+pub const LN_qualityLabelledData = "qualityLabelledData";
+pub const NID_qualityLabelledData = @as(c_int, 457);
+pub const OBJ_qualityLabelledData = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 22);
+};
+pub const SN_userId = "UID";
+pub const LN_userId = "userId";
+pub const NID_userId = @as(c_int, 458);
+pub const OBJ_userId = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 1);
+};
+pub const LN_textEncodedORAddress = "textEncodedORAddress";
+pub const NID_textEncodedORAddress = @as(c_int, 459);
+pub const OBJ_textEncodedORAddress = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 2);
+};
+pub const SN_rfc822Mailbox = "mail";
+pub const LN_rfc822Mailbox = "rfc822Mailbox";
+pub const NID_rfc822Mailbox = @as(c_int, 460);
+pub const OBJ_rfc822Mailbox = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 3);
+};
+pub const SN_info = "info";
+pub const NID_info = @as(c_int, 461);
+pub const OBJ_info = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 4);
+};
+pub const LN_favouriteDrink = "favouriteDrink";
+pub const NID_favouriteDrink = @as(c_int, 462);
+pub const OBJ_favouriteDrink = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 5);
+};
+pub const LN_roomNumber = "roomNumber";
+pub const NID_roomNumber = @as(c_int, 463);
+pub const OBJ_roomNumber = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 6);
+};
+pub const SN_photo = "photo";
+pub const NID_photo = @as(c_int, 464);
+pub const OBJ_photo = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 7);
+};
+pub const LN_userClass = "userClass";
+pub const NID_userClass = @as(c_int, 465);
+pub const OBJ_userClass = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 8);
+};
+pub const SN_host = "host";
+pub const NID_host = @as(c_int, 466);
+pub const OBJ_host = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 9);
+};
+pub const SN_manager = "manager";
+pub const NID_manager = @as(c_int, 467);
+pub const OBJ_manager = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 10);
+};
+pub const LN_documentIdentifier = "documentIdentifier";
+pub const NID_documentIdentifier = @as(c_int, 468);
+pub const OBJ_documentIdentifier = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 11);
+};
+pub const LN_documentTitle = "documentTitle";
+pub const NID_documentTitle = @as(c_int, 469);
+pub const OBJ_documentTitle = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 12);
+};
+pub const LN_documentVersion = "documentVersion";
+pub const NID_documentVersion = @as(c_int, 470);
+pub const OBJ_documentVersion = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 13);
+};
+pub const LN_documentAuthor = "documentAuthor";
+pub const NID_documentAuthor = @as(c_int, 471);
+pub const OBJ_documentAuthor = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 14);
+};
+pub const LN_documentLocation = "documentLocation";
+pub const NID_documentLocation = @as(c_int, 472);
+pub const OBJ_documentLocation = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 15);
+};
+pub const LN_homeTelephoneNumber = "homeTelephoneNumber";
+pub const NID_homeTelephoneNumber = @as(c_int, 473);
+pub const OBJ_homeTelephoneNumber = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 20);
+};
+pub const SN_secretary = "secretary";
+pub const NID_secretary = @as(c_int, 474);
+pub const OBJ_secretary = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 21);
+};
+pub const LN_otherMailbox = "otherMailbox";
+pub const NID_otherMailbox = @as(c_int, 475);
+pub const OBJ_otherMailbox = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 22);
+};
+pub const LN_lastModifiedTime = "lastModifiedTime";
+pub const NID_lastModifiedTime = @as(c_int, 476);
+pub const OBJ_lastModifiedTime = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 23);
+};
+pub const LN_lastModifiedBy = "lastModifiedBy";
+pub const NID_lastModifiedBy = @as(c_int, 477);
+pub const OBJ_lastModifiedBy = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 24);
+};
+pub const LN_aRecord = "aRecord";
+pub const NID_aRecord = @as(c_int, 478);
+pub const OBJ_aRecord = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 26);
+};
+pub const LN_pilotAttributeType27 = "pilotAttributeType27";
+pub const NID_pilotAttributeType27 = @as(c_int, 479);
+pub const OBJ_pilotAttributeType27 = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 27);
+};
+pub const LN_mXRecord = "mXRecord";
+pub const NID_mXRecord = @as(c_int, 480);
+pub const OBJ_mXRecord = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 28);
+};
+pub const LN_nSRecord = "nSRecord";
+pub const NID_nSRecord = @as(c_int, 481);
+pub const OBJ_nSRecord = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 29);
+};
+pub const LN_sOARecord = "sOARecord";
+pub const NID_sOARecord = @as(c_int, 482);
+pub const OBJ_sOARecord = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 30);
+};
+pub const LN_cNAMERecord = "cNAMERecord";
+pub const NID_cNAMERecord = @as(c_int, 483);
+pub const OBJ_cNAMERecord = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 31);
+};
+pub const LN_associatedDomain = "associatedDomain";
+pub const NID_associatedDomain = @as(c_int, 484);
+pub const OBJ_associatedDomain = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 37);
+};
+pub const LN_associatedName = "associatedName";
+pub const NID_associatedName = @as(c_int, 485);
+pub const OBJ_associatedName = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 38);
+};
+pub const LN_homePostalAddress = "homePostalAddress";
+pub const NID_homePostalAddress = @as(c_int, 486);
+pub const OBJ_homePostalAddress = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 39);
+};
+pub const LN_personalTitle = "personalTitle";
+pub const NID_personalTitle = @as(c_int, 487);
+pub const OBJ_personalTitle = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 40);
+};
+pub const LN_mobileTelephoneNumber = "mobileTelephoneNumber";
+pub const NID_mobileTelephoneNumber = @as(c_int, 488);
+pub const OBJ_mobileTelephoneNumber = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 41);
+};
+pub const LN_pagerTelephoneNumber = "pagerTelephoneNumber";
+pub const NID_pagerTelephoneNumber = @as(c_int, 489);
+pub const OBJ_pagerTelephoneNumber = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 42);
+};
+pub const LN_friendlyCountryName = "friendlyCountryName";
+pub const NID_friendlyCountryName = @as(c_int, 490);
+pub const OBJ_friendlyCountryName = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 43);
+};
+pub const LN_organizationalStatus = "organizationalStatus";
+pub const NID_organizationalStatus = @as(c_int, 491);
+pub const OBJ_organizationalStatus = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 45);
+};
+pub const LN_janetMailbox = "janetMailbox";
+pub const NID_janetMailbox = @as(c_int, 492);
+pub const OBJ_janetMailbox = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 46);
+};
+pub const LN_mailPreferenceOption = "mailPreferenceOption";
+pub const NID_mailPreferenceOption = @as(c_int, 493);
+pub const OBJ_mailPreferenceOption = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 47);
+};
+pub const LN_buildingName = "buildingName";
+pub const NID_buildingName = @as(c_int, 494);
+pub const OBJ_buildingName = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 48);
+};
+pub const LN_dSAQuality = "dSAQuality";
+pub const NID_dSAQuality = @as(c_int, 495);
+pub const OBJ_dSAQuality = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 49);
+};
+pub const LN_singleLevelQuality = "singleLevelQuality";
+pub const NID_singleLevelQuality = @as(c_int, 496);
+pub const OBJ_singleLevelQuality = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 50);
+};
+pub const LN_subtreeMinimumQuality = "subtreeMinimumQuality";
+pub const NID_subtreeMinimumQuality = @as(c_int, 497);
+pub const OBJ_subtreeMinimumQuality = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 51);
+};
+pub const LN_subtreeMaximumQuality = "subtreeMaximumQuality";
+pub const NID_subtreeMaximumQuality = @as(c_int, 498);
+pub const OBJ_subtreeMaximumQuality = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 52);
+};
+pub const LN_personalSignature = "personalSignature";
+pub const NID_personalSignature = @as(c_int, 499);
+pub const OBJ_personalSignature = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 53);
+};
+pub const LN_dITRedirect = "dITRedirect";
+pub const NID_dITRedirect = @as(c_int, 500);
+pub const OBJ_dITRedirect = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 54);
+};
+pub const SN_audio = "audio";
+pub const NID_audio = @as(c_int, 501);
+pub const OBJ_audio = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 55);
+};
+pub const LN_documentPublisher = "documentPublisher";
+pub const NID_documentPublisher = @as(c_int, 502);
+pub const OBJ_documentPublisher = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 2342);
+ _ = @as(c_long, 19200300);
+ _ = @as(c_long, 100);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 56);
+};
+pub const LN_x500UniqueIdentifier = "x500UniqueIdentifier";
+pub const NID_x500UniqueIdentifier = @as(c_int, 503);
+pub const OBJ_x500UniqueIdentifier = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 45);
+};
+pub const SN_mime_mhs = "mime-mhs";
+pub const LN_mime_mhs = "MIME MHS";
+pub const NID_mime_mhs = @as(c_int, 504);
+pub const OBJ_mime_mhs = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 1);
+};
+pub const SN_mime_mhs_headings = "mime-mhs-headings";
+pub const LN_mime_mhs_headings = "mime-mhs-headings";
+pub const NID_mime_mhs_headings = @as(c_int, 505);
+pub const OBJ_mime_mhs_headings = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 1);
+};
+pub const SN_mime_mhs_bodies = "mime-mhs-bodies";
+pub const LN_mime_mhs_bodies = "mime-mhs-bodies";
+pub const NID_mime_mhs_bodies = @as(c_int, 506);
+pub const OBJ_mime_mhs_bodies = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 2);
+};
+pub const SN_id_hex_partial_message = "id-hex-partial-message";
+pub const LN_id_hex_partial_message = "id-hex-partial-message";
+pub const NID_id_hex_partial_message = @as(c_int, 507);
+pub const OBJ_id_hex_partial_message = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_hex_multipart_message = "id-hex-multipart-message";
+pub const LN_id_hex_multipart_message = "id-hex-multipart-message";
+pub const NID_id_hex_multipart_message = @as(c_int, 508);
+pub const OBJ_id_hex_multipart_message = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 2);
+};
+pub const LN_generationQualifier = "generationQualifier";
+pub const NID_generationQualifier = @as(c_int, 509);
+pub const OBJ_generationQualifier = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 44);
+};
+pub const LN_pseudonym = "pseudonym";
+pub const NID_pseudonym = @as(c_int, 510);
+pub const OBJ_pseudonym = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 65);
+};
+pub const SN_id_set = "id-set";
+pub const LN_id_set = "Secure Electronic Transactions";
+pub const NID_id_set = @as(c_int, 512);
+pub const OBJ_id_set = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ break :blk @as(c_long, 42);
+};
+pub const SN_set_ctype = "set-ctype";
+pub const LN_set_ctype = "content types";
+pub const NID_set_ctype = @as(c_int, 513);
+pub const OBJ_set_ctype = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ break :blk @as(c_long, 0);
+};
+pub const SN_set_msgExt = "set-msgExt";
+pub const LN_set_msgExt = "message extensions";
+pub const NID_set_msgExt = @as(c_int, 514);
+pub const OBJ_set_msgExt = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ break :blk @as(c_long, 1);
+};
+pub const SN_set_attr = "set-attr";
+pub const NID_set_attr = @as(c_int, 515);
+pub const OBJ_set_attr = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ break :blk @as(c_long, 3);
+};
+pub const SN_set_policy = "set-policy";
+pub const NID_set_policy = @as(c_int, 516);
+pub const OBJ_set_policy = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ break :blk @as(c_long, 5);
+};
+pub const SN_set_certExt = "set-certExt";
+pub const LN_set_certExt = "certificate extensions";
+pub const NID_set_certExt = @as(c_int, 517);
+pub const OBJ_set_certExt = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ break :blk @as(c_long, 7);
+};
+pub const SN_set_brand = "set-brand";
+pub const NID_set_brand = @as(c_int, 518);
+pub const OBJ_set_brand = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ break :blk @as(c_long, 8);
+};
+pub const SN_setct_PANData = "setct-PANData";
+pub const NID_setct_PANData = @as(c_int, 519);
+pub const OBJ_setct_PANData = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 0);
+};
+pub const SN_setct_PANToken = "setct-PANToken";
+pub const NID_setct_PANToken = @as(c_int, 520);
+pub const OBJ_setct_PANToken = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 1);
+};
+pub const SN_setct_PANOnly = "setct-PANOnly";
+pub const NID_setct_PANOnly = @as(c_int, 521);
+pub const OBJ_setct_PANOnly = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 2);
+};
+pub const SN_setct_OIData = "setct-OIData";
+pub const NID_setct_OIData = @as(c_int, 522);
+pub const OBJ_setct_OIData = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 3);
+};
+pub const SN_setct_PI = "setct-PI";
+pub const NID_setct_PI = @as(c_int, 523);
+pub const OBJ_setct_PI = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 4);
+};
+pub const SN_setct_PIData = "setct-PIData";
+pub const NID_setct_PIData = @as(c_int, 524);
+pub const OBJ_setct_PIData = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 5);
+};
+pub const SN_setct_PIDataUnsigned = "setct-PIDataUnsigned";
+pub const NID_setct_PIDataUnsigned = @as(c_int, 525);
+pub const OBJ_setct_PIDataUnsigned = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 6);
+};
+pub const SN_setct_HODInput = "setct-HODInput";
+pub const NID_setct_HODInput = @as(c_int, 526);
+pub const OBJ_setct_HODInput = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 7);
+};
+pub const SN_setct_AuthResBaggage = "setct-AuthResBaggage";
+pub const NID_setct_AuthResBaggage = @as(c_int, 527);
+pub const OBJ_setct_AuthResBaggage = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 8);
+};
+pub const SN_setct_AuthRevReqBaggage = "setct-AuthRevReqBaggage";
+pub const NID_setct_AuthRevReqBaggage = @as(c_int, 528);
+pub const OBJ_setct_AuthRevReqBaggage = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 9);
+};
+pub const SN_setct_AuthRevResBaggage = "setct-AuthRevResBaggage";
+pub const NID_setct_AuthRevResBaggage = @as(c_int, 529);
+pub const OBJ_setct_AuthRevResBaggage = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 10);
+};
+pub const SN_setct_CapTokenSeq = "setct-CapTokenSeq";
+pub const NID_setct_CapTokenSeq = @as(c_int, 530);
+pub const OBJ_setct_CapTokenSeq = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 11);
+};
+pub const SN_setct_PInitResData = "setct-PInitResData";
+pub const NID_setct_PInitResData = @as(c_int, 531);
+pub const OBJ_setct_PInitResData = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 12);
+};
+pub const SN_setct_PI_TBS = "setct-PI-TBS";
+pub const NID_setct_PI_TBS = @as(c_int, 532);
+pub const OBJ_setct_PI_TBS = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 13);
+};
+pub const SN_setct_PResData = "setct-PResData";
+pub const NID_setct_PResData = @as(c_int, 533);
+pub const OBJ_setct_PResData = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 14);
+};
+pub const SN_setct_AuthReqTBS = "setct-AuthReqTBS";
+pub const NID_setct_AuthReqTBS = @as(c_int, 534);
+pub const OBJ_setct_AuthReqTBS = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 16);
+};
+pub const SN_setct_AuthResTBS = "setct-AuthResTBS";
+pub const NID_setct_AuthResTBS = @as(c_int, 535);
+pub const OBJ_setct_AuthResTBS = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 17);
+};
+pub const SN_setct_AuthResTBSX = "setct-AuthResTBSX";
+pub const NID_setct_AuthResTBSX = @as(c_int, 536);
+pub const OBJ_setct_AuthResTBSX = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 18);
+};
+pub const SN_setct_AuthTokenTBS = "setct-AuthTokenTBS";
+pub const NID_setct_AuthTokenTBS = @as(c_int, 537);
+pub const OBJ_setct_AuthTokenTBS = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 19);
+};
+pub const SN_setct_CapTokenData = "setct-CapTokenData";
+pub const NID_setct_CapTokenData = @as(c_int, 538);
+pub const OBJ_setct_CapTokenData = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 20);
+};
+pub const SN_setct_CapTokenTBS = "setct-CapTokenTBS";
+pub const NID_setct_CapTokenTBS = @as(c_int, 539);
+pub const OBJ_setct_CapTokenTBS = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 21);
+};
+pub const SN_setct_AcqCardCodeMsg = "setct-AcqCardCodeMsg";
+pub const NID_setct_AcqCardCodeMsg = @as(c_int, 540);
+pub const OBJ_setct_AcqCardCodeMsg = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 22);
+};
+pub const SN_setct_AuthRevReqTBS = "setct-AuthRevReqTBS";
+pub const NID_setct_AuthRevReqTBS = @as(c_int, 541);
+pub const OBJ_setct_AuthRevReqTBS = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 23);
+};
+pub const SN_setct_AuthRevResData = "setct-AuthRevResData";
+pub const NID_setct_AuthRevResData = @as(c_int, 542);
+pub const OBJ_setct_AuthRevResData = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 24);
+};
+pub const SN_setct_AuthRevResTBS = "setct-AuthRevResTBS";
+pub const NID_setct_AuthRevResTBS = @as(c_int, 543);
+pub const OBJ_setct_AuthRevResTBS = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 25);
+};
+pub const SN_setct_CapReqTBS = "setct-CapReqTBS";
+pub const NID_setct_CapReqTBS = @as(c_int, 544);
+pub const OBJ_setct_CapReqTBS = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 26);
+};
+pub const SN_setct_CapReqTBSX = "setct-CapReqTBSX";
+pub const NID_setct_CapReqTBSX = @as(c_int, 545);
+pub const OBJ_setct_CapReqTBSX = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 27);
+};
+pub const SN_setct_CapResData = "setct-CapResData";
+pub const NID_setct_CapResData = @as(c_int, 546);
+pub const OBJ_setct_CapResData = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 28);
+};
+pub const SN_setct_CapRevReqTBS = "setct-CapRevReqTBS";
+pub const NID_setct_CapRevReqTBS = @as(c_int, 547);
+pub const OBJ_setct_CapRevReqTBS = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 29);
+};
+pub const SN_setct_CapRevReqTBSX = "setct-CapRevReqTBSX";
+pub const NID_setct_CapRevReqTBSX = @as(c_int, 548);
+pub const OBJ_setct_CapRevReqTBSX = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 30);
+};
+pub const SN_setct_CapRevResData = "setct-CapRevResData";
+pub const NID_setct_CapRevResData = @as(c_int, 549);
+pub const OBJ_setct_CapRevResData = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 31);
+};
+pub const SN_setct_CredReqTBS = "setct-CredReqTBS";
+pub const NID_setct_CredReqTBS = @as(c_int, 550);
+pub const OBJ_setct_CredReqTBS = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 32);
+};
+pub const SN_setct_CredReqTBSX = "setct-CredReqTBSX";
+pub const NID_setct_CredReqTBSX = @as(c_int, 551);
+pub const OBJ_setct_CredReqTBSX = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 33);
+};
+pub const SN_setct_CredResData = "setct-CredResData";
+pub const NID_setct_CredResData = @as(c_int, 552);
+pub const OBJ_setct_CredResData = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 34);
+};
+pub const SN_setct_CredRevReqTBS = "setct-CredRevReqTBS";
+pub const NID_setct_CredRevReqTBS = @as(c_int, 553);
+pub const OBJ_setct_CredRevReqTBS = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 35);
+};
+pub const SN_setct_CredRevReqTBSX = "setct-CredRevReqTBSX";
+pub const NID_setct_CredRevReqTBSX = @as(c_int, 554);
+pub const OBJ_setct_CredRevReqTBSX = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 36);
+};
+pub const SN_setct_CredRevResData = "setct-CredRevResData";
+pub const NID_setct_CredRevResData = @as(c_int, 555);
+pub const OBJ_setct_CredRevResData = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 37);
+};
+pub const SN_setct_PCertReqData = "setct-PCertReqData";
+pub const NID_setct_PCertReqData = @as(c_int, 556);
+pub const OBJ_setct_PCertReqData = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 38);
+};
+pub const SN_setct_PCertResTBS = "setct-PCertResTBS";
+pub const NID_setct_PCertResTBS = @as(c_int, 557);
+pub const OBJ_setct_PCertResTBS = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 39);
+};
+pub const SN_setct_BatchAdminReqData = "setct-BatchAdminReqData";
+pub const NID_setct_BatchAdminReqData = @as(c_int, 558);
+pub const OBJ_setct_BatchAdminReqData = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 40);
+};
+pub const SN_setct_BatchAdminResData = "setct-BatchAdminResData";
+pub const NID_setct_BatchAdminResData = @as(c_int, 559);
+pub const OBJ_setct_BatchAdminResData = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 41);
+};
+pub const SN_setct_CardCInitResTBS = "setct-CardCInitResTBS";
+pub const NID_setct_CardCInitResTBS = @as(c_int, 560);
+pub const OBJ_setct_CardCInitResTBS = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 42);
+};
+pub const SN_setct_MeAqCInitResTBS = "setct-MeAqCInitResTBS";
+pub const NID_setct_MeAqCInitResTBS = @as(c_int, 561);
+pub const OBJ_setct_MeAqCInitResTBS = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 43);
+};
+pub const SN_setct_RegFormResTBS = "setct-RegFormResTBS";
+pub const NID_setct_RegFormResTBS = @as(c_int, 562);
+pub const OBJ_setct_RegFormResTBS = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 44);
+};
+pub const SN_setct_CertReqData = "setct-CertReqData";
+pub const NID_setct_CertReqData = @as(c_int, 563);
+pub const OBJ_setct_CertReqData = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 45);
+};
+pub const SN_setct_CertReqTBS = "setct-CertReqTBS";
+pub const NID_setct_CertReqTBS = @as(c_int, 564);
+pub const OBJ_setct_CertReqTBS = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 46);
+};
+pub const SN_setct_CertResData = "setct-CertResData";
+pub const NID_setct_CertResData = @as(c_int, 565);
+pub const OBJ_setct_CertResData = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 47);
+};
+pub const SN_setct_CertInqReqTBS = "setct-CertInqReqTBS";
+pub const NID_setct_CertInqReqTBS = @as(c_int, 566);
+pub const OBJ_setct_CertInqReqTBS = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 48);
+};
+pub const SN_setct_ErrorTBS = "setct-ErrorTBS";
+pub const NID_setct_ErrorTBS = @as(c_int, 567);
+pub const OBJ_setct_ErrorTBS = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 49);
+};
+pub const SN_setct_PIDualSignedTBE = "setct-PIDualSignedTBE";
+pub const NID_setct_PIDualSignedTBE = @as(c_int, 568);
+pub const OBJ_setct_PIDualSignedTBE = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 50);
+};
+pub const SN_setct_PIUnsignedTBE = "setct-PIUnsignedTBE";
+pub const NID_setct_PIUnsignedTBE = @as(c_int, 569);
+pub const OBJ_setct_PIUnsignedTBE = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 51);
+};
+pub const SN_setct_AuthReqTBE = "setct-AuthReqTBE";
+pub const NID_setct_AuthReqTBE = @as(c_int, 570);
+pub const OBJ_setct_AuthReqTBE = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 52);
+};
+pub const SN_setct_AuthResTBE = "setct-AuthResTBE";
+pub const NID_setct_AuthResTBE = @as(c_int, 571);
+pub const OBJ_setct_AuthResTBE = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 53);
+};
+pub const SN_setct_AuthResTBEX = "setct-AuthResTBEX";
+pub const NID_setct_AuthResTBEX = @as(c_int, 572);
+pub const OBJ_setct_AuthResTBEX = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 54);
+};
+pub const SN_setct_AuthTokenTBE = "setct-AuthTokenTBE";
+pub const NID_setct_AuthTokenTBE = @as(c_int, 573);
+pub const OBJ_setct_AuthTokenTBE = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 55);
+};
+pub const SN_setct_CapTokenTBE = "setct-CapTokenTBE";
+pub const NID_setct_CapTokenTBE = @as(c_int, 574);
+pub const OBJ_setct_CapTokenTBE = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 56);
+};
+pub const SN_setct_CapTokenTBEX = "setct-CapTokenTBEX";
+pub const NID_setct_CapTokenTBEX = @as(c_int, 575);
+pub const OBJ_setct_CapTokenTBEX = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 57);
+};
+pub const SN_setct_AcqCardCodeMsgTBE = "setct-AcqCardCodeMsgTBE";
+pub const NID_setct_AcqCardCodeMsgTBE = @as(c_int, 576);
+pub const OBJ_setct_AcqCardCodeMsgTBE = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 58);
+};
+pub const SN_setct_AuthRevReqTBE = "setct-AuthRevReqTBE";
+pub const NID_setct_AuthRevReqTBE = @as(c_int, 577);
+pub const OBJ_setct_AuthRevReqTBE = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 59);
+};
+pub const SN_setct_AuthRevResTBE = "setct-AuthRevResTBE";
+pub const NID_setct_AuthRevResTBE = @as(c_int, 578);
+pub const OBJ_setct_AuthRevResTBE = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 60);
+};
+pub const SN_setct_AuthRevResTBEB = "setct-AuthRevResTBEB";
+pub const NID_setct_AuthRevResTBEB = @as(c_int, 579);
+pub const OBJ_setct_AuthRevResTBEB = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 61);
+};
+pub const SN_setct_CapReqTBE = "setct-CapReqTBE";
+pub const NID_setct_CapReqTBE = @as(c_int, 580);
+pub const OBJ_setct_CapReqTBE = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 62);
+};
+pub const SN_setct_CapReqTBEX = "setct-CapReqTBEX";
+pub const NID_setct_CapReqTBEX = @as(c_int, 581);
+pub const OBJ_setct_CapReqTBEX = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 63);
+};
+pub const SN_setct_CapResTBE = "setct-CapResTBE";
+pub const NID_setct_CapResTBE = @as(c_int, 582);
+pub const OBJ_setct_CapResTBE = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 64);
+};
+pub const SN_setct_CapRevReqTBE = "setct-CapRevReqTBE";
+pub const NID_setct_CapRevReqTBE = @as(c_int, 583);
+pub const OBJ_setct_CapRevReqTBE = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 65);
+};
+pub const SN_setct_CapRevReqTBEX = "setct-CapRevReqTBEX";
+pub const NID_setct_CapRevReqTBEX = @as(c_int, 584);
+pub const OBJ_setct_CapRevReqTBEX = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 66);
+};
+pub const SN_setct_CapRevResTBE = "setct-CapRevResTBE";
+pub const NID_setct_CapRevResTBE = @as(c_int, 585);
+pub const OBJ_setct_CapRevResTBE = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 67);
+};
+pub const SN_setct_CredReqTBE = "setct-CredReqTBE";
+pub const NID_setct_CredReqTBE = @as(c_int, 586);
+pub const OBJ_setct_CredReqTBE = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 68);
+};
+pub const SN_setct_CredReqTBEX = "setct-CredReqTBEX";
+pub const NID_setct_CredReqTBEX = @as(c_int, 587);
+pub const OBJ_setct_CredReqTBEX = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 69);
+};
+pub const SN_setct_CredResTBE = "setct-CredResTBE";
+pub const NID_setct_CredResTBE = @as(c_int, 588);
+pub const OBJ_setct_CredResTBE = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 70);
+};
+pub const SN_setct_CredRevReqTBE = "setct-CredRevReqTBE";
+pub const NID_setct_CredRevReqTBE = @as(c_int, 589);
+pub const OBJ_setct_CredRevReqTBE = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 71);
+};
+pub const SN_setct_CredRevReqTBEX = "setct-CredRevReqTBEX";
+pub const NID_setct_CredRevReqTBEX = @as(c_int, 590);
+pub const OBJ_setct_CredRevReqTBEX = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 72);
+};
+pub const SN_setct_CredRevResTBE = "setct-CredRevResTBE";
+pub const NID_setct_CredRevResTBE = @as(c_int, 591);
+pub const OBJ_setct_CredRevResTBE = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 73);
+};
+pub const SN_setct_BatchAdminReqTBE = "setct-BatchAdminReqTBE";
+pub const NID_setct_BatchAdminReqTBE = @as(c_int, 592);
+pub const OBJ_setct_BatchAdminReqTBE = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 74);
+};
+pub const SN_setct_BatchAdminResTBE = "setct-BatchAdminResTBE";
+pub const NID_setct_BatchAdminResTBE = @as(c_int, 593);
+pub const OBJ_setct_BatchAdminResTBE = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 75);
+};
+pub const SN_setct_RegFormReqTBE = "setct-RegFormReqTBE";
+pub const NID_setct_RegFormReqTBE = @as(c_int, 594);
+pub const OBJ_setct_RegFormReqTBE = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 76);
+};
+pub const SN_setct_CertReqTBE = "setct-CertReqTBE";
+pub const NID_setct_CertReqTBE = @as(c_int, 595);
+pub const OBJ_setct_CertReqTBE = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 77);
+};
+pub const SN_setct_CertReqTBEX = "setct-CertReqTBEX";
+pub const NID_setct_CertReqTBEX = @as(c_int, 596);
+pub const OBJ_setct_CertReqTBEX = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 78);
+};
+pub const SN_setct_CertResTBE = "setct-CertResTBE";
+pub const NID_setct_CertResTBE = @as(c_int, 597);
+pub const OBJ_setct_CertResTBE = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 79);
+};
+pub const SN_setct_CRLNotificationTBS = "setct-CRLNotificationTBS";
+pub const NID_setct_CRLNotificationTBS = @as(c_int, 598);
+pub const OBJ_setct_CRLNotificationTBS = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 80);
+};
+pub const SN_setct_CRLNotificationResTBS = "setct-CRLNotificationResTBS";
+pub const NID_setct_CRLNotificationResTBS = @as(c_int, 599);
+pub const OBJ_setct_CRLNotificationResTBS = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 81);
+};
+pub const SN_setct_BCIDistributionTBS = "setct-BCIDistributionTBS";
+pub const NID_setct_BCIDistributionTBS = @as(c_int, 600);
+pub const OBJ_setct_BCIDistributionTBS = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 82);
+};
+pub const SN_setext_genCrypt = "setext-genCrypt";
+pub const LN_setext_genCrypt = "generic cryptogram";
+pub const NID_setext_genCrypt = @as(c_int, 601);
+pub const OBJ_setext_genCrypt = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 1);
+};
+pub const SN_setext_miAuth = "setext-miAuth";
+pub const LN_setext_miAuth = "merchant initiated auth";
+pub const NID_setext_miAuth = @as(c_int, 602);
+pub const OBJ_setext_miAuth = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 3);
+};
+pub const SN_setext_pinSecure = "setext-pinSecure";
+pub const NID_setext_pinSecure = @as(c_int, 603);
+pub const OBJ_setext_pinSecure = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 4);
+};
+pub const SN_setext_pinAny = "setext-pinAny";
+pub const NID_setext_pinAny = @as(c_int, 604);
+pub const OBJ_setext_pinAny = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 5);
+};
+pub const SN_setext_track2 = "setext-track2";
+pub const NID_setext_track2 = @as(c_int, 605);
+pub const OBJ_setext_track2 = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 7);
+};
+pub const SN_setext_cv = "setext-cv";
+pub const LN_setext_cv = "additional verification";
+pub const NID_setext_cv = @as(c_int, 606);
+pub const OBJ_setext_cv = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 8);
+};
+pub const SN_set_policy_root = "set-policy-root";
+pub const NID_set_policy_root = @as(c_int, 607);
+pub const OBJ_set_policy_root = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 5);
+ break :blk @as(c_long, 0);
+};
+pub const SN_setCext_hashedRoot = "setCext-hashedRoot";
+pub const NID_setCext_hashedRoot = @as(c_int, 608);
+pub const OBJ_setCext_hashedRoot = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 0);
+};
+pub const SN_setCext_certType = "setCext-certType";
+pub const NID_setCext_certType = @as(c_int, 609);
+pub const OBJ_setCext_certType = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 1);
+};
+pub const SN_setCext_merchData = "setCext-merchData";
+pub const NID_setCext_merchData = @as(c_int, 610);
+pub const OBJ_setCext_merchData = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 2);
+};
+pub const SN_setCext_cCertRequired = "setCext-cCertRequired";
+pub const NID_setCext_cCertRequired = @as(c_int, 611);
+pub const OBJ_setCext_cCertRequired = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 3);
+};
+pub const SN_setCext_tunneling = "setCext-tunneling";
+pub const NID_setCext_tunneling = @as(c_int, 612);
+pub const OBJ_setCext_tunneling = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 4);
+};
+pub const SN_setCext_setExt = "setCext-setExt";
+pub const NID_setCext_setExt = @as(c_int, 613);
+pub const OBJ_setCext_setExt = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 5);
+};
+pub const SN_setCext_setQualf = "setCext-setQualf";
+pub const NID_setCext_setQualf = @as(c_int, 614);
+pub const OBJ_setCext_setQualf = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 6);
+};
+pub const SN_setCext_PGWYcapabilities = "setCext-PGWYcapabilities";
+pub const NID_setCext_PGWYcapabilities = @as(c_int, 615);
+pub const OBJ_setCext_PGWYcapabilities = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 7);
+};
+pub const SN_setCext_TokenIdentifier = "setCext-TokenIdentifier";
+pub const NID_setCext_TokenIdentifier = @as(c_int, 616);
+pub const OBJ_setCext_TokenIdentifier = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 8);
+};
+pub const SN_setCext_Track2Data = "setCext-Track2Data";
+pub const NID_setCext_Track2Data = @as(c_int, 617);
+pub const OBJ_setCext_Track2Data = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 9);
+};
+pub const SN_setCext_TokenType = "setCext-TokenType";
+pub const NID_setCext_TokenType = @as(c_int, 618);
+pub const OBJ_setCext_TokenType = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 10);
+};
+pub const SN_setCext_IssuerCapabilities = "setCext-IssuerCapabilities";
+pub const NID_setCext_IssuerCapabilities = @as(c_int, 619);
+pub const OBJ_setCext_IssuerCapabilities = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 11);
+};
+pub const SN_setAttr_Cert = "setAttr-Cert";
+pub const NID_setAttr_Cert = @as(c_int, 620);
+pub const OBJ_setAttr_Cert = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 0);
+};
+pub const SN_setAttr_PGWYcap = "setAttr-PGWYcap";
+pub const LN_setAttr_PGWYcap = "payment gateway capabilities";
+pub const NID_setAttr_PGWYcap = @as(c_int, 621);
+pub const OBJ_setAttr_PGWYcap = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 1);
+};
+pub const SN_setAttr_TokenType = "setAttr-TokenType";
+pub const NID_setAttr_TokenType = @as(c_int, 622);
+pub const OBJ_setAttr_TokenType = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 2);
+};
+pub const SN_setAttr_IssCap = "setAttr-IssCap";
+pub const LN_setAttr_IssCap = "issuer capabilities";
+pub const NID_setAttr_IssCap = @as(c_int, 623);
+pub const OBJ_setAttr_IssCap = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 3);
+};
+pub const SN_set_rootKeyThumb = "set-rootKeyThumb";
+pub const NID_set_rootKeyThumb = @as(c_int, 624);
+pub const OBJ_set_rootKeyThumb = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 0);
+};
+pub const SN_set_addPolicy = "set-addPolicy";
+pub const NID_set_addPolicy = @as(c_int, 625);
+pub const OBJ_set_addPolicy = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 1);
+};
+pub const SN_setAttr_Token_EMV = "setAttr-Token-EMV";
+pub const NID_setAttr_Token_EMV = @as(c_int, 626);
+pub const OBJ_setAttr_Token_EMV = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 1);
+};
+pub const SN_setAttr_Token_B0Prime = "setAttr-Token-B0Prime";
+pub const NID_setAttr_Token_B0Prime = @as(c_int, 627);
+pub const OBJ_setAttr_Token_B0Prime = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 2);
+};
+pub const SN_setAttr_IssCap_CVM = "setAttr-IssCap-CVM";
+pub const NID_setAttr_IssCap_CVM = @as(c_int, 628);
+pub const OBJ_setAttr_IssCap_CVM = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 3);
+};
+pub const SN_setAttr_IssCap_T2 = "setAttr-IssCap-T2";
+pub const NID_setAttr_IssCap_T2 = @as(c_int, 629);
+pub const OBJ_setAttr_IssCap_T2 = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 4);
+};
+pub const SN_setAttr_IssCap_Sig = "setAttr-IssCap-Sig";
+pub const NID_setAttr_IssCap_Sig = @as(c_int, 630);
+pub const OBJ_setAttr_IssCap_Sig = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 5);
+};
+pub const SN_setAttr_GenCryptgrm = "setAttr-GenCryptgrm";
+pub const LN_setAttr_GenCryptgrm = "generate cryptogram";
+pub const NID_setAttr_GenCryptgrm = @as(c_int, 631);
+pub const OBJ_setAttr_GenCryptgrm = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 1);
+};
+pub const SN_setAttr_T2Enc = "setAttr-T2Enc";
+pub const LN_setAttr_T2Enc = "encrypted track 2";
+pub const NID_setAttr_T2Enc = @as(c_int, 632);
+pub const OBJ_setAttr_T2Enc = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 1);
+};
+pub const SN_setAttr_T2cleartxt = "setAttr-T2cleartxt";
+pub const LN_setAttr_T2cleartxt = "cleartext track 2";
+pub const NID_setAttr_T2cleartxt = @as(c_int, 633);
+pub const OBJ_setAttr_T2cleartxt = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 2);
+};
+pub const SN_setAttr_TokICCsig = "setAttr-TokICCsig";
+pub const LN_setAttr_TokICCsig = "ICC or token signature";
+pub const NID_setAttr_TokICCsig = @as(c_int, 634);
+pub const OBJ_setAttr_TokICCsig = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 5);
+ break :blk @as(c_long, 1);
+};
+pub const SN_setAttr_SecDevSig = "setAttr-SecDevSig";
+pub const LN_setAttr_SecDevSig = "secure device signature";
+pub const NID_setAttr_SecDevSig = @as(c_int, 635);
+pub const OBJ_setAttr_SecDevSig = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 5);
+ break :blk @as(c_long, 2);
+};
+pub const SN_set_brand_IATA_ATA = "set-brand-IATA-ATA";
+pub const NID_set_brand_IATA_ATA = @as(c_int, 636);
+pub const OBJ_set_brand_IATA_ATA = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 8);
+ break :blk @as(c_long, 1);
+};
+pub const SN_set_brand_Diners = "set-brand-Diners";
+pub const NID_set_brand_Diners = @as(c_int, 637);
+pub const OBJ_set_brand_Diners = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 8);
+ break :blk @as(c_long, 30);
+};
+pub const SN_set_brand_AmericanExpress = "set-brand-AmericanExpress";
+pub const NID_set_brand_AmericanExpress = @as(c_int, 638);
+pub const OBJ_set_brand_AmericanExpress = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 8);
+ break :blk @as(c_long, 34);
+};
+pub const SN_set_brand_JCB = "set-brand-JCB";
+pub const NID_set_brand_JCB = @as(c_int, 639);
+pub const OBJ_set_brand_JCB = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 8);
+ break :blk @as(c_long, 35);
+};
+pub const SN_set_brand_Visa = "set-brand-Visa";
+pub const NID_set_brand_Visa = @as(c_int, 640);
+pub const OBJ_set_brand_Visa = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 8);
+ break :blk @as(c_long, 4);
+};
+pub const SN_set_brand_MasterCard = "set-brand-MasterCard";
+pub const NID_set_brand_MasterCard = @as(c_int, 641);
+pub const OBJ_set_brand_MasterCard = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 8);
+ break :blk @as(c_long, 5);
+};
+pub const SN_set_brand_Novus = "set-brand-Novus";
+pub const NID_set_brand_Novus = @as(c_int, 642);
+pub const OBJ_set_brand_Novus = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 42);
+ _ = @as(c_long, 8);
+ break :blk @as(c_long, 6011);
+};
+pub const SN_des_cdmf = "DES-CDMF";
+pub const LN_des_cdmf = "des-cdmf";
+pub const NID_des_cdmf = @as(c_int, 643);
+pub const OBJ_des_cdmf = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 10);
+};
+pub const SN_rsaOAEPEncryptionSET = "rsaOAEPEncryptionSET";
+pub const NID_rsaOAEPEncryptionSET = @as(c_int, 644);
+pub const OBJ_rsaOAEPEncryptionSET = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 6);
+};
+pub const SN_itu_t = "ITU-T";
+pub const LN_itu_t = "itu-t";
+pub const NID_itu_t = @as(c_int, 645);
+pub const OBJ_itu_t = @as(c_long, 0);
+pub const SN_joint_iso_itu_t = "JOINT-ISO-ITU-T";
+pub const LN_joint_iso_itu_t = "joint-iso-itu-t";
+pub const NID_joint_iso_itu_t = @as(c_int, 646);
+pub const OBJ_joint_iso_itu_t = @as(c_long, 2);
+pub const SN_international_organizations = "international-organizations";
+pub const LN_international_organizations = "International Organizations";
+pub const NID_international_organizations = @as(c_int, 647);
+pub const OBJ_international_organizations = blk: {
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 23);
+};
+pub const SN_ms_smartcard_login = "msSmartcardLogin";
+pub const LN_ms_smartcard_login = "Microsoft Smartcardlogin";
+pub const NID_ms_smartcard_login = @as(c_int, 648);
+pub const OBJ_ms_smartcard_login = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 311);
+ _ = @as(c_long, 20);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 2);
+};
+pub const SN_ms_upn = "msUPN";
+pub const LN_ms_upn = "Microsoft Universal Principal Name";
+pub const NID_ms_upn = @as(c_int, 649);
+pub const OBJ_ms_upn = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 311);
+ _ = @as(c_long, 20);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 3);
+};
+pub const SN_aes_128_cfb1 = "AES-128-CFB1";
+pub const LN_aes_128_cfb1 = "aes-128-cfb1";
+pub const NID_aes_128_cfb1 = @as(c_int, 650);
+pub const SN_aes_192_cfb1 = "AES-192-CFB1";
+pub const LN_aes_192_cfb1 = "aes-192-cfb1";
+pub const NID_aes_192_cfb1 = @as(c_int, 651);
+pub const SN_aes_256_cfb1 = "AES-256-CFB1";
+pub const LN_aes_256_cfb1 = "aes-256-cfb1";
+pub const NID_aes_256_cfb1 = @as(c_int, 652);
+pub const SN_aes_128_cfb8 = "AES-128-CFB8";
+pub const LN_aes_128_cfb8 = "aes-128-cfb8";
+pub const NID_aes_128_cfb8 = @as(c_int, 653);
+pub const SN_aes_192_cfb8 = "AES-192-CFB8";
+pub const LN_aes_192_cfb8 = "aes-192-cfb8";
+pub const NID_aes_192_cfb8 = @as(c_int, 654);
+pub const SN_aes_256_cfb8 = "AES-256-CFB8";
+pub const LN_aes_256_cfb8 = "aes-256-cfb8";
+pub const NID_aes_256_cfb8 = @as(c_int, 655);
+pub const SN_des_cfb1 = "DES-CFB1";
+pub const LN_des_cfb1 = "des-cfb1";
+pub const NID_des_cfb1 = @as(c_int, 656);
+pub const SN_des_cfb8 = "DES-CFB8";
+pub const LN_des_cfb8 = "des-cfb8";
+pub const NID_des_cfb8 = @as(c_int, 657);
+pub const SN_des_ede3_cfb1 = "DES-EDE3-CFB1";
+pub const LN_des_ede3_cfb1 = "des-ede3-cfb1";
+pub const NID_des_ede3_cfb1 = @as(c_int, 658);
+pub const SN_des_ede3_cfb8 = "DES-EDE3-CFB8";
+pub const LN_des_ede3_cfb8 = "des-ede3-cfb8";
+pub const NID_des_ede3_cfb8 = @as(c_int, 659);
+pub const SN_streetAddress = "street";
+pub const LN_streetAddress = "streetAddress";
+pub const NID_streetAddress = @as(c_int, 660);
+pub const OBJ_streetAddress = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 9);
+};
+pub const LN_postalCode = "postalCode";
+pub const NID_postalCode = @as(c_int, 661);
+pub const OBJ_postalCode = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 17);
+};
+pub const SN_id_ppl = "id-ppl";
+pub const NID_id_ppl = @as(c_int, 662);
+pub const OBJ_id_ppl = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ break :blk @as(c_long, 21);
+};
+pub const SN_proxyCertInfo = "proxyCertInfo";
+pub const LN_proxyCertInfo = "Proxy Certificate Information";
+pub const NID_proxyCertInfo = @as(c_int, 663);
+pub const OBJ_proxyCertInfo = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 14);
+};
+pub const SN_id_ppl_anyLanguage = "id-ppl-anyLanguage";
+pub const LN_id_ppl_anyLanguage = "Any language";
+pub const NID_id_ppl_anyLanguage = @as(c_int, 664);
+pub const OBJ_id_ppl_anyLanguage = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 21);
+ break :blk @as(c_long, 0);
+};
+pub const SN_id_ppl_inheritAll = "id-ppl-inheritAll";
+pub const LN_id_ppl_inheritAll = "Inherit all";
+pub const NID_id_ppl_inheritAll = @as(c_int, 665);
+pub const OBJ_id_ppl_inheritAll = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 21);
+ break :blk @as(c_long, 1);
+};
+pub const SN_name_constraints = "nameConstraints";
+pub const LN_name_constraints = "X509v3 Name Constraints";
+pub const NID_name_constraints = @as(c_int, 666);
+pub const OBJ_name_constraints = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 29);
+ break :blk @as(c_long, 30);
+};
+pub const SN_Independent = "id-ppl-independent";
+pub const LN_Independent = "Independent";
+pub const NID_Independent = @as(c_int, 667);
+pub const OBJ_Independent = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 21);
+ break :blk @as(c_long, 2);
+};
+pub const SN_sha256WithRSAEncryption = "RSA-SHA256";
+pub const LN_sha256WithRSAEncryption = "sha256WithRSAEncryption";
+pub const NID_sha256WithRSAEncryption = @as(c_int, 668);
+pub const OBJ_sha256WithRSAEncryption = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 11);
+};
+pub const SN_sha384WithRSAEncryption = "RSA-SHA384";
+pub const LN_sha384WithRSAEncryption = "sha384WithRSAEncryption";
+pub const NID_sha384WithRSAEncryption = @as(c_int, 669);
+pub const OBJ_sha384WithRSAEncryption = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 12);
+};
+pub const SN_sha512WithRSAEncryption = "RSA-SHA512";
+pub const LN_sha512WithRSAEncryption = "sha512WithRSAEncryption";
+pub const NID_sha512WithRSAEncryption = @as(c_int, 670);
+pub const OBJ_sha512WithRSAEncryption = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 13);
+};
+pub const SN_sha224WithRSAEncryption = "RSA-SHA224";
+pub const LN_sha224WithRSAEncryption = "sha224WithRSAEncryption";
+pub const NID_sha224WithRSAEncryption = @as(c_int, 671);
+pub const OBJ_sha224WithRSAEncryption = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 14);
+};
+pub const SN_sha256 = "SHA256";
+pub const LN_sha256 = "sha256";
+pub const NID_sha256 = @as(c_int, 672);
+pub const OBJ_sha256 = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 1);
+};
+pub const SN_sha384 = "SHA384";
+pub const LN_sha384 = "sha384";
+pub const NID_sha384 = @as(c_int, 673);
+pub const OBJ_sha384 = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 2);
+};
+pub const SN_sha512 = "SHA512";
+pub const LN_sha512 = "sha512";
+pub const NID_sha512 = @as(c_int, 674);
+pub const OBJ_sha512 = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 3);
+};
+pub const SN_sha224 = "SHA224";
+pub const LN_sha224 = "sha224";
+pub const NID_sha224 = @as(c_int, 675);
+pub const OBJ_sha224 = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 4);
+};
+pub const SN_identified_organization = "identified-organization";
+pub const NID_identified_organization = @as(c_int, 676);
+pub const OBJ_identified_organization = blk: {
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 3);
+};
+pub const SN_certicom_arc = "certicom-arc";
+pub const NID_certicom_arc = @as(c_int, 677);
+pub const OBJ_certicom_arc = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 132);
+};
+pub const SN_wap = "wap";
+pub const NID_wap = @as(c_int, 678);
+pub const OBJ_wap = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ break :blk @as(c_long, 43);
+};
+pub const SN_wap_wsg = "wap-wsg";
+pub const NID_wap_wsg = @as(c_int, 679);
+pub const OBJ_wap_wsg = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 43);
+ break :blk @as(c_long, 1);
+};
+pub const SN_X9_62_id_characteristic_two_basis = "id-characteristic-two-basis";
+pub const NID_X9_62_id_characteristic_two_basis = @as(c_int, 680);
+pub const OBJ_X9_62_id_characteristic_two_basis = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 3);
+};
+pub const SN_X9_62_onBasis = "onBasis";
+pub const NID_X9_62_onBasis = @as(c_int, 681);
+pub const OBJ_X9_62_onBasis = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 1);
+};
+pub const SN_X9_62_tpBasis = "tpBasis";
+pub const NID_X9_62_tpBasis = @as(c_int, 682);
+pub const OBJ_X9_62_tpBasis = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 2);
+};
+pub const SN_X9_62_ppBasis = "ppBasis";
+pub const NID_X9_62_ppBasis = @as(c_int, 683);
+pub const OBJ_X9_62_ppBasis = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 3);
+};
+pub const SN_X9_62_c2pnb163v1 = "c2pnb163v1";
+pub const NID_X9_62_c2pnb163v1 = @as(c_int, 684);
+pub const OBJ_X9_62_c2pnb163v1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 1);
+};
+pub const SN_X9_62_c2pnb163v2 = "c2pnb163v2";
+pub const NID_X9_62_c2pnb163v2 = @as(c_int, 685);
+pub const OBJ_X9_62_c2pnb163v2 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 2);
+};
+pub const SN_X9_62_c2pnb163v3 = "c2pnb163v3";
+pub const NID_X9_62_c2pnb163v3 = @as(c_int, 686);
+pub const OBJ_X9_62_c2pnb163v3 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 3);
+};
+pub const SN_X9_62_c2pnb176v1 = "c2pnb176v1";
+pub const NID_X9_62_c2pnb176v1 = @as(c_int, 687);
+pub const OBJ_X9_62_c2pnb176v1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 4);
+};
+pub const SN_X9_62_c2tnb191v1 = "c2tnb191v1";
+pub const NID_X9_62_c2tnb191v1 = @as(c_int, 688);
+pub const OBJ_X9_62_c2tnb191v1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 5);
+};
+pub const SN_X9_62_c2tnb191v2 = "c2tnb191v2";
+pub const NID_X9_62_c2tnb191v2 = @as(c_int, 689);
+pub const OBJ_X9_62_c2tnb191v2 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 6);
+};
+pub const SN_X9_62_c2tnb191v3 = "c2tnb191v3";
+pub const NID_X9_62_c2tnb191v3 = @as(c_int, 690);
+pub const OBJ_X9_62_c2tnb191v3 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 7);
+};
+pub const SN_X9_62_c2onb191v4 = "c2onb191v4";
+pub const NID_X9_62_c2onb191v4 = @as(c_int, 691);
+pub const OBJ_X9_62_c2onb191v4 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 8);
+};
+pub const SN_X9_62_c2onb191v5 = "c2onb191v5";
+pub const NID_X9_62_c2onb191v5 = @as(c_int, 692);
+pub const OBJ_X9_62_c2onb191v5 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 9);
+};
+pub const SN_X9_62_c2pnb208w1 = "c2pnb208w1";
+pub const NID_X9_62_c2pnb208w1 = @as(c_int, 693);
+pub const OBJ_X9_62_c2pnb208w1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 10);
+};
+pub const SN_X9_62_c2tnb239v1 = "c2tnb239v1";
+pub const NID_X9_62_c2tnb239v1 = @as(c_int, 694);
+pub const OBJ_X9_62_c2tnb239v1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 11);
+};
+pub const SN_X9_62_c2tnb239v2 = "c2tnb239v2";
+pub const NID_X9_62_c2tnb239v2 = @as(c_int, 695);
+pub const OBJ_X9_62_c2tnb239v2 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 12);
+};
+pub const SN_X9_62_c2tnb239v3 = "c2tnb239v3";
+pub const NID_X9_62_c2tnb239v3 = @as(c_int, 696);
+pub const OBJ_X9_62_c2tnb239v3 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 13);
+};
+pub const SN_X9_62_c2onb239v4 = "c2onb239v4";
+pub const NID_X9_62_c2onb239v4 = @as(c_int, 697);
+pub const OBJ_X9_62_c2onb239v4 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 14);
+};
+pub const SN_X9_62_c2onb239v5 = "c2onb239v5";
+pub const NID_X9_62_c2onb239v5 = @as(c_int, 698);
+pub const OBJ_X9_62_c2onb239v5 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 15);
+};
+pub const SN_X9_62_c2pnb272w1 = "c2pnb272w1";
+pub const NID_X9_62_c2pnb272w1 = @as(c_int, 699);
+pub const OBJ_X9_62_c2pnb272w1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 16);
+};
+pub const SN_X9_62_c2pnb304w1 = "c2pnb304w1";
+pub const NID_X9_62_c2pnb304w1 = @as(c_int, 700);
+pub const OBJ_X9_62_c2pnb304w1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 17);
+};
+pub const SN_X9_62_c2tnb359v1 = "c2tnb359v1";
+pub const NID_X9_62_c2tnb359v1 = @as(c_int, 701);
+pub const OBJ_X9_62_c2tnb359v1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 18);
+};
+pub const SN_X9_62_c2pnb368w1 = "c2pnb368w1";
+pub const NID_X9_62_c2pnb368w1 = @as(c_int, 702);
+pub const OBJ_X9_62_c2pnb368w1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 19);
+};
+pub const SN_X9_62_c2tnb431r1 = "c2tnb431r1";
+pub const NID_X9_62_c2tnb431r1 = @as(c_int, 703);
+pub const OBJ_X9_62_c2tnb431r1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 20);
+};
+pub const SN_secp112r1 = "secp112r1";
+pub const NID_secp112r1 = @as(c_int, 704);
+pub const OBJ_secp112r1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 6);
+};
+pub const SN_secp112r2 = "secp112r2";
+pub const NID_secp112r2 = @as(c_int, 705);
+pub const OBJ_secp112r2 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 7);
+};
+pub const SN_secp128r1 = "secp128r1";
+pub const NID_secp128r1 = @as(c_int, 706);
+pub const OBJ_secp128r1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 28);
+};
+pub const SN_secp128r2 = "secp128r2";
+pub const NID_secp128r2 = @as(c_int, 707);
+pub const OBJ_secp128r2 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 29);
+};
+pub const SN_secp160k1 = "secp160k1";
+pub const NID_secp160k1 = @as(c_int, 708);
+pub const OBJ_secp160k1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 9);
+};
+pub const SN_secp160r1 = "secp160r1";
+pub const NID_secp160r1 = @as(c_int, 709);
+pub const OBJ_secp160r1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 8);
+};
+pub const SN_secp160r2 = "secp160r2";
+pub const NID_secp160r2 = @as(c_int, 710);
+pub const OBJ_secp160r2 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 30);
+};
+pub const SN_secp192k1 = "secp192k1";
+pub const NID_secp192k1 = @as(c_int, 711);
+pub const OBJ_secp192k1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 31);
+};
+pub const SN_secp224k1 = "secp224k1";
+pub const NID_secp224k1 = @as(c_int, 712);
+pub const OBJ_secp224k1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 32);
+};
+pub const SN_secp224r1 = "secp224r1";
+pub const NID_secp224r1 = @as(c_int, 713);
+pub const OBJ_secp224r1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 33);
+};
+pub const SN_secp256k1 = "secp256k1";
+pub const NID_secp256k1 = @as(c_int, 714);
+pub const OBJ_secp256k1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 10);
+};
+pub const SN_secp384r1 = "secp384r1";
+pub const NID_secp384r1 = @as(c_int, 715);
+pub const OBJ_secp384r1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 34);
+};
+pub const SN_secp521r1 = "secp521r1";
+pub const NID_secp521r1 = @as(c_int, 716);
+pub const OBJ_secp521r1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 35);
+};
+pub const SN_sect113r1 = "sect113r1";
+pub const NID_sect113r1 = @as(c_int, 717);
+pub const OBJ_sect113r1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 4);
+};
+pub const SN_sect113r2 = "sect113r2";
+pub const NID_sect113r2 = @as(c_int, 718);
+pub const OBJ_sect113r2 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 5);
+};
+pub const SN_sect131r1 = "sect131r1";
+pub const NID_sect131r1 = @as(c_int, 719);
+pub const OBJ_sect131r1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 22);
+};
+pub const SN_sect131r2 = "sect131r2";
+pub const NID_sect131r2 = @as(c_int, 720);
+pub const OBJ_sect131r2 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 23);
+};
+pub const SN_sect163k1 = "sect163k1";
+pub const NID_sect163k1 = @as(c_int, 721);
+pub const OBJ_sect163k1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 1);
+};
+pub const SN_sect163r1 = "sect163r1";
+pub const NID_sect163r1 = @as(c_int, 722);
+pub const OBJ_sect163r1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 2);
+};
+pub const SN_sect163r2 = "sect163r2";
+pub const NID_sect163r2 = @as(c_int, 723);
+pub const OBJ_sect163r2 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 15);
+};
+pub const SN_sect193r1 = "sect193r1";
+pub const NID_sect193r1 = @as(c_int, 724);
+pub const OBJ_sect193r1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 24);
+};
+pub const SN_sect193r2 = "sect193r2";
+pub const NID_sect193r2 = @as(c_int, 725);
+pub const OBJ_sect193r2 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 25);
+};
+pub const SN_sect233k1 = "sect233k1";
+pub const NID_sect233k1 = @as(c_int, 726);
+pub const OBJ_sect233k1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 26);
+};
+pub const SN_sect233r1 = "sect233r1";
+pub const NID_sect233r1 = @as(c_int, 727);
+pub const OBJ_sect233r1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 27);
+};
+pub const SN_sect239k1 = "sect239k1";
+pub const NID_sect239k1 = @as(c_int, 728);
+pub const OBJ_sect239k1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 3);
+};
+pub const SN_sect283k1 = "sect283k1";
+pub const NID_sect283k1 = @as(c_int, 729);
+pub const OBJ_sect283k1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 16);
+};
+pub const SN_sect283r1 = "sect283r1";
+pub const NID_sect283r1 = @as(c_int, 730);
+pub const OBJ_sect283r1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 17);
+};
+pub const SN_sect409k1 = "sect409k1";
+pub const NID_sect409k1 = @as(c_int, 731);
+pub const OBJ_sect409k1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 36);
+};
+pub const SN_sect409r1 = "sect409r1";
+pub const NID_sect409r1 = @as(c_int, 732);
+pub const OBJ_sect409r1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 37);
+};
+pub const SN_sect571k1 = "sect571k1";
+pub const NID_sect571k1 = @as(c_int, 733);
+pub const OBJ_sect571k1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 38);
+};
+pub const SN_sect571r1 = "sect571r1";
+pub const NID_sect571r1 = @as(c_int, 734);
+pub const OBJ_sect571r1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 39);
+};
+pub const SN_wap_wsg_idm_ecid_wtls1 = "wap-wsg-idm-ecid-wtls1";
+pub const NID_wap_wsg_idm_ecid_wtls1 = @as(c_int, 735);
+pub const OBJ_wap_wsg_idm_ecid_wtls1 = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 43);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 1);
+};
+pub const SN_wap_wsg_idm_ecid_wtls3 = "wap-wsg-idm-ecid-wtls3";
+pub const NID_wap_wsg_idm_ecid_wtls3 = @as(c_int, 736);
+pub const OBJ_wap_wsg_idm_ecid_wtls3 = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 43);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 3);
+};
+pub const SN_wap_wsg_idm_ecid_wtls4 = "wap-wsg-idm-ecid-wtls4";
+pub const NID_wap_wsg_idm_ecid_wtls4 = @as(c_int, 737);
+pub const OBJ_wap_wsg_idm_ecid_wtls4 = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 43);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 4);
+};
+pub const SN_wap_wsg_idm_ecid_wtls5 = "wap-wsg-idm-ecid-wtls5";
+pub const NID_wap_wsg_idm_ecid_wtls5 = @as(c_int, 738);
+pub const OBJ_wap_wsg_idm_ecid_wtls5 = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 43);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 5);
+};
+pub const SN_wap_wsg_idm_ecid_wtls6 = "wap-wsg-idm-ecid-wtls6";
+pub const NID_wap_wsg_idm_ecid_wtls6 = @as(c_int, 739);
+pub const OBJ_wap_wsg_idm_ecid_wtls6 = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 43);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 6);
+};
+pub const SN_wap_wsg_idm_ecid_wtls7 = "wap-wsg-idm-ecid-wtls7";
+pub const NID_wap_wsg_idm_ecid_wtls7 = @as(c_int, 740);
+pub const OBJ_wap_wsg_idm_ecid_wtls7 = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 43);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 7);
+};
+pub const SN_wap_wsg_idm_ecid_wtls8 = "wap-wsg-idm-ecid-wtls8";
+pub const NID_wap_wsg_idm_ecid_wtls8 = @as(c_int, 741);
+pub const OBJ_wap_wsg_idm_ecid_wtls8 = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 43);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 8);
+};
+pub const SN_wap_wsg_idm_ecid_wtls9 = "wap-wsg-idm-ecid-wtls9";
+pub const NID_wap_wsg_idm_ecid_wtls9 = @as(c_int, 742);
+pub const OBJ_wap_wsg_idm_ecid_wtls9 = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 43);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 9);
+};
+pub const SN_wap_wsg_idm_ecid_wtls10 = "wap-wsg-idm-ecid-wtls10";
+pub const NID_wap_wsg_idm_ecid_wtls10 = @as(c_int, 743);
+pub const OBJ_wap_wsg_idm_ecid_wtls10 = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 43);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 10);
+};
+pub const SN_wap_wsg_idm_ecid_wtls11 = "wap-wsg-idm-ecid-wtls11";
+pub const NID_wap_wsg_idm_ecid_wtls11 = @as(c_int, 744);
+pub const OBJ_wap_wsg_idm_ecid_wtls11 = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 43);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 11);
+};
+pub const SN_wap_wsg_idm_ecid_wtls12 = "wap-wsg-idm-ecid-wtls12";
+pub const NID_wap_wsg_idm_ecid_wtls12 = @as(c_int, 745);
+pub const OBJ_wap_wsg_idm_ecid_wtls12 = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 23);
+ _ = @as(c_long, 43);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 12);
+};
+pub const SN_any_policy = "anyPolicy";
+pub const LN_any_policy = "X509v3 Any Policy";
+pub const NID_any_policy = @as(c_int, 746);
+pub const OBJ_any_policy = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 29);
+ _ = @as(c_long, 32);
+ break :blk @as(c_long, 0);
+};
+pub const SN_policy_mappings = "policyMappings";
+pub const LN_policy_mappings = "X509v3 Policy Mappings";
+pub const NID_policy_mappings = @as(c_int, 747);
+pub const OBJ_policy_mappings = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 29);
+ break :blk @as(c_long, 33);
+};
+pub const SN_inhibit_any_policy = "inhibitAnyPolicy";
+pub const LN_inhibit_any_policy = "X509v3 Inhibit Any Policy";
+pub const NID_inhibit_any_policy = @as(c_int, 748);
+pub const OBJ_inhibit_any_policy = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 29);
+ break :blk @as(c_long, 54);
+};
+pub const SN_ipsec3 = "Oakley-EC2N-3";
+pub const LN_ipsec3 = "ipsec3";
+pub const NID_ipsec3 = @as(c_int, 749);
+pub const SN_ipsec4 = "Oakley-EC2N-4";
+pub const LN_ipsec4 = "ipsec4";
+pub const NID_ipsec4 = @as(c_int, 750);
+pub const SN_camellia_128_cbc = "CAMELLIA-128-CBC";
+pub const LN_camellia_128_cbc = "camellia-128-cbc";
+pub const NID_camellia_128_cbc = @as(c_int, 751);
+pub const OBJ_camellia_128_cbc = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 392);
+ _ = @as(c_long, 200011);
+ _ = @as(c_long, 61);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 2);
+};
+pub const SN_camellia_192_cbc = "CAMELLIA-192-CBC";
+pub const LN_camellia_192_cbc = "camellia-192-cbc";
+pub const NID_camellia_192_cbc = @as(c_int, 752);
+pub const OBJ_camellia_192_cbc = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 392);
+ _ = @as(c_long, 200011);
+ _ = @as(c_long, 61);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 3);
+};
+pub const SN_camellia_256_cbc = "CAMELLIA-256-CBC";
+pub const LN_camellia_256_cbc = "camellia-256-cbc";
+pub const NID_camellia_256_cbc = @as(c_int, 753);
+pub const OBJ_camellia_256_cbc = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 392);
+ _ = @as(c_long, 200011);
+ _ = @as(c_long, 61);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 4);
+};
+pub const SN_camellia_128_ecb = "CAMELLIA-128-ECB";
+pub const LN_camellia_128_ecb = "camellia-128-ecb";
+pub const NID_camellia_128_ecb = @as(c_int, 754);
+pub const OBJ_camellia_128_ecb = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4401);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ break :blk @as(c_long, 1);
+};
+pub const SN_camellia_192_ecb = "CAMELLIA-192-ECB";
+pub const LN_camellia_192_ecb = "camellia-192-ecb";
+pub const NID_camellia_192_ecb = @as(c_int, 755);
+pub const OBJ_camellia_192_ecb = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4401);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ break :blk @as(c_long, 21);
+};
+pub const SN_camellia_256_ecb = "CAMELLIA-256-ECB";
+pub const LN_camellia_256_ecb = "camellia-256-ecb";
+pub const NID_camellia_256_ecb = @as(c_int, 756);
+pub const OBJ_camellia_256_ecb = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4401);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ break :blk @as(c_long, 41);
+};
+pub const SN_camellia_128_cfb128 = "CAMELLIA-128-CFB";
+pub const LN_camellia_128_cfb128 = "camellia-128-cfb";
+pub const NID_camellia_128_cfb128 = @as(c_int, 757);
+pub const OBJ_camellia_128_cfb128 = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4401);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ break :blk @as(c_long, 4);
+};
+pub const SN_camellia_192_cfb128 = "CAMELLIA-192-CFB";
+pub const LN_camellia_192_cfb128 = "camellia-192-cfb";
+pub const NID_camellia_192_cfb128 = @as(c_int, 758);
+pub const OBJ_camellia_192_cfb128 = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4401);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ break :blk @as(c_long, 24);
+};
+pub const SN_camellia_256_cfb128 = "CAMELLIA-256-CFB";
+pub const LN_camellia_256_cfb128 = "camellia-256-cfb";
+pub const NID_camellia_256_cfb128 = @as(c_int, 759);
+pub const OBJ_camellia_256_cfb128 = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4401);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ break :blk @as(c_long, 44);
+};
+pub const SN_camellia_128_cfb1 = "CAMELLIA-128-CFB1";
+pub const LN_camellia_128_cfb1 = "camellia-128-cfb1";
+pub const NID_camellia_128_cfb1 = @as(c_int, 760);
+pub const SN_camellia_192_cfb1 = "CAMELLIA-192-CFB1";
+pub const LN_camellia_192_cfb1 = "camellia-192-cfb1";
+pub const NID_camellia_192_cfb1 = @as(c_int, 761);
+pub const SN_camellia_256_cfb1 = "CAMELLIA-256-CFB1";
+pub const LN_camellia_256_cfb1 = "camellia-256-cfb1";
+pub const NID_camellia_256_cfb1 = @as(c_int, 762);
+pub const SN_camellia_128_cfb8 = "CAMELLIA-128-CFB8";
+pub const LN_camellia_128_cfb8 = "camellia-128-cfb8";
+pub const NID_camellia_128_cfb8 = @as(c_int, 763);
+pub const SN_camellia_192_cfb8 = "CAMELLIA-192-CFB8";
+pub const LN_camellia_192_cfb8 = "camellia-192-cfb8";
+pub const NID_camellia_192_cfb8 = @as(c_int, 764);
+pub const SN_camellia_256_cfb8 = "CAMELLIA-256-CFB8";
+pub const LN_camellia_256_cfb8 = "camellia-256-cfb8";
+pub const NID_camellia_256_cfb8 = @as(c_int, 765);
+pub const SN_camellia_128_ofb128 = "CAMELLIA-128-OFB";
+pub const LN_camellia_128_ofb128 = "camellia-128-ofb";
+pub const NID_camellia_128_ofb128 = @as(c_int, 766);
+pub const OBJ_camellia_128_ofb128 = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4401);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ break :blk @as(c_long, 3);
+};
+pub const SN_camellia_192_ofb128 = "CAMELLIA-192-OFB";
+pub const LN_camellia_192_ofb128 = "camellia-192-ofb";
+pub const NID_camellia_192_ofb128 = @as(c_int, 767);
+pub const OBJ_camellia_192_ofb128 = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4401);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ break :blk @as(c_long, 23);
+};
+pub const SN_camellia_256_ofb128 = "CAMELLIA-256-OFB";
+pub const LN_camellia_256_ofb128 = "camellia-256-ofb";
+pub const NID_camellia_256_ofb128 = @as(c_int, 768);
+pub const OBJ_camellia_256_ofb128 = blk: {
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4401);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ break :blk @as(c_long, 43);
+};
+pub const SN_subject_directory_attributes = "subjectDirectoryAttributes";
+pub const LN_subject_directory_attributes = "X509v3 Subject Directory Attributes";
+pub const NID_subject_directory_attributes = @as(c_int, 769);
+pub const OBJ_subject_directory_attributes = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 29);
+ break :blk @as(c_long, 9);
+};
+pub const SN_issuing_distribution_point = "issuingDistributionPoint";
+pub const LN_issuing_distribution_point = "X509v3 Issuing Distribution Point";
+pub const NID_issuing_distribution_point = @as(c_int, 770);
+pub const OBJ_issuing_distribution_point = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 29);
+ break :blk @as(c_long, 28);
+};
+pub const SN_certificate_issuer = "certificateIssuer";
+pub const LN_certificate_issuer = "X509v3 Certificate Issuer";
+pub const NID_certificate_issuer = @as(c_int, 771);
+pub const OBJ_certificate_issuer = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 29);
+ break :blk @as(c_long, 29);
+};
+pub const SN_kisa = "KISA";
+pub const LN_kisa = "kisa";
+pub const NID_kisa = @as(c_int, 773);
+pub const OBJ_kisa = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 410);
+ break :blk @as(c_long, 200004);
+};
+pub const SN_seed_ecb = "SEED-ECB";
+pub const LN_seed_ecb = "seed-ecb";
+pub const NID_seed_ecb = @as(c_int, 776);
+pub const OBJ_seed_ecb = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 410);
+ _ = @as(c_long, 200004);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 3);
+};
+pub const SN_seed_cbc = "SEED-CBC";
+pub const LN_seed_cbc = "seed-cbc";
+pub const NID_seed_cbc = @as(c_int, 777);
+pub const OBJ_seed_cbc = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 410);
+ _ = @as(c_long, 200004);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 4);
+};
+pub const SN_seed_ofb128 = "SEED-OFB";
+pub const LN_seed_ofb128 = "seed-ofb";
+pub const NID_seed_ofb128 = @as(c_int, 778);
+pub const OBJ_seed_ofb128 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 410);
+ _ = @as(c_long, 200004);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 6);
+};
+pub const SN_seed_cfb128 = "SEED-CFB";
+pub const LN_seed_cfb128 = "seed-cfb";
+pub const NID_seed_cfb128 = @as(c_int, 779);
+pub const OBJ_seed_cfb128 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 410);
+ _ = @as(c_long, 200004);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 5);
+};
+pub const SN_hmac_md5 = "HMAC-MD5";
+pub const LN_hmac_md5 = "hmac-md5";
+pub const NID_hmac_md5 = @as(c_int, 780);
+pub const OBJ_hmac_md5 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 8);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 1);
+};
+pub const SN_hmac_sha1 = "HMAC-SHA1";
+pub const LN_hmac_sha1 = "hmac-sha1";
+pub const NID_hmac_sha1 = @as(c_int, 781);
+pub const OBJ_hmac_sha1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 8);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 2);
+};
+pub const SN_id_PasswordBasedMAC = "id-PasswordBasedMAC";
+pub const LN_id_PasswordBasedMAC = "password based MAC";
+pub const NID_id_PasswordBasedMAC = @as(c_int, 782);
+pub const OBJ_id_PasswordBasedMAC = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113533);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 66);
+ break :blk @as(c_long, 13);
+};
+pub const SN_id_DHBasedMac = "id-DHBasedMac";
+pub const LN_id_DHBasedMac = "Diffie-Hellman based MAC";
+pub const NID_id_DHBasedMac = @as(c_int, 783);
+pub const OBJ_id_DHBasedMac = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113533);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 66);
+ break :blk @as(c_long, 30);
+};
+pub const SN_id_it_suppLangTags = "id-it-suppLangTags";
+pub const NID_id_it_suppLangTags = @as(c_int, 784);
+pub const OBJ_id_it_suppLangTags = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 16);
+};
+pub const SN_caRepository = "caRepository";
+pub const LN_caRepository = "CA Repository";
+pub const NID_caRepository = @as(c_int, 785);
+pub const OBJ_caRepository = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 48);
+ break :blk @as(c_long, 5);
+};
+pub const SN_id_smime_ct_compressedData = "id-smime-ct-compressedData";
+pub const NID_id_smime_ct_compressedData = @as(c_int, 786);
+pub const OBJ_id_smime_ct_compressedData = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 9);
+};
+pub const SN_id_ct_asciiTextWithCRLF = "id-ct-asciiTextWithCRLF";
+pub const NID_id_ct_asciiTextWithCRLF = @as(c_int, 787);
+pub const OBJ_id_ct_asciiTextWithCRLF = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 27);
+};
+pub const SN_id_aes128_wrap = "id-aes128-wrap";
+pub const NID_id_aes128_wrap = @as(c_int, 788);
+pub const OBJ_id_aes128_wrap = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 5);
+};
+pub const SN_id_aes192_wrap = "id-aes192-wrap";
+pub const NID_id_aes192_wrap = @as(c_int, 789);
+pub const OBJ_id_aes192_wrap = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 25);
+};
+pub const SN_id_aes256_wrap = "id-aes256-wrap";
+pub const NID_id_aes256_wrap = @as(c_int, 790);
+pub const OBJ_id_aes256_wrap = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 45);
+};
+pub const SN_ecdsa_with_Recommended = "ecdsa-with-Recommended";
+pub const NID_ecdsa_with_Recommended = @as(c_int, 791);
+pub const OBJ_ecdsa_with_Recommended = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 2);
+};
+pub const SN_ecdsa_with_Specified = "ecdsa-with-Specified";
+pub const NID_ecdsa_with_Specified = @as(c_int, 792);
+pub const OBJ_ecdsa_with_Specified = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 3);
+};
+pub const SN_ecdsa_with_SHA224 = "ecdsa-with-SHA224";
+pub const NID_ecdsa_with_SHA224 = @as(c_int, 793);
+pub const OBJ_ecdsa_with_SHA224 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 1);
+};
+pub const SN_ecdsa_with_SHA256 = "ecdsa-with-SHA256";
+pub const NID_ecdsa_with_SHA256 = @as(c_int, 794);
+pub const OBJ_ecdsa_with_SHA256 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 2);
+};
+pub const SN_ecdsa_with_SHA384 = "ecdsa-with-SHA384";
+pub const NID_ecdsa_with_SHA384 = @as(c_int, 795);
+pub const OBJ_ecdsa_with_SHA384 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 3);
+};
+pub const SN_ecdsa_with_SHA512 = "ecdsa-with-SHA512";
+pub const NID_ecdsa_with_SHA512 = @as(c_int, 796);
+pub const OBJ_ecdsa_with_SHA512 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10045);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 4);
+};
+pub const LN_hmacWithMD5 = "hmacWithMD5";
+pub const NID_hmacWithMD5 = @as(c_int, 797);
+pub const OBJ_hmacWithMD5 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 6);
+};
+pub const LN_hmacWithSHA224 = "hmacWithSHA224";
+pub const NID_hmacWithSHA224 = @as(c_int, 798);
+pub const OBJ_hmacWithSHA224 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 8);
+};
+pub const LN_hmacWithSHA256 = "hmacWithSHA256";
+pub const NID_hmacWithSHA256 = @as(c_int, 799);
+pub const OBJ_hmacWithSHA256 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 9);
+};
+pub const LN_hmacWithSHA384 = "hmacWithSHA384";
+pub const NID_hmacWithSHA384 = @as(c_int, 800);
+pub const OBJ_hmacWithSHA384 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 10);
+};
+pub const LN_hmacWithSHA512 = "hmacWithSHA512";
+pub const NID_hmacWithSHA512 = @as(c_int, 801);
+pub const OBJ_hmacWithSHA512 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 11);
+};
+pub const SN_dsa_with_SHA224 = "dsa_with_SHA224";
+pub const NID_dsa_with_SHA224 = @as(c_int, 802);
+pub const OBJ_dsa_with_SHA224 = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 1);
+};
+pub const SN_dsa_with_SHA256 = "dsa_with_SHA256";
+pub const NID_dsa_with_SHA256 = @as(c_int, 803);
+pub const OBJ_dsa_with_SHA256 = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 2);
+};
+pub const SN_whirlpool = "whirlpool";
+pub const NID_whirlpool = @as(c_int, 804);
+pub const OBJ_whirlpool = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 0);
+ _ = @as(c_long, 10118);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 55);
+};
+pub const SN_cryptopro = "cryptopro";
+pub const NID_cryptopro = @as(c_int, 805);
+pub const OBJ_cryptopro = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 2);
+};
+pub const SN_cryptocom = "cryptocom";
+pub const NID_cryptocom = @as(c_int, 806);
+pub const OBJ_cryptocom = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 9);
+};
+pub const SN_id_GostR3411_94_with_GostR3410_2001 = "id-GostR3411-94-with-GostR3410-2001";
+pub const LN_id_GostR3411_94_with_GostR3410_2001 = "GOST R 34.11-94 with GOST R 34.10-2001";
+pub const NID_id_GostR3411_94_with_GostR3410_2001 = @as(c_int, 807);
+pub const OBJ_id_GostR3411_94_with_GostR3410_2001 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 3);
+};
+pub const SN_id_GostR3411_94_with_GostR3410_94 = "id-GostR3411-94-with-GostR3410-94";
+pub const LN_id_GostR3411_94_with_GostR3410_94 = "GOST R 34.11-94 with GOST R 34.10-94";
+pub const NID_id_GostR3411_94_with_GostR3410_94 = @as(c_int, 808);
+pub const OBJ_id_GostR3411_94_with_GostR3410_94 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 4);
+};
+pub const SN_id_GostR3411_94 = "md_gost94";
+pub const LN_id_GostR3411_94 = "GOST R 34.11-94";
+pub const NID_id_GostR3411_94 = @as(c_int, 809);
+pub const OBJ_id_GostR3411_94 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 9);
+};
+pub const SN_id_HMACGostR3411_94 = "id-HMACGostR3411-94";
+pub const LN_id_HMACGostR3411_94 = "HMAC GOST 34.11-94";
+pub const NID_id_HMACGostR3411_94 = @as(c_int, 810);
+pub const OBJ_id_HMACGostR3411_94 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 10);
+};
+pub const SN_id_GostR3410_2001 = "gost2001";
+pub const LN_id_GostR3410_2001 = "GOST R 34.10-2001";
+pub const NID_id_GostR3410_2001 = @as(c_int, 811);
+pub const OBJ_id_GostR3410_2001 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 19);
+};
+pub const SN_id_GostR3410_94 = "gost94";
+pub const LN_id_GostR3410_94 = "GOST R 34.10-94";
+pub const NID_id_GostR3410_94 = @as(c_int, 812);
+pub const OBJ_id_GostR3410_94 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 20);
+};
+pub const SN_id_Gost28147_89 = "gost89";
+pub const LN_id_Gost28147_89 = "GOST 28147-89";
+pub const NID_id_Gost28147_89 = @as(c_int, 813);
+pub const OBJ_id_Gost28147_89 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 21);
+};
+pub const SN_gost89_cnt = "gost89-cnt";
+pub const NID_gost89_cnt = @as(c_int, 814);
+pub const SN_id_Gost28147_89_MAC = "gost-mac";
+pub const LN_id_Gost28147_89_MAC = "GOST 28147-89 MAC";
+pub const NID_id_Gost28147_89_MAC = @as(c_int, 815);
+pub const OBJ_id_Gost28147_89_MAC = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 22);
+};
+pub const SN_id_GostR3411_94_prf = "prf-gostr3411-94";
+pub const LN_id_GostR3411_94_prf = "GOST R 34.11-94 PRF";
+pub const NID_id_GostR3411_94_prf = @as(c_int, 816);
+pub const OBJ_id_GostR3411_94_prf = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 23);
+};
+pub const SN_id_GostR3410_2001DH = "id-GostR3410-2001DH";
+pub const LN_id_GostR3410_2001DH = "GOST R 34.10-2001 DH";
+pub const NID_id_GostR3410_2001DH = @as(c_int, 817);
+pub const OBJ_id_GostR3410_2001DH = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 98);
+};
+pub const SN_id_GostR3410_94DH = "id-GostR3410-94DH";
+pub const LN_id_GostR3410_94DH = "GOST R 34.10-94 DH";
+pub const NID_id_GostR3410_94DH = @as(c_int, 818);
+pub const OBJ_id_GostR3410_94DH = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 99);
+};
+pub const SN_id_Gost28147_89_CryptoPro_KeyMeshing = "id-Gost28147-89-CryptoPro-KeyMeshing";
+pub const NID_id_Gost28147_89_CryptoPro_KeyMeshing = @as(c_int, 819);
+pub const OBJ_id_Gost28147_89_CryptoPro_KeyMeshing = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 14);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_Gost28147_89_None_KeyMeshing = "id-Gost28147-89-None-KeyMeshing";
+pub const NID_id_Gost28147_89_None_KeyMeshing = @as(c_int, 820);
+pub const OBJ_id_Gost28147_89_None_KeyMeshing = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 14);
+ break :blk @as(c_long, 0);
+};
+pub const SN_id_GostR3411_94_TestParamSet = "id-GostR3411-94-TestParamSet";
+pub const NID_id_GostR3411_94_TestParamSet = @as(c_int, 821);
+pub const OBJ_id_GostR3411_94_TestParamSet = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 30);
+ break :blk @as(c_long, 0);
+};
+pub const SN_id_GostR3411_94_CryptoProParamSet = "id-GostR3411-94-CryptoProParamSet";
+pub const NID_id_GostR3411_94_CryptoProParamSet = @as(c_int, 822);
+pub const OBJ_id_GostR3411_94_CryptoProParamSet = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 30);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_Gost28147_89_TestParamSet = "id-Gost28147-89-TestParamSet";
+pub const NID_id_Gost28147_89_TestParamSet = @as(c_int, 823);
+pub const OBJ_id_Gost28147_89_TestParamSet = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 31);
+ break :blk @as(c_long, 0);
+};
+pub const SN_id_Gost28147_89_CryptoPro_A_ParamSet = "id-Gost28147-89-CryptoPro-A-ParamSet";
+pub const NID_id_Gost28147_89_CryptoPro_A_ParamSet = @as(c_int, 824);
+pub const OBJ_id_Gost28147_89_CryptoPro_A_ParamSet = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 31);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_Gost28147_89_CryptoPro_B_ParamSet = "id-Gost28147-89-CryptoPro-B-ParamSet";
+pub const NID_id_Gost28147_89_CryptoPro_B_ParamSet = @as(c_int, 825);
+pub const OBJ_id_Gost28147_89_CryptoPro_B_ParamSet = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 31);
+ break :blk @as(c_long, 2);
+};
+pub const SN_id_Gost28147_89_CryptoPro_C_ParamSet = "id-Gost28147-89-CryptoPro-C-ParamSet";
+pub const NID_id_Gost28147_89_CryptoPro_C_ParamSet = @as(c_int, 826);
+pub const OBJ_id_Gost28147_89_CryptoPro_C_ParamSet = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 31);
+ break :blk @as(c_long, 3);
+};
+pub const SN_id_Gost28147_89_CryptoPro_D_ParamSet = "id-Gost28147-89-CryptoPro-D-ParamSet";
+pub const NID_id_Gost28147_89_CryptoPro_D_ParamSet = @as(c_int, 827);
+pub const OBJ_id_Gost28147_89_CryptoPro_D_ParamSet = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 31);
+ break :blk @as(c_long, 4);
+};
+pub const SN_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet = "id-Gost28147-89-CryptoPro-Oscar-1-1-ParamSet";
+pub const NID_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet = @as(c_int, 828);
+pub const OBJ_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 31);
+ break :blk @as(c_long, 5);
+};
+pub const SN_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet = "id-Gost28147-89-CryptoPro-Oscar-1-0-ParamSet";
+pub const NID_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet = @as(c_int, 829);
+pub const OBJ_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 31);
+ break :blk @as(c_long, 6);
+};
+pub const SN_id_Gost28147_89_CryptoPro_RIC_1_ParamSet = "id-Gost28147-89-CryptoPro-RIC-1-ParamSet";
+pub const NID_id_Gost28147_89_CryptoPro_RIC_1_ParamSet = @as(c_int, 830);
+pub const OBJ_id_Gost28147_89_CryptoPro_RIC_1_ParamSet = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 31);
+ break :blk @as(c_long, 7);
+};
+pub const SN_id_GostR3410_94_TestParamSet = "id-GostR3410-94-TestParamSet";
+pub const NID_id_GostR3410_94_TestParamSet = @as(c_int, 831);
+pub const OBJ_id_GostR3410_94_TestParamSet = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 32);
+ break :blk @as(c_long, 0);
+};
+pub const SN_id_GostR3410_94_CryptoPro_A_ParamSet = "id-GostR3410-94-CryptoPro-A-ParamSet";
+pub const NID_id_GostR3410_94_CryptoPro_A_ParamSet = @as(c_int, 832);
+pub const OBJ_id_GostR3410_94_CryptoPro_A_ParamSet = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 32);
+ break :blk @as(c_long, 2);
+};
+pub const SN_id_GostR3410_94_CryptoPro_B_ParamSet = "id-GostR3410-94-CryptoPro-B-ParamSet";
+pub const NID_id_GostR3410_94_CryptoPro_B_ParamSet = @as(c_int, 833);
+pub const OBJ_id_GostR3410_94_CryptoPro_B_ParamSet = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 32);
+ break :blk @as(c_long, 3);
+};
+pub const SN_id_GostR3410_94_CryptoPro_C_ParamSet = "id-GostR3410-94-CryptoPro-C-ParamSet";
+pub const NID_id_GostR3410_94_CryptoPro_C_ParamSet = @as(c_int, 834);
+pub const OBJ_id_GostR3410_94_CryptoPro_C_ParamSet = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 32);
+ break :blk @as(c_long, 4);
+};
+pub const SN_id_GostR3410_94_CryptoPro_D_ParamSet = "id-GostR3410-94-CryptoPro-D-ParamSet";
+pub const NID_id_GostR3410_94_CryptoPro_D_ParamSet = @as(c_int, 835);
+pub const OBJ_id_GostR3410_94_CryptoPro_D_ParamSet = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 32);
+ break :blk @as(c_long, 5);
+};
+pub const SN_id_GostR3410_94_CryptoPro_XchA_ParamSet = "id-GostR3410-94-CryptoPro-XchA-ParamSet";
+pub const NID_id_GostR3410_94_CryptoPro_XchA_ParamSet = @as(c_int, 836);
+pub const OBJ_id_GostR3410_94_CryptoPro_XchA_ParamSet = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 33);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_GostR3410_94_CryptoPro_XchB_ParamSet = "id-GostR3410-94-CryptoPro-XchB-ParamSet";
+pub const NID_id_GostR3410_94_CryptoPro_XchB_ParamSet = @as(c_int, 837);
+pub const OBJ_id_GostR3410_94_CryptoPro_XchB_ParamSet = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 33);
+ break :blk @as(c_long, 2);
+};
+pub const SN_id_GostR3410_94_CryptoPro_XchC_ParamSet = "id-GostR3410-94-CryptoPro-XchC-ParamSet";
+pub const NID_id_GostR3410_94_CryptoPro_XchC_ParamSet = @as(c_int, 838);
+pub const OBJ_id_GostR3410_94_CryptoPro_XchC_ParamSet = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 33);
+ break :blk @as(c_long, 3);
+};
+pub const SN_id_GostR3410_2001_TestParamSet = "id-GostR3410-2001-TestParamSet";
+pub const NID_id_GostR3410_2001_TestParamSet = @as(c_int, 839);
+pub const OBJ_id_GostR3410_2001_TestParamSet = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 35);
+ break :blk @as(c_long, 0);
+};
+pub const SN_id_GostR3410_2001_CryptoPro_A_ParamSet = "id-GostR3410-2001-CryptoPro-A-ParamSet";
+pub const NID_id_GostR3410_2001_CryptoPro_A_ParamSet = @as(c_int, 840);
+pub const OBJ_id_GostR3410_2001_CryptoPro_A_ParamSet = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 35);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_GostR3410_2001_CryptoPro_B_ParamSet = "id-GostR3410-2001-CryptoPro-B-ParamSet";
+pub const NID_id_GostR3410_2001_CryptoPro_B_ParamSet = @as(c_int, 841);
+pub const OBJ_id_GostR3410_2001_CryptoPro_B_ParamSet = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 35);
+ break :blk @as(c_long, 2);
+};
+pub const SN_id_GostR3410_2001_CryptoPro_C_ParamSet = "id-GostR3410-2001-CryptoPro-C-ParamSet";
+pub const NID_id_GostR3410_2001_CryptoPro_C_ParamSet = @as(c_int, 842);
+pub const OBJ_id_GostR3410_2001_CryptoPro_C_ParamSet = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 35);
+ break :blk @as(c_long, 3);
+};
+pub const SN_id_GostR3410_2001_CryptoPro_XchA_ParamSet = "id-GostR3410-2001-CryptoPro-XchA-ParamSet";
+pub const NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet = @as(c_int, 843);
+pub const OBJ_id_GostR3410_2001_CryptoPro_XchA_ParamSet = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 36);
+ break :blk @as(c_long, 0);
+};
+pub const SN_id_GostR3410_2001_CryptoPro_XchB_ParamSet = "id-GostR3410-2001-CryptoPro-XchB-ParamSet";
+pub const NID_id_GostR3410_2001_CryptoPro_XchB_ParamSet = @as(c_int, 844);
+pub const OBJ_id_GostR3410_2001_CryptoPro_XchB_ParamSet = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 36);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_GostR3410_94_a = "id-GostR3410-94-a";
+pub const NID_id_GostR3410_94_a = @as(c_int, 845);
+pub const OBJ_id_GostR3410_94_a = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 20);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_GostR3410_94_aBis = "id-GostR3410-94-aBis";
+pub const NID_id_GostR3410_94_aBis = @as(c_int, 846);
+pub const OBJ_id_GostR3410_94_aBis = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 20);
+ break :blk @as(c_long, 2);
+};
+pub const SN_id_GostR3410_94_b = "id-GostR3410-94-b";
+pub const NID_id_GostR3410_94_b = @as(c_int, 847);
+pub const OBJ_id_GostR3410_94_b = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 20);
+ break :blk @as(c_long, 3);
+};
+pub const SN_id_GostR3410_94_bBis = "id-GostR3410-94-bBis";
+pub const NID_id_GostR3410_94_bBis = @as(c_int, 848);
+pub const OBJ_id_GostR3410_94_bBis = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 20);
+ break :blk @as(c_long, 4);
+};
+pub const SN_id_Gost28147_89_cc = "id-Gost28147-89-cc";
+pub const LN_id_Gost28147_89_cc = "GOST 28147-89 Cryptocom ParamSet";
+pub const NID_id_Gost28147_89_cc = @as(c_int, 849);
+pub const OBJ_id_Gost28147_89_cc = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 6);
+ break :blk @as(c_long, 1);
+};
+pub const SN_id_GostR3410_94_cc = "gost94cc";
+pub const LN_id_GostR3410_94_cc = "GOST 34.10-94 Cryptocom";
+pub const NID_id_GostR3410_94_cc = @as(c_int, 850);
+pub const OBJ_id_GostR3410_94_cc = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ break :blk @as(c_long, 3);
+};
+pub const SN_id_GostR3410_2001_cc = "gost2001cc";
+pub const LN_id_GostR3410_2001_cc = "GOST 34.10-2001 Cryptocom";
+pub const NID_id_GostR3410_2001_cc = @as(c_int, 851);
+pub const OBJ_id_GostR3410_2001_cc = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ break :blk @as(c_long, 4);
+};
+pub const SN_id_GostR3411_94_with_GostR3410_94_cc = "id-GostR3411-94-with-GostR3410-94-cc";
+pub const LN_id_GostR3411_94_with_GostR3410_94_cc = "GOST R 34.11-94 with GOST R 34.10-94 Cryptocom";
+pub const NID_id_GostR3411_94_with_GostR3410_94_cc = @as(c_int, 852);
+pub const OBJ_id_GostR3411_94_with_GostR3410_94_cc = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 3);
+};
+pub const SN_id_GostR3411_94_with_GostR3410_2001_cc = "id-GostR3411-94-with-GostR3410-2001-cc";
+pub const LN_id_GostR3411_94_with_GostR3410_2001_cc = "GOST R 34.11-94 with GOST R 34.10-2001 Cryptocom";
+pub const NID_id_GostR3411_94_with_GostR3410_2001_cc = @as(c_int, 853);
+pub const OBJ_id_GostR3411_94_with_GostR3410_2001_cc = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 4);
+};
+pub const SN_id_GostR3410_2001_ParamSet_cc = "id-GostR3410-2001-ParamSet-cc";
+pub const LN_id_GostR3410_2001_ParamSet_cc = "GOST R 3410-2001 Parameter Set Cryptocom";
+pub const NID_id_GostR3410_2001_ParamSet_cc = @as(c_int, 854);
+pub const OBJ_id_GostR3410_2001_ParamSet_cc = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 643);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 8);
+ break :blk @as(c_long, 1);
+};
+pub const SN_hmac = "HMAC";
+pub const LN_hmac = "hmac";
+pub const NID_hmac = @as(c_int, 855);
+pub const SN_LocalKeySet = "LocalKeySet";
+pub const LN_LocalKeySet = "Microsoft Local Key set";
+pub const NID_LocalKeySet = @as(c_int, 856);
+pub const OBJ_LocalKeySet = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 311);
+ _ = @as(c_long, 17);
+ break :blk @as(c_long, 2);
+};
+pub const SN_freshest_crl = "freshestCRL";
+pub const LN_freshest_crl = "X509v3 Freshest CRL";
+pub const NID_freshest_crl = @as(c_int, 857);
+pub const OBJ_freshest_crl = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 29);
+ break :blk @as(c_long, 46);
+};
+pub const SN_id_on_permanentIdentifier = "id-on-permanentIdentifier";
+pub const LN_id_on_permanentIdentifier = "Permanent Identifier";
+pub const NID_id_on_permanentIdentifier = @as(c_int, 858);
+pub const OBJ_id_on_permanentIdentifier = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 6);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 7);
+ _ = @as(c_long, 8);
+ break :blk @as(c_long, 3);
+};
+pub const LN_searchGuide = "searchGuide";
+pub const NID_searchGuide = @as(c_int, 859);
+pub const OBJ_searchGuide = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 14);
+};
+pub const LN_businessCategory = "businessCategory";
+pub const NID_businessCategory = @as(c_int, 860);
+pub const OBJ_businessCategory = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 15);
+};
+pub const LN_postalAddress = "postalAddress";
+pub const NID_postalAddress = @as(c_int, 861);
+pub const OBJ_postalAddress = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 16);
+};
+pub const LN_postOfficeBox = "postOfficeBox";
+pub const NID_postOfficeBox = @as(c_int, 862);
+pub const OBJ_postOfficeBox = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 18);
+};
+pub const LN_physicalDeliveryOfficeName = "physicalDeliveryOfficeName";
+pub const NID_physicalDeliveryOfficeName = @as(c_int, 863);
+pub const OBJ_physicalDeliveryOfficeName = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 19);
+};
+pub const LN_telephoneNumber = "telephoneNumber";
+pub const NID_telephoneNumber = @as(c_int, 864);
+pub const OBJ_telephoneNumber = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 20);
+};
+pub const LN_telexNumber = "telexNumber";
+pub const NID_telexNumber = @as(c_int, 865);
+pub const OBJ_telexNumber = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 21);
+};
+pub const LN_teletexTerminalIdentifier = "teletexTerminalIdentifier";
+pub const NID_teletexTerminalIdentifier = @as(c_int, 866);
+pub const OBJ_teletexTerminalIdentifier = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 22);
+};
+pub const LN_facsimileTelephoneNumber = "facsimileTelephoneNumber";
+pub const NID_facsimileTelephoneNumber = @as(c_int, 867);
+pub const OBJ_facsimileTelephoneNumber = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 23);
+};
+pub const LN_x121Address = "x121Address";
+pub const NID_x121Address = @as(c_int, 868);
+pub const OBJ_x121Address = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 24);
+};
+pub const LN_internationaliSDNNumber = "internationaliSDNNumber";
+pub const NID_internationaliSDNNumber = @as(c_int, 869);
+pub const OBJ_internationaliSDNNumber = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 25);
+};
+pub const LN_registeredAddress = "registeredAddress";
+pub const NID_registeredAddress = @as(c_int, 870);
+pub const OBJ_registeredAddress = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 26);
+};
+pub const LN_destinationIndicator = "destinationIndicator";
+pub const NID_destinationIndicator = @as(c_int, 871);
+pub const OBJ_destinationIndicator = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 27);
+};
+pub const LN_preferredDeliveryMethod = "preferredDeliveryMethod";
+pub const NID_preferredDeliveryMethod = @as(c_int, 872);
+pub const OBJ_preferredDeliveryMethod = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 28);
+};
+pub const LN_presentationAddress = "presentationAddress";
+pub const NID_presentationAddress = @as(c_int, 873);
+pub const OBJ_presentationAddress = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 29);
+};
+pub const LN_supportedApplicationContext = "supportedApplicationContext";
+pub const NID_supportedApplicationContext = @as(c_int, 874);
+pub const OBJ_supportedApplicationContext = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 30);
+};
+pub const SN_member = "member";
+pub const NID_member = @as(c_int, 875);
+pub const OBJ_member = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 31);
+};
+pub const SN_owner = "owner";
+pub const NID_owner = @as(c_int, 876);
+pub const OBJ_owner = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 32);
+};
+pub const LN_roleOccupant = "roleOccupant";
+pub const NID_roleOccupant = @as(c_int, 877);
+pub const OBJ_roleOccupant = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 33);
+};
+pub const SN_seeAlso = "seeAlso";
+pub const NID_seeAlso = @as(c_int, 878);
+pub const OBJ_seeAlso = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 34);
+};
+pub const LN_userPassword = "userPassword";
+pub const NID_userPassword = @as(c_int, 879);
+pub const OBJ_userPassword = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 35);
+};
+pub const LN_userCertificate = "userCertificate";
+pub const NID_userCertificate = @as(c_int, 880);
+pub const OBJ_userCertificate = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 36);
+};
+pub const LN_cACertificate = "cACertificate";
+pub const NID_cACertificate = @as(c_int, 881);
+pub const OBJ_cACertificate = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 37);
+};
+pub const LN_authorityRevocationList = "authorityRevocationList";
+pub const NID_authorityRevocationList = @as(c_int, 882);
+pub const OBJ_authorityRevocationList = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 38);
+};
+pub const LN_certificateRevocationList = "certificateRevocationList";
+pub const NID_certificateRevocationList = @as(c_int, 883);
+pub const OBJ_certificateRevocationList = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 39);
+};
+pub const LN_crossCertificatePair = "crossCertificatePair";
+pub const NID_crossCertificatePair = @as(c_int, 884);
+pub const OBJ_crossCertificatePair = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 40);
+};
+pub const LN_enhancedSearchGuide = "enhancedSearchGuide";
+pub const NID_enhancedSearchGuide = @as(c_int, 885);
+pub const OBJ_enhancedSearchGuide = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 47);
+};
+pub const LN_protocolInformation = "protocolInformation";
+pub const NID_protocolInformation = @as(c_int, 886);
+pub const OBJ_protocolInformation = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 48);
+};
+pub const LN_distinguishedName = "distinguishedName";
+pub const NID_distinguishedName = @as(c_int, 887);
+pub const OBJ_distinguishedName = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 49);
+};
+pub const LN_uniqueMember = "uniqueMember";
+pub const NID_uniqueMember = @as(c_int, 888);
+pub const OBJ_uniqueMember = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 50);
+};
+pub const LN_houseIdentifier = "houseIdentifier";
+pub const NID_houseIdentifier = @as(c_int, 889);
+pub const OBJ_houseIdentifier = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 51);
+};
+pub const LN_supportedAlgorithms = "supportedAlgorithms";
+pub const NID_supportedAlgorithms = @as(c_int, 890);
+pub const OBJ_supportedAlgorithms = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 52);
+};
+pub const LN_deltaRevocationList = "deltaRevocationList";
+pub const NID_deltaRevocationList = @as(c_int, 891);
+pub const OBJ_deltaRevocationList = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 53);
+};
+pub const SN_dmdName = "dmdName";
+pub const NID_dmdName = @as(c_int, 892);
+pub const OBJ_dmdName = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 4);
+ break :blk @as(c_long, 54);
+};
+pub const SN_id_alg_PWRI_KEK = "id-alg-PWRI-KEK";
+pub const NID_id_alg_PWRI_KEK = @as(c_int, 893);
+pub const OBJ_id_alg_PWRI_KEK = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 9);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 9);
+};
+pub const SN_cmac = "CMAC";
+pub const LN_cmac = "cmac";
+pub const NID_cmac = @as(c_int, 894);
+pub const SN_aes_128_gcm = "id-aes128-GCM";
+pub const LN_aes_128_gcm = "aes-128-gcm";
+pub const NID_aes_128_gcm = @as(c_int, 895);
+pub const OBJ_aes_128_gcm = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 6);
+};
+pub const SN_aes_128_ccm = "id-aes128-CCM";
+pub const LN_aes_128_ccm = "aes-128-ccm";
+pub const NID_aes_128_ccm = @as(c_int, 896);
+pub const OBJ_aes_128_ccm = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 7);
+};
+pub const SN_id_aes128_wrap_pad = "id-aes128-wrap-pad";
+pub const NID_id_aes128_wrap_pad = @as(c_int, 897);
+pub const OBJ_id_aes128_wrap_pad = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 8);
+};
+pub const SN_aes_192_gcm = "id-aes192-GCM";
+pub const LN_aes_192_gcm = "aes-192-gcm";
+pub const NID_aes_192_gcm = @as(c_int, 898);
+pub const OBJ_aes_192_gcm = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 26);
+};
+pub const SN_aes_192_ccm = "id-aes192-CCM";
+pub const LN_aes_192_ccm = "aes-192-ccm";
+pub const NID_aes_192_ccm = @as(c_int, 899);
+pub const OBJ_aes_192_ccm = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 27);
+};
+pub const SN_id_aes192_wrap_pad = "id-aes192-wrap-pad";
+pub const NID_id_aes192_wrap_pad = @as(c_int, 900);
+pub const OBJ_id_aes192_wrap_pad = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 28);
+};
+pub const SN_aes_256_gcm = "id-aes256-GCM";
+pub const LN_aes_256_gcm = "aes-256-gcm";
+pub const NID_aes_256_gcm = @as(c_int, 901);
+pub const OBJ_aes_256_gcm = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 46);
+};
+pub const SN_aes_256_ccm = "id-aes256-CCM";
+pub const LN_aes_256_ccm = "aes-256-ccm";
+pub const NID_aes_256_ccm = @as(c_int, 902);
+pub const OBJ_aes_256_ccm = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 47);
+};
+pub const SN_id_aes256_wrap_pad = "id-aes256-wrap-pad";
+pub const NID_id_aes256_wrap_pad = @as(c_int, 903);
+pub const OBJ_id_aes256_wrap_pad = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 48);
+};
+pub const SN_aes_128_ctr = "AES-128-CTR";
+pub const LN_aes_128_ctr = "aes-128-ctr";
+pub const NID_aes_128_ctr = @as(c_int, 904);
+pub const SN_aes_192_ctr = "AES-192-CTR";
+pub const LN_aes_192_ctr = "aes-192-ctr";
+pub const NID_aes_192_ctr = @as(c_int, 905);
+pub const SN_aes_256_ctr = "AES-256-CTR";
+pub const LN_aes_256_ctr = "aes-256-ctr";
+pub const NID_aes_256_ctr = @as(c_int, 906);
+pub const SN_id_camellia128_wrap = "id-camellia128-wrap";
+pub const NID_id_camellia128_wrap = @as(c_int, 907);
+pub const OBJ_id_camellia128_wrap = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 392);
+ _ = @as(c_long, 200011);
+ _ = @as(c_long, 61);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 2);
+};
+pub const SN_id_camellia192_wrap = "id-camellia192-wrap";
+pub const NID_id_camellia192_wrap = @as(c_int, 908);
+pub const OBJ_id_camellia192_wrap = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 392);
+ _ = @as(c_long, 200011);
+ _ = @as(c_long, 61);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 3);
+};
+pub const SN_id_camellia256_wrap = "id-camellia256-wrap";
+pub const NID_id_camellia256_wrap = @as(c_int, 909);
+pub const OBJ_id_camellia256_wrap = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 392);
+ _ = @as(c_long, 200011);
+ _ = @as(c_long, 61);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ break :blk @as(c_long, 4);
+};
+pub const SN_anyExtendedKeyUsage = "anyExtendedKeyUsage";
+pub const LN_anyExtendedKeyUsage = "Any Extended Key Usage";
+pub const NID_anyExtendedKeyUsage = @as(c_int, 910);
+pub const OBJ_anyExtendedKeyUsage = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 5);
+ _ = @as(c_long, 29);
+ _ = @as(c_long, 37);
+ break :blk @as(c_long, 0);
+};
+pub const SN_mgf1 = "MGF1";
+pub const LN_mgf1 = "mgf1";
+pub const NID_mgf1 = @as(c_int, 911);
+pub const OBJ_mgf1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 8);
+};
+pub const SN_rsassaPss = "RSASSA-PSS";
+pub const LN_rsassaPss = "rsassaPss";
+pub const NID_rsassaPss = @as(c_int, 912);
+pub const OBJ_rsassaPss = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 10);
+};
+pub const SN_aes_128_xts = "AES-128-XTS";
+pub const LN_aes_128_xts = "aes-128-xts";
+pub const NID_aes_128_xts = @as(c_int, 913);
+pub const SN_aes_256_xts = "AES-256-XTS";
+pub const LN_aes_256_xts = "aes-256-xts";
+pub const NID_aes_256_xts = @as(c_int, 914);
+pub const SN_rc4_hmac_md5 = "RC4-HMAC-MD5";
+pub const LN_rc4_hmac_md5 = "rc4-hmac-md5";
+pub const NID_rc4_hmac_md5 = @as(c_int, 915);
+pub const SN_aes_128_cbc_hmac_sha1 = "AES-128-CBC-HMAC-SHA1";
+pub const LN_aes_128_cbc_hmac_sha1 = "aes-128-cbc-hmac-sha1";
+pub const NID_aes_128_cbc_hmac_sha1 = @as(c_int, 916);
+pub const SN_aes_192_cbc_hmac_sha1 = "AES-192-CBC-HMAC-SHA1";
+pub const LN_aes_192_cbc_hmac_sha1 = "aes-192-cbc-hmac-sha1";
+pub const NID_aes_192_cbc_hmac_sha1 = @as(c_int, 917);
+pub const SN_aes_256_cbc_hmac_sha1 = "AES-256-CBC-HMAC-SHA1";
+pub const LN_aes_256_cbc_hmac_sha1 = "aes-256-cbc-hmac-sha1";
+pub const NID_aes_256_cbc_hmac_sha1 = @as(c_int, 918);
+pub const SN_rsaesOaep = "RSAES-OAEP";
+pub const LN_rsaesOaep = "rsaesOaep";
+pub const NID_rsaesOaep = @as(c_int, 919);
+pub const OBJ_rsaesOaep = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 7);
+};
+pub const SN_dhpublicnumber = "dhpublicnumber";
+pub const LN_dhpublicnumber = "X9.42 DH";
+pub const NID_dhpublicnumber = @as(c_int, 920);
+pub const OBJ_dhpublicnumber = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 10046);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 1);
+};
+pub const SN_brainpoolP160r1 = "brainpoolP160r1";
+pub const NID_brainpoolP160r1 = @as(c_int, 921);
+pub const OBJ_brainpoolP160r1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 36);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 8);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 1);
+};
+pub const SN_brainpoolP160t1 = "brainpoolP160t1";
+pub const NID_brainpoolP160t1 = @as(c_int, 922);
+pub const OBJ_brainpoolP160t1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 36);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 8);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 2);
+};
+pub const SN_brainpoolP192r1 = "brainpoolP192r1";
+pub const NID_brainpoolP192r1 = @as(c_int, 923);
+pub const OBJ_brainpoolP192r1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 36);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 8);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 3);
+};
+pub const SN_brainpoolP192t1 = "brainpoolP192t1";
+pub const NID_brainpoolP192t1 = @as(c_int, 924);
+pub const OBJ_brainpoolP192t1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 36);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 8);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 4);
+};
+pub const SN_brainpoolP224r1 = "brainpoolP224r1";
+pub const NID_brainpoolP224r1 = @as(c_int, 925);
+pub const OBJ_brainpoolP224r1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 36);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 8);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 5);
+};
+pub const SN_brainpoolP224t1 = "brainpoolP224t1";
+pub const NID_brainpoolP224t1 = @as(c_int, 926);
+pub const OBJ_brainpoolP224t1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 36);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 8);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 6);
+};
+pub const SN_brainpoolP256r1 = "brainpoolP256r1";
+pub const NID_brainpoolP256r1 = @as(c_int, 927);
+pub const OBJ_brainpoolP256r1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 36);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 8);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 7);
+};
+pub const SN_brainpoolP256t1 = "brainpoolP256t1";
+pub const NID_brainpoolP256t1 = @as(c_int, 928);
+pub const OBJ_brainpoolP256t1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 36);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 8);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 8);
+};
+pub const SN_brainpoolP320r1 = "brainpoolP320r1";
+pub const NID_brainpoolP320r1 = @as(c_int, 929);
+pub const OBJ_brainpoolP320r1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 36);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 8);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 9);
+};
+pub const SN_brainpoolP320t1 = "brainpoolP320t1";
+pub const NID_brainpoolP320t1 = @as(c_int, 930);
+pub const OBJ_brainpoolP320t1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 36);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 8);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 10);
+};
+pub const SN_brainpoolP384r1 = "brainpoolP384r1";
+pub const NID_brainpoolP384r1 = @as(c_int, 931);
+pub const OBJ_brainpoolP384r1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 36);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 8);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 11);
+};
+pub const SN_brainpoolP384t1 = "brainpoolP384t1";
+pub const NID_brainpoolP384t1 = @as(c_int, 932);
+pub const OBJ_brainpoolP384t1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 36);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 8);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 12);
+};
+pub const SN_brainpoolP512r1 = "brainpoolP512r1";
+pub const NID_brainpoolP512r1 = @as(c_int, 933);
+pub const OBJ_brainpoolP512r1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 36);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 8);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 13);
+};
+pub const SN_brainpoolP512t1 = "brainpoolP512t1";
+pub const NID_brainpoolP512t1 = @as(c_int, 934);
+pub const OBJ_brainpoolP512t1 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 36);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 8);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 14);
+};
+pub const SN_pSpecified = "PSPECIFIED";
+pub const LN_pSpecified = "pSpecified";
+pub const NID_pSpecified = @as(c_int, 935);
+pub const OBJ_pSpecified = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 113549);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 1);
+ break :blk @as(c_long, 9);
+};
+pub const SN_dhSinglePass_stdDH_sha1kdf_scheme = "dhSinglePass-stdDH-sha1kdf-scheme";
+pub const NID_dhSinglePass_stdDH_sha1kdf_scheme = @as(c_int, 936);
+pub const OBJ_dhSinglePass_stdDH_sha1kdf_scheme = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 133);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 63);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 2);
+};
+pub const SN_dhSinglePass_stdDH_sha224kdf_scheme = "dhSinglePass-stdDH-sha224kdf-scheme";
+pub const NID_dhSinglePass_stdDH_sha224kdf_scheme = @as(c_int, 937);
+pub const OBJ_dhSinglePass_stdDH_sha224kdf_scheme = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 11);
+ break :blk @as(c_long, 0);
+};
+pub const SN_dhSinglePass_stdDH_sha256kdf_scheme = "dhSinglePass-stdDH-sha256kdf-scheme";
+pub const NID_dhSinglePass_stdDH_sha256kdf_scheme = @as(c_int, 938);
+pub const OBJ_dhSinglePass_stdDH_sha256kdf_scheme = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 11);
+ break :blk @as(c_long, 1);
+};
+pub const SN_dhSinglePass_stdDH_sha384kdf_scheme = "dhSinglePass-stdDH-sha384kdf-scheme";
+pub const NID_dhSinglePass_stdDH_sha384kdf_scheme = @as(c_int, 939);
+pub const OBJ_dhSinglePass_stdDH_sha384kdf_scheme = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 11);
+ break :blk @as(c_long, 2);
+};
+pub const SN_dhSinglePass_stdDH_sha512kdf_scheme = "dhSinglePass-stdDH-sha512kdf-scheme";
+pub const NID_dhSinglePass_stdDH_sha512kdf_scheme = @as(c_int, 940);
+pub const OBJ_dhSinglePass_stdDH_sha512kdf_scheme = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 11);
+ break :blk @as(c_long, 3);
+};
+pub const SN_dhSinglePass_cofactorDH_sha1kdf_scheme = "dhSinglePass-cofactorDH-sha1kdf-scheme";
+pub const NID_dhSinglePass_cofactorDH_sha1kdf_scheme = @as(c_int, 941);
+pub const OBJ_dhSinglePass_cofactorDH_sha1kdf_scheme = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 133);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 63);
+ _ = @as(c_long, 0);
+ break :blk @as(c_long, 3);
+};
+pub const SN_dhSinglePass_cofactorDH_sha224kdf_scheme = "dhSinglePass-cofactorDH-sha224kdf-scheme";
+pub const NID_dhSinglePass_cofactorDH_sha224kdf_scheme = @as(c_int, 942);
+pub const OBJ_dhSinglePass_cofactorDH_sha224kdf_scheme = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 14);
+ break :blk @as(c_long, 0);
+};
+pub const SN_dhSinglePass_cofactorDH_sha256kdf_scheme = "dhSinglePass-cofactorDH-sha256kdf-scheme";
+pub const NID_dhSinglePass_cofactorDH_sha256kdf_scheme = @as(c_int, 943);
+pub const OBJ_dhSinglePass_cofactorDH_sha256kdf_scheme = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 14);
+ break :blk @as(c_long, 1);
+};
+pub const SN_dhSinglePass_cofactorDH_sha384kdf_scheme = "dhSinglePass-cofactorDH-sha384kdf-scheme";
+pub const NID_dhSinglePass_cofactorDH_sha384kdf_scheme = @as(c_int, 944);
+pub const OBJ_dhSinglePass_cofactorDH_sha384kdf_scheme = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 14);
+ break :blk @as(c_long, 2);
+};
+pub const SN_dhSinglePass_cofactorDH_sha512kdf_scheme = "dhSinglePass-cofactorDH-sha512kdf-scheme";
+pub const NID_dhSinglePass_cofactorDH_sha512kdf_scheme = @as(c_int, 945);
+pub const OBJ_dhSinglePass_cofactorDH_sha512kdf_scheme = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 132);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 14);
+ break :blk @as(c_long, 3);
+};
+pub const SN_dh_std_kdf = "dh-std-kdf";
+pub const NID_dh_std_kdf = @as(c_int, 946);
+pub const SN_dh_cofactor_kdf = "dh-cofactor-kdf";
+pub const NID_dh_cofactor_kdf = @as(c_int, 947);
+pub const SN_X25519 = "X25519";
+pub const NID_X25519 = @as(c_int, 948);
+pub const OBJ_X25519 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 101);
+ break :blk @as(c_long, 110);
+};
+pub const SN_ED25519 = "ED25519";
+pub const NID_ED25519 = @as(c_int, 949);
+pub const OBJ_ED25519 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 101);
+ break :blk @as(c_long, 112);
+};
+pub const SN_chacha20_poly1305 = "ChaCha20-Poly1305";
+pub const LN_chacha20_poly1305 = "chacha20-poly1305";
+pub const NID_chacha20_poly1305 = @as(c_int, 950);
+pub const SN_kx_rsa = "KxRSA";
+pub const LN_kx_rsa = "kx-rsa";
+pub const NID_kx_rsa = @as(c_int, 951);
+pub const SN_kx_ecdhe = "KxECDHE";
+pub const LN_kx_ecdhe = "kx-ecdhe";
+pub const NID_kx_ecdhe = @as(c_int, 952);
+pub const SN_kx_psk = "KxPSK";
+pub const LN_kx_psk = "kx-psk";
+pub const NID_kx_psk = @as(c_int, 953);
+pub const SN_auth_rsa = "AuthRSA";
+pub const LN_auth_rsa = "auth-rsa";
+pub const NID_auth_rsa = @as(c_int, 954);
+pub const SN_auth_ecdsa = "AuthECDSA";
+pub const LN_auth_ecdsa = "auth-ecdsa";
+pub const NID_auth_ecdsa = @as(c_int, 955);
+pub const SN_auth_psk = "AuthPSK";
+pub const LN_auth_psk = "auth-psk";
+pub const NID_auth_psk = @as(c_int, 956);
+pub const SN_kx_any = "KxANY";
+pub const LN_kx_any = "kx-any";
+pub const NID_kx_any = @as(c_int, 957);
+pub const SN_auth_any = "AuthANY";
+pub const LN_auth_any = "auth-any";
+pub const NID_auth_any = @as(c_int, 958);
+pub const SN_CECPQ2 = "CECPQ2";
+pub const NID_CECPQ2 = @as(c_int, 959);
+pub const SN_ED448 = "ED448";
+pub const NID_ED448 = @as(c_int, 960);
+pub const OBJ_ED448 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 101);
+ break :blk @as(c_long, 113);
+};
+pub const SN_X448 = "X448";
+pub const NID_X448 = @as(c_int, 961);
+pub const OBJ_X448 = blk: {
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 101);
+ break :blk @as(c_long, 111);
+};
+pub const SN_sha512_256 = "SHA512-256";
+pub const LN_sha512_256 = "sha512-256";
+pub const NID_sha512_256 = @as(c_int, 962);
+pub const OBJ_sha512_256 = blk: {
+ _ = @as(c_long, 2);
+ _ = @as(c_long, 16);
+ _ = @as(c_long, 840);
+ _ = @as(c_long, 1);
+ _ = @as(c_long, 101);
+ _ = @as(c_long, 3);
+ _ = @as(c_long, 4);
+ _ = @as(c_long, 2);
+ break :blk @as(c_long, 6);
+};
+pub const EVP_PKEY_NONE = NID_undef;
+pub const EVP_PKEY_RSA = NID_rsaEncryption;
+pub const EVP_PKEY_RSA_PSS = NID_rsassaPss;
+pub const EVP_PKEY_DSA = NID_dsa;
+pub const EVP_PKEY_EC = NID_X9_62_id_ecPublicKey;
+pub const EVP_PKEY_ED25519 = NID_ED25519;
+pub const EVP_PKEY_X25519 = NID_X25519;
+pub const EVP_PKEY_DH = NID_dhKeyAgreement;
+pub const EVP_PKEY_RSA2 = NID_rsa;
+pub const EVP_PKEY_X448 = NID_X448;
+pub const EVP_PKEY_ED448 = NID_ED448;
+pub inline fn EVPerr(function: anytype, reason: anytype) @TypeOf(ERR_put_error(ERR_LIB_EVP, @as(c_int, 0), reason, __FILE__, __LINE__)) {
+ _ = function;
+ return ERR_put_error(ERR_LIB_EVP, @as(c_int, 0), reason, __FILE__, __LINE__);
+}
+pub const PKCS7_DETACHED = @as(c_int, 0x40);
+pub const PKCS7_TEXT = @as(c_int, 0x1);
+pub const PKCS7_NOCERTS = @as(c_int, 0x2);
+pub const PKCS7_NOSIGS = @as(c_int, 0x4);
+pub const PKCS7_NOCHAIN = @as(c_int, 0x8);
+pub const PKCS7_NOINTERN = @as(c_int, 0x10);
+pub const PKCS7_NOVERIFY = @as(c_int, 0x20);
+pub const PKCS7_BINARY = @as(c_int, 0x80);
+pub const PKCS7_NOATTR = @as(c_int, 0x100);
+pub const PKCS7_NOSMIMECAP = @as(c_int, 0x200);
+pub const PKCS7_STREAM = @as(c_int, 0x1000);
+pub const PKCS7_PARTIAL = @as(c_int, 0x4000);
+pub const PKCS7_R_BAD_PKCS7_VERSION = @as(c_int, 100);
+pub const PKCS7_R_NOT_PKCS7_SIGNED_DATA = @as(c_int, 101);
+pub const PKCS7_R_NO_CERTIFICATES_INCLUDED = @as(c_int, 102);
+pub const PKCS7_R_NO_CRLS_INCLUDED = @as(c_int, 103);
+pub const _STRUCT_TIMESPEC = struct_timespec;
+pub const CLOCKS_PER_SEC = @import("std").zig.c_translation.promoteIntLiteral(c_int, 1000000, .decimal);
+pub const CLOCK_REALTIME = _CLOCK_REALTIME;
+pub const CLOCK_MONOTONIC = _CLOCK_MONOTONIC;
+pub const CLOCK_MONOTONIC_RAW = _CLOCK_MONOTONIC_RAW;
+pub const CLOCK_MONOTONIC_RAW_APPROX = _CLOCK_MONOTONIC_RAW_APPROX;
+pub const CLOCK_UPTIME_RAW = _CLOCK_UPTIME_RAW;
+pub const CLOCK_UPTIME_RAW_APPROX = _CLOCK_UPTIME_RAW_APPROX;
+pub const CLOCK_PROCESS_CPUTIME_ID = _CLOCK_PROCESS_CPUTIME_ID;
+pub const CLOCK_THREAD_CPUTIME_ID = _CLOCK_THREAD_CPUTIME_ID;
+pub const TIME_UTC = @as(c_int, 1);
+pub const __PRI_8_LENGTH_MODIFIER__ = "hh";
+pub const __PRI_64_LENGTH_MODIFIER__ = "ll";
+pub const __SCN_64_LENGTH_MODIFIER__ = "ll";
+pub const __PRI_MAX_LENGTH_MODIFIER__ = "j";
+pub const __SCN_MAX_LENGTH_MODIFIER__ = "j";
+pub const PRId8 = __PRI_8_LENGTH_MODIFIER__ ++ "d";
+pub const PRIi8 = __PRI_8_LENGTH_MODIFIER__ ++ "i";
+pub const PRIo8 = __PRI_8_LENGTH_MODIFIER__ ++ "o";
+pub const PRIu8 = __PRI_8_LENGTH_MODIFIER__ ++ "u";
+pub const PRIx8 = __PRI_8_LENGTH_MODIFIER__ ++ "x";
+pub const PRIX8 = __PRI_8_LENGTH_MODIFIER__ ++ "X";
+pub const PRId16 = "hd";
+pub const PRIi16 = "hi";
+pub const PRIo16 = "ho";
+pub const PRIu16 = "hu";
+pub const PRIx16 = "hx";
+pub const PRIX16 = "hX";
+pub const PRId32 = "d";
+pub const PRIi32 = "i";
+pub const PRIo32 = "o";
+pub const PRIu32 = "u";
+pub const PRIx32 = "x";
+pub const PRIX32 = "X";
+pub const PRId64 = __PRI_64_LENGTH_MODIFIER__ ++ "d";
+pub const PRIi64 = __PRI_64_LENGTH_MODIFIER__ ++ "i";
+pub const PRIo64 = __PRI_64_LENGTH_MODIFIER__ ++ "o";
+pub const PRIu64 = __PRI_64_LENGTH_MODIFIER__ ++ "u";
+pub const PRIx64 = __PRI_64_LENGTH_MODIFIER__ ++ "x";
+pub const PRIX64 = __PRI_64_LENGTH_MODIFIER__ ++ "X";
+pub const PRIdLEAST8 = PRId8;
+pub const PRIiLEAST8 = PRIi8;
+pub const PRIoLEAST8 = PRIo8;
+pub const PRIuLEAST8 = PRIu8;
+pub const PRIxLEAST8 = PRIx8;
+pub const PRIXLEAST8 = PRIX8;
+pub const PRIdLEAST16 = PRId16;
+pub const PRIiLEAST16 = PRIi16;
+pub const PRIoLEAST16 = PRIo16;
+pub const PRIuLEAST16 = PRIu16;
+pub const PRIxLEAST16 = PRIx16;
+pub const PRIXLEAST16 = PRIX16;
+pub const PRIdLEAST32 = PRId32;
+pub const PRIiLEAST32 = PRIi32;
+pub const PRIoLEAST32 = PRIo32;
+pub const PRIuLEAST32 = PRIu32;
+pub const PRIxLEAST32 = PRIx32;
+pub const PRIXLEAST32 = PRIX32;
+pub const PRIdLEAST64 = PRId64;
+pub const PRIiLEAST64 = PRIi64;
+pub const PRIoLEAST64 = PRIo64;
+pub const PRIuLEAST64 = PRIu64;
+pub const PRIxLEAST64 = PRIx64;
+pub const PRIXLEAST64 = PRIX64;
+pub const PRIdFAST8 = PRId8;
+pub const PRIiFAST8 = PRIi8;
+pub const PRIoFAST8 = PRIo8;
+pub const PRIuFAST8 = PRIu8;
+pub const PRIxFAST8 = PRIx8;
+pub const PRIXFAST8 = PRIX8;
+pub const PRIdFAST16 = PRId16;
+pub const PRIiFAST16 = PRIi16;
+pub const PRIoFAST16 = PRIo16;
+pub const PRIuFAST16 = PRIu16;
+pub const PRIxFAST16 = PRIx16;
+pub const PRIXFAST16 = PRIX16;
+pub const PRIdFAST32 = PRId32;
+pub const PRIiFAST32 = PRIi32;
+pub const PRIoFAST32 = PRIo32;
+pub const PRIuFAST32 = PRIu32;
+pub const PRIxFAST32 = PRIx32;
+pub const PRIXFAST32 = PRIX32;
+pub const PRIdFAST64 = PRId64;
+pub const PRIiFAST64 = PRIi64;
+pub const PRIoFAST64 = PRIo64;
+pub const PRIuFAST64 = PRIu64;
+pub const PRIxFAST64 = PRIx64;
+pub const PRIXFAST64 = PRIX64;
+pub const PRIdPTR = "ld";
+pub const PRIiPTR = "li";
+pub const PRIoPTR = "lo";
+pub const PRIuPTR = "lu";
+pub const PRIxPTR = "lx";
+pub const PRIXPTR = "lX";
+pub const PRIdMAX = __PRI_MAX_LENGTH_MODIFIER__ ++ "d";
+pub const PRIiMAX = __PRI_MAX_LENGTH_MODIFIER__ ++ "i";
+pub const PRIoMAX = __PRI_MAX_LENGTH_MODIFIER__ ++ "o";
+pub const PRIuMAX = __PRI_MAX_LENGTH_MODIFIER__ ++ "u";
+pub const PRIxMAX = __PRI_MAX_LENGTH_MODIFIER__ ++ "x";
+pub const PRIXMAX = __PRI_MAX_LENGTH_MODIFIER__ ++ "X";
+pub const SCNd8 = __PRI_8_LENGTH_MODIFIER__ ++ "d";
+pub const SCNi8 = __PRI_8_LENGTH_MODIFIER__ ++ "i";
+pub const SCNo8 = __PRI_8_LENGTH_MODIFIER__ ++ "o";
+pub const SCNu8 = __PRI_8_LENGTH_MODIFIER__ ++ "u";
+pub const SCNx8 = __PRI_8_LENGTH_MODIFIER__ ++ "x";
+pub const SCNd16 = "hd";
+pub const SCNi16 = "hi";
+pub const SCNo16 = "ho";
+pub const SCNu16 = "hu";
+pub const SCNx16 = "hx";
+pub const SCNd32 = "d";
+pub const SCNi32 = "i";
+pub const SCNo32 = "o";
+pub const SCNu32 = "u";
+pub const SCNx32 = "x";
+pub const SCNd64 = __SCN_64_LENGTH_MODIFIER__ ++ "d";
+pub const SCNi64 = __SCN_64_LENGTH_MODIFIER__ ++ "i";
+pub const SCNo64 = __SCN_64_LENGTH_MODIFIER__ ++ "o";
+pub const SCNu64 = __SCN_64_LENGTH_MODIFIER__ ++ "u";
+pub const SCNx64 = __SCN_64_LENGTH_MODIFIER__ ++ "x";
+pub const SCNdLEAST8 = SCNd8;
+pub const SCNiLEAST8 = SCNi8;
+pub const SCNoLEAST8 = SCNo8;
+pub const SCNuLEAST8 = SCNu8;
+pub const SCNxLEAST8 = SCNx8;
+pub const SCNdLEAST16 = SCNd16;
+pub const SCNiLEAST16 = SCNi16;
+pub const SCNoLEAST16 = SCNo16;
+pub const SCNuLEAST16 = SCNu16;
+pub const SCNxLEAST16 = SCNx16;
+pub const SCNdLEAST32 = SCNd32;
+pub const SCNiLEAST32 = SCNi32;
+pub const SCNoLEAST32 = SCNo32;
+pub const SCNuLEAST32 = SCNu32;
+pub const SCNxLEAST32 = SCNx32;
+pub const SCNdLEAST64 = SCNd64;
+pub const SCNiLEAST64 = SCNi64;
+pub const SCNoLEAST64 = SCNo64;
+pub const SCNuLEAST64 = SCNu64;
+pub const SCNxLEAST64 = SCNx64;
+pub const SCNdFAST8 = SCNd8;
+pub const SCNiFAST8 = SCNi8;
+pub const SCNoFAST8 = SCNo8;
+pub const SCNuFAST8 = SCNu8;
+pub const SCNxFAST8 = SCNx8;
+pub const SCNdFAST16 = SCNd16;
+pub const SCNiFAST16 = SCNi16;
+pub const SCNoFAST16 = SCNo16;
+pub const SCNuFAST16 = SCNu16;
+pub const SCNxFAST16 = SCNx16;
+pub const SCNdFAST32 = SCNd32;
+pub const SCNiFAST32 = SCNi32;
+pub const SCNoFAST32 = SCNo32;
+pub const SCNuFAST32 = SCNu32;
+pub const SCNxFAST32 = SCNx32;
+pub const SCNdFAST64 = SCNd64;
+pub const SCNiFAST64 = SCNi64;
+pub const SCNoFAST64 = SCNo64;
+pub const SCNuFAST64 = SCNu64;
+pub const SCNxFAST64 = SCNx64;
+pub const SCNdPTR = "ld";
+pub const SCNiPTR = "li";
+pub const SCNoPTR = "lo";
+pub const SCNuPTR = "lu";
+pub const SCNxPTR = "lx";
+pub const SCNdMAX = __SCN_MAX_LENGTH_MODIFIER__ ++ "d";
+pub const SCNiMAX = __SCN_MAX_LENGTH_MODIFIER__ ++ "i";
+pub const SCNoMAX = __SCN_MAX_LENGTH_MODIFIER__ ++ "o";
+pub const SCNuMAX = __SCN_MAX_LENGTH_MODIFIER__ ++ "u";
+pub const SCNxMAX = __SCN_MAX_LENGTH_MODIFIER__ ++ "x";
+pub const BN_ULONG = u64;
+pub const BN_BITS2 = @as(c_int, 64);
+pub const BN_DEC_FMT1 = "%" ++ PRIu64;
+pub const BN_DEC_FMT2 = "%019" ++ PRIu64;
+pub const BN_HEX_FMT1 = "%" ++ PRIx64;
+pub const BN_HEX_FMT2 = "%016" ++ PRIx64;
+pub inline fn BN_mod(rem: anytype, numerator: anytype, divisor: anytype, ctx: anytype) @TypeOf(BN_div(NULL, rem, numerator, divisor, ctx)) {
+ return BN_div(NULL, rem, numerator, divisor, ctx);
+}
+pub const BN_RAND_TOP_ANY = -@as(c_int, 1);
+pub const BN_RAND_TOP_ONE = @as(c_int, 0);
+pub const BN_RAND_TOP_TWO = @as(c_int, 1);
+pub const BN_RAND_BOTTOM_ANY = @as(c_int, 0);
+pub const BN_RAND_BOTTOM_ODD = @as(c_int, 1);
+pub const BN_GENCB_GENERATED = @as(c_int, 0);
+pub const BN_GENCB_PRIME_TEST = @as(c_int, 1);
+pub const BN_prime_checks_for_validation = @as(c_int, 64);
+pub const BN_prime_checks_for_generation = @as(c_int, 0);
+pub const BN_prime_checks = BN_prime_checks_for_validation;
+pub const BN_FLG_MALLOCED = @as(c_int, 0x01);
+pub const BN_FLG_STATIC_DATA = @as(c_int, 0x02);
+pub const BN_R_ARG2_LT_ARG3 = @as(c_int, 100);
+pub const BN_R_BAD_RECIPROCAL = @as(c_int, 101);
+pub const BN_R_BIGNUM_TOO_LONG = @as(c_int, 102);
+pub const BN_R_BITS_TOO_SMALL = @as(c_int, 103);
+pub const BN_R_CALLED_WITH_EVEN_MODULUS = @as(c_int, 104);
+pub const BN_R_DIV_BY_ZERO = @as(c_int, 105);
+pub const BN_R_EXPAND_ON_STATIC_BIGNUM_DATA = @as(c_int, 106);
+pub const BN_R_INPUT_NOT_REDUCED = @as(c_int, 107);
+pub const BN_R_INVALID_RANGE = @as(c_int, 108);
+pub const BN_R_NEGATIVE_NUMBER = @as(c_int, 109);
+pub const BN_R_NOT_A_SQUARE = @as(c_int, 110);
+pub const BN_R_NOT_INITIALIZED = @as(c_int, 111);
+pub const BN_R_NO_INVERSE = @as(c_int, 112);
+pub const BN_R_PRIVATE_KEY_TOO_LARGE = @as(c_int, 113);
+pub const BN_R_P_IS_NOT_PRIME = @as(c_int, 114);
+pub const BN_R_TOO_MANY_ITERATIONS = @as(c_int, 115);
+pub const BN_R_TOO_MANY_TEMPORARY_VARIABLES = @as(c_int, 116);
+pub const BN_R_BAD_ENCODING = @as(c_int, 117);
+pub const BN_R_ENCODE_ERROR = @as(c_int, 118);
+pub const BN_R_INVALID_INPUT = @as(c_int, 119);
+pub const V_ASN1_UNIVERSAL = @as(c_int, 0x00);
+pub const V_ASN1_APPLICATION = @as(c_int, 0x40);
+pub const V_ASN1_CONTEXT_SPECIFIC = @as(c_int, 0x80);
+pub const V_ASN1_PRIVATE = @as(c_int, 0xc0);
+pub const V_ASN1_CONSTRUCTED = @as(c_int, 0x20);
+pub const V_ASN1_PRIMITIVE_TAG = @as(c_int, 0x1f);
+pub const V_ASN1_MAX_UNIVERSAL = @as(c_int, 0xff);
+pub const V_ASN1_UNDEF = -@as(c_int, 1);
+pub const V_ASN1_OTHER = -@as(c_int, 3);
+pub const V_ASN1_ANY = -@as(c_int, 4);
+pub const V_ASN1_EOC = @as(c_int, 0);
+pub const V_ASN1_BOOLEAN = @as(c_int, 1);
+pub const V_ASN1_INTEGER = @as(c_int, 2);
+pub const V_ASN1_BIT_STRING = @as(c_int, 3);
+pub const V_ASN1_OCTET_STRING = @as(c_int, 4);
+pub const V_ASN1_NULL = @as(c_int, 5);
+pub const V_ASN1_OBJECT = @as(c_int, 6);
+pub const V_ASN1_OBJECT_DESCRIPTOR = @as(c_int, 7);
+pub const V_ASN1_EXTERNAL = @as(c_int, 8);
+pub const V_ASN1_REAL = @as(c_int, 9);
+pub const V_ASN1_ENUMERATED = @as(c_int, 10);
+pub const V_ASN1_UTF8STRING = @as(c_int, 12);
+pub const V_ASN1_SEQUENCE = @as(c_int, 16);
+pub const V_ASN1_SET = @as(c_int, 17);
+pub const V_ASN1_NUMERICSTRING = @as(c_int, 18);
+pub const V_ASN1_PRINTABLESTRING = @as(c_int, 19);
+pub const V_ASN1_T61STRING = @as(c_int, 20);
+pub const V_ASN1_TELETEXSTRING = @as(c_int, 20);
+pub const V_ASN1_VIDEOTEXSTRING = @as(c_int, 21);
+pub const V_ASN1_IA5STRING = @as(c_int, 22);
+pub const V_ASN1_UTCTIME = @as(c_int, 23);
+pub const V_ASN1_GENERALIZEDTIME = @as(c_int, 24);
+pub const V_ASN1_GRAPHICSTRING = @as(c_int, 25);
+pub const V_ASN1_ISO64STRING = @as(c_int, 26);
+pub const V_ASN1_VISIBLESTRING = @as(c_int, 26);
+pub const V_ASN1_GENERALSTRING = @as(c_int, 27);
+pub const V_ASN1_UNIVERSALSTRING = @as(c_int, 28);
+pub const V_ASN1_BMPSTRING = @as(c_int, 30);
+pub const V_ASN1_NEG = @as(c_int, 0x100);
+pub const V_ASN1_NEG_INTEGER = V_ASN1_INTEGER | V_ASN1_NEG;
+pub const V_ASN1_NEG_ENUMERATED = V_ASN1_ENUMERATED | V_ASN1_NEG;
+pub const B_ASN1_NUMERICSTRING = @as(c_int, 0x0001);
+pub const B_ASN1_PRINTABLESTRING = @as(c_int, 0x0002);
+pub const B_ASN1_T61STRING = @as(c_int, 0x0004);
+pub const B_ASN1_TELETEXSTRING = @as(c_int, 0x0004);
+pub const B_ASN1_VIDEOTEXSTRING = @as(c_int, 0x0008);
+pub const B_ASN1_IA5STRING = @as(c_int, 0x0010);
+pub const B_ASN1_GRAPHICSTRING = @as(c_int, 0x0020);
+pub const B_ASN1_ISO64STRING = @as(c_int, 0x0040);
+pub const B_ASN1_VISIBLESTRING = @as(c_int, 0x0040);
+pub const B_ASN1_GENERALSTRING = @as(c_int, 0x0080);
+pub const B_ASN1_UNIVERSALSTRING = @as(c_int, 0x0100);
+pub const B_ASN1_OCTET_STRING = @as(c_int, 0x0200);
+pub const B_ASN1_BIT_STRING = @as(c_int, 0x0400);
+pub const B_ASN1_BMPSTRING = @as(c_int, 0x0800);
+pub const B_ASN1_UNKNOWN = @as(c_int, 0x1000);
+pub const B_ASN1_UTF8STRING = @as(c_int, 0x2000);
+pub const B_ASN1_UTCTIME = @as(c_int, 0x4000);
+pub const B_ASN1_GENERALIZEDTIME = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x8000, .hexadecimal);
+pub const B_ASN1_SEQUENCE = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x10000, .hexadecimal);
+pub inline fn ASN1_ITEM_ptr(iptr: anytype) @TypeOf(iptr) {
+ return iptr;
+}
+pub const ASN1_STRING_FLAG_BITS_LEFT = @as(c_int, 0x08);
+pub const MBSTRING_FLAG = @as(c_int, 0x1000);
+pub const MBSTRING_UTF8 = MBSTRING_FLAG;
+pub const MBSTRING_ASC = MBSTRING_FLAG | @as(c_int, 1);
+pub const MBSTRING_BMP = MBSTRING_FLAG | @as(c_int, 2);
+pub const MBSTRING_UNIV = MBSTRING_FLAG | @as(c_int, 4);
+pub const DIRSTRING_TYPE = ((B_ASN1_PRINTABLESTRING | B_ASN1_T61STRING) | B_ASN1_BMPSTRING) | B_ASN1_UTF8STRING;
+pub const PKCS9STRING_TYPE = DIRSTRING_TYPE | B_ASN1_IA5STRING;
+pub const STABLE_NO_MASK = @as(c_int, 0x02);
+pub const B_ASN1_DIRECTORYSTRING = (((B_ASN1_PRINTABLESTRING | B_ASN1_TELETEXSTRING) | B_ASN1_BMPSTRING) | B_ASN1_UNIVERSALSTRING) | B_ASN1_UTF8STRING;
+pub const B_ASN1_DISPLAYTEXT = ((B_ASN1_IA5STRING | B_ASN1_VISIBLESTRING) | B_ASN1_BMPSTRING) | B_ASN1_UTF8STRING;
+pub const B_ASN1_TIME = B_ASN1_UTCTIME | B_ASN1_GENERALIZEDTIME;
+pub const ASN1_STRFLGS_ESC_2253 = @as(c_int, 1);
+pub const ASN1_STRFLGS_ESC_CTRL = @as(c_int, 2);
+pub const ASN1_STRFLGS_ESC_MSB = @as(c_int, 4);
+pub const ASN1_STRFLGS_ESC_QUOTE = @as(c_int, 8);
+pub const ASN1_STRFLGS_UTF8_CONVERT = @as(c_int, 0x10);
+pub const ASN1_STRFLGS_IGNORE_TYPE = @as(c_int, 0x20);
+pub const ASN1_STRFLGS_SHOW_TYPE = @as(c_int, 0x40);
+pub const ASN1_STRFLGS_DUMP_ALL = @as(c_int, 0x80);
+pub const ASN1_STRFLGS_DUMP_UNKNOWN = @as(c_int, 0x100);
+pub const ASN1_STRFLGS_DUMP_DER = @as(c_int, 0x200);
+pub const ASN1_STRFLGS_RFC2253 = ((((ASN1_STRFLGS_ESC_2253 | ASN1_STRFLGS_ESC_CTRL) | ASN1_STRFLGS_ESC_MSB) | ASN1_STRFLGS_UTF8_CONVERT) | ASN1_STRFLGS_DUMP_UNKNOWN) | ASN1_STRFLGS_DUMP_DER;
+pub inline fn DECLARE_ASN1_FUNCTIONS(@"type": anytype) @TypeOf(DECLARE_ASN1_FUNCTIONS_name(@"type", @"type")) {
+ return DECLARE_ASN1_FUNCTIONS_name(@"type", @"type");
+}
+pub inline fn DECLARE_ASN1_ALLOC_FUNCTIONS(@"type": anytype) @TypeOf(DECLARE_ASN1_ALLOC_FUNCTIONS_name(@"type", @"type")) {
+ return DECLARE_ASN1_ALLOC_FUNCTIONS_name(@"type", @"type");
+}
+pub inline fn M_ASN1_STRING_length(x: anytype) @TypeOf(ASN1_STRING_length(x)) {
+ return ASN1_STRING_length(x);
+}
+pub inline fn M_ASN1_STRING_type(x: anytype) @TypeOf(ASN1_STRING_type(x)) {
+ return ASN1_STRING_type(x);
+}
+pub inline fn M_ASN1_STRING_data(x: anytype) @TypeOf(ASN1_STRING_data(x)) {
+ return ASN1_STRING_data(x);
+}
+pub inline fn M_ASN1_BIT_STRING_new() @TypeOf(ASN1_BIT_STRING_new()) {
+ return ASN1_BIT_STRING_new();
+}
+pub inline fn M_ASN1_BIT_STRING_free(a: anytype) @TypeOf(ASN1_BIT_STRING_free(a)) {
+ return ASN1_BIT_STRING_free(a);
+}
+pub inline fn M_ASN1_BIT_STRING_dup(a: anytype) @TypeOf(ASN1_STRING_dup(a)) {
+ return ASN1_STRING_dup(a);
+}
+pub inline fn M_ASN1_BIT_STRING_cmp(a: anytype, b: anytype) @TypeOf(ASN1_STRING_cmp(a, b)) {
+ return ASN1_STRING_cmp(a, b);
+}
+pub inline fn M_ASN1_BIT_STRING_set(a: anytype, b: anytype, c: anytype) @TypeOf(ASN1_BIT_STRING_set(a, b, c)) {
+ return ASN1_BIT_STRING_set(a, b, c);
+}
+pub inline fn M_ASN1_INTEGER_new() @TypeOf(ASN1_INTEGER_new()) {
+ return ASN1_INTEGER_new();
+}
+pub inline fn M_ASN1_INTEGER_free(a: anytype) @TypeOf(ASN1_INTEGER_free(a)) {
+ return ASN1_INTEGER_free(a);
+}
+pub inline fn M_ASN1_INTEGER_dup(a: anytype) @TypeOf(ASN1_INTEGER_dup(a)) {
+ return ASN1_INTEGER_dup(a);
+}
+pub inline fn M_ASN1_INTEGER_cmp(a: anytype, b: anytype) @TypeOf(ASN1_INTEGER_cmp(a, b)) {
+ return ASN1_INTEGER_cmp(a, b);
+}
+pub inline fn M_ASN1_ENUMERATED_new() @TypeOf(ASN1_ENUMERATED_new()) {
+ return ASN1_ENUMERATED_new();
+}
+pub inline fn M_ASN1_ENUMERATED_free(a: anytype) @TypeOf(ASN1_ENUMERATED_free(a)) {
+ return ASN1_ENUMERATED_free(a);
+}
+pub inline fn M_ASN1_ENUMERATED_dup(a: anytype) @TypeOf(ASN1_STRING_dup(a)) {
+ return ASN1_STRING_dup(a);
+}
+pub inline fn M_ASN1_ENUMERATED_cmp(a: anytype, b: anytype) @TypeOf(ASN1_STRING_cmp(a, b)) {
+ return ASN1_STRING_cmp(a, b);
+}
+pub inline fn M_ASN1_OCTET_STRING_new() @TypeOf(ASN1_OCTET_STRING_new()) {
+ return ASN1_OCTET_STRING_new();
+}
+pub inline fn M_ASN1_OCTET_STRING_free(a: anytype) @TypeOf(ASN1_OCTET_STRING_free()) {
+ _ = a;
+ return ASN1_OCTET_STRING_free();
+}
+pub inline fn M_ASN1_OCTET_STRING_dup(a: anytype) @TypeOf(ASN1_OCTET_STRING_dup(a)) {
+ return ASN1_OCTET_STRING_dup(a);
+}
+pub inline fn M_ASN1_OCTET_STRING_cmp(a: anytype, b: anytype) @TypeOf(ASN1_OCTET_STRING_cmp(a, b)) {
+ return ASN1_OCTET_STRING_cmp(a, b);
+}
+pub inline fn M_ASN1_OCTET_STRING_set(a: anytype, b: anytype, c: anytype) @TypeOf(ASN1_OCTET_STRING_set(a, b, c)) {
+ return ASN1_OCTET_STRING_set(a, b, c);
+}
+pub inline fn M_ASN1_OCTET_STRING_print(a: anytype, b: anytype) @TypeOf(ASN1_STRING_print(a, b)) {
+ return ASN1_STRING_print(a, b);
+}
+pub inline fn M_ASN1_PRINTABLESTRING_new() @TypeOf(ASN1_PRINTABLESTRING_new()) {
+ return ASN1_PRINTABLESTRING_new();
+}
+pub inline fn M_ASN1_PRINTABLESTRING_free(a: anytype) @TypeOf(ASN1_PRINTABLESTRING_free(a)) {
+ return ASN1_PRINTABLESTRING_free(a);
+}
+pub inline fn M_ASN1_IA5STRING_new() @TypeOf(ASN1_IA5STRING_new()) {
+ return ASN1_IA5STRING_new();
+}
+pub inline fn M_ASN1_IA5STRING_free(a: anytype) @TypeOf(ASN1_IA5STRING_free(a)) {
+ return ASN1_IA5STRING_free(a);
+}
+pub inline fn M_ASN1_IA5STRING_dup(a: anytype) @TypeOf(ASN1_STRING_dup(a)) {
+ return ASN1_STRING_dup(a);
+}
+pub inline fn M_ASN1_UTCTIME_new() @TypeOf(ASN1_UTCTIME_new()) {
+ return ASN1_UTCTIME_new();
+}
+pub inline fn M_ASN1_UTCTIME_free(a: anytype) @TypeOf(ASN1_UTCTIME_free(a)) {
+ return ASN1_UTCTIME_free(a);
+}
+pub inline fn M_ASN1_UTCTIME_dup(a: anytype) @TypeOf(ASN1_STRING_dup(a)) {
+ return ASN1_STRING_dup(a);
+}
+pub inline fn M_ASN1_T61STRING_new() @TypeOf(ASN1_T61STRING_new()) {
+ return ASN1_T61STRING_new();
+}
+pub inline fn M_ASN1_T61STRING_free(a: anytype) @TypeOf(ASN1_T61STRING_free(a)) {
+ return ASN1_T61STRING_free(a);
+}
+pub inline fn M_ASN1_GENERALIZEDTIME_new() @TypeOf(ASN1_GENERALIZEDTIME_new()) {
+ return ASN1_GENERALIZEDTIME_new();
+}
+pub inline fn M_ASN1_GENERALIZEDTIME_free(a: anytype) @TypeOf(ASN1_GENERALIZEDTIME_free(a)) {
+ return ASN1_GENERALIZEDTIME_free(a);
+}
+pub inline fn M_ASN1_GENERALIZEDTIME_dup(a: anytype) @TypeOf(ASN1_STRING_dup(a)) {
+ return ASN1_STRING_dup(a);
+}
+pub inline fn M_ASN1_GENERALSTRING_new() @TypeOf(ASN1_GENERALSTRING_new()) {
+ return ASN1_GENERALSTRING_new();
+}
+pub inline fn M_ASN1_GENERALSTRING_free(a: anytype) @TypeOf(ASN1_GENERALSTRING_free(a)) {
+ return ASN1_GENERALSTRING_free(a);
+}
+pub inline fn M_ASN1_UNIVERSALSTRING_new() @TypeOf(ASN1_UNIVERSALSTRING_new()) {
+ return ASN1_UNIVERSALSTRING_new();
+}
+pub inline fn M_ASN1_UNIVERSALSTRING_free(a: anytype) @TypeOf(ASN1_UNIVERSALSTRING_free(a)) {
+ return ASN1_UNIVERSALSTRING_free(a);
+}
+pub inline fn M_ASN1_BMPSTRING_new() @TypeOf(ASN1_BMPSTRING_new()) {
+ return ASN1_BMPSTRING_new();
+}
+pub inline fn M_ASN1_BMPSTRING_free(a: anytype) @TypeOf(ASN1_BMPSTRING_free(a)) {
+ return ASN1_BMPSTRING_free(a);
+}
+pub inline fn M_ASN1_VISIBLESTRING_new() @TypeOf(ASN1_VISIBLESTRING_new()) {
+ return ASN1_VISIBLESTRING_new();
+}
+pub inline fn M_ASN1_VISIBLESTRING_free(a: anytype) @TypeOf(ASN1_VISIBLESTRING_free(a)) {
+ return ASN1_VISIBLESTRING_free(a);
+}
+pub inline fn M_ASN1_UTF8STRING_new() @TypeOf(ASN1_UTF8STRING_new()) {
+ return ASN1_UTF8STRING_new();
+}
+pub inline fn M_ASN1_UTF8STRING_free(a: anytype) @TypeOf(ASN1_UTF8STRING_free(a)) {
+ return ASN1_UTF8STRING_free(a);
+}
+pub const B_ASN1_PRINTABLE = ((((((((B_ASN1_NUMERICSTRING | B_ASN1_PRINTABLESTRING) | B_ASN1_T61STRING) | B_ASN1_IA5STRING) | B_ASN1_BIT_STRING) | B_ASN1_UNIVERSALSTRING) | B_ASN1_BMPSTRING) | B_ASN1_UTF8STRING) | B_ASN1_SEQUENCE) | B_ASN1_UNKNOWN;
+pub const ASN1_R_ASN1_LENGTH_MISMATCH = @as(c_int, 100);
+pub const ASN1_R_AUX_ERROR = @as(c_int, 101);
+pub const ASN1_R_BAD_GET_ASN1_OBJECT_CALL = @as(c_int, 102);
+pub const ASN1_R_BAD_OBJECT_HEADER = @as(c_int, 103);
+pub const ASN1_R_BMPSTRING_IS_WRONG_LENGTH = @as(c_int, 104);
+pub const ASN1_R_BN_LIB = @as(c_int, 105);
+pub const ASN1_R_BOOLEAN_IS_WRONG_LENGTH = @as(c_int, 106);
+pub const ASN1_R_BUFFER_TOO_SMALL = @as(c_int, 107);
+pub const ASN1_R_CONTEXT_NOT_INITIALISED = @as(c_int, 108);
+pub const ASN1_R_DECODE_ERROR = @as(c_int, 109);
+pub const ASN1_R_DEPTH_EXCEEDED = @as(c_int, 110);
+pub const ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED = @as(c_int, 111);
+pub const ASN1_R_ENCODE_ERROR = @as(c_int, 112);
+pub const ASN1_R_ERROR_GETTING_TIME = @as(c_int, 113);
+pub const ASN1_R_EXPECTING_AN_ASN1_SEQUENCE = @as(c_int, 114);
+pub const ASN1_R_EXPECTING_AN_INTEGER = @as(c_int, 115);
+pub const ASN1_R_EXPECTING_AN_OBJECT = @as(c_int, 116);
+pub const ASN1_R_EXPECTING_A_BOOLEAN = @as(c_int, 117);
+pub const ASN1_R_EXPECTING_A_TIME = @as(c_int, 118);
+pub const ASN1_R_EXPLICIT_LENGTH_MISMATCH = @as(c_int, 119);
+pub const ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED = @as(c_int, 120);
+pub const ASN1_R_FIELD_MISSING = @as(c_int, 121);
+pub const ASN1_R_FIRST_NUM_TOO_LARGE = @as(c_int, 122);
+pub const ASN1_R_HEADER_TOO_LONG = @as(c_int, 123);
+pub const ASN1_R_ILLEGAL_BITSTRING_FORMAT = @as(c_int, 124);
+pub const ASN1_R_ILLEGAL_BOOLEAN = @as(c_int, 125);
+pub const ASN1_R_ILLEGAL_CHARACTERS = @as(c_int, 126);
+pub const ASN1_R_ILLEGAL_FORMAT = @as(c_int, 127);
+pub const ASN1_R_ILLEGAL_HEX = @as(c_int, 128);
+pub const ASN1_R_ILLEGAL_IMPLICIT_TAG = @as(c_int, 129);
+pub const ASN1_R_ILLEGAL_INTEGER = @as(c_int, 130);
+pub const ASN1_R_ILLEGAL_NESTED_TAGGING = @as(c_int, 131);
+pub const ASN1_R_ILLEGAL_NULL = @as(c_int, 132);
+pub const ASN1_R_ILLEGAL_NULL_VALUE = @as(c_int, 133);
+pub const ASN1_R_ILLEGAL_OBJECT = @as(c_int, 134);
+pub const ASN1_R_ILLEGAL_OPTIONAL_ANY = @as(c_int, 135);
+pub const ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE = @as(c_int, 136);
+pub const ASN1_R_ILLEGAL_TAGGED_ANY = @as(c_int, 137);
+pub const ASN1_R_ILLEGAL_TIME_VALUE = @as(c_int, 138);
+pub const ASN1_R_INTEGER_NOT_ASCII_FORMAT = @as(c_int, 139);
+pub const ASN1_R_INTEGER_TOO_LARGE_FOR_LONG = @as(c_int, 140);
+pub const ASN1_R_INVALID_BIT_STRING_BITS_LEFT = @as(c_int, 141);
+pub const ASN1_R_INVALID_BMPSTRING = @as(c_int, 142);
+pub const ASN1_R_INVALID_DIGIT = @as(c_int, 143);
+pub const ASN1_R_INVALID_MODIFIER = @as(c_int, 144);
+pub const ASN1_R_INVALID_NUMBER = @as(c_int, 145);
+pub const ASN1_R_INVALID_OBJECT_ENCODING = @as(c_int, 146);
+pub const ASN1_R_INVALID_SEPARATOR = @as(c_int, 147);
+pub const ASN1_R_INVALID_TIME_FORMAT = @as(c_int, 148);
+pub const ASN1_R_INVALID_UNIVERSALSTRING = @as(c_int, 149);
+pub const ASN1_R_INVALID_UTF8STRING = @as(c_int, 150);
+pub const ASN1_R_LIST_ERROR = @as(c_int, 151);
+pub const ASN1_R_MISSING_ASN1_EOS = @as(c_int, 152);
+pub const ASN1_R_MISSING_EOC = @as(c_int, 153);
+pub const ASN1_R_MISSING_SECOND_NUMBER = @as(c_int, 154);
+pub const ASN1_R_MISSING_VALUE = @as(c_int, 155);
+pub const ASN1_R_MSTRING_NOT_UNIVERSAL = @as(c_int, 156);
+pub const ASN1_R_MSTRING_WRONG_TAG = @as(c_int, 157);
+pub const ASN1_R_NESTED_ASN1_ERROR = @as(c_int, 158);
+pub const ASN1_R_NESTED_ASN1_STRING = @as(c_int, 159);
+pub const ASN1_R_NON_HEX_CHARACTERS = @as(c_int, 160);
+pub const ASN1_R_NOT_ASCII_FORMAT = @as(c_int, 161);
+pub const ASN1_R_NOT_ENOUGH_DATA = @as(c_int, 162);
+pub const ASN1_R_NO_MATCHING_CHOICE_TYPE = @as(c_int, 163);
+pub const ASN1_R_NULL_IS_WRONG_LENGTH = @as(c_int, 164);
+pub const ASN1_R_OBJECT_NOT_ASCII_FORMAT = @as(c_int, 165);
+pub const ASN1_R_ODD_NUMBER_OF_CHARS = @as(c_int, 166);
+pub const ASN1_R_SECOND_NUMBER_TOO_LARGE = @as(c_int, 167);
+pub const ASN1_R_SEQUENCE_LENGTH_MISMATCH = @as(c_int, 168);
+pub const ASN1_R_SEQUENCE_NOT_CONSTRUCTED = @as(c_int, 169);
+pub const ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG = @as(c_int, 170);
+pub const ASN1_R_SHORT_LINE = @as(c_int, 171);
+pub const ASN1_R_STREAMING_NOT_SUPPORTED = @as(c_int, 172);
+pub const ASN1_R_STRING_TOO_LONG = @as(c_int, 173);
+pub const ASN1_R_STRING_TOO_SHORT = @as(c_int, 174);
+pub const ASN1_R_TAG_VALUE_TOO_HIGH = @as(c_int, 175);
+pub const ASN1_R_TIME_NOT_ASCII_FORMAT = @as(c_int, 176);
+pub const ASN1_R_TOO_LONG = @as(c_int, 177);
+pub const ASN1_R_TYPE_NOT_CONSTRUCTED = @as(c_int, 178);
+pub const ASN1_R_TYPE_NOT_PRIMITIVE = @as(c_int, 179);
+pub const ASN1_R_UNEXPECTED_EOC = @as(c_int, 180);
+pub const ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH = @as(c_int, 181);
+pub const ASN1_R_UNKNOWN_FORMAT = @as(c_int, 182);
+pub const ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM = @as(c_int, 183);
+pub const ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM = @as(c_int, 184);
+pub const ASN1_R_UNKNOWN_TAG = @as(c_int, 185);
+pub const ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE = @as(c_int, 186);
+pub const ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE = @as(c_int, 187);
+pub const ASN1_R_UNSUPPORTED_TYPE = @as(c_int, 188);
+pub const ASN1_R_WRONG_PUBLIC_KEY_TYPE = @as(c_int, 189);
+pub const ASN1_R_WRONG_TAG = @as(c_int, 190);
+pub const ASN1_R_WRONG_TYPE = @as(c_int, 191);
+pub const ASN1_R_NESTED_TOO_DEEP = @as(c_int, 192);
+pub const ASN1_R_BAD_TEMPLATE = @as(c_int, 193);
+pub const ASN1_R_INVALID_BIT_STRING_PADDING = @as(c_int, 194);
+pub const DH_GENERATOR_2 = @as(c_int, 2);
+pub const DH_GENERATOR_5 = @as(c_int, 5);
+pub const DH_CHECK_P_NOT_PRIME = @as(c_int, 0x01);
+pub const DH_CHECK_P_NOT_SAFE_PRIME = @as(c_int, 0x02);
+pub const DH_CHECK_UNABLE_TO_CHECK_GENERATOR = @as(c_int, 0x04);
+pub const DH_CHECK_NOT_SUITABLE_GENERATOR = @as(c_int, 0x08);
+pub const DH_CHECK_Q_NOT_PRIME = @as(c_int, 0x10);
+pub const DH_CHECK_INVALID_Q_VALUE = @as(c_int, 0x20);
+pub const DH_CHECK_INVALID_J_VALUE = @as(c_int, 0x40);
+pub const DH_NOT_SUITABLE_GENERATOR = DH_CHECK_NOT_SUITABLE_GENERATOR;
+pub const DH_UNABLE_TO_CHECK_GENERATOR = DH_CHECK_UNABLE_TO_CHECK_GENERATOR;
+pub const DH_CHECK_PUBKEY_TOO_SMALL = @as(c_int, 0x1);
+pub const DH_CHECK_PUBKEY_TOO_LARGE = @as(c_int, 0x2);
+pub const DH_CHECK_PUBKEY_INVALID = @as(c_int, 0x4);
+pub const DH_R_BAD_GENERATOR = @as(c_int, 100);
+pub const DH_R_INVALID_PUBKEY = @as(c_int, 101);
+pub const DH_R_MODULUS_TOO_LARGE = @as(c_int, 102);
+pub const DH_R_NO_PRIVATE_VALUE = @as(c_int, 103);
+pub const DH_R_DECODE_ERROR = @as(c_int, 104);
+pub const DH_R_ENCODE_ERROR = @as(c_int, 105);
+pub const ENGINE_R_OPERATION_NOT_SUPPORTED = @as(c_int, 100);
+pub const DSA_R_BAD_Q_VALUE = @as(c_int, 100);
+pub const DSA_R_MISSING_PARAMETERS = @as(c_int, 101);
+pub const DSA_R_MODULUS_TOO_LARGE = @as(c_int, 102);
+pub const DSA_R_NEED_NEW_SETUP_VALUES = @as(c_int, 103);
+pub const DSA_R_BAD_VERSION = @as(c_int, 104);
+pub const DSA_R_DECODE_ERROR = @as(c_int, 105);
+pub const DSA_R_ENCODE_ERROR = @as(c_int, 106);
+pub const DSA_R_INVALID_PARAMETERS = @as(c_int, 107);
+pub const OPENSSL_EC_EXPLICIT_CURVE = @as(c_int, 0);
+pub const OPENSSL_EC_NAMED_CURVE = @as(c_int, 1);
+pub const EC_PKEY_NO_PARAMETERS = @as(c_int, 0x001);
+pub const EC_PKEY_NO_PUBKEY = @as(c_int, 0x002);
+pub const ECDSA_FLAG_OPAQUE = @as(c_int, 1);
+pub const EC_R_BUFFER_TOO_SMALL = @as(c_int, 100);
+pub const EC_R_COORDINATES_OUT_OF_RANGE = @as(c_int, 101);
+pub const EC_R_D2I_ECPKPARAMETERS_FAILURE = @as(c_int, 102);
+pub const EC_R_EC_GROUP_NEW_BY_NAME_FAILURE = @as(c_int, 103);
+pub const EC_R_GROUP2PKPARAMETERS_FAILURE = @as(c_int, 104);
+pub const EC_R_I2D_ECPKPARAMETERS_FAILURE = @as(c_int, 105);
+pub const EC_R_INCOMPATIBLE_OBJECTS = @as(c_int, 106);
+pub const EC_R_INVALID_COMPRESSED_POINT = @as(c_int, 107);
+pub const EC_R_INVALID_COMPRESSION_BIT = @as(c_int, 108);
+pub const EC_R_INVALID_ENCODING = @as(c_int, 109);
+pub const EC_R_INVALID_FIELD = @as(c_int, 110);
+pub const EC_R_INVALID_FORM = @as(c_int, 111);
+pub const EC_R_INVALID_GROUP_ORDER = @as(c_int, 112);
+pub const EC_R_INVALID_PRIVATE_KEY = @as(c_int, 113);
+pub const EC_R_MISSING_PARAMETERS = @as(c_int, 114);
+pub const EC_R_MISSING_PRIVATE_KEY = @as(c_int, 115);
+pub const EC_R_NON_NAMED_CURVE = @as(c_int, 116);
+pub const EC_R_NOT_INITIALIZED = @as(c_int, 117);
+pub const EC_R_PKPARAMETERS2GROUP_FAILURE = @as(c_int, 118);
+pub const EC_R_POINT_AT_INFINITY = @as(c_int, 119);
+pub const EC_R_POINT_IS_NOT_ON_CURVE = @as(c_int, 120);
+pub const EC_R_SLOT_FULL = @as(c_int, 121);
+pub const EC_R_UNDEFINED_GENERATOR = @as(c_int, 122);
+pub const EC_R_UNKNOWN_GROUP = @as(c_int, 123);
+pub const EC_R_UNKNOWN_ORDER = @as(c_int, 124);
+pub const EC_R_WRONG_ORDER = @as(c_int, 125);
+pub const EC_R_BIGNUM_OUT_OF_RANGE = @as(c_int, 126);
+pub const EC_R_WRONG_CURVE_PARAMETERS = @as(c_int, 127);
+pub const EC_R_DECODE_ERROR = @as(c_int, 128);
+pub const EC_R_ENCODE_ERROR = @as(c_int, 129);
+pub const EC_R_GROUP_MISMATCH = @as(c_int, 130);
+pub const EC_R_INVALID_COFACTOR = @as(c_int, 131);
+pub const EC_R_PUBLIC_KEY_VALIDATION_FAILED = @as(c_int, 132);
+pub const EC_R_INVALID_SCALAR = @as(c_int, 133);
+pub const ECDH_R_KDF_FAILED = @as(c_int, 100);
+pub const ECDH_R_NO_PRIVATE_VALUE = @as(c_int, 101);
+pub const ECDH_R_POINT_ARITHMETIC_FAILURE = @as(c_int, 102);
+pub const ECDH_R_UNKNOWN_DIGEST_LENGTH = @as(c_int, 103);
+pub const ECDSA_R_BAD_SIGNATURE = @as(c_int, 100);
+pub const ECDSA_R_MISSING_PARAMETERS = @as(c_int, 101);
+pub const ECDSA_R_NEED_NEW_SETUP_VALUES = @as(c_int, 102);
+pub const ECDSA_R_NOT_IMPLEMENTED = @as(c_int, 103);
+pub const ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED = @as(c_int, 104);
+pub const ECDSA_R_ENCODE_ERROR = @as(c_int, 105);
+pub const CBS_ASN1_TAG_SHIFT = @as(c_int, 24);
+pub const CBS_ASN1_CONSTRUCTED = @as(c_uint, 0x20) << CBS_ASN1_TAG_SHIFT;
+pub const CBS_ASN1_UNIVERSAL = @as(c_uint, 0) << CBS_ASN1_TAG_SHIFT;
+pub const CBS_ASN1_APPLICATION = @as(c_uint, 0x40) << CBS_ASN1_TAG_SHIFT;
+pub const CBS_ASN1_CONTEXT_SPECIFIC = @as(c_uint, 0x80) << CBS_ASN1_TAG_SHIFT;
+pub const CBS_ASN1_PRIVATE = @as(c_uint, 0xc0) << CBS_ASN1_TAG_SHIFT;
+pub const CBS_ASN1_CLASS_MASK = @as(c_uint, 0xc0) << CBS_ASN1_TAG_SHIFT;
+pub const CBS_ASN1_TAG_NUMBER_MASK = (@as(c_uint, 1) << (@as(c_int, 5) + CBS_ASN1_TAG_SHIFT)) - @as(c_int, 1);
+pub const CBS_ASN1_BOOLEAN = @as(c_uint, 0x1);
+pub const CBS_ASN1_INTEGER = @as(c_uint, 0x2);
+pub const CBS_ASN1_BITSTRING = @as(c_uint, 0x3);
+pub const CBS_ASN1_OCTETSTRING = @as(c_uint, 0x4);
+pub const CBS_ASN1_NULL = @as(c_uint, 0x5);
+pub const CBS_ASN1_OBJECT = @as(c_uint, 0x6);
+pub const CBS_ASN1_ENUMERATED = @as(c_uint, 0xa);
+pub const CBS_ASN1_UTF8STRING = @as(c_uint, 0xc);
+pub const CBS_ASN1_SEQUENCE = @as(c_uint, 0x10) | CBS_ASN1_CONSTRUCTED;
+pub const CBS_ASN1_SET = @as(c_uint, 0x11) | CBS_ASN1_CONSTRUCTED;
+pub const CBS_ASN1_NUMERICSTRING = @as(c_uint, 0x12);
+pub const CBS_ASN1_PRINTABLESTRING = @as(c_uint, 0x13);
+pub const CBS_ASN1_T61STRING = @as(c_uint, 0x14);
+pub const CBS_ASN1_VIDEOTEXSTRING = @as(c_uint, 0x15);
+pub const CBS_ASN1_IA5STRING = @as(c_uint, 0x16);
+pub const CBS_ASN1_UTCTIME = @as(c_uint, 0x17);
+pub const CBS_ASN1_GENERALIZEDTIME = @as(c_uint, 0x18);
+pub const CBS_ASN1_GRAPHICSTRING = @as(c_uint, 0x19);
+pub const CBS_ASN1_VISIBLESTRING = @as(c_uint, 0x1a);
+pub const CBS_ASN1_GENERALSTRING = @as(c_uint, 0x1b);
+pub const CBS_ASN1_UNIVERSALSTRING = @as(c_uint, 0x1c);
+pub const CBS_ASN1_BMPSTRING = @as(c_uint, 0x1e);
+pub const OBJ_NAME_TYPE_MD_METH = @as(c_int, 1);
+pub const OBJ_NAME_TYPE_CIPHER_METH = @as(c_int, 2);
+pub const OBJ_R_UNKNOWN_NID = @as(c_int, 100);
+pub const OBJ_R_INVALID_OID_STRING = @as(c_int, 101);
+pub const RSA_PKCS1_PADDING = @as(c_int, 1);
+pub const RSA_NO_PADDING = @as(c_int, 3);
+pub const RSA_PKCS1_OAEP_PADDING = @as(c_int, 4);
+pub const RSA_PKCS1_PSS_PADDING = @as(c_int, 6);
+pub const RSA_FLAG_OPAQUE = @as(c_int, 1);
+pub const RSA_FLAG_NO_BLINDING = @as(c_int, 8);
+pub const RSA_FLAG_EXT_PKEY = @as(c_int, 0x20);
+pub const RSA_3 = @as(c_int, 0x3);
+pub const RSA_F4 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x10001, .hexadecimal);
+pub const RSA_METHOD_FLAG_NO_CHECK = RSA_FLAG_OPAQUE;
+pub const RSA_R_BAD_ENCODING = @as(c_int, 100);
+pub const RSA_R_BAD_E_VALUE = @as(c_int, 101);
+pub const RSA_R_BAD_FIXED_HEADER_DECRYPT = @as(c_int, 102);
+pub const RSA_R_BAD_PAD_BYTE_COUNT = @as(c_int, 103);
+pub const RSA_R_BAD_RSA_PARAMETERS = @as(c_int, 104);
+pub const RSA_R_BAD_SIGNATURE = @as(c_int, 105);
+pub const RSA_R_BAD_VERSION = @as(c_int, 106);
+pub const RSA_R_BLOCK_TYPE_IS_NOT_01 = @as(c_int, 107);
+pub const RSA_R_BN_NOT_INITIALIZED = @as(c_int, 108);
+pub const RSA_R_CANNOT_RECOVER_MULTI_PRIME_KEY = @as(c_int, 109);
+pub const RSA_R_CRT_PARAMS_ALREADY_GIVEN = @as(c_int, 110);
+pub const RSA_R_CRT_VALUES_INCORRECT = @as(c_int, 111);
+pub const RSA_R_DATA_LEN_NOT_EQUAL_TO_MOD_LEN = @as(c_int, 112);
+pub const RSA_R_DATA_TOO_LARGE = @as(c_int, 113);
+pub const RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE = @as(c_int, 114);
+pub const RSA_R_DATA_TOO_LARGE_FOR_MODULUS = @as(c_int, 115);
+pub const RSA_R_DATA_TOO_SMALL = @as(c_int, 116);
+pub const RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE = @as(c_int, 117);
+pub const RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY = @as(c_int, 118);
+pub const RSA_R_D_E_NOT_CONGRUENT_TO_1 = @as(c_int, 119);
+pub const RSA_R_EMPTY_PUBLIC_KEY = @as(c_int, 120);
+pub const RSA_R_ENCODE_ERROR = @as(c_int, 121);
+pub const RSA_R_FIRST_OCTET_INVALID = @as(c_int, 122);
+pub const RSA_R_INCONSISTENT_SET_OF_CRT_VALUES = @as(c_int, 123);
+pub const RSA_R_INTERNAL_ERROR = @as(c_int, 124);
+pub const RSA_R_INVALID_MESSAGE_LENGTH = @as(c_int, 125);
+pub const RSA_R_KEY_SIZE_TOO_SMALL = @as(c_int, 126);
+pub const RSA_R_LAST_OCTET_INVALID = @as(c_int, 127);
+pub const RSA_R_MODULUS_TOO_LARGE = @as(c_int, 128);
+pub const RSA_R_MUST_HAVE_AT_LEAST_TWO_PRIMES = @as(c_int, 129);
+pub const RSA_R_NO_PUBLIC_EXPONENT = @as(c_int, 130);
+pub const RSA_R_NULL_BEFORE_BLOCK_MISSING = @as(c_int, 131);
+pub const RSA_R_N_NOT_EQUAL_P_Q = @as(c_int, 132);
+pub const RSA_R_OAEP_DECODING_ERROR = @as(c_int, 133);
+pub const RSA_R_ONLY_ONE_OF_P_Q_GIVEN = @as(c_int, 134);
+pub const RSA_R_OUTPUT_BUFFER_TOO_SMALL = @as(c_int, 135);
+pub const RSA_R_PADDING_CHECK_FAILED = @as(c_int, 136);
+pub const RSA_R_PKCS_DECODING_ERROR = @as(c_int, 137);
+pub const RSA_R_SLEN_CHECK_FAILED = @as(c_int, 138);
+pub const RSA_R_SLEN_RECOVERY_FAILED = @as(c_int, 139);
+pub const RSA_R_TOO_LONG = @as(c_int, 140);
+pub const RSA_R_TOO_MANY_ITERATIONS = @as(c_int, 141);
+pub const RSA_R_UNKNOWN_ALGORITHM_TYPE = @as(c_int, 142);
+pub const RSA_R_UNKNOWN_PADDING_TYPE = @as(c_int, 143);
+pub const RSA_R_VALUE_MISSING = @as(c_int, 144);
+pub const RSA_R_WRONG_SIGNATURE_LENGTH = @as(c_int, 145);
+pub const RSA_R_PUBLIC_KEY_VALIDATION_FAILED = @as(c_int, 146);
+pub const RSA_R_D_OUT_OF_RANGE = @as(c_int, 147);
+pub const RSA_R_BLOCK_TYPE_IS_NOT_02 = @as(c_int, 148);
+pub const SHA_CBLOCK = @as(c_int, 64);
+pub const SHA_DIGEST_LENGTH = @as(c_int, 20);
+pub const SHA224_CBLOCK = @as(c_int, 64);
+pub const SHA224_DIGEST_LENGTH = @as(c_int, 28);
+pub const SHA256_CBLOCK = @as(c_int, 64);
+pub const SHA256_DIGEST_LENGTH = @as(c_int, 32);
+pub const SHA384_CBLOCK = @as(c_int, 128);
+pub const SHA384_DIGEST_LENGTH = @as(c_int, 48);
+pub const SHA512_CBLOCK = @as(c_int, 128);
+pub const SHA512_DIGEST_LENGTH = @as(c_int, 64);
+pub const SHA512_256_DIGEST_LENGTH = @as(c_int, 32);
+pub const X509_FILETYPE_PEM = @as(c_int, 1);
+pub const X509_FILETYPE_ASN1 = @as(c_int, 2);
+pub const X509_FILETYPE_DEFAULT = @as(c_int, 3);
+pub const X509v3_KU_DIGITAL_SIGNATURE = @as(c_int, 0x0080);
+pub const X509v3_KU_NON_REPUDIATION = @as(c_int, 0x0040);
+pub const X509v3_KU_KEY_ENCIPHERMENT = @as(c_int, 0x0020);
+pub const X509v3_KU_DATA_ENCIPHERMENT = @as(c_int, 0x0010);
+pub const X509v3_KU_KEY_AGREEMENT = @as(c_int, 0x0008);
+pub const X509v3_KU_KEY_CERT_SIGN = @as(c_int, 0x0004);
+pub const X509v3_KU_CRL_SIGN = @as(c_int, 0x0002);
+pub const X509v3_KU_ENCIPHER_ONLY = @as(c_int, 0x0001);
+pub const X509v3_KU_DECIPHER_ONLY = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x8000, .hexadecimal);
+pub const X509v3_KU_UNDEF = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0xffff, .hexadecimal);
+pub const X509_TRUST_DEFAULT = -@as(c_int, 1);
+pub const X509_TRUST_COMPAT = @as(c_int, 1);
+pub const X509_TRUST_SSL_CLIENT = @as(c_int, 2);
+pub const X509_TRUST_SSL_SERVER = @as(c_int, 3);
+pub const X509_TRUST_EMAIL = @as(c_int, 4);
+pub const X509_TRUST_OBJECT_SIGN = @as(c_int, 5);
+pub const X509_TRUST_OCSP_SIGN = @as(c_int, 6);
+pub const X509_TRUST_OCSP_REQUEST = @as(c_int, 7);
+pub const X509_TRUST_TSA = @as(c_int, 8);
+pub const X509_TRUST_MIN = @as(c_int, 1);
+pub const X509_TRUST_MAX = @as(c_int, 8);
+pub const X509_TRUST_DYNAMIC = @as(c_int, 1);
+pub const X509_TRUST_DYNAMIC_NAME = @as(c_int, 2);
+pub const X509_TRUST_TRUSTED = @as(c_int, 1);
+pub const X509_TRUST_REJECTED = @as(c_int, 2);
+pub const X509_TRUST_UNTRUSTED = @as(c_int, 3);
+pub const X509_FLAG_COMPAT = @as(c_int, 0);
+pub const X509_FLAG_NO_HEADER = @as(c_long, 1);
+pub const X509_FLAG_NO_VERSION = @as(c_long, 1) << @as(c_int, 1);
+pub const X509_FLAG_NO_SERIAL = @as(c_long, 1) << @as(c_int, 2);
+pub const X509_FLAG_NO_SIGNAME = @as(c_long, 1) << @as(c_int, 3);
+pub const X509_FLAG_NO_ISSUER = @as(c_long, 1) << @as(c_int, 4);
+pub const X509_FLAG_NO_VALIDITY = @as(c_long, 1) << @as(c_int, 5);
+pub const X509_FLAG_NO_SUBJECT = @as(c_long, 1) << @as(c_int, 6);
+pub const X509_FLAG_NO_PUBKEY = @as(c_long, 1) << @as(c_int, 7);
+pub const X509_FLAG_NO_EXTENSIONS = @as(c_long, 1) << @as(c_int, 8);
+pub const X509_FLAG_NO_SIGDUMP = @as(c_long, 1) << @as(c_int, 9);
+pub const X509_FLAG_NO_AUX = @as(c_long, 1) << @as(c_int, 10);
+pub const X509_FLAG_NO_ATTRIBUTES = @as(c_long, 1) << @as(c_int, 11);
+pub const X509_FLAG_NO_IDS = @as(c_long, 1) << @as(c_int, 12);
+pub const XN_FLAG_SEP_MASK = @as(c_int, 0xf) << @as(c_int, 16);
+pub const XN_FLAG_COMPAT = @as(c_int, 0);
+pub const XN_FLAG_SEP_COMMA_PLUS = @as(c_int, 1) << @as(c_int, 16);
+pub const XN_FLAG_SEP_CPLUS_SPC = @as(c_int, 2) << @as(c_int, 16);
+pub const XN_FLAG_SEP_SPLUS_SPC = @as(c_int, 3) << @as(c_int, 16);
+pub const XN_FLAG_SEP_MULTILINE = @as(c_int, 4) << @as(c_int, 16);
+pub const XN_FLAG_DN_REV = @as(c_int, 1) << @as(c_int, 20);
+pub const XN_FLAG_FN_MASK = @as(c_int, 0x3) << @as(c_int, 21);
+pub const XN_FLAG_FN_SN = @as(c_int, 0);
+pub const XN_FLAG_FN_LN = @as(c_int, 1) << @as(c_int, 21);
+pub const XN_FLAG_FN_OID = @as(c_int, 2) << @as(c_int, 21);
+pub const XN_FLAG_FN_NONE = @as(c_int, 3) << @as(c_int, 21);
+pub const XN_FLAG_SPC_EQ = @as(c_int, 1) << @as(c_int, 23);
+pub const XN_FLAG_DUMP_UNKNOWN_FIELDS = @as(c_int, 1) << @as(c_int, 24);
+pub const XN_FLAG_FN_ALIGN = @as(c_int, 1) << @as(c_int, 25);
+pub const XN_FLAG_RFC2253 = (((ASN1_STRFLGS_RFC2253 | XN_FLAG_SEP_COMMA_PLUS) | XN_FLAG_DN_REV) | XN_FLAG_FN_SN) | XN_FLAG_DUMP_UNKNOWN_FIELDS;
+pub const XN_FLAG_ONELINE = (((ASN1_STRFLGS_RFC2253 | ASN1_STRFLGS_ESC_QUOTE) | XN_FLAG_SEP_CPLUS_SPC) | XN_FLAG_SPC_EQ) | XN_FLAG_FN_SN;
+pub const XN_FLAG_MULTILINE = ((((ASN1_STRFLGS_ESC_CTRL | ASN1_STRFLGS_ESC_MSB) | XN_FLAG_SEP_MULTILINE) | XN_FLAG_SPC_EQ) | XN_FLAG_FN_LN) | XN_FLAG_FN_ALIGN;
+pub const X509_VERSION_1 = @as(c_int, 0);
+pub const X509_VERSION_2 = @as(c_int, 1);
+pub const X509_VERSION_3 = @as(c_int, 2);
+pub inline fn X509_extract_key(x: anytype) @TypeOf(X509_get_pubkey(x)) {
+ return X509_get_pubkey(x);
+}
+pub const X509_REQ_VERSION_1 = @as(c_int, 0);
+pub inline fn X509_REQ_extract_key(a: anytype) @TypeOf(X509_REQ_get_pubkey(a)) {
+ return X509_REQ_get_pubkey(a);
+}
+pub inline fn X509_name_cmp(a: anytype, b: anytype) @TypeOf(X509_NAME_cmp(a, b)) {
+ return X509_NAME_cmp(a, b);
+}
+pub const X509_CRL_VERSION_1 = @as(c_int, 0);
+pub const X509_CRL_VERSION_2 = @as(c_int, 1);
+pub const X509_CRL_set_lastUpdate = X509_CRL_set1_lastUpdate;
+pub const X509_CRL_set_nextUpdate = X509_CRL_set1_nextUpdate;
+pub const X509_LU_X509 = @as(c_int, 1);
+pub const X509_LU_CRL = @as(c_int, 2);
+pub const X509_LU_PKEY = @as(c_int, 3);
+pub inline fn X509_STORE_CTX_set_app_data(ctx: anytype, data: anytype) @TypeOf(X509_STORE_CTX_set_ex_data(ctx, @as(c_int, 0), data)) {
+ return X509_STORE_CTX_set_ex_data(ctx, @as(c_int, 0), data);
+}
+pub inline fn X509_STORE_CTX_get_app_data(ctx: anytype) @TypeOf(X509_STORE_CTX_get_ex_data(ctx, @as(c_int, 0))) {
+ return X509_STORE_CTX_get_ex_data(ctx, @as(c_int, 0));
+}
+pub const X509_L_FILE_LOAD = @as(c_int, 1);
+pub const X509_L_ADD_DIR = @as(c_int, 2);
+pub inline fn X509_LOOKUP_load_file(x: anytype, name: anytype, @"type": anytype) @TypeOf(X509_LOOKUP_ctrl(x, X509_L_FILE_LOAD, name, @import("std").zig.c_translation.cast(c_long, @"type"), NULL)) {
+ return X509_LOOKUP_ctrl(x, X509_L_FILE_LOAD, name, @import("std").zig.c_translation.cast(c_long, @"type"), NULL);
+}
+pub inline fn X509_LOOKUP_add_dir(x: anytype, name: anytype, @"type": anytype) @TypeOf(X509_LOOKUP_ctrl(x, X509_L_ADD_DIR, name, @import("std").zig.c_translation.cast(c_long, @"type"), NULL)) {
+ return X509_LOOKUP_ctrl(x, X509_L_ADD_DIR, name, @import("std").zig.c_translation.cast(c_long, @"type"), NULL);
+}
+pub const X509_V_OK = @as(c_int, 0);
+pub const X509_V_ERR_UNSPECIFIED = @as(c_int, 1);
+pub const X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT = @as(c_int, 2);
+pub const X509_V_ERR_UNABLE_TO_GET_CRL = @as(c_int, 3);
+pub const X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE = @as(c_int, 4);
+pub const X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE = @as(c_int, 5);
+pub const X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY = @as(c_int, 6);
+pub const X509_V_ERR_CERT_SIGNATURE_FAILURE = @as(c_int, 7);
+pub const X509_V_ERR_CRL_SIGNATURE_FAILURE = @as(c_int, 8);
+pub const X509_V_ERR_CERT_NOT_YET_VALID = @as(c_int, 9);
+pub const X509_V_ERR_CERT_HAS_EXPIRED = @as(c_int, 10);
+pub const X509_V_ERR_CRL_NOT_YET_VALID = @as(c_int, 11);
+pub const X509_V_ERR_CRL_HAS_EXPIRED = @as(c_int, 12);
+pub const X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD = @as(c_int, 13);
+pub const X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD = @as(c_int, 14);
+pub const X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD = @as(c_int, 15);
+pub const X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD = @as(c_int, 16);
+pub const X509_V_ERR_OUT_OF_MEM = @as(c_int, 17);
+pub const X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT = @as(c_int, 18);
+pub const X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN = @as(c_int, 19);
+pub const X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY = @as(c_int, 20);
+pub const X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE = @as(c_int, 21);
+pub const X509_V_ERR_CERT_CHAIN_TOO_LONG = @as(c_int, 22);
+pub const X509_V_ERR_CERT_REVOKED = @as(c_int, 23);
+pub const X509_V_ERR_INVALID_CA = @as(c_int, 24);
+pub const X509_V_ERR_PATH_LENGTH_EXCEEDED = @as(c_int, 25);
+pub const X509_V_ERR_INVALID_PURPOSE = @as(c_int, 26);
+pub const X509_V_ERR_CERT_UNTRUSTED = @as(c_int, 27);
+pub const X509_V_ERR_CERT_REJECTED = @as(c_int, 28);
+pub const X509_V_ERR_SUBJECT_ISSUER_MISMATCH = @as(c_int, 29);
+pub const X509_V_ERR_AKID_SKID_MISMATCH = @as(c_int, 30);
+pub const X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH = @as(c_int, 31);
+pub const X509_V_ERR_KEYUSAGE_NO_CERTSIGN = @as(c_int, 32);
+pub const X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER = @as(c_int, 33);
+pub const X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION = @as(c_int, 34);
+pub const X509_V_ERR_KEYUSAGE_NO_CRL_SIGN = @as(c_int, 35);
+pub const X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION = @as(c_int, 36);
+pub const X509_V_ERR_INVALID_NON_CA = @as(c_int, 37);
+pub const X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED = @as(c_int, 38);
+pub const X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE = @as(c_int, 39);
+pub const X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED = @as(c_int, 40);
+pub const X509_V_ERR_INVALID_EXTENSION = @as(c_int, 41);
+pub const X509_V_ERR_INVALID_POLICY_EXTENSION = @as(c_int, 42);
+pub const X509_V_ERR_NO_EXPLICIT_POLICY = @as(c_int, 43);
+pub const X509_V_ERR_DIFFERENT_CRL_SCOPE = @as(c_int, 44);
+pub const X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE = @as(c_int, 45);
+pub const X509_V_ERR_UNNESTED_RESOURCE = @as(c_int, 46);
+pub const X509_V_ERR_PERMITTED_VIOLATION = @as(c_int, 47);
+pub const X509_V_ERR_EXCLUDED_VIOLATION = @as(c_int, 48);
+pub const X509_V_ERR_SUBTREE_MINMAX = @as(c_int, 49);
+pub const X509_V_ERR_APPLICATION_VERIFICATION = @as(c_int, 50);
+pub const X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE = @as(c_int, 51);
+pub const X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX = @as(c_int, 52);
+pub const X509_V_ERR_UNSUPPORTED_NAME_SYNTAX = @as(c_int, 53);
+pub const X509_V_ERR_CRL_PATH_VALIDATION_ERROR = @as(c_int, 54);
+pub const X509_V_ERR_SUITE_B_INVALID_VERSION = @as(c_int, 56);
+pub const X509_V_ERR_SUITE_B_INVALID_ALGORITHM = @as(c_int, 57);
+pub const X509_V_ERR_SUITE_B_INVALID_CURVE = @as(c_int, 58);
+pub const X509_V_ERR_SUITE_B_INVALID_SIGNATURE_ALGORITHM = @as(c_int, 59);
+pub const X509_V_ERR_SUITE_B_LOS_NOT_ALLOWED = @as(c_int, 60);
+pub const X509_V_ERR_SUITE_B_CANNOT_SIGN_P_384_WITH_P_256 = @as(c_int, 61);
+pub const X509_V_ERR_HOSTNAME_MISMATCH = @as(c_int, 62);
+pub const X509_V_ERR_EMAIL_MISMATCH = @as(c_int, 63);
+pub const X509_V_ERR_IP_ADDRESS_MISMATCH = @as(c_int, 64);
+pub const X509_V_ERR_INVALID_CALL = @as(c_int, 65);
+pub const X509_V_ERR_STORE_LOOKUP = @as(c_int, 66);
+pub const X509_V_ERR_NAME_CONSTRAINTS_WITHOUT_SANS = @as(c_int, 67);
+pub const X509_V_FLAG_CB_ISSUER_CHECK = @as(c_int, 0x1);
+pub const X509_V_FLAG_USE_CHECK_TIME = @as(c_int, 0x2);
+pub const X509_V_FLAG_CRL_CHECK = @as(c_int, 0x4);
+pub const X509_V_FLAG_CRL_CHECK_ALL = @as(c_int, 0x8);
+pub const X509_V_FLAG_IGNORE_CRITICAL = @as(c_int, 0x10);
+pub const X509_V_FLAG_X509_STRICT = @as(c_int, 0x00);
+pub const X509_V_FLAG_ALLOW_PROXY_CERTS = @as(c_int, 0x40);
+pub const X509_V_FLAG_POLICY_CHECK = @as(c_int, 0x80);
+pub const X509_V_FLAG_EXPLICIT_POLICY = @as(c_int, 0x100);
+pub const X509_V_FLAG_INHIBIT_ANY = @as(c_int, 0x200);
+pub const X509_V_FLAG_INHIBIT_MAP = @as(c_int, 0x400);
+pub const X509_V_FLAG_NOTIFY_POLICY = @as(c_int, 0x800);
+pub const X509_V_FLAG_EXTENDED_CRL_SUPPORT = @as(c_int, 0x1000);
+pub const X509_V_FLAG_USE_DELTAS = @as(c_int, 0x2000);
+pub const X509_V_FLAG_CHECK_SS_SIGNATURE = @as(c_int, 0x4000);
+pub const X509_V_FLAG_TRUSTED_FIRST = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x8000, .hexadecimal);
+pub const X509_V_FLAG_SUITEB_128_LOS_ONLY = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x10000, .hexadecimal);
+pub const X509_V_FLAG_SUITEB_192_LOS = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x20000, .hexadecimal);
+pub const X509_V_FLAG_SUITEB_128_LOS = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x30000, .hexadecimal);
+pub const X509_V_FLAG_PARTIAL_CHAIN = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x80000, .hexadecimal);
+pub const X509_V_FLAG_NO_ALT_CHAINS = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x100000, .hexadecimal);
+pub const X509_VP_FLAG_DEFAULT = @as(c_int, 0x1);
+pub const X509_VP_FLAG_OVERWRITE = @as(c_int, 0x2);
+pub const X509_VP_FLAG_RESET_FLAGS = @as(c_int, 0x4);
+pub const X509_VP_FLAG_LOCKED = @as(c_int, 0x8);
+pub const X509_VP_FLAG_ONCE = @as(c_int, 0x10);
+pub const X509_V_FLAG_POLICY_MASK = ((X509_V_FLAG_POLICY_CHECK | X509_V_FLAG_EXPLICIT_POLICY) | X509_V_FLAG_INHIBIT_ANY) | X509_V_FLAG_INHIBIT_MAP;
+pub inline fn X509_STORE_set_verify_func(ctx: anytype, func: anytype) @TypeOf(X509_STORE_set_verify(ctx, func)) {
+ return X509_STORE_set_verify(ctx, func);
+}
+pub inline fn X509_STORE_set_verify_cb_func(ctx: anytype, func: anytype) @TypeOf(X509_STORE_set_verify_cb(ctx, func)) {
+ return X509_STORE_set_verify_cb(ctx, func);
+}
+pub inline fn X509_STORE_set_lookup_crls_cb(ctx: anytype, func: anytype) @TypeOf(X509_STORE_set_lookup_crls(ctx, func)) {
+ return X509_STORE_set_lookup_crls(ctx, func);
+}
+pub const X509_R_AKID_MISMATCH = @as(c_int, 100);
+pub const X509_R_BAD_PKCS7_VERSION = @as(c_int, 101);
+pub const X509_R_BAD_X509_FILETYPE = @as(c_int, 102);
+pub const X509_R_BASE64_DECODE_ERROR = @as(c_int, 103);
+pub const X509_R_CANT_CHECK_DH_KEY = @as(c_int, 104);
+pub const X509_R_CERT_ALREADY_IN_HASH_TABLE = @as(c_int, 105);
+pub const X509_R_CRL_ALREADY_DELTA = @as(c_int, 106);
+pub const X509_R_CRL_VERIFY_FAILURE = @as(c_int, 107);
+pub const X509_R_IDP_MISMATCH = @as(c_int, 108);
+pub const X509_R_INVALID_BIT_STRING_BITS_LEFT = @as(c_int, 109);
+pub const X509_R_INVALID_DIRECTORY = @as(c_int, 110);
+pub const X509_R_INVALID_FIELD_NAME = @as(c_int, 111);
+pub const X509_R_INVALID_PSS_PARAMETERS = @as(c_int, 112);
+pub const X509_R_INVALID_TRUST = @as(c_int, 113);
+pub const X509_R_ISSUER_MISMATCH = @as(c_int, 114);
+pub const X509_R_KEY_TYPE_MISMATCH = @as(c_int, 115);
+pub const X509_R_KEY_VALUES_MISMATCH = @as(c_int, 116);
+pub const X509_R_LOADING_CERT_DIR = @as(c_int, 117);
+pub const X509_R_LOADING_DEFAULTS = @as(c_int, 118);
+pub const X509_R_NEWER_CRL_NOT_NEWER = @as(c_int, 119);
+pub const X509_R_NOT_PKCS7_SIGNED_DATA = @as(c_int, 120);
+pub const X509_R_NO_CERTIFICATES_INCLUDED = @as(c_int, 121);
+pub const X509_R_NO_CERT_SET_FOR_US_TO_VERIFY = @as(c_int, 122);
+pub const X509_R_NO_CRLS_INCLUDED = @as(c_int, 123);
+pub const X509_R_NO_CRL_NUMBER = @as(c_int, 124);
+pub const X509_R_PUBLIC_KEY_DECODE_ERROR = @as(c_int, 125);
+pub const X509_R_PUBLIC_KEY_ENCODE_ERROR = @as(c_int, 126);
+pub const X509_R_SHOULD_RETRY = @as(c_int, 127);
+pub const X509_R_UNKNOWN_KEY_TYPE = @as(c_int, 128);
+pub const X509_R_UNKNOWN_NID = @as(c_int, 129);
+pub const X509_R_UNKNOWN_PURPOSE_ID = @as(c_int, 130);
+pub const X509_R_UNKNOWN_TRUST_ID = @as(c_int, 131);
+pub const X509_R_UNSUPPORTED_ALGORITHM = @as(c_int, 132);
+pub const X509_R_WRONG_LOOKUP_TYPE = @as(c_int, 133);
+pub const X509_R_WRONG_TYPE = @as(c_int, 134);
+pub const X509_R_NAME_TOO_LONG = @as(c_int, 135);
+pub const X509_R_INVALID_PARAMETER = @as(c_int, 136);
+pub const X509_R_SIGNATURE_ALGORITHM_MISMATCH = @as(c_int, 137);
+pub const X509_R_DELTA_CRL_WITHOUT_CRL_NUMBER = @as(c_int, 138);
+pub const X509_R_INVALID_FIELD_FOR_VERSION = @as(c_int, 139);
+pub const X509_R_INVALID_VERSION = @as(c_int, 140);
+pub const OPENSSL_VERSION_TEXT = "OpenSSL 1.1.1 (compatible; BoringSSL)";
+pub const OPENSSL_VERSION = @as(c_int, 0);
+pub const OPENSSL_CFLAGS = @as(c_int, 1);
+pub const OPENSSL_BUILT_ON = @as(c_int, 2);
+pub const OPENSSL_PLATFORM = @as(c_int, 3);
+pub const OPENSSL_DIR = @as(c_int, 4);
+pub const SSLEAY_VERSION = OPENSSL_VERSION;
+pub const SSLEAY_CFLAGS = OPENSSL_CFLAGS;
+pub const SSLEAY_BUILT_ON = OPENSSL_BUILT_ON;
+pub const SSLEAY_PLATFORM = OPENSSL_PLATFORM;
+pub const SSLEAY_DIR = OPENSSL_DIR;
+pub const OPENSSL_INIT_NO_LOAD_CRYPTO_STRINGS = @as(c_int, 0);
+pub const OPENSSL_INIT_LOAD_CRYPTO_STRINGS = @as(c_int, 0);
+pub const OPENSSL_INIT_ADD_ALL_CIPHERS = @as(c_int, 0);
+pub const OPENSSL_INIT_ADD_ALL_DIGESTS = @as(c_int, 0);
+pub const OPENSSL_INIT_NO_ADD_ALL_CIPHERS = @as(c_int, 0);
+pub const OPENSSL_INIT_NO_ADD_ALL_DIGESTS = @as(c_int, 0);
+pub const OPENSSL_INIT_LOAD_CONFIG = @as(c_int, 0);
+pub const OPENSSL_INIT_NO_LOAD_CONFIG = @as(c_int, 0);
+pub const PEM_BUFSIZE = @as(c_int, 1024);
+pub const PEM_STRING_X509_OLD = "X509 CERTIFICATE";
+pub const PEM_STRING_X509 = "CERTIFICATE";
+pub const PEM_STRING_X509_PAIR = "CERTIFICATE PAIR";
+pub const PEM_STRING_X509_TRUSTED = "TRUSTED CERTIFICATE";
+pub const PEM_STRING_X509_REQ_OLD = "NEW CERTIFICATE REQUEST";
+pub const PEM_STRING_X509_REQ = "CERTIFICATE REQUEST";
+pub const PEM_STRING_X509_CRL = "X509 CRL";
+pub const PEM_STRING_EVP_PKEY = "ANY PRIVATE KEY";
+pub const PEM_STRING_PUBLIC = "PUBLIC KEY";
+pub const PEM_STRING_RSA = "RSA PRIVATE KEY";
+pub const PEM_STRING_RSA_PUBLIC = "RSA PUBLIC KEY";
+pub const PEM_STRING_DSA = "DSA PRIVATE KEY";
+pub const PEM_STRING_DSA_PUBLIC = "DSA PUBLIC KEY";
+pub const PEM_STRING_EC = "EC PRIVATE KEY";
+pub const PEM_STRING_PKCS7 = "PKCS7";
+pub const PEM_STRING_PKCS7_SIGNED = "PKCS #7 SIGNED DATA";
+pub const PEM_STRING_PKCS8 = "ENCRYPTED PRIVATE KEY";
+pub const PEM_STRING_PKCS8INF = "PRIVATE KEY";
+pub const PEM_STRING_DHPARAMS = "DH PARAMETERS";
+pub const PEM_STRING_SSL_SESSION = "SSL SESSION PARAMETERS";
+pub const PEM_STRING_DSAPARAMS = "DSA PARAMETERS";
+pub const PEM_STRING_ECDSA_PUBLIC = "ECDSA PUBLIC KEY";
+pub const PEM_STRING_ECPRIVATEKEY = "EC PRIVATE KEY";
+pub const PEM_STRING_CMS = "CMS";
+pub const PEM_TYPE_ENCRYPTED = @as(c_int, 10);
+pub const PEM_TYPE_MIC_ONLY = @as(c_int, 20);
+pub const PEM_TYPE_MIC_CLEAR = @as(c_int, 30);
+pub const PEM_TYPE_CLEAR = @as(c_int, 40);
+pub const PEM_R_BAD_BASE64_DECODE = @as(c_int, 100);
+pub const PEM_R_BAD_DECRYPT = @as(c_int, 101);
+pub const PEM_R_BAD_END_LINE = @as(c_int, 102);
+pub const PEM_R_BAD_IV_CHARS = @as(c_int, 103);
+pub const PEM_R_BAD_PASSWORD_READ = @as(c_int, 104);
+pub const PEM_R_CIPHER_IS_NULL = @as(c_int, 105);
+pub const PEM_R_ERROR_CONVERTING_PRIVATE_KEY = @as(c_int, 106);
+pub const PEM_R_NOT_DEK_INFO = @as(c_int, 107);
+pub const PEM_R_NOT_ENCRYPTED = @as(c_int, 108);
+pub const PEM_R_NOT_PROC_TYPE = @as(c_int, 109);
+pub const PEM_R_NO_START_LINE = @as(c_int, 110);
+pub const PEM_R_READ_KEY = @as(c_int, 111);
+pub const PEM_R_SHORT_HEADER = @as(c_int, 112);
+pub const PEM_R_UNSUPPORTED_CIPHER = @as(c_int, 113);
+pub const PEM_R_UNSUPPORTED_ENCRYPTION = @as(c_int, 114);
+pub const SSL2_MT_CLIENT_HELLO = @as(c_int, 1);
+pub const SSL2_VERSION = @as(c_int, 0x0002);
+pub const SSL3_CK_SCSV = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x030000FF, .hexadecimal);
+pub const SSL3_CK_FALLBACK_SCSV = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03005600, .hexadecimal);
+pub const SSL3_CK_RSA_NULL_MD5 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000001, .hexadecimal);
+pub const SSL3_CK_RSA_NULL_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000002, .hexadecimal);
+pub const SSL3_CK_RSA_RC4_40_MD5 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000003, .hexadecimal);
+pub const SSL3_CK_RSA_RC4_128_MD5 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000004, .hexadecimal);
+pub const SSL3_CK_RSA_RC4_128_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000005, .hexadecimal);
+pub const SSL3_CK_RSA_RC2_40_MD5 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000006, .hexadecimal);
+pub const SSL3_CK_RSA_IDEA_128_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000007, .hexadecimal);
+pub const SSL3_CK_RSA_DES_40_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000008, .hexadecimal);
+pub const SSL3_CK_RSA_DES_64_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000009, .hexadecimal);
+pub const SSL3_CK_RSA_DES_192_CBC3_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300000A, .hexadecimal);
+pub const SSL3_CK_DH_DSS_DES_40_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300000B, .hexadecimal);
+pub const SSL3_CK_DH_DSS_DES_64_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300000C, .hexadecimal);
+pub const SSL3_CK_DH_DSS_DES_192_CBC3_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300000D, .hexadecimal);
+pub const SSL3_CK_DH_RSA_DES_40_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300000E, .hexadecimal);
+pub const SSL3_CK_DH_RSA_DES_64_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300000F, .hexadecimal);
+pub const SSL3_CK_DH_RSA_DES_192_CBC3_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000010, .hexadecimal);
+pub const SSL3_CK_EDH_DSS_DES_40_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000011, .hexadecimal);
+pub const SSL3_CK_EDH_DSS_DES_64_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000012, .hexadecimal);
+pub const SSL3_CK_EDH_DSS_DES_192_CBC3_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000013, .hexadecimal);
+pub const SSL3_CK_EDH_RSA_DES_40_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000014, .hexadecimal);
+pub const SSL3_CK_EDH_RSA_DES_64_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000015, .hexadecimal);
+pub const SSL3_CK_EDH_RSA_DES_192_CBC3_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000016, .hexadecimal);
+pub const SSL3_CK_ADH_RC4_40_MD5 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000017, .hexadecimal);
+pub const SSL3_CK_ADH_RC4_128_MD5 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000018, .hexadecimal);
+pub const SSL3_CK_ADH_DES_40_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000019, .hexadecimal);
+pub const SSL3_CK_ADH_DES_64_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300001A, .hexadecimal);
+pub const SSL3_CK_ADH_DES_192_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300001B, .hexadecimal);
+pub const SSL3_TXT_RSA_NULL_MD5 = "NULL-MD5";
+pub const SSL3_TXT_RSA_NULL_SHA = "NULL-SHA";
+pub const SSL3_TXT_RSA_RC4_40_MD5 = "EXP-RC4-MD5";
+pub const SSL3_TXT_RSA_RC4_128_MD5 = "RC4-MD5";
+pub const SSL3_TXT_RSA_RC4_128_SHA = "RC4-SHA";
+pub const SSL3_TXT_RSA_RC2_40_MD5 = "EXP-RC2-CBC-MD5";
+pub const SSL3_TXT_RSA_IDEA_128_SHA = "IDEA-CBC-SHA";
+pub const SSL3_TXT_RSA_DES_40_CBC_SHA = "EXP-DES-CBC-SHA";
+pub const SSL3_TXT_RSA_DES_64_CBC_SHA = "DES-CBC-SHA";
+pub const SSL3_TXT_RSA_DES_192_CBC3_SHA = "DES-CBC3-SHA";
+pub const SSL3_TXT_DH_DSS_DES_40_CBC_SHA = "EXP-DH-DSS-DES-CBC-SHA";
+pub const SSL3_TXT_DH_DSS_DES_64_CBC_SHA = "DH-DSS-DES-CBC-SHA";
+pub const SSL3_TXT_DH_DSS_DES_192_CBC3_SHA = "DH-DSS-DES-CBC3-SHA";
+pub const SSL3_TXT_DH_RSA_DES_40_CBC_SHA = "EXP-DH-RSA-DES-CBC-SHA";
+pub const SSL3_TXT_DH_RSA_DES_64_CBC_SHA = "DH-RSA-DES-CBC-SHA";
+pub const SSL3_TXT_DH_RSA_DES_192_CBC3_SHA = "DH-RSA-DES-CBC3-SHA";
+pub const SSL3_TXT_EDH_DSS_DES_40_CBC_SHA = "EXP-EDH-DSS-DES-CBC-SHA";
+pub const SSL3_TXT_EDH_DSS_DES_64_CBC_SHA = "EDH-DSS-DES-CBC-SHA";
+pub const SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA = "EDH-DSS-DES-CBC3-SHA";
+pub const SSL3_TXT_EDH_RSA_DES_40_CBC_SHA = "EXP-EDH-RSA-DES-CBC-SHA";
+pub const SSL3_TXT_EDH_RSA_DES_64_CBC_SHA = "EDH-RSA-DES-CBC-SHA";
+pub const SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA = "EDH-RSA-DES-CBC3-SHA";
+pub const SSL3_TXT_ADH_RC4_40_MD5 = "EXP-ADH-RC4-MD5";
+pub const SSL3_TXT_ADH_RC4_128_MD5 = "ADH-RC4-MD5";
+pub const SSL3_TXT_ADH_DES_40_CBC_SHA = "EXP-ADH-DES-CBC-SHA";
+pub const SSL3_TXT_ADH_DES_64_CBC_SHA = "ADH-DES-CBC-SHA";
+pub const SSL3_TXT_ADH_DES_192_CBC_SHA = "ADH-DES-CBC3-SHA";
+pub const SSL3_SSL_SESSION_ID_LENGTH = @as(c_int, 32);
+pub const SSL3_MAX_SSL_SESSION_ID_LENGTH = @as(c_int, 32);
+pub const SSL3_MASTER_SECRET_SIZE = @as(c_int, 48);
+pub const SSL3_RANDOM_SIZE = @as(c_int, 32);
+pub const SSL3_SESSION_ID_SIZE = @as(c_int, 32);
+pub const SSL3_RT_HEADER_LENGTH = @as(c_int, 5);
+pub const SSL3_HM_HEADER_LENGTH = @as(c_int, 4);
+pub const SSL3_ALIGN_PAYLOAD = @as(c_int, 8);
+pub const SSL3_RT_MAX_MD_SIZE = @as(c_int, 64);
+pub const SSL_RT_MAX_CIPHER_BLOCK_SIZE = @as(c_int, 16);
+pub const SSL3_RT_MAX_PLAIN_LENGTH = @as(c_int, 16384);
+pub const SSL3_RT_MAX_COMPRESSED_OVERHEAD = @as(c_int, 1024);
+pub const SSL3_RT_MAX_ENCRYPTED_OVERHEAD = @as(c_int, 256) + SSL3_RT_MAX_MD_SIZE;
+pub const SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD = EVP_AEAD_MAX_OVERHEAD + EVP_AEAD_MAX_NONCE_LENGTH;
+pub const SSL3_RT_MAX_COMPRESSED_LENGTH = SSL3_RT_MAX_PLAIN_LENGTH;
+pub const SSL3_RT_MAX_ENCRYPTED_LENGTH = SSL3_RT_MAX_ENCRYPTED_OVERHEAD + SSL3_RT_MAX_COMPRESSED_LENGTH;
+pub const SSL3_RT_MAX_PACKET_SIZE = SSL3_RT_MAX_ENCRYPTED_LENGTH + SSL3_RT_HEADER_LENGTH;
+pub const SSL3_MD_CLIENT_FINISHED_CONST = "\x43\x4c\x4e\x54";
+pub const SSL3_MD_SERVER_FINISHED_CONST = "\x53\x52\x56\x52";
+pub const SSL3_RT_CHANGE_CIPHER_SPEC = @as(c_int, 20);
+pub const SSL3_RT_ALERT = @as(c_int, 21);
+pub const SSL3_RT_HANDSHAKE = @as(c_int, 22);
+pub const SSL3_RT_APPLICATION_DATA = @as(c_int, 23);
+pub const SSL3_RT_HEADER = @as(c_int, 0x100);
+pub const SSL3_AL_WARNING = @as(c_int, 1);
+pub const SSL3_AL_FATAL = @as(c_int, 2);
+pub const SSL3_AD_CLOSE_NOTIFY = @as(c_int, 0);
+pub const SSL3_AD_UNEXPECTED_MESSAGE = @as(c_int, 10);
+pub const SSL3_AD_BAD_RECORD_MAC = @as(c_int, 20);
+pub const SSL3_AD_DECOMPRESSION_FAILURE = @as(c_int, 30);
+pub const SSL3_AD_HANDSHAKE_FAILURE = @as(c_int, 40);
+pub const SSL3_AD_NO_CERTIFICATE = @as(c_int, 41);
+pub const SSL3_AD_BAD_CERTIFICATE = @as(c_int, 42);
+pub const SSL3_AD_UNSUPPORTED_CERTIFICATE = @as(c_int, 43);
+pub const SSL3_AD_CERTIFICATE_REVOKED = @as(c_int, 44);
+pub const SSL3_AD_CERTIFICATE_EXPIRED = @as(c_int, 45);
+pub const SSL3_AD_CERTIFICATE_UNKNOWN = @as(c_int, 46);
+pub const SSL3_AD_ILLEGAL_PARAMETER = @as(c_int, 47);
+pub const SSL3_AD_INAPPROPRIATE_FALLBACK = @as(c_int, 86);
+pub const SSL3_CT_RSA_SIGN = @as(c_int, 1);
+pub const SSL3_MT_HELLO_REQUEST = @as(c_int, 0);
+pub const SSL3_MT_CLIENT_HELLO = @as(c_int, 1);
+pub const SSL3_MT_SERVER_HELLO = @as(c_int, 2);
+pub const SSL3_MT_NEW_SESSION_TICKET = @as(c_int, 4);
+pub const SSL3_MT_END_OF_EARLY_DATA = @as(c_int, 5);
+pub const SSL3_MT_ENCRYPTED_EXTENSIONS = @as(c_int, 8);
+pub const SSL3_MT_CERTIFICATE = @as(c_int, 11);
+pub const SSL3_MT_SERVER_KEY_EXCHANGE = @as(c_int, 12);
+pub const SSL3_MT_CERTIFICATE_REQUEST = @as(c_int, 13);
+pub const SSL3_MT_SERVER_HELLO_DONE = @as(c_int, 14);
+pub const SSL3_MT_CERTIFICATE_VERIFY = @as(c_int, 15);
+pub const SSL3_MT_CLIENT_KEY_EXCHANGE = @as(c_int, 16);
+pub const SSL3_MT_FINISHED = @as(c_int, 20);
+pub const SSL3_MT_CERTIFICATE_STATUS = @as(c_int, 22);
+pub const SSL3_MT_SUPPLEMENTAL_DATA = @as(c_int, 23);
+pub const SSL3_MT_KEY_UPDATE = @as(c_int, 24);
+pub const SSL3_MT_COMPRESSED_CERTIFICATE = @as(c_int, 25);
+pub const SSL3_MT_NEXT_PROTO = @as(c_int, 67);
+pub const SSL3_MT_CHANNEL_ID = @as(c_int, 203);
+pub const SSL3_MT_MESSAGE_HASH = @as(c_int, 254);
+pub const DTLS1_MT_HELLO_VERIFY_REQUEST = @as(c_int, 3);
+pub const SSL3_MT_SERVER_DONE = SSL3_MT_SERVER_HELLO_DONE;
+pub const SSL3_MT_NEWSESSION_TICKET = SSL3_MT_NEW_SESSION_TICKET;
+pub const SSL3_MT_CCS = @as(c_int, 1);
+pub const TLS1_AD_END_OF_EARLY_DATA = @as(c_int, 1);
+pub const TLS1_AD_DECRYPTION_FAILED = @as(c_int, 21);
+pub const TLS1_AD_RECORD_OVERFLOW = @as(c_int, 22);
+pub const TLS1_AD_UNKNOWN_CA = @as(c_int, 48);
+pub const TLS1_AD_ACCESS_DENIED = @as(c_int, 49);
+pub const TLS1_AD_DECODE_ERROR = @as(c_int, 50);
+pub const TLS1_AD_DECRYPT_ERROR = @as(c_int, 51);
+pub const TLS1_AD_EXPORT_RESTRICTION = @as(c_int, 60);
+pub const TLS1_AD_PROTOCOL_VERSION = @as(c_int, 70);
+pub const TLS1_AD_INSUFFICIENT_SECURITY = @as(c_int, 71);
+pub const TLS1_AD_INTERNAL_ERROR = @as(c_int, 80);
+pub const TLS1_AD_USER_CANCELLED = @as(c_int, 90);
+pub const TLS1_AD_NO_RENEGOTIATION = @as(c_int, 100);
+pub const TLS1_AD_MISSING_EXTENSION = @as(c_int, 109);
+pub const TLS1_AD_UNSUPPORTED_EXTENSION = @as(c_int, 110);
+pub const TLS1_AD_CERTIFICATE_UNOBTAINABLE = @as(c_int, 111);
+pub const TLS1_AD_UNRECOGNIZED_NAME = @as(c_int, 112);
+pub const TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE = @as(c_int, 113);
+pub const TLS1_AD_BAD_CERTIFICATE_HASH_VALUE = @as(c_int, 114);
+pub const TLS1_AD_UNKNOWN_PSK_IDENTITY = @as(c_int, 115);
+pub const TLS1_AD_CERTIFICATE_REQUIRED = @as(c_int, 116);
+pub const TLS1_AD_NO_APPLICATION_PROTOCOL = @as(c_int, 120);
+pub const TLS1_AD_ECH_REQUIRED = @as(c_int, 121);
+pub const TLSEXT_TYPE_server_name = @as(c_int, 0);
+pub const TLSEXT_TYPE_status_request = @as(c_int, 5);
+pub const TLSEXT_TYPE_ec_point_formats = @as(c_int, 11);
+pub const TLSEXT_TYPE_signature_algorithms = @as(c_int, 13);
+pub const TLSEXT_TYPE_srtp = @as(c_int, 14);
+pub const TLSEXT_TYPE_application_layer_protocol_negotiation = @as(c_int, 16);
+pub const TLSEXT_TYPE_padding = @as(c_int, 21);
+pub const TLSEXT_TYPE_extended_master_secret = @as(c_int, 23);
+pub const TLSEXT_TYPE_quic_transport_parameters_legacy = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0xffa5, .hexadecimal);
+pub const TLSEXT_TYPE_quic_transport_parameters = @as(c_int, 57);
+pub const TLSEXT_TYPE_quic_transport_parameters_standard = TLSEXT_TYPE_quic_transport_parameters;
+pub const TLSEXT_TYPE_cert_compression = @as(c_int, 27);
+pub const TLSEXT_TYPE_session_ticket = @as(c_int, 35);
+pub const TLSEXT_TYPE_supported_groups = @as(c_int, 10);
+pub const TLSEXT_TYPE_pre_shared_key = @as(c_int, 41);
+pub const TLSEXT_TYPE_early_data = @as(c_int, 42);
+pub const TLSEXT_TYPE_supported_versions = @as(c_int, 43);
+pub const TLSEXT_TYPE_cookie = @as(c_int, 44);
+pub const TLSEXT_TYPE_psk_key_exchange_modes = @as(c_int, 45);
+pub const TLSEXT_TYPE_certificate_authorities = @as(c_int, 47);
+pub const TLSEXT_TYPE_signature_algorithms_cert = @as(c_int, 50);
+pub const TLSEXT_TYPE_key_share = @as(c_int, 51);
+pub const TLSEXT_TYPE_renegotiate = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0xff01, .hexadecimal);
+pub const TLSEXT_TYPE_delegated_credential = @as(c_int, 0x22);
+pub const TLSEXT_TYPE_application_settings = @as(c_int, 17513);
+pub const TLSEXT_TYPE_encrypted_client_hello = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0xfe0d, .hexadecimal);
+pub const TLSEXT_TYPE_ech_outer_extensions = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0xfd00, .hexadecimal);
+pub const TLSEXT_TYPE_certificate_timestamp = @as(c_int, 18);
+pub const TLSEXT_TYPE_next_proto_neg = @as(c_int, 13172);
+pub const TLSEXT_TYPE_channel_id = @as(c_int, 30032);
+pub const TLSEXT_STATUSTYPE_nothing = -@as(c_int, 1);
+pub const TLSEXT_STATUSTYPE_ocsp = @as(c_int, 1);
+pub const TLSEXT_ECPOINTFORMAT_uncompressed = @as(c_int, 0);
+pub const TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime = @as(c_int, 1);
+pub const TLSEXT_signature_anonymous = @as(c_int, 0);
+pub const TLSEXT_signature_rsa = @as(c_int, 1);
+pub const TLSEXT_signature_dsa = @as(c_int, 2);
+pub const TLSEXT_signature_ecdsa = @as(c_int, 3);
+pub const TLSEXT_hash_none = @as(c_int, 0);
+pub const TLSEXT_hash_md5 = @as(c_int, 1);
+pub const TLSEXT_hash_sha1 = @as(c_int, 2);
+pub const TLSEXT_hash_sha224 = @as(c_int, 3);
+pub const TLSEXT_hash_sha256 = @as(c_int, 4);
+pub const TLSEXT_hash_sha384 = @as(c_int, 5);
+pub const TLSEXT_hash_sha512 = @as(c_int, 6);
+pub const TLSEXT_cert_compression_zlib = @as(c_int, 1);
+pub const TLSEXT_cert_compression_brotli = @as(c_int, 2);
+pub const TLSEXT_MAXLEN_host_name = @as(c_int, 255);
+pub const TLS1_CK_PSK_WITH_RC4_128_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300008A, .hexadecimal);
+pub const TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300008B, .hexadecimal);
+pub const TLS1_CK_PSK_WITH_AES_128_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300008C, .hexadecimal);
+pub const TLS1_CK_PSK_WITH_AES_256_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300008D, .hexadecimal);
+pub const TLS1_CK_ECDHE_PSK_WITH_AES_128_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C035, .hexadecimal);
+pub const TLS1_CK_ECDHE_PSK_WITH_AES_256_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C036, .hexadecimal);
+pub const TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000060, .hexadecimal);
+pub const TLS1_CK_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000061, .hexadecimal);
+pub const TLS1_CK_RSA_EXPORT1024_WITH_DES_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000062, .hexadecimal);
+pub const TLS1_CK_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000063, .hexadecimal);
+pub const TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000064, .hexadecimal);
+pub const TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000065, .hexadecimal);
+pub const TLS1_CK_DHE_DSS_WITH_RC4_128_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000066, .hexadecimal);
+pub const TLS1_CK_RSA_WITH_AES_128_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300002F, .hexadecimal);
+pub const TLS1_CK_DH_DSS_WITH_AES_128_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000030, .hexadecimal);
+pub const TLS1_CK_DH_RSA_WITH_AES_128_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000031, .hexadecimal);
+pub const TLS1_CK_DHE_DSS_WITH_AES_128_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000032, .hexadecimal);
+pub const TLS1_CK_DHE_RSA_WITH_AES_128_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000033, .hexadecimal);
+pub const TLS1_CK_ADH_WITH_AES_128_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000034, .hexadecimal);
+pub const TLS1_CK_RSA_WITH_AES_256_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000035, .hexadecimal);
+pub const TLS1_CK_DH_DSS_WITH_AES_256_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000036, .hexadecimal);
+pub const TLS1_CK_DH_RSA_WITH_AES_256_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000037, .hexadecimal);
+pub const TLS1_CK_DHE_DSS_WITH_AES_256_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000038, .hexadecimal);
+pub const TLS1_CK_DHE_RSA_WITH_AES_256_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000039, .hexadecimal);
+pub const TLS1_CK_ADH_WITH_AES_256_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300003A, .hexadecimal);
+pub const TLS1_CK_RSA_WITH_NULL_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300003B, .hexadecimal);
+pub const TLS1_CK_RSA_WITH_AES_128_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300003C, .hexadecimal);
+pub const TLS1_CK_RSA_WITH_AES_256_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300003D, .hexadecimal);
+pub const TLS1_CK_DH_DSS_WITH_AES_128_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300003E, .hexadecimal);
+pub const TLS1_CK_DH_RSA_WITH_AES_128_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300003F, .hexadecimal);
+pub const TLS1_CK_DHE_DSS_WITH_AES_128_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000040, .hexadecimal);
+pub const TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000041, .hexadecimal);
+pub const TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000042, .hexadecimal);
+pub const TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000043, .hexadecimal);
+pub const TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000044, .hexadecimal);
+pub const TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000045, .hexadecimal);
+pub const TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000046, .hexadecimal);
+pub const TLS1_CK_DHE_RSA_WITH_AES_128_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000067, .hexadecimal);
+pub const TLS1_CK_DH_DSS_WITH_AES_256_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000068, .hexadecimal);
+pub const TLS1_CK_DH_RSA_WITH_AES_256_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000069, .hexadecimal);
+pub const TLS1_CK_DHE_DSS_WITH_AES_256_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300006A, .hexadecimal);
+pub const TLS1_CK_DHE_RSA_WITH_AES_256_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300006B, .hexadecimal);
+pub const TLS1_CK_ADH_WITH_AES_128_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300006C, .hexadecimal);
+pub const TLS1_CK_ADH_WITH_AES_256_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300006D, .hexadecimal);
+pub const TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000084, .hexadecimal);
+pub const TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000085, .hexadecimal);
+pub const TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000086, .hexadecimal);
+pub const TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000087, .hexadecimal);
+pub const TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000088, .hexadecimal);
+pub const TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000089, .hexadecimal);
+pub const TLS1_CK_RSA_WITH_SEED_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000096, .hexadecimal);
+pub const TLS1_CK_DH_DSS_WITH_SEED_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000097, .hexadecimal);
+pub const TLS1_CK_DH_RSA_WITH_SEED_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000098, .hexadecimal);
+pub const TLS1_CK_DHE_DSS_WITH_SEED_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03000099, .hexadecimal);
+pub const TLS1_CK_DHE_RSA_WITH_SEED_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300009A, .hexadecimal);
+pub const TLS1_CK_ADH_WITH_SEED_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300009B, .hexadecimal);
+pub const TLS1_CK_RSA_WITH_AES_128_GCM_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300009C, .hexadecimal);
+pub const TLS1_CK_RSA_WITH_AES_256_GCM_SHA384 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300009D, .hexadecimal);
+pub const TLS1_CK_DHE_RSA_WITH_AES_128_GCM_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300009E, .hexadecimal);
+pub const TLS1_CK_DHE_RSA_WITH_AES_256_GCM_SHA384 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300009F, .hexadecimal);
+pub const TLS1_CK_DH_RSA_WITH_AES_128_GCM_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x030000A0, .hexadecimal);
+pub const TLS1_CK_DH_RSA_WITH_AES_256_GCM_SHA384 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x030000A1, .hexadecimal);
+pub const TLS1_CK_DHE_DSS_WITH_AES_128_GCM_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x030000A2, .hexadecimal);
+pub const TLS1_CK_DHE_DSS_WITH_AES_256_GCM_SHA384 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x030000A3, .hexadecimal);
+pub const TLS1_CK_DH_DSS_WITH_AES_128_GCM_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x030000A4, .hexadecimal);
+pub const TLS1_CK_DH_DSS_WITH_AES_256_GCM_SHA384 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x030000A5, .hexadecimal);
+pub const TLS1_CK_ADH_WITH_AES_128_GCM_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x030000A6, .hexadecimal);
+pub const TLS1_CK_ADH_WITH_AES_256_GCM_SHA384 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x030000A7, .hexadecimal);
+pub const TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C001, .hexadecimal);
+pub const TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C002, .hexadecimal);
+pub const TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C003, .hexadecimal);
+pub const TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C004, .hexadecimal);
+pub const TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C005, .hexadecimal);
+pub const TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C006, .hexadecimal);
+pub const TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C007, .hexadecimal);
+pub const TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C008, .hexadecimal);
+pub const TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C009, .hexadecimal);
+pub const TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C00A, .hexadecimal);
+pub const TLS1_CK_ECDH_RSA_WITH_NULL_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C00B, .hexadecimal);
+pub const TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C00C, .hexadecimal);
+pub const TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C00D, .hexadecimal);
+pub const TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C00E, .hexadecimal);
+pub const TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C00F, .hexadecimal);
+pub const TLS1_CK_ECDHE_RSA_WITH_NULL_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C010, .hexadecimal);
+pub const TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C011, .hexadecimal);
+pub const TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C012, .hexadecimal);
+pub const TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C013, .hexadecimal);
+pub const TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C014, .hexadecimal);
+pub const TLS1_CK_ECDH_anon_WITH_NULL_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C015, .hexadecimal);
+pub const TLS1_CK_ECDH_anon_WITH_RC4_128_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C016, .hexadecimal);
+pub const TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C017, .hexadecimal);
+pub const TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C018, .hexadecimal);
+pub const TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C019, .hexadecimal);
+pub const TLS1_CK_SRP_SHA_WITH_3DES_EDE_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C01A, .hexadecimal);
+pub const TLS1_CK_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C01B, .hexadecimal);
+pub const TLS1_CK_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C01C, .hexadecimal);
+pub const TLS1_CK_SRP_SHA_WITH_AES_128_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C01D, .hexadecimal);
+pub const TLS1_CK_SRP_SHA_RSA_WITH_AES_128_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C01E, .hexadecimal);
+pub const TLS1_CK_SRP_SHA_DSS_WITH_AES_128_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C01F, .hexadecimal);
+pub const TLS1_CK_SRP_SHA_WITH_AES_256_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C020, .hexadecimal);
+pub const TLS1_CK_SRP_SHA_RSA_WITH_AES_256_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C021, .hexadecimal);
+pub const TLS1_CK_SRP_SHA_DSS_WITH_AES_256_CBC_SHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C022, .hexadecimal);
+pub const TLS1_CK_ECDHE_ECDSA_WITH_AES_128_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C023, .hexadecimal);
+pub const TLS1_CK_ECDHE_ECDSA_WITH_AES_256_SHA384 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C024, .hexadecimal);
+pub const TLS1_CK_ECDH_ECDSA_WITH_AES_128_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C025, .hexadecimal);
+pub const TLS1_CK_ECDH_ECDSA_WITH_AES_256_SHA384 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C026, .hexadecimal);
+pub const TLS1_CK_ECDHE_RSA_WITH_AES_128_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C027, .hexadecimal);
+pub const TLS1_CK_ECDHE_RSA_WITH_AES_256_SHA384 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C028, .hexadecimal);
+pub const TLS1_CK_ECDH_RSA_WITH_AES_128_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C029, .hexadecimal);
+pub const TLS1_CK_ECDH_RSA_WITH_AES_256_SHA384 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C02A, .hexadecimal);
+pub const TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C02B, .hexadecimal);
+pub const TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C02C, .hexadecimal);
+pub const TLS1_CK_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C02D, .hexadecimal);
+pub const TLS1_CK_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C02E, .hexadecimal);
+pub const TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C02F, .hexadecimal);
+pub const TLS1_CK_ECDHE_RSA_WITH_AES_256_GCM_SHA384 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C030, .hexadecimal);
+pub const TLS1_CK_ECDH_RSA_WITH_AES_128_GCM_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C031, .hexadecimal);
+pub const TLS1_CK_ECDH_RSA_WITH_AES_256_GCM_SHA384 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300C032, .hexadecimal);
+pub const TLS1_CK_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300CCA8, .hexadecimal);
+pub const TLS1_CK_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300CCA9, .hexadecimal);
+pub const TLS1_CK_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0300CCAC, .hexadecimal);
+pub const TLS1_CK_AES_128_GCM_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03001301, .hexadecimal);
+pub const TLS1_CK_AES_256_GCM_SHA384 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03001302, .hexadecimal);
+pub const TLS1_CK_CHACHA20_POLY1305_SHA256 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x03001303, .hexadecimal);
+pub const TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_MD5 = "EXP1024-RC4-MD5";
+pub const TLS1_TXT_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5 = "EXP1024-RC2-CBC-MD5";
+pub const TLS1_TXT_RSA_EXPORT1024_WITH_DES_CBC_SHA = "EXP1024-DES-CBC-SHA";
+pub const TLS1_TXT_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA = "EXP1024-DHE-DSS-DES-CBC-SHA";
+pub const TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA = "EXP1024-RC4-SHA";
+pub const TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA = "EXP1024-DHE-DSS-RC4-SHA";
+pub const TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA = "DHE-DSS-RC4-SHA";
+pub const TLS1_TXT_RSA_WITH_AES_128_SHA = "AES128-SHA";
+pub const TLS1_TXT_DH_DSS_WITH_AES_128_SHA = "DH-DSS-AES128-SHA";
+pub const TLS1_TXT_DH_RSA_WITH_AES_128_SHA = "DH-RSA-AES128-SHA";
+pub const TLS1_TXT_DHE_DSS_WITH_AES_128_SHA = "DHE-DSS-AES128-SHA";
+pub const TLS1_TXT_DHE_RSA_WITH_AES_128_SHA = "DHE-RSA-AES128-SHA";
+pub const TLS1_TXT_ADH_WITH_AES_128_SHA = "ADH-AES128-SHA";
+pub const TLS1_TXT_RSA_WITH_AES_256_SHA = "AES256-SHA";
+pub const TLS1_TXT_DH_DSS_WITH_AES_256_SHA = "DH-DSS-AES256-SHA";
+pub const TLS1_TXT_DH_RSA_WITH_AES_256_SHA = "DH-RSA-AES256-SHA";
+pub const TLS1_TXT_DHE_DSS_WITH_AES_256_SHA = "DHE-DSS-AES256-SHA";
+pub const TLS1_TXT_DHE_RSA_WITH_AES_256_SHA = "DHE-RSA-AES256-SHA";
+pub const TLS1_TXT_ADH_WITH_AES_256_SHA = "ADH-AES256-SHA";
+pub const TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA = "ECDH-ECDSA-NULL-SHA";
+pub const TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA = "ECDH-ECDSA-RC4-SHA";
+pub const TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA = "ECDH-ECDSA-DES-CBC3-SHA";
+pub const TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA = "ECDH-ECDSA-AES128-SHA";
+pub const TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA = "ECDH-ECDSA-AES256-SHA";
+pub const TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA = "ECDHE-ECDSA-NULL-SHA";
+pub const TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA = "ECDHE-ECDSA-RC4-SHA";
+pub const TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA = "ECDHE-ECDSA-DES-CBC3-SHA";
+pub const TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA = "ECDHE-ECDSA-AES128-SHA";
+pub const TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA = "ECDHE-ECDSA-AES256-SHA";
+pub const TLS1_TXT_ECDH_RSA_WITH_NULL_SHA = "ECDH-RSA-NULL-SHA";
+pub const TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA = "ECDH-RSA-RC4-SHA";
+pub const TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA = "ECDH-RSA-DES-CBC3-SHA";
+pub const TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA = "ECDH-RSA-AES128-SHA";
+pub const TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA = "ECDH-RSA-AES256-SHA";
+pub const TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA = "ECDHE-RSA-NULL-SHA";
+pub const TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA = "ECDHE-RSA-RC4-SHA";
+pub const TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA = "ECDHE-RSA-DES-CBC3-SHA";
+pub const TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA = "ECDHE-RSA-AES128-SHA";
+pub const TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA = "ECDHE-RSA-AES256-SHA";
+pub const TLS1_TXT_ECDH_anon_WITH_NULL_SHA = "AECDH-NULL-SHA";
+pub const TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA = "AECDH-RC4-SHA";
+pub const TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA = "AECDH-DES-CBC3-SHA";
+pub const TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA = "AECDH-AES128-SHA";
+pub const TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA = "AECDH-AES256-SHA";
+pub const TLS1_TXT_PSK_WITH_RC4_128_SHA = "PSK-RC4-SHA";
+pub const TLS1_TXT_PSK_WITH_3DES_EDE_CBC_SHA = "PSK-3DES-EDE-CBC-SHA";
+pub const TLS1_TXT_PSK_WITH_AES_128_CBC_SHA = "PSK-AES128-CBC-SHA";
+pub const TLS1_TXT_PSK_WITH_AES_256_CBC_SHA = "PSK-AES256-CBC-SHA";
+pub const TLS1_TXT_ECDHE_PSK_WITH_AES_128_CBC_SHA = "ECDHE-PSK-AES128-CBC-SHA";
+pub const TLS1_TXT_ECDHE_PSK_WITH_AES_256_CBC_SHA = "ECDHE-PSK-AES256-CBC-SHA";
+pub const TLS1_TXT_SRP_SHA_WITH_3DES_EDE_CBC_SHA = "SRP-3DES-EDE-CBC-SHA";
+pub const TLS1_TXT_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA = "SRP-RSA-3DES-EDE-CBC-SHA";
+pub const TLS1_TXT_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA = "SRP-DSS-3DES-EDE-CBC-SHA";
+pub const TLS1_TXT_SRP_SHA_WITH_AES_128_CBC_SHA = "SRP-AES-128-CBC-SHA";
+pub const TLS1_TXT_SRP_SHA_RSA_WITH_AES_128_CBC_SHA = "SRP-RSA-AES-128-CBC-SHA";
+pub const TLS1_TXT_SRP_SHA_DSS_WITH_AES_128_CBC_SHA = "SRP-DSS-AES-128-CBC-SHA";
+pub const TLS1_TXT_SRP_SHA_WITH_AES_256_CBC_SHA = "SRP-AES-256-CBC-SHA";
+pub const TLS1_TXT_SRP_SHA_RSA_WITH_AES_256_CBC_SHA = "SRP-RSA-AES-256-CBC-SHA";
+pub const TLS1_TXT_SRP_SHA_DSS_WITH_AES_256_CBC_SHA = "SRP-DSS-AES-256-CBC-SHA";
+pub const TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA = "CAMELLIA128-SHA";
+pub const TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA = "DH-DSS-CAMELLIA128-SHA";
+pub const TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA = "DH-RSA-CAMELLIA128-SHA";
+pub const TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA = "DHE-DSS-CAMELLIA128-SHA";
+pub const TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA = "DHE-RSA-CAMELLIA128-SHA";
+pub const TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA = "ADH-CAMELLIA128-SHA";
+pub const TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA = "CAMELLIA256-SHA";
+pub const TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA = "DH-DSS-CAMELLIA256-SHA";
+pub const TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA = "DH-RSA-CAMELLIA256-SHA";
+pub const TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA = "DHE-DSS-CAMELLIA256-SHA";
+pub const TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA = "DHE-RSA-CAMELLIA256-SHA";
+pub const TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA = "ADH-CAMELLIA256-SHA";
+pub const TLS1_TXT_RSA_WITH_SEED_SHA = "SEED-SHA";
+pub const TLS1_TXT_DH_DSS_WITH_SEED_SHA = "DH-DSS-SEED-SHA";
+pub const TLS1_TXT_DH_RSA_WITH_SEED_SHA = "DH-RSA-SEED-SHA";
+pub const TLS1_TXT_DHE_DSS_WITH_SEED_SHA = "DHE-DSS-SEED-SHA";
+pub const TLS1_TXT_DHE_RSA_WITH_SEED_SHA = "DHE-RSA-SEED-SHA";
+pub const TLS1_TXT_ADH_WITH_SEED_SHA = "ADH-SEED-SHA";
+pub const TLS1_TXT_RSA_WITH_NULL_SHA256 = "NULL-SHA256";
+pub const TLS1_TXT_RSA_WITH_AES_128_SHA256 = "AES128-SHA256";
+pub const TLS1_TXT_RSA_WITH_AES_256_SHA256 = "AES256-SHA256";
+pub const TLS1_TXT_DH_DSS_WITH_AES_128_SHA256 = "DH-DSS-AES128-SHA256";
+pub const TLS1_TXT_DH_RSA_WITH_AES_128_SHA256 = "DH-RSA-AES128-SHA256";
+pub const TLS1_TXT_DHE_DSS_WITH_AES_128_SHA256 = "DHE-DSS-AES128-SHA256";
+pub const TLS1_TXT_DHE_RSA_WITH_AES_128_SHA256 = "DHE-RSA-AES128-SHA256";
+pub const TLS1_TXT_DH_DSS_WITH_AES_256_SHA256 = "DH-DSS-AES256-SHA256";
+pub const TLS1_TXT_DH_RSA_WITH_AES_256_SHA256 = "DH-RSA-AES256-SHA256";
+pub const TLS1_TXT_DHE_DSS_WITH_AES_256_SHA256 = "DHE-DSS-AES256-SHA256";
+pub const TLS1_TXT_DHE_RSA_WITH_AES_256_SHA256 = "DHE-RSA-AES256-SHA256";
+pub const TLS1_TXT_ADH_WITH_AES_128_SHA256 = "ADH-AES128-SHA256";
+pub const TLS1_TXT_ADH_WITH_AES_256_SHA256 = "ADH-AES256-SHA256";
+pub const TLS1_TXT_RSA_WITH_AES_128_GCM_SHA256 = "AES128-GCM-SHA256";
+pub const TLS1_TXT_RSA_WITH_AES_256_GCM_SHA384 = "AES256-GCM-SHA384";
+pub const TLS1_TXT_DHE_RSA_WITH_AES_128_GCM_SHA256 = "DHE-RSA-AES128-GCM-SHA256";
+pub const TLS1_TXT_DHE_RSA_WITH_AES_256_GCM_SHA384 = "DHE-RSA-AES256-GCM-SHA384";
+pub const TLS1_TXT_DH_RSA_WITH_AES_128_GCM_SHA256 = "DH-RSA-AES128-GCM-SHA256";
+pub const TLS1_TXT_DH_RSA_WITH_AES_256_GCM_SHA384 = "DH-RSA-AES256-GCM-SHA384";
+pub const TLS1_TXT_DHE_DSS_WITH_AES_128_GCM_SHA256 = "DHE-DSS-AES128-GCM-SHA256";
+pub const TLS1_TXT_DHE_DSS_WITH_AES_256_GCM_SHA384 = "DHE-DSS-AES256-GCM-SHA384";
+pub const TLS1_TXT_DH_DSS_WITH_AES_128_GCM_SHA256 = "DH-DSS-AES128-GCM-SHA256";
+pub const TLS1_TXT_DH_DSS_WITH_AES_256_GCM_SHA384 = "DH-DSS-AES256-GCM-SHA384";
+pub const TLS1_TXT_ADH_WITH_AES_128_GCM_SHA256 = "ADH-AES128-GCM-SHA256";
+pub const TLS1_TXT_ADH_WITH_AES_256_GCM_SHA384 = "ADH-AES256-GCM-SHA384";
+pub const TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_SHA256 = "ECDHE-ECDSA-AES128-SHA256";
+pub const TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_SHA384 = "ECDHE-ECDSA-AES256-SHA384";
+pub const TLS1_TXT_ECDH_ECDSA_WITH_AES_128_SHA256 = "ECDH-ECDSA-AES128-SHA256";
+pub const TLS1_TXT_ECDH_ECDSA_WITH_AES_256_SHA384 = "ECDH-ECDSA-AES256-SHA384";
+pub const TLS1_TXT_ECDHE_RSA_WITH_AES_128_SHA256 = "ECDHE-RSA-AES128-SHA256";
+pub const TLS1_TXT_ECDHE_RSA_WITH_AES_256_SHA384 = "ECDHE-RSA-AES256-SHA384";
+pub const TLS1_TXT_ECDH_RSA_WITH_AES_128_SHA256 = "ECDH-RSA-AES128-SHA256";
+pub const TLS1_TXT_ECDH_RSA_WITH_AES_256_SHA384 = "ECDH-RSA-AES256-SHA384";
+pub const TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 = "ECDHE-ECDSA-AES128-GCM-SHA256";
+pub const TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 = "ECDHE-ECDSA-AES256-GCM-SHA384";
+pub const TLS1_TXT_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 = "ECDH-ECDSA-AES128-GCM-SHA256";
+pub const TLS1_TXT_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 = "ECDH-ECDSA-AES256-GCM-SHA384";
+pub const TLS1_TXT_ECDHE_RSA_WITH_AES_128_GCM_SHA256 = "ECDHE-RSA-AES128-GCM-SHA256";
+pub const TLS1_TXT_ECDHE_RSA_WITH_AES_256_GCM_SHA384 = "ECDHE-RSA-AES256-GCM-SHA384";
+pub const TLS1_TXT_ECDH_RSA_WITH_AES_128_GCM_SHA256 = "ECDH-RSA-AES128-GCM-SHA256";
+pub const TLS1_TXT_ECDH_RSA_WITH_AES_256_GCM_SHA384 = "ECDH-RSA-AES256-GCM-SHA384";
+pub const TLS1_TXT_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 = "ECDHE-RSA-CHACHA20-POLY1305";
+pub const TLS1_TXT_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 = "ECDHE-ECDSA-CHACHA20-POLY1305";
+pub const TLS1_TXT_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256 = "ECDHE-PSK-CHACHA20-POLY1305";
+pub const TLS1_TXT_AES_128_GCM_SHA256 = "TLS_AES_128_GCM_SHA256";
+pub const TLS1_TXT_AES_256_GCM_SHA384 = "TLS_AES_256_GCM_SHA384";
+pub const TLS1_TXT_CHACHA20_POLY1305_SHA256 = "TLS_CHACHA20_POLY1305_SHA256";
+pub const TLS_CT_RSA_SIGN = @as(c_int, 1);
+pub const TLS_CT_DSS_SIGN = @as(c_int, 2);
+pub const TLS_CT_RSA_FIXED_DH = @as(c_int, 3);
+pub const TLS_CT_DSS_FIXED_DH = @as(c_int, 4);
+pub const TLS_CT_ECDSA_SIGN = @as(c_int, 64);
+pub const TLS_CT_RSA_FIXED_ECDH = @as(c_int, 65);
+pub const TLS_CT_ECDSA_FIXED_ECDH = @as(c_int, 66);
+pub const TLS_MD_MAX_CONST_SIZE = @as(c_int, 20);
+pub const ITIMER_REAL = @as(c_int, 0);
+pub const ITIMER_VIRTUAL = @as(c_int, 1);
+pub const ITIMER_PROF = @as(c_int, 2);
+pub const DST_NONE = @as(c_int, 0);
+pub const DST_USA = @as(c_int, 1);
+pub const DST_AUST = @as(c_int, 2);
+pub const DST_WET = @as(c_int, 3);
+pub const DST_MET = @as(c_int, 4);
+pub const DST_EET = @as(c_int, 5);
+pub const DST_CAN = @as(c_int, 6);
+pub inline fn timerisset(tvp: anytype) @TypeOf((tvp.*.tv_sec != 0) or (tvp.*.tv_usec != 0)) {
+ return (tvp.*.tv_sec != 0) or (tvp.*.tv_usec != 0);
+}
+pub inline fn timevalcmp(l: anytype, r: anytype, cmp: anytype) @TypeOf(timercmp(l, r, cmp)) {
+ return timercmp(l, r, cmp);
+}
+pub const SSL_KEY_UPDATE_REQUESTED = @as(c_int, 1);
+pub const SSL_KEY_UPDATE_NOT_REQUESTED = @as(c_int, 0);
+pub const SSL_ERROR_NONE = @as(c_int, 0);
+pub const SSL_ERROR_SSL = @as(c_int, 1);
+pub const SSL_ERROR_WANT_READ = @as(c_int, 2);
+pub const SSL_ERROR_WANT_WRITE = @as(c_int, 3);
+pub const SSL_ERROR_WANT_X509_LOOKUP = @as(c_int, 4);
+pub const SSL_ERROR_SYSCALL = @as(c_int, 5);
+pub const SSL_ERROR_ZERO_RETURN = @as(c_int, 6);
+pub const SSL_ERROR_WANT_CONNECT = @as(c_int, 7);
+pub const SSL_ERROR_WANT_ACCEPT = @as(c_int, 8);
+pub const SSL_ERROR_WANT_CHANNEL_ID_LOOKUP = @as(c_int, 9);
+pub const SSL_ERROR_PENDING_SESSION = @as(c_int, 11);
+pub const SSL_ERROR_PENDING_CERTIFICATE = @as(c_int, 12);
+pub const SSL_ERROR_WANT_PRIVATE_KEY_OPERATION = @as(c_int, 13);
+pub const SSL_ERROR_PENDING_TICKET = @as(c_int, 14);
+pub const SSL_ERROR_EARLY_DATA_REJECTED = @as(c_int, 15);
+pub const SSL_ERROR_WANT_CERTIFICATE_VERIFY = @as(c_int, 16);
+pub const SSL_ERROR_HANDOFF = @as(c_int, 17);
+pub const SSL_ERROR_HANDBACK = @as(c_int, 18);
+pub const SSL_ERROR_WANT_RENEGOTIATE = @as(c_int, 19);
+pub const SSL_ERROR_HANDSHAKE_HINTS_READY = @as(c_int, 20);
+pub const DTLS1_VERSION_MAJOR = @as(c_int, 0xfe);
+pub const SSL3_VERSION_MAJOR = @as(c_int, 0x03);
+pub const SSL3_VERSION = @as(c_int, 0x0300);
+pub const TLS1_VERSION = @as(c_int, 0x0301);
+pub const TLS1_1_VERSION = @as(c_int, 0x0302);
+pub const TLS1_2_VERSION = @as(c_int, 0x0303);
+pub const TLS1_3_VERSION = @as(c_int, 0x0304);
+pub const DTLS1_VERSION = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0xfeff, .hexadecimal);
+pub const DTLS1_2_VERSION = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0xfefd, .hexadecimal);
+pub const SSL_OP_NO_QUERY_MTU = @as(c_long, 0x00001000);
+pub const SSL_OP_NO_TICKET = @as(c_long, 0x00004000);
+pub const SSL_OP_CIPHER_SERVER_PREFERENCE = @as(c_long, 0x00400000);
+pub const SSL_OP_NO_TLSv1 = @as(c_long, 0x04000000);
+pub const SSL_OP_NO_TLSv1_2 = @as(c_long, 0x08000000);
+pub const SSL_OP_NO_TLSv1_1 = @as(c_long, 0x10000000);
+pub const SSL_OP_NO_TLSv1_3 = @as(c_long, 0x20000000);
+pub const SSL_OP_NO_DTLSv1 = SSL_OP_NO_TLSv1;
+pub const SSL_OP_NO_DTLSv1_2 = SSL_OP_NO_TLSv1_2;
+pub const SSL_MODE_ENABLE_PARTIAL_WRITE = @as(c_long, 0x00000001);
+pub const SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER = @as(c_long, 0x00000002);
+pub const SSL_MODE_NO_AUTO_CHAIN = @as(c_long, 0x00000008);
+pub const SSL_MODE_ENABLE_FALSE_START = @as(c_long, 0x00000080);
+pub const SSL_MODE_CBC_RECORD_SPLITTING = @as(c_long, 0x00000100);
+pub const SSL_MODE_NO_SESSION_CREATION = @as(c_long, 0x00000200);
+pub const SSL_MODE_SEND_FALLBACK_SCSV = @as(c_long, 0x00000400);
+pub const SSL_SIGN_RSA_PKCS1_SHA1 = @as(c_int, 0x0201);
+pub const SSL_SIGN_RSA_PKCS1_SHA256 = @as(c_int, 0x0401);
+pub const SSL_SIGN_RSA_PKCS1_SHA384 = @as(c_int, 0x0501);
+pub const SSL_SIGN_RSA_PKCS1_SHA512 = @as(c_int, 0x0601);
+pub const SSL_SIGN_ECDSA_SHA1 = @as(c_int, 0x0203);
+pub const SSL_SIGN_ECDSA_SECP256R1_SHA256 = @as(c_int, 0x0403);
+pub const SSL_SIGN_ECDSA_SECP384R1_SHA384 = @as(c_int, 0x0503);
+pub const SSL_SIGN_ECDSA_SECP521R1_SHA512 = @as(c_int, 0x0603);
+pub const SSL_SIGN_RSA_PSS_RSAE_SHA256 = @as(c_int, 0x0804);
+pub const SSL_SIGN_RSA_PSS_RSAE_SHA384 = @as(c_int, 0x0805);
+pub const SSL_SIGN_RSA_PSS_RSAE_SHA512 = @as(c_int, 0x0806);
+pub const SSL_SIGN_ED25519 = @as(c_int, 0x0807);
+pub const SSL_SIGN_RSA_PKCS1_MD5_SHA1 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0xff01, .hexadecimal);
+pub const SSL_FILETYPE_PEM = @as(c_int, 1);
+pub const SSL_FILETYPE_ASN1 = @as(c_int, 2);
+pub const SSL_DEFAULT_CIPHER_LIST = "ALL";
+pub const SSL_MAX_SSL_SESSION_ID_LENGTH = @as(c_int, 32);
+pub const SSL_MAX_MASTER_KEY_LENGTH = @as(c_int, 48);
+pub const SSL_SESS_CACHE_OFF = @as(c_int, 0x0000);
+pub const SSL_SESS_CACHE_CLIENT = @as(c_int, 0x0001);
+pub const SSL_SESS_CACHE_SERVER = @as(c_int, 0x0002);
+pub const SSL_SESS_CACHE_BOTH = SSL_SESS_CACHE_CLIENT | SSL_SESS_CACHE_SERVER;
+pub const SSL_SESS_CACHE_NO_AUTO_CLEAR = @as(c_int, 0x0080);
+pub const SSL_SESS_CACHE_NO_INTERNAL_LOOKUP = @as(c_int, 0x0100);
+pub const SSL_SESS_CACHE_NO_INTERNAL_STORE = @as(c_int, 0x0200);
+pub const SSL_SESS_CACHE_NO_INTERNAL = SSL_SESS_CACHE_NO_INTERNAL_LOOKUP | SSL_SESS_CACHE_NO_INTERNAL_STORE;
+pub const SSL_DEFAULT_SESSION_TIMEOUT = (@as(c_int, 2) * @as(c_int, 60)) * @as(c_int, 60);
+pub const SSL_DEFAULT_SESSION_PSK_DHE_TIMEOUT = ((@as(c_int, 2) * @as(c_int, 24)) * @as(c_int, 60)) * @as(c_int, 60);
+pub const SSL_DEFAULT_SESSION_AUTH_TIMEOUT = ((@as(c_int, 7) * @as(c_int, 24)) * @as(c_int, 60)) * @as(c_int, 60);
+pub const SSL_MAX_SID_CTX_LENGTH = @as(c_int, 32);
+pub const SSL_SESSION_CACHE_MAX_SIZE_DEFAULT = @as(c_int, 1024) * @as(c_int, 20);
+pub const SSL_DEFAULT_TICKET_KEY_ROTATION_INTERVAL = ((@as(c_int, 2) * @as(c_int, 24)) * @as(c_int, 60)) * @as(c_int, 60);
+pub const SSL_TICKET_KEY_NAME_LEN = @as(c_int, 16);
+pub const SSL_CURVE_SECP224R1 = @as(c_int, 21);
+pub const SSL_CURVE_SECP256R1 = @as(c_int, 23);
+pub const SSL_CURVE_SECP384R1 = @as(c_int, 24);
+pub const SSL_CURVE_SECP521R1 = @as(c_int, 25);
+pub const SSL_CURVE_X25519 = @as(c_int, 29);
+pub const SSL_CURVE_CECPQ2 = @as(c_int, 16696);
+pub const SSL_VERIFY_NONE = @as(c_int, 0x00);
+pub const SSL_VERIFY_PEER = @as(c_int, 0x01);
+pub const SSL_VERIFY_FAIL_IF_NO_PEER_CERT = @as(c_int, 0x02);
+pub const SSL_VERIFY_PEER_IF_NO_OBC = @as(c_int, 0x04);
+pub const TLSEXT_NAMETYPE_host_name = @as(c_int, 0);
+pub const SSL_TLSEXT_ERR_OK = @as(c_int, 0);
+pub const SSL_TLSEXT_ERR_ALERT_WARNING = @as(c_int, 1);
+pub const SSL_TLSEXT_ERR_ALERT_FATAL = @as(c_int, 2);
+pub const SSL_TLSEXT_ERR_NOACK = @as(c_int, 3);
+pub const OPENSSL_NPN_UNSUPPORTED = @as(c_int, 0);
+pub const OPENSSL_NPN_NEGOTIATED = @as(c_int, 1);
+pub const OPENSSL_NPN_NO_OVERLAP = @as(c_int, 2);
+pub const SRTP_AES128_CM_SHA1_80 = @as(c_int, 0x0001);
+pub const SRTP_AES128_CM_SHA1_32 = @as(c_int, 0x0002);
+pub const SRTP_AES128_F8_SHA1_80 = @as(c_int, 0x0003);
+pub const SRTP_AES128_F8_SHA1_32 = @as(c_int, 0x0004);
+pub const SRTP_NULL_SHA1_80 = @as(c_int, 0x0005);
+pub const SRTP_NULL_SHA1_32 = @as(c_int, 0x0006);
+pub const SRTP_AEAD_AES_128_GCM = @as(c_int, 0x0007);
+pub const SRTP_AEAD_AES_256_GCM = @as(c_int, 0x0008);
+pub const PSK_MAX_IDENTITY_LEN = @as(c_int, 128);
+pub const PSK_MAX_PSK_LEN = @as(c_int, 256);
+pub const SSL_AD_REASON_OFFSET = @as(c_int, 1000);
+pub const SSL_AD_CLOSE_NOTIFY = SSL3_AD_CLOSE_NOTIFY;
+pub const SSL_AD_UNEXPECTED_MESSAGE = SSL3_AD_UNEXPECTED_MESSAGE;
+pub const SSL_AD_BAD_RECORD_MAC = SSL3_AD_BAD_RECORD_MAC;
+pub const SSL_AD_DECRYPTION_FAILED = TLS1_AD_DECRYPTION_FAILED;
+pub const SSL_AD_RECORD_OVERFLOW = TLS1_AD_RECORD_OVERFLOW;
+pub const SSL_AD_DECOMPRESSION_FAILURE = SSL3_AD_DECOMPRESSION_FAILURE;
+pub const SSL_AD_HANDSHAKE_FAILURE = SSL3_AD_HANDSHAKE_FAILURE;
+pub const SSL_AD_NO_CERTIFICATE = SSL3_AD_NO_CERTIFICATE;
+pub const SSL_AD_BAD_CERTIFICATE = SSL3_AD_BAD_CERTIFICATE;
+pub const SSL_AD_UNSUPPORTED_CERTIFICATE = SSL3_AD_UNSUPPORTED_CERTIFICATE;
+pub const SSL_AD_CERTIFICATE_REVOKED = SSL3_AD_CERTIFICATE_REVOKED;
+pub const SSL_AD_CERTIFICATE_EXPIRED = SSL3_AD_CERTIFICATE_EXPIRED;
+pub const SSL_AD_CERTIFICATE_UNKNOWN = SSL3_AD_CERTIFICATE_UNKNOWN;
+pub const SSL_AD_ILLEGAL_PARAMETER = SSL3_AD_ILLEGAL_PARAMETER;
+pub const SSL_AD_UNKNOWN_CA = TLS1_AD_UNKNOWN_CA;
+pub const SSL_AD_ACCESS_DENIED = TLS1_AD_ACCESS_DENIED;
+pub const SSL_AD_DECODE_ERROR = TLS1_AD_DECODE_ERROR;
+pub const SSL_AD_DECRYPT_ERROR = TLS1_AD_DECRYPT_ERROR;
+pub const SSL_AD_EXPORT_RESTRICTION = TLS1_AD_EXPORT_RESTRICTION;
+pub const SSL_AD_PROTOCOL_VERSION = TLS1_AD_PROTOCOL_VERSION;
+pub const SSL_AD_INSUFFICIENT_SECURITY = TLS1_AD_INSUFFICIENT_SECURITY;
+pub const SSL_AD_INTERNAL_ERROR = TLS1_AD_INTERNAL_ERROR;
+pub const SSL_AD_INAPPROPRIATE_FALLBACK = SSL3_AD_INAPPROPRIATE_FALLBACK;
+pub const SSL_AD_USER_CANCELLED = TLS1_AD_USER_CANCELLED;
+pub const SSL_AD_NO_RENEGOTIATION = TLS1_AD_NO_RENEGOTIATION;
+pub const SSL_AD_MISSING_EXTENSION = TLS1_AD_MISSING_EXTENSION;
+pub const SSL_AD_UNSUPPORTED_EXTENSION = TLS1_AD_UNSUPPORTED_EXTENSION;
+pub const SSL_AD_CERTIFICATE_UNOBTAINABLE = TLS1_AD_CERTIFICATE_UNOBTAINABLE;
+pub const SSL_AD_UNRECOGNIZED_NAME = TLS1_AD_UNRECOGNIZED_NAME;
+pub const SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE = TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE;
+pub const SSL_AD_BAD_CERTIFICATE_HASH_VALUE = TLS1_AD_BAD_CERTIFICATE_HASH_VALUE;
+pub const SSL_AD_UNKNOWN_PSK_IDENTITY = TLS1_AD_UNKNOWN_PSK_IDENTITY;
+pub const SSL_AD_CERTIFICATE_REQUIRED = TLS1_AD_CERTIFICATE_REQUIRED;
+pub const SSL_AD_NO_APPLICATION_PROTOCOL = TLS1_AD_NO_APPLICATION_PROTOCOL;
+pub const SSL_AD_ECH_REQUIRED = TLS1_AD_ECH_REQUIRED;
+pub const SSL_MAX_CERT_LIST_DEFAULT = @as(c_int, 1024) * @as(c_int, 100);
+pub const SSL_ST_CONNECT = @as(c_int, 0x1000);
+pub const SSL_ST_ACCEPT = @as(c_int, 0x2000);
+pub const SSL_ST_MASK = @as(c_int, 0x0FFF);
+pub const SSL_ST_INIT = SSL_ST_CONNECT | SSL_ST_ACCEPT;
+pub const SSL_ST_OK = @as(c_int, 0x03);
+pub const SSL_ST_RENEGOTIATE = @as(c_int, 0x04) | SSL_ST_INIT;
+pub const SSL_ST_BEFORE = @as(c_int, 0x05) | SSL_ST_INIT;
+pub const TLS_ST_OK = SSL_ST_OK;
+pub const TLS_ST_BEFORE = SSL_ST_BEFORE;
+pub const SSL_CB_LOOP = @as(c_int, 0x01);
+pub const SSL_CB_EXIT = @as(c_int, 0x02);
+pub const SSL_CB_READ = @as(c_int, 0x04);
+pub const SSL_CB_WRITE = @as(c_int, 0x08);
+pub const SSL_CB_ALERT = @as(c_int, 0x4000);
+pub const SSL_CB_READ_ALERT = SSL_CB_ALERT | SSL_CB_READ;
+pub const SSL_CB_WRITE_ALERT = SSL_CB_ALERT | SSL_CB_WRITE;
+pub const SSL_CB_ACCEPT_LOOP = SSL_ST_ACCEPT | SSL_CB_LOOP;
+pub const SSL_CB_ACCEPT_EXIT = SSL_ST_ACCEPT | SSL_CB_EXIT;
+pub const SSL_CB_CONNECT_LOOP = SSL_ST_CONNECT | SSL_CB_LOOP;
+pub const SSL_CB_CONNECT_EXIT = SSL_ST_CONNECT | SSL_CB_EXIT;
+pub const SSL_CB_HANDSHAKE_START = @as(c_int, 0x10);
+pub const SSL_CB_HANDSHAKE_DONE = @as(c_int, 0x20);
+pub const SSL_SENT_SHUTDOWN = @as(c_int, 1);
+pub const SSL_RECEIVED_SHUTDOWN = @as(c_int, 2);
+pub const SSL_MODE_HANDSHAKE_CUTTHROUGH = SSL_MODE_ENABLE_FALSE_START;
+pub inline fn SSL_set_app_data(s: anytype, arg: anytype) @TypeOf(SSL_set_ex_data(s, @as(c_int, 0), @import("std").zig.c_translation.cast([*c]u8, arg))) {
+ return SSL_set_ex_data(s, @as(c_int, 0), @import("std").zig.c_translation.cast([*c]u8, arg));
+}
+pub inline fn SSL_get_app_data(s: anytype) @TypeOf(SSL_get_ex_data(s, @as(c_int, 0))) {
+ return SSL_get_ex_data(s, @as(c_int, 0));
+}
+pub inline fn SSL_SESSION_set_app_data(s: anytype, a: anytype) @TypeOf(SSL_SESSION_set_ex_data(s, @as(c_int, 0), @import("std").zig.c_translation.cast([*c]u8, a))) {
+ return SSL_SESSION_set_ex_data(s, @as(c_int, 0), @import("std").zig.c_translation.cast([*c]u8, a));
+}
+pub inline fn SSL_SESSION_get_app_data(s: anytype) @TypeOf(SSL_SESSION_get_ex_data(s, @as(c_int, 0))) {
+ return SSL_SESSION_get_ex_data(s, @as(c_int, 0));
+}
+pub inline fn SSL_CTX_get_app_data(ctx: anytype) @TypeOf(SSL_CTX_get_ex_data(ctx, @as(c_int, 0))) {
+ return SSL_CTX_get_ex_data(ctx, @as(c_int, 0));
+}
+pub inline fn SSL_CTX_set_app_data(ctx: anytype, arg: anytype) @TypeOf(SSL_CTX_set_ex_data(ctx, @as(c_int, 0), @import("std").zig.c_translation.cast([*c]u8, arg))) {
+ return SSL_CTX_set_ex_data(ctx, @as(c_int, 0), @import("std").zig.c_translation.cast([*c]u8, arg));
+}
+pub inline fn OpenSSL_add_ssl_algorithms() @TypeOf(SSL_library_init()) {
+ return SSL_library_init();
+}
+pub inline fn SSLeay_add_ssl_algorithms() @TypeOf(SSL_library_init()) {
+ return SSL_library_init();
+}
+pub inline fn SSL_get_cipher(ssl: anytype) @TypeOf(SSL_CIPHER_get_name(SSL_get_current_cipher(ssl))) {
+ return SSL_CIPHER_get_name(SSL_get_current_cipher(ssl));
+}
+pub inline fn SSL_get_cipher_bits(ssl: anytype, out_alg_bits: anytype) @TypeOf(SSL_CIPHER_get_bits(SSL_get_current_cipher(ssl), out_alg_bits)) {
+ return SSL_CIPHER_get_bits(SSL_get_current_cipher(ssl), out_alg_bits);
+}
+pub inline fn SSL_get_cipher_version(ssl: anytype) @TypeOf(SSL_CIPHER_get_version(SSL_get_current_cipher(ssl))) {
+ return SSL_CIPHER_get_version(SSL_get_current_cipher(ssl));
+}
+pub inline fn SSL_get_cipher_name(ssl: anytype) @TypeOf(SSL_CIPHER_get_name(SSL_get_current_cipher(ssl))) {
+ return SSL_CIPHER_get_name(SSL_get_current_cipher(ssl));
+}
+pub inline fn SSL_get_time(session: anytype) @TypeOf(SSL_SESSION_get_time(session)) {
+ return SSL_SESSION_get_time(session);
+}
+pub inline fn SSL_set_time(session: anytype, time_1: anytype) @TypeOf(SSL_SESSION_set_time(session, time_1)) {
+ return SSL_SESSION_set_time(session, time_1);
+}
+pub inline fn SSL_get_timeout(session: anytype) @TypeOf(SSL_SESSION_get_timeout(session)) {
+ return SSL_SESSION_get_timeout(session);
+}
+pub inline fn SSL_set_timeout(session: anytype, timeout: anytype) @TypeOf(SSL_SESSION_set_timeout(session, timeout)) {
+ return SSL_SESSION_set_timeout(session, timeout);
+}
+pub const SSL_MODE_AUTO_RETRY = @as(c_int, 0);
+pub const SSL_MODE_RELEASE_BUFFERS = @as(c_int, 0);
+pub const SSL_MODE_SEND_CLIENTHELLO_TIME = @as(c_int, 0);
+pub const SSL_MODE_SEND_SERVERHELLO_TIME = @as(c_int, 0);
+pub const SSL_OP_ALL = @as(c_int, 0);
+pub const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION = @as(c_int, 0);
+pub const SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS = @as(c_int, 0);
+pub const SSL_OP_EPHEMERAL_RSA = @as(c_int, 0);
+pub const SSL_OP_LEGACY_SERVER_CONNECT = @as(c_int, 0);
+pub const SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER = @as(c_int, 0);
+pub const SSL_OP_MICROSOFT_SESS_ID_BUG = @as(c_int, 0);
+pub const SSL_OP_MSIE_SSLV2_RSA_PADDING = @as(c_int, 0);
+pub const SSL_OP_NETSCAPE_CA_DN_BUG = @as(c_int, 0);
+pub const SSL_OP_NETSCAPE_CHALLENGE_BUG = @as(c_int, 0);
+pub const SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG = @as(c_int, 0);
+pub const SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG = @as(c_int, 0);
+pub const SSL_OP_NO_COMPRESSION = @as(c_int, 0);
+pub const SSL_OP_NO_RENEGOTIATION = @as(c_int, 0);
+pub const SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION = @as(c_int, 0);
+pub const SSL_OP_NO_SSLv2 = @as(c_int, 0);
+pub const SSL_OP_NO_SSLv3 = @as(c_int, 0);
+pub const SSL_OP_PKCS1_CHECK_1 = @as(c_int, 0);
+pub const SSL_OP_PKCS1_CHECK_2 = @as(c_int, 0);
+pub const SSL_OP_SINGLE_DH_USE = @as(c_int, 0);
+pub const SSL_OP_SINGLE_ECDH_USE = @as(c_int, 0);
+pub const SSL_OP_SSLEAY_080_CLIENT_DH_BUG = @as(c_int, 0);
+pub const SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG = @as(c_int, 0);
+pub const SSL_OP_TLS_BLOCK_PADDING_BUG = @as(c_int, 0);
+pub const SSL_OP_TLS_D5_BUG = @as(c_int, 0);
+pub const SSL_OP_TLS_ROLLBACK_BUG = @as(c_int, 0);
+pub const SSL_VERIFY_CLIENT_ONCE = @as(c_int, 0);
+pub const SSL_NOTHING = SSL_ERROR_NONE;
+pub const SSL_WRITING = SSL_ERROR_WANT_WRITE;
+pub const SSL_READING = SSL_ERROR_WANT_READ;
+pub inline fn SSL_want_read(ssl: anytype) @TypeOf(SSL_want(ssl) == SSL_READING) {
+ return SSL_want(ssl) == SSL_READING;
+}
+pub inline fn SSL_want_write(ssl: anytype) @TypeOf(SSL_want(ssl) == SSL_WRITING) {
+ return SSL_want(ssl) == SSL_WRITING;
+}
+pub const SSL_TXT_MEDIUM = "MEDIUM";
+pub const SSL_TXT_HIGH = "HIGH";
+pub const SSL_TXT_FIPS = "FIPS";
+pub const SSL_TXT_kRSA = "kRSA";
+pub const SSL_TXT_kDHE = "kDHE";
+pub const SSL_TXT_kEDH = "kEDH";
+pub const SSL_TXT_kECDHE = "kECDHE";
+pub const SSL_TXT_kEECDH = "kEECDH";
+pub const SSL_TXT_kPSK = "kPSK";
+pub const SSL_TXT_aRSA = "aRSA";
+pub const SSL_TXT_aECDSA = "aECDSA";
+pub const SSL_TXT_aPSK = "aPSK";
+pub const SSL_TXT_DH = "DH";
+pub const SSL_TXT_DHE = "DHE";
+pub const SSL_TXT_EDH = "EDH";
+pub const SSL_TXT_RSA = "RSA";
+pub const SSL_TXT_ECDH = "ECDH";
+pub const SSL_TXT_ECDHE = "ECDHE";
+pub const SSL_TXT_EECDH = "EECDH";
+pub const SSL_TXT_ECDSA = "ECDSA";
+pub const SSL_TXT_PSK = "PSK";
+pub const SSL_TXT_3DES = "3DES";
+pub const SSL_TXT_RC4 = "RC4";
+pub const SSL_TXT_AES128 = "AES128";
+pub const SSL_TXT_AES256 = "AES256";
+pub const SSL_TXT_AES = "AES";
+pub const SSL_TXT_AES_GCM = "AESGCM";
+pub const SSL_TXT_CHACHA20 = "CHACHA20";
+pub const SSL_TXT_MD5 = "MD5";
+pub const SSL_TXT_SHA1 = "SHA1";
+pub const SSL_TXT_SHA = "SHA";
+pub const SSL_TXT_SHA256 = "SHA256";
+pub const SSL_TXT_SHA384 = "SHA384";
+pub const SSL_TXT_SSLV3 = "SSLv3";
+pub const SSL_TXT_TLSV1 = "TLSv1";
+pub const SSL_TXT_TLSV1_1 = "TLSv1.1";
+pub const SSL_TXT_TLSV1_2 = "TLSv1.2";
+pub const SSL_TXT_TLSV1_3 = "TLSv1.3";
+pub const SSL_TXT_ALL = "ALL";
+pub const SSL_TXT_CMPDEF = "COMPLEMENTOFDEFAULT";
+pub inline fn SSL_get_state(ssl: anytype) @TypeOf(SSL_state(ssl)) {
+ return SSL_state(ssl);
+}
+pub inline fn SSL_CTX_set_ecdh_auto(ctx: anytype, onoff: anytype) @TypeOf(@as(c_int, 1)) {
+ _ = ctx;
+ _ = onoff;
+ return @as(c_int, 1);
+}
+pub inline fn SSL_set_ecdh_auto(ssl: anytype, onoff: anytype) @TypeOf(@as(c_int, 1)) {
+ _ = ssl;
+ _ = onoff;
+ return @as(c_int, 1);
+}
+pub const SSL_get0_session = SSL_get_session;
+pub const OPENSSL_INIT_NO_LOAD_SSL_STRINGS = @as(c_int, 0);
+pub const OPENSSL_INIT_LOAD_SSL_STRINGS = @as(c_int, 0);
+pub const OPENSSL_INIT_SSL_DEFAULT = @as(c_int, 0);
+pub const SSL_SIGN_RSA_PSS_SHA256 = SSL_SIGN_RSA_PSS_RSAE_SHA256;
+pub const SSL_SIGN_RSA_PSS_SHA384 = SSL_SIGN_RSA_PSS_RSAE_SHA384;
+pub const SSL_SIGN_RSA_PSS_SHA512 = SSL_SIGN_RSA_PSS_RSAE_SHA512;
+pub const SSL_R_TLSV1_UNSUPPORTED_EXTENSION = SSL_R_TLSV1_ALERT_UNSUPPORTED_EXTENSION;
+pub const SSL_R_TLSV1_CERTIFICATE_UNOBTAINABLE = SSL_R_TLSV1_ALERT_CERTIFICATE_UNOBTAINABLE;
+pub const SSL_R_TLSV1_UNRECOGNIZED_NAME = SSL_R_TLSV1_ALERT_UNRECOGNIZED_NAME;
+pub const SSL_R_TLSV1_BAD_CERTIFICATE_STATUS_RESPONSE = SSL_R_TLSV1_ALERT_BAD_CERTIFICATE_STATUS_RESPONSE;
+pub const SSL_R_TLSV1_BAD_CERTIFICATE_HASH_VALUE = SSL_R_TLSV1_ALERT_BAD_CERTIFICATE_HASH_VALUE;
+pub const SSL_R_TLSV1_CERTIFICATE_REQUIRED = SSL_R_TLSV1_ALERT_CERTIFICATE_REQUIRED;
+pub inline fn SSLerr(function: anytype, reason: anytype) @TypeOf(ERR_put_error(ERR_LIB_SSL, @as(c_int, 0), reason, __FILE__, __LINE__)) {
+ _ = function;
+ return ERR_put_error(ERR_LIB_SSL, @as(c_int, 0), reason, __FILE__, __LINE__);
+}
+pub const DTLS_CTRL_GET_TIMEOUT = doesnt_exist;
+pub const DTLS_CTRL_HANDLE_TIMEOUT = doesnt_exist;
+pub const SSL_CTRL_CHAIN = doesnt_exist;
+pub const SSL_CTRL_CHAIN_CERT = doesnt_exist;
+pub const SSL_CTRL_CHANNEL_ID = doesnt_exist;
+pub const SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS = doesnt_exist;
+pub const SSL_CTRL_CLEAR_MODE = doesnt_exist;
+pub const SSL_CTRL_CLEAR_OPTIONS = doesnt_exist;
+pub const SSL_CTRL_EXTRA_CHAIN_CERT = doesnt_exist;
+pub const SSL_CTRL_GET_CHAIN_CERTS = doesnt_exist;
+pub const SSL_CTRL_GET_CHANNEL_ID = doesnt_exist;
+pub const SSL_CTRL_GET_CLIENT_CERT_TYPES = doesnt_exist;
+pub const SSL_CTRL_GET_EXTRA_CHAIN_CERTS = doesnt_exist;
+pub const SSL_CTRL_GET_MAX_CERT_LIST = doesnt_exist;
+pub const SSL_CTRL_GET_NUM_RENEGOTIATIONS = doesnt_exist;
+pub const SSL_CTRL_GET_READ_AHEAD = doesnt_exist;
+pub const SSL_CTRL_GET_RI_SUPPORT = doesnt_exist;
+pub const SSL_CTRL_GET_SERVER_TMP_KEY = doesnt_exist;
+pub const SSL_CTRL_GET_SESSION_REUSED = doesnt_exist;
+pub const SSL_CTRL_GET_SESS_CACHE_MODE = doesnt_exist;
+pub const SSL_CTRL_GET_SESS_CACHE_SIZE = doesnt_exist;
+pub const SSL_CTRL_GET_TLSEXT_TICKET_KEYS = doesnt_exist;
+pub const SSL_CTRL_GET_TOTAL_RENEGOTIATIONS = doesnt_exist;
+pub const SSL_CTRL_MODE = doesnt_exist;
+pub const SSL_CTRL_NEED_TMP_RSA = doesnt_exist;
+pub const SSL_CTRL_OPTIONS = doesnt_exist;
+pub const SSL_CTRL_SESS_NUMBER = doesnt_exist;
+pub const SSL_CTRL_SET_CURVES = doesnt_exist;
+pub const SSL_CTRL_SET_CURVES_LIST = doesnt_exist;
+pub const SSL_CTRL_SET_ECDH_AUTO = doesnt_exist;
+pub const SSL_CTRL_SET_MAX_CERT_LIST = doesnt_exist;
+pub const SSL_CTRL_SET_MAX_SEND_FRAGMENT = doesnt_exist;
+pub const SSL_CTRL_SET_MSG_CALLBACK = doesnt_exist;
+pub const SSL_CTRL_SET_MSG_CALLBACK_ARG = doesnt_exist;
+pub const SSL_CTRL_SET_MTU = doesnt_exist;
+pub const SSL_CTRL_SET_READ_AHEAD = doesnt_exist;
+pub const SSL_CTRL_SET_SESS_CACHE_MODE = doesnt_exist;
+pub const SSL_CTRL_SET_SESS_CACHE_SIZE = doesnt_exist;
+pub const SSL_CTRL_SET_TLSEXT_HOSTNAME = doesnt_exist;
+pub const SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG = doesnt_exist;
+pub const SSL_CTRL_SET_TLSEXT_SERVERNAME_CB = doesnt_exist;
+pub const SSL_CTRL_SET_TLSEXT_TICKET_KEYS = doesnt_exist;
+pub const SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB = doesnt_exist;
+pub const SSL_CTRL_SET_TMP_DH = doesnt_exist;
+pub const SSL_CTRL_SET_TMP_DH_CB = doesnt_exist;
+pub const SSL_CTRL_SET_TMP_ECDH = doesnt_exist;
+pub const SSL_CTRL_SET_TMP_ECDH_CB = doesnt_exist;
+pub const SSL_CTRL_SET_TMP_RSA = doesnt_exist;
+pub const SSL_CTRL_SET_TMP_RSA_CB = doesnt_exist;
+pub const SSL_R_APP_DATA_IN_HANDSHAKE = @as(c_int, 100);
+pub const SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT = @as(c_int, 101);
+pub const SSL_R_BAD_ALERT = @as(c_int, 102);
+pub const SSL_R_BAD_CHANGE_CIPHER_SPEC = @as(c_int, 103);
+pub const SSL_R_BAD_DATA_RETURNED_BY_CALLBACK = @as(c_int, 104);
+pub const SSL_R_BAD_DH_P_LENGTH = @as(c_int, 105);
+pub const SSL_R_BAD_DIGEST_LENGTH = @as(c_int, 106);
+pub const SSL_R_BAD_ECC_CERT = @as(c_int, 107);
+pub const SSL_R_BAD_ECPOINT = @as(c_int, 108);
+pub const SSL_R_BAD_HANDSHAKE_RECORD = @as(c_int, 109);
+pub const SSL_R_BAD_HELLO_REQUEST = @as(c_int, 110);
+pub const SSL_R_BAD_LENGTH = @as(c_int, 111);
+pub const SSL_R_BAD_PACKET_LENGTH = @as(c_int, 112);
+pub const SSL_R_BAD_RSA_ENCRYPT = @as(c_int, 113);
+pub const SSL_R_BAD_SIGNATURE = @as(c_int, 114);
+pub const SSL_R_BAD_SRTP_MKI_VALUE = @as(c_int, 115);
+pub const SSL_R_BAD_SRTP_PROTECTION_PROFILE_LIST = @as(c_int, 116);
+pub const SSL_R_BAD_SSL_FILETYPE = @as(c_int, 117);
+pub const SSL_R_BAD_WRITE_RETRY = @as(c_int, 118);
+pub const SSL_R_BIO_NOT_SET = @as(c_int, 119);
+pub const SSL_R_BN_LIB = @as(c_int, 120);
+pub const SSL_R_BUFFER_TOO_SMALL = @as(c_int, 121);
+pub const SSL_R_CA_DN_LENGTH_MISMATCH = @as(c_int, 122);
+pub const SSL_R_CA_DN_TOO_LONG = @as(c_int, 123);
+pub const SSL_R_CCS_RECEIVED_EARLY = @as(c_int, 124);
+pub const SSL_R_CERTIFICATE_VERIFY_FAILED = @as(c_int, 125);
+pub const SSL_R_CERT_CB_ERROR = @as(c_int, 126);
+pub const SSL_R_CERT_LENGTH_MISMATCH = @as(c_int, 127);
+pub const SSL_R_CHANNEL_ID_NOT_P256 = @as(c_int, 128);
+pub const SSL_R_CHANNEL_ID_SIGNATURE_INVALID = @as(c_int, 129);
+pub const SSL_R_CIPHER_OR_HASH_UNAVAILABLE = @as(c_int, 130);
+pub const SSL_R_CLIENTHELLO_PARSE_FAILED = @as(c_int, 131);
+pub const SSL_R_CLIENTHELLO_TLSEXT = @as(c_int, 132);
+pub const SSL_R_CONNECTION_REJECTED = @as(c_int, 133);
+pub const SSL_R_CONNECTION_TYPE_NOT_SET = @as(c_int, 134);
+pub const SSL_R_CUSTOM_EXTENSION_ERROR = @as(c_int, 135);
+pub const SSL_R_DATA_LENGTH_TOO_LONG = @as(c_int, 136);
+pub const SSL_R_DECODE_ERROR = @as(c_int, 137);
+pub const SSL_R_DECRYPTION_FAILED = @as(c_int, 138);
+pub const SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC = @as(c_int, 139);
+pub const SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG = @as(c_int, 140);
+pub const SSL_R_DH_P_TOO_LONG = @as(c_int, 141);
+pub const SSL_R_DIGEST_CHECK_FAILED = @as(c_int, 142);
+pub const SSL_R_DTLS_MESSAGE_TOO_BIG = @as(c_int, 143);
+pub const SSL_R_ECC_CERT_NOT_FOR_SIGNING = @as(c_int, 144);
+pub const SSL_R_EMS_STATE_INCONSISTENT = @as(c_int, 145);
+pub const SSL_R_ENCRYPTED_LENGTH_TOO_LONG = @as(c_int, 146);
+pub const SSL_R_ERROR_ADDING_EXTENSION = @as(c_int, 147);
+pub const SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST = @as(c_int, 148);
+pub const SSL_R_ERROR_PARSING_EXTENSION = @as(c_int, 149);
+pub const SSL_R_EXCESSIVE_MESSAGE_SIZE = @as(c_int, 150);
+pub const SSL_R_EXTRA_DATA_IN_MESSAGE = @as(c_int, 151);
+pub const SSL_R_FRAGMENT_MISMATCH = @as(c_int, 152);
+pub const SSL_R_GOT_NEXT_PROTO_WITHOUT_EXTENSION = @as(c_int, 153);
+pub const SSL_R_HANDSHAKE_FAILURE_ON_CLIENT_HELLO = @as(c_int, 154);
+pub const SSL_R_HTTPS_PROXY_REQUEST = @as(c_int, 155);
+pub const SSL_R_HTTP_REQUEST = @as(c_int, 156);
+pub const SSL_R_INAPPROPRIATE_FALLBACK = @as(c_int, 157);
+pub const SSL_R_INVALID_COMMAND = @as(c_int, 158);
+pub const SSL_R_INVALID_MESSAGE = @as(c_int, 159);
+pub const SSL_R_INVALID_SSL_SESSION = @as(c_int, 160);
+pub const SSL_R_INVALID_TICKET_KEYS_LENGTH = @as(c_int, 161);
+pub const SSL_R_LENGTH_MISMATCH = @as(c_int, 162);
+pub const SSL_R_MISSING_EXTENSION = @as(c_int, 164);
+pub const SSL_R_MISSING_RSA_CERTIFICATE = @as(c_int, 165);
+pub const SSL_R_MISSING_TMP_DH_KEY = @as(c_int, 166);
+pub const SSL_R_MISSING_TMP_ECDH_KEY = @as(c_int, 167);
+pub const SSL_R_MIXED_SPECIAL_OPERATOR_WITH_GROUPS = @as(c_int, 168);
+pub const SSL_R_MTU_TOO_SMALL = @as(c_int, 169);
+pub const SSL_R_NEGOTIATED_BOTH_NPN_AND_ALPN = @as(c_int, 170);
+pub const SSL_R_NESTED_GROUP = @as(c_int, 171);
+pub const SSL_R_NO_CERTIFICATES_RETURNED = @as(c_int, 172);
+pub const SSL_R_NO_CERTIFICATE_ASSIGNED = @as(c_int, 173);
+pub const SSL_R_NO_CERTIFICATE_SET = @as(c_int, 174);
+pub const SSL_R_NO_CIPHERS_AVAILABLE = @as(c_int, 175);
+pub const SSL_R_NO_CIPHERS_PASSED = @as(c_int, 176);
+pub const SSL_R_NO_CIPHER_MATCH = @as(c_int, 177);
+pub const SSL_R_NO_COMPRESSION_SPECIFIED = @as(c_int, 178);
+pub const SSL_R_NO_METHOD_SPECIFIED = @as(c_int, 179);
+pub const SSL_R_NO_P256_SUPPORT = @as(c_int, 180);
+pub const SSL_R_NO_PRIVATE_KEY_ASSIGNED = @as(c_int, 181);
+pub const SSL_R_NO_RENEGOTIATION = @as(c_int, 182);
+pub const SSL_R_NO_REQUIRED_DIGEST = @as(c_int, 183);
+pub const SSL_R_NO_SHARED_CIPHER = @as(c_int, 184);
+pub const SSL_R_NULL_SSL_CTX = @as(c_int, 185);
+pub const SSL_R_NULL_SSL_METHOD_PASSED = @as(c_int, 186);
+pub const SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED = @as(c_int, 187);
+pub const SSL_R_OLD_SESSION_VERSION_NOT_RETURNED = @as(c_int, 188);
+pub const SSL_R_OUTPUT_ALIASES_INPUT = @as(c_int, 189);
+pub const SSL_R_PARSE_TLSEXT = @as(c_int, 190);
+pub const SSL_R_PATH_TOO_LONG = @as(c_int, 191);
+pub const SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE = @as(c_int, 192);
+pub const SSL_R_PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE = @as(c_int, 193);
+pub const SSL_R_PROTOCOL_IS_SHUTDOWN = @as(c_int, 194);
+pub const SSL_R_PSK_IDENTITY_NOT_FOUND = @as(c_int, 195);
+pub const SSL_R_PSK_NO_CLIENT_CB = @as(c_int, 196);
+pub const SSL_R_PSK_NO_SERVER_CB = @as(c_int, 197);
+pub const SSL_R_READ_TIMEOUT_EXPIRED = @as(c_int, 198);
+pub const SSL_R_RECORD_LENGTH_MISMATCH = @as(c_int, 199);
+pub const SSL_R_RECORD_TOO_LARGE = @as(c_int, 200);
+pub const SSL_R_RENEGOTIATION_ENCODING_ERR = @as(c_int, 201);
+pub const SSL_R_RENEGOTIATION_MISMATCH = @as(c_int, 202);
+pub const SSL_R_REQUIRED_CIPHER_MISSING = @as(c_int, 203);
+pub const SSL_R_RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION = @as(c_int, 204);
+pub const SSL_R_RESUMED_NON_EMS_SESSION_WITH_EMS_EXTENSION = @as(c_int, 205);
+pub const SSL_R_SCSV_RECEIVED_WHEN_RENEGOTIATING = @as(c_int, 206);
+pub const SSL_R_SERVERHELLO_TLSEXT = @as(c_int, 207);
+pub const SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED = @as(c_int, 208);
+pub const SSL_R_SESSION_MAY_NOT_BE_CREATED = @as(c_int, 209);
+pub const SSL_R_SIGNATURE_ALGORITHMS_EXTENSION_SENT_BY_SERVER = @as(c_int, 210);
+pub const SSL_R_SRTP_COULD_NOT_ALLOCATE_PROFILES = @as(c_int, 211);
+pub const SSL_R_SRTP_UNKNOWN_PROTECTION_PROFILE = @as(c_int, 212);
+pub const SSL_R_SSL3_EXT_INVALID_SERVERNAME = @as(c_int, 213);
+pub const SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION = @as(c_int, 214);
+pub const SSL_R_SSL_HANDSHAKE_FAILURE = @as(c_int, 215);
+pub const SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG = @as(c_int, 216);
+pub const SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST = @as(c_int, 217);
+pub const SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG = @as(c_int, 218);
+pub const SSL_R_TOO_MANY_EMPTY_FRAGMENTS = @as(c_int, 219);
+pub const SSL_R_TOO_MANY_WARNING_ALERTS = @as(c_int, 220);
+pub const SSL_R_UNABLE_TO_FIND_ECDH_PARAMETERS = @as(c_int, 221);
+pub const SSL_R_UNEXPECTED_EXTENSION = @as(c_int, 222);
+pub const SSL_R_UNEXPECTED_MESSAGE = @as(c_int, 223);
+pub const SSL_R_UNEXPECTED_OPERATOR_IN_GROUP = @as(c_int, 224);
+pub const SSL_R_UNEXPECTED_RECORD = @as(c_int, 225);
+pub const SSL_R_UNINITIALIZED = @as(c_int, 226);
+pub const SSL_R_UNKNOWN_ALERT_TYPE = @as(c_int, 227);
+pub const SSL_R_UNKNOWN_CERTIFICATE_TYPE = @as(c_int, 228);
+pub const SSL_R_UNKNOWN_CIPHER_RETURNED = @as(c_int, 229);
+pub const SSL_R_UNKNOWN_CIPHER_TYPE = @as(c_int, 230);
+pub const SSL_R_UNKNOWN_DIGEST = @as(c_int, 231);
+pub const SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE = @as(c_int, 232);
+pub const SSL_R_UNKNOWN_PROTOCOL = @as(c_int, 233);
+pub const SSL_R_UNKNOWN_SSL_VERSION = @as(c_int, 234);
+pub const SSL_R_UNKNOWN_STATE = @as(c_int, 235);
+pub const SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED = @as(c_int, 236);
+pub const SSL_R_UNSUPPORTED_CIPHER = @as(c_int, 237);
+pub const SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM = @as(c_int, 238);
+pub const SSL_R_UNSUPPORTED_ELLIPTIC_CURVE = @as(c_int, 239);
+pub const SSL_R_UNSUPPORTED_PROTOCOL = @as(c_int, 240);
+pub const SSL_R_WRONG_CERTIFICATE_TYPE = @as(c_int, 241);
+pub const SSL_R_WRONG_CIPHER_RETURNED = @as(c_int, 242);
+pub const SSL_R_WRONG_CURVE = @as(c_int, 243);
+pub const SSL_R_WRONG_MESSAGE_TYPE = @as(c_int, 244);
+pub const SSL_R_WRONG_SIGNATURE_TYPE = @as(c_int, 245);
+pub const SSL_R_WRONG_SSL_VERSION = @as(c_int, 246);
+pub const SSL_R_WRONG_VERSION_NUMBER = @as(c_int, 247);
+pub const SSL_R_X509_LIB = @as(c_int, 248);
+pub const SSL_R_X509_VERIFICATION_SETUP_PROBLEMS = @as(c_int, 249);
+pub const SSL_R_SHUTDOWN_WHILE_IN_INIT = @as(c_int, 250);
+pub const SSL_R_INVALID_OUTER_RECORD_TYPE = @as(c_int, 251);
+pub const SSL_R_UNSUPPORTED_PROTOCOL_FOR_CUSTOM_KEY = @as(c_int, 252);
+pub const SSL_R_NO_COMMON_SIGNATURE_ALGORITHMS = @as(c_int, 253);
+pub const SSL_R_DOWNGRADE_DETECTED = @as(c_int, 254);
+pub const SSL_R_EXCESS_HANDSHAKE_DATA = @as(c_int, 255);
+pub const SSL_R_INVALID_COMPRESSION_LIST = @as(c_int, 256);
+pub const SSL_R_DUPLICATE_EXTENSION = @as(c_int, 257);
+pub const SSL_R_MISSING_KEY_SHARE = @as(c_int, 258);
+pub const SSL_R_INVALID_ALPN_PROTOCOL = @as(c_int, 259);
+pub const SSL_R_TOO_MANY_KEY_UPDATES = @as(c_int, 260);
+pub const SSL_R_BLOCK_CIPHER_PAD_IS_WRONG = @as(c_int, 261);
+pub const SSL_R_NO_CIPHERS_SPECIFIED = @as(c_int, 262);
+pub const SSL_R_RENEGOTIATION_EMS_MISMATCH = @as(c_int, 263);
+pub const SSL_R_DUPLICATE_KEY_SHARE = @as(c_int, 264);
+pub const SSL_R_NO_GROUPS_SPECIFIED = @as(c_int, 265);
+pub const SSL_R_NO_SHARED_GROUP = @as(c_int, 266);
+pub const SSL_R_PRE_SHARED_KEY_MUST_BE_LAST = @as(c_int, 267);
+pub const SSL_R_OLD_SESSION_PRF_HASH_MISMATCH = @as(c_int, 268);
+pub const SSL_R_INVALID_SCT_LIST = @as(c_int, 269);
+pub const SSL_R_TOO_MUCH_SKIPPED_EARLY_DATA = @as(c_int, 270);
+pub const SSL_R_PSK_IDENTITY_BINDER_COUNT_MISMATCH = @as(c_int, 271);
+pub const SSL_R_CANNOT_PARSE_LEAF_CERT = @as(c_int, 272);
+pub const SSL_R_SERVER_CERT_CHANGED = @as(c_int, 273);
+pub const SSL_R_CERTIFICATE_AND_PRIVATE_KEY_MISMATCH = @as(c_int, 274);
+pub const SSL_R_CANNOT_HAVE_BOTH_PRIVKEY_AND_METHOD = @as(c_int, 275);
+pub const SSL_R_TICKET_ENCRYPTION_FAILED = @as(c_int, 276);
+pub const SSL_R_ALPN_MISMATCH_ON_EARLY_DATA = @as(c_int, 277);
+pub const SSL_R_WRONG_VERSION_ON_EARLY_DATA = @as(c_int, 278);
+pub const SSL_R_UNEXPECTED_EXTENSION_ON_EARLY_DATA = @as(c_int, 279);
+pub const SSL_R_NO_SUPPORTED_VERSIONS_ENABLED = @as(c_int, 280);
+pub const SSL_R_APPLICATION_DATA_INSTEAD_OF_HANDSHAKE = @as(c_int, 281);
+pub const SSL_R_EMPTY_HELLO_RETRY_REQUEST = @as(c_int, 282);
+pub const SSL_R_EARLY_DATA_NOT_IN_USE = @as(c_int, 283);
+pub const SSL_R_HANDSHAKE_NOT_COMPLETE = @as(c_int, 284);
+pub const SSL_R_NEGOTIATED_TB_WITHOUT_EMS_OR_RI = @as(c_int, 285);
+pub const SSL_R_SERVER_ECHOED_INVALID_SESSION_ID = @as(c_int, 286);
+pub const SSL_R_PRIVATE_KEY_OPERATION_FAILED = @as(c_int, 287);
+pub const SSL_R_SECOND_SERVERHELLO_VERSION_MISMATCH = @as(c_int, 288);
+pub const SSL_R_OCSP_CB_ERROR = @as(c_int, 289);
+pub const SSL_R_SSL_SESSION_ID_TOO_LONG = @as(c_int, 290);
+pub const SSL_R_APPLICATION_DATA_ON_SHUTDOWN = @as(c_int, 291);
+pub const SSL_R_CERT_DECOMPRESSION_FAILED = @as(c_int, 292);
+pub const SSL_R_UNCOMPRESSED_CERT_TOO_LARGE = @as(c_int, 293);
+pub const SSL_R_UNKNOWN_CERT_COMPRESSION_ALG = @as(c_int, 294);
+pub const SSL_R_INVALID_SIGNATURE_ALGORITHM = @as(c_int, 295);
+pub const SSL_R_DUPLICATE_SIGNATURE_ALGORITHM = @as(c_int, 296);
+pub const SSL_R_TLS13_DOWNGRADE = @as(c_int, 297);
+pub const SSL_R_QUIC_INTERNAL_ERROR = @as(c_int, 298);
+pub const SSL_R_WRONG_ENCRYPTION_LEVEL_RECEIVED = @as(c_int, 299);
+pub const SSL_R_TOO_MUCH_READ_EARLY_DATA = @as(c_int, 300);
+pub const SSL_R_INVALID_DELEGATED_CREDENTIAL = @as(c_int, 301);
+pub const SSL_R_KEY_USAGE_BIT_INCORRECT = @as(c_int, 302);
+pub const SSL_R_INCONSISTENT_CLIENT_HELLO = @as(c_int, 303);
+pub const SSL_R_CIPHER_MISMATCH_ON_EARLY_DATA = @as(c_int, 304);
+pub const SSL_R_QUIC_TRANSPORT_PARAMETERS_MISCONFIGURED = @as(c_int, 305);
+pub const SSL_R_UNEXPECTED_COMPATIBILITY_MODE = @as(c_int, 306);
+pub const SSL_R_NO_APPLICATION_PROTOCOL = @as(c_int, 307);
+pub const SSL_R_NEGOTIATED_ALPS_WITHOUT_ALPN = @as(c_int, 308);
+pub const SSL_R_ALPS_MISMATCH_ON_EARLY_DATA = @as(c_int, 309);
+pub const SSL_R_ECH_SERVER_CONFIG_AND_PRIVATE_KEY_MISMATCH = @as(c_int, 310);
+pub const SSL_R_ECH_SERVER_CONFIG_UNSUPPORTED_EXTENSION = @as(c_int, 311);
+pub const SSL_R_UNSUPPORTED_ECH_SERVER_CONFIG = @as(c_int, 312);
+pub const SSL_R_ECH_SERVER_WOULD_HAVE_NO_RETRY_CONFIGS = @as(c_int, 313);
+pub const SSL_R_INVALID_CLIENT_HELLO_INNER = @as(c_int, 314);
+pub const SSL_R_INVALID_ALPN_PROTOCOL_LIST = @as(c_int, 315);
+pub const SSL_R_COULD_NOT_PARSE_HINTS = @as(c_int, 316);
+pub const SSL_R_INVALID_ECH_PUBLIC_NAME = @as(c_int, 317);
+pub const SSL_R_INVALID_ECH_CONFIG_LIST = @as(c_int, 318);
+pub const SSL_R_ECH_REJECTED = @as(c_int, 319);
+pub const SSL_R_OUTER_EXTENSION_NOT_FOUND = @as(c_int, 320);
+pub const SSL_R_INCONSISTENT_ECH_NEGOTIATION = @as(c_int, 321);
+pub const SSL_R_SSLV3_ALERT_CLOSE_NOTIFY = @as(c_int, 1000);
+pub const SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE = @as(c_int, 1010);
+pub const SSL_R_SSLV3_ALERT_BAD_RECORD_MAC = @as(c_int, 1020);
+pub const SSL_R_TLSV1_ALERT_DECRYPTION_FAILED = @as(c_int, 1021);
+pub const SSL_R_TLSV1_ALERT_RECORD_OVERFLOW = @as(c_int, 1022);
+pub const SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE = @as(c_int, 1030);
+pub const SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE = @as(c_int, 1040);
+pub const SSL_R_SSLV3_ALERT_NO_CERTIFICATE = @as(c_int, 1041);
+pub const SSL_R_SSLV3_ALERT_BAD_CERTIFICATE = @as(c_int, 1042);
+pub const SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE = @as(c_int, 1043);
+pub const SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED = @as(c_int, 1044);
+pub const SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED = @as(c_int, 1045);
+pub const SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN = @as(c_int, 1046);
+pub const SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER = @as(c_int, 1047);
+pub const SSL_R_TLSV1_ALERT_UNKNOWN_CA = @as(c_int, 1048);
+pub const SSL_R_TLSV1_ALERT_ACCESS_DENIED = @as(c_int, 1049);
+pub const SSL_R_TLSV1_ALERT_DECODE_ERROR = @as(c_int, 1050);
+pub const SSL_R_TLSV1_ALERT_DECRYPT_ERROR = @as(c_int, 1051);
+pub const SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION = @as(c_int, 1060);
+pub const SSL_R_TLSV1_ALERT_PROTOCOL_VERSION = @as(c_int, 1070);
+pub const SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY = @as(c_int, 1071);
+pub const SSL_R_TLSV1_ALERT_INTERNAL_ERROR = @as(c_int, 1080);
+pub const SSL_R_TLSV1_ALERT_INAPPROPRIATE_FALLBACK = @as(c_int, 1086);
+pub const SSL_R_TLSV1_ALERT_USER_CANCELLED = @as(c_int, 1090);
+pub const SSL_R_TLSV1_ALERT_NO_RENEGOTIATION = @as(c_int, 1100);
+pub const SSL_R_TLSV1_ALERT_UNSUPPORTED_EXTENSION = @as(c_int, 1110);
+pub const SSL_R_TLSV1_ALERT_CERTIFICATE_UNOBTAINABLE = @as(c_int, 1111);
+pub const SSL_R_TLSV1_ALERT_UNRECOGNIZED_NAME = @as(c_int, 1112);
+pub const SSL_R_TLSV1_ALERT_BAD_CERTIFICATE_STATUS_RESPONSE = @as(c_int, 1113);
+pub const SSL_R_TLSV1_ALERT_BAD_CERTIFICATE_HASH_VALUE = @as(c_int, 1114);
+pub const SSL_R_TLSV1_ALERT_UNKNOWN_PSK_IDENTITY = @as(c_int, 1115);
+pub const SSL_R_TLSV1_ALERT_CERTIFICATE_REQUIRED = @as(c_int, 1116);
+pub const SSL_R_TLSV1_ALERT_NO_APPLICATION_PROTOCOL = @as(c_int, 1120);
+pub const SSL_R_TLSV1_ALERT_ECH_REQUIRED = @as(c_int, 1121);
+pub const asn1_null_st = struct_asn1_null_st;
+pub const ASN1_ITEM_st = struct_ASN1_ITEM_st;
+pub const asn1_object_st = struct_asn1_object_st;
+pub const asn1_pctx_st = struct_asn1_pctx_st;
+pub const asn1_string_st = struct_asn1_string_st;
+pub const ASN1_VALUE_st = struct_ASN1_VALUE_st;
+pub const asn1_type_st = struct_asn1_type_st;
+pub const AUTHORITY_KEYID_st = struct_AUTHORITY_KEYID_st;
+pub const BASIC_CONSTRAINTS_st = struct_BASIC_CONSTRAINTS_st;
+pub const DIST_POINT_st = struct_DIST_POINT_st;
+pub const bignum_st = struct_bignum_st;
+pub const DSA_SIG_st = struct_DSA_SIG_st;
+pub const ISSUING_DIST_POINT_st = struct_ISSUING_DIST_POINT_st;
+pub const NAME_CONSTRAINTS_st = struct_NAME_CONSTRAINTS_st;
+pub const X509_pubkey_st = struct_X509_pubkey_st;
+pub const Netscape_spkac_st = struct_Netscape_spkac_st;
+pub const X509_algor_st = struct_X509_algor_st;
+pub const Netscape_spki_st = struct_Netscape_spki_st;
+pub const RIPEMD160state_st = struct_RIPEMD160state_st;
+pub const X509_POLICY_CACHE_st = struct_X509_POLICY_CACHE_st;
+pub const X509_POLICY_LEVEL_st = struct_X509_POLICY_LEVEL_st;
+pub const X509_POLICY_NODE_st = struct_X509_POLICY_NODE_st;
+pub const X509_POLICY_TREE_st = struct_X509_POLICY_TREE_st;
+pub const X509_VERIFY_PARAM_st = struct_X509_VERIFY_PARAM_st;
+pub const X509_crl_st = struct_X509_crl_st;
+pub const X509_extension_st = struct_X509_extension_st;
+pub const x509_st = struct_x509_st;
+pub const openssl_method_common_st = struct_openssl_method_common_st;
+pub const rsa_meth_st = struct_rsa_meth_st;
+pub const stack_st_void = struct_stack_st_void;
+pub const crypto_ex_data_st = struct_crypto_ex_data_st;
+pub const bn_mont_ctx_st = struct_bn_mont_ctx_st;
+pub const bn_blinding_st = struct_bn_blinding_st;
+pub const rsa_st = struct_rsa_st;
+pub const dsa_st = struct_dsa_st;
+pub const dh_st = struct_dh_st;
+pub const ec_key_st = struct_ec_key_st;
+pub const evp_pkey_asn1_method_st = struct_evp_pkey_asn1_method_st;
+pub const evp_pkey_st = struct_evp_pkey_st;
+pub const evp_cipher_ctx_st = struct_evp_cipher_ctx_st;
+pub const evp_cipher_st = struct_evp_cipher_st;
+pub const evp_cipher_info_st = struct_evp_cipher_info_st;
+pub const private_key_st = struct_private_key_st;
+pub const X509_info_st = struct_X509_info_st;
+pub const X509_name_entry_st = struct_X509_name_entry_st;
+pub const X509_name_st = struct_X509_name_st;
+pub const X509_req_st = struct_X509_req_st;
+pub const X509_sig_st = struct_X509_sig_st;
+pub const bignum_ctx = struct_bignum_ctx;
+pub const bio_st = struct_bio_st;
+pub const bio_method_st = struct_bio_method_st;
+pub const blake2b_state_st = struct_blake2b_state_st;
+pub const bn_gencb_st = struct_bn_gencb_st;
+pub const buf_mem_st = struct_buf_mem_st;
+pub const cbb_buffer_st = struct_cbb_buffer_st;
+pub const cbb_st = struct_cbb_st;
+pub const cbs_st = struct_cbs_st;
+pub const cmac_ctx_st = struct_cmac_ctx_st;
+pub const conf_st = struct_conf_st;
+pub const conf_value_st = struct_conf_value_st;
+pub const crypto_buffer_pool_st = struct_crypto_buffer_pool_st;
+pub const crypto_buffer_st = struct_crypto_buffer_st;
+pub const ec_group_st = struct_ec_group_st;
+pub const ec_point_st = struct_ec_point_st;
+pub const ecdsa_method_st = struct_ecdsa_method_st;
+pub const ecdsa_sig_st = struct_ecdsa_sig_st;
+pub const engine_st = struct_engine_st;
+pub const env_md_st = struct_env_md_st;
+pub const evp_pkey_ctx_st = struct_evp_pkey_ctx_st;
+pub const evp_md_pctx_ops = struct_evp_md_pctx_ops;
+pub const env_md_ctx_st = struct_env_md_ctx_st;
+pub const evp_aead_st = struct_evp_aead_st;
+pub const evp_encode_ctx_st = struct_evp_encode_ctx_st;
+pub const evp_hpke_aead_st = struct_evp_hpke_aead_st;
+pub const evp_hpke_ctx_st = struct_evp_hpke_ctx_st;
+pub const evp_hpke_kdf_st = struct_evp_hpke_kdf_st;
+pub const evp_hpke_kem_st = struct_evp_hpke_kem_st;
+pub const evp_hpke_key_st = struct_evp_hpke_key_st;
+pub const evp_pkey_method_st = struct_evp_pkey_method_st;
+pub const hmac_ctx_st = struct_hmac_ctx_st;
+pub const md4_state_st = struct_md4_state_st;
+pub const md5_state_st = struct_md5_state_st;
+pub const ossl_init_settings_st = struct_ossl_init_settings_st;
+pub const pkcs12_st = struct_pkcs12_st;
+pub const pkcs8_priv_key_info_st = struct_pkcs8_priv_key_info_st;
+pub const rand_meth_st = struct_rand_meth_st;
+pub const rc4_key_st = struct_rc4_key_st;
+pub const rsa_pss_params_st = struct_rsa_pss_params_st;
+pub const sha256_state_st = struct_sha256_state_st;
+pub const sha512_state_st = struct_sha512_state_st;
+pub const sha_state_st = struct_sha_state_st;
+pub const spake2_ctx_st = struct_spake2_ctx_st;
+pub const srtp_protection_profile_st = struct_srtp_protection_profile_st;
+pub const ssl_cipher_st = struct_ssl_cipher_st;
+pub const ssl_ctx_st = SSL_CTX;
+pub const ssl_st = SSL;
+pub const ssl_early_callback_ctx = struct_ssl_early_callback_ctx;
+pub const ssl_ech_keys_st = struct_ssl_ech_keys_st;
+pub const ssl_method_st = struct_ssl_method_st;
+pub const ssl_private_key_result_t = enum_ssl_private_key_result_t;
+pub const ssl_private_key_method_st = struct_ssl_private_key_method_st;
+pub const ssl_encryption_level_t = enum_ssl_encryption_level_t;
+pub const ssl_quic_method_st = struct_ssl_quic_method_st;
+pub const ssl_session_st = struct_ssl_session_st;
+pub const ssl_ticket_aead_result_t = enum_ssl_ticket_aead_result_t;
+pub const ssl_ticket_aead_method_st = struct_ssl_ticket_aead_method_st;
+pub const st_ERR_FNS = struct_st_ERR_FNS;
+pub const trust_token_st = struct_trust_token_st;
+pub const trust_token_client_st = struct_trust_token_client_st;
+pub const trust_token_issuer_st = struct_trust_token_issuer_st;
+pub const trust_token_method_st = struct_trust_token_method_st;
+pub const v3_ext_ctx = struct_v3_ext_ctx;
+pub const x509_attributes_st = struct_x509_attributes_st;
+pub const x509_cert_aux_st = struct_x509_cert_aux_st;
+pub const x509_crl_method_st = struct_x509_crl_method_st;
+pub const x509_lookup_st = struct_x509_lookup_st;
+pub const x509_lookup_method_st = struct_x509_lookup_method_st;
+pub const x509_object_st = struct_x509_object_st;
+pub const stack_st_X509_EXTENSION = struct_stack_st_X509_EXTENSION;
+pub const stack_st_GENERAL_NAME = struct_stack_st_GENERAL_NAME;
+pub const x509_revoked_st = struct_x509_revoked_st;
+pub const x509_store_ctx_st = struct_x509_store_ctx_st;
+pub const x509_store_st = struct_x509_store_st;
+pub const x509_trust_st = struct_x509_trust_st;
+pub const __sbuf = struct___sbuf;
+pub const __sFILEX = struct___sFILEX;
+pub const __sFILE = struct___sFILE;
+pub const stack_st = struct_stack_st;
+pub const stack_st_OPENSSL_STRING = struct_stack_st_OPENSSL_STRING;
+pub const CRYPTO_dynlock_value = struct_CRYPTO_dynlock_value;
+pub const stack_st_BIO = struct_stack_st_BIO;
+pub const evp_aead_ctx_st_state = union_evp_aead_ctx_st_state;
+pub const evp_aead_ctx_st = struct_evp_aead_ctx_st;
+pub const evp_aead_direction_t = enum_evp_aead_direction_t;
+pub const stack_st_CRYPTO_BUFFER = struct_stack_st_CRYPTO_BUFFER;
+pub const stack_st_X509 = struct_stack_st_X509;
+pub const stack_st_X509_CRL = struct_stack_st_X509_CRL;
+pub const tm = struct_tm;
+pub const bn_primality_result_t = enum_bn_primality_result_t;
+pub const stack_st_ASN1_INTEGER = struct_stack_st_ASN1_INTEGER;
+pub const stack_st_ASN1_OBJECT = struct_stack_st_ASN1_OBJECT;
+pub const stack_st_ASN1_TYPE = struct_stack_st_ASN1_TYPE;
+pub const ec_method_st = struct_ec_method_st;
+pub const obj_name_st = struct_obj_name_st;
+pub const stack_st_X509_ALGOR = struct_stack_st_X509_ALGOR;
+pub const stack_st_X509_NAME_ENTRY = struct_stack_st_X509_NAME_ENTRY;
+pub const stack_st_X509_NAME = struct_stack_st_X509_NAME;
+pub const stack_st_X509_ATTRIBUTE = struct_stack_st_X509_ATTRIBUTE;
+pub const stack_st_DIST_POINT = struct_stack_st_DIST_POINT;
+pub const stack_st_X509_TRUST = struct_stack_st_X509_TRUST;
+pub const stack_st_X509_REVOKED = struct_stack_st_X509_REVOKED;
+pub const stack_st_GENERAL_NAMES = struct_stack_st_GENERAL_NAMES;
+pub const stack_st_X509_INFO = struct_stack_st_X509_INFO;
+pub const stack_st_X509_LOOKUP = struct_stack_st_X509_LOOKUP;
+pub const stack_st_X509_OBJECT = struct_stack_st_X509_OBJECT;
+pub const stack_st_X509_VERIFY_PARAM = struct_stack_st_X509_VERIFY_PARAM;
+pub const stack_st_X509_POLICY_NODE = struct_stack_st_X509_POLICY_NODE;
+pub const stack_st_POLICYQUALINFO = struct_stack_st_POLICYQUALINFO;
+pub const fips_counter_t = enum_fips_counter_t;
+pub const stack_st_SSL_CIPHER = struct_stack_st_SSL_CIPHER;
+pub const ssl_verify_result_t = enum_ssl_verify_result_t;
+pub const stack_st_SRTP_PROTECTION_PROFILE = struct_stack_st_SRTP_PROTECTION_PROFILE;
+pub const ssl_early_data_reason_t = enum_ssl_early_data_reason_t;
+pub const ssl_renegotiate_mode_t = enum_ssl_renegotiate_mode_t;
+pub const ssl_select_cert_result_t = enum_ssl_select_cert_result_t;
+pub const ssl_comp_st = struct_ssl_comp_st;
+pub const stack_st_SSL_COMP = struct_stack_st_SSL_COMP;
+pub const ssl_conf_ctx_st = struct_ssl_conf_ctx_st;
+
+// Manual modification
+
+pub const struct_bio_st = extern struct {
+ method: [*c]const BIO_METHOD,
+ init: c_int,
+ shutdown: c_int,
+ flags: c_int,
+ retry_reason: c_int,
+ num: c_int,
+ references: CRYPTO_refcount_t,
+ ptr: ?*c_void,
+ next_bio: ?*BIO,
+ num_read: usize,
+ num_write: usize,
+
+ pub fn isEmpty(this: *struct_bio_st) bool {
+ return BIO_eof(this) > 0;
+ }
+
+ pub fn init() !*struct_bio_st {
+ return BIO_new(BIO_s_mem()) orelse error.OutOfMemory;
+ }
+
+ pub fn deinit(this: *struct_bio_st) void {
+ _ = BIO_free(this);
+ }
+
+ pub fn slice(this: *struct_bio_st) []u8 {
+ var buf_mem: ?*BUF_MEM = null;
+ std.debug.assert(BIO_get_mem_ptr(this, &buf_mem) > -1);
+ if (buf_mem) |buf| {
+ if (buf.data == null) return &[_]u8{};
+
+ return buf.data[0..buf.length];
+ }
+
+ return &[_]u8{};
+ }
+
+ pub fn pending(this: *const struct_bio_st) usize {
+ return BIO_ctrl_pending(this);
+ }
+
+ pub fn write(this: *struct_bio_st, buffer: []const u8) !usize {
+ const rc = BIO_write(this, buffer.ptr, @intCast(c_int, buffer.len));
+
+ return if (rc > -1)
+ return @intCast(usize, rc)
+ else
+ return error.Fail;
+ }
+
+ pub fn read(this: *struct_bio_st, buffer: []u8) !usize {
+ const rc = BIO_read(this, buffer.ptr, @intCast(c_int, buffer.len));
+ return if (rc > -1)
+ return @intCast(usize, rc)
+ else
+ return error.Fail;
+ }
+};
+
+pub const SSL = opaque {
+ pub const Error = error{
+ SSL,
+ WantRead,
+ WantWrite,
+ WantX509Lookup,
+ Syscall,
+ ZeroReturn,
+ WantConnect,
+ WantAccept,
+ WantChannelIdLookup,
+ PendingSession,
+ PendingCertificate,
+ WantPrivateKeyOperation,
+ PendingTicket,
+ EarlyDataRejected,
+ WantCertificateVerify,
+ Handoff,
+ Handback,
+ WantRenegotiate,
+ HandshakeHintsReady,
+ };
+
+ pub inline fn deinit(this: *SSL) void {
+ _ = SSL_free(this);
+ }
+
+ pub inline fn init(ctx: *SSL_CTX) *SSL {
+ return SSL_new(ctx);
+ }
+
+ pub inline fn isInitFinished(ssl: *const SSL) bool {
+ return SSL_is_init_finished(ssl) > 0;
+ }
+
+ pub inline fn pending(ssl: *SSL) usize {
+ return @intCast(usize, SSL_pending(ssl));
+ }
+
+ pub inline fn hasPending(ssl: *SSL) bool {
+ return SSL_has_pending(ssl) > 0;
+ }
+
+ pub inline fn setIsClient(ssl: *SSL, comptime is_client: bool) void {
+ if (comptime !is_client) {
+ SSL_set_accept_state(ssl);
+ } else {
+ SSL_set_connect_state(ssl);
+ }
+ }
+
+ pub inline fn setBIO(ssl: *SSL, in: *BIO, out: *BIO) void {
+ SSL_set_bio(ssl, in, out);
+ }
+
+ pub fn setHostname(ssl: *SSL, hostname: [*c]const u8) void {
+ _ = SSL_set_tlsext_host_name(ssl, hostname);
+ }
+
+ pub fn handshake(this: *SSL) Error!void {
+ const rc = SSL_connect(this);
+ return switch (SSL_get_error(this, rc)) {
+ SSL_ERROR_SSL => return error.SSL,
+ SSL_ERROR_WANT_READ => return error.WantRead,
+ SSL_ERROR_WANT_WRITE => return error.WantWrite,
+ SSL_ERROR_WANT_X509_LOOKUP => return error.WantX509Lookup,
+ SSL_ERROR_SYSCALL => return error.Syscall,
+ SSL_ERROR_ZERO_RETURN => return error.ZeroReturn,
+ SSL_ERROR_WANT_CONNECT => return error.WantConnect,
+ SSL_ERROR_WANT_ACCEPT => return error.WantAccept,
+ SSL_ERROR_WANT_CHANNEL_ID_LOOKUP => return error.WantChannelIdLookup,
+ SSL_ERROR_PENDING_SESSION => return error.PendingSession,
+ SSL_ERROR_PENDING_CERTIFICATE => return error.PendingCertificate,
+ SSL_ERROR_WANT_PRIVATE_KEY_OPERATION => return error.WantPrivateKeyOperation,
+ SSL_ERROR_PENDING_TICKET => return error.PendingTicket,
+ SSL_ERROR_EARLY_DATA_REJECTED => return error.EarlyDataRejected,
+ SSL_ERROR_WANT_CERTIFICATE_VERIFY => return error.WantCertificateVerify,
+ SSL_ERROR_HANDOFF => return error.Handoff,
+ SSL_ERROR_HANDBACK => return error.Handback,
+ SSL_ERROR_WANT_RENEGOTIATE => return error.WantRenegotiate,
+ SSL_ERROR_HANDSHAKE_HINTS_READY => return error.HandshakeHintsReady,
+ else => void{},
+ };
+ }
+
+ pub fn read(this: *SSL, buf: []u8) Error!usize {
+ const rc = SSL_read(this, buf.ptr, @intCast(c_int, buf.len));
+ return switch (SSL_get_error(this, rc)) {
+ SSL_ERROR_SSL => error.SSL,
+ SSL_ERROR_WANT_READ => error.WantRead,
+ SSL_ERROR_WANT_WRITE => error.WantWrite,
+ SSL_ERROR_WANT_X509_LOOKUP => error.WantX509Lookup,
+ SSL_ERROR_SYSCALL => error.Syscall,
+ SSL_ERROR_ZERO_RETURN => error.ZeroReturn,
+ SSL_ERROR_WANT_CONNECT => error.WantConnect,
+ SSL_ERROR_WANT_ACCEPT => error.WantAccept,
+ SSL_ERROR_WANT_CHANNEL_ID_LOOKUP => error.WantChannelIdLookup,
+ SSL_ERROR_PENDING_SESSION => error.PendingSession,
+ SSL_ERROR_PENDING_CERTIFICATE => error.PendingCertificate,
+ SSL_ERROR_WANT_PRIVATE_KEY_OPERATION => error.WantPrivateKeyOperation,
+ SSL_ERROR_PENDING_TICKET => error.PendingTicket,
+ SSL_ERROR_EARLY_DATA_REJECTED => error.EarlyDataRejected,
+ SSL_ERROR_WANT_CERTIFICATE_VERIFY => error.WantCertificateVerify,
+ SSL_ERROR_HANDOFF => error.Handoff,
+ SSL_ERROR_HANDBACK => error.Handback,
+ SSL_ERROR_WANT_RENEGOTIATE => error.WantRenegotiate,
+ SSL_ERROR_HANDSHAKE_HINTS_READY => error.HandshakeHintsReady,
+ else => @intCast(usize, rc),
+ };
+ }
+
+ pub fn write(this: *SSL, buf: []const u8) Error!usize {
+ const rc = SSL_write(this, buf.ptr, @intCast(c_int, buf.len));
+ return switch (SSL_get_error(this, rc)) {
+ SSL_ERROR_SSL => error.SSL,
+ SSL_ERROR_WANT_READ => error.WantRead,
+ SSL_ERROR_WANT_WRITE => error.WantWrite,
+ SSL_ERROR_WANT_X509_LOOKUP => error.WantX509Lookup,
+ SSL_ERROR_SYSCALL => error.Syscall,
+ SSL_ERROR_ZERO_RETURN => error.ZeroReturn,
+ SSL_ERROR_WANT_CONNECT => error.WantConnect,
+ SSL_ERROR_WANT_ACCEPT => error.WantAccept,
+ SSL_ERROR_WANT_CHANNEL_ID_LOOKUP => error.WantChannelIdLookup,
+ SSL_ERROR_PENDING_SESSION => error.PendingSession,
+ SSL_ERROR_PENDING_CERTIFICATE => error.PendingCertificate,
+ SSL_ERROR_WANT_PRIVATE_KEY_OPERATION => error.WantPrivateKeyOperation,
+ SSL_ERROR_PENDING_TICKET => error.PendingTicket,
+ SSL_ERROR_EARLY_DATA_REJECTED => error.EarlyDataRejected,
+ SSL_ERROR_WANT_CERTIFICATE_VERIFY => error.WantCertificateVerify,
+ SSL_ERROR_HANDOFF => error.Handoff,
+ SSL_ERROR_HANDBACK => error.Handback,
+ SSL_ERROR_WANT_RENEGOTIATE => error.WantRenegotiate,
+ SSL_ERROR_HANDSHAKE_HINTS_READY => error.HandshakeHintsReady,
+ else => @intCast(usize, rc),
+ };
+ }
+
+ pub fn readAll(this: *SSL, buf: []u8) Error![]u8 {
+ var rbio = SSL_get_rbio(this);
+ const start_len = rbio.slice().len;
+ const written = try this.read(buf);
+ return rbio.slice()[start_len..];
+ }
+
+ pub fn writeAll(this: *SSL, buf: []const u8) Error![]const u8 {
+ var rbio = SSL_get_wbio(this);
+ const start_len = rbio.slice().len;
+ const written = try this.write(buf);
+ return rbio.slice()[start_len..];
+ }
+};
+
+pub const SSL_CTX = opaque {
+ pub fn init() ?*SSL_CTX {
+ var ctx = SSL_CTX_new(TLS_with_buffers_method()) orelse return null;
+ ctx.setCustomVerify(noop_custom_verify);
+ if (auto_crypto_buffer_pool == null) auto_crypto_buffer_pool = CRYPTO_BUFFER_POOL_new();
+ SSL_CTX_set0_buffer_pool(ctx, auto_crypto_buffer_pool);
+ // _ = SSL_CTX_set_mode(ctx, SSL_MODE_AUTO_RETRY);
+ _ = SSL_CTX_set_cipher_list(ctx, SSL_DEFAULT_CIPHER_LIST);
+ return ctx;
+ }
+
+ pub inline fn setCustomVerify(this: *SSL_CTX, cb: ?VerifyCallback) void {
+ SSL_CTX_set_custom_verify(this, 0, cb);
+ // SSL_CTX_set_custom_verify(this, 1, cb);
+ // SSL_CTX_set_custom_verify(this, 2, cb);
+ }
+};
+
+fn noop_custom_verify(_: *SSL, _: [*c]u8) callconv(.C) VerifyResult {
+ return VerifyResult.ok;
+}
+
+var auto_crypto_buffer_pool: ?*CRYPTO_BUFFER_POOL = null;
+
+pub const BIOMethod = struct {
+ pub const create = fn (*BIO) callconv(.C) c_int;
+ pub const destroy = fn (*BIO) callconv(.C) c_int;
+ pub const write = fn (*BIO, [*c]const u8, c_int) callconv(.C) c_int;
+ pub const read = fn (*BIO, [*c]u8, c_int) callconv(.C) c_int;
+ pub const gets = fn (*BIO, [*c]u8, c_int) callconv(.C) c_int;
+ pub const ctrl = fn (*BIO, c_int, c_long, ?*c_void) callconv(.C) c_long;
+ pub fn init(
+ name: [:0]const u8,
+ comptime create__: ?create,
+ comptime destroy__: ?destroy,
+ comptime write__: ?write,
+ comptime read__: ?read,
+ comptime gets__: ?gets,
+ comptime ctrl__: ?ctrl,
+ ) *BIO_METHOD {
+ var method = BIO_meth_new(BIO_get_new_index() | BIO_TYPE_SOURCE_SINK, name);
+ if (comptime create__) |create_| {
+ std.debug.assert(BIO_meth_set_create(method, create_) > 0);
+ }
+ if (comptime destroy__) |destroy_| {
+ std.debug.assert(BIO_meth_set_destroy(method, destroy_) > 0);
+ }
+ if (comptime write__) |write_| {
+ std.debug.assert(BIO_meth_set_write(method, write_) > 0);
+ }
+ if (comptime read__) |read_| {
+ std.debug.assert(BIO_meth_set_read(method, read_) > 0);
+ }
+ if (comptime gets__) |gets_| {
+ std.debug.assert(BIO_meth_set_gets(method, gets_) > 0);
+ }
+ if (comptime ctrl__) |ctrl_| {
+ std.debug.assert(BIO_meth_set_ctrl(method, ctrl_) > 0);
+ }
+
+ return method;
+ }
+};
diff --git a/src/deps/boringssl.zig b/src/deps/boringssl.zig
new file mode 100644
index 000000000..5d0fbfe3c
--- /dev/null
+++ b/src/deps/boringssl.zig
@@ -0,0 +1,47 @@
+const boring = @import("./boringssl.translated.zig");
+pub usingnamespace boring;
+const std = @import("std");
+
+var loaded = false;
+pub fn load() void {
+ if (loaded) return;
+ loaded = true;
+ boring.CRYPTO_library_init();
+ std.debug.assert(boring.SSL_library_init() > 0);
+ boring.SSL_load_error_strings();
+ boring.ERR_load_BIO_strings();
+ boring.OpenSSL_add_all_algorithms();
+}
+
+var ctx_: ?*boring.SSL_CTX = null;
+pub fn initClient() *boring.SSL {
+ if (ctx_ != null) _ = boring.SSL_CTX_up_ref(ctx_.?);
+
+ var ctx = ctx_ orelse brk: {
+ ctx_ = boring.SSL_CTX.init().?;
+ break :brk ctx_.?;
+ };
+
+ var ssl = boring.SSL.init(ctx);
+ ssl.setIsClient(true);
+
+ return ssl;
+}
+
+pub const ReadOnlyBio = struct {
+ bio: *boring.BIO,
+
+ pub fn init(slice: []const u8) ReadOnlyBio {
+ var bio = boring.BIO_new_mem_buf(slice.ptr, @intCast(c_int, slice.len));
+ BIO_set_mem_eof_return(bio, -1);
+ return ReadOnlyBio{ .bio = bio };
+ }
+
+ pub fn deinit(this: *ReadOnlyBio) void {
+ _ = boring.BIO_free(this.bio);
+ }
+};
+
+test "load" {
+ load();
+}
diff --git a/src/deps/mimalloc b/src/deps/mimalloc
-Subproject 076f815cece59e0a0ee08237c8fbba75465452b
+Subproject 0560fc27c08d28d523b7f741a42deb26cd01c0c
diff --git a/src/deps/s2n-tls b/src/deps/s2n-tls
deleted file mode 160000
-Subproject eb59b83674119bc14c7e1fb48b95bd666bf4fd0
diff --git a/src/env.zig b/src/env.zig
index a24baa00b..bdf3c2ae7 100644
--- a/src/env.zig
+++ b/src/env.zig
@@ -22,5 +22,7 @@ pub const isRelease = std.builtin.Mode.Debug != std.builtin.mode and !isTest;
pub const isTest = std.builtin.is_test;
pub const isLinux = std.Target.current.os.tag == .linux;
pub const isAarch64 = std.Target.current.cpu.arch.isAARCH64();
-
+pub const isX86 = std.Target.current.cpu.arch.isX86();
+pub const isX64 = std.Target.current.cpu.arch == .x86_64;
+pub const allow_assert = isDebug or isTest;
pub const analytics_url = if (isDebug) "http://localhost:4000/events" else "http://i.bun.sh/events";
diff --git a/src/fallback.version b/src/fallback.version
index 23bd52db7..74aeaab27 100644
--- a/src/fallback.version
+++ b/src/fallback.version
@@ -1 +1 @@
-796022f759787f0a \ No newline at end of file
+2bbe5942da63d2ba \ No newline at end of file
diff --git a/src/fs.zig b/src/fs.zig
index 9c8a0b6d3..af32745cf 100644
--- a/src/fs.zig
+++ b/src/fs.zig
@@ -499,9 +499,13 @@ pub const FileSystem = struct {
};
pub var tmpdir_path: []const u8 = undefined;
+ pub var tmpdir_path_set = false;
pub fn openTmpDir(fs: *const RealFS) !std.fs.Dir {
- var tmpdir_base = std.os.getenv("TMPDIR") orelse PLATFORM_TMP_DIR;
- tmpdir_path = try std.fs.realpath(tmpdir_base, &tmpdir_buf);
+ if (!tmpdir_path_set) {
+ tmpdir_path = std.os.getenv("TMPDIR") orelse PLATFORM_TMP_DIR;
+ tmpdir_path_set = true;
+ }
+
return try std.fs.openDirAbsolute(tmpdir_path, .{ .access_sub_paths = true, .iterate = true });
}
@@ -998,10 +1002,11 @@ pub const FileSystem = struct {
// doNotCacheEntries bool
};
- pub const Implementation = switch (build_target) {
- .wasi, .native => RealFS,
- .wasm => WasmFS,
- };
+ pub const Implementation = RealFS;
+ // pub const Implementation = switch (build_target) {
+ // .wasi, .native => RealFS,
+ // .wasm => WasmFS,
+ // };
};
pub const Directory = struct { path: Path, contents: []string };
@@ -1260,5 +1265,3 @@ test "PathName.init" {
try std.testing.expectEqualStrings(res.base, "file");
try std.testing.expectEqualStrings(res.ext, ".ext");
}
-
-test {}
diff --git a/src/global.zig b/src/global.zig
index 5d2370b53..08cc77fab 100644
--- a/src/global.zig
+++ b/src/global.zig
@@ -1,7 +1,7 @@
const std = @import("std");
pub const Environment = @import("env.zig");
-const use_mimalloc = !Environment.isTest and Environment.isNative;
+const use_mimalloc = !Environment.isTest;
pub const default_allocator: *std.mem.Allocator = if (!use_mimalloc)
std.heap.c_allocator
@@ -24,6 +24,14 @@ pub const Output = struct {
var stderr_stream: Source.StreamType = undefined;
var stdout_stream: Source.StreamType = undefined;
var stdout_stream_set = false;
+
+ pub var terminal_size: std.os.winsize = .{
+ .ws_row = 0,
+ .ws_col = 0,
+ .ws_xpixel = 0,
+ .ws_ypixel = 0,
+ };
+
pub const Source = struct {
pub const StreamType: type = brk: {
if (isWasm) {
@@ -48,7 +56,16 @@ pub const Output = struct {
stream: StreamType,
err: StreamType,
) Source {
+ if (comptime Environment.isDebug) {
+ if (comptime use_mimalloc) {
+ if (!source_set) {
+ const Mimalloc = @import("./allocators/mimalloc.zig");
+ Mimalloc.mi_option_set(.show_errors, 1);
+ }
+ }
+ }
source_set = true;
+
return Source{
.stream = stream,
.error_stream = err,
@@ -58,6 +75,7 @@ pub const Output = struct {
}
pub fn configureThread() void {
+ if (source_set) return;
std.debug.assert(stdout_stream_set);
source = Source.init(stdout_stream, stderr_stream);
}
@@ -74,6 +92,10 @@ pub const Output = struct {
is_stdout_piped = !_source.stream.isTty();
is_stderr_piped = !_source.error_stream.isTty();
+ if (!is_stderr_piped) {
+ // _ = std.c.ioctl(source.error_stream.handle, std.os.TIOCGWINSZ, &terminal_size);
+ }
+
stdout_stream = _source.stream;
stderr_stream = _source.error_stream;
}
@@ -108,6 +130,14 @@ pub const Output = struct {
enable_buffering = false;
}
+ pub fn panic(comptime fmt: string, args: anytype) noreturn {
+ if (Output.isEmojiEnabled()) {
+ std.debug.panic(comptime Output.prettyFmt(fmt, true), args);
+ } else {
+ std.debug.panic(comptime Output.prettyFmt(fmt, false), args);
+ }
+ }
+
pub const WriterType: type = @typeInfo(std.meta.declarationInfo(Source.StreamType, "writer").data.Fn.fn_type).Fn.return_type.?;
pub fn errorWriter() WriterType {
@@ -134,22 +164,52 @@ pub const Output = struct {
}
}
- pub fn printElapsed(elapsed: f64) void {
+ inline fn printElapsedToWithCtx(elapsed: f64, comptime printerFn: anytype, comptime has_ctx: bool, ctx: anytype) void {
switch (elapsed) {
0...1500 => {
- Output.prettyError("<r><d>[<b>{d:>.2}ms<r><d>]<r>", .{elapsed});
+ const fmt = "<r><d>[<b>{d:>.2}ms<r><d>]<r>";
+ const args = .{elapsed};
+ if (comptime has_ctx) {
+ printerFn(ctx, fmt, args);
+ } else {
+ printerFn(fmt, args);
+ }
},
else => {
- Output.prettyError("<r><d>[<b>{d:>.2}s<r><d>]<r>", .{elapsed / 1000.0});
+ const fmt = "<r><d>[<b>{d:>.2}s<r><d>]<r>";
+ const args = .{elapsed / 1000.0};
+
+ if (comptime has_ctx) {
+ printerFn(ctx, fmt, args);
+ } else {
+ printerFn(fmt, args);
+ }
},
}
}
+ pub fn printElapsedTo(elapsed: f64, comptime printerFn: anytype, ctx: anytype) void {
+ printElapsedToWithCtx(elapsed, printerFn, true, ctx);
+ }
+
+ pub fn printElapsed(elapsed: f64) void {
+ printElapsedToWithCtx(elapsed, Output.prettyError, false, void{});
+ }
+
+ pub fn printElapsedStdout(elapsed: f64) void {
+ printElapsedToWithCtx(elapsed, Output.pretty, false, void{});
+ }
+
pub fn printStartEnd(start: i128, end: i128) void {
const elapsed = @divTrunc(end - start, @as(i128, std.time.ns_per_ms));
printElapsed(@intToFloat(f64, elapsed));
}
+ pub fn printStartEndStdout(start: i128, end: i128) void {
+ const elapsed = @divTrunc(end - start, @as(i128, std.time.ns_per_ms));
+ printElapsedStdout(@intToFloat(f64, elapsed));
+ }
+
pub fn printTimer(timer: *std.time.Timer) void {
const elapsed = @divTrunc(timer.read(), @as(u64, std.time.ns_per_ms));
printElapsed(@intToFloat(f64, elapsed));
@@ -326,6 +386,14 @@ pub const Output = struct {
}
}
+ pub fn prettyWithPrinterFn(comptime fmt: string, args: anytype, comptime printFn: anytype, ctx: anytype) void {
+ if (enable_ansi_colors) {
+ printFn(ctx, comptime prettyFmt(fmt, true), args);
+ } else {
+ printFn(ctx, comptime prettyFmt(fmt, false), args);
+ }
+ }
+
pub fn pretty(comptime fmt: string, args: anytype) void {
prettyWithPrinter(fmt, args, print, .Error);
}
@@ -414,6 +482,13 @@ pub const Global = struct {
long_running: bool = false,
};
+ pub inline fn mimalloc_cleanup() void {
+ if (comptime use_mimalloc) {
+ const Mimalloc = @import("./allocators/mimalloc.zig");
+ Mimalloc.mi_collect(false);
+ }
+ }
+
// Enabling huge pages slows down Bun by 8x or so
// Keeping this code for:
// 1. documentation that an attempt was made
diff --git a/src/http.zig b/src/http.zig
index 4f978d44d..11c3d4077 100644
--- a/src/http.zig
+++ b/src/http.zig
@@ -1159,7 +1159,7 @@ pub const RequestContext = struct {
handler.handleJSError(.configure_defines, err) catch {};
return;
};
-
+
var entry_point = boot;
if (!std.fs.path.isAbsolute(entry_point)) {
const resolved_entry_point = vm.bundler.resolver.resolve(
@@ -1258,6 +1258,7 @@ pub const RequestContext = struct {
var __arena: std.heap.ArenaAllocator = undefined;
pub fn runLoop(vm: *JavaScript.VirtualMachine, thread: *HandlerThread) !void {
var module_map = ZigGlobalObject.getModuleRegistryMap(vm.global);
+
if (!VM.isJITEnabled()) {
Output.prettyErrorln("<red><r>warn:<r> JIT is disabled,,,this is a bug in Bun and/or a permissions problem. JS will run slower.", .{});
if (vm.bundler.env.map.get("BUN_CRASH_WITHOUT_JIT") != null) {
@@ -1269,6 +1270,7 @@ pub const RequestContext = struct {
__arena = std.heap.ArenaAllocator.init(vm.allocator);
JavaScript.VirtualMachine.vm.arena = &__arena;
JavaScript.VirtualMachine.vm.has_loaded = true;
+ JavaScript.VirtualMachine.vm.tick();
defer {
JavaScript.VirtualMachine.vm.flush();
std.debug.assert(
@@ -1284,6 +1286,7 @@ pub const RequestContext = struct {
}
var handler: *JavaScriptHandler = try channel.readItem();
+ JavaScript.VirtualMachine.vm.tick();
JavaScript.VirtualMachine.vm.preflush();
@@ -1294,6 +1297,7 @@ pub const RequestContext = struct {
thread,
HandlerThread.handleFetchEventError,
) catch |err| {};
+ JavaScript.VirtualMachine.vm.tick();
}
}
@@ -1540,7 +1544,7 @@ pub const RequestContext = struct {
ctx.appendHeader("Sec-WebSocket-Protocol", "bun-hmr");
try ctx.writeStatus(101);
try ctx.flushHeaders();
- // Output.prettyln("<r><green>101<r><d> Hot Module Reloading connected.<r>", .{});
+ // Output.prettyErrorln("<r><green>101<r><d> Hot Module Reloading connected.<r>", .{});
// Output.flush();
Analytics.Features.hot_module_reloading = true;
@@ -1591,7 +1595,7 @@ pub const RequestContext = struct {
var frame = handler.websocket.read() catch |err| {
switch (err) {
error.ConnectionClosed => {
- // Output.prettyln("Websocket closed.", .{});
+ // Output.prettyErrorln("Websocket closed.", .{});
handler.tombstone = true;
is_socket_closed = true;
continue;
@@ -1604,7 +1608,7 @@ pub const RequestContext = struct {
};
switch (frame.header.opcode) {
.Close => {
- // Output.prettyln("Websocket closed.", .{});
+ // Output.prettyErrorln("Websocket closed.", .{});
is_socket_closed = true;
return;
},
@@ -1639,7 +1643,7 @@ pub const RequestContext = struct {
},
.success => {
if (build_result.timestamp > cmd.timestamp) {
- Output.prettyln(
+ Output.prettyErrorln(
"<r><b><green>{d}ms<r> <d>built<r> <b>{s}<r><b> <r><d>({d}+ LOC)",
.{
build_result.timestamp - cmd.timestamp,
@@ -1876,6 +1880,12 @@ pub const RequestContext = struct {
return;
}
+ // Failed experiment: inject "Link" tags for each import path
+ // Browsers ignore this header when it's coming from a script import.
+ // In Chrome, the header appears in the Network tab but doesn't seem to do anything
+ // In Firefox,the header does not appear in the Network tab.
+ // Safari was not tested
+
if (FeatureFlags.strong_etags_for_built_files) {
// Always cache css & json files, even big ones
// css is especially important because we want to try and skip having the browser parse it whenever we can
@@ -2553,7 +2563,7 @@ pub const Server = struct {
);
if (comptime FeatureFlags.verbose_watcher) {
- Output.prettyln("<r><d>File changed: {s}<r>", .{ctx.bundler.fs.relativeTo(file_path)});
+ Output.prettyErrorln("<r><d>File changed: {s}<r>", .{ctx.bundler.fs.relativeTo(file_path)});
}
} else {
const change_message = Api.WebsocketMessageFileChangeNotification{
@@ -2566,12 +2576,12 @@ pub const Server = struct {
const change_buf = content_fbs.getWritten();
const written_buf = filechange_buf[0 .. header.len + change_buf.len];
RequestContext.WebsocketHandler.broadcast(written_buf) catch |err| {
- Output.prettyln("Error writing change notification: {s}<r>", .{@errorName(err)});
+ Output.prettyErrorln("Error writing change notification: {s}<r>", .{@errorName(err)});
};
if (comptime is_emoji_enabled) {
- Output.prettyln("<r>📜 <d>File change: {s}<r>", .{ctx.bundler.fs.relativeTo(file_path)});
+ Output.prettyErrorln("<r>📜 <d>File change: {s}<r>", .{ctx.bundler.fs.relativeTo(file_path)});
} else {
- Output.prettyln("<r> <d>File change: {s}<r>", .{ctx.bundler.fs.relativeTo(file_path)});
+ Output.prettyErrorln("<r> <d>File change: {s}<r>", .{ctx.bundler.fs.relativeTo(file_path)});
}
}
},
@@ -2583,9 +2593,9 @@ pub const Server = struct {
// ctx.watcher.removeAtIndex(event.index, hashes[event.index], parent_hashes, .directory);
if (comptime is_emoji_enabled) {
- Output.prettyln("<r>📁 <d>Dir change: {s}<r>", .{ctx.bundler.fs.relativeTo(file_path)});
+ Output.prettyErrorln("<r>📁 <d>Dir change: {s}<r>", .{ctx.bundler.fs.relativeTo(file_path)});
} else {
- Output.prettyln("<r> <d>Dir change: {s}<r>", .{ctx.bundler.fs.relativeTo(file_path)});
+ Output.prettyErrorln("<r> <d>Dir change: {s}<r>", .{ctx.bundler.fs.relativeTo(file_path)});
}
},
}
@@ -2839,13 +2849,13 @@ pub const Server = struct {
200, 304, 101 => {},
201...303, 305...399 => {
- Output.prettyln("<r><green>{d}<r><d> {s} <r>{s}<d> as {s}<r>", .{ status, @tagName(req_ctx.method), req.path, req_ctx.mime_type.value });
+ Output.prettyErrorln("<r><green>{d}<r><d> {s} <r>{s}<d> as {s}<r>", .{ status, @tagName(req_ctx.method), req.path, req_ctx.mime_type.value });
},
400...499 => {
- Output.prettyln("<r><yellow>{d}<r><d> {s} <r>{s}<d> as {s}<r>", .{ status, @tagName(req_ctx.method), req.path, req_ctx.mime_type.value });
+ Output.prettyErrorln("<r><yellow>{d}<r><d> {s} <r>{s}<d> as {s}<r>", .{ status, @tagName(req_ctx.method), req.path, req_ctx.mime_type.value });
},
else => {
- Output.prettyln("<r><red>{d}<r><d> {s} <r>{s}<d> as {s}<r>", .{ status, @tagName(req_ctx.method), req.path, req_ctx.mime_type.value });
+ Output.prettyErrorln("<r><red>{d}<r><d> {s} <r>{s}<d> as {s}<r>", .{ status, @tagName(req_ctx.method), req.path, req_ctx.mime_type.value });
},
}
}
@@ -2861,13 +2871,13 @@ pub const Server = struct {
200, 304, 101 => {},
201...303, 305...399 => {
- Output.prettyln("<r><green>{d}<r><d> <r>{s}<d> {s} as {s}<r>", .{ status, @tagName(req_ctx.method), req.path, req_ctx.mime_type.value });
+ Output.prettyErrorln("<r><green>{d}<r><d> <r>{s}<d> {s} as {s}<r>", .{ status, @tagName(req_ctx.method), req.path, req_ctx.mime_type.value });
},
400...499 => {
- Output.prettyln("<r><yellow>{d}<r><d> <r>{s}<d> {s} as {s}<r>", .{ status, @tagName(req_ctx.method), req.path, req_ctx.mime_type.value });
+ Output.prettyErrorln("<r><yellow>{d}<r><d> <r>{s}<d> {s} as {s}<r>", .{ status, @tagName(req_ctx.method), req.path, req_ctx.mime_type.value });
},
else => {
- Output.prettyln("<r><red>{d}<r><d> <r>{s}<d> {s} as {s}<r>", .{ status, @tagName(req_ctx.method), req.path, req_ctx.mime_type.value });
+ Output.prettyErrorln("<r><red>{d}<r><d> <r>{s}<d> {s} as {s}<r>", .{ status, @tagName(req_ctx.method), req.path, req_ctx.mime_type.value });
},
}
}
diff --git a/src/http/network_thread.zig b/src/http/network_thread.zig
new file mode 100644
index 000000000..d3826dcb3
--- /dev/null
+++ b/src/http/network_thread.zig
@@ -0,0 +1,82 @@
+const ThreadPool = @import("thread_pool");
+pub const Batch = ThreadPool.Batch;
+pub const Task = ThreadPool.Task;
+const std = @import("std");
+const AsyncIO = @import("io");
+
+const NetworkThread = @This();
+
+/// Single-thread in this pool
+pool: ThreadPool,
+
+pub var global: NetworkThread = undefined;
+pub var global_loaded: std.atomic.Atomic(u32) = std.atomic.Atomic(u32).init(0);
+
+const CachedAddressList = struct {
+ address_list: *std.net.AddressList,
+ expire_after: u64,
+ key: u64,
+ index: ?u32 = null,
+ pub fn hash(name: []const u8, port: u16) u64 {
+ var hasher = std.hash.Wyhash.init(0);
+ hasher.update(name);
+ hasher.update(":");
+ hasher.update(std.mem.asBytes(&port));
+ return hasher.final();
+ }
+
+ pub fn init(key: u64, address_list: *std.net.AddressList, now: u64) CachedAddressList {
+ return CachedAddressList{
+ .address_list = address_list,
+ .expire_after = now + std.time.ms_per_hour,
+ .key = key,
+ };
+ }
+
+ pub fn invalidate(this: *CachedAddressList) void {
+ this.address_list.deinit();
+ _ = address_list_cached.remove(this.key);
+ }
+};
+
+const IdentityContext = struct {
+ pub fn eql(this: @This(), a: u64, b: u64) bool {
+ return a == b;
+ }
+
+ pub fn hash(this: @This(), a: u64) u64 {
+ return a;
+ }
+};
+
+const AddressListCache = std.HashMap(u64, CachedAddressList, IdentityContext, 80);
+var address_list_cached: AddressListCache = undefined;
+pub fn getAddressList(allocator: *std.mem.Allocator, name: []const u8, port: u16) !*CachedAddressList {
+ const hash = CachedAddressList.hash(name, port);
+ const now = @intCast(u64, @maximum(0, std.time.milliTimestamp()));
+ if (address_list_cached.getPtr(hash)) |cached| {
+ if (cached.expire_after > now) {
+ return cached;
+ }
+
+ cached.address_list.deinit();
+ }
+
+ const address_list = try std.net.getAddressList(allocator, name, port);
+ var entry = try address_list_cached.getOrPut(hash);
+ entry.value_ptr.* = CachedAddressList.init(hash, address_list, now);
+ return entry.value_ptr;
+}
+
+pub fn init() !void {
+ if ((global_loaded.swap(1, .Monotonic)) == 1) return;
+ AsyncIO.global_loaded = true;
+ AsyncIO.global = try AsyncIO.init(1024, 0);
+
+ global = NetworkThread{
+ .pool = ThreadPool.init(.{ .max_threads = 1, .stack_size = 64 * 1024 * 1024 }),
+ };
+
+ global.pool.io = &AsyncIO.global;
+ address_list_cached = AddressListCache.init(@import("../global.zig").default_allocator);
+}
diff --git a/src/http_client.zig b/src/http_client.zig
deleted file mode 100644
index 560bd0797..000000000
--- a/src/http_client.zig
+++ /dev/null
@@ -1,870 +0,0 @@
-// @link "/Users/jarred/Code/bun/src/deps/zlib/libz.a"
-
-const picohttp = @import("./deps/picohttp.zig");
-usingnamespace @import("./global.zig");
-const std = @import("std");
-const Headers = @import("./javascript/jsc/webcore/response.zig").Headers;
-const URL = @import("./query_string_map.zig").URL;
-const Method = @import("./http/method.zig").Method;
-const Api = @import("./api/schema.zig").Api;
-const Lock = @import("./lock.zig").Lock;
-const HTTPClient = @This();
-const SOCKET_FLAGS = os.SOCK_CLOEXEC;
-const S2n = @import("./s2n.zig");
-const Zlib = @import("./zlib.zig");
-
-fn writeRequest(
- comptime Writer: type,
- writer: Writer,
- request: picohttp.Request,
- body: string,
- // header_hashes: []u64,
-) !void {
- try writer.writeAll(request.method);
- try writer.writeAll(" ");
- try writer.writeAll(request.path);
- try writer.writeAll(" HTTP/1.1\r\n");
-
- for (request.headers) |header, i| {
- try writer.writeAll(header.name);
- try writer.writeAll(": ");
- try writer.writeAll(header.value);
- try writer.writeAll("\r\n");
- }
-}
-
-method: Method,
-header_entries: Headers.Entries,
-header_buf: string,
-url: URL,
-allocator: *std.mem.Allocator,
-verbose: bool = isTest,
-tcp_client: tcp.Client = undefined,
-body_size: u32 = 0,
-read_count: u32 = 0,
-remaining_redirect_count: i8 = 127,
-redirect_buf: [2048]u8 = undefined,
-disable_shutdown: bool = true,
-timeout: u32 = 0,
-progress_node: ?*std.Progress.Node = null,
-
-pub fn init(allocator: *std.mem.Allocator, method: Method, url: URL, header_entries: Headers.Entries, header_buf: string) HTTPClient {
- return HTTPClient{
- .allocator = allocator,
- .method = method,
- .url = url,
- .header_entries = header_entries,
- .header_buf = header_buf,
- };
-}
-
-threadlocal var response_headers_buf: [256]picohttp.Header = undefined;
-threadlocal var request_headers_buf: [256]picohttp.Header = undefined;
-threadlocal var request_content_len_buf: [64]u8 = undefined;
-threadlocal var header_name_hashes: [256]u64 = undefined;
-// threadlocal var resolver_cache
-const tcp = std.x.net.tcp;
-const ip = std.x.net.ip;
-
-const IPv4 = std.x.os.IPv4;
-const IPv6 = std.x.os.IPv6;
-const Socket = std.x.os.Socket;
-const os = std.os;
-
-// lowercase hash header names so that we can be sure
-fn hashHeaderName(name: string) u64 {
- var hasher = std.hash.Wyhash.init(0);
- var remain: string = name;
- var buf: [32]u8 = undefined;
- var buf_slice: []u8 = std.mem.span(&buf);
-
- while (remain.len > 0) {
- var end = std.math.min(hasher.buf.len, remain.len);
-
- hasher.update(strings.copyLowercase(std.mem.span(remain[0..end]), buf_slice));
- remain = remain[end..];
- }
- return hasher.final();
-}
-
-const host_header_hash = hashHeaderName("Host");
-const connection_header_hash = hashHeaderName("Connection");
-
-pub const Encoding = enum {
- identity,
- gzip,
- deflate,
- brotli,
- chunked,
-};
-
-const content_encoding_hash = hashHeaderName("Content-Encoding");
-const transfer_encoding_header = hashHeaderName("Transfer-Encoding");
-
-const host_header_name = "Host";
-const content_length_header_name = "Content-Length";
-const content_length_header_hash = hashHeaderName("Content-Length");
-const connection_header = picohttp.Header{ .name = "Connection", .value = "close" };
-const accept_header = picohttp.Header{ .name = "Accept", .value = "*/*" };
-const accept_header_hash = hashHeaderName("Accept");
-
-const accept_encoding_no_compression = "identity";
-const accept_encoding_compression = "deflate, gzip";
-const accept_encoding_header_compression = picohttp.Header{ .name = "Accept-Encoding", .value = accept_encoding_compression };
-const accept_encoding_header_no_compression = picohttp.Header{ .name = "Accept-Encoding", .value = accept_encoding_no_compression };
-
-const accept_encoding_header = if (FeatureFlags.disable_compression_in_http_client)
- accept_encoding_header_no_compression
-else
- accept_encoding_header_compression;
-
-const accept_encoding_header_hash = hashHeaderName("Accept-Encoding");
-
-const user_agent_header = picohttp.Header{ .name = "User-Agent", .value = "Bun.js " ++ Global.package_json_version };
-const user_agent_header_hash = hashHeaderName("User-Agent");
-const location_header_hash = hashHeaderName("Location");
-
-pub fn headerStr(this: *const HTTPClient, ptr: Api.StringPointer) string {
- return this.header_buf[ptr.offset..][0..ptr.length];
-}
-
-threadlocal var server_name_buf: [1024]u8 = undefined;
-
-pub fn buildRequest(this: *const HTTPClient, body_len: usize) picohttp.Request {
- var header_count: usize = 0;
- var header_entries = this.header_entries.slice();
- var header_names = header_entries.items(.name);
- var header_values = header_entries.items(.value);
-
- var override_accept_encoding = false;
-
- var override_user_agent = false;
- for (header_names) |head, i| {
- const name = this.headerStr(head);
- // Hash it as lowercase
- const hash = hashHeaderName(name);
-
- // Skip host and connection header
- // we manage those
- switch (hash) {
- host_header_hash,
- connection_header_hash,
- content_length_header_hash,
- => continue,
- else => {},
- }
-
- override_user_agent = override_user_agent or hash == user_agent_header_hash;
-
- override_accept_encoding = override_accept_encoding or hash == accept_encoding_header_hash;
-
- request_headers_buf[header_count] = picohttp.Header{
- .name = name,
- .value = this.headerStr(header_values[i]),
- };
-
- // header_name_hashes[header_count] = hash;
-
- // // ensure duplicate headers come after each other
- // if (header_count > 2) {
- // var head_i: usize = header_count - 1;
- // while (head_i > 0) : (head_i -= 1) {
- // if (header_name_hashes[head_i] == header_name_hashes[header_count]) {
- // std.mem.swap(picohttp.Header, &header_name_hashes[header_count], &header_name_hashes[head_i + 1]);
- // std.mem.swap(u64, &request_headers_buf[header_count], &request_headers_buf[head_i + 1]);
- // break;
- // }
- // }
- // }
- header_count += 1;
- }
-
- // request_headers_buf[header_count] = connection_header;
- // header_count += 1;
-
- if (!override_user_agent) {
- request_headers_buf[header_count] = user_agent_header;
- header_count += 1;
- }
-
- request_headers_buf[header_count] = accept_header;
- header_count += 1;
-
- request_headers_buf[header_count] = picohttp.Header{
- .name = host_header_name,
- .value = this.url.hostname,
- };
- header_count += 1;
-
- if (!override_accept_encoding) {
- request_headers_buf[header_count] = accept_encoding_header;
- header_count += 1;
- }
-
- if (body_len > 0) {
- request_headers_buf[header_count] = picohttp.Header{
- .name = content_length_header_name,
- .value = std.fmt.bufPrint(&request_content_len_buf, "{d}", .{body_len}) catch "0",
- };
- header_count += 1;
- }
-
- return picohttp.Request{
- .method = @tagName(this.method),
- .path = this.url.pathname,
- .minor_version = 1,
- .headers = request_headers_buf[0..header_count],
- };
-}
-
-pub fn connect(
- this: *HTTPClient,
-) !tcp.Client {
- var client: tcp.Client = try tcp.Client.init(tcp.Domain.ip, .{ .close_on_exec = true });
- const port = this.url.getPortAuto();
- client.setNoDelay(true) catch {};
- client.setReadBufferSize(http_req_buf.len) catch {};
- client.setQuickACK(true) catch {};
-
- if (this.timeout > 0) {
- client.setReadTimeout(this.timeout) catch {};
- client.setWriteTimeout(this.timeout) catch {};
- }
-
- // if (this.url.isLocalhost()) {
- // try client.connect(
- // try std.x.os.Socket.Address.initIPv4(try std.net.Address.resolveIp("localhost", port), port),
- // );
- // } else {
- // } else if (this.url.isDomainName()) {
- var stream = try std.net.tcpConnectToHost(default_allocator, this.url.hostname, port);
- client.socket = std.x.os.Socket.from(stream.handle);
-
- // }
- // } else if (this.url.getIPv4Address()) |ip_addr| {
- // try client.connect(std.x.os.Socket.Address(ip_addr, port));
- // } else if (this.url.getIPv6Address()) |ip_addr| {
- // try client.connect(std.x.os.Socket.Address.initIPv6(ip_addr, port));
- // } else {
- // return error.MissingHostname;
- // }
-
- return client;
-}
-
-threadlocal var http_req_buf: [65436]u8 = undefined;
-
-pub fn send(this: *HTTPClient, body: []const u8, body_out_str: *MutableString) !picohttp.Response {
- // this prevents stack overflow
- redirect: while (this.remaining_redirect_count >= -1) {
- if (this.url.isHTTPS()) {
- return this.sendHTTPS(body, body_out_str) catch |err| {
- switch (err) {
- error.Redirect => {
- this.remaining_redirect_count -= 1;
- continue :redirect;
- },
- else => return err,
- }
- };
- } else {
- return this.sendHTTP(body, body_out_str) catch |err| {
- switch (err) {
- error.Redirect => {
- this.remaining_redirect_count -= 1;
- continue :redirect;
- },
- else => return err,
- }
- };
- }
- }
-
- return error.TooManyRedirects;
-}
-
-pub fn sendHTTP(this: *HTTPClient, body: []const u8, body_out_str: *MutableString) !picohttp.Response {
- this.tcp_client = try this.connect();
- defer std.os.closeSocket(this.tcp_client.socket.fd);
- var request = buildRequest(this, body.len);
- if (this.verbose) {
- Output.prettyErrorln("{s}", .{request});
- }
- var client_writer = this.tcp_client.writer(SOCKET_FLAGS);
- {
- var client_writer_buffered = std.io.bufferedWriter(client_writer);
- var client_writer_buffered_writer = client_writer_buffered.writer();
-
- try writeRequest(@TypeOf(&client_writer_buffered_writer), &client_writer_buffered_writer, request, body);
- try client_writer_buffered_writer.writeAll("\r\n");
- try client_writer_buffered.flush();
- }
-
- if (body.len > 0) {
- try client_writer.writeAll(body);
- }
-
- var client_reader = this.tcp_client.reader(SOCKET_FLAGS);
-
- if (this.progress_node == null) {
- return this.processResponse(
- false,
- false,
- @TypeOf(client_reader),
- client_reader,
- body_out_str,
- );
- } else {
- return this.processResponse(
- false,
- true,
- @TypeOf(client_reader),
- client_reader,
- body_out_str,
- );
- }
-}
-
-const ZlibPool = struct {
- lock: Lock = Lock.init(),
- items: std.ArrayList(*MutableString),
- allocator: *std.mem.Allocator,
- pub var instance: ZlibPool = undefined;
- pub var loaded: bool = false;
-
- pub fn init(allocator: *std.mem.Allocator) ZlibPool {
- return ZlibPool{
- .allocator = allocator,
- .items = std.ArrayList(*MutableString).init(allocator),
- };
- }
-
- pub fn get(this: *ZlibPool) !*MutableString {
- this.lock.lock();
- defer this.lock.unlock();
- switch (this.items.items.len) {
- 0 => {
- var mutable = try this.allocator.create(MutableString);
- mutable.* = try MutableString.init(this.allocator, 0);
- return mutable;
- },
- else => {
- return this.items.pop();
- },
- }
-
- return item;
- }
-
- pub fn put(this: *ZlibPool, mutable: *MutableString) !void {
- this.lock.lock();
- defer this.lock.unlock();
- mutable.reset();
- try this.items.append(mutable);
- }
-};
-
-pub fn processResponse(this: *HTTPClient, comptime is_https: bool, comptime report_progress: bool, comptime Client: type, client: Client, body_out_str: *MutableString) !picohttp.Response {
- var response: picohttp.Response = undefined;
- var read_length: usize = 0;
- {
- var read_headers_up_to: usize = 0;
-
- var req_buf_read: usize = std.math.maxInt(usize);
- defer this.read_count += @intCast(u32, read_length);
-
- restart: while (req_buf_read != 0) {
- req_buf_read = try client.read(http_req_buf[read_length..]);
- read_length += req_buf_read;
- if (comptime report_progress) {
- this.progress_node.?.activate();
- this.progress_node.?.setCompletedItems(read_length);
- this.progress_node.?.context.maybeRefresh();
- }
-
- var request_buffer = http_req_buf[0..read_length];
- read_headers_up_to = if (read_headers_up_to > read_length) read_length else read_headers_up_to;
-
- response = picohttp.Response.parseParts(request_buffer, &response_headers_buf, &read_headers_up_to) catch |err| {
- switch (err) {
- error.ShortRead => {
- continue :restart;
- },
- else => {
- return err;
- },
- }
- };
- break :restart;
- }
- }
-
- body_out_str.reset();
- var content_length: u32 = 0;
- var encoding = Encoding.identity;
- var transfer_encoding = Encoding.identity;
-
- var location: string = "";
-
- if (this.verbose) {
- Output.prettyErrorln("Response: {s}", .{response});
- }
-
- for (response.headers) |header| {
- switch (hashHeaderName(header.name)) {
- content_length_header_hash => {
- content_length = std.fmt.parseInt(u32, header.value, 10) catch 0;
- try body_out_str.inflate(content_length);
- body_out_str.list.expandToCapacity();
- this.body_size = content_length;
- },
- content_encoding_hash => {
- if (strings.eqlComptime(header.value, "gzip")) {
- encoding = Encoding.gzip;
- } else if (strings.eqlComptime(header.value, "deflate")) {
- encoding = Encoding.deflate;
- } else if (!strings.eqlComptime(header.value, "identity")) {
- return error.UnsupportedContentEncoding;
- }
- },
- transfer_encoding_header => {
- if (strings.eqlComptime(header.value, "gzip")) {
- transfer_encoding = Encoding.gzip;
- } else if (strings.eqlComptime(header.value, "deflate")) {
- transfer_encoding = Encoding.deflate;
- } else if (strings.eqlComptime(header.value, "identity")) {
- transfer_encoding = Encoding.identity;
- } else if (strings.eqlComptime(header.value, "chunked")) {
- transfer_encoding = Encoding.chunked;
- } else {
- return error.UnsupportedTransferEncoding;
- }
- },
- location_header_hash => {
- location = header.value;
- },
-
- else => {},
- }
- }
-
- if (location.len > 0 and this.remaining_redirect_count > 0) {
- switch (response.status_code) {
- 302, 301, 307, 308, 303 => {
- if (strings.indexOf(location, "://")) |i| {
- const protocol_name = location[0..i];
- if (strings.eqlComptime(protocol_name, "http") or strings.eqlComptime(protocol_name, "https")) {} else {
- return error.UnsupportedRedirectProtocol;
- }
-
- std.mem.copy(u8, &this.redirect_buf, location);
- this.url = URL.parse(location);
- } else {
- const original_url = this.url;
- this.url = URL.parse(std.fmt.bufPrint(
- &this.redirect_buf,
- "{s}://{s}{s}",
- .{ original_url.displayProtocol(), original_url.displayHostname(), location },
- ) catch return error.RedirectURLTooLong);
- }
-
- // https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/303
- if (response.status_code == 303) {
- this.method = .GET;
- }
-
- return error.Redirect;
- },
- else => {},
- }
- }
-
- if (transfer_encoding == Encoding.chunked) {
- var decoder = std.mem.zeroes(picohttp.phr_chunked_decoder);
- var buffer_: *MutableString = body_out_str;
-
- switch (encoding) {
- Encoding.gzip, Encoding.deflate => {
- if (!ZlibPool.loaded) {
- ZlibPool.instance = ZlibPool.init(default_allocator);
- ZlibPool.loaded = true;
- }
-
- buffer_ = try ZlibPool.instance.get();
- },
- else => {},
- }
-
- var buffer = buffer_.*;
-
- var last_read: usize = 0;
- {
- var remainder = http_req_buf[@intCast(usize, response.bytes_read)..read_length];
- last_read = remainder.len;
- try buffer.inflate(std.math.max(remainder.len, 2048));
- buffer.list.expandToCapacity();
- std.mem.copy(u8, buffer.list.items, remainder);
- }
-
- // set consume_trailer to 1 to discard the trailing header
- // using content-encoding per chunk is not supported
- decoder.consume_trailer = 1;
-
- // these variable names are terrible
- // it's copypasta from https://github.com/h2o/picohttpparser#phr_decode_chunked
- // (but ported from C -> zig)
- var rret: usize = 0;
- var rsize: usize = last_read;
- var pret: isize = picohttp.phr_decode_chunked(&decoder, buffer.list.items.ptr, &rsize);
- var total_size = rsize;
-
- while (pret == -2) {
- if (buffer.list.items[total_size..].len < @intCast(usize, decoder.bytes_left_in_chunk) or buffer.list.items[total_size..].len < 512) {
- try buffer.inflate(std.math.max(total_size * 2, 1024));
- buffer.list.expandToCapacity();
- }
-
- rret = try client.read(buffer.list.items[total_size..]);
-
- if (rret == 0) {
- return error.ChunkedEncodingError;
- }
-
- rsize = rret;
- pret = picohttp.phr_decode_chunked(&decoder, buffer.list.items[total_size..].ptr, &rsize);
- if (pret == -1) return error.ChunkedEncodingParseError;
-
- total_size += rsize;
-
- if (comptime report_progress) {
- this.progress_node.?.activate();
- this.progress_node.?.setCompletedItems(total_size);
- this.progress_node.?.context.maybeRefresh();
- }
- }
-
- buffer.list.shrinkRetainingCapacity(total_size);
- buffer_.* = buffer;
-
- switch (encoding) {
- Encoding.gzip, Encoding.deflate => {
- body_out_str.list.expandToCapacity();
- defer ZlibPool.instance.put(buffer_) catch unreachable;
- var reader = try Zlib.ZlibReaderArrayList.init(buffer.list.items, &body_out_str.list, default_allocator);
- reader.readAll() catch |err| {
- if (reader.errorMessage()) |msg| {
- Output.prettyErrorln("<r><red>Zlib error<r>: <b>{s}<r>", .{msg});
- Output.flush();
- }
- return err;
- };
- },
- else => {},
- }
-
- if (comptime report_progress) {
- this.progress_node.?.activate();
- this.progress_node.?.setCompletedItems(body_out_str.list.items.len);
- this.progress_node.?.context.maybeRefresh();
- }
-
- this.body_size = @intCast(u32, body_out_str.list.items.len);
- return response;
- }
-
- if (content_length > 0) {
- var remaining_content_length = content_length;
- var remainder = http_req_buf[@intCast(usize, response.bytes_read)..read_length];
- remainder = remainder[0..std.math.min(remainder.len, content_length)];
- var buffer_: *MutableString = body_out_str;
-
- switch (encoding) {
- Encoding.gzip, Encoding.deflate => {
- if (!ZlibPool.loaded) {
- ZlibPool.instance = ZlibPool.init(default_allocator);
- ZlibPool.loaded = true;
- }
-
- buffer_ = try ZlibPool.instance.get();
- if (buffer_.list.capacity < remaining_content_length) {
- try buffer_.list.ensureUnusedCapacity(buffer_.allocator, remaining_content_length);
- }
- buffer_.list.items = buffer_.list.items.ptr[0..remaining_content_length];
- },
- else => {},
- }
- var buffer = buffer_.*;
-
- var body_size: usize = 0;
- if (remainder.len > 0) {
- std.mem.copy(u8, buffer.list.items, remainder);
- body_size = remainder.len;
- this.read_count += @intCast(u32, body_size);
- remaining_content_length -= @intCast(u32, remainder.len);
- }
-
- while (remaining_content_length > 0) {
- const size = @intCast(u32, try client.read(
- buffer.list.items[body_size..],
- ));
- this.read_count += size;
- if (size == 0) break;
-
- body_size += size;
- remaining_content_length -= size;
-
- if (comptime report_progress) {
- this.progress_node.?.activate();
- this.progress_node.?.setCompletedItems(body_size);
- this.progress_node.?.context.maybeRefresh();
- }
- }
-
- if (comptime report_progress) {
- this.progress_node.?.activate();
- this.progress_node.?.setCompletedItems(body_size);
- this.progress_node.?.context.maybeRefresh();
- }
-
- buffer.list.shrinkRetainingCapacity(body_size);
- buffer_.* = buffer;
-
- switch (encoding) {
- Encoding.gzip, Encoding.deflate => {
- body_out_str.list.expandToCapacity();
- defer ZlibPool.instance.put(buffer_) catch unreachable;
- var reader = try Zlib.ZlibReaderArrayList.init(buffer.list.items, &body_out_str.list, default_allocator);
- reader.readAll() catch |err| {
- if (reader.errorMessage()) |msg| {
- Output.prettyErrorln("<r><red>Zlib error<r>: <b>{s}<r>", .{msg});
- Output.flush();
- }
- return err;
- };
- },
- else => {},
- }
- }
-
- if (comptime report_progress) {
- this.progress_node.?.activate();
- this.progress_node.?.setCompletedItems(body_out_str.list.items.len);
- this.progress_node.?.context.maybeRefresh();
- }
-
- return response;
-}
-
-pub fn sendHTTPS(this: *HTTPClient, body_str: []const u8, body_out_str: *MutableString) !picohttp.Response {
- var connection = try this.connect();
- S2n.boot(default_allocator);
- const hostname = this.url.displayHostname();
- std.mem.copy(u8, &server_name_buf, hostname);
- server_name_buf[hostname.len] = 0;
- var server_name = server_name_buf[0..hostname.len :0];
-
- var client = S2n.Connection.init(connection.socket.fd);
- try client.start(server_name);
- client.disable_shutdown = this.disable_shutdown;
- defer client.close() catch {};
-
- var request = buildRequest(this, body_str.len);
- if (this.verbose) {
- Output.prettyErrorln("{s}", .{request});
- }
- const body = body_str;
-
- var client_writer = client.writer();
- {
- var client_writer_buffered = std.io.bufferedWriter(client_writer);
- var client_writer_buffered_writer = client_writer_buffered.writer();
-
- try writeRequest(@TypeOf(&client_writer_buffered_writer), &client_writer_buffered_writer, request, body);
- try client_writer_buffered_writer.writeAll("\r\n");
- try client_writer_buffered.flush();
- }
-
- if (body.len > 0) {
- try client_writer.writeAll(body);
- }
-
- if (this.progress_node == null) {
- return try this.processResponse(true, false, @TypeOf(&client), &client, body_out_str);
- } else {
- return try this.processResponse(true, true, @TypeOf(&client), &client, body_out_str);
- }
-}
-
-// zig test src/http_client.zig --test-filter "sendHTTP - only" -lc -lc++ /Users/jarred/Code/bun/src/deps/zlib/libz.a /Users/jarred/Code/bun/src/deps/picohttpparser.o --cache-dir /Users/jarred/Code/bun/zig-cache --global-cache-dir /Users/jarred/.cache/zig --name bun --pkg-begin clap /Users/jarred/Code/bun/src/deps/zig-clap/clap.zig --pkg-end --pkg-begin picohttp /Users/jarred/Code/bun/src/deps/picohttp.zig --pkg-end --pkg-begin iguanaTLS /Users/jarred/Code/bun/src/deps/iguanaTLS/src/main.zig --pkg-end -I /Users/jarred/Code/bun/src/deps -I /Users/jarred/Code/bun/src/deps/mimalloc -I /usr/local/opt/icu4c/include -L src/deps/mimalloc -L /usr/local/opt/icu4c/lib --main-pkg-path /Users/jarred/Code/bun --enable-cache -femit-bin=zig-out/bin/test --test-no-exec
-test "sendHTTP - only" {
- Output.initTest();
- defer Output.flush();
-
- var headers = try std.heap.c_allocator.create(Headers);
- headers.* = Headers{
- .entries = @TypeOf(headers.entries){},
- .buf = @TypeOf(headers.buf){},
- .used = 0,
- .allocator = std.heap.c_allocator,
- };
-
- // headers.appendHeader("X-What", "ok", true, true, false);
- headers.appendHeader("Accept-Encoding", "identity", true, true, false);
-
- var client = HTTPClient.init(
- std.heap.c_allocator,
- .GET,
- URL.parse("http://example.com/"),
- headers.entries,
- headers.buf.items,
- );
- var body_out_str = try MutableString.init(std.heap.c_allocator, 0);
- var response = try client.sendHTTP("", &body_out_str);
- try std.testing.expectEqual(response.status_code, 200);
- try std.testing.expectEqual(body_out_str.list.items.len, 1256);
- try std.testing.expectEqualStrings(body_out_str.list.items, @embedFile("fixtures_example.com.html"));
-}
-
-// zig test src/http_client.zig --test-filter "sendHTTP - gzip" -lc -lc++ /Users/jarred/Code/bun/src/deps/zlib/libz.a /Users/jarred/Code/bun/src/deps/picohttpparser.o --cache-dir /Users/jarred/Code/bun/zig-cache --global-cache-dir /Users/jarred/.cache/zig --name bun --pkg-begin clap /Users/jarred/Code/bun/src/deps/zig-clap/clap.zig --pkg-end --pkg-begin picohttp /Users/jarred/Code/bun/src/deps/picohttp.zig --pkg-end --pkg-begin iguanaTLS /Users/jarred/Code/bun/src/deps/iguanaTLS/src/main.zig --pkg-end -I /Users/jarred/Code/bun/src/deps -I /Users/jarred/Code/bun/src/deps/mimalloc -I /usr/local/opt/icu4c/include -L src/deps/mimalloc -L /usr/local/opt/icu4c/lib --main-pkg-path /Users/jarred/Code/bun --enable-cache -femit-bin=zig-out/bin/test --test-no-exec
-test "sendHTTP - gzip" {
- Output.initTest();
- defer Output.flush();
-
- var headers = try std.heap.c_allocator.create(Headers);
- headers.* = Headers{
- .entries = @TypeOf(headers.entries){},
- .buf = @TypeOf(headers.buf){},
- .used = 0,
- .allocator = std.heap.c_allocator,
- };
-
- // headers.appendHeader("X-What", "ok", true, true, false);
- headers.appendHeader("Accept-Encoding", "gzip", true, true, false);
-
- var client = HTTPClient.init(
- std.heap.c_allocator,
- .GET,
- URL.parse("http://example.com/"),
- headers.entries,
- headers.buf.items,
- );
- var body_out_str = try MutableString.init(std.heap.c_allocator, 0);
- var response = try client.sendHTTP("", &body_out_str);
- try std.testing.expectEqual(response.status_code, 200);
- try std.testing.expectEqualStrings(body_out_str.list.items, @embedFile("fixtures_example.com.html"));
-}
-
-// zig test src/http_client.zig --test-filter "sendHTTPS - identity" -lc -lc++ /Users/jarred/Code/bun/src/deps/zlib/libz.a /Users/jarred/Code/bun/src/deps/picohttpparser.o --cache-dir /Users/jarred/Code/bun/zig-cache --global-cache-dir /Users/jarred/.cache/zig --name bun --pkg-begin clap /Users/jarred/Code/bun/src/deps/zig-clap/clap.zig --pkg-end --pkg-begin picohttp /Users/jarred/Code/bun/src/deps/picohttp.zig --pkg-end --pkg-begin iguanaTLS /Users/jarred/Code/bun/src/deps/iguanaTLS/src/main.zig --pkg-end -I /Users/jarred/Code/bun/src/deps -I /Users/jarred/Code/bun/src/deps/mimalloc -I /usr/local/opt/icu4c/include -L src/deps/mimalloc -L /usr/local/opt/icu4c/lib --main-pkg-path /Users/jarred/Code/bun --enable-cache -femit-bin=zig-out/bin/test --test-no-exec
-test "sendHTTPS - identity" {
- Output.initTest();
- defer Output.flush();
-
- var headers = try std.heap.c_allocator.create(Headers);
- headers.* = Headers{
- .entries = @TypeOf(headers.entries){},
- .buf = @TypeOf(headers.buf){},
- .used = 0,
- .allocator = std.heap.c_allocator,
- };
-
- headers.appendHeader("X-What", "ok", true, true, false);
- headers.appendHeader("Accept-Encoding", "identity", true, true, false);
-
- var client = HTTPClient.init(
- std.heap.c_allocator,
- .GET,
- URL.parse("https://example.com/"),
- headers.entries,
- headers.buf.items,
- );
- var body_out_str = try MutableString.init(std.heap.c_allocator, 0);
- var response = try client.sendHTTPS("", &body_out_str);
- try std.testing.expectEqual(response.status_code, 200);
- try std.testing.expectEqualStrings(body_out_str.list.items, @embedFile("fixtures_example.com.html"));
-}
-
-test "sendHTTPS - gzip" {
- Output.initTest();
- defer Output.flush();
-
- var headers = try std.heap.c_allocator.create(Headers);
- headers.* = Headers{
- .entries = @TypeOf(headers.entries){},
- .buf = @TypeOf(headers.buf){},
- .used = 0,
- .allocator = std.heap.c_allocator,
- };
-
- headers.appendHeader("Accept-Encoding", "gzip", false, false, false);
-
- var client = HTTPClient.init(
- std.heap.c_allocator,
- .GET,
- URL.parse("https://example.com/"),
- headers.entries,
- headers.buf.items,
- );
- var body_out_str = try MutableString.init(std.heap.c_allocator, 0);
- var response = try client.sendHTTPS("", &body_out_str);
- try std.testing.expectEqual(response.status_code, 200);
- try std.testing.expectEqualStrings(body_out_str.list.items, @embedFile("fixtures_example.com.html"));
-}
-
-// zig test src/http_client.zig --test-filter "sendHTTPS - deflate" -lc -lc++ /Users/jarred/Code/bun/src/deps/zlib/libz.a /Users/jarred/Code/bun/src/deps/picohttpparser.o --cache-dir /Users/jarred/Code/bun/zig-cache --global-cache-dir /Users/jarred/.cache/zig --name bun --pkg-begin clap /Users/jarred/Code/bun/src/deps/zig-clap/clap.zig --pkg-end --pkg-begin picohttp /Users/jarred/Code/bun/src/deps/picohttp.zig --pkg-end --pkg-begin iguanaTLS /Users/jarred/Code/bun/src/deps/iguanaTLS/src/main.zig --pkg-end -I /Users/jarred/Code/bun/src/deps -I /Users/jarred/Code/bun/src/deps/mimalloc -I /usr/local/opt/icu4c/include -L src/deps/mimalloc -L /usr/local/opt/icu4c/lib --main-pkg-path /Users/jarred/Code/bun --enable-cache -femit-bin=zig-out/bin/test
-test "sendHTTPS - deflate" {
- Output.initTest();
- defer Output.flush();
-
- var headers = try std.heap.c_allocator.create(Headers);
- headers.* = Headers{
- .entries = @TypeOf(headers.entries){},
- .buf = @TypeOf(headers.buf){},
- .used = 0,
- .allocator = std.heap.c_allocator,
- };
-
- headers.appendHeader("Accept-Encoding", "deflate", false, false, false);
-
- var client = HTTPClient.init(
- std.heap.c_allocator,
- .GET,
- URL.parse("https://example.com/"),
- headers.entries,
- headers.buf.items,
- );
- var body_out_str = try MutableString.init(std.heap.c_allocator, 0);
- var response = try client.sendHTTPS("", &body_out_str);
- try std.testing.expectEqual(response.status_code, 200);
- try std.testing.expectEqualStrings(body_out_str.list.items, @embedFile("fixtures_example.com.html"));
-}
-
-// zig test src/http_client.zig --test-filter "sendHTTP" -lc -lc++ /Users/jarred/Code/bun/src/deps/zlib/libz.a /Users/jarred/Code/bun/src/deps/picohttpparser.o --cache-dir /Users/jarred/Code/bun/zig-cache --global-cache-dir /Users/jarred/.cache/zig --name bun --pkg-begin clap /Users/jarred/Code/bun/src/deps/zig-clap/clap.zig --pkg-end --pkg-begin picohttp /Users/jarred/Code/bun/src/deps/picohttp.zig --pkg-end --pkg-begin iguanaTLS /Users/jarred/Code/bun/src/deps/iguanaTLS/src/main.zig --pkg-end -I /Users/jarred/Code/bun/src/deps -I /Users/jarred/Code/bun/src/deps/mimalloc -I /usr/local/opt/icu4c/include -L src/deps/mimalloc -L /usr/local/opt/icu4c/lib --main-pkg-path /Users/jarred/Code/bun --enable-cache -femit-bin=zig-out/bin/test
-
-test "send - redirect" {
- Output.initTest();
- defer Output.flush();
-
- var headers = try std.heap.c_allocator.create(Headers);
- headers.* = Headers{
- .entries = @TypeOf(headers.entries){},
- .buf = @TypeOf(headers.buf){},
- .used = 0,
- .allocator = std.heap.c_allocator,
- };
-
- headers.appendHeader("Accept-Encoding", "gzip", false, false, false);
-
- var client = HTTPClient.init(
- std.heap.c_allocator,
- .GET,
- URL.parse("https://www.bun.sh/"),
- headers.entries,
- headers.buf.items,
- );
- try std.testing.expectEqualStrings(client.url.hostname, "www.bun.sh");
- var body_out_str = try MutableString.init(std.heap.c_allocator, 0);
- var response = try client.send("", &body_out_str);
- try std.testing.expectEqual(response.status_code, 200);
- try std.testing.expectEqual(client.url.hostname, "bun.sh");
- try std.testing.expectEqualStrings(body_out_str.list.items, @embedFile("fixtures_example.com.html"));
-}
diff --git a/src/http_client_async.zig b/src/http_client_async.zig
new file mode 100644
index 000000000..8b8bd6082
--- /dev/null
+++ b/src/http_client_async.zig
@@ -0,0 +1,2190 @@
+const picohttp = @import("picohttp");
+usingnamespace @import("./global.zig");
+const std = @import("std");
+const Headers = @import("./javascript/jsc/webcore/response.zig").Headers;
+const URL = @import("./query_string_map.zig").URL;
+const Method = @import("./http/method.zig").Method;
+const Api = @import("./api/schema.zig").Api;
+const Lock = @import("./lock.zig").Lock;
+const HTTPClient = @This();
+const SOCKET_FLAGS = os.SOCK_CLOEXEC;
+const Zlib = @import("./zlib.zig");
+const StringBuilder = @import("./string_builder.zig");
+const AsyncIO = @import("io");
+const ThreadPool = @import("thread_pool");
+const boring = @import("boringssl");
+
+const NetworkThread = @import("network_thread");
+
+const extremely_verbose = false;
+
+fn writeRequest(
+ comptime Writer: type,
+ writer: Writer,
+ request: picohttp.Request,
+ body: string,
+ // header_hashes: []u64,
+) !void {
+ _ = writer.write(request.method);
+ _ = writer.write(" ");
+ _ = writer.write(request.path);
+ _ = writer.write(" HTTP/1.1\r\n");
+
+ for (request.headers) |header, i| {
+ _ = writer.write(header.name);
+ _ = writer.write(": ");
+ _ = writer.write(header.value);
+ _ = writer.write("\r\n");
+ }
+
+ _ = writer.write("\r\n");
+
+ if (body.len > 0) {
+ _ = writer.write(body);
+ }
+}
+
+method: Method,
+header_entries: Headers.Entries,
+header_buf: string,
+url: URL,
+allocator: *std.mem.Allocator,
+verbose: bool = isTest,
+tcp_client: tcp.Client = undefined,
+body_size: u32 = 0,
+read_count: u32 = 0,
+remaining_redirect_count: i8 = 127,
+redirect: ?*URLBufferPool = null,
+disable_shutdown: bool = true,
+timeout: usize = 0,
+progress_node: ?*std.Progress.Node = null,
+socket: AsyncSocket.SSL = undefined,
+gzip_elapsed: u64 = 0,
+
+/// Some HTTP servers (such as npm) report Last-Modified times but ignore If-Modified-Since.
+/// This is a workaround for that.
+force_last_modified: bool = false,
+if_modified_since: string = "",
+request_content_len_buf: ["-4294967295".len]u8 = undefined,
+request_headers_buf: [128]picohttp.Header = undefined,
+response_headers_buf: [128]picohttp.Header = undefined,
+
+pub fn init(
+ allocator: *std.mem.Allocator,
+ method: Method,
+ url: URL,
+ header_entries: Headers.Entries,
+ header_buf: string,
+) !HTTPClient {
+ return HTTPClient{
+ .allocator = allocator,
+ .method = method,
+ .url = url,
+ .header_entries = header_entries,
+ .header_buf = header_buf,
+ .socket = undefined,
+ };
+}
+
+pub fn deinit(this: *HTTPClient) !void {
+ if (this.redirect) |redirect| {
+ redirect.release();
+ this.redirect = null;
+ }
+}
+
+// threadlocal var resolver_cache
+const tcp = std.x.net.tcp;
+const ip = std.x.net.ip;
+
+const IPv4 = std.x.os.IPv4;
+const IPv6 = std.x.os.IPv6;
+const Socket = std.x.os.Socket;
+const os = std.os;
+
+// lowercase hash header names so that we can be sure
+pub fn hashHeaderName(name: string) u64 {
+ var hasher = std.hash.Wyhash.init(0);
+ var remain: string = name;
+ var buf: [32]u8 = undefined;
+ var buf_slice: []u8 = std.mem.span(&buf);
+
+ while (remain.len > 0) {
+ var end = std.math.min(hasher.buf.len, remain.len);
+
+ hasher.update(strings.copyLowercase(std.mem.span(remain[0..end]), buf_slice));
+ remain = remain[end..];
+ }
+
+ return hasher.final();
+}
+
+const host_header_hash = hashHeaderName("Host");
+const connection_header_hash = hashHeaderName("Connection");
+
+pub const Encoding = enum {
+ identity,
+ gzip,
+ deflate,
+ brotli,
+ chunked,
+};
+
+const content_encoding_hash = hashHeaderName("Content-Encoding");
+const transfer_encoding_header = hashHeaderName("Transfer-Encoding");
+
+const host_header_name = "Host";
+const content_length_header_name = "Content-Length";
+const content_length_header_hash = hashHeaderName("Content-Length");
+const connection_header = picohttp.Header{ .name = "Connection", .value = "close" };
+const accept_header = picohttp.Header{ .name = "Accept", .value = "*/*" };
+const accept_header_hash = hashHeaderName("Accept");
+
+const accept_encoding_no_compression = "identity";
+const accept_encoding_compression = "deflate, gzip";
+const accept_encoding_header_compression = picohttp.Header{ .name = "Accept-Encoding", .value = accept_encoding_compression };
+const accept_encoding_header_no_compression = picohttp.Header{ .name = "Accept-Encoding", .value = accept_encoding_no_compression };
+
+const accept_encoding_header = if (FeatureFlags.disable_compression_in_http_client)
+ accept_encoding_header_no_compression
+else
+ accept_encoding_header_compression;
+
+const accept_encoding_header_hash = hashHeaderName("Accept-Encoding");
+
+const user_agent_header = picohttp.Header{ .name = "User-Agent", .value = "Bun.js " ++ Global.package_json_version };
+const user_agent_header_hash = hashHeaderName("User-Agent");
+const location_header_hash = hashHeaderName("Location");
+
+pub fn headerStr(this: *const HTTPClient, ptr: Api.StringPointer) string {
+ return this.header_buf[ptr.offset..][0..ptr.length];
+}
+
+pub const HeaderBuilder = struct {
+ content: StringBuilder = StringBuilder{},
+ header_count: u64 = 0,
+ entries: Headers.Entries = Headers.Entries{},
+
+ pub fn count(this: *HeaderBuilder, name: string, value: string) void {
+ this.header_count += 1;
+ this.content.count(name);
+ this.content.count(value);
+ }
+
+ pub fn allocate(this: *HeaderBuilder, allocator: *std.mem.Allocator) !void {
+ try this.content.allocate(allocator);
+ try this.entries.ensureTotalCapacity(allocator, this.header_count);
+ }
+ pub fn append(this: *HeaderBuilder, name: string, value: string) void {
+ const name_ptr = Api.StringPointer{
+ .offset = @truncate(u32, this.content.len),
+ .length = @truncate(u32, name.len),
+ };
+
+ _ = this.content.append(name);
+
+ const value_ptr = Api.StringPointer{
+ .offset = @truncate(u32, this.content.len),
+ .length = @truncate(u32, value.len),
+ };
+ _ = this.content.append(value);
+ this.entries.appendAssumeCapacity(Headers.Kv{ .name = name_ptr, .value = value_ptr });
+ }
+
+ pub fn apply(this: *HeaderBuilder, client: *HTTPClient) void {
+ client.header_entries = this.entries;
+ client.header_buf = this.content.ptr.?[0..this.content.len];
+ }
+};
+
+pub const HTTPChannel = @import("./sync.zig").Channel(*AsyncHTTP, .{ .Static = 1000 });
+
+// 32 pointers much cheaper than 1000 pointers
+const SingleHTTPChannel = @import("./sync.zig").Channel(*AsyncHTTP, .{ .Static = 32 });
+var send_sync_channel: SingleHTTPChannel = undefined;
+var send_sync_channel_loaded: bool = false;
+
+pub const HTTPChannelContext = struct {
+ http: AsyncHTTP = undefined,
+ channel: *HTTPChannel,
+
+ pub fn callback(http: *AsyncHTTP, sender: *AsyncHTTP.HTTPSender) void {
+ var this: *HTTPChannelContext = @fieldParentPtr(HTTPChannelContext, "http", http);
+ this.channel.writeItem(http) catch unreachable;
+ sender.onFinish();
+ }
+};
+
+pub const AsyncHTTP = struct {
+ request: ?picohttp.Request = null,
+ response: ?picohttp.Response = null,
+ request_headers: Headers.Entries = Headers.Entries{},
+ response_headers: Headers.Entries = Headers.Entries{},
+ response_buffer: *MutableString,
+ request_body: *MutableString,
+ allocator: *std.mem.Allocator,
+ request_header_buf: string = "",
+ method: Method = Method.GET,
+ max_retry_count: u32 = 0,
+ url: URL,
+
+ /// Timeout in nanoseconds
+ timeout: usize = 0,
+
+ response_encoding: Encoding = Encoding.identity,
+ redirect_count: u32 = 0,
+ retries_count: u32 = 0,
+ verbose: bool = false,
+
+ client: HTTPClient = undefined,
+ err: ?anyerror = null,
+
+ state: AtomicState = AtomicState.init(State.pending),
+ elapsed: u64 = 0,
+ gzip_elapsed: u64 = 0,
+
+ /// Callback runs when request finishes
+ /// Executes on the network thread
+ callback: ?CompletionCallback = null,
+
+ pub const CompletionCallback = fn (this: *AsyncHTTP, sender: *HTTPSender) void;
+ pub var active_requests_count = std.atomic.Atomic(u32).init(0);
+
+ pub const State = enum(u32) {
+ pending = 0,
+ scheduled = 1,
+ sending = 2,
+ success = 3,
+ fail = 4,
+ };
+ const AtomicState = std.atomic.Atomic(State);
+
+ pub fn init(
+ allocator: *std.mem.Allocator,
+ method: Method,
+ url: URL,
+ headers: Headers.Entries,
+ headers_buf: string,
+ response_buffer: *MutableString,
+ request_body: *MutableString,
+ timeout: usize,
+ ) !AsyncHTTP {
+ var this = AsyncHTTP{
+ .allocator = allocator,
+ .url = url,
+ .method = method,
+ .request_headers = headers,
+ .request_header_buf = headers_buf,
+ .request_body = request_body,
+ .response_buffer = response_buffer,
+ };
+ this.client = try HTTPClient.init(allocator, method, url, headers, headers_buf);
+ this.client.timeout = timeout;
+ this.timeout = timeout;
+ return this;
+ }
+
+ pub fn schedule(this: *AsyncHTTP, allocator: *std.mem.Allocator, batch: *ThreadPool.Batch) void {
+ std.debug.assert(NetworkThread.global_loaded.load(.Monotonic) == 1);
+ var sender = HTTPSender.get(this, allocator);
+ this.state.store(.scheduled, .Monotonic);
+ batch.push(ThreadPool.Batch.from(&sender.task));
+ }
+
+ fn sendSyncCallback(this: *AsyncHTTP, sender: *HTTPSender) void {
+ send_sync_channel.writeItem(this) catch unreachable;
+ sender.release();
+ }
+
+ pub fn sendSync(this: *AsyncHTTP) anyerror!picohttp.Response {
+ if (!send_sync_channel_loaded) {
+ send_sync_channel_loaded = true;
+ send_sync_channel = SingleHTTPChannel.init();
+ }
+
+ this.callback = sendSyncCallback;
+ var batch = NetworkThread.Batch{};
+ this.schedule(this.allocator, &batch);
+ NetworkThread.global.pool.schedule(batch);
+ while (true) {
+ var async_http: *AsyncHTTP = (send_sync_channel.tryReadItem() catch unreachable) orelse {
+ std.atomic.spinLoopHint();
+ std.time.sleep(std.time.ns_per_us * 100);
+ continue;
+ };
+ if (async_http.err) |err| {
+ return err;
+ }
+
+ return async_http.response.?;
+ }
+
+ unreachable;
+ }
+
+ var http_sender_head: std.atomic.Atomic(?*HTTPSender) = std.atomic.Atomic(?*HTTPSender).init(null);
+
+ pub const HTTPSender = struct {
+ task: ThreadPool.Task = .{ .callback = callback },
+ frame: @Frame(AsyncHTTP.do) = undefined,
+ http: *AsyncHTTP = undefined,
+
+ next: ?*HTTPSender = null,
+
+ pub fn get(http: *AsyncHTTP, allocator: *std.mem.Allocator) *HTTPSender {
+ @fence(.Acquire);
+
+ var head_ = http_sender_head.load(.Monotonic);
+
+ if (head_ == null) {
+ var new_head = allocator.create(HTTPSender) catch unreachable;
+ new_head.* = HTTPSender{};
+ new_head.next = null;
+ new_head.task = .{ .callback = callback };
+ new_head.http = http;
+ return new_head;
+ }
+
+ http_sender_head.store(head_.?.next, .Monotonic);
+
+ head_.?.* = HTTPSender{};
+ head_.?.next = null;
+ head_.?.task = .{ .callback = callback };
+ head_.?.http = http;
+
+ return head_.?;
+ }
+
+ pub fn release(this: *HTTPSender) void {
+ @fence(.Acquire);
+ this.task = .{ .callback = callback };
+ this.http = undefined;
+ this.next = http_sender_head.swap(this, .Monotonic);
+ }
+
+ pub fn callback(task: *ThreadPool.Task) void {
+ var this = @fieldParentPtr(HTTPSender, "task", task);
+ this.frame = async AsyncHTTP.do(this);
+ }
+
+ pub fn onFinish(this: *HTTPSender) void {
+ this.release();
+ }
+ };
+
+ pub fn do(sender: *HTTPSender) void {
+ outer: {
+ var this = sender.http;
+ this.err = null;
+ this.state.store(.sending, .Monotonic);
+ var timer = std.time.Timer.start() catch @panic("Timer failure");
+ defer this.elapsed = timer.read();
+ _ = active_requests_count.fetchAdd(1, .Monotonic);
+ defer _ = active_requests_count.fetchSub(1, .Monotonic);
+
+ this.response = await this.client.sendAsync(this.request_body.list.items, this.response_buffer) catch |err| {
+ this.state.store(.fail, .Monotonic);
+ this.err = err;
+
+ if (sender.http.max_retry_count > sender.http.retries_count) {
+ sender.http.retries_count += 1;
+ NetworkThread.global.pool.schedule(ThreadPool.Batch.from(&sender.task));
+ return;
+ }
+ break :outer;
+ };
+
+ this.redirect_count = @intCast(u32, @maximum(127 - this.client.remaining_redirect_count, 0));
+ this.state.store(.success, .Monotonic);
+ this.gzip_elapsed = this.client.gzip_elapsed;
+ }
+
+ if (sender.http.callback) |callback| {
+ callback(sender.http, sender);
+ }
+ }
+};
+
+const BufferPool = struct {
+ pub const len = std.math.maxInt(u16) - 64;
+ buf: [len]u8 = undefined,
+ next: ?*BufferPool = null,
+ allocator: *std.mem.Allocator = undefined,
+
+ var head: ?*BufferPool = null;
+
+ pub fn get(allocator: *std.mem.Allocator) !*BufferPool {
+ if (head) |item| {
+ var this = item;
+ var head_ = item.next;
+ head = head_;
+ this.next = null;
+
+ return this;
+ }
+
+ var entry = try allocator.create(BufferPool);
+ entry.* = BufferPool{ .allocator = allocator };
+ return entry;
+ }
+
+ pub fn release(this: *BufferPool) void {
+ if (head) |item| {
+ item.next = this;
+ } else {
+ head = this;
+ }
+ }
+};
+
+const URLBufferPool = struct {
+ pub const len = 4096;
+ buf: [len]u8 = undefined,
+ next: ?*URLBufferPool = null,
+ allocator: *std.mem.Allocator = undefined,
+
+ var head: ?*URLBufferPool = null;
+
+ pub fn get(allocator: *std.mem.Allocator) !*URLBufferPool {
+ if (head) |item| {
+ var this = item;
+ var head_ = item.next;
+ head = head_;
+ this.next = null;
+
+ return this;
+ }
+
+ var entry = try allocator.create(URLBufferPool);
+ entry.* = URLBufferPool{ .allocator = allocator };
+ return entry;
+ }
+
+ pub fn release(this: *URLBufferPool) void {
+ if (head) |item| {
+ item.next = this;
+ } else {
+ head = this;
+ }
+ }
+};
+
+pub const AsyncMessage = struct {
+ used: u32 = 0,
+ sent: u32 = 0,
+ completion: AsyncIO.Completion = undefined,
+ buf: []u8 = undefined,
+ pooled: ?*BufferPool = null,
+ allocator: *std.mem.Allocator,
+ next: ?*AsyncMessage = null,
+ context: *c_void = undefined,
+ released: bool = false,
+ var _first_ssl: ?*AsyncMessage = null;
+ pub fn getSSL(allocator: *std.mem.Allocator) *AsyncMessage {
+ if (_first_ssl) |first| {
+ var prev = first;
+ std.debug.assert(prev.released);
+ if (prev.next) |next| {
+ _first_ssl = next;
+ prev.next = null;
+ } else {
+ _first_ssl = null;
+ }
+ prev.released = false;
+
+ return prev;
+ }
+
+ var msg = allocator.create(AsyncMessage) catch unreachable;
+ msg.* = AsyncMessage{
+ .allocator = allocator,
+ .pooled = null,
+ .buf = &[_]u8{},
+ };
+ return msg;
+ }
+
+ var _first: ?*AsyncMessage = null;
+ pub fn get(allocator: *std.mem.Allocator) *AsyncMessage {
+ if (_first) |first| {
+ var prev = first;
+ std.debug.assert(prev.released);
+ prev.released = false;
+
+ if (first.next) |next| {
+ _first = next;
+ prev.next = null;
+ return prev;
+ } else {
+ _first = null;
+ }
+
+ return prev;
+ }
+
+ var msg = allocator.create(AsyncMessage) catch unreachable;
+ var pooled = BufferPool.get(allocator) catch unreachable;
+ msg.* = AsyncMessage{ .allocator = allocator, .buf = &pooled.buf, .pooled = pooled };
+ return msg;
+ }
+
+ pub fn release(self: *AsyncMessage) void {
+ self.used = 0;
+ self.sent = 0;
+ std.debug.assert(!self.released);
+ self.released = true;
+
+ if (self.pooled != null) {
+ var old = _first;
+ _first = self;
+ self.next = old;
+ } else {
+ var old = _first_ssl;
+ self.next = old;
+ _first_ssl = self;
+ }
+ }
+
+ const WriteResponse = struct {
+ written: u32 = 0,
+ overflow: bool = false,
+ };
+
+ pub fn writeAll(this: *AsyncMessage, buffer: []const u8) WriteResponse {
+ var remain = this.buf[this.used..];
+ var writable = buffer[0..@minimum(buffer.len, remain.len)];
+ if (writable.len == 0) {
+ return .{ .written = 0, .overflow = buffer.len > 0 };
+ }
+
+ std.mem.copy(u8, remain, writable);
+ this.used += @intCast(u16, writable.len);
+
+ return .{ .written = @truncate(u32, writable.len), .overflow = writable.len == remain.len };
+ }
+
+ pub inline fn slice(this: *const AsyncMessage) []const u8 {
+ return this.buf[0..this.used][this.sent..];
+ }
+
+ pub inline fn available(this: *AsyncMessage) []u8 {
+ return this.buf[0 .. this.buf.len - this.used];
+ }
+};
+
+const Completion = AsyncIO.Completion;
+
+const AsyncSocket = struct {
+ const This = @This();
+ io: *AsyncIO = undefined,
+ socket: std.os.socket_t = 0,
+ head: *AsyncMessage = undefined,
+ tail: *AsyncMessage = undefined,
+ allocator: *std.mem.Allocator,
+ err: ?anyerror = null,
+ queued: usize = 0,
+ sent: usize = 0,
+ send_frame: @Frame(AsyncSocket.send) = undefined,
+ read_frame: @Frame(AsyncSocket.read) = undefined,
+ connect_frame: @Frame(AsyncSocket.connectToAddress) = undefined,
+ close_frame: @Frame(AsyncSocket.close) = undefined,
+
+ read_context: []u8 = undefined,
+ read_offset: u64 = 0,
+ read_completion: AsyncIO.Completion = undefined,
+ connect_completion: AsyncIO.Completion = undefined,
+ close_completion: AsyncIO.Completion = undefined,
+
+ const ConnectError = AsyncIO.ConnectError || std.os.SocketError || std.os.SetSockOptError;
+
+ pub fn init(io: *AsyncIO, socket: std.os.socket_t, allocator: *std.mem.Allocator) !AsyncSocket {
+ var head = AsyncMessage.get(allocator);
+
+ return AsyncSocket{ .io = io, .socket = socket, .head = head, .tail = head, .allocator = allocator };
+ }
+
+ fn on_connect(this: *AsyncSocket, _: *Completion, err: ConnectError!void) void {
+ err catch |resolved_err| {
+ this.err = resolved_err;
+ };
+
+ resume this.connect_frame;
+ }
+
+ fn connectToAddress(this: *AsyncSocket, address: std.net.Address) ConnectError!void {
+ const sockfd = AsyncIO.openSocket(address.any.family, SOCKET_FLAGS | std.os.SOCK_STREAM, std.os.IPPROTO_TCP) catch return error.ConnectionRefused;
+
+ this.io.connect(*AsyncSocket, this, on_connect, &this.connect_completion, sockfd, address);
+ suspend {
+ this.connect_frame = @frame().*;
+ }
+
+ if (this.err) |e| {
+ return @errSetCast(ConnectError, e);
+ }
+
+ this.socket = sockfd;
+ return;
+ }
+
+ fn on_close(this: *AsyncSocket, _: *Completion, _: AsyncIO.CloseError!void) void {
+ resume this.close_frame;
+ }
+
+ pub fn close(this: *AsyncSocket) void {
+ if (this.socket == 0) return;
+ this.io.close(*AsyncSocket, this, on_close, &this.close_completion, this.socket);
+ suspend {
+ this.close_frame = @frame().*;
+ }
+ this.socket = 0;
+ }
+
+ pub fn connect(this: *AsyncSocket, name: []const u8, port: u16) ConnectError!void {
+ this.socket = 0;
+ outer: while (true) {
+ // on macOS, getaddrinfo() is very slow
+ // If you send ~200 network requests, about 1.5s is spent on getaddrinfo()
+ // So, we cache this.
+ var address_list = NetworkThread.getAddressList(this.allocator, name, port) catch |err| {
+ return @errSetCast(ConnectError, err);
+ };
+
+ const list = address_list.address_list;
+ if (list.addrs.len == 0) return error.ConnectionRefused;
+
+ try_cached_index: {
+ if (address_list.index) |i| {
+ const address = list.addrs[i];
+ this.connectToAddress(address) catch |err| {
+ if (err == error.ConnectionRefused) {
+ address_list.index = null;
+ break :try_cached_index;
+ }
+
+ address_list.invalidate();
+ continue :outer;
+ };
+ }
+ }
+
+ for (list.addrs) |address, i| {
+ this.connectToAddress(address) catch |err| {
+ if (err == error.ConnectionRefused) continue;
+ address_list.invalidate();
+ return err;
+ };
+ address_list.index = @truncate(u32, i);
+ return;
+ }
+
+ address_list.invalidate();
+ return error.ConnectionRefused;
+ }
+ }
+
+ fn on_send(msg: *AsyncMessage, completion: *Completion, result: SendError!usize) void {
+ var this = @ptrCast(*AsyncSocket, @alignCast(@alignOf(*AsyncSocket), msg.context));
+ const written = result catch |err| {
+ this.err = err;
+ resume this.send_frame;
+ return;
+ };
+
+ if (written == 0) {
+ resume this.send_frame;
+ return;
+ }
+
+ msg.sent += @truncate(u16, written);
+ const has_more = msg.used > msg.sent;
+ this.sent += written;
+
+ if (has_more) {
+ this.io.send(
+ *AsyncMessage,
+ msg,
+ on_send,
+ &msg.completion,
+ this.socket,
+ msg.slice(),
+ SOCKET_FLAGS,
+ );
+ } else {
+ msg.release();
+ }
+
+ // complete
+ if (this.queued <= this.sent) {
+ resume this.send_frame;
+ }
+ }
+
+ pub fn write(this: *AsyncSocket, buf: []const u8) usize {
+ this.tail.context = this;
+
+ const resp = this.tail.writeAll(buf);
+ this.queued += resp.written;
+
+ if (resp.overflow) {
+ var next = AsyncMessage.get(this.allocator);
+ this.tail.next = next;
+ this.tail = next;
+
+ return @as(usize, resp.written) + this.write(buf[resp.written..]);
+ }
+
+ return @as(usize, resp.written);
+ }
+
+ pub const SendError = AsyncIO.SendError;
+
+ pub fn deinit(this: *AsyncSocket) void {
+ var node = this.head;
+ this.head.release();
+ }
+
+ pub fn send(this: *This) SendError!usize {
+ const original_sent = this.sent;
+ this.head.context = this;
+
+ this.io.send(
+ *AsyncMessage,
+ this.head,
+ on_send,
+ &this.head.completion,
+ this.socket,
+ this.head.slice(),
+ SOCKET_FLAGS,
+ );
+
+ var node = this.head;
+ while (node.next) |element| {
+ this.io.send(
+ *AsyncMessage,
+ element,
+ on_send,
+ &element.completion,
+ this.socket,
+ element.slice(),
+ SOCKET_FLAGS,
+ );
+ node = element.next orelse break;
+ }
+
+ suspend {
+ this.send_frame = @frame().*;
+ }
+
+ if (this.err) |err| {
+ this.err = null;
+ return @errSetCast(AsyncSocket.SendError, err);
+ }
+
+ return this.sent - original_sent;
+ }
+
+ pub const RecvError = AsyncIO.RecvError;
+
+ const Reader = struct {
+ pub fn on_read(ctx: *AsyncSocket, completion: *AsyncIO.Completion, result: RecvError!usize) void {
+ const len = result catch |err| {
+ ctx.err = err;
+ resume ctx.read_frame;
+ return;
+ };
+ ctx.read_offset += len;
+ resume ctx.read_frame;
+ }
+ };
+
+ pub fn read(
+ this: *AsyncSocket,
+ bytes: []u8,
+ offset: u64,
+ ) RecvError!u64 {
+ this.read_context = bytes;
+ this.read_offset = offset;
+ const original_read_offset = this.read_offset;
+
+ this.io.recv(
+ *AsyncSocket,
+ this,
+ Reader.on_read,
+ &this.read_completion,
+ this.socket,
+ bytes,
+ );
+
+ suspend {
+ this.read_frame = @frame().*;
+ }
+
+ if (this.err) |err| {
+ this.err = null;
+ return @errSetCast(RecvError, err);
+ }
+
+ return this.read_offset - original_read_offset;
+ }
+
+ pub const SSL = struct {
+ ssl: *boring.SSL = undefined,
+ socket: AsyncSocket,
+ handshake_complete: bool = false,
+ ssl_bio: *AsyncBIO = undefined,
+ read_bio: ?*AsyncMessage = null,
+ handshake_frame: @Frame(SSL.handshake) = undefined,
+ send_frame: @Frame(SSL.send) = undefined,
+ read_frame: @Frame(SSL.read) = undefined,
+ hostname: [std.fs.MAX_PATH_BYTES]u8 = undefined,
+
+ const SSLConnectError = ConnectError || HandshakeError;
+ const HandshakeError = error{OpenSSLError};
+
+ pub fn connect(this: *SSL, name: []const u8, port: u16) !void {
+ try this.socket.connect(name, port);
+ this.handshake_complete = false;
+
+ var ssl = boring.initClient();
+
+ {
+ std.mem.copy(u8, &this.hostname, name);
+ this.hostname[name.len] = 0;
+ var name_ = this.hostname[0..name.len :0];
+ ssl.setHostname(name_);
+ }
+
+ var bio = try AsyncBIO.init(this.socket.allocator);
+ bio.socket_fd = this.socket.socket;
+ this.ssl_bio = bio;
+
+ boring.SSL_set_bio(ssl, bio.bio, bio.bio);
+
+ this.ssl = ssl;
+ this.read_bio = AsyncMessage.get(this.socket.allocator);
+
+ try this.handshake();
+ }
+
+ pub fn close(this: *SSL) void {
+ this.socket.close();
+ }
+
+ fn handshake(this: *SSL) HandshakeError!void {
+ while (!this.ssl.isInitFinished()) {
+ boring.ERR_clear_error();
+ this.ssl_bio.enqueueSend();
+ const handshake_result = boring.SSL_connect(this.ssl);
+ if (handshake_result == 0) {
+ Output.prettyErrorln("ssl accept error", .{});
+ Output.flush();
+ return error.OpenSSLError;
+ }
+ this.handshake_complete = handshake_result == 1 and this.ssl.isInitFinished();
+
+ if (!this.handshake_complete) {
+ // accept_result < 0
+ const e = boring.SSL_get_error(this.ssl, handshake_result);
+ if ((e == boring.SSL_ERROR_WANT_READ or e == boring.SSL_ERROR_WANT_WRITE)) {
+ this.ssl_bio.enqueueSend();
+ suspend {
+ this.handshake_frame = @frame().*;
+ this.ssl_bio.pushPendingFrame(&this.handshake_frame);
+ }
+
+ continue;
+ }
+
+ Output.prettyErrorln("ssl accept error = {}, return val was {}", .{ e, handshake_result });
+ Output.flush();
+ return error.OpenSSLError;
+ }
+ }
+ }
+
+ pub fn write(this: *SSL, buffer_: []const u8) usize {
+ var buffer = buffer_;
+ var read_bio = this.read_bio;
+ while (buffer.len > 0) {
+ const response = read_bio.?.writeAll(buffer);
+ buffer = buffer[response.written..];
+ if (response.overflow) {
+ read_bio = read_bio.?.next orelse brk: {
+ read_bio.?.next = AsyncMessage.get(this.socket.allocator);
+ break :brk read_bio.?.next.?;
+ };
+ }
+ }
+
+ return buffer_.len;
+ }
+
+ pub fn send(this: *SSL) !usize {
+ var bio_ = this.read_bio;
+ var len: usize = 0;
+ while (bio_) |bio| {
+ var slice = bio.slice();
+ len += this.ssl.write(slice) catch |err| {
+ switch (err) {
+ error.WantRead => {
+ suspend {
+ this.send_frame = @frame().*;
+ this.ssl_bio.pushPendingFrame(&this.send_frame);
+ }
+ continue;
+ },
+ error.WantWrite => {
+ this.ssl_bio.enqueueSend();
+
+ suspend {
+ this.send_frame = @frame().*;
+ this.ssl_bio.pushPendingFrame(&this.send_frame);
+ }
+ continue;
+ },
+ else => {},
+ }
+
+ if (comptime Environment.isDebug) {
+ Output.prettyErrorln("SSL error: {s} (buf: {s})\n URL:", .{
+ @errorName(err),
+ bio.slice(),
+ });
+ Output.flush();
+ }
+
+ return err;
+ };
+
+ bio_ = bio.next;
+ }
+ return len;
+ }
+
+ pub fn read(this: *SSL, buf_: []u8, offset: u64) !u64 {
+ var buf = buf_[offset..];
+ var bio_ = this.read_bio;
+ var len: usize = 0;
+ while (buf.len > 0) {
+ len = this.ssl.read(buf) catch |err| {
+ switch (err) {
+ error.WantWrite => {
+ this.ssl_bio.enqueueSend();
+
+ if (extremely_verbose) {
+ Output.prettyErrorln(
+ "Error: {s}: \n Read Wait: {s}\n Send Wait: {s}",
+ .{
+ @errorName(err),
+ @tagName(this.ssl_bio.read_wait),
+ @tagName(this.ssl_bio.send_wait),
+ },
+ );
+ Output.flush();
+ }
+
+ suspend {
+ this.read_frame = @frame().*;
+ this.ssl_bio.pushPendingFrame(&this.read_frame);
+ }
+ continue;
+ },
+ error.WantRead => {
+ // this.ssl_bio.enqueueSend();
+
+ if (extremely_verbose) {
+ Output.prettyErrorln(
+ "Error: {s}: \n Read Wait: {s}\n Send Wait: {s}",
+ .{
+ @errorName(err),
+ @tagName(this.ssl_bio.read_wait),
+ @tagName(this.ssl_bio.send_wait),
+ },
+ );
+ Output.flush();
+ }
+
+ suspend {
+ this.read_frame = @frame().*;
+ this.ssl_bio.pushPendingFrame(&this.read_frame);
+ }
+ continue;
+ },
+ else => return err,
+ }
+ unreachable;
+ };
+
+ break;
+ }
+
+ return len;
+ }
+
+ pub inline fn init(allocator: *std.mem.Allocator, io: *AsyncIO) !SSL {
+ var head = AsyncMessage.get(allocator);
+
+ return SSL{
+ .socket = try AsyncSocket.init(io, 0, allocator),
+ };
+ }
+
+ pub fn deinit(this: *SSL) void {
+ _ = boring.BIO_set_data(this.ssl_bio.bio, null);
+ this.ssl_bio.pending_frame = AsyncBIO.PendingFrame.init();
+ this.ssl_bio.socket_fd = 0;
+ this.ssl_bio.release();
+ this.ssl.deinit();
+ this.handshake_complete = false;
+
+ if (this.read_bio) |bio| {
+ var next_ = bio.next;
+ while (next_) |next| {
+ next.release();
+ next_ = next.next;
+ }
+
+ bio.release();
+ this.read_bio = null;
+ }
+ }
+ };
+};
+
+pub const AsyncBIO = struct {
+ bio: *boring.BIO = undefined,
+ socket_fd: std.os.socket_t = 0,
+ allocator: *std.mem.Allocator,
+
+ read_wait: Wait = Wait.pending,
+ send_wait: Wait = Wait.pending,
+ recv_completion: AsyncIO.Completion = undefined,
+ send_completion: AsyncIO.Completion = undefined,
+
+ write_buffer: ?*AsyncMessage = null,
+
+ last_send_result: AsyncIO.SendError!usize = 0,
+
+ last_read_result: AsyncIO.RecvError!usize = 0,
+ next: ?*AsyncBIO = null,
+ pending_frame: PendingFrame = PendingFrame.init(),
+
+ pub const PendingFrame = std.fifo.LinearFifo(anyframe, .{ .Static = 8 });
+
+ pub inline fn pushPendingFrame(this: *AsyncBIO, frame: anyframe) void {
+ this.pending_frame.writeItem(frame) catch {};
+ }
+
+ pub inline fn popPendingFrame(this: *AsyncBIO) ?anyframe {
+ return this.pending_frame.readItem();
+ }
+
+ var method: ?*boring.BIO_METHOD = null;
+ var head: ?*AsyncBIO = null;
+
+ const async_bio_name: [:0]const u8 = "AsyncBIO";
+
+ const Wait = enum {
+ pending,
+ suspended,
+ completed,
+ };
+
+ fn instance(allocator: *std.mem.Allocator) *AsyncBIO {
+ if (head) |head_| {
+ var next = head_.next;
+ var ret = head_;
+ ret.read_wait = .pending;
+ ret.send_wait = .pending;
+ head = next;
+
+ ret.pending_frame = PendingFrame.init();
+ return ret;
+ }
+
+ var bio = allocator.create(AsyncBIO) catch unreachable;
+ bio.* = AsyncBIO{
+ .allocator = allocator,
+ .read_wait = .pending,
+ .send_wait = .pending,
+ };
+
+ return bio;
+ }
+
+ pub fn release(this: *AsyncBIO) void {
+ if (head) |head_| {
+ this.next = head_;
+ }
+
+ this.read_wait = .pending;
+ this.last_read_result = 0;
+ this.send_wait = .pending;
+ this.last_read_result = 0;
+ this.pending_frame = PendingFrame.init();
+
+ if (this.write_buffer) |write| {
+ write.release();
+ this.write_buffer = null;
+ }
+
+ head = this;
+ }
+
+ pub fn init(allocator: *std.mem.Allocator) !*AsyncBIO {
+ var bio = instance(allocator);
+
+ bio.bio = boring.BIO_new(
+ method orelse brk: {
+ method = boring.BIOMethod.init(async_bio_name, Bio.create, Bio.destroy, Bio.write, Bio.read, null, Bio.ctrl);
+ break :brk method.?;
+ },
+ ) orelse return error.OutOfMemory;
+
+ _ = boring.BIO_set_data(bio.bio, bio);
+ return bio;
+ }
+
+ const WaitResult = enum {
+ none,
+ read,
+ send,
+ };
+
+ const Sender = struct {
+ pub fn onSend(this: *AsyncBIO, _: *Completion, result: AsyncIO.SendError!usize) void {
+ this.last_send_result = result;
+ this.send_wait = .completed;
+ this.write_buffer.?.sent += @truncate(u32, result catch 0);
+
+ if (extremely_verbose) {
+ const read_result = result catch @as(usize, 999);
+ Output.prettyErrorln("onSend: {d}", .{read_result});
+ Output.flush();
+ }
+
+ if (this.pending_frame.readItem()) |frame| {
+ resume frame;
+ }
+ }
+ };
+
+ pub fn enqueueSend(
+ self: *AsyncBIO,
+ ) void {
+ if (self.write_buffer == null) return;
+ var to_write = self.write_buffer.?.slice();
+ if (to_write.len == 0) {
+ return;
+ }
+
+ self.last_send_result = 0;
+
+ AsyncIO.global.send(
+ *AsyncBIO,
+ self,
+ Sender.onSend,
+ &self.send_completion,
+ self.socket_fd,
+ to_write,
+ SOCKET_FLAGS,
+ );
+ self.send_wait = .suspended;
+ if (extremely_verbose) {
+ Output.prettyErrorln("enqueueSend: {d}", .{to_write.len});
+ Output.flush();
+ }
+ }
+
+ const Reader = struct {
+ pub fn onRead(this: *AsyncBIO, _: *Completion, result: AsyncIO.RecvError!usize) void {
+ this.last_read_result = result;
+ this.read_wait = .completed;
+ if (extremely_verbose) {
+ const read_result = result catch @as(usize, 999);
+ Output.prettyErrorln("onRead: {d}", .{read_result});
+ Output.flush();
+ }
+ if (this.pending_frame.readItem()) |frame| {
+ resume frame;
+ }
+ }
+ };
+
+ pub fn enqueueRead(self: *AsyncBIO, read_buf: []u8, off: u64) void {
+ var read_buffer = read_buf[off..];
+ if (read_buffer.len == 0) {
+ return;
+ }
+
+ self.last_read_result = 0;
+ AsyncIO.global.recv(*AsyncBIO, self, Reader.onRead, &self.recv_completion, self.socket_fd, read_buffer);
+ self.read_wait = .suspended;
+ if (extremely_verbose) {
+ Output.prettyErrorln("enqueuedRead: {d}", .{read_buf.len});
+ Output.flush();
+ }
+ }
+
+ pub const Bio = struct {
+ inline fn cast(bio: *boring.BIO) *AsyncBIO {
+ return @ptrCast(*AsyncBIO, @alignCast(@alignOf(*AsyncBIO), boring.BIO_get_data(bio)));
+ }
+
+ pub fn create(this_bio: *boring.BIO) callconv(.C) c_int {
+ boring.BIO_set_init(this_bio, 1);
+ return 1;
+ }
+ pub fn destroy(this_bio: *boring.BIO) callconv(.C) c_int {
+ boring.BIO_set_init(this_bio, 0);
+
+ if (boring.BIO_get_data(this_bio) != null) {
+ var this = cast(this_bio);
+ this.release();
+ }
+
+ return 0;
+ }
+ pub fn write(this_bio: *boring.BIO, ptr: [*c]const u8, len: c_int) callconv(.C) c_int {
+ std.debug.assert(@ptrToInt(ptr) > 0 and len >= 0);
+
+ var buf = ptr[0..@intCast(usize, len)];
+ boring.BIO_clear_flags(this_bio, boring.BIO_FLAGS_RWS | boring.BIO_FLAGS_SHOULD_RETRY);
+
+ if (len <= 0) {
+ return 0;
+ }
+
+ var this = cast(this_bio);
+ if (this.read_wait == .suspended) {
+ boring.BIO_set_flags(this_bio, (boring.BIO_FLAGS_RWS | boring.BIO_FLAGS_SHOULD_RETRY));
+ return -1;
+ }
+
+ switch (this.send_wait) {
+ .pending => {
+ var write_buffer = this.write_buffer orelse brk: {
+ this.write_buffer = AsyncMessage.get(this.allocator);
+ break :brk this.write_buffer.?;
+ };
+
+ _ = write_buffer.writeAll(buf);
+ boring.BIO_set_flags(this_bio, (boring.BIO_FLAGS_RWS | boring.BIO_FLAGS_SHOULD_RETRY));
+
+ return -1;
+ },
+ .suspended => {
+ boring.BIO_set_flags(this_bio, (boring.BIO_FLAGS_RWS | boring.BIO_FLAGS_SHOULD_RETRY));
+
+ return -1;
+ },
+ .completed => {
+ this.send_wait = .pending;
+ const written = this.last_send_result catch |err| {
+ Output.prettyErrorln("HTTPS error: {s}", .{@errorName(err)});
+ Output.flush();
+ boring.BIO_set_flags(this_bio, (boring.BIO_FLAGS_RWS | boring.BIO_FLAGS_SHOULD_RETRY));
+ return -1;
+ };
+ this.last_send_result = 0;
+ return @intCast(c_int, written);
+ },
+ }
+
+ unreachable;
+ }
+
+ pub fn read(this_bio: *boring.BIO, ptr: [*c]u8, len: c_int) callconv(.C) c_int {
+ std.debug.assert(@ptrToInt(ptr) > 0 and len >= 0);
+ var buf = ptr[0..@intCast(usize, len)];
+
+ boring.BIO_clear_flags(this_bio, boring.BIO_FLAGS_RWS | boring.BIO_FLAGS_SHOULD_RETRY);
+ var this = cast(this_bio);
+
+ switch (this.read_wait) {
+ .pending => {
+ this.enqueueRead(buf, 0);
+ boring.BIO_set_flags(this_bio, (boring.BIO_FLAGS_WRITE | boring.BIO_FLAGS_SHOULD_RETRY));
+ return -1;
+ },
+ .suspended => {
+ boring.BIO_set_flags(this_bio, (boring.BIO_FLAGS_WRITE | boring.BIO_FLAGS_SHOULD_RETRY));
+ return -1;
+ },
+ .completed => {
+ this.read_wait = .pending;
+ const read_len = this.last_read_result catch |err| {
+ Output.prettyErrorln("HTTPS error: {s}", .{@errorName(err)});
+ Output.flush();
+ boring.BIO_set_flags(this_bio, (boring.BIO_FLAGS_WRITE | boring.BIO_FLAGS_SHOULD_RETRY));
+ return -1;
+ };
+ this.last_read_result = 0;
+ return @intCast(c_int, read_len);
+ },
+ }
+ unreachable;
+ }
+ pub fn ctrl(this_bio: *boring.BIO, cmd: c_int, larg: c_long, pargs: ?*c_void) callconv(.C) c_long {
+ return switch (cmd) {
+ boring.BIO_CTRL_PENDING, boring.BIO_CTRL_WPENDING => 0,
+ else => 1,
+ };
+ }
+ };
+};
+
+pub fn buildRequest(this: *HTTPClient, body_len: usize) picohttp.Request {
+ var header_count: usize = 0;
+ var header_entries = this.header_entries.slice();
+ var header_names = header_entries.items(.name);
+ var header_values = header_entries.items(.value);
+ var request_headers_buf = &this.request_headers_buf;
+
+ var override_accept_encoding = false;
+ var override_accept_header = false;
+
+ var override_user_agent = false;
+ for (header_names) |head, i| {
+ const name = this.headerStr(head);
+ // Hash it as lowercase
+ const hash = hashHeaderName(name);
+
+ // Skip host and connection header
+ // we manage those
+ switch (hash) {
+ host_header_hash,
+ connection_header_hash,
+ content_length_header_hash,
+ => continue,
+ hashHeaderName("if-modified-since") => {
+ if (this.force_last_modified and this.if_modified_since.len == 0) {
+ this.if_modified_since = this.headerStr(header_values[i]);
+ }
+ },
+ accept_header_hash => {
+ override_accept_header = true;
+ },
+ else => {},
+ }
+
+ override_user_agent = override_user_agent or hash == user_agent_header_hash;
+
+ override_accept_encoding = override_accept_encoding or hash == accept_encoding_header_hash;
+
+ request_headers_buf[header_count] = (picohttp.Header{
+ .name = name,
+ .value = this.headerStr(header_values[i]),
+ });
+
+ // header_name_hashes[header_count] = hash;
+
+ // // ensure duplicate headers come after each other
+ // if (header_count > 2) {
+ // var head_i: usize = header_count - 1;
+ // while (head_i > 0) : (head_i -= 1) {
+ // if (header_name_hashes[head_i] == header_name_hashes[header_count]) {
+ // std.mem.swap(picohttp.Header, &header_name_hashes[header_count], &header_name_hashes[head_i + 1]);
+ // std.mem.swap(u64, &request_headers_buf[header_count], &request_headers_buf[head_i + 1]);
+ // break;
+ // }
+ // }
+ // }
+ header_count += 1;
+ }
+
+ // request_headers_buf[header_count] = connection_header;
+ // header_count += 1;
+
+ if (!override_user_agent) {
+ request_headers_buf[header_count] = user_agent_header;
+ header_count += 1;
+ }
+
+ if (!override_accept_header) {
+ request_headers_buf[header_count] = accept_header;
+ header_count += 1;
+ }
+
+ request_headers_buf[header_count] = picohttp.Header{
+ .name = host_header_name,
+ .value = this.url.hostname,
+ };
+ header_count += 1;
+
+ if (!override_accept_encoding) {
+ request_headers_buf[header_count] = accept_encoding_header;
+ header_count += 1;
+ }
+
+ if (body_len > 0) {
+ request_headers_buf[header_count] = picohttp.Header{
+ .name = content_length_header_name,
+ .value = std.fmt.bufPrint(&this.request_content_len_buf, "{d}", .{body_len}) catch "0",
+ };
+ header_count += 1;
+ }
+
+ return picohttp.Request{
+ .method = @tagName(this.method),
+ .path = this.url.pathname,
+ .minor_version = 1,
+ .headers = request_headers_buf[0..header_count],
+ };
+}
+
+pub fn connect(
+ this: *HTTPClient,
+ comptime ConnectType: type,
+ connector: ConnectType,
+) !void {
+ const port = this.url.getPortAuto();
+
+ try connector.connect(this.url.hostname, port);
+ var client = std.x.net.tcp.Client{ .socket = std.x.os.Socket.from(this.socket.socket.socket) };
+ client.setNoDelay(true) catch {};
+ client.setReadBufferSize(BufferPool.len) catch {};
+ client.setQuickACK(true) catch {};
+ this.tcp_client = client;
+ if (this.timeout > 0) {
+ client.setReadTimeout(@truncate(u32, this.timeout / std.time.ns_per_ms)) catch {};
+ client.setWriteTimeout(@truncate(u32, this.timeout / std.time.ns_per_ms)) catch {};
+ }
+}
+
+pub fn sendAsync(this: *HTTPClient, body: []const u8, body_out_str: *MutableString) @Frame(HTTPClient.send) {
+ return async this.send(body, body_out_str);
+}
+
+pub fn send(this: *HTTPClient, body: []const u8, body_out_str: *MutableString) !picohttp.Response {
+ // this prevents stack overflow
+ redirect: while (this.remaining_redirect_count >= -1) {
+ if (this.url.isHTTPS()) {
+ return this.sendHTTPS(body, body_out_str) catch |err| {
+ switch (err) {
+ error.Redirect => {
+ this.remaining_redirect_count -= 1;
+ this.socket.deinit();
+
+ continue :redirect;
+ },
+ else => return err,
+ }
+ };
+ } else {
+ return this.sendHTTP(body, body_out_str) catch |err| {
+ switch (err) {
+ error.Redirect => {
+ this.remaining_redirect_count -= 1;
+ this.socket.socket.deinit();
+
+ continue :redirect;
+ },
+ else => return err,
+ }
+ };
+ }
+ }
+
+ return error.TooManyRedirects;
+}
+
+const Task = ThreadPool.Task;
+
+pub fn sendHTTP(this: *HTTPClient, body: []const u8, body_out_str: *MutableString) !picohttp.Response {
+ this.socket = AsyncSocket.SSL{
+ .socket = try AsyncSocket.init(&AsyncIO.global, 0, this.allocator),
+ };
+ var socket = &this.socket.socket;
+ try this.connect(*AsyncSocket, socket);
+
+ defer this.socket.close();
+ var request = buildRequest(this, body.len);
+ if (this.verbose) {
+ Output.prettyErrorln("{s}", .{request});
+ }
+
+ try writeRequest(@TypeOf(socket), socket, request, body);
+ _ = try socket.send();
+
+ if (this.progress_node == null) {
+ return this.processResponse(
+ false,
+ false,
+ @TypeOf(socket),
+ socket,
+ body_out_str,
+ );
+ } else {
+ return this.processResponse(
+ false,
+ true,
+ @TypeOf(socket),
+ socket,
+ body_out_str,
+ );
+ }
+}
+
+const ZlibPool = struct {
+ lock: Lock = Lock.init(),
+ items: std.ArrayList(*MutableString),
+ allocator: *std.mem.Allocator,
+ pub var instance: ZlibPool = undefined;
+ pub var loaded: bool = false;
+ pub var decompression_thread_pool: ThreadPool = undefined;
+ pub var decompression_thread_pool_loaded: bool = false;
+
+ pub fn init(allocator: *std.mem.Allocator) ZlibPool {
+ return ZlibPool{
+ .allocator = allocator,
+ .items = std.ArrayList(*MutableString).init(allocator),
+ };
+ }
+
+ pub fn get(this: *ZlibPool) !*MutableString {
+ switch (this.items.items.len) {
+ 0 => {
+ var mutable = try this.allocator.create(MutableString);
+ mutable.* = try MutableString.init(this.allocator, 0);
+ return mutable;
+ },
+ else => {
+ return this.items.pop();
+ },
+ }
+
+ return item;
+ }
+
+ pub fn put(this: *ZlibPool, mutable: *MutableString) !void {
+ mutable.reset();
+ try this.items.append(mutable);
+ }
+
+ pub fn decompress(compressed_data: []const u8, output: *MutableString) Zlib.ZlibError!void {
+ // Heuristic: if we have more than 128 KB of data to decompress
+ // it may take 1ms or so
+ // We must keep the network thread unblocked as often as possible
+ // So if we have more than 50 KB of data to decompress, we do it off the network thread
+ // if (compressed_data.len < 50_000) {
+ var reader = try Zlib.ZlibReaderArrayList.init(compressed_data, &output.list, default_allocator);
+ try reader.readAll();
+ return;
+ // }
+
+ // var task = try DecompressionTask.get(default_allocator);
+ // defer task.release();
+ // task.* = DecompressionTask{
+ // .data = compressed_data,
+ // .output = output,
+ // .event_fd = AsyncIO.global.eventfd(),
+ // };
+ // task.scheduleAndWait();
+
+ // if (task.err) |err| {
+ // return @errSetCast(Zlib.ZlibError, err);
+ // }
+ }
+
+ pub const DecompressionTask = struct {
+ task: ThreadPool.Task = ThreadPool.Task{ .callback = callback },
+ frame: @Frame(scheduleAndWait) = undefined,
+ data: []const u8,
+ output: *MutableString = undefined,
+ completion: Completion = undefined,
+ event_fd: std.os.fd_t = 0,
+ err: ?anyerror = null,
+ next: ?*DecompressionTask = null,
+
+ pub var head: ?*DecompressionTask = null;
+
+ pub fn get(allocator: *std.mem.Allocator) !*DecompressionTask {
+ if (head) |head_| {
+ var this = head_;
+ head = this.next;
+ this.next = null;
+ return this;
+ }
+
+ return try allocator.create(DecompressionTask);
+ }
+
+ pub fn scheduleAndWait(task: *DecompressionTask) void {
+ if (!decompression_thread_pool_loaded) {
+ decompression_thread_pool_loaded = true;
+ decompression_thread_pool = ThreadPool.init(.{ .max_threads = 1 });
+ }
+
+ AsyncIO.global.event(
+ *DecompressionTask,
+ task,
+ DecompressionTask.finished,
+ &task.completion,
+ task.event_fd,
+ );
+
+ suspend {
+ var batch = ThreadPool.Batch.from(&task.task);
+ decompression_thread_pool.schedule(batch);
+ task.frame = @frame().*;
+ }
+ }
+
+ pub fn release(this: *DecompressionTask) void {
+ this.next = head;
+ head = this;
+ }
+
+ fn callback_(this: *DecompressionTask) Zlib.ZlibError!void {
+ var reader = try Zlib.ZlibReaderArrayList.init(this.data, &this.output.list, default_allocator);
+ try reader.readAll();
+ }
+
+ pub fn callback(task: *ThreadPool.Task) void {
+ var this: *DecompressionTask = @fieldParentPtr(DecompressionTask, "task", task);
+ this.callback_() catch |err| {
+ this.err = err;
+ };
+ AsyncIO.triggerEvent(this.event_fd, &this.completion) catch {};
+ }
+
+ pub fn finished(this: *DecompressionTask, completion: *Completion, _: void) void {
+ resume this.frame;
+ }
+ };
+};
+
+pub fn processResponse(this: *HTTPClient, comptime is_https: bool, comptime report_progress: bool, comptime Client: type, client: Client, body_out_str: *MutableString) !picohttp.Response {
+ defer if (this.verbose) Output.flush();
+ var response: picohttp.Response = undefined;
+ var request_message = AsyncMessage.get(this.allocator);
+ defer request_message.release();
+ var request_buffer: []u8 = request_message.buf;
+ var read_length: usize = 0;
+ {
+ var read_headers_up_to: usize = 0;
+
+ var req_buf_read: usize = std.math.maxInt(usize);
+ defer this.read_count += @intCast(u32, read_length);
+
+ restart: while (req_buf_read != 0) {
+ req_buf_read = try client.read(request_buffer, read_length);
+ read_length += req_buf_read;
+ if (comptime report_progress) {
+ this.progress_node.?.activate();
+ this.progress_node.?.setCompletedItems(read_length);
+ this.progress_node.?.context.maybeRefresh();
+ }
+
+ var request_body = request_buffer[0..read_length];
+ read_headers_up_to = if (read_headers_up_to > read_length) read_length else read_headers_up_to;
+
+ response = picohttp.Response.parseParts(request_body, &this.response_headers_buf, &read_headers_up_to) catch |err| {
+ switch (err) {
+ error.ShortRead => {
+ continue :restart;
+ },
+ else => {
+ return err;
+ },
+ }
+ };
+ break :restart;
+ }
+ }
+ if (read_length == 0) {
+ return error.NoData;
+ }
+
+ body_out_str.reset();
+ var content_length: u32 = 0;
+ var encoding = Encoding.identity;
+ var transfer_encoding = Encoding.identity;
+
+ var location: string = "";
+
+ var pretend_its_304 = false;
+
+ for (response.headers) |header| {
+ switch (hashHeaderName(header.name)) {
+ content_length_header_hash => {
+ content_length = std.fmt.parseInt(u32, header.value, 10) catch 0;
+ try body_out_str.inflate(content_length);
+ body_out_str.list.expandToCapacity();
+ this.body_size = content_length;
+ },
+ content_encoding_hash => {
+ if (strings.eqlComptime(header.value, "gzip")) {
+ encoding = Encoding.gzip;
+ } else if (strings.eqlComptime(header.value, "deflate")) {
+ encoding = Encoding.deflate;
+ } else if (!strings.eqlComptime(header.value, "identity")) {
+ return error.UnsupportedContentEncoding;
+ }
+ },
+ transfer_encoding_header => {
+ if (strings.eqlComptime(header.value, "gzip")) {
+ transfer_encoding = Encoding.gzip;
+ } else if (strings.eqlComptime(header.value, "deflate")) {
+ transfer_encoding = Encoding.deflate;
+ } else if (strings.eqlComptime(header.value, "identity")) {
+ transfer_encoding = Encoding.identity;
+ } else if (strings.eqlComptime(header.value, "chunked")) {
+ transfer_encoding = Encoding.chunked;
+ } else {
+ return error.UnsupportedTransferEncoding;
+ }
+ },
+ location_header_hash => {
+ location = header.value;
+ },
+ hashHeaderName("Last-Modified") => {
+ if (this.force_last_modified and response.status_code > 199 and response.status_code < 300 and this.if_modified_since.len > 0) {
+ if (strings.eql(this.if_modified_since, header.value)) {
+ pretend_its_304 = true;
+ }
+ }
+ },
+
+ else => {},
+ }
+ }
+
+ if (this.verbose) {
+ Output.prettyErrorln("Response: {s}", .{response});
+ }
+
+ if (location.len > 0 and this.remaining_redirect_count > 0) {
+ switch (response.status_code) {
+ 302, 301, 307, 308, 303 => {
+ if (strings.indexOf(location, "://")) |i| {
+ var url_buf = this.redirect orelse try URLBufferPool.get(this.allocator);
+
+ const protocol_name = location[0..i];
+ if (strings.eqlComptime(protocol_name, "http") or strings.eqlComptime(protocol_name, "https")) {} else {
+ return error.UnsupportedRedirectProtocol;
+ }
+
+ std.mem.copy(u8, &url_buf.buf, location);
+ this.url = URL.parse(url_buf.buf[0..location.len]);
+ this.redirect = url_buf;
+ } else {
+ var url_buf = try URLBufferPool.get(this.allocator);
+ const original_url = this.url;
+ this.url = URL.parse(std.fmt.bufPrint(
+ &url_buf.buf,
+ "{s}://{s}{s}",
+ .{ original_url.displayProtocol(), original_url.displayHostname(), location },
+ ) catch return error.RedirectURLTooLong);
+
+ if (this.redirect) |red| {
+ red.release();
+ }
+
+ this.redirect = url_buf;
+ }
+
+ // Ensure we don't up ove
+
+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/303
+ if (response.status_code == 303) {
+ this.method = .GET;
+ }
+
+ return error.Redirect;
+ },
+ else => {},
+ }
+ }
+
+ body_getter: {
+ if (pretend_its_304) {
+ response.status_code = 304;
+ }
+
+ if (response.status_code == 304) break :body_getter;
+
+ if (transfer_encoding == Encoding.chunked) {
+ var decoder = std.mem.zeroes(picohttp.phr_chunked_decoder);
+ var buffer_: *MutableString = body_out_str;
+
+ switch (encoding) {
+ Encoding.gzip, Encoding.deflate => {
+ if (!ZlibPool.loaded) {
+ ZlibPool.instance = ZlibPool.init(default_allocator);
+ ZlibPool.loaded = true;
+ }
+
+ buffer_ = try ZlibPool.instance.get();
+ },
+ else => {},
+ }
+
+ var buffer = buffer_.*;
+
+ var last_read: usize = 0;
+ {
+ var remainder = request_buffer[@intCast(usize, response.bytes_read)..read_length];
+ last_read = remainder.len;
+ try buffer.inflate(std.math.max(remainder.len, 2048));
+ buffer.list.expandToCapacity();
+ std.mem.copy(u8, buffer.list.items, remainder);
+ }
+
+ // set consume_trailer to 1 to discard the trailing header
+ // using content-encoding per chunk is not supported
+ decoder.consume_trailer = 1;
+
+ // these variable names are terrible
+ // it's copypasta from https://github.com/h2o/picohttpparser#phr_decode_chunked
+ // (but ported from C -> zig)
+ var rret: usize = 0;
+ var rsize: usize = last_read;
+ var pret: isize = picohttp.phr_decode_chunked(&decoder, buffer.list.items.ptr, &rsize);
+ var total_size = rsize;
+
+ while (pret == -2) {
+ if (buffer.list.items[total_size..].len < @intCast(usize, decoder.bytes_left_in_chunk) or buffer.list.items[total_size..].len < 512) {
+ try buffer.inflate(std.math.max(total_size * 2, 1024));
+ buffer.list.expandToCapacity();
+ }
+
+ rret = try client.read(buffer.list.items, total_size);
+
+ if (rret == 0) {
+ return error.ChunkedEncodingError;
+ }
+
+ rsize = rret;
+ pret = picohttp.phr_decode_chunked(&decoder, buffer.list.items[total_size..].ptr, &rsize);
+ if (pret == -1) return error.ChunkedEncodingParseError;
+
+ total_size += rsize;
+
+ if (comptime report_progress) {
+ this.progress_node.?.activate();
+ this.progress_node.?.setCompletedItems(total_size);
+ this.progress_node.?.context.maybeRefresh();
+ }
+ }
+
+ buffer.list.shrinkRetainingCapacity(total_size);
+ buffer_.* = buffer;
+
+ switch (encoding) {
+ Encoding.gzip, Encoding.deflate => {
+ var gzip_timer = std.time.Timer.start() catch @panic("Timer failure");
+ body_out_str.list.expandToCapacity();
+ defer ZlibPool.instance.put(buffer_) catch unreachable;
+ ZlibPool.decompress(buffer.list.items, body_out_str) catch |err| {
+ Output.prettyErrorln("<r><red>Zlib error<r>", .{});
+ Output.flush();
+ return err;
+ };
+ this.gzip_elapsed = gzip_timer.read();
+ },
+ else => {},
+ }
+
+ if (comptime report_progress) {
+ this.progress_node.?.activate();
+ this.progress_node.?.setCompletedItems(body_out_str.list.items.len);
+ this.progress_node.?.context.maybeRefresh();
+ }
+
+ this.body_size = @intCast(u32, body_out_str.list.items.len);
+ return response;
+ }
+
+ if (content_length > 0) {
+ var remaining_content_length = content_length;
+ var remainder = request_buffer[@intCast(usize, response.bytes_read)..read_length];
+ remainder = remainder[0..std.math.min(remainder.len, content_length)];
+ var buffer_: *MutableString = body_out_str;
+
+ switch (encoding) {
+ Encoding.gzip, Encoding.deflate => {
+ if (!ZlibPool.loaded) {
+ ZlibPool.instance = ZlibPool.init(default_allocator);
+ ZlibPool.loaded = true;
+ }
+
+ buffer_ = try ZlibPool.instance.get();
+ if (buffer_.list.capacity < remaining_content_length) {
+ try buffer_.list.ensureUnusedCapacity(buffer_.allocator, remaining_content_length);
+ }
+ buffer_.list.items = buffer_.list.items.ptr[0..remaining_content_length];
+ },
+ else => {},
+ }
+ var buffer = buffer_.*;
+
+ var body_size: usize = 0;
+ if (remainder.len > 0) {
+ std.mem.copy(u8, buffer.list.items, remainder);
+ body_size = remainder.len;
+ this.read_count += @intCast(u32, body_size);
+ remaining_content_length -= @intCast(u32, remainder.len);
+ }
+
+ while (remaining_content_length > 0) {
+ const size = @intCast(u32, try client.read(
+ buffer.list.items,
+ body_size,
+ ));
+ this.read_count += size;
+ if (size == 0) break;
+
+ body_size += size;
+ remaining_content_length -= size;
+
+ if (comptime report_progress) {
+ this.progress_node.?.activate();
+ this.progress_node.?.setCompletedItems(body_size);
+ this.progress_node.?.context.maybeRefresh();
+ }
+ }
+
+ if (comptime report_progress) {
+ this.progress_node.?.activate();
+ this.progress_node.?.setCompletedItems(body_size);
+ this.progress_node.?.context.maybeRefresh();
+ }
+
+ buffer.list.shrinkRetainingCapacity(body_size);
+ buffer_.* = buffer;
+
+ switch (encoding) {
+ Encoding.gzip, Encoding.deflate => {
+ var gzip_timer = std.time.Timer.start() catch @panic("Timer failure");
+ body_out_str.list.expandToCapacity();
+ defer ZlibPool.instance.put(buffer_) catch unreachable;
+ ZlibPool.decompress(buffer.list.items, body_out_str) catch |err| {
+ Output.prettyErrorln("<r><red>Zlib error<r>", .{});
+ Output.flush();
+ return err;
+ };
+ this.gzip_elapsed = gzip_timer.read();
+ },
+ else => {},
+ }
+ }
+ }
+
+ if (comptime report_progress) {
+ this.progress_node.?.activate();
+ this.progress_node.?.setCompletedItems(body_out_str.list.items.len);
+ this.progress_node.?.context.maybeRefresh();
+ }
+
+ return response;
+}
+
+pub fn sendHTTPS(this: *HTTPClient, body_str: []const u8, body_out_str: *MutableString) !picohttp.Response {
+ this.socket = try AsyncSocket.SSL.init(this.allocator, &AsyncIO.global);
+ var socket = &this.socket;
+ try this.connect(*AsyncSocket.SSL, socket);
+ defer this.socket.close();
+
+ var request = buildRequest(this, body_str.len);
+ if (this.verbose) {
+ Output.prettyErrorln("{s}", .{request});
+ }
+
+ try writeRequest(@TypeOf(socket), socket, request, body_str);
+ _ = try socket.send();
+
+ if (this.progress_node == null) {
+ return this.processResponse(
+ false,
+ false,
+ @TypeOf(socket),
+ socket,
+ body_out_str,
+ );
+ } else {
+ return this.processResponse(
+ false,
+ true,
+ @TypeOf(socket),
+ socket,
+ body_out_str,
+ );
+ }
+}
+
+// zig test src/http_client.zig --test-filter "sendHTTP - only" -lc -lc++ /Users/jarred/Code/bun/src/deps/zlib/libz.a /Users/jarred/Code/bun/src/deps/picohttpparser.o --cache-dir /Users/jarred/Code/bun/zig-cache --global-cache-dir /Users/jarred/.cache/zig --name bun --pkg-begin clap /Users/jarred/Code/bun/src/deps/zig-clap/clap.zig --pkg-end --pkg-begin picohttp /Users/jarred/Code/bun/src/deps/picohttp.zig --pkg-end --pkg-begin iguanaTLS /Users/jarred/Code/bun/src/deps/iguanaTLS/src/main.zig --pkg-end -I /Users/jarred/Code/bun/src/deps -I /Users/jarred/Code/bun/src/deps/mimalloc -I /usr/local/opt/icu4c/include -L src/deps/mimalloc -L /usr/local/opt/icu4c/lib --main-pkg-path /Users/jarred/Code/bun --enable-cache -femit-bin=zig-out/bin/test --test-no-exec
+test "sendHTTP - only" {
+ Output.initTest();
+ defer Output.flush();
+
+ var headers = try std.heap.c_allocator.create(Headers);
+ headers.* = Headers{
+ .entries = @TypeOf(headers.entries){},
+ .buf = @TypeOf(headers.buf){},
+ .used = 0,
+ .allocator = std.heap.c_allocator,
+ };
+
+ // headers.appendHeader("X-What", "ok", true, true, false);
+ headers.appendHeader("Accept-Encoding", "identity", true, true, false);
+
+ var client = HTTPClient.init(
+ std.heap.c_allocator,
+ .GET,
+ URL.parse("http://example.com/"),
+ headers.entries,
+ headers.buf.items,
+ );
+ var body_out_str = try MutableString.init(std.heap.c_allocator, 0);
+ var response = try client.sendHTTP("", &body_out_str);
+ try std.testing.expectEqual(response.status_code, 200);
+ try std.testing.expectEqual(body_out_str.list.items.len, 1256);
+ try std.testing.expectEqualStrings(body_out_str.list.items, @embedFile("fixtures_example.com.html"));
+}
+
+// zig test src/http_client.zig --test-filter "sendHTTP - gzip" -lc -lc++ /Users/jarred/Code/bun/src/deps/zlib/libz.a /Users/jarred/Code/bun/src/deps/picohttpparser.o --cache-dir /Users/jarred/Code/bun/zig-cache --global-cache-dir /Users/jarred/.cache/zig --name bun --pkg-begin clap /Users/jarred/Code/bun/src/deps/zig-clap/clap.zig --pkg-end --pkg-begin picohttp /Users/jarred/Code/bun/src/deps/picohttp.zig --pkg-end --pkg-begin iguanaTLS /Users/jarred/Code/bun/src/deps/iguanaTLS/src/main.zig --pkg-end -I /Users/jarred/Code/bun/src/deps -I /Users/jarred/Code/bun/src/deps/mimalloc -I /usr/local/opt/icu4c/include -L src/deps/mimalloc -L /usr/local/opt/icu4c/lib --main-pkg-path /Users/jarred/Code/bun --enable-cache -femit-bin=zig-out/bin/test --test-no-exec
+test "sendHTTP - gzip" {
+ Output.initTest();
+ defer Output.flush();
+
+ var headers = try std.heap.c_allocator.create(Headers);
+ headers.* = Headers{
+ .entries = @TypeOf(headers.entries){},
+ .buf = @TypeOf(headers.buf){},
+ .used = 0,
+ .allocator = std.heap.c_allocator,
+ };
+
+ // headers.appendHeader("X-What", "ok", true, true, false);
+ headers.appendHeader("Accept-Encoding", "gzip", true, true, false);
+
+ var client = HTTPClient.init(
+ std.heap.c_allocator,
+ .GET,
+ URL.parse("http://example.com/"),
+ headers.entries,
+ headers.buf.items,
+ );
+ var body_out_str = try MutableString.init(std.heap.c_allocator, 0);
+ var response = try client.sendHTTP("", &body_out_str);
+ try std.testing.expectEqual(response.status_code, 200);
+ try std.testing.expectEqualStrings(body_out_str.list.items, @embedFile("fixtures_example.com.html"));
+}
+
+// zig test src/http_client.zig --test-filter "sendHTTPS - identity" -lc -lc++ /Users/jarred/Code/bun/src/deps/zlib/libz.a /Users/jarred/Code/bun/src/deps/picohttpparser.o --cache-dir /Users/jarred/Code/bun/zig-cache --global-cache-dir /Users/jarred/.cache/zig --name bun --pkg-begin clap /Users/jarred/Code/bun/src/deps/zig-clap/clap.zig --pkg-end --pkg-begin picohttp /Users/jarred/Code/bun/src/deps/picohttp.zig --pkg-end --pkg-begin iguanaTLS /Users/jarred/Code/bun/src/deps/iguanaTLS/src/main.zig --pkg-end -I /Users/jarred/Code/bun/src/deps -I /Users/jarred/Code/bun/src/deps/mimalloc -I /usr/local/opt/icu4c/include -L src/deps/mimalloc -L /usr/local/opt/icu4c/lib --main-pkg-path /Users/jarred/Code/bun --enable-cache -femit-bin=zig-out/bin/test --test-no-exec
+test "sendHTTPS - identity" {
+ Output.initTest();
+ defer Output.flush();
+
+ var headers = try std.heap.c_allocator.create(Headers);
+ headers.* = Headers{
+ .entries = @TypeOf(headers.entries){},
+ .buf = @TypeOf(headers.buf){},
+ .used = 0,
+ .allocator = std.heap.c_allocator,
+ };
+
+ headers.appendHeader("X-What", "ok", true, true, false);
+ headers.appendHeader("Accept-Encoding", "identity", true, true, false);
+
+ var client = HTTPClient.init(
+ std.heap.c_allocator,
+ .GET,
+ URL.parse("https://example.com/"),
+ headers.entries,
+ headers.buf.items,
+ );
+ var body_out_str = try MutableString.init(std.heap.c_allocator, 0);
+ var response = try client.sendHTTPS("", &body_out_str);
+ try std.testing.expectEqual(response.status_code, 200);
+ try std.testing.expectEqualStrings(body_out_str.list.items, @embedFile("fixtures_example.com.html"));
+}
+
+test "sendHTTPS - gzip" {
+ Output.initTest();
+ defer Output.flush();
+
+ var headers = try std.heap.c_allocator.create(Headers);
+ headers.* = Headers{
+ .entries = @TypeOf(headers.entries){},
+ .buf = @TypeOf(headers.buf){},
+ .used = 0,
+ .allocator = std.heap.c_allocator,
+ };
+
+ headers.appendHeader("Accept-Encoding", "gzip", false, false, false);
+
+ var client = HTTPClient.init(
+ std.heap.c_allocator,
+ .GET,
+ URL.parse("https://example.com/"),
+ headers.entries,
+ headers.buf.items,
+ );
+ var body_out_str = try MutableString.init(std.heap.c_allocator, 0);
+ var response = try client.sendHTTPS("", &body_out_str);
+ try std.testing.expectEqual(response.status_code, 200);
+ try std.testing.expectEqualStrings(body_out_str.list.items, @embedFile("fixtures_example.com.html"));
+}
+
+// zig test src/http_client.zig --test-filter "sendHTTPS - deflate" -lc -lc++ /Users/jarred/Code/bun/src/deps/zlib/libz.a /Users/jarred/Code/bun/src/deps/picohttpparser.o --cache-dir /Users/jarred/Code/bun/zig-cache --global-cache-dir /Users/jarred/.cache/zig --name bun --pkg-begin clap /Users/jarred/Code/bun/src/deps/zig-clap/clap.zig --pkg-end --pkg-begin picohttp /Users/jarred/Code/bun/src/deps/picohttp.zig --pkg-end --pkg-begin iguanaTLS /Users/jarred/Code/bun/src/deps/iguanaTLS/src/main.zig --pkg-end -I /Users/jarred/Code/bun/src/deps -I /Users/jarred/Code/bun/src/deps/mimalloc -I /usr/local/opt/icu4c/include -L src/deps/mimalloc -L /usr/local/opt/icu4c/lib --main-pkg-path /Users/jarred/Code/bun --enable-cache -femit-bin=zig-out/bin/test
+test "sendHTTPS - deflate" {
+ Output.initTest();
+ defer Output.flush();
+
+ var headers = try std.heap.c_allocator.create(Headers);
+ headers.* = Headers{
+ .entries = @TypeOf(headers.entries){},
+ .buf = @TypeOf(headers.buf){},
+ .used = 0,
+ .allocator = std.heap.c_allocator,
+ };
+
+ headers.appendHeader("Accept-Encoding", "deflate", false, false, false);
+
+ var client = HTTPClient.init(
+ std.heap.c_allocator,
+ .GET,
+ URL.parse("https://example.com/"),
+ headers.entries,
+ headers.buf.items,
+ );
+ var body_out_str = try MutableString.init(std.heap.c_allocator, 0);
+ var response = try client.sendHTTPS("", &body_out_str);
+ try std.testing.expectEqual(response.status_code, 200);
+ try std.testing.expectEqualStrings(body_out_str.list.items, @embedFile("fixtures_example.com.html"));
+}
+
+// zig test src/http_client.zig --test-filter "sendHTTP" -lc -lc++ /Users/jarred/Code/bun/src/deps/zlib/libz.a /Users/jarred/Code/bun/src/deps/picohttpparser.o --cache-dir /Users/jarred/Code/bun/zig-cache --global-cache-dir /Users/jarred/.cache/zig --name bun --pkg-begin clap /Users/jarred/Code/bun/src/deps/zig-clap/clap.zig --pkg-end --pkg-begin picohttp /Users/jarred/Code/bun/src/deps/picohttp.zig --pkg-end --pkg-begin iguanaTLS /Users/jarred/Code/bun/src/deps/iguanaTLS/src/main.zig --pkg-end -I /Users/jarred/Code/bun/src/deps -I /Users/jarred/Code/bun/src/deps/mimalloc -I /usr/local/opt/icu4c/include -L src/deps/mimalloc -L /usr/local/opt/icu4c/lib --main-pkg-path /Users/jarred/Code/bun --enable-cache -femit-bin=zig-out/bin/test
+
+test "send - redirect" {
+ Output.initTest();
+ defer Output.flush();
+
+ var headers = try std.heap.c_allocator.create(Headers);
+ headers.* = Headers{
+ .entries = @TypeOf(headers.entries){},
+ .buf = @TypeOf(headers.buf){},
+ .used = 0,
+ .allocator = std.heap.c_allocator,
+ };
+
+ headers.appendHeader("Accept-Encoding", "gzip", false, false, false);
+
+ var client = HTTPClient.init(
+ std.heap.c_allocator,
+ .GET,
+ URL.parse("https://www.bun.sh/"),
+ headers.entries,
+ headers.buf.items,
+ );
+ try std.testing.expectEqualStrings(client.url.hostname, "www.bun.sh");
+ var body_out_str = try MutableString.init(std.heap.c_allocator, 0);
+ var response = try client.send("", &body_out_str);
+ try std.testing.expectEqual(response.status_code, 200);
+ try std.testing.expectEqual(client.url.hostname, "bun.sh");
+ try std.testing.expectEqualStrings(body_out_str.list.items, @embedFile("fixtures_example.com.html"));
+}
diff --git a/src/identity_context.zig b/src/identity_context.zig
new file mode 100644
index 000000000..eefdca6b5
--- /dev/null
+++ b/src/identity_context.zig
@@ -0,0 +1,23 @@
+pub fn IdentityContext(comptime Key: type) type {
+ return struct {
+ pub fn hash(this: @This(), key: Key) u64 {
+ return key;
+ }
+
+ pub fn eql(this: @This(), a: Key, b: Key) bool {
+ return a == b;
+ }
+ };
+}
+
+/// When storing hashes as keys in a hash table, we don't want to hash the hashes or else we increase the chance of collisions. This is also marginally faster since it means hashing less stuff.
+/// `ArrayIdentityContext` and `IdentityContext` are distinct because ArrayHashMap expects u32 hashes but HashMap expects u64 hashes.
+const ArrayIdentityContext = struct {
+ pub fn hash(this: @This(), key: u32) u32 {
+ return key;
+ }
+
+ pub fn eql(this: @This(), a: u32, b: u32) bool {
+ return a == b;
+ }
+};
diff --git a/src/install/bin.zig b/src/install/bin.zig
new file mode 100644
index 000000000..fb343a16d
--- /dev/null
+++ b/src/install/bin.zig
@@ -0,0 +1,287 @@
+const ExternalStringList = @import("./install.zig").ExternalStringList;
+const Semver = @import("./semver.zig");
+const ExternalString = Semver.ExternalString;
+const String = Semver.String;
+const std = @import("std");
+const strings = @import("strings");
+const Environment = @import("../env.zig");
+const Path = @import("../resolver/resolve_path.zig");
+const C = @import("../c.zig");
+/// Normalized `bin` field in [package.json](https://docs.npmjs.com/cli/v8/configuring-npm/package-json#bin)
+/// Can be a:
+/// - file path (relative to the package root)
+/// - directory (relative to the package root)
+/// - map where keys are names of the binaries and values are file paths to the binaries
+pub const Bin = extern struct {
+ tag: Tag = Tag.none,
+ value: Value = Value{ .none = .{} },
+
+ pub fn count(this: Bin, buf: []const u8, comptime StringBuilder: type, builder: StringBuilder) void {
+ switch (this.tag) {
+ .file => builder.count(this.value.file.slice(buf)),
+ .named_file => {
+ builder.count(this.value.named_file[0].slice(buf));
+ builder.count(this.value.named_file[1].slice(buf));
+ },
+ .dir => builder.count(this.value.dir.slice(buf)),
+ .map => @panic("Bin.map not implemented yet!!. That means \"bin\" as multiple specific files won't work just yet"),
+ else => {},
+ }
+ }
+
+ pub fn clone(this: Bin, buf: []const u8, comptime StringBuilder: type, builder: StringBuilder) Bin {
+ return switch (this.tag) {
+ .none => Bin{ .tag = .none, .value = .{ .none = .{} } },
+ .file => Bin{
+ .tag = .file,
+ .value = .{ .file = builder.append(String, this.value.file.slice(buf)) },
+ },
+ .named_file => Bin{
+ .tag = .named_file,
+ .value = .{
+ .named_file = [2]String{
+ builder.append(String, this.value.named_file[0].slice(buf)),
+ builder.append(String, this.value.named_file[1].slice(buf)),
+ },
+ },
+ },
+ .dir => Bin{
+ .tag = .dir,
+ .value = .{ .dir = builder.append(String, this.value.dir.slice(buf)) },
+ },
+ .map => @panic("Bin.map not implemented yet!!. That means \"bin\" as multiple specific files won't work just yet"),
+ };
+ }
+
+ pub const Value = extern union {
+ /// no "bin", or empty "bin"
+ none: void,
+
+ /// "bin" is a string
+ /// ```
+ /// "bin": "./bin/foo",
+ /// ```
+ file: String,
+
+ // Single-entry map
+ ///```
+ /// "bin": {
+ /// "babel": "./cli.js",
+ /// }
+ ///```
+ named_file: [2]String,
+
+ /// "bin" is a directory
+ ///```
+ /// "dirs": {
+ /// "bin": "./bin",
+ /// }
+ ///```
+ dir: String,
+ // "bin" is a map
+ ///```
+ /// "bin": {
+ /// "babel": "./cli.js",
+ /// "babel-cli": "./cli.js",
+ /// }
+ ///```
+ map: ExternalStringList,
+ };
+
+ pub const Tag = enum(u8) {
+ /// no bin field
+ none = 0,
+ /// "bin" is a string
+ /// ```
+ /// "bin": "./bin/foo",
+ /// ```
+ file = 1,
+
+ // Single-entry map
+ ///```
+ /// "bin": {
+ /// "babel": "./cli.js",
+ /// }
+ ///```
+ named_file = 2,
+ /// "bin" is a directory
+ ///```
+ /// "dirs": {
+ /// "bin": "./bin",
+ /// }
+ ///```
+ dir = 3,
+ // "bin" is a map
+ ///```
+ /// "bin": {
+ /// "babel": "./cli.js",
+ /// "babel-cli": "./cli.js",
+ /// }
+ ///```
+ map = 4,
+ };
+
+ pub const Linker = struct {
+ bin: Bin,
+
+ package_installed_node_modules: std.os.fd_t = std.math.maxInt(std.os.fd_t),
+ root_node_modules_folder: std.os.fd_t = std.math.maxInt(std.os.fd_t),
+
+ /// Used for generating relative paths
+ package_name: strings.StringOrTinyString,
+
+ string_buf: []const u8,
+
+ err: ?anyerror = null,
+
+ pub var umask: std.os.mode_t = 0;
+
+ pub const Error = error{
+ NotImplementedYet,
+ } || std.os.SymLinkError || std.os.OpenError || std.os.RealPathError;
+
+ // It is important that we use symlinkat(2) with relative paths instead of symlink()
+ // That way, if you move your node_modules folder around, the symlinks in .bin still work
+ // If we used absolute paths for the symlinks, you'd end up with broken symlinks
+ pub fn link(this: *Linker) void {
+ var from_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
+ var path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
+
+ from_buf[0..".bin/".len].* = ".bin/".*;
+ var from_remain: []u8 = from_buf[".bin/".len..];
+ path_buf[0.."../".len].* = "../".*;
+
+ var remain: []u8 = path_buf["../".len..];
+ const name = this.package_name.slice();
+ std.mem.copy(u8, remain, name);
+ remain = remain[name.len..];
+ remain[0] = std.fs.path.sep;
+ remain = remain[1..];
+ const base_len = @ptrToInt(remain.ptr) - @ptrToInt(&path_buf);
+
+ if (comptime Environment.isWindows) {
+ @compileError("Bin.Linker.link() needs to be updated to generate .cmd files on Windows");
+ }
+
+ switch (this.bin.tag) {
+ .none => {
+ if (comptime Environment.isDebug) {
+ unreachable;
+ }
+ },
+ .file => {
+ var target = this.bin.value.file.slice(this.string_buf);
+ if (strings.hasPrefix(target, "./")) {
+ target = target[2..];
+ }
+ std.mem.copy(u8, remain, target);
+ remain = remain[target.len..];
+ remain[0] = 0;
+ const target_len = @ptrToInt(remain.ptr) - @ptrToInt(&path_buf);
+ remain = remain[1..];
+
+ var target_path: [:0]u8 = path_buf[0..target_len :0];
+ std.mem.copy(u8, from_remain, name);
+ from_remain = from_remain[name.len..];
+ from_remain[0] = 0;
+ var dest_path: [:0]u8 = from_buf[0 .. @ptrToInt(from_remain.ptr) - @ptrToInt(&from_buf) :0];
+
+ _ = C.chmod(target_path, umask & 0o777);
+ std.os.symlinkatZ(target_path, this.root_node_modules_folder, dest_path) catch |err| {
+ // Silently ignore PathAlreadyExists
+ // Most likely, the symlink was already created by another package
+ if (err == error.PathAlreadyExists) return;
+
+ this.err = err;
+ };
+ },
+ .named_file => {
+ var target = this.bin.value.named_file[1].slice(this.string_buf);
+ if (strings.hasPrefix(target, "./")) {
+ target = target[2..];
+ }
+ std.mem.copy(u8, remain, target);
+ remain = remain[target.len..];
+ remain[0] = 0;
+ const target_len = @ptrToInt(remain.ptr) - @ptrToInt(&path_buf);
+ remain = remain[1..];
+
+ var target_path: [:0]u8 = path_buf[0..target_len :0];
+ var name_to_use = this.bin.value.named_file[0].slice(this.string_buf);
+ std.mem.copy(u8, from_remain, name_to_use);
+ from_remain = from_remain[name_to_use.len..];
+ from_remain[0] = 0;
+ var dest_path: [:0]u8 = from_buf[0 .. @ptrToInt(from_remain.ptr) - @ptrToInt(&from_buf) :0];
+
+ _ = C.chmod(target_path, umask & 0o777);
+ std.os.symlinkatZ(target_path, this.root_node_modules_folder, dest_path) catch |err| {
+ // Silently ignore PathAlreadyExists
+ // Most likely, the symlink was already created by another package
+ if (err == error.PathAlreadyExists) return;
+
+ this.err = err;
+ };
+ },
+ .dir => {
+ var target = this.bin.value.dir.slice(this.string_buf);
+ var parts = [_][]const u8{ name, target };
+ if (strings.hasPrefix(target, "./")) {
+ target = target[2..];
+ }
+ std.mem.copy(u8, remain, target);
+ remain = remain[target.len..];
+ remain[0] = 0;
+ var dir = std.fs.Dir{ .fd = this.package_installed_node_modules };
+
+ var joined = Path.joinStringBuf(&from_buf, &parts, .auto);
+ from_buf[joined.len] = 0;
+ var joined_: [:0]u8 = from_buf[0..joined.len :0];
+ var child_dir = dir.openDirZ(joined_, .{ .iterate = true }) catch |err| {
+ this.err = err;
+ return;
+ };
+ defer child_dir.close();
+
+ var iter = child_dir.iterate();
+
+ var basedir_path = std.os.getFdPath(child_dir.fd, &from_buf) catch |err| {
+ this.err = err;
+ return;
+ };
+ from_buf[basedir_path.len] = std.fs.path.sep;
+ var from_buf_remain = from_buf[basedir_path.len + 1 ..];
+
+ while (iter.next() catch null) |entry_| {
+ const entry: std.fs.Dir.Entry = entry_;
+ switch (entry.kind) {
+ std.fs.Dir.Entry.Kind.SymLink, std.fs.Dir.Entry.Kind.File => {
+ std.mem.copy(u8, from_buf_remain, entry.name);
+ from_buf_remain = from_buf_remain[entry.name.len..];
+ from_buf_remain[0] = 0;
+ var from_path: [:0]u8 = from_buf[0 .. @ptrToInt(from_buf_remain.ptr) - @ptrToInt(&from_buf) :0];
+ var to_path = std.fmt.bufPrintZ(&path_buf, ".bin/{s}", .{entry.name}) catch unreachable;
+ _ = C.chmod(from_path, umask & 0o777);
+ std.os.symlinkatZ(
+ from_path,
+ this.root_node_modules_folder,
+ to_path,
+ ) catch |err| {
+ // Silently ignore PathAlreadyExists
+ // Most likely, the symlink was already created by another package
+ if (err == error.PathAlreadyExists) return;
+
+ this.err = err;
+ return;
+ };
+ },
+ else => {},
+ }
+ }
+ },
+ .map => {
+ this.err = error.NotImplementedYet;
+ },
+ }
+ }
+ };
+};
diff --git a/src/install/bit_set.zig b/src/install/bit_set.zig
new file mode 100644
index 000000000..d788a2ec9
--- /dev/null
+++ b/src/install/bit_set.zig
@@ -0,0 +1,1296 @@
+//! This file defines several variants of bit sets. A bit set
+//! is a densely stored set of integers with a known maximum,
+//! in which each integer gets a single bit. Bit sets have very
+//! fast presence checks, update operations, and union and intersection
+//! operations. However, if the number of possible items is very
+//! large and the number of actual items in a given set is usually
+//! small, they may be less memory efficient than an array set.
+//!
+//! There are five variants defined here:
+//!
+//! IntegerBitSet:
+//! A bit set with static size, which is backed by a single integer.
+//! This set is good for sets with a small size, but may generate
+//! inefficient code for larger sets, especially in debug mode.
+//!
+//! ArrayBitSet:
+//! A bit set with static size, which is backed by an array of usize.
+//! This set is good for sets with a larger size, but may use
+//! more bytes than necessary if your set is small.
+//!
+//! StaticBitSet:
+//! Picks either IntegerBitSet or ArrayBitSet depending on the requested
+//! size. The interfaces of these two types match exactly, except for fields.
+//!
+//! DynamicBitSet:
+//! A bit set with runtime known size, backed by an allocated slice
+//! of usize.
+//!
+//! DynamicBitSetUnmanaged:
+//! A variant of DynamicBitSet which does not store a pointer to its
+//! allocator, in order to save space.
+
+const std = @import("std");
+const assert = std.debug.assert;
+const Allocator = std.mem.Allocator;
+
+/// Returns the optimal static bit set type for the specified number
+/// of elements. The returned type will perform no allocations,
+/// can be copied by value, and does not require deinitialization.
+/// Both possible implementations fulfill the same interface.
+pub fn StaticBitSet(comptime size: usize) type {
+ if (size <= @bitSizeOf(usize)) {
+ return IntegerBitSet(size);
+ } else {
+ return ArrayBitSet(usize, size);
+ }
+}
+
+/// A bit set with static size, which is backed by a single integer.
+/// This set is good for sets with a small size, but may generate
+/// inefficient code for larger sets, especially in debug mode.
+pub fn IntegerBitSet(comptime size: u16) type {
+ return struct {
+ const Self = @This();
+
+ // TODO: Make this a comptime field once those are fixed
+ /// The number of items in this bit set
+ pub const bit_length: usize = size;
+
+ /// The integer type used to represent a mask in this bit set
+ pub const MaskInt = std.meta.Int(.unsigned, size);
+
+ /// The integer type used to shift a mask in this bit set
+ pub const ShiftInt = std.math.Log2Int(MaskInt);
+
+ /// The bit mask, as a single integer
+ mask: MaskInt,
+
+ /// Creates a bit set with no elements present.
+ pub fn initEmpty() Self {
+ return .{ .mask = 0 };
+ }
+
+ /// Creates a bit set with all elements present.
+ pub fn initFull() Self {
+ return .{ .mask = ~@as(MaskInt, 0) };
+ }
+
+ /// Returns the number of bits in this bit set
+ pub inline fn capacity(self: Self) usize {
+ _ = self;
+ return bit_length;
+ }
+
+ /// Returns true if the bit at the specified index
+ /// is present in the set, false otherwise.
+ pub fn isSet(self: Self, index: usize) bool {
+ assert(index < bit_length);
+ return (self.mask & maskBit(index)) != 0;
+ }
+
+ /// Returns the total number of set bits in this bit set.
+ pub fn count(self: Self) usize {
+ return @popCount(MaskInt, self.mask);
+ }
+
+ /// Changes the value of the specified bit of the bit
+ /// set to match the passed boolean.
+ pub fn setValue(self: *Self, index: usize, value: bool) void {
+ assert(index < bit_length);
+ if (MaskInt == u0) return;
+ const bit = maskBit(index);
+ const new_bit = bit & std.math.boolMask(MaskInt, value);
+ self.mask = (self.mask & ~bit) | new_bit;
+ }
+
+ /// Adds a specific bit to the bit set
+ pub fn set(self: *Self, index: usize) void {
+ assert(index < bit_length);
+ self.mask |= maskBit(index);
+ }
+
+ /// Removes a specific bit from the bit set
+ pub fn unset(self: *Self, index: usize) void {
+ assert(index < bit_length);
+ // Workaround for #7953
+ if (MaskInt == u0) return;
+ self.mask &= ~maskBit(index);
+ }
+
+ /// Flips a specific bit in the bit set
+ pub fn toggle(self: *Self, index: usize) void {
+ assert(index < bit_length);
+ self.mask ^= maskBit(index);
+ }
+
+ /// Flips all bits in this bit set which are present
+ /// in the toggles bit set.
+ pub fn toggleSet(self: *Self, toggles: Self) void {
+ self.mask ^= toggles.mask;
+ }
+
+ /// Flips every bit in the bit set.
+ pub fn toggleAll(self: *Self) void {
+ self.mask = ~self.mask;
+ }
+
+ /// Performs a union of two bit sets, and stores the
+ /// result in the first one. Bits in the result are
+ /// set if the corresponding bits were set in either input.
+ pub fn setUnion(self: *Self, other: Self) void {
+ self.mask |= other.mask;
+ }
+
+ /// Performs an intersection of two bit sets, and stores
+ /// the result in the first one. Bits in the result are
+ /// set if the corresponding bits were set in both inputs.
+ pub fn setIntersection(self: *Self, other: Self) void {
+ self.mask &= other.mask;
+ }
+
+ /// Finds the index of the first set bit.
+ /// If no bits are set, returns null.
+ pub fn findFirstSet(self: Self) ?usize {
+ const mask = self.mask;
+ if (mask == 0) return null;
+ return @ctz(MaskInt, mask);
+ }
+
+ /// Finds the index of the first set bit, and unsets it.
+ /// If no bits are set, returns null.
+ pub fn toggleFirstSet(self: *Self) ?usize {
+ const mask = self.mask;
+ if (mask == 0) return null;
+ const index = @ctz(MaskInt, mask);
+ self.mask = mask & (mask - 1);
+ return index;
+ }
+
+ /// Iterates through the items in the set, according to the options.
+ /// The default options (.{}) will iterate indices of set bits in
+ /// ascending order. Modifications to the underlying bit set may
+ /// or may not be observed by the iterator.
+ pub fn iterator(self: *const Self, comptime options: IteratorOptions) Iterator(options) {
+ return .{
+ .bits_remain = switch (options.kind) {
+ .set => self.mask,
+ .unset => ~self.mask,
+ },
+ };
+ }
+
+ pub fn Iterator(comptime options: IteratorOptions) type {
+ return SingleWordIterator(options.direction);
+ }
+
+ fn SingleWordIterator(comptime direction: IteratorOptions.Direction) type {
+ return struct {
+ const IterSelf = @This();
+ // all bits which have not yet been iterated over
+ bits_remain: MaskInt,
+
+ /// Returns the index of the next unvisited set bit
+ /// in the bit set, in ascending order.
+ pub fn next(self: *IterSelf) ?usize {
+ if (self.bits_remain == 0) return null;
+
+ switch (direction) {
+ .forward => {
+ const next_index = @ctz(MaskInt, self.bits_remain);
+ self.bits_remain &= self.bits_remain - 1;
+ return next_index;
+ },
+ .reverse => {
+ const leading_zeroes = @clz(MaskInt, self.bits_remain);
+ const top_bit = (@bitSizeOf(MaskInt) - 1) - leading_zeroes;
+ self.bits_remain &= (@as(MaskInt, 1) << @intCast(ShiftInt, top_bit)) - 1;
+ return top_bit;
+ },
+ }
+ }
+ };
+ }
+
+ fn maskBit(index: usize) MaskInt {
+ if (MaskInt == u0) return 0;
+ return @as(MaskInt, 1) << @intCast(ShiftInt, index);
+ }
+ fn boolMaskBit(index: usize, value: bool) MaskInt {
+ if (MaskInt == u0) return 0;
+ return @as(MaskInt, @boolToInt(value)) << @intCast(ShiftInt, index);
+ }
+ };
+}
+
+/// A bit set with static size, which is backed by an array of usize.
+/// This set is good for sets with a larger size, but may use
+/// more bytes than necessary if your set is small.
+pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
+ const mask_info: std.builtin.TypeInfo = @typeInfo(MaskIntType);
+
+ // Make sure the mask int is indeed an int
+ if (mask_info != .Int) @compileError("ArrayBitSet can only operate on integer masks, but was passed " ++ @typeName(MaskIntType));
+
+ // It must also be unsigned.
+ if (mask_info.Int.signedness != .unsigned) @compileError("ArrayBitSet requires an unsigned integer mask type, but was passed " ++ @typeName(MaskIntType));
+
+ // And it must not be empty.
+ if (MaskIntType == u0)
+ @compileError("ArrayBitSet requires a sized integer for its mask int. u0 does not work.");
+
+ const byte_size = std.mem.byte_size_in_bits;
+
+ // We use shift and truncate to decompose indices into mask indices and bit indices.
+ // This operation requires that the mask has an exact power of two number of bits.
+ if (!std.math.isPowerOfTwo(@bitSizeOf(MaskIntType))) {
+ var desired_bits = std.math.ceilPowerOfTwoAssert(usize, @bitSizeOf(MaskIntType));
+ if (desired_bits < byte_size) desired_bits = byte_size;
+ const FixedMaskType = std.meta.Int(.unsigned, desired_bits);
+ @compileError("ArrayBitSet was passed integer type " ++ @typeName(MaskIntType) ++
+ ", which is not a power of two. Please round this up to a power of two integer size (i.e. " ++ @typeName(FixedMaskType) ++ ").");
+ }
+
+ // Make sure the integer has no padding bits.
+ // Those would be wasteful here and are probably a mistake by the user.
+ // This case may be hit with small powers of two, like u4.
+ if (@bitSizeOf(MaskIntType) != @sizeOf(MaskIntType) * byte_size) {
+ var desired_bits = @sizeOf(MaskIntType) * byte_size;
+ desired_bits = std.math.ceilPowerOfTwoAssert(usize, desired_bits);
+ const FixedMaskType = std.meta.Int(.unsigned, desired_bits);
+ @compileError("ArrayBitSet was passed integer type " ++ @typeName(MaskIntType) ++
+ ", which contains padding bits. Please round this up to an unpadded integer size (i.e. " ++ @typeName(FixedMaskType) ++ ").");
+ }
+
+ return struct {
+ const Self = @This();
+
+ // TODO: Make this a comptime field once those are fixed
+ /// The number of items in this bit set
+ pub const bit_length: usize = size;
+
+ /// The integer type used to represent a mask in this bit set
+ pub const MaskInt = MaskIntType;
+
+ /// The integer type used to shift a mask in this bit set
+ pub const ShiftInt = std.math.Log2Int(MaskInt);
+
+ // bits in one mask
+ const mask_len = @bitSizeOf(MaskInt);
+ // total number of masks
+ const num_masks = (size + mask_len - 1) / mask_len;
+ // padding bits in the last mask (may be 0)
+ const last_pad_bits = mask_len * num_masks - size;
+ // Mask of valid bits in the last mask.
+ // All functions will ensure that the invalid
+ // bits in the last mask are zero.
+ pub const last_item_mask = ~@as(MaskInt, 0) >> last_pad_bits;
+
+ /// The bit masks, ordered with lower indices first.
+ /// Padding bits at the end are undefined.
+ masks: [num_masks]MaskInt,
+
+ /// Creates a bit set with no elements present.
+ pub fn initEmpty() Self {
+ return .{ .masks = [_]MaskInt{0} ** num_masks };
+ }
+
+ /// Creates a bit set with all elements present.
+ pub fn initFull() Self {
+ if (num_masks == 0) {
+ return .{ .masks = .{} };
+ } else {
+ return .{ .masks = [_]MaskInt{~@as(MaskInt, 0)} ** (num_masks - 1) ++ [_]MaskInt{last_item_mask} };
+ }
+ }
+
+ /// Returns the number of bits in this bit set
+ pub inline fn capacity(self: Self) usize {
+ _ = self;
+ return bit_length;
+ }
+
+ /// Returns true if the bit at the specified index
+ /// is present in the set, false otherwise.
+ pub fn isSet(self: Self, index: usize) bool {
+ assert(index < bit_length);
+ if (num_masks == 0) return false; // doesn't compile in this case
+ return (self.masks[maskIndex(index)] & maskBit(index)) != 0;
+ }
+
+ /// Returns the total number of set bits in this bit set.
+ pub fn count(self: Self) usize {
+ var total: usize = 0;
+ for (self.masks) |mask| {
+ total += @popCount(MaskInt, mask);
+ }
+ return total;
+ }
+
+ /// Changes the value of the specified bit of the bit
+ /// set to match the passed boolean.
+ pub fn setValue(self: *Self, index: usize, value: bool) void {
+ assert(index < bit_length);
+ if (num_masks == 0) return; // doesn't compile in this case
+ const bit = maskBit(index);
+ const mask_index = maskIndex(index);
+ const new_bit = bit & std.math.boolMask(MaskInt, value);
+ self.masks[mask_index] = (self.masks[mask_index] & ~bit) | new_bit;
+ }
+
+ /// Adds a specific bit to the bit set
+ pub fn set(self: *Self, index: usize) void {
+ assert(index < bit_length);
+ if (num_masks == 0) return; // doesn't compile in this case
+ self.masks[maskIndex(index)] |= maskBit(index);
+ }
+
+ /// Removes a specific bit from the bit set
+ pub fn unset(self: *Self, index: usize) void {
+ assert(index < bit_length);
+ if (num_masks == 0) return; // doesn't compile in this case
+ self.masks[maskIndex(index)] &= ~maskBit(index);
+ }
+
+ /// Flips a specific bit in the bit set
+ pub fn toggle(self: *Self, index: usize) void {
+ assert(index < bit_length);
+ if (num_masks == 0) return; // doesn't compile in this case
+ self.masks[maskIndex(index)] ^= maskBit(index);
+ }
+
+ /// Flips all bits in this bit set which are present
+ /// in the toggles bit set.
+ pub fn toggleSet(self: *Self, toggles: Self) void {
+ for (self.masks) |*mask, i| {
+ mask.* ^= toggles.masks[i];
+ }
+ }
+
+ /// Flips every bit in the bit set.
+ pub fn toggleAll(self: *Self) void {
+ for (self.masks) |*mask| {
+ mask.* = ~mask.*;
+ }
+
+ // Zero the padding bits
+ if (num_masks > 0) {
+ self.masks[num_masks - 1] &= last_item_mask;
+ }
+ }
+
+ /// Performs a union of two bit sets, and stores the
+ /// result in the first one. Bits in the result are
+ /// set if the corresponding bits were set in either input.
+ pub fn setUnion(self: *Self, other: Self) void {
+ for (self.masks) |*mask, i| {
+ mask.* |= other.masks[i];
+ }
+ }
+
+ /// Performs an intersection of two bit sets, and stores
+ /// the result in the first one. Bits in the result are
+ /// set if the corresponding bits were set in both inputs.
+ pub fn setIntersection(self: *Self, other: Self) void {
+ for (self.masks) |*mask, i| {
+ mask.* &= other.masks[i];
+ }
+ }
+
+ /// Finds the index of the first set bit.
+ /// If no bits are set, returns null.
+ pub fn findFirstSet(self: Self) ?usize {
+ var offset: usize = 0;
+ const mask = for (self.masks) |mask| {
+ if (mask != 0) break mask;
+ offset += @bitSizeOf(MaskInt);
+ } else return null;
+ return offset + @ctz(MaskInt, mask);
+ }
+
+ /// Finds the index of the first set bit, and unsets it.
+ /// If no bits are set, returns null.
+ pub fn toggleFirstSet(self: *Self) ?usize {
+ var offset: usize = 0;
+ const mask = for (self.masks) |*mask| {
+ if (mask.* != 0) break mask;
+ offset += @bitSizeOf(MaskInt);
+ } else return null;
+ const index = @ctz(MaskInt, mask.*);
+ mask.* &= (mask.* - 1);
+ return offset + index;
+ }
+
+ /// Iterates through the items in the set, according to the options.
+ /// The default options (.{}) will iterate indices of set bits in
+ /// ascending order. Modifications to the underlying bit set may
+ /// or may not be observed by the iterator.
+ pub fn iterator(self: *const Self, comptime options: IteratorOptions) Iterator(options) {
+ return Iterator(options).init(&self.masks, last_item_mask);
+ }
+
+ pub fn Iterator(comptime options: IteratorOptions) type {
+ return BitSetIterator(MaskInt, options);
+ }
+
+ fn maskBit(index: usize) MaskInt {
+ return @as(MaskInt, 1) << @truncate(ShiftInt, index);
+ }
+ fn maskIndex(index: usize) usize {
+ return index >> @bitSizeOf(ShiftInt);
+ }
+ fn boolMaskBit(index: usize, value: bool) MaskInt {
+ return @as(MaskInt, @boolToInt(value)) << @intCast(ShiftInt, index);
+ }
+ };
+}
+
+/// A bit set with runtime known size, backed by an allocated slice
+/// of usize. The allocator must be tracked externally by the user.
+pub const DynamicBitSetUnmanaged = struct {
+ const Self = @This();
+
+ /// The integer type used to represent a mask in this bit set
+ pub const MaskInt = usize;
+
+ /// The integer type used to shift a mask in this bit set
+ pub const ShiftInt = std.math.Log2Int(MaskInt);
+
+ /// The number of valid items in this bit set
+ bit_length: usize = 0,
+
+ /// The bit masks, ordered with lower indices first.
+ /// Padding bits at the end must be zeroed.
+ masks: [*]MaskInt = empty_masks_ptr,
+ // This pointer is one usize after the actual allocation.
+ // That slot holds the size of the true allocation, which
+ // is needed by Zig's allocator interface in case a shrink
+ // fails.
+
+ // Don't modify this value. Ideally it would go in const data so
+ // modifications would cause a bus error, but the only way
+ // to discard a const qualifier is through ptrToInt, which
+ // cannot currently round trip at comptime.
+ var empty_masks_data = [_]MaskInt{ 0, undefined };
+ const empty_masks_ptr = empty_masks_data[1..2];
+
+ /// Creates a bit set with no elements present.
+ /// If bit_length is not zero, deinit must eventually be called.
+ pub fn initEmpty(bit_length: usize, allocator: *Allocator) !Self {
+ var self = Self{};
+ try self.resize(bit_length, false, allocator);
+ return self;
+ }
+
+ /// Creates a bit set with all elements present.
+ /// If bit_length is not zero, deinit must eventually be called.
+ pub fn initFull(bit_length: usize, allocator: *Allocator) !Self {
+ var self = Self{};
+ try self.resize(bit_length, true, allocator);
+ return self;
+ }
+
+ /// Resizes to a new bit_length. If the new length is larger
+ /// than the old length, fills any added bits with `fill`.
+ /// If new_len is not zero, deinit must eventually be called.
+ pub fn resize(self: *@This(), new_len: usize, fill: bool, allocator: *Allocator) !void {
+ const old_len = self.bit_length;
+
+ const old_masks = numMasks(old_len);
+ const new_masks = numMasks(new_len);
+
+ const old_allocation = (self.masks - 1)[0..(self.masks - 1)[0]];
+
+ if (new_masks == 0) {
+ assert(new_len == 0);
+ allocator.free(old_allocation);
+ self.masks = empty_masks_ptr;
+ self.bit_length = 0;
+ return;
+ }
+
+ if (old_allocation.len != new_masks + 1) realloc: {
+ // If realloc fails, it may mean one of two things.
+ // If we are growing, it means we are out of memory.
+ // If we are shrinking, it means the allocator doesn't
+ // want to move the allocation. This means we need to
+ // hold on to the extra 8 bytes required to be able to free
+ // this allocation properly.
+ const new_allocation = allocator.realloc(old_allocation, new_masks + 1) catch |err| {
+ if (new_masks + 1 > old_allocation.len) return err;
+ break :realloc;
+ };
+
+ new_allocation[0] = new_allocation.len;
+ self.masks = new_allocation.ptr + 1;
+ }
+
+ // If we increased in size, we need to set any new bits
+ // to the fill value.
+ if (new_len > old_len) {
+ // set the padding bits in the old last item to 1
+ if (fill and old_masks > 0) {
+ const old_padding_bits = old_masks * @bitSizeOf(MaskInt) - old_len;
+ const old_mask = (~@as(MaskInt, 0)) >> @intCast(ShiftInt, old_padding_bits);
+ self.masks[old_masks - 1] |= ~old_mask;
+ }
+
+ // fill in any new masks
+ if (new_masks > old_masks) {
+ const fill_value = std.math.boolMask(MaskInt, fill);
+ std.mem.set(MaskInt, self.masks[old_masks..new_masks], fill_value);
+ }
+ }
+
+ // Zero out the padding bits
+ if (new_len > 0) {
+ const padding_bits = new_masks * @bitSizeOf(MaskInt) - new_len;
+ const last_item_mask = (~@as(MaskInt, 0)) >> @intCast(ShiftInt, padding_bits);
+ self.masks[new_masks - 1] &= last_item_mask;
+ }
+
+ // And finally, save the new length.
+ self.bit_length = new_len;
+ }
+
+ /// deinitializes the array and releases its memory.
+ /// The passed allocator must be the same one used for
+ /// init* or resize in the past.
+ pub fn deinit(self: *Self, allocator: *Allocator) void {
+ self.resize(0, false, allocator) catch unreachable;
+ }
+
+ /// Creates a duplicate of this bit set, using the new allocator.
+ pub fn clone(self: *const Self, new_allocator: *Allocator) !Self {
+ const num_masks = numMasks(self.bit_length);
+ var copy = Self{};
+ try copy.resize(self.bit_length, false, new_allocator);
+ std.mem.copy(MaskInt, copy.masks[0..num_masks], self.masks[0..num_masks]);
+ return copy;
+ }
+
+ /// Returns the number of bits in this bit set
+ pub inline fn capacity(self: Self) usize {
+ return self.bit_length;
+ }
+
+ /// Returns true if the bit at the specified index
+ /// is present in the set, false otherwise.
+ pub fn isSet(self: Self, index: usize) bool {
+ assert(index < self.bit_length);
+ return (self.masks[maskIndex(index)] & maskBit(index)) != 0;
+ }
+
+ /// Returns the total number of set bits in this bit set.
+ pub fn count(self: Self) usize {
+ const num_masks = (self.bit_length + (@bitSizeOf(MaskInt) - 1)) / @bitSizeOf(MaskInt);
+ var total: usize = 0;
+ for (self.masks[0..num_masks]) |mask| {
+ // Note: This is where we depend on padding bits being zero
+ total += @popCount(MaskInt, mask);
+ }
+ return total;
+ }
+
+ /// Changes the value of the specified bit of the bit
+ /// set to match the passed boolean.
+ pub fn setValue(self: *Self, index: usize, value: bool) void {
+ assert(index < self.bit_length);
+ const bit = maskBit(index);
+ const mask_index = maskIndex(index);
+ const new_bit = bit & std.math.boolMask(MaskInt, value);
+ self.masks[mask_index] = (self.masks[mask_index] & ~bit) | new_bit;
+ }
+
+ /// Adds a specific bit to the bit set
+ pub fn set(self: *Self, index: usize) void {
+ assert(index < self.bit_length);
+ self.masks[maskIndex(index)] |= maskBit(index);
+ }
+
+ /// Removes a specific bit from the bit set
+ pub fn unset(self: *Self, index: usize) void {
+ assert(index < self.bit_length);
+ self.masks[maskIndex(index)] &= ~maskBit(index);
+ }
+
+ /// Flips a specific bit in the bit set
+ pub fn toggle(self: *Self, index: usize) void {
+ assert(index < self.bit_length);
+ self.masks[maskIndex(index)] ^= maskBit(index);
+ }
+
+ /// Flips all bits in this bit set which are present
+ /// in the toggles bit set. Both sets must have the
+ /// same bit_length.
+ pub fn toggleSet(self: *Self, toggles: Self) void {
+ assert(toggles.bit_length == self.bit_length);
+ const num_masks = numMasks(self.bit_length);
+ for (self.masks[0..num_masks]) |*mask, i| {
+ mask.* ^= toggles.masks[i];
+ }
+ }
+
+ /// Flips every bit in the bit set.
+ pub fn toggleAll(self: *Self) void {
+ const bit_length = self.bit_length;
+ // avoid underflow if bit_length is zero
+ if (bit_length == 0) return;
+
+ const num_masks = numMasks(self.bit_length);
+ for (self.masks[0..num_masks]) |*mask| {
+ mask.* = ~mask.*;
+ }
+
+ const padding_bits = num_masks * @bitSizeOf(MaskInt) - bit_length;
+ const last_item_mask = (~@as(MaskInt, 0)) >> @intCast(ShiftInt, padding_bits);
+ self.masks[num_masks - 1] &= last_item_mask;
+ }
+
+ pub fn copyInto(self: *Self, other: Self) void {
+ const bit_length = self.bit_length;
+ // avoid underflow if bit_length is zero
+ if (bit_length == 0) return;
+
+ const num_masks = numMasks(self.bit_length);
+ for (self.masks[0..num_masks]) |*mask, i| {
+ mask.* = other.masks[i];
+ }
+
+ const padding_bits = num_masks * @bitSizeOf(MaskInt) - bit_length;
+ const last_item_mask = (~@as(MaskInt, 0)) >> @intCast(ShiftInt, padding_bits);
+ self.masks[num_masks - 1] &= last_item_mask;
+ }
+
+ /// Performs a union of two bit sets, and stores the
+ /// result in the first one. Bits in the result are
+ /// set if the corresponding bits were set in either input.
+ /// The two sets must both be the same bit_length.
+ pub fn setUnion(self: *Self, other: Self) void {
+ assert(other.bit_length == self.bit_length);
+ const num_masks = numMasks(self.bit_length);
+ for (self.masks[0..num_masks]) |*mask, i| {
+ mask.* |= other.masks[i];
+ }
+ }
+
+ /// Performs an intersection of two bit sets, and stores
+ /// the result in the first one. Bits in the result are
+ /// set if the corresponding bits were set in both inputs.
+ /// The two sets must both be the same bit_length.
+ pub fn setIntersection(self: *Self, other: Self) void {
+ assert(other.bit_length == self.bit_length);
+ const num_masks = numMasks(self.bit_length);
+ for (self.masks[0..num_masks]) |*mask, i| {
+ mask.* &= other.masks[i];
+ }
+ }
+ pub fn setExcludeTwo(self: *Self, other: Self, third: Self) void {
+ assert(other.bit_length == self.bit_length);
+ const num_masks = numMasks(self.bit_length);
+ for (self.masks[0..num_masks]) |*mask, i| {
+ mask.* &= ~other.masks[i];
+ mask.* &= ~third.masks[i];
+ }
+ }
+
+ pub fn setExclude(self: *Self, other: Self) void {
+ assert(other.bit_length == self.bit_length);
+ const num_masks = numMasks(self.bit_length);
+ for (self.masks[0..num_masks]) |*mask, i| {
+ mask.* &= ~other.masks[i];
+ }
+ }
+
+ /// Finds the index of the first set bit.
+ /// If no bits are set, returns null.
+ pub fn findFirstSet(self: Self) ?usize {
+ var offset: usize = 0;
+ var mask = self.masks;
+ while (offset < self.bit_length) {
+ if (mask[0] != 0) break;
+ mask += 1;
+ offset += @bitSizeOf(MaskInt);
+ } else return null;
+ return offset + @ctz(MaskInt, mask[0]);
+ }
+
+ /// Finds the index of the first set bit, and unsets it.
+ /// If no bits are set, returns null.
+ pub fn toggleFirstSet(self: *Self) ?usize {
+ var offset: usize = 0;
+ var mask = self.masks;
+ while (offset < self.bit_length) {
+ if (mask[0] != 0) break;
+ mask += 1;
+ offset += @bitSizeOf(MaskInt);
+ } else return null;
+ const index = @ctz(MaskInt, mask[0]);
+ mask[0] &= (mask[0] - 1);
+ return offset + index;
+ }
+
+ /// Iterates through the items in the set, according to the options.
+ /// The default options (.{}) will iterate indices of set bits in
+ /// ascending order. Modifications to the underlying bit set may
+ /// or may not be observed by the iterator. Resizing the underlying
+ /// bit set invalidates the iterator.
+ pub fn iterator(self: *const Self, comptime options: IteratorOptions) Iterator(options) {
+ const num_masks = numMasks(self.bit_length);
+ const padding_bits = num_masks * @bitSizeOf(MaskInt) - self.bit_length;
+ const last_item_mask = (~@as(MaskInt, 0)) >> @intCast(ShiftInt, padding_bits);
+ return Iterator(options).init(self.masks[0..num_masks], last_item_mask);
+ }
+
+ pub fn Iterator(comptime options: IteratorOptions) type {
+ return BitSetIterator(MaskInt, options);
+ }
+
+ fn maskBit(index: usize) MaskInt {
+ return @as(MaskInt, 1) << @truncate(ShiftInt, index);
+ }
+ fn maskIndex(index: usize) usize {
+ return index >> @bitSizeOf(ShiftInt);
+ }
+ fn boolMaskBit(index: usize, value: bool) MaskInt {
+ return @as(MaskInt, @boolToInt(value)) << @intCast(ShiftInt, index);
+ }
+ fn numMasks(bit_length: usize) usize {
+ return (bit_length + (@bitSizeOf(MaskInt) - 1)) / @bitSizeOf(MaskInt);
+ }
+};
+
+/// A bit set with runtime known size, backed by an allocated slice
+/// of usize. Thin wrapper around DynamicBitSetUnmanaged which keeps
+/// track of the allocator instance.
+pub const DynamicBitSet = struct {
+ const Self = @This();
+
+ /// The integer type used to represent a mask in this bit set
+ pub const MaskInt = usize;
+
+ /// The integer type used to shift a mask in this bit set
+ pub const ShiftInt = std.math.Log2Int(MaskInt);
+
+ /// The allocator used by this bit set
+ allocator: *Allocator,
+
+ /// The number of valid items in this bit set
+ unmanaged: DynamicBitSetUnmanaged = .{},
+
+ /// Creates a bit set with no elements present.
+ pub fn initEmpty(bit_length: usize, allocator: *Allocator) !Self {
+ return Self{
+ .unmanaged = try DynamicBitSetUnmanaged.initEmpty(bit_length, allocator),
+ .allocator = allocator,
+ };
+ }
+
+ /// Creates a bit set with all elements present.
+ pub fn initFull(bit_length: usize, allocator: *Allocator) !Self {
+ return Self{
+ .unmanaged = try DynamicBitSetUnmanaged.initFull(bit_length, allocator),
+ .allocator = allocator,
+ };
+ }
+
+ /// Resizes to a new length. If the new length is larger
+ /// than the old length, fills any added bits with `fill`.
+ pub fn resize(self: *@This(), new_len: usize, fill: bool) !void {
+ try self.unmanaged.resize(new_len, fill, self.allocator);
+ }
+
+ /// deinitializes the array and releases its memory.
+ /// The passed allocator must be the same one used for
+ /// init* or resize in the past.
+ pub fn deinit(self: *Self) void {
+ self.unmanaged.deinit(self.allocator);
+ }
+
+ /// Creates a duplicate of this bit set, using the new allocator.
+ pub fn clone(self: *const Self, new_allocator: *Allocator) !Self {
+ return Self{
+ .unmanaged = try self.unmanaged.clone(new_allocator),
+ .allocator = new_allocator,
+ };
+ }
+
+ /// Returns the number of bits in this bit set
+ pub inline fn capacity(self: Self) usize {
+ return self.unmanaged.capacity();
+ }
+
+ /// Returns true if the bit at the specified index
+ /// is present in the set, false otherwise.
+ pub fn isSet(self: Self, index: usize) bool {
+ return self.unmanaged.isSet(index);
+ }
+
+ /// Returns the total number of set bits in this bit set.
+ pub fn count(self: Self) usize {
+ return self.unmanaged.count();
+ }
+
+ /// Changes the value of the specified bit of the bit
+ /// set to match the passed boolean.
+ pub fn setValue(self: *Self, index: usize, value: bool) void {
+ self.unmanaged.setValue(index, value);
+ }
+
+ /// Adds a specific bit to the bit set
+ pub fn set(self: *Self, index: usize) void {
+ self.unmanaged.set(index);
+ }
+
+ /// Removes a specific bit from the bit set
+ pub fn unset(self: *Self, index: usize) void {
+ self.unmanaged.unset(index);
+ }
+
+ /// Flips a specific bit in the bit set
+ pub fn toggle(self: *Self, index: usize) void {
+ self.unmanaged.toggle(index);
+ }
+
+ /// Flips all bits in this bit set which are present
+ /// in the toggles bit set. Both sets must have the
+ /// same bit_length.
+ pub fn toggleSet(self: *Self, toggles: Self) void {
+ self.unmanaged.toggleSet(toggles.unmanaged);
+ }
+
+ /// Flips every bit in the bit set.
+ pub fn toggleAll(self: *Self) void {
+ self.unmanaged.toggleAll();
+ }
+
+ /// Performs a union of two bit sets, and stores the
+ /// result in the first one. Bits in the result are
+ /// set if the corresponding bits were set in either input.
+ /// The two sets must both be the same bit_length.
+ pub fn setUnion(self: *Self, other: Self) void {
+ self.unmanaged.setUnion(other.unmanaged);
+ }
+
+ /// Performs an intersection of two bit sets, and stores
+ /// the result in the first one. Bits in the result are
+ /// set if the corresponding bits were set in both inputs.
+ /// The two sets must both be the same bit_length.
+ pub fn setIntersection(self: *Self, other: Self) void {
+ self.unmanaged.setIntersection(other.unmanaged);
+ }
+
+ /// Finds the index of the first set bit.
+ /// If no bits are set, returns null.
+ pub fn findFirstSet(self: Self) ?usize {
+ return self.unmanaged.findFirstSet();
+ }
+
+ /// Finds the index of the first set bit, and unsets it.
+ /// If no bits are set, returns null.
+ pub fn toggleFirstSet(self: *Self) ?usize {
+ return self.unmanaged.toggleFirstSet();
+ }
+
+ /// Iterates through the items in the set, according to the options.
+ /// The default options (.{}) will iterate indices of set bits in
+ /// ascending order. Modifications to the underlying bit set may
+ /// or may not be observed by the iterator. Resizing the underlying
+ /// bit set invalidates the iterator.
+ pub fn iterator(self: *const Self, comptime options: IteratorOptions) Iterator(options) {
+ return self.unmanaged.iterator(options);
+ }
+
+ pub const Iterator = DynamicBitSetUnmanaged.Iterator;
+};
+
+/// Options for configuring an iterator over a bit set
+pub const IteratorOptions = struct {
+ /// determines which bits should be visited
+ kind: Type = .set,
+ /// determines the order in which bit indices should be visited
+ direction: Direction = .forward,
+
+ pub const Type = enum {
+ /// visit indexes of set bits
+ set,
+ /// visit indexes of unset bits
+ unset,
+ };
+
+ pub const Direction = enum {
+ /// visit indices in ascending order
+ forward,
+ /// visit indices in descending order.
+ /// Note that this may be slightly more expensive than forward iteration.
+ reverse,
+ };
+};
+
+// The iterator is reusable between several bit set types
+fn BitSetIterator(comptime MaskInt: type, comptime options: IteratorOptions) type {
+ const ShiftInt = std.math.Log2Int(MaskInt);
+ const kind = options.kind;
+ const direction = options.direction;
+ return struct {
+ const Self = @This();
+
+ // all bits which have not yet been iterated over
+ bits_remain: MaskInt,
+ // all words which have not yet been iterated over
+ words_remain: []const MaskInt,
+ // the offset of the current word
+ bit_offset: usize,
+ // the mask of the last word
+ last_word_mask: MaskInt,
+
+ fn init(masks: []const MaskInt, last_word_mask: MaskInt) Self {
+ if (masks.len == 0) {
+ return Self{
+ .bits_remain = 0,
+ .words_remain = &[_]MaskInt{},
+ .last_word_mask = last_word_mask,
+ .bit_offset = 0,
+ };
+ } else {
+ var result = Self{
+ .bits_remain = 0,
+ .words_remain = masks,
+ .last_word_mask = last_word_mask,
+ .bit_offset = if (direction == .forward) 0 else (masks.len - 1) * @bitSizeOf(MaskInt),
+ };
+ result.nextWord(true);
+ return result;
+ }
+ }
+
+ /// Returns the index of the next unvisited set bit
+ /// in the bit set, in ascending order.
+ pub inline fn next(self: *Self) ?usize {
+ while (self.bits_remain == 0) {
+ if (self.words_remain.len == 0) return null;
+ self.nextWord(false);
+ switch (direction) {
+ .forward => self.bit_offset += @bitSizeOf(MaskInt),
+ .reverse => self.bit_offset -= @bitSizeOf(MaskInt),
+ }
+ }
+
+ switch (direction) {
+ .forward => {
+ const next_index = @ctz(MaskInt, self.bits_remain) + self.bit_offset;
+ self.bits_remain &= self.bits_remain - 1;
+ return next_index;
+ },
+ .reverse => {
+ const leading_zeroes = @clz(MaskInt, self.bits_remain);
+ const top_bit = (@bitSizeOf(MaskInt) - 1) - leading_zeroes;
+ const no_top_bit_mask = (@as(MaskInt, 1) << @intCast(ShiftInt, top_bit)) - 1;
+ self.bits_remain &= no_top_bit_mask;
+ return top_bit + self.bit_offset;
+ },
+ }
+ }
+
+ // Load the next word. Don't call this if there
+ // isn't a next word. If the next word is the
+ // last word, mask off the padding bits so we
+ // don't visit them.
+ inline fn nextWord(self: *Self, comptime is_first_word: bool) void {
+ var word = switch (direction) {
+ .forward => self.words_remain[0],
+ .reverse => self.words_remain[self.words_remain.len - 1],
+ };
+ switch (kind) {
+ .set => {},
+ .unset => {
+ word = ~word;
+ if ((direction == .reverse and is_first_word) or
+ (direction == .forward and self.words_remain.len == 1))
+ {
+ word &= self.last_word_mask;
+ }
+ },
+ }
+ switch (direction) {
+ .forward => self.words_remain = self.words_remain[1..],
+ .reverse => self.words_remain.len -= 1,
+ }
+ self.bits_remain = word;
+ }
+ };
+}
+
+// ---------------- Tests -----------------
+
+const testing = std.testing;
+
+fn testBitSet(a: anytype, b: anytype, len: usize) !void {
+ try testing.expectEqual(len, a.capacity());
+ try testing.expectEqual(len, b.capacity());
+
+ {
+ var i: usize = 0;
+ while (i < len) : (i += 1) {
+ a.setValue(i, i & 1 == 0);
+ b.setValue(i, i & 2 == 0);
+ }
+ }
+
+ try testing.expectEqual((len + 1) / 2, a.count());
+ try testing.expectEqual((len + 3) / 4 + (len + 2) / 4, b.count());
+
+ {
+ var iter = a.iterator(.{});
+ var i: usize = 0;
+ while (i < len) : (i += 2) {
+ try testing.expectEqual(@as(?usize, i), iter.next());
+ }
+ try testing.expectEqual(@as(?usize, null), iter.next());
+ try testing.expectEqual(@as(?usize, null), iter.next());
+ try testing.expectEqual(@as(?usize, null), iter.next());
+ }
+ a.toggleAll();
+ {
+ var iter = a.iterator(.{});
+ var i: usize = 1;
+ while (i < len) : (i += 2) {
+ try testing.expectEqual(@as(?usize, i), iter.next());
+ }
+ try testing.expectEqual(@as(?usize, null), iter.next());
+ try testing.expectEqual(@as(?usize, null), iter.next());
+ try testing.expectEqual(@as(?usize, null), iter.next());
+ }
+
+ {
+ var iter = b.iterator(.{ .kind = .unset });
+ var i: usize = 2;
+ while (i < len) : (i += 4) {
+ try testing.expectEqual(@as(?usize, i), iter.next());
+ if (i + 1 < len) {
+ try testing.expectEqual(@as(?usize, i + 1), iter.next());
+ }
+ }
+ try testing.expectEqual(@as(?usize, null), iter.next());
+ try testing.expectEqual(@as(?usize, null), iter.next());
+ try testing.expectEqual(@as(?usize, null), iter.next());
+ }
+
+ {
+ var i: usize = 0;
+ while (i < len) : (i += 1) {
+ try testing.expectEqual(i & 1 != 0, a.isSet(i));
+ try testing.expectEqual(i & 2 == 0, b.isSet(i));
+ }
+ }
+
+ a.setUnion(b.*);
+ {
+ var i: usize = 0;
+ while (i < len) : (i += 1) {
+ try testing.expectEqual(i & 1 != 0 or i & 2 == 0, a.isSet(i));
+ try testing.expectEqual(i & 2 == 0, b.isSet(i));
+ }
+
+ i = len;
+ var set = a.iterator(.{ .direction = .reverse });
+ var unset = a.iterator(.{ .kind = .unset, .direction = .reverse });
+ while (i > 0) {
+ i -= 1;
+ if (i & 1 != 0 or i & 2 == 0) {
+ try testing.expectEqual(@as(?usize, i), set.next());
+ } else {
+ try testing.expectEqual(@as(?usize, i), unset.next());
+ }
+ }
+ try testing.expectEqual(@as(?usize, null), set.next());
+ try testing.expectEqual(@as(?usize, null), set.next());
+ try testing.expectEqual(@as(?usize, null), set.next());
+ try testing.expectEqual(@as(?usize, null), unset.next());
+ try testing.expectEqual(@as(?usize, null), unset.next());
+ try testing.expectEqual(@as(?usize, null), unset.next());
+ }
+
+ a.toggleSet(b.*);
+ {
+ try testing.expectEqual(len / 4, a.count());
+
+ var i: usize = 0;
+ while (i < len) : (i += 1) {
+ try testing.expectEqual(i & 1 != 0 and i & 2 != 0, a.isSet(i));
+ try testing.expectEqual(i & 2 == 0, b.isSet(i));
+ if (i & 1 == 0) {
+ a.set(i);
+ } else {
+ a.unset(i);
+ }
+ }
+ }
+
+ a.setIntersection(b.*);
+ {
+ try testing.expectEqual((len + 3) / 4, a.count());
+
+ var i: usize = 0;
+ while (i < len) : (i += 1) {
+ try testing.expectEqual(i & 1 == 0 and i & 2 == 0, a.isSet(i));
+ try testing.expectEqual(i & 2 == 0, b.isSet(i));
+ }
+ }
+
+ a.toggleSet(a.*);
+ {
+ var iter = a.iterator(.{});
+ try testing.expectEqual(@as(?usize, null), iter.next());
+ try testing.expectEqual(@as(?usize, null), iter.next());
+ try testing.expectEqual(@as(?usize, null), iter.next());
+ try testing.expectEqual(@as(usize, 0), a.count());
+ }
+ {
+ var iter = a.iterator(.{ .direction = .reverse });
+ try testing.expectEqual(@as(?usize, null), iter.next());
+ try testing.expectEqual(@as(?usize, null), iter.next());
+ try testing.expectEqual(@as(?usize, null), iter.next());
+ try testing.expectEqual(@as(usize, 0), a.count());
+ }
+
+ const test_bits = [_]usize{
+ 0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 22, 31, 32, 63, 64,
+ 66, 95, 127, 160, 192, 1000,
+ };
+ for (test_bits) |i| {
+ if (i < a.capacity()) {
+ a.set(i);
+ }
+ }
+
+ for (test_bits) |i| {
+ if (i < a.capacity()) {
+ try testing.expectEqual(@as(?usize, i), a.findFirstSet());
+ try testing.expectEqual(@as(?usize, i), a.toggleFirstSet());
+ }
+ }
+ try testing.expectEqual(@as(?usize, null), a.findFirstSet());
+ try testing.expectEqual(@as(?usize, null), a.toggleFirstSet());
+ try testing.expectEqual(@as(?usize, null), a.findFirstSet());
+ try testing.expectEqual(@as(?usize, null), a.toggleFirstSet());
+ try testing.expectEqual(@as(usize, 0), a.count());
+}
+
+fn testStaticBitSet(comptime Set: type) !void {
+ var a = Set.initEmpty();
+ var b = Set.initFull();
+ try testing.expectEqual(@as(usize, 0), a.count());
+ try testing.expectEqual(@as(usize, Set.bit_length), b.count());
+
+ try testBitSet(&a, &b, Set.bit_length);
+}
+
+test "IntegerBitSet" {
+ try testStaticBitSet(IntegerBitSet(0));
+ try testStaticBitSet(IntegerBitSet(1));
+ try testStaticBitSet(IntegerBitSet(2));
+ try testStaticBitSet(IntegerBitSet(5));
+ try testStaticBitSet(IntegerBitSet(8));
+ try testStaticBitSet(IntegerBitSet(32));
+ try testStaticBitSet(IntegerBitSet(64));
+ try testStaticBitSet(IntegerBitSet(127));
+}
+
+test "ArrayBitSet" {
+ inline for (.{ 0, 1, 2, 31, 32, 33, 63, 64, 65, 254, 500, 3000 }) |size| {
+ try testStaticBitSet(ArrayBitSet(u8, size));
+ try testStaticBitSet(ArrayBitSet(u16, size));
+ try testStaticBitSet(ArrayBitSet(u32, size));
+ try testStaticBitSet(ArrayBitSet(u64, size));
+ try testStaticBitSet(ArrayBitSet(u128, size));
+ }
+}
+
+test "DynamicBitSetUnmanaged" {
+ const allocator = std.testing.allocator;
+ var a = try DynamicBitSetUnmanaged.initEmpty(300, allocator);
+ try testing.expectEqual(@as(usize, 0), a.count());
+ a.deinit(allocator);
+
+ a = try DynamicBitSetUnmanaged.initEmpty(0, allocator);
+ defer a.deinit(allocator);
+ for ([_]usize{ 1, 2, 31, 32, 33, 0, 65, 64, 63, 500, 254, 3000 }) |size| {
+ const old_len = a.capacity();
+
+ var tmp = try a.clone(allocator);
+ defer tmp.deinit(allocator);
+ try testing.expectEqual(old_len, tmp.capacity());
+ var i: usize = 0;
+ while (i < old_len) : (i += 1) {
+ try testing.expectEqual(a.isSet(i), tmp.isSet(i));
+ }
+
+ a.toggleSet(a); // zero a
+ tmp.toggleSet(tmp);
+
+ try a.resize(size, true, allocator);
+ try tmp.resize(size, false, allocator);
+
+ if (size > old_len) {
+ try testing.expectEqual(size - old_len, a.count());
+ } else {
+ try testing.expectEqual(@as(usize, 0), a.count());
+ }
+ try testing.expectEqual(@as(usize, 0), tmp.count());
+
+ var b = try DynamicBitSetUnmanaged.initFull(size, allocator);
+ defer b.deinit(allocator);
+ try testing.expectEqual(@as(usize, size), b.count());
+
+ try testBitSet(&a, &b, size);
+ }
+}
+
+test "DynamicBitSet" {
+ const allocator = std.testing.allocator;
+ var a = try DynamicBitSet.initEmpty(300, allocator);
+ try testing.expectEqual(@as(usize, 0), a.count());
+ a.deinit();
+
+ a = try DynamicBitSet.initEmpty(0, allocator);
+ defer a.deinit();
+ for ([_]usize{ 1, 2, 31, 32, 33, 0, 65, 64, 63, 500, 254, 3000 }) |size| {
+ const old_len = a.capacity();
+
+ var tmp = try a.clone(allocator);
+ defer tmp.deinit();
+ try testing.expectEqual(old_len, tmp.capacity());
+ var i: usize = 0;
+ while (i < old_len) : (i += 1) {
+ try testing.expectEqual(a.isSet(i), tmp.isSet(i));
+ }
+
+ a.toggleSet(a); // zero a
+ tmp.toggleSet(tmp); // zero tmp
+
+ try a.resize(size, true);
+ try tmp.resize(size, false);
+
+ if (size > old_len) {
+ try testing.expectEqual(size - old_len, a.count());
+ } else {
+ try testing.expectEqual(@as(usize, 0), a.count());
+ }
+ try testing.expectEqual(@as(usize, 0), tmp.count());
+
+ var b = try DynamicBitSet.initFull(size, allocator);
+ defer b.deinit();
+ try testing.expectEqual(@as(usize, size), b.count());
+
+ try testBitSet(&a, &b, size);
+ }
+}
+
+test "StaticBitSet" {
+ try testing.expectEqual(IntegerBitSet(0), StaticBitSet(0));
+ try testing.expectEqual(IntegerBitSet(5), StaticBitSet(5));
+ try testing.expectEqual(IntegerBitSet(@bitSizeOf(usize)), StaticBitSet(@bitSizeOf(usize)));
+ try testing.expectEqual(ArrayBitSet(usize, @bitSizeOf(usize) + 1), StaticBitSet(@bitSizeOf(usize) + 1));
+ try testing.expectEqual(ArrayBitSet(usize, 500), StaticBitSet(500));
+}
diff --git a/src/install/dependency.zig b/src/install/dependency.zig
new file mode 100644
index 000000000..d41cfe8d4
--- /dev/null
+++ b/src/install/dependency.zig
@@ -0,0 +1,617 @@
+const ExternalStringList = @import("./install.zig").ExternalStringList;
+const Semver = @import("./semver.zig");
+const ExternalString = Semver.ExternalString;
+const String = Semver.String;
+const std = @import("std");
+const SlicedString = Semver.SlicedString;
+const PackageNameHash = @import("./install.zig").PackageNameHash;
+const Features = @import("./install.zig").Features;
+const logger = @import("../logger.zig");
+const Dependency = @This();
+const string = @import("../string_types.zig").string;
+const strings = @import("../string_immutable.zig");
+
+pub const URI = union(Tag) {
+ local: String,
+ remote: String,
+
+ pub fn eql(lhs: URI, rhs: URI, lhs_buf: []const u8, rhs_buf: []const u8) bool {
+ if (@as(Tag, lhs) != @as(Tag, rhs)) {
+ return false;
+ }
+
+ if (@as(Tag, lhs) == .local) {
+ return strings.eql(lhs.local.slice(lhs_buf), rhs.local.slice(rhs_buf));
+ } else {
+ return strings.eql(lhs.remote.slice(lhs_buf), rhs.remote.slice(rhs_buf));
+ }
+ }
+
+ pub const Tag = enum {
+ local,
+ remote,
+ };
+};
+
+name_hash: PackageNameHash = 0,
+name: String = String{},
+version: Dependency.Version = Dependency.Version{},
+
+/// This is how the dependency is specified in the package.json file.
+/// This allows us to track whether a package originated in any permutation of:
+/// - `dependencies`
+/// - `devDependencies`
+/// - `optionalDependencies`
+/// - `peerDependencies`
+/// Technically, having the same package name specified under multiple fields is invalid
+/// But we don't want to allocate extra arrays for them. So we use a bitfield instead.
+behavior: Behavior = Behavior.uninitialized,
+
+/// Sorting order for dependencies is:
+/// 1. [`dependencies`, `devDependencies`, `optionalDependencies`, `peerDependencies`]
+/// 2. name ASC
+/// "name" must be ASC so that later, when we rebuild the lockfile
+/// we insert it back in reverse order without an extra sorting pass
+pub fn isLessThan(string_buf: []const u8, lhs: Dependency, rhs: Dependency) bool {
+ const behavior = lhs.behavior.cmp(rhs.behavior);
+ if (behavior != .eq) {
+ return behavior == .lt;
+ }
+
+ const lhs_name = lhs.name.slice(string_buf);
+ const rhs_name = rhs.name.slice(string_buf);
+ return strings.cmpStringsAsc(void{}, lhs_name, rhs_name);
+}
+
+pub fn count(this: Dependency, buf: []const u8, comptime StringBuilder: type, builder: StringBuilder) void {
+ builder.count(this.name.slice(buf));
+ builder.count(this.version.literal.slice(buf));
+}
+
+pub fn clone(this: Dependency, buf: []const u8, comptime StringBuilder: type, builder: StringBuilder) !Dependency {
+ const out_slice = builder.lockfile.buffers.string_bytes.items;
+ const new_literal = builder.append(String, this.version.literal.slice(buf));
+ const sliced = new_literal.sliced(out_slice);
+
+ return Dependency{
+ .name_hash = this.name_hash,
+ .name = builder.append(String, this.name.slice(buf)),
+ .version = Dependency.parseWithTag(
+ builder.lockfile.allocator,
+ new_literal.slice(out_slice),
+ this.version.tag,
+ &sliced,
+ null,
+ ) orelse Dependency.Version{},
+ .behavior = this.behavior,
+ };
+}
+
+pub const External = extern struct {
+ name: String = String{},
+ name_hash: PackageNameHash = 0,
+ behavior: Behavior = Behavior.uninitialized,
+ version: Dependency.Version.External,
+
+ pub const Context = struct {
+ allocator: *std.mem.Allocator,
+ log: *logger.Log,
+ buffer: []const u8,
+ };
+
+ pub fn toDependency(
+ this: Dependency.External,
+ ctx: Context,
+ ) Dependency {
+ return Dependency{
+ .name = this.name,
+ .name_hash = this.name_hash,
+ .behavior = this.behavior,
+ .version = this.version.toVersion(ctx),
+ };
+ }
+};
+
+pub fn toExternal(this: Dependency) External {
+ return External{
+ .name = this.name,
+ .name_hash = this.name_hash,
+ .behavior = this.behavior,
+ .version = this.version.toExternal(),
+ };
+}
+
+pub const Version = struct {
+ tag: Dependency.Version.Tag = Dependency.Version.Tag.uninitialized,
+ literal: String = String{},
+ value: Value = Value{ .uninitialized = void{} },
+
+ pub fn clone(
+ this: Version,
+ buf: []const u8,
+ comptime StringBuilder: type,
+ builder: StringBuilder,
+ ) !Version {
+ return Version{
+ .tag = this.tag,
+ .literal = builder.append(String, this.literal.slice(buf)),
+ .value = try this.value.clone(buf, builder),
+ };
+ }
+
+ pub fn isLessThan(string_buf: []const u8, lhs: Dependency.Version, rhs: Dependency.Version) bool {
+ std.debug.assert(lhs.tag == rhs.tag);
+ return strings.cmpStringsAsc(.{}, lhs.literal.slice(string_buf), rhs.literal.slice(string_buf));
+ }
+
+ pub const External = extern struct {
+ tag: Dependency.Version.Tag,
+ literal: String,
+
+ pub fn toVersion(
+ this: Version.External,
+ ctx: Dependency.External.Context,
+ ) Dependency.Version {
+ const sliced = &this.literal.sliced(ctx.buffer);
+ return Dependency.parseWithTag(
+ ctx.allocator,
+ sliced.slice,
+ this.tag,
+ sliced,
+ ctx.log,
+ ) orelse Dependency.Version{};
+ }
+ };
+
+ pub inline fn toExternal(this: Version) Version.External {
+ return Version.External{
+ .tag = this.tag,
+ .literal = this.literal,
+ };
+ }
+
+ pub inline fn eql(
+ lhs: Version,
+ rhs: Version,
+ lhs_buf: []const u8,
+ rhs_buf: []const u8,
+ ) bool {
+ if (lhs.tag != rhs.tag) {
+ return false;
+ }
+
+ return switch (lhs.tag) {
+ // if the two versions are identical as strings, it should often be faster to compare that than the actual semver version
+ // semver ranges involve a ton of pointer chasing
+ .npm => strings.eql(lhs.literal.slice(lhs_buf), rhs.literal.slice(rhs_buf)) or
+ lhs.value.npm.eql(rhs.value.npm),
+ .folder, .dist_tag => lhs.literal.eql(rhs.literal, lhs_buf, rhs_buf),
+ .tarball => lhs.value.tarball.eql(rhs.value.tarball, lhs_buf, rhs_buf),
+ else => true,
+ };
+ }
+
+ pub const Tag = enum(u8) {
+ uninitialized = 0,
+
+ /// Semver range
+ npm = 1,
+
+ /// NPM dist tag, e.g. "latest"
+ dist_tag = 2,
+
+ /// URI to a .tgz or .tar.gz
+ tarball = 3,
+
+ /// Local folder
+ folder = 4,
+
+ /// TODO:
+ symlink = 5,
+ /// TODO:
+ workspace = 6,
+ /// TODO:
+ git = 7,
+ /// TODO:
+ github = 8,
+
+ pub inline fn isNPM(this: Tag) bool {
+ return @enumToInt(this) < 3;
+ }
+
+ pub inline fn isGitHubRepoPath(dependency: string) bool {
+ var slash_count: u8 = 0;
+
+ for (dependency) |c| {
+ slash_count += @as(u8, @boolToInt(c == '/'));
+ if (slash_count > 1 or c == '#') break;
+
+ // Must be alphanumeric
+ switch (c) {
+ '\\', '/', 'a'...'z', 'A'...'Z', '0'...'9', '%' => {},
+ else => return false,
+ }
+ }
+
+ return (slash_count == 1);
+ }
+
+ // this won't work for query string params
+ // i'll let someone file an issue before I add that
+ pub inline fn isTarball(dependency: string) bool {
+ return strings.endsWithComptime(dependency, ".tgz") or strings.endsWithComptime(dependency, ".tar.gz");
+ }
+
+ pub fn infer(dependency: string) Tag {
+ switch (dependency[0]) {
+ // npm package
+ '=', '>', '<', '0'...'9', '^', '*', '~', '|' => return Tag.npm,
+
+ 'n' => {
+ if (dependency.len > 4 and strings.eqlComptimeIgnoreLen(dependency[0..4], "npm:")) {
+ return Tag.npm;
+ }
+ },
+
+ // MIGHT be semver, might not be.
+ 'x', 'X' => {
+ if (dependency.len == 1) {
+ return Tag.npm;
+ }
+
+ if (dependency[1] == '.') {
+ return Tag.npm;
+ }
+
+ return .dist_tag;
+ },
+
+ // git://, git@, git+ssh
+ 'g' => {
+ if (strings.eqlComptime(
+ dependency[0..@minimum("git://".len, dependency.len)],
+ "git://",
+ ) or strings.eqlComptime(
+ dependency[0..@minimum("git@".len, dependency.len)],
+ "git@",
+ ) or strings.eqlComptime(
+ dependency[0..@minimum("git+ssh".len, dependency.len)],
+ "git+ssh",
+ )) {
+ return .git;
+ }
+
+ if (strings.eqlComptime(
+ dependency[0..@minimum("github".len, dependency.len)],
+ "github",
+ ) or isGitHubRepoPath(dependency)) {
+ return .github;
+ }
+
+ return .dist_tag;
+ },
+
+ '/' => {
+ if (isTarball(dependency)) {
+ return .tarball;
+ }
+
+ return .folder;
+ },
+
+ // https://, http://
+ 'h' => {
+ if (isTarball(dependency)) {
+ return .tarball;
+ }
+
+ var remainder = dependency;
+ if (strings.eqlComptime(
+ remainder[0..@minimum("https://".len, remainder.len)],
+ "https://",
+ )) {
+ remainder = remainder["https://".len..];
+ }
+
+ if (strings.eqlComptime(
+ remainder[0..@minimum("http://".len, remainder.len)],
+ "http://",
+ )) {
+ remainder = remainder["http://".len..];
+ }
+
+ if (strings.eqlComptime(
+ remainder[0..@minimum("github".len, remainder.len)],
+ "github",
+ ) or isGitHubRepoPath(remainder)) {
+ return .github;
+ }
+
+ return .dist_tag;
+ },
+
+ // file://
+ 'f' => {
+ if (isTarball(dependency))
+ return .tarball;
+
+ if (strings.eqlComptime(
+ dependency[0..@minimum("file://".len, dependency.len)],
+ "file://",
+ )) {
+ return .folder;
+ }
+
+ if (isGitHubRepoPath(dependency)) {
+ return .github;
+ }
+
+ return .dist_tag;
+ },
+
+ // link://
+ 'l' => {
+ if (isTarball(dependency))
+ return .tarball;
+
+ if (strings.eqlComptime(
+ dependency[0..@minimum("link://".len, dependency.len)],
+ "link://",
+ )) {
+ return .symlink;
+ }
+
+ if (isGitHubRepoPath(dependency)) {
+ return .github;
+ }
+
+ return .dist_tag;
+ },
+
+ // workspace://
+ 'w' => {
+ if (strings.eqlComptime(
+ dependency[0..@minimum("workspace://".len, dependency.len)],
+ "workspace://",
+ )) {
+ return .workspace;
+ }
+
+ if (isTarball(dependency))
+ return .tarball;
+
+ if (isGitHubRepoPath(dependency)) {
+ return .github;
+ }
+
+ return .dist_tag;
+ },
+
+ else => {},
+ }
+
+ if (isTarball(dependency))
+ return .tarball;
+
+ if (isGitHubRepoPath(dependency)) {
+ return .github;
+ }
+
+ return .dist_tag;
+ }
+ };
+
+ pub const Value = union {
+ uninitialized: void,
+
+ npm: Semver.Query.Group,
+ dist_tag: String,
+ tarball: URI,
+ folder: String,
+
+ /// Unsupported, but still parsed so an error can be thrown
+ symlink: void,
+ /// Unsupported, but still parsed so an error can be thrown
+ workspace: void,
+ /// Unsupported, but still parsed so an error can be thrown
+ git: void,
+ /// Unsupported, but still parsed so an error can be thrown
+ github: void,
+ };
+};
+
+pub fn eql(
+ a: Dependency,
+ b: Dependency,
+ lhs_buf: []const u8,
+ rhs_buf: []const u8,
+) bool {
+ return a.name_hash == b.name_hash and a.name.len() == b.name.len() and a.version.eql(b.version, lhs_buf, rhs_buf);
+}
+
+pub fn eqlResolved(a: Dependency, b: Dependency) bool {
+ if (a.isNPM() and b.tag.isNPM()) {
+ return a.resolution == b.resolution;
+ }
+
+ return @as(Dependency.Version.Tag, a.version) == @as(Dependency.Version.Tag, b.version) and a.resolution == b.resolution;
+}
+
+pub fn parse(allocator: *std.mem.Allocator, dependency_: string, sliced: *const SlicedString, log: ?*logger.Log) ?Version {
+ var dependency = std.mem.trimLeft(u8, dependency_, " \t\n\r");
+
+ if (dependency.len == 0) return null;
+ const tag = Version.Tag.infer(dependency);
+
+ if (tag == .npm and dependency.len > 4 and strings.eqlComptimeIgnoreLen(dependency[0..4], "npm:")) {
+ dependency = dependency[4..];
+ }
+
+ return parseWithTag(
+ allocator,
+ dependency,
+ tag,
+ sliced,
+ log,
+ );
+}
+
+pub fn parseWithTag(
+ allocator: *std.mem.Allocator,
+ dependency: string,
+ tag: Dependency.Version.Tag,
+ sliced: *const SlicedString,
+ log_: ?*logger.Log,
+) ?Version {
+ switch (tag) {
+ .npm => {
+ const version = Semver.Query.parse(
+ allocator,
+ dependency,
+ sliced.sub(dependency),
+ ) catch |err| {
+ if (log_) |log| log.addErrorFmt(null, logger.Loc.Empty, allocator, "{s} parsing dependency \"{s}\"", .{ @errorName(err), dependency }) catch unreachable;
+ return null;
+ };
+
+ return Version{
+ .literal = sliced.value(),
+ .value = .{ .npm = version },
+ .tag = .npm,
+ };
+ },
+ .dist_tag => {
+ return Version{
+ .literal = sliced.value(),
+ .value = .{ .dist_tag = sliced.value() },
+ .tag = .dist_tag,
+ };
+ },
+ .tarball => {
+ if (strings.contains(dependency, "://")) {
+ if (strings.startsWith(dependency, "file://")) {
+ return Version{
+ .tag = .tarball,
+ .value = .{ .tarball = URI{ .local = sliced.sub(dependency[7..]).value() } },
+ };
+ } else if (strings.startsWith(dependency, "https://") or strings.startsWith(dependency, "http://")) {
+ return Version{
+ .tag = .tarball,
+ .value = .{ .tarball = URI{ .remote = sliced.sub(dependency).value() } },
+ };
+ } else {
+ if (log_) |log| log.addErrorFmt(null, logger.Loc.Empty, allocator, "invalid dependency \"{s}\"", .{dependency}) catch unreachable;
+ return null;
+ }
+ }
+
+ return Version{
+ .literal = sliced.value(),
+ .value = .{
+ .tarball = URI{
+ .local = sliced.value(),
+ },
+ },
+ .tag = .tarball,
+ };
+ },
+ .folder => {
+ if (strings.contains(dependency, "://")) {
+ if (strings.startsWith(dependency, "file://")) {
+ return Version{ .value = .{ .folder = sliced.sub(dependency[7..]).value() }, .tag = .folder };
+ }
+
+ if (log_) |log| log.addErrorFmt(null, logger.Loc.Empty, allocator, "Unsupported protocol {s}", .{dependency}) catch unreachable;
+ return null;
+ }
+
+ return Version{
+ .value = .{ .folder = sliced.value() },
+ .tag = .folder,
+ .literal = sliced.value(),
+ };
+ },
+ .uninitialized => return null,
+ .symlink, .workspace, .git, .github => {
+ if (log_) |log| log.addErrorFmt(null, logger.Loc.Empty, allocator, "Unsupported dependency type {s} for \"{s}\"", .{ @tagName(tag), dependency }) catch unreachable;
+ return null;
+ },
+ }
+}
+
+pub const Behavior = enum(u8) {
+ uninitialized = 0,
+ _,
+
+ pub const normal: u8 = 1 << 1;
+ pub const optional: u8 = 1 << 2;
+ pub const dev: u8 = 1 << 3;
+ pub const peer: u8 = 1 << 4;
+
+ pub inline fn isOptional(this: Behavior) bool {
+ return (@enumToInt(this) & Behavior.optional) != 0 and !this.isPeer();
+ }
+
+ pub inline fn isDev(this: Behavior) bool {
+ return (@enumToInt(this) & Behavior.dev) != 0;
+ }
+
+ pub inline fn isPeer(this: Behavior) bool {
+ return (@enumToInt(this) & Behavior.peer) != 0;
+ }
+
+ pub inline fn isNormal(this: Behavior) bool {
+ return (@enumToInt(this) & Behavior.normal) != 0;
+ }
+
+ pub inline fn setOptional(this: Behavior, value: bool) Behavior {
+ return @intToEnum(Behavior, @enumToInt(this) | (@as(u8, @boolToInt(value))) << 2);
+ }
+
+ pub inline fn cmp(lhs: Behavior, rhs: Behavior) std.math.Order {
+ if (@enumToInt(lhs) == @enumToInt(rhs)) {
+ return .eq;
+ }
+
+ if (lhs.isNormal() != rhs.isNormal()) {
+ return if (lhs.isNormal())
+ .gt
+ else
+ .lt;
+ }
+
+ if (lhs.isDev() != rhs.isDev()) {
+ return if (lhs.isDev())
+ .gt
+ else
+ .lt;
+ }
+
+ if (lhs.isOptional() != rhs.isOptional()) {
+ return if (lhs.isOptional())
+ .gt
+ else
+ .lt;
+ }
+
+ if (lhs.isPeer() != rhs.isPeer()) {
+ return if (lhs.isPeer())
+ .gt
+ else
+ .lt;
+ }
+
+ return .eq;
+ }
+
+ pub inline fn isRequired(this: Behavior) bool {
+ return !isOptional(this);
+ }
+
+ pub fn isEnabled(this: Behavior, features: Features) bool {
+ return this.isNormal() or
+ (features.dev_dependencies and this.isDev()) or
+ (features.peer_dependencies and this.isPeer()) or
+ (features.optional_dependencies and this.isOptional());
+ }
+};
diff --git a/src/install/extract_tarball.zig b/src/install/extract_tarball.zig
new file mode 100644
index 000000000..6057448e5
--- /dev/null
+++ b/src/install/extract_tarball.zig
@@ -0,0 +1,281 @@
+const Output = @import("../global.zig").Output;
+const strings = @import("../string_immutable.zig");
+const string = @import("../string_types.zig").string;
+const Resolution = @import("./resolution.zig").Resolution;
+const FileSystem = @import("../fs.zig").FileSystem;
+const Semver = @import("./semver.zig");
+const Integrity = @import("./integrity.zig").Integrity;
+const PackageID = @import("./install.zig").PackageID;
+const PackageManager = @import("./install.zig").PackageManager;
+const std = @import("std");
+const Npm = @import("./npm.zig");
+const ExtractTarball = @This();
+const default_allocator = @import("../global.zig").default_allocator;
+const Global = @import("../global.zig").Global;
+
+name: strings.StringOrTinyString,
+resolution: Resolution,
+registry: string,
+cache_dir: string,
+package_id: PackageID,
+extracted_file_count: usize = 0,
+skip_verify: bool = false,
+
+integrity: Integrity = Integrity{},
+
+pub inline fn run(this: ExtractTarball, bytes: []const u8) !string {
+ if (!this.skip_verify and this.integrity.tag.isSupported()) {
+ if (!this.integrity.verify(bytes)) {
+ Output.prettyErrorln("<r><red>Integrity check failed<r> for tarball: {s}", .{this.name.slice()});
+ Output.flush();
+ return error.IntegrityCheckFailed;
+ }
+ }
+ return this.extract(bytes);
+}
+
+pub fn buildURL(
+ registry_: string,
+ full_name_: strings.StringOrTinyString,
+ version: Semver.Version,
+ string_buf: []const u8,
+) !string {
+ return try buildURLWithPrinter(
+ registry_,
+ full_name_,
+ version,
+ string_buf,
+ @TypeOf(FileSystem.instance.dirname_store),
+ string,
+ anyerror,
+ FileSystem.instance.dirname_store,
+ FileSystem.DirnameStore.print,
+ );
+}
+
+pub fn buildURLWithWriter(
+ comptime Writer: type,
+ writer: Writer,
+ registry_: string,
+ full_name_: strings.StringOrTinyString,
+ version: Semver.Version,
+ string_buf: []const u8,
+) !void {
+ const Printer = struct {
+ writer: Writer,
+
+ pub fn print(this: @This(), comptime fmt: string, args: anytype) Writer.Error!void {
+ return try std.fmt.format(this.writer, fmt, args);
+ }
+ };
+
+ return try buildURLWithPrinter(
+ registry_,
+ full_name_,
+ version,
+ string_buf,
+ Printer,
+ void,
+ Writer.Error,
+ Printer{
+ .writer = writer,
+ },
+ Printer.print,
+ );
+}
+
+pub fn buildURLWithPrinter(
+ registry_: string,
+ full_name_: strings.StringOrTinyString,
+ version: Semver.Version,
+ string_buf: []const u8,
+ comptime PrinterContext: type,
+ comptime ReturnType: type,
+ comptime ErrorType: type,
+ printer: PrinterContext,
+ comptime print: fn (ctx: PrinterContext, comptime str: string, args: anytype) ErrorType!ReturnType,
+) ErrorType!ReturnType {
+ const registry = std.mem.trimRight(u8, registry_, "/");
+ const full_name = full_name_.slice();
+
+ var name = full_name;
+ if (name[0] == '@') {
+ if (std.mem.indexOfScalar(u8, name, '/')) |i| {
+ name = name[i + 1 ..];
+ }
+ }
+
+ const default_format = "{s}/{s}/-/";
+
+ if (!version.tag.hasPre() and !version.tag.hasBuild()) {
+ const args = .{ registry, full_name, name, version.major, version.minor, version.patch };
+ return try print(
+ printer,
+ default_format ++ "{s}-{d}.{d}.{d}.tgz",
+ args,
+ );
+ } else if (version.tag.hasPre() and version.tag.hasBuild()) {
+ const args = .{ registry, full_name, name, version.major, version.minor, version.patch, version.tag.pre.slice(string_buf), version.tag.build.slice(string_buf) };
+ return try print(
+ printer,
+ default_format ++ "{s}-{d}.{d}.{d}-{s}+{s}.tgz",
+ args,
+ );
+ } else if (version.tag.hasPre()) {
+ const args = .{ registry, full_name, name, version.major, version.minor, version.patch, version.tag.pre.slice(string_buf) };
+ return try print(
+ printer,
+ default_format ++ "{s}-{d}.{d}.{d}-{s}.tgz",
+ args,
+ );
+ } else if (version.tag.hasBuild()) {
+ const args = .{ registry, full_name, name, version.major, version.minor, version.patch, version.tag.build.slice(string_buf) };
+ return try print(
+ printer,
+ default_format ++ "{s}-{d}.{d}.{d}+{s}.tgz",
+ args,
+ );
+ } else {
+ unreachable;
+ }
+}
+
+threadlocal var abs_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
+threadlocal var abs_buf2: [std.fs.MAX_PATH_BYTES]u8 = undefined;
+
+fn extract(this: *const ExtractTarball, tgz_bytes: []const u8) !string {
+ var tmpdir = FileSystem.instance.tmpdir();
+ var tmpname_buf: [128]u8 = undefined;
+ const name = this.name.slice();
+
+ var basename = this.name.slice();
+ if (basename[0] == '@') {
+ if (std.mem.indexOfScalar(u8, basename, '/')) |i| {
+ basename = basename[i + 1 ..];
+ }
+ }
+
+ var tmpname = try FileSystem.instance.tmpname(basename, &tmpname_buf, tgz_bytes.len);
+
+ var cache_dir = tmpdir.makeOpenPath(std.mem.span(tmpname), .{ .iterate = true }) catch |err| {
+ Output.panic("err: {s} when create temporary directory named {s} (while extracting {s})", .{ @errorName(err), tmpname, name });
+ };
+ var temp_destination = std.os.getFdPath(cache_dir.fd, &abs_buf) catch |err| {
+ Output.panic("err: {s} when resolve path for temporary directory named {s} (while extracting {s})", .{ @errorName(err), tmpname, name });
+ };
+ cache_dir.close();
+
+ if (PackageManager.verbose_install) {
+ Output.prettyErrorln("[{s}] Start extracting {s}<r>", .{ name, tmpname });
+ Output.flush();
+ }
+
+ const Archive = @import("../libarchive/libarchive.zig").Archive;
+ const Zlib = @import("../zlib.zig");
+ var zlib_pool = Npm.Registry.BodyPool.get(default_allocator);
+ zlib_pool.data.reset();
+ defer Npm.Registry.BodyPool.release(zlib_pool);
+
+ var zlib_entry = try Zlib.ZlibReaderArrayList.init(tgz_bytes, &zlib_pool.data.list, default_allocator);
+ zlib_entry.readAll() catch |err| {
+ Output.prettyErrorln(
+ "<r><red>Error {s}<r> decompressing {s}",
+ .{
+ @errorName(err),
+ name,
+ },
+ );
+ Output.flush();
+ Global.crash();
+ };
+ const extracted_file_count = if (PackageManager.verbose_install)
+ try Archive.extractToDisk(
+ zlib_pool.data.list.items,
+ temp_destination,
+ null,
+ void,
+ void{},
+ // for npm packages, the root dir is always "package"
+ 1,
+ true,
+ true,
+ )
+ else
+ try Archive.extractToDisk(
+ zlib_pool.data.list.items,
+ temp_destination,
+ null,
+ void,
+ void{},
+ // for npm packages, the root dir is always "package"
+ 1,
+ true,
+ false,
+ );
+
+ if (PackageManager.verbose_install) {
+ Output.prettyErrorln(
+ "[{s}] Extracted<r>",
+ .{
+ name,
+ },
+ );
+ Output.flush();
+ }
+
+ var folder_name = PackageManager.cachedNPMPackageFolderNamePrint(&abs_buf2, name, this.resolution.value.npm);
+ if (folder_name.len == 0 or (folder_name.len == 1 and folder_name[0] == '/')) @panic("Tried to delete root and stopped it");
+ PackageManager.instance.cache_directory.deleteTree(folder_name) catch {};
+
+ // e.g. @next
+ // if it's a namespace package, we need to make sure the @name folder exists
+ if (basename.len != name.len) {
+ PackageManager.instance.cache_directory.makeDir(std.mem.trim(u8, name[0 .. name.len - basename.len], "/")) catch {};
+ }
+
+ // Now that we've extracted the archive, we rename.
+ std.os.renameatZ(tmpdir.fd, tmpname, PackageManager.instance.cache_directory.fd, folder_name) catch |err| {
+ Output.prettyErrorln(
+ "<r><red>Error {s}<r> moving {s} to cache dir:\n From: {s} To: {s}",
+ .{
+ @errorName(err),
+ name,
+ tmpname,
+ folder_name,
+ },
+ );
+ Output.flush();
+ Global.crash();
+ };
+
+ // We return a resolved absolute absolute file path to the cache dir.
+ // To get that directory, we open the directory again.
+ var final_dir = PackageManager.instance.cache_directory.openDirZ(folder_name, .{ .iterate = true }) catch |err| {
+ Output.prettyErrorln(
+ "<r><red>Error {s}<r> failed to verify cache dir for {s}",
+ .{
+ @errorName(err),
+ name,
+ },
+ );
+ Output.flush();
+ Global.crash();
+ };
+ defer final_dir.close();
+ // and get the fd path
+ var final_path = std.os.getFdPath(
+ final_dir.fd,
+ &abs_buf,
+ ) catch |err| {
+ Output.prettyErrorln(
+ "<r><red>Error {s}<r> failed to verify cache dir for {s}",
+ .{
+ @errorName(err),
+ name,
+ },
+ );
+ Output.flush();
+ Global.crash();
+ };
+ return try FileSystem.instance.dirname_store.append(@TypeOf(final_path), final_path);
+}
diff --git a/src/install/install-scripts-allowlist.txt b/src/install/install-scripts-allowlist.txt
new file mode 100644
index 000000000..fdd5d1c06
--- /dev/null
+++ b/src/install/install-scripts-allowlist.txt
@@ -0,0 +1,4 @@
+static-ffmpeg
+canvas
+better-sqlite3
+node-sass \ No newline at end of file
diff --git a/src/install/install.zig b/src/install/install.zig
new file mode 100644
index 000000000..075a249a0
--- /dev/null
+++ b/src/install/install.zig
@@ -0,0 +1,6707 @@
+usingnamespace @import("../global.zig");
+const std = @import("std");
+
+const JSLexer = @import("../js_lexer.zig");
+const logger = @import("../logger.zig");
+const alloc = @import("../alloc.zig");
+const js_parser = @import("../js_parser.zig");
+const json_parser = @import("../json_parser.zig");
+const JSPrinter = @import("../js_printer.zig");
+
+const linker = @import("../linker.zig");
+usingnamespace @import("../ast/base.zig");
+usingnamespace @import("../defines.zig");
+const panicky = @import("../panic_handler.zig");
+const sync = @import("../sync.zig");
+const Api = @import("../api/schema.zig").Api;
+const resolve_path = @import("../resolver/resolve_path.zig");
+const configureTransformOptionsForBun = @import("../javascript/jsc/config.zig").configureTransformOptionsForBun;
+const Command = @import("../cli.zig").Command;
+const bundler = @import("../bundler.zig");
+const NodeModuleBundle = @import("../node_module_bundle.zig").NodeModuleBundle;
+const DotEnv = @import("../env_loader.zig");
+const which = @import("../which.zig").which;
+const Run = @import("../bun_js.zig").Run;
+const NewBunQueue = @import("../bun_queue.zig").NewBunQueue;
+const HeaderBuilder = @import("http").HeaderBuilder;
+const Fs = @import("../fs.zig");
+const FileSystem = Fs.FileSystem;
+const Lock = @import("../lock.zig").Lock;
+var path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
+var path_buf2: [std.fs.MAX_PATH_BYTES]u8 = undefined;
+const URL = @import("../query_string_map.zig").URL;
+const NetworkThread = @import("network_thread");
+const AsyncHTTP = @import("http").AsyncHTTP;
+const HTTPChannel = @import("http").HTTPChannel;
+const Integrity = @import("./integrity.zig").Integrity;
+const clap = @import("clap");
+const ExtractTarball = @import("./extract_tarball.zig");
+const Npm = @import("./npm.zig");
+const Bitset = @import("./bit_set.zig").DynamicBitSetUnmanaged;
+
+threadlocal var initialized_store = false;
+
+// these bytes are skipped
+// so we just make it repeat bun bun bun bun bun bun bun bun bun
+// because why not
+const alignment_bytes_to_repeat = "bun";
+const alignment_bytes_to_repeat_buffer = "bunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbunbun";
+
+const JSAst = @import("../js_ast.zig");
+
+pub fn initializeStore() void {
+ if (initialized_store) {
+ JSAst.Expr.Data.Store.reset();
+ JSAst.Stmt.Data.Store.reset();
+ return;
+ }
+
+ initialized_store = true;
+ JSAst.Expr.Data.Store.create(default_allocator);
+ JSAst.Stmt.Data.Store.create(default_allocator);
+}
+
+const IdentityContext = @import("../identity_context.zig").IdentityContext;
+const ArrayIdentityContext = @import("../identity_context.zig").ArrayIdentityContext;
+const NetworkQueue = std.fifo.LinearFifo(*NetworkTask, .{ .Static = 32 });
+const Semver = @import("./semver.zig");
+const ExternalString = Semver.ExternalString;
+const String = Semver.String;
+const GlobalStringBuilder = @import("../string_builder.zig");
+const SlicedString = Semver.SlicedString;
+const Repository = @import("./repository.zig").Repository;
+const StructBuilder = @import("../builder.zig");
+const Bin = @import("./bin.zig").Bin;
+const Dependency = @import("./dependency.zig");
+const Behavior = @import("./dependency.zig").Behavior;
+
+pub const ExternalStringBuilder = StructBuilder.Builder(ExternalString);
+pub const SmallExternalStringList = ExternalSlice(String);
+
+pub fn ExternalSlice(comptime Type: type) type {
+ return ExternalSliceAligned(Type, null);
+}
+
+pub fn ExternalSliceAligned(comptime Type: type, comptime alignment_: ?u29) type {
+ return extern struct {
+ const alignment = alignment_ orelse @alignOf(*Type);
+ const Slice = @This();
+
+ pub const Child: type = Type;
+
+ off: u32 = 0,
+ len: u32 = 0,
+
+ pub inline fn get(this: Slice, in: []const Type) []const Type {
+ // it should be impossible to address this out of bounds due to the minimum here
+ return in.ptr[this.off..@minimum(in.len, this.off + this.len)];
+ }
+
+ pub inline fn mut(this: Slice, in: []Type) []Type {
+ return in.ptr[this.off..@minimum(in.len, this.off + this.len)];
+ }
+
+ pub fn init(buf: []const Type, in: []const Type) Slice {
+ // if (comptime isDebug or isTest) {
+ // std.debug.assert(@ptrToInt(buf.ptr) <= @ptrToInt(in.ptr));
+ // std.debug.assert((@ptrToInt(in.ptr) + in.len) <= (@ptrToInt(buf.ptr) + buf.len));
+ // }
+
+ return Slice{
+ .off = @truncate(u32, (@ptrToInt(in.ptr) - @ptrToInt(buf.ptr)) / @sizeOf(Type)),
+ .len = @truncate(u32, in.len),
+ };
+ }
+ };
+}
+
+pub const PackageID = u32;
+pub const DependencyID = u32;
+pub const PackageIDMultiple = [*:invalid_package_id]PackageID;
+pub const invalid_package_id = std.math.maxInt(PackageID);
+
+pub const ExternalStringList = ExternalSlice(ExternalString);
+pub const VersionSlice = ExternalSlice(Semver.Version);
+
+pub const ExternalStringMap = extern struct {
+ name: ExternalStringList = ExternalStringList{},
+ value: ExternalStringList = ExternalStringList{},
+
+ pub const Iterator = NewIterator(ExternalStringList);
+
+ pub const Small = extern struct {
+ name: SmallExternalStringList = SmallExternalStringList{},
+ value: SmallExternalStringList = SmallExternalStringList{},
+
+ pub const Iterator = NewIterator(SmallExternalStringList);
+
+ pub inline fn iterator(this: Small, buf: []const String) Small.Iterator {
+ return Small.Iterator.init(buf, this.name, this.value);
+ }
+ };
+
+ pub inline fn iterator(this: ExternalStringMap, buf: []const String) Iterator {
+ return Iterator.init(buf, this.name, this.value);
+ }
+
+ fn NewIterator(comptime Type: type) type {
+ return struct {
+ const ThisIterator = @This();
+
+ i: usize = 0,
+ names: []const Type.Child,
+ values: []const Type.Child,
+
+ pub fn init(all: []const Type.Child, names: Type, values: Type) ThisIterator {
+ this.names = names.get(all);
+ this.values = values.get(all);
+ return this;
+ }
+
+ pub fn next(this: *ThisIterator) ?[2]Type.Child {
+ if (this.i < this.names.len) {
+ const ret = [2]Type.Child{ this.names[this.i], this.values[this.i] };
+ this.i += 1;
+ }
+
+ return null;
+ }
+ };
+ }
+};
+
+pub const PackageNameHash = u64;
+
+pub const Aligner = struct {
+ pub fn write(comptime Type: type, comptime Writer: type, writer: Writer, pos: usize) !usize {
+ const to_write = std.mem.alignForward(pos, @alignOf(Type)) - pos;
+ var i: usize = 0;
+
+ var remainder: string = alignment_bytes_to_repeat_buffer[0..@minimum(to_write, alignment_bytes_to_repeat_buffer.len)];
+ try writer.writeAll(remainder);
+
+ return to_write;
+ }
+
+ pub inline fn skipAmount(comptime Type: type, pos: usize) usize {
+ return std.mem.alignForward(pos, @alignOf(Type)) - pos;
+ }
+};
+
+const NetworkTask = struct {
+ http: AsyncHTTP = undefined,
+ task_id: u64,
+ url_buf: []const u8 = &[_]u8{},
+ allocator: *std.mem.Allocator,
+ request_buffer: MutableString = undefined,
+ response_buffer: MutableString = undefined,
+ callback: union(Task.Tag) {
+ package_manifest: struct {
+ loaded_manifest: ?Npm.PackageManifest = null,
+ name: strings.StringOrTinyString,
+ },
+ extract: ExtractTarball,
+ binlink: void,
+ },
+
+ pub fn notify(http: *AsyncHTTP, sender: *AsyncHTTP.HTTPSender) void {
+ PackageManager.instance.network_channel.writeItem(@fieldParentPtr(NetworkTask, "http", http)) catch {};
+ sender.onFinish();
+ }
+
+ const default_headers_buf: string = "Acceptapplication/vnd.npm.install-v1+json";
+ pub fn forManifest(
+ this: *NetworkTask,
+ name: string,
+ allocator: *std.mem.Allocator,
+ registry_url: URL,
+ loaded_manifest: ?Npm.PackageManifest,
+ ) !void {
+ this.url_buf = try std.fmt.allocPrint(allocator, "{s}://{s}/{s}", .{ registry_url.displayProtocol(), registry_url.hostname, name });
+ var last_modified: string = "";
+ var etag: string = "";
+ if (loaded_manifest) |manifest| {
+ last_modified = manifest.pkg.last_modified.slice(manifest.string_buf);
+ etag = manifest.pkg.etag.slice(manifest.string_buf);
+ }
+
+ var header_builder = HeaderBuilder{};
+
+ if (etag.len != 0) {
+ header_builder.count("If-None-Match", etag);
+ } else if (last_modified.len != 0) {
+ header_builder.count("If-Modified-Since", last_modified);
+ }
+
+ if (header_builder.header_count > 0) {
+ header_builder.count("Accept", "application/vnd.npm.install-v1+json");
+ if (last_modified.len > 0 and etag.len > 0) {
+ header_builder.content.count(last_modified);
+ }
+ try header_builder.allocate(allocator);
+
+ if (etag.len != 0) {
+ header_builder.append("If-None-Match", etag);
+ } else if (last_modified.len != 0) {
+ header_builder.append("If-Modified-Since", last_modified);
+ }
+
+ header_builder.append("Accept", "application/vnd.npm.install-v1+json");
+
+ if (last_modified.len > 0 and etag.len > 0) {
+ last_modified = header_builder.content.append(last_modified);
+ }
+ } else {
+ try header_builder.entries.append(
+ allocator,
+ .{
+ .name = .{ .offset = 0, .length = @truncate(u32, "Accept".len) },
+ .value = .{ .offset = "Accept".len, .length = @truncate(u32, default_headers_buf.len - "Accept".len) },
+ },
+ );
+ header_builder.header_count = 1;
+ header_builder.content = GlobalStringBuilder{ .ptr = @intToPtr([*]u8, @ptrToInt(std.mem.span(default_headers_buf).ptr)), .len = default_headers_buf.len, .cap = default_headers_buf.len };
+ }
+
+ this.request_buffer = try MutableString.init(allocator, 0);
+ this.response_buffer = try MutableString.init(allocator, 0);
+ this.allocator = allocator;
+ this.http = try AsyncHTTP.init(
+ allocator,
+ .GET,
+ URL.parse(this.url_buf),
+ header_builder.entries,
+ header_builder.content.ptr.?[0..header_builder.content.len],
+ &this.response_buffer,
+ &this.request_buffer,
+ 0,
+ );
+ this.callback = .{
+ .package_manifest = .{
+ .name = try strings.StringOrTinyString.initAppendIfNeeded(name, *FileSystem.FilenameStore, &FileSystem.FilenameStore.instance),
+ .loaded_manifest = loaded_manifest,
+ },
+ };
+
+ if (PackageManager.verbose_install) {
+ this.http.verbose = true;
+ this.http.client.verbose = true;
+ }
+
+ // Incase the ETag causes invalidation, we fallback to the last modified date.
+ if (last_modified.len != 0) {
+ this.http.client.force_last_modified = true;
+ this.http.client.if_modified_since = last_modified;
+ }
+
+ this.http.callback = notify;
+ }
+
+ pub fn schedule(this: *NetworkTask, batch: *ThreadPool.Batch) void {
+ this.http.schedule(this.allocator, batch);
+ }
+
+ pub fn forTarball(
+ this: *NetworkTask,
+ allocator: *std.mem.Allocator,
+ tarball: ExtractTarball,
+ ) !void {
+ this.url_buf = try ExtractTarball.buildURL(
+ tarball.registry,
+ tarball.name,
+ tarball.resolution.value.npm,
+ PackageManager.instance.lockfile.buffers.string_bytes.items,
+ );
+
+ this.request_buffer = try MutableString.init(allocator, 0);
+ this.response_buffer = try MutableString.init(allocator, 0);
+ this.allocator = allocator;
+
+ this.http = try AsyncHTTP.init(
+ allocator,
+ .GET,
+ URL.parse(this.url_buf),
+ .{},
+ "",
+ &this.response_buffer,
+ &this.request_buffer,
+ 0,
+ );
+ this.http.callback = notify;
+ this.callback = .{ .extract = tarball };
+ }
+};
+
+pub const Origin = enum(u8) {
+ local = 0,
+ npm = 1,
+ tarball = 2,
+};
+
+pub const Features = struct {
+ optional_dependencies: bool = false,
+ dev_dependencies: bool = false,
+ scripts: bool = false,
+ peer_dependencies: bool = true,
+ is_main: bool = false,
+
+ check_for_duplicate_dependencies: bool = false,
+
+ pub const npm = Features{
+ .optional_dependencies = true,
+ };
+
+ pub const npm_manifest = Features{
+ .optional_dependencies = true,
+ };
+};
+
+pub const PreinstallState = enum(u8) {
+ unknown = 0,
+ done = 1,
+ extract = 2,
+ extracting = 3,
+};
+
+pub const Lockfile = struct {
+
+ // Serialized data
+ /// The version of the lockfile format, intended to prevent data corruption for format changes.
+ format: FormatVersion = .v0,
+
+ ///
+ packages: Lockfile.Package.List = Lockfile.Package.List{},
+ buffers: Buffers = Buffers{},
+
+ /// name -> PackageID || [*]PackageID
+ /// Not for iterating.
+ package_index: PackageIndex.Map,
+ unique_packages: Bitset,
+ string_pool: StringPool,
+ allocator: *std.mem.Allocator,
+ scratch: Scratch = Scratch{},
+
+ const Stream = std.io.FixedBufferStream([]u8);
+ pub const default_filename = "bun.lockb";
+
+ pub const LoadFromDiskResult = union(Tag) {
+ not_found: void,
+ err: struct {
+ step: Step,
+ value: anyerror,
+ },
+ ok: *Lockfile,
+
+ pub const Step = enum { open_file, read_file, parse_file };
+
+ pub const Tag = enum {
+ not_found,
+ err,
+ ok,
+ };
+ };
+
+ pub fn loadFromDisk(this: *Lockfile, allocator: *std.mem.Allocator, log: *logger.Log, filename: stringZ) LoadFromDiskResult {
+ std.debug.assert(FileSystem.instance_loaded);
+ var file = std.fs.cwd().openFileZ(filename, .{ .read = true }) catch |err| {
+ return switch (err) {
+ error.AccessDenied, error.BadPathName, error.FileNotFound => LoadFromDiskResult{ .not_found = .{} },
+ else => LoadFromDiskResult{ .err = .{ .step = .open_file, .value = err } },
+ };
+ };
+ defer file.close();
+ var buf = file.readToEndAlloc(allocator, std.math.maxInt(usize)) catch |err| {
+ return LoadFromDiskResult{ .err = .{ .step = .read_file, .value = err } };
+ };
+
+ var stream = Stream{ .buffer = buf, .pos = 0 };
+ Lockfile.Serializer.load(this, &stream, allocator, log) catch |err| {
+ return LoadFromDiskResult{ .err = .{ .step = .parse_file, .value = err } };
+ };
+
+ return LoadFromDiskResult{ .ok = this };
+ }
+
+ const PackageIDQueue = std.fifo.LinearFifo(PackageID, .Dynamic);
+
+ pub const InstallResult = struct {
+ lockfile: *Lockfile,
+ summary: PackageInstall.Summary,
+ };
+
+ pub const Tree = extern struct {
+ id: Id = invalid_id,
+ package_id: PackageID = invalid_package_id,
+
+ parent: Id = invalid_id,
+ packages: Lockfile.PackageIDSlice = Lockfile.PackageIDSlice{},
+
+ pub const Slice = ExternalSlice(Tree);
+ pub const List = std.ArrayListUnmanaged(Tree);
+ pub const Id = u32;
+ const invalid_id: Id = std.math.maxInt(Id);
+ const dependency_loop = invalid_id - 1;
+ const hoisted = invalid_id - 2;
+ const error_id = hoisted;
+
+ const SubtreeError = error{ OutOfMemory, DependencyLoop };
+
+ const NodeModulesFolder = struct {
+ relative_path: stringZ,
+ in: PackageID,
+ packages: []const PackageID,
+ };
+
+ pub const Iterator = struct {
+ trees: []const Tree,
+ package_ids: []const PackageID,
+ names: []const String,
+ tree_id: Id = 0,
+ path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined,
+ path_buf_len: usize = 0,
+ last_parent: Id = invalid_id,
+ string_buf: string,
+
+ // max number of node_modules folders
+ depth_stack: [(std.fs.MAX_PATH_BYTES / "node_modules".len) + 1]Id = undefined,
+
+ pub fn init(
+ trees: []const Tree,
+ package_ids: []const PackageID,
+ names: []const String,
+ string_buf: string,
+ ) Iterator {
+ return Tree.Iterator{
+ .trees = trees,
+ .package_ids = package_ids,
+ .names = names,
+ .tree_id = 0,
+ .path_buf = undefined,
+ .path_buf_len = 0,
+ .last_parent = invalid_id,
+ .string_buf = string_buf,
+ };
+ }
+
+ pub fn nextNodeModulesFolder(this: *Iterator) ?NodeModulesFolder {
+ if (this.tree_id >= this.trees.len) return null;
+
+ while (this.trees[this.tree_id].packages.len == 0) {
+ this.tree_id += 1;
+ if (this.tree_id >= this.trees.len) return null;
+ }
+
+ const tree = this.trees[this.tree_id];
+ const string_buf = this.string_buf;
+
+ {
+
+ // For now, the dumb way
+ // (the smart way is avoiding this copy)
+ this.path_buf[0.."node_modules".len].* = "node_modules".*;
+ var parent_id = tree.id;
+ var path_written: usize = "node_modules".len;
+ this.depth_stack[0] = 0;
+
+ if (tree.id > 0) {
+ var depth_buf_len: usize = 1;
+ while (parent_id > 0 and parent_id < @intCast(Id, this.trees.len)) {
+ this.depth_stack[depth_buf_len] = parent_id;
+ parent_id = this.trees[parent_id].parent;
+ depth_buf_len += 1;
+ }
+ depth_buf_len -= 1;
+ while (depth_buf_len > 0) : (depth_buf_len -= 1) {
+ this.path_buf[path_written] = std.fs.path.sep;
+ path_written += 1;
+
+ const tree_id = this.depth_stack[depth_buf_len];
+
+ const name = this.names[this.trees[tree_id].package_id].slice(string_buf);
+ std.mem.copy(u8, this.path_buf[path_written..], name);
+ path_written += name.len;
+
+ this.path_buf[path_written..][0.."/node_modules".len].* = (std.fs.path.sep_str ++ "node_modules").*;
+ path_written += "/node_modules".len;
+ }
+ }
+ this.path_buf[path_written] = 0;
+ this.path_buf_len = path_written;
+ }
+
+ this.tree_id += 1;
+ var relative_path: [:0]u8 = this.path_buf[0..this.path_buf_len :0];
+ return NodeModulesFolder{
+ .relative_path = relative_path,
+ .in = tree.package_id,
+ .packages = tree.packages.get(this.package_ids),
+ };
+ }
+ };
+
+ const Builder = struct {
+ allocator: *std.mem.Allocator,
+ name_hashes: []const PackageNameHash,
+ list: ArrayList = ArrayList{},
+ resolutions: []const PackageID,
+ dependencies: []const Dependency,
+ resolution_lists: []const Lockfile.PackageIDSlice,
+ queue: Lockfile.TreeFiller,
+
+ pub const Entry = struct {
+ tree: Tree,
+ packages: Lockfile.PackageIDList,
+ };
+
+ pub const ArrayList = std.MultiArrayList(Entry);
+
+ /// Flatten the multi-dimensional ArrayList of package IDs into a single easily serializable array
+ pub fn clean(this: *Builder) ![]PackageID {
+ const end = @truncate(Id, this.list.len);
+ var i: Id = 0;
+ var total_packages_count: u32 = 0;
+
+ var slice = this.list.slice();
+ var trees = this.list.items(.tree);
+ var packages = this.list.items(.packages);
+
+ // TODO: can we cull empty trees here?
+ while (i < end) : (i += 1) {
+ total_packages_count += trees[i].packages.len;
+ }
+
+ var package_ids = try this.allocator.alloc(PackageID, total_packages_count);
+ var next = PackageIDSlice{};
+
+ for (trees) |tree, id| {
+ if (tree.packages.len > 0) {
+ var child = packages[id];
+ const len = @truncate(PackageID, child.items.len);
+ next.off += next.len;
+ next.len = len;
+ trees[id].packages = next;
+ std.mem.copy(PackageID, package_ids[next.off..][0..next.len], child.items);
+ child.deinit(this.allocator);
+ }
+ }
+ this.queue.deinit();
+
+ return package_ids;
+ }
+ };
+
+ pub fn processSubtree(
+ this: *Tree,
+ package_id: PackageID,
+ builder: *Builder,
+ ) SubtreeError!void {
+ try builder.list.append(builder.allocator, .{
+ .tree = Tree{
+ .parent = this.id,
+ .id = @truncate(Id, builder.list.len),
+ .package_id = package_id,
+ },
+ .packages = .{},
+ });
+
+ var list_slice = builder.list.slice();
+ var trees = list_slice.items(.tree);
+ var package_lists = list_slice.items(.packages);
+ var next: *Tree = &trees[builder.list.len - 1];
+
+ const resolution_list = builder.resolution_lists[package_id];
+ const resolutions: []const PackageID = resolution_list.get(builder.resolutions);
+ if (resolutions.len == 0) {
+ return;
+ }
+ const dependencies: []const Dependency = builder.dependencies[resolution_list.off .. resolution_list.off + resolution_list.len];
+
+ const max_package_id = builder.name_hashes.len;
+
+ for (resolutions) |pid, j| {
+ if (pid >= max_package_id or dependencies[j].behavior.isPeer()) continue;
+
+ const destination = next.addDependency(pid, builder.name_hashes, package_lists, trees, builder.allocator);
+ switch (destination) {
+ Tree.dependency_loop => return error.DependencyLoop,
+ Tree.hoisted => continue,
+ else => {},
+ }
+
+ if (builder.resolution_lists[pid].len > 0) {
+ try builder.queue.writeItem([2]PackageID{ pid, destination });
+ }
+ }
+ }
+
+ // todo: use error type when it no longer takes up extra stack space
+ pub fn addDependency(
+ this: *Tree,
+ package_id: PackageID,
+ name_hashes: []const PackageNameHash,
+ lists: []Lockfile.PackageIDList,
+ trees: []Tree,
+ allocator: *std.mem.Allocator,
+ ) Id {
+ const this_packages = this.packages.get(lists[this.id].items);
+ const name_hash = name_hashes[package_id];
+
+ for (this_packages) |pid, slot| {
+ if (name_hashes[pid] == name_hash) {
+ if (pid != package_id) {
+ return dependency_loop;
+ }
+
+ return hoisted;
+ }
+ }
+
+ if (this.parent < error_id) {
+ const id = trees[this.parent].addDependency(
+ package_id,
+ name_hashes,
+ lists,
+ trees,
+ allocator,
+ );
+ switch (id) {
+ // If there is a dependency loop, we've reached the highest point
+ // Therefore, we resolve the dependency loop by appending to ourself
+ Tree.dependency_loop => {},
+ Tree.hoisted => return hoisted,
+ else => return id,
+ }
+ }
+
+ lists[this.id].append(allocator, package_id) catch unreachable;
+ this.packages.len += 1;
+ return this.id;
+ }
+ };
+
+ pub fn clean(old: *Lockfile, deduped: *u32, updates: []PackageManager.UpdateRequest, options: *const PackageManager.Options) !*Lockfile {
+
+ // We will only shrink the number of packages here.
+ // never grow
+ const max_package_id = old.packages.len;
+
+ if (updates.len > 0) {
+ var root_deps: []Dependency = old.packages.items(.dependencies)[0].mut(old.buffers.dependencies.items);
+ const old_resolutions: []const PackageID = old.packages.items(.resolutions)[0].get(old.buffers.resolutions.items);
+ const resolutions_of_yore: []const Resolution = old.packages.items(.resolution);
+ const old_names = old.packages.items(.name);
+ var string_builder = old.stringBuilder();
+ for (updates) |update| {
+ if (update.version.tag == .uninitialized) {
+ for (root_deps) |dep, i| {
+ if (dep.name_hash == String.Builder.stringHash(update.name)) {
+ const old_resolution = old_resolutions[i];
+ if (old_resolution > old.packages.len) continue;
+ const res = resolutions_of_yore[old_resolution];
+ const len = std.fmt.count("^{}", .{res.value.npm.fmt(old.buffers.string_bytes.items)});
+ if (len >= String.max_inline_len) {
+ string_builder.cap += len;
+ }
+ }
+ }
+ }
+ }
+
+ try string_builder.allocate();
+ defer string_builder.clamp();
+ var full_buf = string_builder.ptr.?[0 .. string_builder.cap + old.buffers.string_bytes.items.len];
+ var temp_buf: [513]u8 = undefined;
+
+ for (updates) |update, update_i| {
+ if (update.version.tag == .uninitialized) {
+ // prevent the deduping logic
+ updates[update_i].e_string = null;
+
+ for (root_deps) |dep, i| {
+ if (dep.name_hash == String.Builder.stringHash(update.name)) {
+ const old_resolution = old_resolutions[i];
+ if (old_resolution > old.packages.len) continue;
+ const res = resolutions_of_yore[old_resolution];
+ var buf = std.fmt.bufPrint(&temp_buf, "^{}", .{res.value.npm.fmt(old.buffers.string_bytes.items)}) catch break;
+ const external_version = string_builder.append(ExternalString, buf);
+ const sliced = external_version.value.sliced(
+ old.buffers.string_bytes.items,
+ );
+ root_deps[i].version = Dependency.parse(
+ old.allocator,
+ sliced.slice,
+ &sliced,
+ null,
+ ) orelse Dependency.Version{};
+ }
+ }
+ }
+ }
+ }
+
+ // Deduplication works like this
+ // Go through *already* resolved package versions
+ // Ask, do any of those versions happen to match a lower version?
+ // If yes, choose that version instead.
+ // Why lower?
+ //
+ // Normally, the problem is looks like this:
+ // Package A: "react@^17"
+ // Package B: "react@17.0.1
+ //
+ // Now you have two copies of React.
+ // When you really only wanted one.
+ // Since _typically_ the issue is that Semver ranges with "^" or "~" say "choose latest", we end up with latest
+ // if (options.enable.deduplicate_packages) {
+ // var resolutions: []PackageID = old.buffers.resolutions.items;
+ // const dependencies: []const Dependency = old.buffers.dependencies.items;
+ // const package_resolutions: []const Resolution = old.packages.items(.resolution);
+ // const string_buf = old.buffers.string_bytes.items;
+
+ // const root_resolution = @as(usize, old.packages.items(.resolutions)[0].len);
+
+ // const DedupeMap = std.ArrayHashMap(PackageNameHash, std.ArrayListUnmanaged([2]PackageID), ArrayIdentityContext(PackageNameHash), false);
+ // var dedupe_map = DedupeMap.initContext(allocator, .{});
+ // try dedupe_map.ensureTotalCapacity(old.unique_packages.count());
+
+ // for (resolutions) |resolved_package_id, dep_i| {
+ // if (resolved_package_id < max_package_id and !old.unique_packages.isSet(resolved_package_id)) {
+ // const dependency = dependencies[dep_i];
+ // if (dependency.version.tag == .npm) {
+ // var dedupe_entry = try dedupe_map.getOrPut(dependency.name_hash);
+ // if (!dedupe_entry.found_existing) dedupe_entry.value_ptr.* = .{};
+ // try dedupe_entry.value_ptr.append(allocator, [2]PackageID{ dep_i, resolved_package_id });
+ // }
+ // }
+ // }
+ // }
+
+ var new = try old.allocator.create(Lockfile);
+ try new.initEmpty(
+ old.allocator,
+ );
+ try new.string_pool.ensureTotalCapacity(old.string_pool.capacity());
+ try new.package_index.ensureTotalCapacity(old.package_index.capacity());
+ try new.packages.ensureTotalCapacity(old.allocator, old.packages.len);
+ try new.buffers.preallocate(old.buffers, old.allocator);
+
+ const InstallOrder = struct {
+ parent: PackageID,
+ children: PackageIDSlice,
+ };
+
+ old.scratch.dependency_list_queue.head = 0;
+
+ // Step 1. Recreate the lockfile with only the packages that are still alive
+ const root = old.rootPackage() orelse return error.NoPackage;
+
+ var package_id_mapping = try old.allocator.alloc(PackageID, old.packages.len);
+ std.mem.set(
+ PackageID,
+ package_id_mapping,
+ invalid_package_id,
+ );
+ var clone_queue_ = PendingResolutions.init(old.allocator);
+ new.unique_packages = try Bitset.initEmpty(old.unique_packages.bit_length, old.allocator);
+ var cloner = Cloner{
+ .old = old,
+ .lockfile = new,
+ .mapping = package_id_mapping,
+ .clone_queue = clone_queue_,
+ };
+ // try clone_queue.ensureUnusedCapacity(root.dependencies.len);
+ _ = try root.clone(old, new, package_id_mapping, &cloner);
+
+ // When you run `"bun add react"
+ // This is where we update it in the lockfile from "latest" to "^17.0.2"
+
+ try cloner.flush();
+
+ // Don't allow invalid memory to happen
+ if (updates.len > 0) {
+ const dep_list = new.packages.items(.dependencies)[0];
+ const res_list = new.packages.items(.resolutions)[0];
+ const root_deps: []const Dependency = dep_list.get(new.buffers.dependencies.items);
+ const new_resolutions: []const PackageID = res_list.get(new.buffers.resolutions.items);
+
+ for (updates) |update, update_i| {
+ if (update.version.tag == .uninitialized) {
+ for (root_deps) |dep, i| {
+ if (dep.name_hash == String.Builder.stringHash(update.name)) {
+ if (new_resolutions[i] > new.packages.len) continue;
+ updates[update_i].version_buf = new.buffers.string_bytes.items;
+ updates[update_i].version = dep.version;
+ updates[update_i].resolved_version_buf = new.buffers.string_bytes.items;
+ updates[update_i].missing_version = true;
+ }
+ }
+ }
+ }
+ }
+
+ return new;
+ }
+
+ pub const TreeFiller = std.fifo.LinearFifo([2]PackageID, .Dynamic);
+
+ const Cloner = struct {
+ clone_queue: PendingResolutions,
+ lockfile: *Lockfile,
+ old: *Lockfile,
+ mapping: []PackageID,
+ trees: Tree.List = Tree.List{},
+ trees_count: u32 = 1,
+
+ pub fn flush(this: *Cloner) anyerror!void {
+ const max_package_id = this.old.packages.len;
+ while (this.clone_queue.popOrNull()) |to_clone_| {
+ const to_clone: PendingResolution = to_clone_;
+
+ const mapping = this.mapping[to_clone.old_resolution];
+ if (mapping < max_package_id) {
+ this.lockfile.buffers.resolutions.items[to_clone.resolve_id] = this.mapping[to_clone.old_resolution];
+ continue;
+ }
+
+ const old_package = this.old.packages.get(to_clone.old_resolution);
+
+ this.lockfile.buffers.resolutions.items[to_clone.resolve_id] = try old_package.clone(
+ this.old,
+ this.lockfile,
+ this.mapping,
+ this,
+ );
+ }
+
+ try this.hoist();
+ }
+
+ fn hoist(this: *Cloner) anyerror!void {
+ const max = @truncate(PackageID, this.lockfile.packages.len);
+ if (max == 0) return;
+ var allocator = this.lockfile.allocator;
+
+ var tree_list = Tree.Builder.ArrayList{};
+
+ var slice = this.lockfile.packages.slice();
+ const unique_packages = this.lockfile.unique_packages;
+
+ var resolutions_lists: []const PackageIDSlice = slice.items(.resolutions);
+ const name_hashes: []const PackageNameHash = slice.items(.name_hash);
+ const resolutions_buffer: []const PackageID = this.lockfile.buffers.resolutions.items;
+ // populate the root of the tree with:
+ // - packages where only one version exists in the tree and they have no dependencies
+ // - dependencies from package.json
+ // Dependencies from package.json must always be put into the tree
+
+ var root_packages_count: u32 = resolutions_lists[0].len;
+ for (resolutions_lists[1..]) |list, package_id| {
+ if (list.len > 0 or !unique_packages.isSet(package_id + 1)) continue;
+ root_packages_count += 1;
+ }
+
+ var root_package_list = try PackageIDList.initCapacity(allocator, root_packages_count);
+ const root_resolutions: []const PackageID = resolutions_lists[0].get(resolutions_buffer);
+
+ try tree_list.ensureTotalCapacity(allocator, root_packages_count);
+ tree_list.len = root_packages_count;
+
+ for (resolutions_lists[1..]) |list, package_id_| {
+ const package_id = @intCast(PackageID, package_id_ + 1);
+ if (list.len > 0 or
+ !unique_packages.isSet(package_id) or
+ std.mem.indexOfScalar(PackageID, root_package_list.items, package_id) != null)
+ continue;
+ root_package_list.appendAssumeCapacity(package_id);
+ }
+
+ var tree_filler_queue: TreeFiller = TreeFiller.init(allocator);
+ try tree_filler_queue.ensureUnusedCapacity(root_resolutions.len);
+
+ var possible_duplicates_len = root_package_list.items.len;
+ for (root_resolutions) |package_id| {
+ if (package_id >= max) continue;
+ if (std.mem.indexOfScalar(PackageID, root_package_list.items[0..possible_duplicates_len], package_id) != null) continue;
+
+ root_package_list.appendAssumeCapacity(package_id);
+ }
+ {
+ var sliced = tree_list.slice();
+ var trees = sliced.items(.tree);
+ var packages = sliced.items(.packages);
+ trees[0] = .{
+ .parent = Tree.invalid_id,
+ .id = 0,
+ .packages = .{
+ .len = @truncate(PackageID, root_package_list.items.len),
+ },
+ };
+ packages[0] = root_package_list;
+
+ std.mem.set(PackageIDList, packages[1..], PackageIDList{});
+ std.mem.set(Tree, trees[1..], Tree{});
+ }
+
+ var builder = Tree.Builder{
+ .name_hashes = name_hashes,
+ .list = tree_list,
+ .queue = tree_filler_queue,
+ .resolution_lists = resolutions_lists,
+ .resolutions = resolutions_buffer,
+ .allocator = allocator,
+ .dependencies = this.lockfile.buffers.dependencies.items,
+ };
+ var builder_ = &builder;
+
+ for (root_resolutions) |package_id| {
+ if (package_id >= max) continue;
+
+ try builder.list.items(.tree)[0].processSubtree(
+ package_id,
+ builder_,
+ );
+ }
+
+ // This goes breadth-first
+ while (builder.queue.readItem()) |pids| {
+ try builder.list.items(.tree)[pids[1]].processSubtree(pids[0], builder_);
+ }
+
+ var tree_packages = try builder.clean();
+ this.lockfile.buffers.hoisted_packages = Lockfile.PackageIDList{
+ .items = tree_packages,
+ .capacity = tree_packages.len,
+ };
+ {
+ const final = builder.list.items(.tree);
+ this.lockfile.buffers.trees = Tree.List{
+ .items = final,
+ .capacity = final.len,
+ };
+ }
+ }
+ };
+
+ const PendingResolution = struct {
+ old_resolution: PackageID,
+ resolve_id: PackageID,
+ parent: PackageID,
+ };
+
+ const PendingResolutions = std.ArrayList(PendingResolution);
+
+ pub const Printer = struct {
+ lockfile: *Lockfile,
+ options: PackageManager.Options,
+ successfully_installed: ?std.DynamicBitSetUnmanaged = null,
+
+ pub const Format = enum { yarn };
+
+ var lockfile_path_buf1: [std.fs.MAX_PATH_BYTES]u8 = undefined;
+ var lockfile_path_buf2: [std.fs.MAX_PATH_BYTES]u8 = undefined;
+
+ pub fn print(
+ allocator: *std.mem.Allocator,
+ log: *logger.Log,
+ lockfile_path_: string,
+ format: Format,
+ ) !void {
+ var lockfile_path: stringZ = undefined;
+
+ if (!std.fs.path.isAbsolute(lockfile_path_)) {
+ var cwd = try std.os.getcwd(&lockfile_path_buf1);
+ var parts = [_]string{lockfile_path_};
+ var lockfile_path__ = resolve_path.joinAbsStringBuf(cwd, &lockfile_path_buf2, &parts, .auto);
+ lockfile_path_buf2[lockfile_path__.len] = 0;
+ lockfile_path = lockfile_path_buf2[0..lockfile_path__.len :0];
+ } else {
+ std.mem.copy(u8, &lockfile_path_buf1, lockfile_path);
+ lockfile_path_buf1[lockfile_path_.len] = 0;
+ lockfile_path = lockfile_path_buf1[0..lockfile_path_.len :0];
+ }
+
+ std.os.chdir(std.fs.path.dirname(lockfile_path) orelse "/") catch {};
+
+ _ = try FileSystem.init1(allocator, null);
+
+ var lockfile = try allocator.create(Lockfile);
+
+ const load_from_disk = lockfile.loadFromDisk(allocator, log, lockfile_path);
+ switch (load_from_disk) {
+ .err => |cause| {
+ switch (cause.step) {
+ .open_file => Output.prettyErrorln("<r><red>error opening lockfile:<r> {s}.", .{
+ @errorName(cause.value),
+ }),
+ .parse_file => Output.prettyErrorln("<r><red>error parsing lockfile:<r> {s}", .{
+ @errorName(cause.value),
+ }),
+ .read_file => Output.prettyErrorln("<r><red>error reading lockfile:<r> {s}", .{
+ @errorName(cause.value),
+ }),
+ }
+ if (log.errors > 0) {
+ if (Output.enable_ansi_colors) {
+ try log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), true);
+ } else {
+ try log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), false);
+ }
+ }
+ Output.flush();
+ std.os.exit(1);
+ return;
+ },
+ .not_found => {
+ Output.prettyErrorln("<r><red>lockfile not found:<r> {s}", .{
+ std.mem.span(lockfile_path),
+ });
+ Output.flush();
+ std.os.exit(1);
+ return;
+ },
+
+ .ok => {},
+ }
+
+ var writer = Output.writer();
+ try printWithLockfile(allocator, lockfile, format, @TypeOf(writer), writer);
+ Output.flush();
+ }
+
+ pub fn printWithLockfile(
+ allocator: *std.mem.Allocator,
+ lockfile: *Lockfile,
+ format: Format,
+ comptime Writer: type,
+ writer: Writer,
+ ) !void {
+ var fs = &FileSystem.instance;
+ var options = PackageManager.Options{};
+
+ var entries_option = try fs.fs.readDirectory(fs.top_level_dir, null);
+
+ var env_loader: *DotEnv.Loader = brk: {
+ var map = try allocator.create(DotEnv.Map);
+ map.* = DotEnv.Map.init(allocator);
+
+ var loader = try allocator.create(DotEnv.Loader);
+ loader.* = DotEnv.Loader.init(map, allocator);
+ break :brk loader;
+ };
+
+ env_loader.loadProcess();
+ try env_loader.load(&fs.fs, &entries_option.entries, false);
+ var log = logger.Log.init(allocator);
+ try options.load(
+ allocator,
+ &log,
+ env_loader,
+ null,
+ );
+
+ var printer = Printer{
+ .lockfile = lockfile,
+ .options = options,
+ };
+
+ switch (format) {
+ .yarn => {
+ try Yarn.print(&printer, Writer, writer);
+ },
+ }
+ }
+
+ pub const Tree = struct {
+ pub fn print(
+ this: *Printer,
+ comptime Writer: type,
+ writer: Writer,
+ comptime enable_ansi_colors: bool,
+ ) !void {
+ var lockfile = this.lockfile;
+
+ const IDDepthPair = struct {
+ depth: u16 = 0,
+ id: PackageID,
+ };
+
+ var visited = try Bitset.initEmpty(this.lockfile.packages.len, this.lockfile.allocator);
+
+ var slice = this.lockfile.packages.slice();
+ const names: []const String = slice.items(.name);
+ const resolved: []const Resolution = slice.items(.resolution);
+ const metas: []const Lockfile.Package.Meta = slice.items(.meta);
+ if (names.len == 0) return;
+ const dependency_lists = slice.items(.dependencies);
+ const resolutions_list = slice.items(.resolutions);
+ const resolutions_buffer = this.lockfile.buffers.resolutions.items;
+ const dependencies_buffer = this.lockfile.buffers.dependencies.items;
+ const package_count = @truncate(PackageID, names.len);
+ const string_buf = this.lockfile.buffers.string_bytes.items;
+
+ const root = this.lockfile.rootPackage() orelse return;
+ visited.set(0);
+ const end = @truncate(PackageID, names.len);
+
+ if (this.successfully_installed) |installed| {
+ for (resolutions_list[0].get(resolutions_buffer)) |package_id| {
+ if (package_id > end or !installed.isSet(package_id)) continue;
+
+ const package_name = names[package_id].slice(string_buf);
+
+ const dependency_list = dependency_lists[package_id];
+
+ const fmt = comptime brk: {
+ if (enable_ansi_colors) {
+ break :brk Output.prettyFmt("<r> <green>+<r> <b>{s}<r><d>@{}<r>\n", enable_ansi_colors);
+ } else {
+ break :brk Output.prettyFmt("<r> + {s}<r><d>@{}<r>\n", enable_ansi_colors);
+ }
+ };
+
+ try writer.print(
+ fmt,
+ .{
+ package_name,
+ resolved[package_id].fmt(string_buf),
+ },
+ );
+ }
+ } else {
+ for (names) |name, package_id| {
+ const package_name = name.slice(string_buf);
+
+ const dependency_list = dependency_lists[package_id];
+
+ try writer.print(
+ comptime Output.prettyFmt(" <r><b>{s}<r><d>@<b>{}<r>\n", enable_ansi_colors),
+ .{
+ package_name,
+ resolved[package_id].fmt(string_buf),
+ },
+ );
+ }
+ }
+
+ for (resolutions_list) |list, parent_id| {
+ for (list.get(resolutions_buffer)) |package_id, j| {
+ if (package_id >= end) {
+ const failed_dep: Dependency = dependency_lists[parent_id].get(dependencies_buffer)[j];
+ if (failed_dep.behavior.isOptional() or failed_dep.behavior.isPeer() or (failed_dep.behavior.isDev() and parent_id > 0)) continue;
+
+ try writer.print(
+ comptime Output.prettyFmt(
+ "<r><red>ERROR<r><d>:<r> <b>{s}<r><d>@<b>{}<r><d> failed to resolve\n",
+ enable_ansi_colors,
+ ),
+ .{
+ failed_dep.name.slice(string_buf),
+ failed_dep.version.literal.fmt(string_buf),
+ },
+ );
+ continue;
+ }
+ }
+ }
+ }
+ };
+
+ pub const Yarn = struct {
+ pub fn print(
+ this: *Printer,
+ comptime Writer: type,
+ writer: Writer,
+ ) !void {
+ try writer.writeAll(
+ \\# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
+ \\# yarn lockfile v1
+ \\
+ \\
+ );
+
+ try Yarn.packages(this, Writer, writer);
+ }
+
+ pub fn packages(
+ this: *Printer,
+ comptime Writer: type,
+ writer: Writer,
+ ) !void {
+ var slice = this.lockfile.packages.slice();
+ const names: []const String = slice.items(.name);
+ const resolved: []const Resolution = slice.items(.resolution);
+ const metas: []const Lockfile.Package.Meta = slice.items(.meta);
+ if (names.len == 0) return;
+ const dependency_lists = slice.items(.dependencies);
+ const resolutions_list = slice.items(.resolutions);
+ const resolutions_buffer = this.lockfile.buffers.resolutions.items;
+ const dependencies_buffer = this.lockfile.buffers.dependencies.items;
+ const RequestedVersion = std.HashMap(PackageID, []Dependency.Version, IdentityContext(PackageID), 80);
+ var requested_versions = RequestedVersion.init(this.lockfile.allocator);
+ var all_requested_versions = try this.lockfile.allocator.alloc(Dependency.Version, resolutions_buffer.len);
+ defer this.lockfile.allocator.free(all_requested_versions);
+ const package_count = @truncate(PackageID, names.len);
+ var alphabetized_names = try this.lockfile.allocator.alloc(PackageID, package_count - 1);
+ defer this.lockfile.allocator.free(alphabetized_names);
+
+ const string_buf = this.lockfile.buffers.string_bytes.items;
+
+ // First, we need to build a map of all requested versions
+ // This is so we can print requested versions
+ {
+ var i: PackageID = 1;
+ while (i < package_count) : (i += 1) {
+ alphabetized_names[i - 1] = @truncate(PackageID, i);
+
+ var resolutions = resolutions_buffer;
+ var dependencies = dependencies_buffer;
+
+ var j: PackageID = 0;
+ var requested_version_start = all_requested_versions;
+ while (std.mem.indexOfScalar(PackageID, resolutions, i)) |k| {
+ j += 1;
+
+ all_requested_versions[0] = dependencies[k].version;
+ all_requested_versions = all_requested_versions[1..];
+
+ dependencies = dependencies[k + 1 ..];
+ resolutions = resolutions[k + 1 ..];
+ }
+
+ var dependency_versions = requested_version_start[0..j];
+ if (dependency_versions.len > 1) std.sort.insertionSort(Dependency.Version, dependency_versions, string_buf, Dependency.Version.isLessThan);
+ try requested_versions.put(i, dependency_versions);
+ }
+ }
+
+ std.sort.sort(
+ PackageID,
+ alphabetized_names,
+ Lockfile.Package.Alphabetizer{
+ .names = names,
+ .buf = string_buf,
+ .resolutions = resolved,
+ },
+ Lockfile.Package.Alphabetizer.isAlphabetical,
+ );
+
+ // When printing, we start at 1
+ for (alphabetized_names) |i| {
+ const name = names[i].slice(string_buf);
+ const resolution = resolved[i];
+ const meta = metas[i];
+ const dependencies: []const Dependency = dependency_lists[i].get(dependencies_buffer);
+
+ // This prints:
+ // "@babel/core@7.9.0":
+ {
+ try writer.writeAll("\n");
+
+ const dependency_versions = requested_versions.get(i).?;
+ const always_needs_quote = name[0] == '@';
+
+ for (dependency_versions) |dependency_version, j| {
+ if (j > 0) {
+ try writer.writeAll(", ");
+ }
+ const version_name = dependency_version.literal.slice(string_buf);
+ const needs_quote = always_needs_quote or std.mem.indexOfAny(u8, version_name, " |\t-/!") != null;
+
+ if (needs_quote) {
+ try writer.writeByte('"');
+ }
+
+ try writer.writeAll(name);
+ try writer.writeByte('@');
+ try writer.writeAll(version_name);
+
+ if (needs_quote) {
+ try writer.writeByte('"');
+ }
+ }
+
+ try writer.writeAll(":\n");
+ }
+
+ {
+ try writer.writeAll(" version ");
+
+ const version_formatter = resolution.fmt(string_buf);
+
+ // Version is always quoted
+ try std.fmt.format(writer, "\"{any}\"\n", .{version_formatter});
+
+ try writer.writeAll(" resolved ");
+
+ const url_formatter = resolution.fmtURL(&this.options, name, string_buf);
+
+ // Resolved URL is always quoted
+ try std.fmt.format(writer, "\"{any}\"\n", .{url_formatter});
+
+ if (meta.integrity.tag != .unknown) {
+ // Integrity is...never quoted?
+ try std.fmt.format(writer, " integrity {any}\n", .{&meta.integrity});
+ }
+
+ if (dependencies.len > 0) {
+ var behavior = Behavior.uninitialized;
+ var dependency_behavior_change_count: u8 = 0;
+ for (dependencies) |dep, j| {
+ if (dep.behavior != behavior) {
+ if (dep.behavior.isOptional()) {
+ try writer.writeAll(" optionalDependencies:\n");
+ if (comptime Environment.isDebug or Environment.isTest) dependency_behavior_change_count += 1;
+ } else if (dep.behavior.isNormal()) {
+ try writer.writeAll(" dependencies:\n");
+ if (comptime Environment.isDebug or Environment.isTest) dependency_behavior_change_count += 1;
+ } else if (dep.behavior.isDev()) {
+ try writer.writeAll(" devDependencies:\n");
+ if (comptime Environment.isDebug or Environment.isTest) dependency_behavior_change_count += 1;
+ } else {
+ continue;
+ }
+ behavior = dep.behavior;
+
+ // assert its sorted
+ if (comptime Environment.isDebug or Environment.isTest) std.debug.assert(dependency_behavior_change_count < 3);
+ }
+
+ try writer.writeAll(" ");
+ const dependency_name = dep.name.slice(string_buf);
+ const needs_quote = dependency_name[0] == '@';
+ if (needs_quote) {
+ try writer.writeByte('"');
+ }
+ try writer.writeAll(dependency_name);
+ if (needs_quote) {
+ try writer.writeByte('"');
+ }
+ try writer.writeAll(" \"");
+ try writer.writeAll(dep.version.literal.slice(string_buf));
+ try writer.writeAll("\"\n");
+ }
+ }
+ }
+ }
+ }
+ };
+ };
+
+ pub fn verify(this: *Lockfile) !void {
+ std.debug.assert(this.format == .v0);
+ {
+ var i: usize = 0;
+ while (i < this.packages.len) : (i += 1) {
+ const package: Lockfile.Package = this.packages.get(i);
+ std.debug.assert(this.str(package.name).len == @as(usize, package.name.len()));
+ std.debug.assert(stringHash(this.str(package.name)) == @as(usize, package.name_hash));
+ std.debug.assert(package.dependencies.get(this.buffers.dependencies.items).len == @as(usize, package.dependencies.len));
+ std.debug.assert(package.resolutions.get(this.buffers.resolutions.items).len == @as(usize, package.resolutions.len));
+ std.debug.assert(package.resolutions.get(this.buffers.resolutions.items).len == @as(usize, package.dependencies.len));
+ const dependencies = package.dependencies.get(this.buffers.dependencies.items);
+ for (dependencies) |dependency| {
+ std.debug.assert(this.str(dependency.name).len == @as(usize, dependency.name.len()));
+ std.debug.assert(stringHash(this.str(dependency.name)) == dependency.name_hash);
+ }
+ }
+ }
+ }
+
+ pub fn saveToDisk(this: *Lockfile, filename: stringZ) void {
+ if (comptime Environment.isDebug) {
+ this.verify() catch |err| {
+ Output.prettyErrorln("<r><red>error:<r> failed to verify lockfile: {s}", .{@errorName(err)});
+ Output.flush();
+ Global.crash();
+ };
+ }
+ std.debug.assert(FileSystem.instance_loaded);
+ var tmpname_buf: [512]u8 = undefined;
+ tmpname_buf[0..8].* = "bunlock-".*;
+ var tmpfile = FileSystem.RealFS.Tmpfile{};
+ var secret: [32]u8 = undefined;
+ std.mem.writeIntNative(u64, secret[0..8], @intCast(u64, std.time.milliTimestamp()));
+ var rng = std.rand.Gimli.init(secret);
+ var base64_bytes: [64]u8 = undefined;
+ rng.random.bytes(&base64_bytes);
+
+ const tmpname__ = std.fmt.bufPrint(tmpname_buf[8..], "{s}", .{std.fmt.fmtSliceHexLower(&base64_bytes)}) catch unreachable;
+ tmpname_buf[tmpname__.len + 8] = 0;
+ const tmpname = tmpname_buf[0 .. tmpname__.len + 8 :0];
+
+ tmpfile.create(&FileSystem.instance.fs, tmpname) catch |err| {
+ Output.prettyErrorln("<r><red>error:<r> failed to open lockfile: {s}", .{@errorName(err)});
+ Output.flush();
+ Global.crash();
+ };
+
+ var file = tmpfile.file();
+
+ Lockfile.Serializer.save(this, std.fs.File, file) catch |err| {
+ tmpfile.dir().deleteFileZ(tmpname) catch {};
+ Output.prettyErrorln("<r><red>error:<r> failed to serialize lockfile: {s}", .{@errorName(err)});
+ Output.flush();
+ Global.crash();
+ };
+
+ _ = C.fchmod(
+ tmpfile.fd,
+ // chmod 777
+ 0000010 | 0000100 | 0000001 | 0001000 | 0000040 | 0000004 | 0000002 | 0000400 | 0000200 | 0000020,
+ );
+
+ tmpfile.promote(tmpname, std.fs.cwd().fd, filename) catch |err| {
+ tmpfile.dir().deleteFileZ(tmpname) catch {};
+ Output.prettyErrorln("<r><red>error:<r> failed to save lockfile: {s}", .{@errorName(err)});
+ Output.flush();
+ Global.crash();
+ };
+ }
+
+ pub fn rootPackage(this: *Lockfile) ?Lockfile.Package {
+ if (this.packages.len == 0) {
+ return null;
+ }
+
+ return this.packages.get(0);
+ }
+
+ pub inline fn str(this: *Lockfile, slicable: anytype) string {
+ return slicable.slice(this.buffers.string_bytes.items);
+ }
+
+ pub inline fn cloneString(this: *Lockfile, slicable: anytype, from: *Lockfile) string {
+ // const slice = from.str(slicable);
+ // if (this.string_pool) {
+
+ // }
+ }
+
+ pub fn initEmpty(this: *Lockfile, allocator: *std.mem.Allocator) !void {
+ this.* = Lockfile{
+ .format = .v0,
+ .packages = Lockfile.Package.List{},
+ .buffers = Buffers{},
+ .package_index = PackageIndex.Map.initContext(allocator, .{}),
+ .unique_packages = try Bitset.initFull(0, allocator),
+ .string_pool = StringPool.init(allocator),
+ .allocator = allocator,
+ .scratch = Scratch.init(allocator),
+ };
+ }
+
+ pub fn getPackageID(
+ this: *Lockfile,
+ name_hash: u64,
+ // if it's a peer dependency
+ version: ?Dependency.Version,
+ resolution: Resolution,
+ ) ?PackageID {
+ const entry = this.package_index.get(name_hash) orelse return null;
+ const resolutions: []const Resolution = this.packages.items(.resolution);
+ switch (entry) {
+ .PackageID => |id| {
+ if (comptime Environment.isDebug or Environment.isTest) {
+ std.debug.assert(id != invalid_package_id);
+ std.debug.assert(id != invalid_package_id - 1);
+ }
+
+ if (resolutions[id].eql(
+ resolution,
+ this.buffers.string_bytes.items,
+ this.buffers.string_bytes.items,
+ )) {
+ return id;
+ } else if (version) |version_| {
+ switch (version_.tag) {
+ .npm => {
+ // is it a peerDependency satisfied by a parent package?
+ if (version_.value.npm.satisfies(resolutions[id].value.npm)) {
+ return id;
+ }
+ },
+ else => return null,
+ }
+ }
+ },
+ .PackageIDMultiple => |multi_| {
+ const multi = std.mem.span(multi_);
+
+ const can_satisfy = version != null and version.?.tag == .npm;
+
+ for (multi) |id| {
+ if (comptime Environment.isDebug or Environment.isTest) {
+ std.debug.assert(id != invalid_package_id);
+ }
+
+ if (id == invalid_package_id - 1) return null;
+
+ if (resolutions[id].eql(resolution, this.buffers.string_bytes.items, this.buffers.string_bytes.items)) {
+ return id;
+ }
+
+ if (can_satisfy and version.?.value.npm.satisfies(resolutions[id].value.npm)) {
+ return id;
+ }
+ }
+ },
+ }
+
+ return null;
+ }
+
+ pub fn getOrPutID(this: *Lockfile, id: PackageID, name_hash: PackageNameHash) !void {
+ if (this.unique_packages.capacity() < this.packages.len) try this.unique_packages.resize(this.packages.len, true, this.allocator);
+ var gpe = try this.package_index.getOrPut(name_hash);
+
+ if (gpe.found_existing) {
+ var index: *PackageIndex.Entry = gpe.value_ptr;
+
+ this.unique_packages.unset(id);
+
+ switch (index.*) {
+ .PackageID => |single_| {
+ var ids = try this.allocator.alloc(PackageID, 8);
+ ids[0] = single_;
+ ids[1] = id;
+ this.unique_packages.unset(single_);
+ for (ids[2..7]) |_, i| {
+ ids[i + 2] = invalid_package_id - 1;
+ }
+ ids[7] = invalid_package_id;
+ // stage1 compiler doesn't like this
+ var ids_sentinel = ids.ptr[0 .. ids.len - 1 :invalid_package_id];
+ index.* = .{
+ .PackageIDMultiple = ids_sentinel,
+ };
+ },
+ .PackageIDMultiple => |ids_| {
+ var ids = std.mem.span(ids_);
+ for (ids) |id2, i| {
+ if (id2 == invalid_package_id - 1) {
+ ids[i] = id;
+ return;
+ }
+ }
+
+ var new_ids = try this.allocator.alloc(PackageID, ids.len + 8);
+ defer this.allocator.free(ids);
+ std.mem.set(PackageID, new_ids, invalid_package_id - 1);
+ for (ids) |id2, i| {
+ new_ids[i] = id2;
+ }
+ new_ids[new_ids.len - 1] = invalid_package_id;
+
+ // stage1 compiler doesn't like this
+ var new_ids_sentinel = new_ids.ptr[0 .. new_ids.len - 1 :invalid_package_id];
+ index.* = .{
+ .PackageIDMultiple = new_ids_sentinel,
+ };
+ },
+ }
+ } else {
+ gpe.value_ptr.* = .{ .PackageID = id };
+ this.unique_packages.set(id);
+ }
+ }
+
+ pub fn appendPackage(this: *Lockfile, package_: Lockfile.Package) !Lockfile.Package {
+ const id = @truncate(PackageID, this.packages.len);
+ return try appendPackageWithID(this, package_, id);
+ }
+
+ pub fn appendPackageWithID(this: *Lockfile, package_: Lockfile.Package, id: PackageID) !Lockfile.Package {
+ defer {
+ if (comptime Environment.isDebug) {
+ std.debug.assert(this.getPackageID(package_.name_hash, null, package_.resolution) != null);
+ std.debug.assert(this.getPackageID(package_.name_hash, null, package_.resolution).? == id);
+ }
+ }
+ var package = package_;
+ package.meta.id = id;
+ try this.packages.append(this.allocator, package);
+ try this.getOrPutID(id, package.name_hash);
+
+ return package;
+ }
+
+ const StringPool = String.Builder.StringPool;
+
+ pub inline fn stringHash(in: []const u8) u64 {
+ return std.hash.Wyhash.hash(0, in);
+ }
+
+ pub inline fn stringBuilder(this: *Lockfile) Lockfile.StringBuilder {
+ return Lockfile.StringBuilder{
+ .lockfile = this,
+ };
+ }
+
+ pub const Scratch = struct {
+ pub const DuplicateCheckerMap = std.HashMap(PackageNameHash, logger.Loc, IdentityContext(PackageNameHash), 80);
+ pub const DependencyQueue = std.fifo.LinearFifo(DependencySlice, .Dynamic);
+
+ duplicate_checker_map: DuplicateCheckerMap = undefined,
+ dependency_list_queue: DependencyQueue = undefined,
+
+ pub fn init(allocator: *std.mem.Allocator) Scratch {
+ return Scratch{
+ .dependency_list_queue = DependencyQueue.init(allocator),
+ .duplicate_checker_map = DuplicateCheckerMap.init(allocator),
+ };
+ }
+ };
+
+ pub const StringBuilder = struct {
+ const Allocator = @import("std").mem.Allocator;
+ const assert = @import("std").debug.assert;
+ const copy = @import("std").mem.copy;
+
+ len: usize = 0,
+ cap: usize = 0,
+ off: usize = 0,
+ ptr: ?[*]u8 = null,
+ lockfile: *Lockfile = undefined,
+
+ pub inline fn count(this: *StringBuilder, slice: string) void {
+ if (String.canInline(slice)) return;
+ return countWithHash(this, slice, stringHash(slice));
+ }
+
+ pub inline fn countWithHash(this: *StringBuilder, slice: string, hash: u64) void {
+ if (String.canInline(slice)) return;
+ if (!this.lockfile.string_pool.contains(hash)) {
+ this.cap += slice.len;
+ }
+ }
+
+ pub fn allocatedSlice(this: *StringBuilder) ![]u8 {
+ return this.ptr.?[0..this.cap];
+ }
+
+ pub fn clamp(this: *StringBuilder) void {
+ std.debug.assert(this.cap >= this.len);
+
+ const excess = this.cap - this.len;
+
+ if (excess > 0)
+ this.lockfile.buffers.string_bytes.items = this.lockfile.buffers.string_bytes.items[0 .. this.lockfile.buffers.string_bytes.items.len - excess];
+ }
+
+ pub fn allocate(this: *StringBuilder) !void {
+ var string_bytes = &this.lockfile.buffers.string_bytes;
+ try string_bytes.ensureUnusedCapacity(this.lockfile.allocator, this.cap);
+ const prev_len = string_bytes.items.len;
+ this.off = prev_len;
+ string_bytes.items = string_bytes.items.ptr[0 .. string_bytes.items.len + this.cap];
+ this.ptr = string_bytes.items.ptr[prev_len .. prev_len + this.cap].ptr;
+ this.len = 0;
+ }
+
+ pub fn append(this: *StringBuilder, comptime Type: type, slice: string) Type {
+ return @call(.{ .modifier = .always_inline }, appendWithHash, .{ this, Type, slice, stringHash(slice) });
+ }
+
+ // SlicedString is not supported due to inline strings.
+ pub fn appendWithoutPool(this: *StringBuilder, comptime Type: type, slice: string, hash: u64) Type {
+ if (String.canInline(slice)) {
+ switch (Type) {
+ String => {
+ return String.init(this.lockfile.buffers.string_bytes.items, slice);
+ },
+ ExternalString => {
+ return ExternalString.init(this.lockfile.buffers.string_bytes.items, slice, hash);
+ },
+ else => @compileError("Invalid type passed to StringBuilder"),
+ }
+ }
+ assert(this.len <= this.cap); // didn't count everything
+ assert(this.ptr != null); // must call allocate first
+
+ copy(u8, this.ptr.?[this.len..this.cap], slice);
+ const final_slice = this.ptr.?[this.len..this.cap][0..slice.len];
+ this.len += slice.len;
+
+ assert(this.len <= this.cap);
+
+ switch (Type) {
+ String => {
+ return String.init(this.lockfile.buffers.string_bytes.items, final_slice);
+ },
+ ExternalString => {
+ return ExternalString.init(this.lockfile.buffers.string_bytes.items, final_slice, hash);
+ },
+ else => @compileError("Invalid type passed to StringBuilder"),
+ }
+ }
+
+ pub fn appendWithHash(this: *StringBuilder, comptime Type: type, slice: string, hash: u64) Type {
+ if (String.canInline(slice)) {
+ switch (Type) {
+ String => {
+ return String.init(this.lockfile.buffers.string_bytes.items, slice);
+ },
+ ExternalString => {
+ return ExternalString.init(this.lockfile.buffers.string_bytes.items, slice, hash);
+ },
+ else => @compileError("Invalid type passed to StringBuilder"),
+ }
+ }
+
+ assert(this.len <= this.cap); // didn't count everything
+ assert(this.ptr != null); // must call allocate first
+
+ var string_entry = this.lockfile.string_pool.getOrPut(hash) catch unreachable;
+ if (!string_entry.found_existing) {
+ copy(u8, this.ptr.?[this.len..this.cap], slice);
+ const final_slice = this.ptr.?[this.len..this.cap][0..slice.len];
+ this.len += slice.len;
+
+ string_entry.value_ptr.* = String.init(this.lockfile.buffers.string_bytes.items, final_slice);
+ }
+
+ assert(this.len <= this.cap);
+
+ switch (Type) {
+ String => {
+ return string_entry.value_ptr.*;
+ },
+ ExternalString => {
+ return ExternalString{
+ .value = string_entry.value_ptr.*,
+ .hash = hash,
+ };
+ },
+ else => @compileError("Invalid type passed to StringBuilder"),
+ }
+ }
+ };
+
+ pub const PackageIndex = struct {
+ pub const Map = std.HashMap(PackageNameHash, PackageIndex.Entry, IdentityContext(PackageNameHash), 80);
+ pub const Entry = union(Tag) {
+ PackageID: PackageID,
+ PackageIDMultiple: PackageIDMultiple,
+
+ pub const Tag = enum(u8) {
+ PackageID = 0,
+ PackageIDMultiple = 1,
+ };
+ };
+ };
+
+ pub const FormatVersion = enum(u32) {
+ v0,
+ _,
+ };
+
+ pub const DependencySlice = ExternalSlice(Dependency);
+ pub const PackageIDSlice = ExternalSlice(PackageID);
+ pub const NodeModulesFolderSlice = ExternalSlice(NodeModulesFolder);
+
+ pub const PackageIDList = std.ArrayListUnmanaged(PackageID);
+ pub const DependencyList = std.ArrayListUnmanaged(Dependency);
+ pub const StringBuffer = std.ArrayListUnmanaged(u8);
+ pub const SmallExternalStringBuffer = std.ArrayListUnmanaged(String);
+
+ pub const Package = extern struct {
+ const DependencyGroup = struct {
+ prop: string,
+ field: string,
+ behavior: Behavior,
+
+ pub const dependencies = DependencyGroup{ .prop = "dependencies", .field = "dependencies", .behavior = @intToEnum(Behavior, Behavior.normal) };
+ pub const dev = DependencyGroup{ .prop = "devDependencies", .field = "dev_dependencies", .behavior = @intToEnum(Behavior, Behavior.dev) };
+ pub const optional = DependencyGroup{ .prop = "optionalDependencies", .field = "optional_dependencies", .behavior = @intToEnum(Behavior, Behavior.optional) };
+ pub const peer = DependencyGroup{ .prop = "peerDependencies", .field = "peer_dependencies", .behavior = @intToEnum(Behavior, Behavior.peer) };
+ };
+
+ pub inline fn isDisabled(this: *const Lockfile.Package) bool {
+ return this.meta.isDisabled();
+ }
+
+ const Alphabetizer = struct {
+ names: []const String,
+ buf: []const u8,
+ resolutions: []const Resolution,
+
+ pub fn isAlphabetical(ctx: Alphabetizer, lhs: PackageID, rhs: PackageID) bool {
+ return switch (ctx.names[lhs].order(&ctx.names[rhs], ctx.buf, ctx.buf)) {
+ .eq => ctx.resolutions[lhs].order(&ctx.resolutions[rhs], ctx.buf, ctx.buf) == .lt,
+ .lt => true,
+ .gt => false,
+ };
+ }
+ };
+
+ pub fn clone(
+ this: *const Lockfile.Package,
+ old: *Lockfile,
+ new: *Lockfile,
+ package_id_mapping: []PackageID,
+ cloner: *Cloner,
+ ) !PackageID {
+ const old_string_buf = old.buffers.string_bytes.items;
+ var builder_ = new.stringBuilder();
+ var builder = &builder_;
+
+ builder.count(this.name.slice(old_string_buf));
+ this.resolution.count(old_string_buf, *Lockfile.StringBuilder, builder);
+ this.meta.count(old_string_buf, *Lockfile.StringBuilder, builder);
+ this.bin.count(old_string_buf, *Lockfile.StringBuilder, builder);
+
+ const old_dependencies: []const Dependency = this.dependencies.get(old.buffers.dependencies.items);
+ const old_resolutions: []const PackageID = this.resolutions.get(old.buffers.resolutions.items);
+
+ for (old_dependencies) |dependency, i| {
+ dependency.count(old_string_buf, *Lockfile.StringBuilder, builder);
+ }
+
+ try builder.allocate();
+
+ // should be unnecessary, but Just In Case
+ try new.buffers.dependencies.ensureUnusedCapacity(new.allocator, old_dependencies.len);
+ try new.buffers.resolutions.ensureUnusedCapacity(new.allocator, old_dependencies.len);
+
+ const prev_len = @truncate(u32, new.buffers.dependencies.items.len);
+ const end = prev_len + @truncate(u32, old_dependencies.len);
+ const max_package_id = @truncate(PackageID, old.packages.len);
+
+ new.buffers.dependencies.items = new.buffers.dependencies.items.ptr[0..end];
+ new.buffers.resolutions.items = new.buffers.resolutions.items.ptr[0..end];
+
+ var dependencies: []Dependency = new.buffers.dependencies.items[prev_len..end];
+ var resolutions: []PackageID = new.buffers.resolutions.items[prev_len..end];
+
+ const id = @truncate(PackageID, new.packages.len);
+ const new_package = try new.appendPackageWithID(
+ Lockfile.Package{
+ .name = builder.appendWithHash(
+ String,
+ this.name.slice(old_string_buf),
+ this.name_hash,
+ ),
+ .bin = this.bin.clone(old_string_buf, *Lockfile.StringBuilder, builder),
+ .name_hash = this.name_hash,
+ .meta = this.meta.clone(
+ old_string_buf,
+ *Lockfile.StringBuilder,
+ builder,
+ ),
+ .resolution = this.resolution.clone(
+ old_string_buf,
+ *Lockfile.StringBuilder,
+ builder,
+ ),
+ .dependencies = .{ .off = prev_len, .len = end - prev_len },
+ .resolutions = .{ .off = prev_len, .len = end - prev_len },
+ },
+ id,
+ );
+
+ package_id_mapping[this.meta.id] = new_package.meta.id;
+
+ for (old_dependencies) |dependency, i| {
+ dependencies[i] = try dependency.clone(
+ old_string_buf,
+ *Lockfile.StringBuilder,
+ builder,
+ );
+ }
+
+ builder.clamp();
+
+ cloner.trees_count += @as(u32, @boolToInt(old_resolutions.len > 0));
+
+ for (old_resolutions) |old_resolution, i| {
+ if (old_resolution >= max_package_id) continue;
+
+ const mapped = package_id_mapping[old_resolution];
+ const resolve_id = new_package.resolutions.off + @intCast(PackageID, i);
+
+ if (mapped < max_package_id) {
+ resolutions[i] = mapped;
+ } else {
+ try cloner.clone_queue.append(
+ PendingResolution{
+ .old_resolution = old_resolution,
+ .parent = new_package.meta.id,
+ .resolve_id = resolve_id,
+ },
+ );
+ }
+ }
+
+ return new_package.meta.id;
+ }
+
+ pub fn fromNPM(
+ allocator: *std.mem.Allocator,
+ lockfile: *Lockfile,
+ log: *logger.Log,
+ manifest: *const Npm.PackageManifest,
+ version: Semver.Version,
+ package_version_ptr: *const Npm.PackageVersion,
+ string_buf: []const u8,
+ comptime features: Features,
+ ) !Lockfile.Package {
+ var npm_count: u32 = 0;
+ var package = Lockfile.Package{};
+
+ const package_version = package_version_ptr.*;
+
+ const dependency_groups = comptime brk: {
+ var out_groups: [
+ 1 +
+ @as(usize, @boolToInt(features.dev_dependencies)) +
+ @as(usize, @boolToInt(features.optional_dependencies)) +
+ @as(usize, @boolToInt(features.peer_dependencies))
+ ]DependencyGroup = undefined;
+ var out_group_i: usize = 0;
+
+ out_groups[out_group_i] = DependencyGroup.dependencies;
+ out_group_i += 1;
+
+ if (features.dev_dependencies) {
+ out_groups[out_group_i] = DependencyGroup.dev;
+ out_group_i += 1;
+ }
+
+ if (features.optional_dependencies) {
+ out_groups[out_group_i] = DependencyGroup.optional;
+ out_group_i += 1;
+ }
+
+ if (features.peer_dependencies) {
+ out_groups[out_group_i] = DependencyGroup.peer;
+ out_group_i += 1;
+ }
+
+ break :brk out_groups;
+ };
+
+ var string_builder = lockfile.stringBuilder();
+
+ var total_dependencies_count: u32 = 0;
+
+ // --- Counting
+ {
+ string_builder.count(manifest.name());
+ version.count(string_buf, @TypeOf(&string_builder), &string_builder);
+
+ inline for (dependency_groups) |group| {
+ const map: ExternalStringMap = @field(package_version, group.field);
+ const keys = map.name.get(manifest.external_strings);
+ const version_strings = map.value.get(manifest.external_strings_for_versions);
+ total_dependencies_count += map.value.len;
+
+ if (comptime Environment.isDebug) std.debug.assert(keys.len == version_strings.len);
+
+ for (keys) |key, i| {
+ string_builder.count(key.slice(string_buf));
+ string_builder.count(version_strings[i].slice(string_buf));
+ }
+ }
+
+ package_version.bin.count(string_buf, @TypeOf(&string_builder), &string_builder);
+ }
+
+ try string_builder.allocate();
+ defer string_builder.clamp();
+
+ var dependencies_list = &lockfile.buffers.dependencies;
+ var resolutions_list = &lockfile.buffers.resolutions;
+ try dependencies_list.ensureUnusedCapacity(lockfile.allocator, total_dependencies_count);
+ try resolutions_list.ensureUnusedCapacity(lockfile.allocator, total_dependencies_count);
+
+ // -- Cloning
+ {
+ const package_name: ExternalString = string_builder.appendWithHash(ExternalString, manifest.name(), manifest.pkg.name.hash);
+ package.name_hash = package_name.hash;
+ package.name = package_name.value;
+ package.resolution = Resolution{
+ .value = .{
+ .npm = version.clone(
+ manifest.string_buf,
+ @TypeOf(&string_builder),
+ &string_builder,
+ ),
+ },
+ .tag = .npm,
+ };
+
+ const total_len = dependencies_list.items.len + total_dependencies_count;
+ std.debug.assert(dependencies_list.items.len == resolutions_list.items.len);
+
+ var dependencies: []Dependency = dependencies_list.items.ptr[dependencies_list.items.len..total_len];
+ std.mem.set(Dependency, dependencies, Dependency{});
+
+ var start_dependencies = dependencies;
+
+ const off = @truncate(u32, dependencies_list.items.len);
+
+ inline for (dependency_groups) |group| {
+ const map: ExternalStringMap = @field(package_version, group.field);
+ const keys = map.name.get(manifest.external_strings);
+ const version_strings = map.value.get(manifest.external_strings_for_versions);
+
+ if (comptime Environment.isDebug) std.debug.assert(keys.len == version_strings.len);
+ const is_peer = comptime strings.eqlComptime(group.field, "peer_dependencies");
+ var i: usize = 0;
+
+ list: while (i < keys.len) {
+ const key = keys[i];
+ const version_string_ = version_strings[i];
+
+ // Duplicate peer & dev dependencies are promoted to whichever appeared first
+ // In practice, npm validates this so it shouldn't happen
+ if (comptime group.behavior.isPeer() or group.behavior.isDev()) {
+ for (start_dependencies[0 .. total_dependencies_count - dependencies.len]) |dependency, j| {
+ if (dependency.name_hash == key.hash) {
+ i += 1;
+ continue :list;
+ }
+ }
+ }
+
+ const name: ExternalString = string_builder.appendWithHash(ExternalString, key.slice(string_buf), key.hash);
+ const dep_version = string_builder.appendWithHash(String, version_string_.slice(string_buf), version_string_.hash);
+ const sliced = dep_version.sliced(lockfile.buffers.string_bytes.items);
+
+ const dependency = Dependency{
+ .name = name.value,
+ .name_hash = name.hash,
+ .behavior = if (comptime is_peer)
+ group.behavior.setOptional(package_version.optional_peer_dependencies_len > i)
+ else
+ group.behavior,
+ .version = Dependency.parse(
+ allocator,
+ sliced.slice,
+ &sliced,
+ log,
+ ) orelse Dependency.Version{},
+ };
+
+ // If a dependency appears in both "dependencies" and "optionalDependencies", it is considered optional!
+ if (comptime group.behavior.isOptional()) {
+ for (start_dependencies[0 .. total_dependencies_count - dependencies.len]) |dep, j| {
+ if (dep.name_hash == key.hash) {
+ // https://docs.npmjs.com/cli/v8/configuring-npm/package-json#optionaldependencies
+ // > Entries in optionalDependencies will override entries of the same name in dependencies, so it's usually best to only put in one place.
+ start_dependencies[j] = dep;
+
+ i += 1;
+ continue :list;
+ }
+ }
+ }
+
+ package.meta.npm_dependency_count += @as(u32, @boolToInt(dependency.version.tag.isNPM()));
+
+ dependencies[0] = dependency;
+ dependencies = dependencies[1..];
+ i += 1;
+ }
+ }
+
+ package.bin = package_version.bin.clone(string_buf, @TypeOf(&string_builder), &string_builder);
+
+ package.meta.arch = package_version.cpu;
+ package.meta.os = package_version.os;
+ package.meta.unpacked_size = package_version.unpacked_size;
+ package.meta.file_count = package_version.file_count;
+
+ package.meta.integrity = package_version.integrity;
+
+ package.dependencies.off = @truncate(u32, dependencies_list.items.len);
+ package.dependencies.len = total_dependencies_count - @truncate(u32, dependencies.len);
+ package.resolutions.off = package.dependencies.off;
+ package.resolutions.len = package.dependencies.len;
+
+ const new_length = package.dependencies.len + dependencies_list.items.len;
+
+ std.mem.set(PackageID, resolutions_list.items.ptr[package.dependencies.off .. package.dependencies.off + package.dependencies.len], invalid_package_id);
+
+ dependencies_list.items = dependencies_list.items.ptr[0..new_length];
+ resolutions_list.items = resolutions_list.items.ptr[0..new_length];
+
+ return package;
+ }
+ }
+
+ pub const Diff = union(Op) {
+ add: Lockfile.Package.Diff.Entry,
+ remove: Lockfile.Package.Diff.Entry,
+ update: struct { in: PackageID, from: Dependency, to: Dependency, from_resolution: PackageID, to_resolution: PackageID },
+
+ pub const Entry = struct { in: PackageID, dependency: Dependency, resolution: PackageID };
+ pub const Op = enum {
+ add,
+ remove,
+ update,
+ };
+
+ pub const List = std.fifo.LinearFifo(Diff, .Dynamic);
+
+ pub const Summary = struct {
+ add: u32 = 0,
+ remove: u32 = 0,
+ update: u32 = 0,
+ deduped: u32 = 0,
+
+ pub inline fn sum(this: *Summary, that: Summary) void {
+ this.add += that.add;
+ this.remove += that.remove;
+ this.update += that.update;
+ this.deduped += that.deduped;
+ }
+ };
+
+ pub fn generate(
+ allocator: *std.mem.Allocator,
+ from_lockfile: *Lockfile,
+ to_lockfile: *Lockfile,
+ from: *Lockfile.Package,
+ to: *Lockfile.Package,
+ mapping: []PackageID,
+ ) !Summary {
+ var summary = Summary{};
+ const to_deps = to.dependencies.get(to_lockfile.buffers.dependencies.items);
+ const to_res = to.resolutions.get(to_lockfile.buffers.resolutions.items);
+ const from_res = from.resolutions.get(from_lockfile.buffers.resolutions.items);
+ const from_deps = from.dependencies.get(from_lockfile.buffers.dependencies.items);
+
+ for (from_deps) |from_dep, i| {
+ // common case: dependency is present in both versions and in the same position
+ const to_i = if (to_deps.len > i and to_deps[i].name_hash == from_dep.name_hash)
+ i
+ else brk: {
+ // less common, o(n^2) case
+ for (to_deps) |to_dep, j| {
+ if (from_dep.name_hash == to_dep.name_hash) break :brk j;
+ }
+
+ // We found a removed dependency!
+ // We don't need to remove it
+ // It will be cleaned up later
+ summary.remove += 1;
+ continue;
+ };
+
+ if (to_deps[to_i].eql(from_dep, from_lockfile.buffers.string_bytes.items, to_lockfile.buffers.string_bytes.items)) {
+ mapping[to_i] = @truncate(PackageID, i);
+ continue;
+ }
+
+ // We found a changed dependency!
+ summary.update += 1;
+ }
+
+ outer: for (to_deps) |to_dep, i| {
+ if (from_deps.len > i and from_deps[i].name_hash == to_dep.name_hash) continue;
+
+ for (from_deps) |from_dep, j| {
+ if (from_dep.name_hash == to_dep.name_hash) continue :outer;
+ }
+
+ summary.add += 1;
+ }
+
+ return summary;
+ }
+ };
+
+ pub fn determinePreinstallState(this: *Lockfile.Package, lockfile: *Lockfile, manager: *PackageManager) PreinstallState {
+ switch (this.meta.preinstall_state) {
+ .unknown => {
+ // Do not automatically start downloading packages which are disabled
+ // i.e. don't download all of esbuild's versions or SWCs
+ if (this.isDisabled()) {
+ this.meta.preinstall_state = .done;
+ return .done;
+ }
+
+ const folder_path = PackageManager.cachedNPMPackageFolderName(this.name.slice(lockfile.buffers.string_bytes.items), this.resolution.value.npm);
+ if (manager.isFolderInCache(folder_path)) {
+ this.meta.preinstall_state = .done;
+ return this.meta.preinstall_state;
+ }
+
+ this.meta.preinstall_state = .extract;
+ return this.meta.preinstall_state;
+ },
+ else => return this.meta.preinstall_state,
+ }
+ }
+
+ pub fn hash(name: string, version: Semver.Version) u64 {
+ var hasher = std.hash.Wyhash.init(0);
+ hasher.update(name);
+ hasher.update(std.mem.asBytes(&version));
+ return hasher.final();
+ }
+
+ pub fn parse(
+ lockfile: *Lockfile,
+ package: *Lockfile.Package,
+ allocator: *std.mem.Allocator,
+ log: *logger.Log,
+ source: logger.Source,
+ comptime features: Features,
+ ) !void {
+ initializeStore();
+
+ var json = json_parser.ParseJSON(&source, log, allocator) catch |err| {
+ if (Output.enable_ansi_colors) {
+ log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), true) catch {};
+ } else {
+ log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), false) catch {};
+ }
+
+ Output.panic("<r><red>{s}<r> parsing package.json for <b>\"{s}\"<r>", .{ @errorName(err), source.path.prettyDir() });
+ };
+
+ var string_builder = lockfile.stringBuilder();
+ var total_dependencies_count: u32 = 0;
+
+ package.meta.origin = if (features.is_main) .local else .npm;
+
+ // -- Count the sizes
+ if (json.asProperty("name")) |name_q| {
+ if (name_q.expr.asString(allocator)) |name| {
+ string_builder.count(name);
+ }
+ }
+
+ if (comptime !features.is_main) {
+ if (json.asProperty("version")) |version_q| {
+ if (version_q.expr.asString(allocator)) |version_str| {
+ string_builder.count(version_str);
+ }
+ }
+ }
+
+ const dependency_groups = comptime brk: {
+ var out_groups: [
+ 2 +
+ @as(usize, @boolToInt(features.optional_dependencies)) +
+ @as(usize, @boolToInt(features.peer_dependencies))
+ ]DependencyGroup = undefined;
+ var out_group_i: usize = 0;
+
+ out_groups[out_group_i] = DependencyGroup.dependencies;
+ out_group_i += 1;
+
+ out_groups[out_group_i] = DependencyGroup.dev;
+ out_group_i += 1;
+
+ if (features.optional_dependencies) {
+ out_groups[out_group_i] = DependencyGroup.optional;
+ out_group_i += 1;
+ }
+
+ if (features.peer_dependencies) {
+ out_groups[out_group_i] = DependencyGroup.peer;
+ out_group_i += 1;
+ }
+
+ break :brk out_groups;
+ };
+
+ inline for (dependency_groups) |group| {
+ if (json.asProperty(group.prop)) |dependencies_q| {
+ if (dependencies_q.expr.data == .e_object) {
+ for (dependencies_q.expr.data.e_object.properties) |item| {
+ string_builder.count(item.key.?.asString(allocator) orelse "");
+ string_builder.count(item.value.?.asString(allocator) orelse "");
+ }
+ total_dependencies_count += @truncate(u32, dependencies_q.expr.data.e_object.properties.len);
+ }
+ }
+ }
+
+ try string_builder.allocate();
+ try lockfile.buffers.dependencies.ensureUnusedCapacity(lockfile.allocator, total_dependencies_count);
+ try lockfile.buffers.resolutions.ensureUnusedCapacity(lockfile.allocator, total_dependencies_count);
+
+ const total_len = lockfile.buffers.dependencies.items.len + total_dependencies_count;
+ std.debug.assert(lockfile.buffers.dependencies.items.len == lockfile.buffers.resolutions.items.len);
+ const off = lockfile.buffers.dependencies.items.len;
+
+ var package_dependencies = lockfile.buffers.dependencies.items.ptr[off..total_len];
+ var dependencies = package_dependencies;
+
+ if (json.asProperty("name")) |name_q| {
+ if (name_q.expr.asString(allocator)) |name| {
+ const external_string = string_builder.append(ExternalString, name);
+
+ package.name = external_string.value;
+ package.name_hash = external_string.hash;
+ }
+ }
+
+ if (comptime !features.is_main) {
+ if (json.asProperty("version")) |version_q| {
+ if (version_q.expr.asString(allocator)) |version_str_| {
+ const version_str: String = string_builder.append(String, version_str_);
+ const sliced_string: SlicedString = version_str.sliced(string_buf.allocatedSlice());
+
+ const semver_version = Semver.Version.parse(sliced_string, allocator);
+
+ if (semver_version.valid) {
+ package.resolution = .{
+ .tag = .npm,
+ .value = .{ .npm = semver_version.version },
+ };
+ } else {
+ log.addErrorFmt(null, logger.Loc.Empty, allocator, "invalid version \"{s}\"", .{version_str}) catch unreachable;
+ }
+ }
+ }
+ } else {
+ package.resolution = .{
+ .tag = .root,
+ .value = .{ .root = .{} },
+ };
+ }
+
+ // It is allowed for duplicate dependencies to exist in optionalDependencies and regular dependencies
+ if (comptime features.check_for_duplicate_dependencies) {
+ lockfile.scratch.duplicate_checker_map.clearRetainingCapacity();
+ try lockfile.scratch.duplicate_checker_map.ensureTotalCapacity(total_dependencies_count);
+ }
+
+ inline for (dependency_groups) |group| {
+ if (json.asProperty(group.prop)) |dependencies_q| {
+ if (dependencies_q.expr.data == .e_object) {
+ const dependency_props: []const JSAst.G.Property = dependencies_q.expr.data.e_object.properties;
+ var i: usize = 0;
+ outer: while (i < dependency_props.len) {
+ const item = dependency_props[i];
+
+ const name_ = item.key.?.asString(allocator) orelse "";
+ const version_ = item.value.?.asString(allocator) orelse "";
+
+ const external_name = string_builder.append(ExternalString, name_);
+
+ const external_version = string_builder.append(String, version_);
+
+ const sliced = external_version.sliced(
+ lockfile.buffers.string_bytes.items,
+ );
+
+ const dependency_version = Dependency.parse(
+ allocator,
+ sliced.slice,
+ &sliced,
+ log,
+ ) orelse Dependency.Version{};
+ const this_dep = Dependency{
+ .behavior = group.behavior,
+ .name = external_name.value,
+ .name_hash = external_name.hash,
+ .version = dependency_version,
+ };
+
+ if (comptime features.check_for_duplicate_dependencies) {
+ var entry = lockfile.scratch.duplicate_checker_map.getOrPutAssumeCapacity(external_name.hash);
+ if (entry.found_existing) {
+ // duplicate dependencies are allowed in optionalDependencies
+ if (comptime group.behavior.isOptional()) {
+ for (package_dependencies[0 .. package_dependencies.len - dependencies.len]) |package_dep, j| {
+ if (package_dep.name_hash == this_dep.name_hash) {
+ package_dependencies[j] = this_dep;
+ break;
+ }
+ }
+
+ i += 1;
+ continue :outer;
+ } else {
+ var notes = try allocator.alloc(logger.Data, 1);
+
+ notes[0] = logger.Data{
+ .text = try std.fmt.allocPrint(lockfile.allocator, "\"{s}\" originally specified here", .{name_}),
+ .location = logger.Location.init_or_nil(&source, source.rangeOfString(entry.value_ptr.*)),
+ };
+
+ try log.addRangeErrorFmtWithNotes(
+ &source,
+ source.rangeOfString(item.key.?.loc),
+ lockfile.allocator,
+ notes,
+ "Duplicate dependency: \"{s}\" specified in package.json",
+ .{name_},
+ );
+ }
+ }
+
+ entry.value_ptr.* = item.value.?.loc;
+ }
+
+ dependencies[0] = this_dep;
+ package.meta.npm_dependency_count += @as(u32, @boolToInt(dependency_version.tag.isNPM()));
+ dependencies = dependencies[1..];
+ i += 1;
+ }
+ }
+ }
+ }
+
+ std.sort.sort(
+ Dependency,
+ package_dependencies[0 .. package_dependencies.len - dependencies.len],
+ lockfile.buffers.string_bytes.items,
+ Dependency.isLessThan,
+ );
+
+ total_dependencies_count -= @truncate(u32, dependencies.len);
+ package.dependencies.off = @truncate(u32, off);
+ package.dependencies.len = @truncate(u32, total_dependencies_count);
+
+ package.resolutions = @bitCast(@TypeOf(package.resolutions), package.dependencies);
+
+ std.mem.set(PackageID, lockfile.buffers.resolutions.items.ptr[off..total_len], invalid_package_id);
+
+ lockfile.buffers.dependencies.items = lockfile.buffers.dependencies.items.ptr[0 .. lockfile.buffers.dependencies.items.len + total_dependencies_count];
+ lockfile.buffers.resolutions.items = lockfile.buffers.resolutions.items.ptr[0..lockfile.buffers.dependencies.items.len];
+ }
+
+ pub const List = std.MultiArrayList(Lockfile.Package);
+
+ pub const Meta = extern struct {
+ preinstall_state: PreinstallState = PreinstallState.unknown,
+
+ origin: Origin = Origin.npm,
+ arch: Npm.Architecture = Npm.Architecture.all,
+ os: Npm.OperatingSystem = Npm.OperatingSystem.all,
+
+ file_count: u32 = 0,
+ npm_dependency_count: u32 = 0,
+ id: PackageID = invalid_package_id,
+
+ man_dir: String = String{},
+ unpacked_size: u64 = 0,
+ integrity: Integrity = Integrity{},
+
+ pub fn isDisabled(this: *const Meta) bool {
+ return !this.arch.isMatch() or !this.os.isMatch();
+ }
+
+ pub fn count(this: *const Meta, buf: []const u8, comptime StringBuilderType: type, builder: StringBuilderType) void {
+ builder.count(this.man_dir.slice(buf));
+ }
+
+ pub fn clone(this: *const Meta, buf: []const u8, comptime StringBuilderType: type, builder: StringBuilderType) Meta {
+ var new = this.*;
+ new.id = invalid_package_id;
+ new.man_dir = builder.append(String, this.man_dir.slice(buf));
+
+ return new;
+ }
+ };
+
+ name: String = String{},
+ name_hash: PackageNameHash = 0,
+ resolution: Resolution = Resolution{},
+ dependencies: DependencySlice = DependencySlice{},
+ resolutions: PackageIDSlice = PackageIDSlice{},
+ meta: Meta = Meta{},
+ bin: Bin = Bin{},
+
+ pub const Serializer = struct {
+ pub const sizes = blk: {
+ const fields = std.meta.fields(Lockfile.Package);
+ const Data = struct {
+ size: usize,
+ size_index: usize,
+ alignment: usize,
+ Type: type,
+ };
+ var data: [fields.len]Data = undefined;
+ for (fields) |field_info, i| {
+ data[i] = .{
+ .size = @sizeOf(field_info.field_type),
+ .size_index = i,
+ .Type = field_info.field_type,
+ .alignment = if (@sizeOf(field_info.field_type) == 0) 1 else field_info.alignment,
+ };
+ }
+ const Sort = struct {
+ fn lessThan(trash: *i32, comptime lhs: Data, comptime rhs: Data) bool {
+ _ = trash;
+ return lhs.alignment > rhs.alignment;
+ }
+ };
+ var trash: i32 = undefined; // workaround for stage1 compiler bug
+ std.sort.sort(Data, &data, &trash, Sort.lessThan);
+ var sizes_bytes: [fields.len]usize = undefined;
+ var field_indexes: [fields.len]usize = undefined;
+ var Types: [fields.len]type = undefined;
+ for (data) |elem, i| {
+ sizes_bytes[i] = elem.size;
+ field_indexes[i] = elem.size_index;
+ Types[i] = elem.Type;
+ }
+ break :blk .{
+ .bytes = sizes_bytes,
+ .fields = field_indexes,
+ .Types = Types,
+ };
+ };
+
+ const FieldsEnum = @typeInfo(Lockfile.Package.List.Field).Enum;
+
+ pub fn byteSize(list: Lockfile.Package.List) usize {
+ const sizes_vector: std.meta.Vector(sizes.bytes.len, usize) = sizes.bytes;
+ const capacity_vector = @splat(sizes.bytes.len, list.len);
+ return @reduce(.Add, capacity_vector * sizes_vector);
+ }
+
+ const AlignmentType = sizes.Types[sizes.fields[0]];
+
+ pub fn save(list: Lockfile.Package.List, comptime StreamType: type, stream: StreamType, comptime Writer: type, writer: Writer) !void {
+ const bytes = list.bytes[0..byteSize(list)];
+ try writer.writeIntLittle(u64, bytes.len);
+ try writer.writeIntLittle(u64, list.len);
+ // _ = try Aligner.write(AlignmentType, Writer, writer, try stream.getPos());
+ var slice = list.slice();
+ inline for (sizes.fields) |field_index| {
+ const Type = sizes.Types[field_index];
+ _ = try Aligner.write(Type, Writer, writer, try stream.getPos());
+ try writer.writeAll(std.mem.sliceAsBytes(
+ slice.items(
+ @intToEnum(Lockfile.Package.List.Field, FieldsEnum.fields[field_index].value),
+ ),
+ ));
+ }
+ }
+
+ pub fn load(
+ stream: *Stream,
+ allocator: *std.mem.Allocator,
+ ) !Lockfile.Package.List {
+ var reader = stream.reader();
+
+ const byte_len = try reader.readIntLittle(u64);
+
+ if (byte_len == 0) {
+ return Lockfile.Package.List{
+ .len = 0,
+ .capacity = 0,
+ };
+ }
+
+ // Count of items in the list
+ const list_len = try reader.readIntLittle(u64);
+
+ var list = Lockfile.Package.List{};
+ try list.ensureTotalCapacity(allocator, list_len);
+ list.len = list_len;
+ var slice = list.slice();
+
+ inline for (sizes.fields) |field_index| {
+ const Type = sizes.Types[field_index];
+ stream.pos += Aligner.skipAmount(Type, try stream.getPos());
+ var bytes = std.mem.sliceAsBytes(
+ slice.items(
+ @intToEnum(Lockfile.Package.List.Field, FieldsEnum.fields[field_index].value),
+ ),
+ );
+ @memcpy(bytes.ptr, @ptrCast([*]u8, &stream.buffer[stream.pos]), bytes.len);
+ stream.pos += bytes.len;
+ }
+
+ // Alignment bytes to skip
+ // stream.pos += Aligner.skipAmount(AlignmentType, try stream.getPos());
+
+ return list;
+ }
+ };
+ };
+
+ const Buffers = struct {
+ trees: Tree.List = Tree.List{},
+ hoisted_packages: PackageIDList = PackageIDList{},
+ resolutions: PackageIDList = PackageIDList{},
+ dependencies: DependencyList = DependencyList{},
+ extern_strings: SmallExternalStringBuffer = SmallExternalStringBuffer{},
+ // node_modules_folders: NodeModulesFolderList = NodeModulesFolderList{},
+ // node_modules_package_ids: PackageIDList = PackageIDList{},
+ string_bytes: StringBuffer = StringBuffer{},
+
+ pub fn preallocate(this: *Buffers, that: Buffers, allocator: *std.mem.Allocator) !void {
+ try this.trees.ensureTotalCapacity(allocator, that.trees.items.len);
+ try this.resolutions.ensureTotalCapacity(allocator, that.resolutions.items.len);
+ try this.dependencies.ensureTotalCapacity(allocator, that.dependencies.items.len);
+ try this.extern_strings.ensureTotalCapacity(allocator, that.extern_strings.items.len);
+ try this.string_bytes.ensureTotalCapacity(allocator, that.string_bytes.items.len);
+ }
+
+ pub fn readArray(stream: *Stream, comptime ArrayList: type) !ArrayList {
+ const arraylist: ArrayList = undefined;
+
+ const PointerType = std.meta.Child(@TypeOf(arraylist.items.ptr));
+ const alignment = @alignOf([*]PointerType);
+
+ var reader = stream.reader();
+ const byte_len = try reader.readIntLittle(u64);
+
+ if (byte_len == 0) return ArrayList{
+ .items = &[_]PointerType{},
+ .capacity = 0,
+ };
+
+ stream.pos += Aligner.skipAmount([*]PointerType, stream.pos);
+ const start = stream.pos;
+ stream.pos += byte_len;
+
+ if (stream.pos > stream.buffer.len) {
+ return error.BufferOverflow;
+ }
+
+ return ArrayList{
+ .items = @ptrCast([*]PointerType, @alignCast(alignment, &stream.buffer[start]))[0 .. byte_len / @sizeOf(PointerType)],
+ .capacity = byte_len,
+ };
+ }
+
+ const sizes = blk: {
+ const fields = std.meta.fields(Lockfile.Buffers);
+ const Data = struct {
+ size: usize,
+ name: []const u8,
+ field_type: type,
+ alignment: usize,
+ };
+ var data: [fields.len]Data = undefined;
+ for (fields) |field_info, i| {
+ data[i] = .{
+ .size = @sizeOf(field_info.field_type),
+ .name = field_info.name,
+ .alignment = if (@sizeOf(field_info.field_type) == 0) 1 else field_info.alignment,
+ .field_type = field_info.field_type.Slice,
+ };
+ }
+ const Sort = struct {
+ fn lessThan(trash: *i32, comptime lhs: Data, comptime rhs: Data) bool {
+ _ = trash;
+ return lhs.alignment > rhs.alignment;
+ }
+ };
+ var trash: i32 = undefined; // workaround for stage1 compiler bug
+ std.sort.sort(Data, &data, &trash, Sort.lessThan);
+ var sizes_bytes: [fields.len]usize = undefined;
+ var names: [fields.len][]const u8 = undefined;
+ var types: [fields.len]type = undefined;
+ for (data) |elem, i| {
+ sizes_bytes[i] = elem.size;
+ names[i] = elem.name;
+ types[i] = elem.field_type;
+ }
+ break :blk .{
+ .bytes = sizes_bytes,
+ .names = names,
+ .types = types,
+ };
+ };
+
+ pub fn writeArray(comptime StreamType: type, stream: StreamType, comptime Writer: type, writer: Writer, comptime ArrayList: type, array: ArrayList) !void {
+ const bytes = std.mem.sliceAsBytes(array);
+ try writer.writeIntLittle(u64, bytes.len);
+
+ if (bytes.len > 0) {
+ _ = try Aligner.write([*]std.meta.Child(ArrayList), Writer, writer, try stream.getPos());
+
+ try writer.writeAll(bytes);
+ }
+ }
+
+ pub fn save(this: Buffers, allocator: *std.mem.Allocator, comptime StreamType: type, stream: StreamType, comptime Writer: type, writer: Writer) !void {
+ inline for (sizes.names) |name, i| {
+ var pos: usize = 0;
+ if (comptime Environment.isDebug) {
+ pos = try stream.getPos();
+ }
+
+ // Dependencies have to be converted to .toExternal first
+ // We store pointers in Version.Value, so we can't just write it directly
+ if (comptime strings.eqlComptime(name, "dependencies")) {
+ var remaining = this.dependencies.items;
+
+ var buf: [128]Dependency.External = undefined;
+
+ switch (remaining.len) {
+ 0 => {
+ try writer.writeIntLittle(u64, 0);
+ },
+ 1...127 => {
+ for (remaining) |dep, j| {
+ buf[j] = dep.toExternal();
+ }
+ const to_write = std.mem.sliceAsBytes(buf[0..remaining.len]);
+ try writer.writeIntLittle(u64, to_write.len);
+ _ = try Aligner.write(
+ [*]Dependency.External,
+ Writer,
+ writer,
+ try stream.getPos(),
+ );
+ try writer.writeAll(to_write);
+ },
+ else => {
+ try writer.writeIntLittle(u64, @sizeOf(Dependency.External) * remaining.len);
+ _ = try Aligner.write(
+ [*]Dependency.External,
+ Writer,
+ writer,
+ try stream.getPos(),
+ );
+
+ var buf_i: usize = 0;
+ for (remaining) |dep| {
+ if (buf_i >= buf.len) {
+ try writer.writeAll(std.mem.sliceAsBytes(&buf));
+ buf_i = 0;
+ }
+ buf[buf_i] = dep.toExternal();
+ buf_i += 1;
+ }
+ if (buf_i > 0) {
+ const to_write = std.mem.sliceAsBytes(buf[0..buf_i]);
+ try writer.writeAll(to_write);
+ }
+ },
+ }
+ } else {
+ const list = @field(this, name).items;
+ const Type = @TypeOf(list);
+
+ try writeArray(StreamType, stream, Writer, writer, Type, list);
+ }
+
+ if (comptime Environment.isDebug) {
+ // Output.prettyErrorln("Field {s}: {d} - {d}", .{ name, pos, try stream.getPos() });
+ }
+ }
+ }
+
+ pub fn load(stream: *Stream, allocator: *std.mem.Allocator, log: *logger.Log) !Buffers {
+ var this = Buffers{};
+ var external_dependency_list: []Dependency.External = &[_]Dependency.External{};
+ inline for (sizes.names) |name, i| {
+ const Type = @TypeOf(@field(this, name));
+
+ var pos: usize = 0;
+ if (comptime Environment.isDebug) {
+ pos = try stream.getPos();
+ }
+
+ if (comptime Type == @TypeOf(this.dependencies)) {
+ var reader = stream.reader();
+ const len = try reader.readIntLittle(u64);
+ if (len > 0) {
+ stream.pos += Aligner.skipAmount([*]Dependency.External, stream.pos);
+ const start = stream.pos;
+ stream.pos += len;
+ if (stream.pos > stream.buffer.len) {
+ return error.BufferOverflow;
+ }
+ var bytes = stream.buffer[start..][0..len];
+ external_dependency_list = @alignCast(
+ @alignOf([]Dependency.External),
+ std.mem.bytesAsSlice(
+ Dependency.External,
+ bytes,
+ ),
+ );
+ }
+ } else {
+ @field(this, sizes.names[i]) = try readArray(stream, Type);
+ }
+
+ if (comptime Environment.isDebug) {
+ // Output.prettyErrorln("Field {s}: {d} - {d}", .{ sizes.names[i], pos, try stream.getPos() });
+ }
+ }
+
+ // Dependencies are serialized separately.
+ // This is unfortunate. However, not using pointers for Semver Range's make the code a lot more complex.
+ this.dependencies = try DependencyList.initCapacity(allocator, external_dependency_list.len);
+ const extern_context = Dependency.External.Context{
+ .log = log,
+ .allocator = allocator,
+ .buffer = this.string_bytes.items,
+ };
+
+ this.dependencies.expandToCapacity();
+ this.dependencies.items.len = external_dependency_list.len;
+ for (external_dependency_list) |dep, i| {
+ this.dependencies.items[i] = dep.toDependency(extern_context);
+ }
+
+ return this;
+ }
+ };
+
+ pub const Serializer = struct {
+ pub const version = "bun-lockfile-format-v0\n";
+ const header_bytes: string = "#!/usr/bin/env bun\n" ++ version;
+
+ pub fn save(this: *Lockfile, comptime StreamType: type, stream: StreamType) !void {
+ var writer = stream.writer();
+ try writer.writeAll(header_bytes);
+ try writer.writeIntLittle(u32, @enumToInt(this.format));
+ const pos = try stream.getPos();
+ try writer.writeIntLittle(u64, 0);
+
+ try Lockfile.Package.Serializer.save(this.packages, StreamType, stream, @TypeOf(&writer), &writer);
+ try Lockfile.Buffers.save(this.buffers, this.allocator, StreamType, stream, @TypeOf(&writer), &writer);
+
+ try writer.writeIntLittle(u64, 0);
+ const end = try stream.getPos();
+ try writer.writeAll(alignment_bytes_to_repeat_buffer);
+
+ _ = try std.os.pwrite(stream.handle, std.mem.asBytes(&end), pos);
+ }
+ pub fn load(
+ lockfile: *Lockfile,
+ stream: *Stream,
+ allocator: *std.mem.Allocator,
+ log: *logger.Log,
+ ) !void {
+ var reader = stream.reader();
+ var header_buf_: [header_bytes.len]u8 = undefined;
+ var header_buf = header_buf_[0..try reader.readAll(&header_buf_)];
+
+ if (!strings.eqlComptime(header_buf, header_bytes)) {
+ return error.InvalidLockfile;
+ }
+
+ var format = try reader.readIntLittle(u32);
+ if (format != @enumToInt(Lockfile.FormatVersion.v0)) {
+ return error.InvalidLockfileVersion;
+ }
+ lockfile.format = .v0;
+ lockfile.allocator = allocator;
+ const byte_len = try reader.readIntLittle(u64);
+
+ lockfile.packages = try Lockfile.Package.Serializer.load(
+ stream,
+ allocator,
+ );
+ lockfile.buffers = try Lockfile.Buffers.load(stream, allocator, log);
+ lockfile.scratch = Lockfile.Scratch.init(allocator);
+
+ {
+ lockfile.package_index = PackageIndex.Map.initContext(allocator, .{});
+ lockfile.unique_packages = try Bitset.initFull(lockfile.packages.len, allocator);
+ lockfile.string_pool = StringPool.initContext(allocator, .{});
+ try lockfile.package_index.ensureTotalCapacity(@truncate(u32, lockfile.packages.len));
+ var slice = lockfile.packages.slice();
+ var name_hashes = slice.items(.name_hash);
+ for (name_hashes) |name_hash, id| {
+ try lockfile.getOrPutID(@truncate(PackageID, id), name_hash);
+ }
+ }
+
+ // const end = try reader.readIntLittle(u64);
+ }
+ };
+};
+/// Schedule long-running callbacks for a task
+/// Slow stuff is broken into tasks, each can run independently without locks
+const Task = struct {
+ tag: Tag,
+ request: Request,
+ data: Data,
+ status: Status = Status.waiting,
+ threadpool_task: ThreadPool.Task = ThreadPool.Task{ .callback = callback },
+ log: logger.Log,
+ id: u64,
+
+ /// An ID that lets us register a callback without keeping the same pointer around
+ pub const Id = struct {
+ pub fn forNPMPackage(tag: Task.Tag, package_name: string, package_version: Semver.Version) u64 {
+ var hasher = std.hash.Wyhash.init(0);
+ hasher.update(package_name);
+ hasher.update("@");
+ hasher.update(std.mem.asBytes(&package_version));
+ return @as(u64, @truncate(u63, hasher.final())) | @as(u64, 1 << 63);
+ }
+
+ pub fn forBinLink(package_id: PackageID) u64 {
+ const hash = std.hash.Wyhash.hash(0, std.mem.asBytes(&package_id));
+ return @as(u64, @truncate(u62, hash)) | @as(u64, 1 << 62) | @as(u64, 1 << 63);
+ }
+
+ pub fn forManifest(
+ tag: Task.Tag,
+ name: string,
+ ) u64 {
+ return @as(u64, @truncate(u63, std.hash.Wyhash.hash(0, name)));
+ }
+ };
+
+ pub fn callback(task: *ThreadPool.Task) void {
+ Output.Source.configureThread();
+ defer Output.flush();
+
+ var this = @fieldParentPtr(Task, "threadpool_task", task);
+
+ switch (this.tag) {
+ .package_manifest => {
+ var allocator = PackageManager.instance.allocator;
+ const package_manifest = Npm.Registry.getPackageMetadata(
+ allocator,
+ this.request.package_manifest.network.http.response.?,
+ this.request.package_manifest.network.response_buffer.toOwnedSliceLeaky(),
+ &this.log,
+ this.request.package_manifest.name.slice(),
+ this.request.package_manifest.network.callback.package_manifest.loaded_manifest,
+ ) catch |err| {
+ this.status = Status.fail;
+ PackageManager.instance.resolve_tasks.writeItem(this.*) catch unreachable;
+ return;
+ };
+
+ this.data = .{ .package_manifest = .{} };
+
+ switch (package_manifest) {
+ .cached => unreachable,
+ .fresh => |manifest| {
+ this.data = .{ .package_manifest = manifest };
+ this.status = Status.success;
+ PackageManager.instance.resolve_tasks.writeItem(this.*) catch unreachable;
+ return;
+ },
+ .not_found => {
+ this.log.addErrorFmt(null, logger.Loc.Empty, allocator, "404 - GET {s}", .{
+ this.request.package_manifest.name.slice(),
+ }) catch unreachable;
+ this.status = Status.fail;
+ PackageManager.instance.resolve_tasks.writeItem(this.*) catch unreachable;
+ return;
+ },
+ }
+ },
+ .extract => {
+ const result = this.request.extract.tarball.run(
+ this.request.extract.network.response_buffer.toOwnedSliceLeaky(),
+ ) catch |err| {
+ this.status = Status.fail;
+ this.data = .{ .extract = "" };
+ PackageManager.instance.resolve_tasks.writeItem(this.*) catch unreachable;
+ return;
+ };
+
+ this.data = .{ .extract = result };
+ this.status = Status.success;
+ PackageManager.instance.resolve_tasks.writeItem(this.*) catch unreachable;
+ },
+ .binlink => {},
+ }
+ }
+
+ pub const Tag = enum(u2) {
+ package_manifest = 1,
+ extract = 2,
+ binlink = 3,
+ // install = 3,
+ };
+
+ pub const Status = enum {
+ waiting,
+ success,
+ fail,
+ };
+
+ pub const Data = union {
+ package_manifest: Npm.PackageManifest,
+ extract: string,
+ binlink: bool,
+ };
+
+ pub const Request = union {
+ /// package name
+ // todo: Registry URL
+ package_manifest: struct {
+ name: strings.StringOrTinyString,
+ network: *NetworkTask,
+ },
+ extract: struct {
+ network: *NetworkTask,
+ tarball: ExtractTarball,
+ },
+ binlink: Bin.Linker,
+ // install: PackageInstall,
+ };
+};
+
+const PackageInstall = struct {
+ cache_dir: std.fs.Dir,
+ destination_dir: std.fs.Dir,
+ cache_dir_subpath: stringZ = "",
+ destination_dir_subpath: stringZ = "",
+ destination_dir_subpath_buf: []u8,
+
+ allocator: *std.mem.Allocator,
+
+ progress: *Progress,
+
+ package_name: string,
+ package_version: string,
+ file_count: u32 = 0,
+
+ threadlocal var package_json_checker: json_parser.PackageJSONVersionChecker = undefined;
+
+ pub const Context = struct {
+ metas: []const Lockfile.Package.Meta,
+ names: []const String,
+ resolutions: []const Resolution,
+ string_buf: []const u8,
+ channel: PackageInstall.Task.Channel = undefined,
+ skip_verify: bool = false,
+ progress: *Progress = undefined,
+ cache_dir: std.fs.Dir = undefined,
+ allocator: *std.mem.Allocator,
+ };
+
+ pub const Task = struct {
+ task: ThreadPool.Task = .{ .callback = callback },
+ result: Result = Result{ .pending = void{} },
+ package_install: PackageInstall = undefined,
+ package_id: PackageID,
+ ctx: *PackageInstall.Context,
+ destination_dir: std.fs.Dir,
+
+ pub const Channel = sync.Channel(*PackageInstall.Task, .{ .Static = 1024 });
+
+ pub fn callback(task: *ThreadPool.Task) void {
+ Output.Source.configureThread();
+ defer Output.flush();
+
+ var this: *PackageInstall.Task = @fieldParentPtr(PackageInstall.Task, "task", task);
+ var ctx = this.ctx;
+
+ var destination_dir_subpath_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
+ var cache_dir_subpath_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
+ const name = ctx.names[this.package_id].slice(ctx.string_buf);
+ const meta = ctx.metas[this.package_id];
+ const resolution = ctx.resolutions[this.package_id];
+ std.mem.copy(u8, &destination_dir_subpath_buf, name);
+ destination_dir_subpath_buf[name.len] = 0;
+ var destination_dir_subpath: [:0]u8 = destination_dir_subpath_buf[0..name.len :0];
+ var resolution_buf: [512]u8 = undefined;
+ var resolution_label = std.fmt.bufPrint(&resolution_buf, "{}", .{resolution.fmt(ctx.string_buf)}) catch unreachable;
+
+ switch (resolution.tag) {
+ .npm => {
+ this.package_install = PackageInstall{
+ .cache_dir = ctx.cache_dir,
+ .progress = ctx.progress,
+ .cache_dir_subpath = PackageManager.cachedNPMPackageFolderNamePrint(&cache_dir_subpath_buf, name, resolution.value.npm),
+ .destination_dir = this.destination_dir,
+ .destination_dir_subpath = destination_dir_subpath,
+ .destination_dir_subpath_buf = &destination_dir_subpath_buf,
+ .allocator = ctx.allocator,
+ .package_name = name,
+ .package_version = resolution_label,
+ };
+
+ const needs_install = ctx.skip_verify or !this.package_install.verify();
+
+ if (needs_install) {
+ this.result = this.package_install.install(ctx.skip_verify);
+ } else {
+ this.result = .{ .skip = .{} };
+ }
+ },
+ else => {},
+ }
+
+ ctx.channel.writeItem(this) catch unreachable;
+ }
+ };
+
+ pub const Summary = struct {
+ fail: u32 = 0,
+ success: u32 = 0,
+ skipped: u32 = 0,
+ successfully_installed: ?std.DynamicBitSetUnmanaged = null,
+ };
+
+ pub const Method = enum {
+ clonefile,
+
+ // Slower than clonefile
+ clonefile_each_dir,
+
+ // On macOS, slow.
+ // On Linux, fast.
+ hardlink,
+
+ // Slowest if single-threaded
+ copyfile,
+
+ const BackendSupport = std.EnumArray(Method, bool);
+
+ pub const macOS = BackendSupport.initDefault(false, .{
+ .clonefile = true,
+ .clonefile_each_dir = true,
+ .hardlink = true,
+ .copyfile = true,
+ });
+
+ pub const linux = BackendSupport.initDefault(false, .{
+ .hardlink = true,
+ .copyfile = true,
+ });
+
+ pub inline fn isSupported(this: Method) bool {
+ if (comptime Environment.isMac) return macOS.get(this);
+ if (comptime Environment.isLinux) return linux.get(this);
+
+ return false;
+ }
+ };
+
+ pub fn verify(
+ this: *PackageInstall,
+ ) bool {
+ var allocator = this.allocator;
+ std.mem.copy(u8, this.destination_dir_subpath_buf[this.destination_dir_subpath.len..], std.fs.path.sep_str ++ "package.json");
+ this.destination_dir_subpath_buf[this.destination_dir_subpath.len + std.fs.path.sep_str.len + "package.json".len] = 0;
+ var package_json_path: [:0]u8 = this.destination_dir_subpath_buf[0 .. this.destination_dir_subpath.len + std.fs.path.sep_str.len + "package.json".len :0];
+ defer this.destination_dir_subpath_buf[this.destination_dir_subpath.len] = 0;
+
+ var package_json_file = this.destination_dir.openFileZ(package_json_path, .{ .read = true }) catch return false;
+ defer package_json_file.close();
+
+ var body_pool = Npm.Registry.BodyPool.get(allocator);
+ var mutable: MutableString = body_pool.data;
+ defer {
+ body_pool.data = mutable;
+ Npm.Registry.BodyPool.release(body_pool);
+ }
+
+ mutable.reset();
+ var total: usize = 0;
+ var read: usize = 0;
+ mutable.list.expandToCapacity();
+
+ // Heuristic: most package.jsons will be less than 2048 bytes.
+ read = package_json_file.read(mutable.list.items[total..]) catch return false;
+ var remain = mutable.list.items[@minimum(total, read)..];
+ if (read > 0 and remain.len < 1024) {
+ mutable.growBy(4096) catch return false;
+ mutable.list.expandToCapacity();
+ }
+
+ while (read > 0) : (read = package_json_file.read(remain) catch return false) {
+ total += read;
+
+ mutable.list.expandToCapacity();
+ remain = mutable.list.items[total..];
+
+ if (remain.len < 1024) {
+ mutable.growBy(4096) catch return false;
+ }
+ mutable.list.expandToCapacity();
+ remain = mutable.list.items[total..];
+ }
+
+ // If it's not long enough to have {"name": "foo", "version": "1.2.0"}, there's no way it's valid
+ if (total < "{\"name\":\"\",\"version\":\"\"}".len + this.package_name.len + this.package_version.len) return false;
+
+ const source = logger.Source.initPathString(std.mem.span(package_json_path), mutable.list.items[0..total]);
+ var log = logger.Log.init(allocator);
+ defer log.deinit();
+
+ initializeStore();
+
+ package_json_checker = json_parser.PackageJSONVersionChecker.init(allocator, &source, &log) catch return false;
+ _ = package_json_checker.parseExpr() catch return false;
+ if (!package_json_checker.has_found_name or !package_json_checker.has_found_version or log.errors > 0) return false;
+
+ // Version is more likely to not match than name, so we check it first.
+ return strings.eql(package_json_checker.found_version, this.package_version) and
+ strings.eql(package_json_checker.found_name, this.package_name);
+ }
+
+ pub const Result = union(Tag) {
+ pending: void,
+ success: void,
+ skip: void,
+ fail: struct {
+ err: anyerror,
+ step: Step = Step.clone,
+
+ pub inline fn isPackageMissingFromCache(this: @This()) bool {
+ return this.err == error.FileNotFound and this.step == .opening_cache_dir;
+ }
+ },
+
+ pub const Tag = enum {
+ success,
+ fail,
+ pending,
+ skip,
+ };
+ };
+
+ pub const Step = enum {
+ copyfile,
+ opening_cache_dir,
+ copying_files,
+ };
+
+ const CloneFileError = error{
+ NotSupported,
+ Unexpected,
+ FileNotFound,
+ };
+
+ var supported_method: Method = if (Environment.isMac)
+ Method.clonefile
+ else
+ Method.copyfile;
+
+ fn installWithClonefileEachDir(this: *PackageInstall) !Result {
+ const Walker = @import("../walker_skippable.zig");
+
+ var cached_package_dir = this.cache_dir.openDirZ(this.cache_dir_subpath, .{
+ .iterate = true,
+ }) catch |err| return Result{
+ .fail = .{ .err = err, .step = .opening_cache_dir },
+ };
+ defer cached_package_dir.close();
+ var walker_ = Walker.walk(
+ cached_package_dir,
+ this.allocator,
+ &[_]string{},
+ &[_]string{},
+ ) catch |err| return Result{
+ .fail = .{ .err = err, .step = .opening_cache_dir },
+ };
+ defer walker_.deinit();
+
+ const FileCopier = struct {
+ pub fn copy(
+ destination_dir_: std.fs.Dir,
+ walker: *Walker,
+ ) !u32 {
+ var real_file_count: u32 = 0;
+ var stackpath: [std.fs.MAX_PATH_BYTES]u8 = undefined;
+ while (try walker.next()) |entry| {
+ switch (entry.kind) {
+ .Directory => std.os.mkdirat(destination_dir_.fd, entry.path, 0o755) catch {},
+ .File => {
+ std.mem.copy(u8, &stackpath, entry.path);
+ stackpath[entry.path.len] = 0;
+ var path: [:0]u8 = stackpath[0..entry.path.len :0];
+ var basename: [:0]u8 = stackpath[entry.path.len - entry.basename.len .. entry.path.len :0];
+ switch (C.clonefileat(
+ entry.dir.fd,
+ basename,
+ destination_dir_.fd,
+ path,
+ 0,
+ )) {
+ 0 => void{},
+ else => |errno| switch (std.os.errno(errno)) {
+ .OPNOTSUPP => return error.NotSupported,
+ .NOENT => return error.FileNotFound,
+ else => return error.Unexpected,
+ },
+ }
+
+ real_file_count += 1;
+ },
+ else => {},
+ }
+ }
+
+ return real_file_count;
+ }
+ };
+
+ var subdir = this.destination_dir.makeOpenPath(std.mem.span(this.destination_dir_subpath), .{ .iterate = true }) catch |err| return Result{
+ .fail = .{ .err = err, .step = .opening_cache_dir },
+ };
+
+ defer subdir.close();
+
+ this.file_count = FileCopier.copy(
+ subdir,
+ &walker_,
+ ) catch |err| return Result{
+ .fail = .{ .err = err, .step = .copying_files },
+ };
+
+ return Result{
+ .success = void{},
+ };
+ }
+
+ // https://www.unix.com/man-page/mojave/2/fclonefileat/
+ fn installWithClonefile(this: *PackageInstall) CloneFileError!Result {
+ if (comptime !Environment.isMac) @compileError("clonefileat() is macOS only.");
+
+ if (this.package_name[0] == '@') {
+ const current = std.mem.span(this.destination_dir_subpath);
+ if (strings.indexOfChar(current, std.fs.path.sep)) |slash| {
+ this.destination_dir_subpath_buf[slash] = 0;
+ var subdir = this.destination_dir_subpath_buf[0..slash :0];
+ this.destination_dir.makeDirZ(subdir) catch {};
+ this.destination_dir_subpath_buf[slash] = std.fs.path.sep;
+ }
+ }
+
+ return switch (C.clonefileat(
+ this.cache_dir.fd,
+ this.cache_dir_subpath,
+ this.destination_dir.fd,
+ this.destination_dir_subpath,
+ 0,
+ )) {
+ 0 => .{ .success = void{} },
+ else => |errno| switch (std.os.errno(errno)) {
+ .OPNOTSUPP => error.NotSupported,
+ .NOENT => error.FileNotFound,
+ // We first try to delete the directory
+ // But, this can happen if this package contains a node_modules folder
+ // We want to continue installing as many packages as we can, so we shouldn't block while downloading
+ // We use the slow path in this case
+ .EXIST => try this.installWithClonefileEachDir(),
+ else => error.Unexpected,
+ },
+ };
+ }
+ fn installWithCopyfile(this: *PackageInstall) Result {
+ const Walker = @import("../walker_skippable.zig");
+ const CopyFile = @import("../copy_file.zig");
+
+ var cached_package_dir = this.cache_dir.openDirZ(this.cache_dir_subpath, .{
+ .iterate = true,
+ }) catch |err| return Result{
+ .fail = .{ .err = err, .step = .opening_cache_dir },
+ };
+ defer cached_package_dir.close();
+ var walker_ = Walker.walk(
+ cached_package_dir,
+ this.allocator,
+ &[_]string{},
+ &[_]string{},
+ ) catch |err| return Result{
+ .fail = .{ .err = err, .step = .opening_cache_dir },
+ };
+ defer walker_.deinit();
+
+ const FileCopier = struct {
+ pub fn copy(
+ destination_dir_: std.fs.Dir,
+ walker: *Walker,
+ progress_: *Progress,
+ ) !u32 {
+ var real_file_count: u32 = 0;
+ while (try walker.next()) |entry| {
+ if (entry.kind != .File) continue;
+ real_file_count += 1;
+
+ var outfile = destination_dir_.createFile(entry.path, .{}) catch brk: {
+ if (std.fs.path.dirname(entry.path)) |entry_dirname| {
+ destination_dir_.makePath(entry_dirname) catch {};
+ }
+ break :brk destination_dir_.createFile(entry.path, .{}) catch |err| {
+ progress_.root.end();
+
+ progress_.refresh();
+
+ Output.prettyErrorln("<r><red>{s}<r>: copying file {s}", .{ @errorName(err), entry.path });
+ Output.flush();
+ std.os.exit(1);
+ };
+ };
+ defer outfile.close();
+
+ var infile = try entry.dir.openFile(entry.basename, .{ .read = true });
+ defer infile.close();
+
+ const stat = infile.stat() catch continue;
+ _ = C.fchmod(outfile.handle, stat.mode);
+
+ CopyFile.copy(infile.handle, outfile.handle) catch {
+ entry.dir.copyFile(entry.basename, destination_dir_, entry.path, .{}) catch |err| {
+ progress_.root.end();
+
+ progress_.refresh();
+
+ Output.prettyErrorln("<r><red>{s}<r>: copying file {s}", .{ @errorName(err), entry.path });
+ Output.flush();
+ std.os.exit(1);
+ };
+ };
+ }
+
+ return real_file_count;
+ }
+ };
+
+ var subdir = this.destination_dir.makeOpenPath(std.mem.span(this.destination_dir_subpath), .{ .iterate = true }) catch |err| return Result{
+ .fail = .{ .err = err, .step = .opening_cache_dir },
+ };
+
+ defer subdir.close();
+
+ this.file_count = FileCopier.copy(subdir, &walker_, this.progress) catch |err| return Result{
+ .fail = .{ .err = err, .step = .copying_files },
+ };
+
+ return Result{
+ .success = void{},
+ };
+ }
+
+ fn installWithHardlink(this: *PackageInstall) !Result {
+ const Walker = @import("../walker_skippable.zig");
+
+ var cached_package_dir = this.cache_dir.openDirZ(this.cache_dir_subpath, .{
+ .iterate = true,
+ }) catch |err| return Result{
+ .fail = .{ .err = err, .step = .opening_cache_dir },
+ };
+ defer cached_package_dir.close();
+ var walker_ = Walker.walk(
+ cached_package_dir,
+ this.allocator,
+ &[_]string{},
+ &[_]string{},
+ ) catch |err| return Result{
+ .fail = .{ .err = err, .step = .opening_cache_dir },
+ };
+ defer walker_.deinit();
+
+ const FileCopier = struct {
+ pub fn copy(
+ destination_dir_: std.fs.Dir,
+ walker: *Walker,
+ ) !u32 {
+ var real_file_count: u32 = 0;
+ while (try walker.next()) |entry| {
+ switch (entry.kind) {
+ .Directory => std.os.mkdirat(destination_dir_.fd, entry.path, 0o755) catch {},
+ .File => {
+ try std.os.linkat(entry.dir.fd, entry.basename, destination_dir_.fd, entry.path, 0);
+ real_file_count += 1;
+ },
+ else => {},
+ }
+ }
+
+ return real_file_count;
+ }
+ };
+
+ var subdir = this.destination_dir.makeOpenPath(std.mem.span(this.destination_dir_subpath), .{ .iterate = true }) catch |err| return Result{
+ .fail = .{ .err = err, .step = .opening_cache_dir },
+ };
+
+ defer subdir.close();
+
+ this.file_count = FileCopier.copy(
+ subdir,
+ &walker_,
+ ) catch |err| return Result{
+ .fail = .{ .err = err, .step = .copying_files },
+ };
+
+ return Result{
+ .success = void{},
+ };
+ }
+
+ pub fn install(this: *PackageInstall, skip_delete: bool) Result {
+
+ // If this fails, we don't care.
+ // we'll catch it the next error
+ if (!skip_delete) this.destination_dir.deleteTree(std.mem.span(this.destination_dir_subpath)) catch {};
+
+ switch (supported_method) {
+ .clonefile => {
+ if (comptime Environment.isMac) {
+ // First, attempt to use clonefile
+ // if that fails due to ENOTSUP, mark it as unsupported and then fall back to copyfile
+ if (this.installWithClonefile()) |result| {
+ return result;
+ } else |err| {
+ switch (err) {
+ error.NotSupported => {
+ supported_method = .copyfile;
+ },
+ error.FileNotFound => return Result{
+ .fail = .{ .err = error.FileNotFound, .step = .opening_cache_dir },
+ },
+ else => return Result{
+ .fail = .{ .err = err, .step = .copying_files },
+ },
+ }
+ }
+ }
+ },
+ .clonefile_each_dir => {
+ if (comptime Environment.isMac) {
+ if (this.installWithClonefileEachDir()) |result| {
+ return result;
+ } else |err| {
+ switch (err) {
+ error.NotSupported => {
+ supported_method = .copyfile;
+ },
+ error.FileNotFound => return Result{
+ .fail = .{ .err = error.FileNotFound, .step = .opening_cache_dir },
+ },
+ else => return Result{
+ .fail = .{ .err = err, .step = .copying_files },
+ },
+ }
+ }
+ }
+ },
+ .hardlink => {
+ if (this.installWithHardlink()) |result| {
+ return result;
+ } else |err| {
+ switch (err) {
+ error.NotSupported => {
+ supported_method = .copyfile;
+ },
+ error.FileNotFound => return Result{
+ .fail = .{ .err = error.FileNotFound, .step = .opening_cache_dir },
+ },
+ else => return Result{
+ .fail = .{ .err = err, .step = .copying_files },
+ },
+ }
+ }
+ },
+ else => {},
+ }
+
+ if (supported_method != .copyfile) return Result{
+ .success = void{},
+ };
+
+ // TODO: linux io_uring
+ return this.installWithCopyfile();
+ }
+};
+
+const Resolution = @import("./resolution.zig").Resolution;
+const Progress = std.Progress;
+const TaggedPointer = @import("../tagged_pointer.zig");
+const TaskCallbackContext = union(Tag) {
+ dependency: PackageID,
+ request_id: PackageID,
+ node_modules_folder: u32, // Really, this is a file descriptor
+ pub const Tag = enum {
+ dependency,
+ request_id,
+ node_modules_folder,
+ };
+};
+
+const TaskCallbackList = std.ArrayListUnmanaged(TaskCallbackContext);
+const TaskDependencyQueue = std.HashMapUnmanaged(u64, TaskCallbackList, IdentityContext(u64), 80);
+const TaskChannel = sync.Channel(Task, .{ .Static = 4096 });
+const NetworkChannel = sync.Channel(*NetworkTask, .{ .Static = 8192 });
+const ThreadPool = @import("thread_pool");
+const PackageManifestMap = std.HashMapUnmanaged(PackageNameHash, Npm.PackageManifest, IdentityContext(PackageNameHash), 80);
+
+pub const CacheLevel = struct {
+ use_cache_control_headers: bool,
+ use_etag: bool,
+ use_last_modified: bool,
+};
+
+// We can't know all the package s we need until we've downloaded all the packages
+// The easy way wouild be:
+// 1. Download all packages, parsing their dependencies and enqueuing all dependnecies for resolution
+// 2.
+pub const PackageManager = struct {
+ cache_directory_path: string = "",
+ cache_directory: std.fs.Dir = undefined,
+ root_dir: *Fs.FileSystem.DirEntry,
+ env_loader: *DotEnv.Loader,
+ allocator: *std.mem.Allocator,
+ log: *logger.Log,
+ resolve_tasks: TaskChannel,
+ timestamp: u32 = 0,
+ extracted_count: u32 = 0,
+ default_features: Features = Features{},
+ summary: Lockfile.Package.Diff.Summary = Lockfile.Package.Diff.Summary{},
+ env: *DotEnv.Loader,
+ progress: Progress = .{},
+ downloads_node: ?*Progress.Node = null,
+ progress_name_buf: [768]u8 = undefined,
+ progress_name_buf_dynamic: []u8 = &[_]u8{},
+ cpu_count: u32 = 0,
+ package_json_updates: []UpdateRequest = &[_]UpdateRequest{},
+
+ to_remove: []const UpdateRequest = &[_]UpdateRequest{},
+
+ root_package_json_file: std.fs.File,
+ root_dependency_list: Lockfile.DependencySlice = .{},
+
+ registry: Npm.Registry = Npm.Registry{},
+
+ thread_pool: ThreadPool,
+
+ manifests: PackageManifestMap = PackageManifestMap{},
+ resolved_package_index: PackageIndex = PackageIndex{},
+
+ task_queue: TaskDependencyQueue = .{},
+ network_dedupe_map: NetworkTaskQueue = .{},
+ network_channel: NetworkChannel = NetworkChannel.init(),
+ network_tarball_batch: ThreadPool.Batch = ThreadPool.Batch{},
+ network_resolve_batch: ThreadPool.Batch = ThreadPool.Batch{},
+ network_task_fifo: NetworkQueue = undefined,
+ preallocated_network_tasks: PreallocatedNetworkTasks = PreallocatedNetworkTasks{ .buffer = undefined, .len = 0 },
+ pending_tasks: u32 = 0,
+ total_tasks: u32 = 0,
+
+ lockfile: *Lockfile = undefined,
+
+ options: Options = Options{},
+
+ const PreallocatedNetworkTasks = std.BoundedArray(NetworkTask, 1024);
+ const NetworkTaskQueue = std.HashMapUnmanaged(u64, void, IdentityContext(u64), 80);
+ const PackageIndex = std.AutoHashMapUnmanaged(u64, *Package);
+ pub var verbose_install = false;
+
+ const PackageDedupeList = std.HashMapUnmanaged(
+ u32,
+ void,
+ IdentityContext(u32),
+ 80,
+ );
+
+ pub fn setNodeName(
+ this: *PackageManager,
+ node: *Progress.Node,
+ name: string,
+ emoji: string,
+ comptime is_first: bool,
+ ) void {
+ if (Output.isEmojiEnabled()) {
+ if (is_first) {
+ std.mem.copy(u8, &this.progress_name_buf, emoji);
+ std.mem.copy(u8, this.progress_name_buf[emoji.len..], name);
+ node.name = this.progress_name_buf[0 .. emoji.len + name.len];
+ } else {
+ std.mem.copy(u8, this.progress_name_buf[emoji.len..], name);
+ node.name = this.progress_name_buf[0 .. emoji.len + name.len];
+ }
+ } else {
+ std.mem.copy(u8, &this.progress_name_buf, name);
+ node.name = this.progress_name_buf[0..name.len];
+ }
+ }
+
+ var cached_package_folder_name_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
+
+ pub var instance: PackageManager = undefined;
+
+ pub fn getNetworkTask(this: *PackageManager) *NetworkTask {
+ if (this.preallocated_network_tasks.len + 1 < this.preallocated_network_tasks.buffer.len) {
+ const len = this.preallocated_network_tasks.len;
+ this.preallocated_network_tasks.len += 1;
+ return &this.preallocated_network_tasks.buffer[len];
+ }
+
+ return this.allocator.create(NetworkTask) catch @panic("Memory allocation failure creating NetworkTask!");
+ }
+
+ // TODO: normalize to alphanumeric
+ pub fn cachedNPMPackageFolderName(name: string, version: Semver.Version) stringZ {
+ return cachedNPMPackageFolderNamePrint(&cached_package_folder_name_buf, name, version);
+ }
+
+ // TODO: normalize to alphanumeric
+ pub fn cachedNPMPackageFolderNamePrint(buf: []u8, name: string, version: Semver.Version) stringZ {
+ if (!version.tag.hasPre() and !version.tag.hasBuild()) {
+ return std.fmt.bufPrintZ(buf, "{s}@{d}.{d}.{d}", .{ name, version.major, version.minor, version.patch }) catch unreachable;
+ } else if (version.tag.hasPre() and version.tag.hasBuild()) {
+ return std.fmt.bufPrintZ(
+ buf,
+ "{s}@{d}.{d}.{d}-{x}+{X}",
+ .{ name, version.major, version.minor, version.patch, version.tag.pre.hash, version.tag.build.hash },
+ ) catch unreachable;
+ } else if (version.tag.hasPre()) {
+ return std.fmt.bufPrintZ(
+ buf,
+ "{s}@{d}.{d}.{d}-{x}",
+ .{ name, version.major, version.minor, version.patch, version.tag.pre.hash },
+ ) catch unreachable;
+ } else if (version.tag.hasBuild()) {
+ return std.fmt.bufPrintZ(
+ buf,
+ "{s}@{d}.{d}.{d}+{X}",
+ .{ name, version.major, version.minor, version.patch, version.tag.build.hash },
+ ) catch unreachable;
+ } else {
+ unreachable;
+ }
+
+ unreachable;
+ }
+
+ pub fn isFolderInCache(this: *PackageManager, folder_path: stringZ) bool {
+ // TODO: is this slow?
+ var dir = this.cache_directory.openDirZ(folder_path, .{ .iterate = true }) catch return false;
+ dir.close();
+ return true;
+ }
+
+ const ResolvedPackageResult = struct {
+ package: Lockfile.Package,
+
+ /// Is this the first time we've seen this package?
+ is_first_time: bool = false,
+
+ /// Pending network task to schedule
+ network_task: ?*NetworkTask = null,
+ };
+
+ pub fn getOrPutResolvedPackageWithFindResult(
+ this: *PackageManager,
+ name_hash: PackageNameHash,
+ name: String,
+ version: Dependency.Version,
+ dependency_id: PackageID,
+ behavior: Behavior,
+ manifest: *const Npm.PackageManifest,
+ find_result: Npm.PackageManifest.FindResult,
+ ) !?ResolvedPackageResult {
+
+ // Was this package already allocated? Let's reuse the existing one.
+ if (this.lockfile.getPackageID(
+ name_hash,
+ if (behavior.isPeer()) version else null,
+ .{
+ .tag = .npm,
+ .value = .{ .npm = find_result.version },
+ },
+ )) |id| {
+ this.lockfile.buffers.resolutions.items[dependency_id] = id;
+ return ResolvedPackageResult{
+ .package = this.lockfile.packages.get(id),
+ .is_first_time = false,
+ };
+ }
+
+ var package =
+ try Lockfile.Package.fromNPM(
+ this.allocator,
+ this.lockfile,
+ this.log,
+ manifest,
+ find_result.version,
+ find_result.package,
+ manifest.string_buf,
+ Features.npm,
+ );
+
+ if (!behavior.isEnabled(this.options.omit.toFeatures())) {
+ package.meta.preinstall_state = .done;
+ }
+
+ const preinstall = package.determinePreinstallState(this.lockfile, this);
+
+ // appendPackage sets the PackageID on the package
+ package = try this.lockfile.appendPackage(package);
+ this.lockfile.buffers.resolutions.items[dependency_id] = package.meta.id;
+ if (comptime Environment.isDebug or Environment.isTest) std.debug.assert(package.meta.id != invalid_package_id);
+
+ switch (preinstall) {
+ // Is this package already in the cache?
+ // We don't need to download the tarball, but we should enqueue dependencies
+ .done => {
+ return ResolvedPackageResult{ .package = package, .is_first_time = true };
+ },
+
+ // Do we need to download the tarball?
+ .extract => {
+ const task_id = Task.Id.forNPMPackage(
+ Task.Tag.extract,
+ name.slice(this.lockfile.buffers.string_bytes.items),
+ package.resolution.value.npm,
+ );
+
+ var network_task = (try this.generateNetworkTaskForTarball(task_id, package)).?;
+
+ return ResolvedPackageResult{
+ .package = package,
+ .is_first_time = true,
+ .network_task = network_task,
+ };
+ },
+ else => unreachable,
+ }
+
+ return ResolvedPackageResult{ .package = package };
+ }
+
+ pub fn generateNetworkTaskForTarball(this: *PackageManager, task_id: u64, package: Lockfile.Package) !?*NetworkTask {
+ const dedupe_entry = try this.network_dedupe_map.getOrPut(this.allocator, task_id);
+ if (dedupe_entry.found_existing) return null;
+
+ var network_task = this.getNetworkTask();
+
+ network_task.* = NetworkTask{
+ .task_id = task_id,
+ .callback = undefined,
+ .allocator = this.allocator,
+ };
+
+ try network_task.forTarball(
+ this.allocator,
+ ExtractTarball{
+ .name = if (package.name.len() >= strings.StringOrTinyString.Max)
+ strings.StringOrTinyString.init(
+ try FileSystem.FilenameStore.instance.append(
+ @TypeOf(this.lockfile.str(package.name)),
+ this.lockfile.str(package.name),
+ ),
+ )
+ else
+ strings.StringOrTinyString.init(this.lockfile.str(package.name)),
+
+ .resolution = package.resolution,
+ .cache_dir = this.cache_directory_path,
+ .registry = this.registry.url.href,
+ .package_id = package.meta.id,
+ .extracted_file_count = package.meta.file_count,
+ .integrity = package.meta.integrity,
+ },
+ );
+
+ return network_task;
+ }
+
+ pub fn fetchVersionsForPackageName(
+ this: *PackageManager,
+ name: string,
+ version: Dependency.Version,
+ id: PackageID,
+ ) !?Npm.PackageManifest {
+ const task_id = Task.Id.forManifest(Task.Tag.package_manifest, name);
+ var network_entry = try this.network_dedupe_map.getOrPutContext(this.allocator, task_id, .{});
+ var loaded_manifest: ?Npm.PackageManifest = null;
+ if (!network_entry.found_existing) {
+ if (this.options.enable.manifest_cache) {
+ if (this.manifests.get(std.hash.Wyhash.hash(0, name)) orelse (Npm.PackageManifest.Serializer.load(this.allocator, this.cache_directory, name) catch null)) |manifest_| {
+ const manifest: Npm.PackageManifest = manifest_;
+ loaded_manifest = manifest;
+
+ if (this.options.enable.manifest_cache_control and manifest.pkg.public_max_age > this.timestamp) {
+ try this.manifests.put(this.allocator, @truncate(PackageNameHash, manifest.pkg.name.hash), manifest);
+ }
+
+ // If it's an exact package version already living in the cache
+ // We can skip the network request, even if it's beyond the caching period
+ if (version.tag == .npm and version.value.npm.isExact()) {
+ if (loaded_manifest.?.findByVersion(version.value.npm.head.head.range.left.version) != null) {
+ return manifest;
+ }
+ }
+
+ // Was it recent enough to just load it without the network call?
+ if (this.options.enable.manifest_cache_control and manifest.pkg.public_max_age > this.timestamp) {
+ return manifest;
+ }
+ }
+ }
+
+ if (PackageManager.verbose_install) {
+ Output.prettyErrorln("Enqueue package manifest for download: {s}", .{name});
+ }
+
+ var network_task = this.getNetworkTask();
+ network_task.* = NetworkTask{
+ .callback = undefined,
+ .task_id = task_id,
+ .allocator = this.allocator,
+ };
+ try network_task.forManifest(name, this.allocator, this.registry.url, loaded_manifest);
+ this.enqueueNetworkTask(network_task);
+ }
+
+ var manifest_entry_parse = try this.task_queue.getOrPutContext(this.allocator, task_id, .{});
+ if (!manifest_entry_parse.found_existing) {
+ manifest_entry_parse.value_ptr.* = TaskCallbackList{};
+ }
+
+ try manifest_entry_parse.value_ptr.append(this.allocator, TaskCallbackContext{ .request_id = id });
+ return null;
+ }
+
+ fn enqueueNetworkTask(this: *PackageManager, task: *NetworkTask) void {
+ if (this.network_task_fifo.writableLength() == 0) {
+ this.flushNetworkQueue();
+ }
+
+ this.network_task_fifo.writeItemAssumeCapacity(task);
+ }
+
+ pub fn getOrPutResolvedPackage(
+ this: *PackageManager,
+ name_hash: PackageNameHash,
+ name: String,
+ version: Dependency.Version,
+ behavior: Behavior,
+ dependency_id: PackageID,
+ resolution: PackageID,
+ ) !?ResolvedPackageResult {
+ if (resolution < this.lockfile.packages.len) {
+ return ResolvedPackageResult{ .package = this.lockfile.packages.get(resolution) };
+ }
+
+ switch (version.tag) {
+ .npm, .dist_tag => {
+ // Resolve the version from the loaded NPM manifest
+ const manifest = this.manifests.getPtr(name_hash) orelse return null; // manifest might still be downloading. This feels unreliable.
+ const find_result: Npm.PackageManifest.FindResult = switch (version.tag) {
+ .dist_tag => manifest.findByDistTag(this.lockfile.str(version.value.dist_tag)),
+ .npm => manifest.findBestVersion(version.value.npm),
+ else => unreachable,
+ } orelse return switch (version.tag) {
+ .npm => error.NoMatchingVersion,
+ .dist_tag => error.DistTagNotFound,
+ else => unreachable,
+ };
+
+ return try getOrPutResolvedPackageWithFindResult(this, name_hash, name, version, dependency_id, behavior, manifest, find_result);
+ },
+
+ else => return null,
+ }
+ }
+
+ pub fn resolvePackageFromManifest(
+ this: *PackageManager,
+ semver: Semver.Version,
+ version: *const Npm.PackageVersion,
+ manifest: *const Npm.PackageManifest,
+ ) !void {}
+
+ fn enqueueParseNPMPackage(
+ this: *PackageManager,
+ task_id: u64,
+ name: strings.StringOrTinyString,
+ network_task: *NetworkTask,
+ ) *ThreadPool.Task {
+ var task = this.allocator.create(Task) catch unreachable;
+ task.* = Task{
+ .log = logger.Log.init(this.allocator),
+ .tag = Task.Tag.package_manifest,
+ .request = .{
+ .package_manifest = .{
+ .network = network_task,
+ .name = name,
+ },
+ },
+ .id = task_id,
+ .data = undefined,
+ };
+ return &task.threadpool_task;
+ }
+
+ fn enqueueExtractNPMPackage(
+ this: *PackageManager,
+ tarball: ExtractTarball,
+ network_task: *NetworkTask,
+ ) *ThreadPool.Task {
+ var task = this.allocator.create(Task) catch unreachable;
+ task.* = Task{
+ .log = logger.Log.init(this.allocator),
+ .tag = Task.Tag.extract,
+ .request = .{
+ .extract = .{
+ .network = network_task,
+ .tarball = tarball,
+ },
+ },
+ .id = network_task.task_id,
+ .data = undefined,
+ };
+ return &task.threadpool_task;
+ }
+
+ inline fn enqueueDependency(this: *PackageManager, id: u32, dependency: Dependency, resolution: PackageID) !void {
+ return try this.enqueueDependencyWithMain(id, dependency, resolution, false);
+ }
+
+ pub fn writeYarnLock(this: *PackageManager) !void {
+ var printer = Lockfile.Printer{
+ .lockfile = this.lockfile,
+ .options = this.options,
+ };
+
+ var tmpname_buf: [512]u8 = undefined;
+ tmpname_buf[0..8].* = "tmplock-".*;
+ var tmpfile = FileSystem.RealFS.Tmpfile{};
+ var secret: [32]u8 = undefined;
+ std.mem.writeIntNative(u64, secret[0..8], @intCast(u64, std.time.milliTimestamp()));
+ var rng = std.rand.Gimli.init(secret);
+ var base64_bytes: [64]u8 = undefined;
+ rng.random.bytes(&base64_bytes);
+
+ const tmpname__ = std.fmt.bufPrint(tmpname_buf[8..], "{s}", .{std.fmt.fmtSliceHexLower(&base64_bytes)}) catch unreachable;
+ tmpname_buf[tmpname__.len + 8] = 0;
+ const tmpname = tmpname_buf[0 .. tmpname__.len + 8 :0];
+
+ tmpfile.create(&FileSystem.instance.fs, tmpname) catch |err| {
+ Output.prettyErrorln("<r><red>error:<r> failed to create tmpfile: {s}", .{@errorName(err)});
+ Output.flush();
+ Global.crash();
+ };
+
+ var file = tmpfile.file();
+ var file_writer = file.writer();
+ var buffered_writer = std.io.BufferedWriter(std.mem.page_size, @TypeOf(file_writer)){
+ .unbuffered_writer = file_writer,
+ };
+ var writer = buffered_writer.writer();
+ try Lockfile.Printer.Yarn.print(&printer, @TypeOf(writer), writer);
+ try buffered_writer.flush();
+
+ _ = C.fchmod(
+ tmpfile.fd,
+ // chmod 666,
+ 0000040 | 0000004 | 0000002 | 0000400 | 0000200 | 0000020,
+ );
+
+ try tmpfile.promote(tmpname, std.fs.cwd().fd, "yarn.lock");
+ }
+
+ fn enqueueDependencyWithMain(
+ this: *PackageManager,
+ id: u32,
+ dependency: Dependency,
+ resolution: PackageID,
+ comptime is_main: bool,
+ ) !void {
+ const name = dependency.name;
+ const name_hash = dependency.name_hash;
+ const version: Dependency.Version = dependency.version;
+ var loaded_manifest: ?Npm.PackageManifest = null;
+
+ if (comptime !is_main) {
+ // it might really be main
+ if (!(id >= this.root_dependency_list.off and id < this.root_dependency_list.len + this.root_dependency_list.off)) {
+ if (!dependency.behavior.isEnabled(Features.npm))
+ return;
+ }
+ }
+
+ switch (dependency.version.tag) {
+ .npm, .dist_tag => {
+ retry_from_manifests_ptr: while (true) {
+ var resolve_result_ = this.getOrPutResolvedPackage(
+ name_hash,
+ name,
+ version,
+ dependency.behavior,
+ id,
+ resolution,
+ );
+
+ retry_with_new_resolve_result: while (true) {
+ const resolve_result = resolve_result_ catch |err| {
+ switch (err) {
+ error.DistTagNotFound => {
+ if (dependency.behavior.isRequired()) {
+ this.log.addErrorFmt(
+ null,
+ logger.Loc.Empty,
+ this.allocator,
+ "Package \"{s}\" with tag \"{s}\" not found, but package exists",
+ .{
+ this.lockfile.str(name),
+ this.lockfile.str(version.value.dist_tag),
+ },
+ ) catch unreachable;
+ }
+
+ return;
+ },
+ error.NoMatchingVersion => {
+ if (dependency.behavior.isRequired()) {
+ this.log.addErrorFmt(
+ null,
+ logger.Loc.Empty,
+ this.allocator,
+ "No version matching \"{s}\" found for specifier \"{s}\" (but package exists)",
+ .{
+ this.lockfile.str(version.literal),
+ this.lockfile.str(name),
+ },
+ ) catch unreachable;
+ }
+ return;
+ },
+ else => return err,
+ }
+ };
+
+ if (resolve_result) |result| {
+
+ // First time?
+ if (result.is_first_time) {
+ if (PackageManager.verbose_install) {
+ const label: string = this.lockfile.str(version.literal);
+
+ Output.prettyErrorln(" -> \"{s}\": \"{s}\" -> {s}@{}", .{
+ this.lockfile.str(result.package.name),
+ label,
+ this.lockfile.str(result.package.name),
+ result.package.resolution.fmt(this.lockfile.buffers.string_bytes.items),
+ });
+ }
+ // Resolve dependencies first
+ if (result.package.dependencies.len > 0) {
+ try this.lockfile.scratch.dependency_list_queue.writeItem(result.package.dependencies);
+ }
+ }
+
+ if (result.network_task) |network_task| {
+ var meta: *Lockfile.Package.Meta = &this.lockfile.packages.items(.meta)[result.package.meta.id];
+ if (meta.preinstall_state == .extract) {
+ meta.preinstall_state = .extracting;
+ this.enqueueNetworkTask(network_task);
+ }
+ }
+ } else if (!dependency.behavior.isPeer()) {
+ const name_str = this.lockfile.str(name);
+ const task_id = Task.Id.forManifest(Task.Tag.package_manifest, name_str);
+ var network_entry = try this.network_dedupe_map.getOrPutContext(this.allocator, task_id, .{});
+ if (!network_entry.found_existing) {
+ if (this.options.enable.manifest_cache) {
+ if (Npm.PackageManifest.Serializer.load(this.allocator, this.cache_directory, name_str) catch null) |manifest_| {
+ const manifest: Npm.PackageManifest = manifest_;
+ loaded_manifest = manifest;
+
+ if (this.options.enable.manifest_cache_control and manifest.pkg.public_max_age > this.timestamp) {
+ try this.manifests.put(this.allocator, @truncate(PackageNameHash, manifest.pkg.name.hash), manifest);
+ }
+
+ // If it's an exact package version already living in the cache
+ // We can skip the network request, even if it's beyond the caching period
+ if (dependency.version.tag == .npm and dependency.version.value.npm.isExact()) {
+ if (loaded_manifest.?.findByVersion(dependency.version.value.npm.head.head.range.left.version)) |find_result| {
+ if (this.getOrPutResolvedPackageWithFindResult(
+ name_hash,
+ name,
+ version,
+ id,
+ dependency.behavior,
+ &loaded_manifest.?,
+ find_result,
+ ) catch null) |new_resolve_result| {
+ resolve_result_ = new_resolve_result;
+ _ = this.network_dedupe_map.remove(task_id);
+ continue :retry_with_new_resolve_result;
+ }
+ }
+ }
+
+ // Was it recent enough to just load it without the network call?
+ if (this.options.enable.manifest_cache_control and manifest.pkg.public_max_age > this.timestamp) {
+ _ = this.network_dedupe_map.remove(task_id);
+ continue :retry_from_manifests_ptr;
+ }
+ }
+ }
+
+ if (PackageManager.verbose_install) {
+ Output.prettyErrorln("Enqueue package manifest for download: {s}", .{this.lockfile.str(name)});
+ }
+
+ var network_task = this.getNetworkTask();
+ network_task.* = NetworkTask{
+ .callback = undefined,
+ .task_id = task_id,
+ .allocator = this.allocator,
+ };
+ try network_task.forManifest(this.lockfile.str(name), this.allocator, this.registry.url, loaded_manifest);
+ this.enqueueNetworkTask(network_task);
+ }
+
+ var manifest_entry_parse = try this.task_queue.getOrPutContext(this.allocator, task_id, .{});
+ if (!manifest_entry_parse.found_existing) {
+ manifest_entry_parse.value_ptr.* = TaskCallbackList{};
+ }
+
+ try manifest_entry_parse.value_ptr.append(this.allocator, TaskCallbackContext{ .dependency = id });
+ }
+ return;
+ }
+ }
+ return;
+ },
+ else => {},
+ }
+ }
+
+ fn flushNetworkQueue(this: *PackageManager) void {
+ var network = &this.network_task_fifo;
+
+ while (network.readItem()) |network_task| {
+ network_task.schedule(if (network_task.callback == .extract) &this.network_tarball_batch else &this.network_resolve_batch);
+ }
+ }
+
+ fn doFlushDependencyQueue(this: *PackageManager) void {
+ var lockfile = this.lockfile;
+ var dependency_queue = &lockfile.scratch.dependency_list_queue;
+
+ while (dependency_queue.readItem()) |dependencies_list| {
+ var i: u32 = dependencies_list.off;
+ const end = dependencies_list.off + dependencies_list.len;
+ while (i < end) : (i += 1) {
+ this.enqueueDependencyWithMain(
+ i,
+ lockfile.buffers.dependencies.items[i],
+ lockfile.buffers.resolutions.items[i],
+ false,
+ ) catch {};
+ }
+
+ this.flushNetworkQueue();
+ }
+ }
+ pub fn flushDependencyQueue(this: *PackageManager) void {
+ this.flushNetworkQueue();
+ this.doFlushDependencyQueue();
+ this.doFlushDependencyQueue();
+ this.doFlushDependencyQueue();
+ this.flushNetworkQueue();
+ }
+
+ pub fn scheduleNetworkTasks(manager: *PackageManager) usize {
+ const count = manager.network_resolve_batch.len + manager.network_tarball_batch.len;
+
+ manager.pending_tasks += @truncate(u32, count);
+ manager.total_tasks += @truncate(u32, count);
+ manager.network_resolve_batch.push(manager.network_tarball_batch);
+ NetworkThread.global.pool.schedule(manager.network_resolve_batch);
+ manager.network_tarball_batch = .{};
+ manager.network_resolve_batch = .{};
+ return count;
+ }
+
+ pub fn enqueueDependencyList(
+ this: *PackageManager,
+ dependencies_list: Lockfile.DependencySlice,
+ comptime is_main: bool,
+ ) void {
+ this.task_queue.ensureUnusedCapacity(this.allocator, dependencies_list.len) catch unreachable;
+ var lockfile = this.lockfile;
+
+ // Step 1. Go through main dependencies
+ {
+ var i: u32 = dependencies_list.off;
+ const end = dependencies_list.off + dependencies_list.len;
+ // we have to be very careful with pointers here
+ while (i < end) : (i += 1) {
+ this.enqueueDependencyWithMain(
+ i,
+ lockfile.buffers.dependencies.items[i],
+ lockfile.buffers.resolutions.items[i],
+ is_main,
+ ) catch {};
+ }
+ }
+
+ // Step 2. If there were cached dependencies, go through all of those but don't download the devDependencies for them.
+ this.flushDependencyQueue();
+
+ if (PackageManager.verbose_install) Output.flush();
+
+ // It's only network requests here because we don't store tarballs.
+ const count = this.network_resolve_batch.len + this.network_tarball_batch.len;
+ this.pending_tasks += @truncate(u32, count);
+ this.total_tasks += @truncate(u32, count);
+ this.network_resolve_batch.push(this.network_tarball_batch);
+ NetworkThread.global.pool.schedule(this.network_resolve_batch);
+ this.network_tarball_batch = .{};
+ this.network_resolve_batch = .{};
+ }
+
+ pub fn hoist(this: *PackageManager) !void {}
+ pub fn link(this: *PackageManager) !void {}
+
+ pub fn fetchCacheDirectoryPath(
+ allocator: *std.mem.Allocator,
+ env_loader: *DotEnv.Loader,
+ root_dir: *Fs.FileSystem.DirEntry,
+ ) ?string {
+ if (env_loader.map.get("BUN_INSTALL_CACHE_DIR")) |dir| {
+ return dir;
+ }
+
+ if (env_loader.map.get("BUN_INSTALL")) |dir| {
+ var parts = [_]string{ dir, "install/", "cache/" };
+ return Fs.FileSystem.instance.abs(&parts);
+ }
+
+ if (env_loader.map.get("HOME")) |dir| {
+ var parts = [_]string{ dir, ".bun/", "install/", "cache/" };
+ return Fs.FileSystem.instance.abs(&parts);
+ }
+
+ if (env_loader.map.get("XDG_CACHE_HOME")) |dir| {
+ var parts = [_]string{ dir, ".bun/", "install/", "cache/" };
+ return Fs.FileSystem.instance.abs(&parts);
+ }
+
+ if (env_loader.map.get("TMPDIR")) |dir| {
+ var parts = [_]string{ dir, ".bun-cache" };
+ return Fs.FileSystem.instance.abs(&parts);
+ }
+
+ return null;
+ }
+
+ fn runTasks(
+ manager: *PackageManager,
+ comptime ExtractCompletionContext: type,
+ extract_ctx: ExtractCompletionContext,
+ comptime callback_fn: anytype,
+ comptime log_level: Options.LogLevel,
+ ) anyerror!void {
+ var batch = ThreadPool.Batch{};
+ var has_updated_this_run = false;
+ while (manager.network_channel.tryReadItem() catch null) |task_| {
+ var task: *NetworkTask = task_;
+ manager.pending_tasks -= 1;
+
+ switch (task.callback) {
+ .package_manifest => |manifest_req| {
+ const name = manifest_req.name;
+ if (comptime log_level.showProgress()) {
+ if (!has_updated_this_run) {
+ manager.setNodeName(manager.downloads_node.?, name.slice(), ProgressStrings.download_emoji, true);
+ has_updated_this_run = true;
+ }
+ }
+ const response = task.http.response orelse {
+ if (comptime log_level != .silent) {
+ Output.prettyErrorln("Failed to download package manifest for package {s}", .{name});
+ Output.flush();
+ }
+ continue;
+ };
+
+ if (response.status_code > 399) {
+ if (comptime log_level != .silent) {
+ const fmt = "<r><red><b>GET<r><red> {s}<d> - {d}<r>\n";
+ const args = .{
+ task.http.client.url.href,
+ response.status_code,
+ };
+
+ if (comptime log_level.showProgress()) {
+ Output.prettyWithPrinterFn(fmt, args, Progress.log, &manager.progress);
+ } else {
+ Output.prettyErrorln(fmt, args);
+ Output.flush();
+ }
+ }
+ continue;
+ }
+
+ if (comptime log_level.isVerbose()) {
+ Output.prettyError(" ", .{});
+ Output.printElapsed(@floatCast(f64, @intToFloat(f128, task.http.elapsed) / std.time.ns_per_ms));
+ Output.prettyError(" <d>Downloaded <r><green>{s}<r> versions\n", .{name.slice()});
+ Output.flush();
+ }
+
+ if (response.status_code == 304) {
+ // The HTTP request was cached
+ if (manifest_req.loaded_manifest) |manifest| {
+ var entry = try manager.manifests.getOrPut(manager.allocator, manifest.pkg.name.hash);
+ entry.value_ptr.* = manifest;
+ entry.value_ptr.*.pkg.public_max_age = @truncate(u32, @intCast(u64, @maximum(0, std.time.timestamp()))) + 300;
+ {
+ var tmpdir = Fs.FileSystem.instance.tmpdir();
+ Npm.PackageManifest.Serializer.save(entry.value_ptr, tmpdir, PackageManager.instance.cache_directory) catch {};
+ }
+
+ var dependency_list_entry = manager.task_queue.getEntry(task.task_id).?;
+
+ var dependency_list = dependency_list_entry.value_ptr.*;
+ dependency_list_entry.value_ptr.* = .{};
+
+ if (dependency_list.items.len > 0) {
+ for (dependency_list.items) |item| {
+ var dependency = manager.lockfile.buffers.dependencies.items[item.dependency];
+ var resolution = manager.lockfile.buffers.resolutions.items[item.dependency];
+
+ try manager.enqueueDependency(
+ item.dependency,
+ dependency,
+ resolution,
+ );
+ }
+
+ dependency_list.deinit(manager.allocator);
+ }
+
+ manager.flushDependencyQueue();
+ continue;
+ }
+ }
+
+ batch.push(ThreadPool.Batch.from(manager.enqueueParseNPMPackage(task.task_id, name, task)));
+ },
+ .extract => |extract| {
+ const response = task.http.response orelse {
+ const fmt = "Failed to download package tarball for package {s}\n";
+ const args = .{extract.name};
+
+ if (comptime log_level != .silent) {
+ if (comptime log_level.showProgress()) {
+ Output.prettyWithPrinterFn(fmt, args, Progress.log, &manager.progress);
+ } else {
+ Output.prettyErrorln(fmt, args);
+ Output.flush();
+ }
+ }
+ continue;
+ };
+
+ if (response.status_code > 399) {
+ if (comptime log_level != .silent) {
+ const fmt = "<r><red><b>GET<r><red> {s}<d> - {d}<r>\n";
+ const args = .{
+ task.http.client.url.href,
+ response.status_code,
+ };
+
+ if (comptime log_level.showProgress()) {
+ Output.prettyWithPrinterFn(fmt, args, Progress.log, &manager.progress);
+ } else {
+ Output.prettyErrorln(
+ fmt,
+ args,
+ );
+ Output.flush();
+ }
+ }
+ continue;
+ }
+
+ if (comptime log_level.isVerbose()) {
+ Output.prettyError(" ", .{});
+ Output.printElapsed(@floatCast(f64, @intToFloat(f128, task.http.elapsed) / std.time.ns_per_ms));
+ Output.prettyError(" <d>Downloaded <r><green>{s}<r> tarball\n", .{extract.name.slice()});
+ Output.flush();
+ }
+
+ if (comptime log_level.showProgress()) {
+ if (!has_updated_this_run) {
+ manager.setNodeName(manager.downloads_node.?, extract.name.slice(), ProgressStrings.extract_emoji, true);
+ has_updated_this_run = true;
+ }
+ }
+
+ batch.push(ThreadPool.Batch.from(manager.enqueueExtractNPMPackage(extract, task)));
+ },
+ .binlink => {},
+ }
+ }
+
+ while (manager.resolve_tasks.tryReadItem() catch null) |task_| {
+ manager.pending_tasks -= 1;
+
+ var task: Task = task_;
+ if (task.log.msgs.items.len > 0) {
+ if (Output.enable_ansi_colors) {
+ try task.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), true);
+ } else {
+ try task.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), false);
+ }
+ }
+
+ switch (task.tag) {
+ .package_manifest => {
+ if (task.status == .fail) {
+ if (comptime log_level != .silent) {
+ Output.prettyErrorln("Failed to parse package manifest for {s}", .{task.request.package_manifest.name.slice()});
+ Output.flush();
+ }
+ continue;
+ }
+ const manifest = task.data.package_manifest;
+ var entry = try manager.manifests.getOrPutValue(manager.allocator, @truncate(PackageNameHash, manifest.pkg.name.hash), manifest);
+
+ var dependency_list_entry = manager.task_queue.getEntry(task.id).?;
+ var dependency_list = dependency_list_entry.value_ptr.*;
+ dependency_list_entry.value_ptr.* = .{};
+
+ if (dependency_list.items.len > 0) {
+ for (dependency_list.items) |item| {
+ var dependency = manager.lockfile.buffers.dependencies.items[item.dependency];
+ var resolution = manager.lockfile.buffers.resolutions.items[item.dependency];
+
+ try manager.enqueueDependency(
+ item.dependency,
+ dependency,
+ resolution,
+ );
+ }
+
+ dependency_list.deinit(manager.allocator);
+ }
+
+ if (comptime log_level.showProgress()) {
+ if (!has_updated_this_run) {
+ manager.setNodeName(manager.downloads_node.?, manifest.name(), ProgressStrings.download_emoji, true);
+ has_updated_this_run = true;
+ }
+ }
+ },
+ .extract => {
+ if (task.status == .fail) {
+ Output.prettyErrorln("Failed to extract tarball for {s}", .{
+ task.request.extract.tarball.name,
+ });
+ Output.flush();
+ continue;
+ }
+ const package_id = task.request.extract.tarball.package_id;
+ manager.extracted_count += 1;
+ manager.lockfile.packages.items(.meta)[package_id].preinstall_state = .done;
+
+ if (comptime ExtractCompletionContext != void) {
+ callback_fn(extract_ctx, package_id, comptime log_level);
+ }
+
+ if (comptime log_level.showProgress()) {
+ if (!has_updated_this_run) {
+ manager.setNodeName(manager.downloads_node.?, task.request.extract.tarball.name.slice(), ProgressStrings.extract_emoji, true);
+ has_updated_this_run = true;
+ }
+ }
+ },
+ .binlink => {},
+ }
+ }
+
+ manager.flushDependencyQueue();
+
+ const prev_total = manager.total_tasks;
+ {
+ const count = batch.len + manager.network_resolve_batch.len + manager.network_tarball_batch.len;
+ manager.pending_tasks += @truncate(u32, count);
+ manager.total_tasks += @truncate(u32, count);
+ manager.thread_pool.schedule(batch);
+ manager.network_resolve_batch.push(manager.network_tarball_batch);
+ NetworkThread.global.pool.schedule(manager.network_resolve_batch);
+ manager.network_tarball_batch = .{};
+ manager.network_resolve_batch = .{};
+
+ if (comptime log_level.showProgress()) {
+ if (comptime ExtractCompletionContext == void) {
+ const completed_items = manager.total_tasks - manager.pending_tasks;
+ if (completed_items != manager.downloads_node.?.unprotected_completed_items or has_updated_this_run) {
+ manager.downloads_node.?.setCompletedItems(completed_items);
+ manager.downloads_node.?.setEstimatedTotalItems(manager.total_tasks);
+ }
+ }
+
+ manager.downloads_node.?.activate();
+ manager.progress.maybeRefresh();
+ }
+ }
+ }
+
+ pub const Options = struct {
+ log_level: LogLevel = LogLevel.default,
+
+ lockfile_path: stringZ = Lockfile.default_filename,
+ save_lockfile_path: stringZ = Lockfile.default_filename,
+ scope: Npm.Registry.Scope = .{
+ .name = "",
+ .token = "",
+ .url = URL.parse("https://registry.npmjs.org/"),
+ },
+
+ registries: Npm.Registry.Map = Npm.Registry.Map{},
+ cache_directory: string = "",
+ enable: Enable = .{},
+ do: Do = .{},
+ positionals: []const string = &[_]string{},
+ update: Update = Update{},
+ dry_run: bool = false,
+ omit: CommandLineArguments.Omit = .{},
+
+ allowed_install_scripts: []const PackageNameHash = &default_allowed_install_scripts,
+
+ // The idea here is:
+ // 1. package has a platform-specific binary to install
+ // 2. To prevent downloading & installing incompatible versions, they stick the "real" one in optionalDependencies
+ // 3. The real one we want to link is in another package
+ // 4. Therefore, we remap the "bin" specified in the real package
+ // to the target package which is the one which is:
+ // 1. In optionalDepenencies
+ // 2. Has a platform and/or os specified, which evaluates to not disabled
+ native_bin_link_allowlist: []const PackageNameHash = &default_native_bin_link_allowlist,
+
+ const default_native_bin_link_allowlist = [_]PackageNameHash{
+ String.Builder.stringHash("esbuild"),
+ String.Builder.stringHash("turbo"),
+ };
+
+ const install_scripts_package_count = 5;
+ const default_allowed_install_scripts: [install_scripts_package_count]PackageNameHash = brk: {
+ const names = std.mem.span(@embedFile("install-scripts-allowlist.txt"));
+ var hashes: [install_scripts_package_count]PackageNameHash = undefined;
+ var splitter = std.mem.split(u8, names, "\n");
+ var i: usize = 0;
+ while (splitter.next()) |item| {
+ hashes[i] = String.Builder.stringHash(item);
+ i += 1;
+ }
+ break :brk hashes;
+ };
+
+ pub const LogLevel = enum {
+ default,
+ verbose,
+ silent,
+ default_no_progress,
+ verbose_no_progress,
+
+ pub inline fn isVerbose(this: LogLevel) bool {
+ return return switch (this) {
+ .verbose_no_progress, .verbose => true,
+ else => false,
+ };
+ }
+ pub inline fn showProgress(this: LogLevel) bool {
+ return switch (this) {
+ .default, .verbose => true,
+ else => false,
+ };
+ }
+ };
+
+ pub const Update = struct {
+ development: bool = false,
+ optional: bool = false,
+ };
+
+ pub fn load(
+ this: *Options,
+ allocator: *std.mem.Allocator,
+ log: *logger.Log,
+ env_loader: *DotEnv.Loader,
+ cli_: ?CommandLineArguments,
+ ) !void {
+
+ // technically, npm_config is case in-sensitive
+ // load_registry:
+ {
+ const registry_keys = [_]string{
+ "BUN_CONFIG_REGISTRY",
+ "NPM_CONFIG_REGISTRY",
+ "npm_config_registry",
+ };
+ var did_set = false;
+
+ inline for (registry_keys) |registry_key| {
+ if (!did_set) {
+ if (env_loader.map.get(registry_key)) |registry_| {
+ if (registry_.len > 0 and
+ (strings.startsWith(registry_, "https://") or
+ strings.startsWith(registry_, "http://")))
+ {
+ this.scope.url = URL.parse(registry_);
+ did_set = true;
+ // stage1 bug: break inside inline is broken
+ // break :load_registry;
+ }
+ }
+ }
+ }
+ }
+
+ {
+ const token_keys = [_]string{
+ "BUN_CONFIG_TOKEN",
+ "NPM_CONFIG_token",
+ "npm_config_token",
+ };
+ var did_set = false;
+
+ inline for (token_keys) |registry_key| {
+ if (!did_set) {
+ if (env_loader.map.get(registry_key)) |registry_| {
+ if (registry_.len > 0) {
+ this.scope.token = registry_;
+ did_set = true;
+ // stage1 bug: break inside inline is broken
+ // break :load_registry;
+ }
+ }
+ }
+ }
+ }
+
+ if (cli_) |cli| {
+ if (cli.registry.len > 0 and strings.startsWith(cli.registry, "https://") or
+ strings.startsWith(cli.registry, "http://"))
+ {
+ this.scope.url = URL.parse(cli.registry);
+ }
+
+ if (cli.token.len > 0) {
+ this.scope.token = cli.token;
+ }
+
+ if (cli.lockfile.len > 0) {
+ this.lockfile_path = try allocator.dupeZ(u8, cli.lockfile);
+ }
+ }
+
+ this.save_lockfile_path = this.lockfile_path;
+
+ if (env_loader.map.get("BUN_CONFIG_LOCKFILE_SAVE_PATH")) |save_lockfile_path| {
+ this.save_lockfile_path = try allocator.dupeZ(u8, save_lockfile_path);
+ }
+
+ if (env_loader.map.get("BUN_CONFIG_NO_CLONEFILE") != null) {
+ PackageInstall.supported_method = .copyfile;
+ }
+
+ if (env_loader.map.get("BUN_CONFIG_YARN_LOCKFILE") != null) {
+ this.do.save_yarn_lock = true;
+ }
+
+ if (env_loader.map.get("BUN_CONFIG_LINK_NATIVE_BINS")) |native_packages| {
+ const len = std.mem.count(u8, native_packages, " ");
+ if (len > 0) {
+ var all = try allocator.alloc(PackageNameHash, this.native_bin_link_allowlist.len + len);
+ std.mem.copy(PackageNameHash, all, this.native_bin_link_allowlist);
+ var remain = all[this.native_bin_link_allowlist.len..];
+ var splitter = std.mem.split(u8, native_packages, " ");
+ var i: usize = 0;
+ while (splitter.next()) |name| {
+ remain[i] = String.Builder.stringHash(name);
+ i += 1;
+ }
+ this.native_bin_link_allowlist = all;
+ }
+ }
+
+ // if (env_loader.map.get("BUN_CONFIG_NO_DEDUPLICATE") != null) {
+ // this.enable.deduplicate_packages = false;
+ // }
+
+ this.do.save_lockfile = strings.eqlComptime((env_loader.map.get("BUN_CONFIG_SKIP_SAVE_LOCKFILE") orelse "0"), "0");
+ this.do.load_lockfile = strings.eqlComptime((env_loader.map.get("BUN_CONFIG_SKIP_LOAD_LOCKFILE") orelse "0"), "0");
+ this.do.install_packages = strings.eqlComptime((env_loader.map.get("BUN_CONFIG_SKIP_INSTALL_PACKAGES") orelse "0"), "0");
+
+ if (cli_) |cli| {
+ if (cli.no_save) {
+ this.do.save_lockfile = false;
+ }
+
+ if (cli.dry_run) {
+ this.do.install_packages = false;
+ this.dry_run = true;
+ }
+
+ if (cli.no_cache) {
+ this.enable.manifest_cache = false;
+ this.enable.manifest_cache_control = false;
+ }
+
+ // if (cli.no_dedupe) {
+ // this.enable.deduplicate_packages = false;
+ // }
+
+ this.omit.dev = cli.omit.dev or this.omit.dev;
+ this.omit.optional = cli.omit.optional or this.omit.optional;
+ this.omit.peer = cli.omit.peer or this.omit.peer;
+
+ if (cli.verbose) {
+ this.log_level = .verbose;
+ PackageManager.verbose_install = true;
+ } else if (cli.silent) {
+ this.log_level = .silent;
+ PackageManager.verbose_install = false;
+ }
+
+ if (cli.yarn) {
+ this.do.save_yarn_lock = true;
+ }
+
+ if (cli.link_native_bins.len > 0) {
+ var all = try allocator.alloc(PackageNameHash, this.native_bin_link_allowlist.len + cli.link_native_bins.len);
+ std.mem.copy(PackageNameHash, all, this.native_bin_link_allowlist);
+ var remain = all[this.native_bin_link_allowlist.len..];
+ for (cli.link_native_bins) |name, i| {
+ remain[i] = String.Builder.stringHash(name);
+ }
+ this.native_bin_link_allowlist = all;
+ }
+
+ if (cli.backend) |backend| {
+ PackageInstall.supported_method = backend;
+ }
+
+ if (cli.positionals.len > 0) {
+ this.positionals = cli.positionals;
+ }
+
+ if (cli.production) {
+ this.enable.install_dev_dependencies = false;
+ }
+
+ if (cli.force) {
+ this.enable.manifest_cache_control = false;
+ this.enable.force_install = true;
+ }
+
+ this.update.development = cli.development;
+ if (!this.update.development) this.update.optional = cli.optional;
+ }
+ }
+
+ pub const Do = struct {
+ save_lockfile: bool = true,
+ load_lockfile: bool = true,
+ install_packages: bool = true,
+ save_yarn_lock: bool = false,
+ };
+
+ pub const Enable = struct {
+ manifest_cache: bool = true,
+ manifest_cache_control: bool = true,
+ cache: bool = true,
+
+ /// Disabled because it doesn't actually reduce the number of packages we end up installing
+ /// Probably need to be a little smarter
+ deduplicate_packages: bool = false,
+
+ install_dev_dependencies: bool = true,
+ force_install: bool = false,
+ };
+ };
+
+ const ProgressStrings = struct {
+ pub const download_no_emoji_ = "Resolving";
+ const download_no_emoji: string = download_no_emoji_ ++ "\n";
+ const download_with_emoji: string = download_emoji ++ download_no_emoji_;
+ pub const download_emoji: string = " 🔍 ";
+
+ pub const extract_no_emoji_ = "Resolving & extracting";
+ const extract_no_emoji: string = extract_no_emoji_ ++ "\n";
+ const extract_with_emoji: string = extract_emoji ++ extract_no_emoji_;
+ pub const extract_emoji: string = " 🚚 ";
+
+ pub const install_no_emoji_ = "Installing";
+ const install_no_emoji: string = install_no_emoji_ ++ "\n";
+ const install_with_emoji: string = install_emoji ++ install_no_emoji_;
+ pub const install_emoji: string = " 📦 ";
+
+ pub const save_no_emoji_ = "Saving lockfile";
+ const save_no_emoji: string = save_no_emoji_;
+ const save_with_emoji: string = save_emoji ++ save_no_emoji_;
+ pub const save_emoji: string = " 🔒 ";
+
+ pub inline fn download() string {
+ return if (Output.isEmojiEnabled()) download_with_emoji else download_no_emoji;
+ }
+
+ pub inline fn save() string {
+ return if (Output.isEmojiEnabled()) save_with_emoji else save_no_emoji;
+ }
+
+ pub inline fn extract() string {
+ return if (Output.isEmojiEnabled()) extract_with_emoji else extract_no_emoji;
+ }
+
+ pub inline fn install() string {
+ return if (Output.isEmojiEnabled()) install_with_emoji else install_no_emoji;
+ }
+ };
+
+ const PackageJSONEditor = struct {
+ pub fn edit(
+ allocator: *std.mem.Allocator,
+ updates: []UpdateRequest,
+ current_package_json: *JSAst.Expr,
+ dependency_list: string,
+ ) !void {
+ const G = JSAst.G;
+
+ var remaining: usize = updates.len;
+
+ // There are three possible scenarios here
+ // 1. There is no "dependencies" (or equivalent list) or it is empty
+ // 2. There is a "dependencies" (or equivalent list), but the package name already exists in a separate list
+ // 3. There is a "dependencies" (or equivalent list), and the package name exists in multiple lists
+ ast_modifier: {
+ // Try to use the existing spot in the dependencies list if possible
+ for (updates) |update, i| {
+ outer: for (dependency_lists_to_check) |list| {
+ if (current_package_json.asProperty(list)) |query| {
+ if (query.expr.data == .e_object) {
+ if (query.expr.asProperty(update.name)) |value| {
+ if (value.expr.data == .e_string) {
+ updates[i].e_string = value.expr.data.e_string;
+ remaining -= 1;
+ }
+ break :outer;
+ }
+ }
+ }
+ }
+ }
+
+ if (remaining == 0)
+ break :ast_modifier;
+
+ var dependencies: []G.Property = &[_]G.Property{};
+ if (current_package_json.asProperty(dependency_list)) |query| {
+ if (query.expr.data == .e_object) {
+ dependencies = query.expr.data.e_object.properties;
+ }
+ }
+
+ var new_dependencies = try allocator.alloc(G.Property, dependencies.len + remaining);
+ std.mem.copy(G.Property, new_dependencies, dependencies);
+ std.mem.set(G.Property, new_dependencies[dependencies.len..], G.Property{});
+
+ outer: for (updates) |update, j| {
+ if (update.e_string != null) continue;
+
+ var k: usize = 0;
+
+ while (k < new_dependencies.len) : (k += 1) {
+ if (new_dependencies[k].key == null) {
+ new_dependencies[k].key = JSAst.Expr.init(
+ JSAst.E.String,
+ JSAst.E.String{
+ .utf8 = update.name,
+ },
+ logger.Loc.Empty,
+ );
+
+ new_dependencies[k].value = JSAst.Expr.init(
+ JSAst.E.String,
+ JSAst.E.String{
+ // we set it later
+ .utf8 = "",
+ },
+ logger.Loc.Empty,
+ );
+ updates[j].e_string = new_dependencies[k].value.?.data.e_string;
+ continue :outer;
+ }
+
+ // This actually is a duplicate
+ // like "react" appearing in both "dependencies" and "optionalDependencies"
+ // For this case, we'll just swap remove it
+ if (new_dependencies[k].key.?.data.e_string.eql(string, update.name)) {
+ if (new_dependencies.len > 1) {
+ new_dependencies[k] = new_dependencies[new_dependencies.len - 1];
+ new_dependencies = new_dependencies[0 .. new_dependencies.len - 1];
+ } else {
+ new_dependencies = &[_]G.Property{};
+ }
+ }
+ }
+ }
+
+ var needs_new_dependency_list = true;
+ var dependencies_object: JSAst.Expr = undefined;
+ if (current_package_json.asProperty(dependency_list)) |query| {
+ if (query.expr.data == .e_object) {
+ needs_new_dependency_list = false;
+
+ dependencies_object = query.expr;
+ }
+ }
+
+ if (needs_new_dependency_list) {
+ dependencies_object = JSAst.Expr.init(
+ JSAst.E.Object,
+ JSAst.E.Object{
+ .properties = new_dependencies,
+ },
+ logger.Loc.Empty,
+ );
+ }
+
+ if (current_package_json.data != .e_object or current_package_json.data.e_object.properties.len == 0) {
+ var root_properties = try allocator.alloc(JSAst.G.Property, 1);
+ root_properties[0] = JSAst.G.Property{
+ .key = JSAst.Expr.init(
+ JSAst.E.String,
+ JSAst.E.String{
+ .utf8 = dependency_list,
+ },
+ logger.Loc.Empty,
+ ),
+ .value = dependencies_object,
+ };
+ current_package_json.* = JSAst.Expr.init(JSAst.E.Object, JSAst.E.Object{ .properties = root_properties }, logger.Loc.Empty);
+ } else if (needs_new_dependency_list) {
+ var root_properties = try allocator.alloc(JSAst.G.Property, current_package_json.data.e_object.properties.len + 1);
+ std.mem.copy(JSAst.G.Property, root_properties, current_package_json.data.e_object.properties);
+ root_properties[root_properties.len - 1].key = JSAst.Expr.init(
+ JSAst.E.String,
+ JSAst.E.String{
+ .utf8 = dependency_list,
+ },
+ logger.Loc.Empty,
+ );
+ root_properties[root_properties.len - 1].value = dependencies_object;
+ current_package_json.* = JSAst.Expr.init(JSAst.E.Object, JSAst.E.Object{ .properties = root_properties }, logger.Loc.Empty);
+ }
+
+ dependencies_object.data.e_object.properties = new_dependencies;
+ dependencies_object.data.e_object.packageJSONSort();
+ }
+
+ for (updates) |*update, j| {
+ var str = update.e_string.?;
+
+ if (update.version.tag == .uninitialized) {
+ str.utf8 = latest;
+ } else {
+ str.utf8 = update.version.literal.slice(update.version_buf);
+ }
+ }
+ }
+ };
+
+ fn init(
+ ctx: Command.Context,
+ package_json_file_: ?std.fs.File,
+ comptime params: []const ParamType,
+ ) !*PackageManager {
+ // assume that spawning a thread will take a lil so we do that asap
+ try NetworkThread.init();
+
+ var cli = try CommandLineArguments.parse(ctx.allocator, params);
+
+ var fs = try Fs.FileSystem.init1(ctx.allocator, null);
+ var original_cwd = std.mem.trimRight(u8, fs.top_level_dir, "/");
+
+ std.mem.copy(u8, &cwd_buf, original_cwd);
+
+ // Step 1. Find the nearest package.json directory
+ //
+ // We will walk up from the cwd, calling chdir on each directory until we find a package.json
+ // If we fail to find one, we will report an error saying no packages to install
+ var package_json_file: std.fs.File = undefined;
+
+ if (package_json_file_) |file| {
+ package_json_file = file;
+ } else {
+ // can't use orelse due to a stage1 bug
+ package_json_file = std.fs.cwd().openFileZ("package.json", .{ .read = true, .write = true }) catch |err2| brk: {
+ var this_cwd = original_cwd;
+ outer: while (std.fs.path.dirname(this_cwd)) |parent| {
+ cwd_buf[parent.len] = 0;
+ var chdir = cwd_buf[0..parent.len :0];
+
+ std.os.chdirZ(chdir) catch |err| {
+ Output.prettyErrorln("Error {s} while chdir - {s}", .{ @errorName(err), std.mem.span(chdir) });
+ Output.flush();
+ return err;
+ };
+
+ break :brk std.fs.cwd().openFileZ("package.json", .{ .read = true, .write = true }) catch |err| {
+ this_cwd = parent;
+ continue :outer;
+ };
+ }
+
+ std.mem.copy(u8, &cwd_buf, original_cwd);
+ cwd_buf[original_cwd.len] = 0;
+ var real_cwd: [:0]u8 = cwd_buf[0..original_cwd.len :0];
+ std.os.chdirZ(real_cwd) catch {};
+
+ return error.MissingPackageJSON;
+ };
+ }
+
+ fs.top_level_dir = try std.os.getcwd(&cwd_buf);
+ cwd_buf[fs.top_level_dir.len] = '/';
+ cwd_buf[fs.top_level_dir.len + 1] = 0;
+ fs.top_level_dir = cwd_buf[0 .. fs.top_level_dir.len + 1];
+ std.mem.copy(u8, &package_json_cwd_buf, fs.top_level_dir);
+ std.mem.copy(u8, package_json_cwd_buf[fs.top_level_dir.len..], "package.json");
+
+ var entries_option = try fs.fs.readDirectory(fs.top_level_dir, null);
+ var options = Options{};
+ var cache_directory: std.fs.Dir = undefined;
+
+ var env_loader: *DotEnv.Loader = brk: {
+ var map = try ctx.allocator.create(DotEnv.Map);
+ map.* = DotEnv.Map.init(ctx.allocator);
+
+ var loader = try ctx.allocator.create(DotEnv.Loader);
+ loader.* = DotEnv.Loader.init(map, ctx.allocator);
+ break :brk loader;
+ };
+
+ env_loader.loadProcess();
+ try env_loader.load(&fs.fs, &entries_option.entries, false);
+
+ if (env_loader.map.get("BUN_INSTALL_VERBOSE") != null) {
+ PackageManager.verbose_install = true;
+ }
+
+ if (PackageManager.fetchCacheDirectoryPath(ctx.allocator, env_loader, &entries_option.entries)) |cache_dir_path| {
+ options.cache_directory = try fs.dirname_store.append(@TypeOf(cache_dir_path), cache_dir_path);
+ cache_directory = std.fs.cwd().makeOpenPath(options.cache_directory, .{ .iterate = true }) catch |err| brk: {
+ options.enable.cache = false;
+ options.enable.manifest_cache = false;
+ options.enable.manifest_cache_control = false;
+ Output.prettyErrorln("Cache is disabled due to error: {s}", .{@errorName(err)});
+ break :brk undefined;
+ };
+ } else {}
+
+ if (PackageManager.verbose_install) {
+ Output.prettyErrorln("Cache Dir: {s}", .{options.cache_directory});
+ Output.flush();
+ }
+
+ var cpu_count = @truncate(u32, ((try std.Thread.getCpuCount()) + 1));
+
+ if (env_loader.map.get("GOMAXPROCS")) |max_procs| {
+ if (std.fmt.parseInt(u32, max_procs, 10)) |cpu_count_| {
+ cpu_count = @minimum(cpu_count, cpu_count_);
+ } else |err| {}
+ }
+
+ var manager = &instance;
+ // var progress = Progress{};
+ // var node = progress.start(name: []const u8, estimated_total_items: usize)
+ manager.* = PackageManager{
+ .options = options,
+ .network_task_fifo = NetworkQueue.init(),
+ .cache_directory = cache_directory,
+ .env_loader = env_loader,
+ .allocator = ctx.allocator,
+ .log = ctx.log,
+ .root_dir = &entries_option.entries,
+ .env = env_loader,
+ .cpu_count = cpu_count,
+ .thread_pool = ThreadPool.init(.{
+ .max_threads = cpu_count,
+ }),
+ .resolve_tasks = TaskChannel.init(),
+ .lockfile = undefined,
+ .root_package_json_file = package_json_file,
+ // .progress
+ };
+ manager.lockfile = try ctx.allocator.create(Lockfile);
+
+ if (!manager.options.enable.cache) {
+ manager.options.enable.manifest_cache = false;
+ manager.options.enable.manifest_cache_control = false;
+ }
+
+ if (env_loader.map.get("BUN_MANIFEST_CACHE")) |manifest_cache| {
+ if (strings.eqlComptime(manifest_cache, "1")) {
+ manager.options.enable.manifest_cache = true;
+ manager.options.enable.manifest_cache_control = false;
+ } else if (strings.eqlComptime(manifest_cache, "2")) {
+ manager.options.enable.manifest_cache = true;
+ manager.options.enable.manifest_cache_control = true;
+ } else {
+ manager.options.enable.manifest_cache = false;
+ manager.options.enable.manifest_cache_control = false;
+ }
+ }
+
+ try manager.options.load(
+ ctx.allocator,
+ ctx.log,
+ env_loader,
+ cli,
+ );
+ manager.registry.url = manager.options.scope.url;
+ manager.registry.scopes = manager.options.registries;
+ manager.registry.token = manager.options.scope.token;
+ manager.registry.auth = manager.options.scope.auth;
+
+ manager.timestamp = @truncate(u32, @intCast(u64, @maximum(std.time.timestamp(), 0)));
+ return manager;
+ }
+
+ pub inline fn add(
+ ctx: Command.Context,
+ ) !void {
+ try updatePackageJSONAndInstall(ctx, .add, &add_params);
+ }
+
+ pub inline fn remove(
+ ctx: Command.Context,
+ ) !void {
+ try updatePackageJSONAndInstall(ctx, .remove, &remove_params);
+ }
+
+ const ParamType = clap.Param(clap.Help);
+ pub const install_params_ = [_]ParamType{
+ clap.parseParam("--registry <STR> Change default registry (default: $BUN_CONFIG_REGISTRY || $npm_config_registry)") catch unreachable,
+ clap.parseParam("--token <STR> Authentication token used for npm registry requests (default: $npm_config_token)") catch unreachable,
+ clap.parseParam("-y, --yarn Write a yarn.lock file (yarn v1)") catch unreachable,
+ clap.parseParam("-p, --production Don't install devDependencies") catch unreachable,
+ clap.parseParam("--no-save Don't save a lockfile") catch unreachable,
+ clap.parseParam("--dry-run Don't install anything") catch unreachable,
+ clap.parseParam("--lockfile <STR> Store & load a lockfile at a specific filepath") catch unreachable,
+ clap.parseParam("-f, --force Always request the latest versions from the registry & reinstall all dependenices") catch unreachable,
+ clap.parseParam("--cache-dir <STR> Store & load cached data from a specific directory path") catch unreachable,
+ clap.parseParam("--no-cache Ignore manifest cache entirely") catch unreachable,
+ clap.parseParam("--silent Don't log anything") catch unreachable,
+ clap.parseParam("--verbose Excessively verbose logging") catch unreachable,
+ clap.parseParam("--cwd <STR> Set a specific cwd") catch unreachable,
+ clap.parseParam("--backend <STR> Platform-specific optimizations for installing dependencies. For macOS, \"clonefile\" (default), \"copyfile\"") catch unreachable,
+ clap.parseParam("--link-native-bins <STR>... Link \"bin\" from a matching platform-specific \"optionalDependencies\" instead. Default: esbuild, turbo") catch unreachable,
+
+ // clap.parseParam("--omit <STR>... Skip installing dependencies of a certain type. \"dev\", \"optional\", or \"peer\"") catch unreachable,
+ // clap.parseParam("--no-dedupe Disable automatic downgrading of dependencies that would otherwise cause unnecessary duplicate package versions ($BUN_CONFIG_NO_DEDUPLICATE)") catch unreachable,
+
+ clap.parseParam("--help Print this help menu") catch unreachable,
+ };
+
+ pub const install_params = install_params_ ++ [_]ParamType{
+ clap.parseParam("<POS> ... ") catch unreachable,
+ };
+
+ pub const add_params = install_params_ ++ [_]ParamType{
+ clap.parseParam("-d, --development Add depenedency to \"devDependencies\"") catch unreachable,
+ clap.parseParam("--optional Add depenedency to \"optionalDependencies\"") catch unreachable,
+ clap.parseParam("<POS> ... \"name\" or \"name@version\" of packages to install") catch unreachable,
+ };
+
+ pub const remove_params = install_params_ ++ [_]ParamType{
+ clap.parseParam("<POS> ... \"name\" of packages to remove from package.json") catch unreachable,
+ };
+
+ const CommandLineArguments = struct {
+ registry: string = "",
+ cache_dir: string = "",
+ lockfile: string = "",
+ token: string = "",
+
+ backend: ?PackageInstall.Method = null,
+
+ positionals: []const string = &[_]string{},
+
+ yarn: bool = false,
+ production: bool = false,
+ no_save: bool = false,
+ dry_run: bool = false,
+ force: bool = false,
+ no_dedupe: bool = false,
+ no_cache: bool = false,
+ silent: bool = false,
+ verbose: bool = false,
+
+ link_native_bins: []const string = &[_]string{},
+
+ development: bool = false,
+ optional: bool = false,
+
+ no_optional: bool = false,
+ omit: Omit = Omit{},
+
+ const Omit = struct {
+ dev: bool = false,
+ optional: bool = false,
+ peer: bool = false,
+
+ pub inline fn toFeatures(this: Omit) Features {
+ return Features{
+ .dev_dependencies = this.dev,
+ .optional_dependencies = this.optional,
+ .peer_dependencies = this.peer,
+ };
+ }
+ };
+
+ pub fn parse(
+ allocator: *std.mem.Allocator,
+ comptime params: []const ParamType,
+ ) !CommandLineArguments {
+ var diag = clap.Diagnostic{};
+
+ var args = clap.parse(clap.Help, params, .{
+ .diagnostic = &diag,
+ .allocator = allocator,
+ }) catch |err| {
+ // Report useful error and exit
+ diag.report(Output.errorWriter(), err) catch {};
+ return err;
+ };
+
+ if (args.flag("--help")) {
+ Output.prettyln("\n<b><magenta>bun<r> (package manager) flags:<r>\n\n", .{});
+ Output.flush();
+
+ clap.help(Output.writer(), params) catch {};
+
+ Output.flush();
+ std.os.exit(0);
+ }
+
+ var cli = CommandLineArguments{};
+ cli.yarn = args.flag("--yarn");
+ cli.production = args.flag("--production");
+ cli.no_save = args.flag("--no-save");
+ cli.dry_run = args.flag("--dry-run");
+ cli.force = args.flag("--force");
+ // cli.no_dedupe = args.flag("--no-dedupe");
+ cli.no_cache = args.flag("--no-cache");
+ cli.silent = args.flag("--silent");
+ cli.verbose = args.flag("--verbose");
+
+ cli.link_native_bins = args.options("--link-native-bins");
+
+ if (comptime params.len == add_params.len) {
+ cli.development = args.flag("--development");
+ cli.optional = args.flag("--optional");
+ }
+
+ // for (args.options("--omit")) |omit| {
+ // if (strings.eqlComptime(omit, "dev")) {
+ // cli.omit.dev = true;
+ // } else if (strings.eqlComptime(omit, "optional")) {
+ // cli.omit.optional = true;
+ // } else if (strings.eqlComptime(omit, "peer")) {
+ // cli.omit.peer = true;
+ // } else {
+ // Output.prettyErrorln("<b>error<r><d>:<r> Invalid argument <b>\"--omit\"<r> must be one of <cyan>\"dev\"<r>, <cyan>\"optional\"<r>, or <cyan>\"peer\"<r>. ", .{});
+ // Output.flush();
+ // std.os.exit(1);
+ // }
+ // }
+
+ if (args.option("--token")) |token| {
+ cli.token = token;
+ }
+
+ if (args.option("--lockfile")) |lockfile| {
+ cli.lockfile = lockfile;
+ }
+
+ if (args.option("--cwd")) |cwd_| {
+ var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
+ var buf2: [std.fs.MAX_PATH_BYTES]u8 = undefined;
+ var final_path: [:0]u8 = undefined;
+ if (cwd_.len > 0 and cwd_[0] == '.') {
+ var cwd = try std.os.getcwd(&buf);
+ var parts = [_]string{cwd_};
+ var path_ = resolve_path.joinAbsStringBuf(cwd, &buf2, &parts, .auto);
+ buf2[path_.len] = 0;
+ final_path = buf2[0..path_.len :0];
+ } else {
+ std.mem.copy(u8, &buf, cwd_);
+ buf[cwd_.len] = 0;
+ final_path = buf[0..cwd_.len :0];
+ }
+ try std.os.chdirZ(final_path);
+ }
+
+ if (args.option("--registry")) |registry_| {
+ cli.registry = registry_;
+ }
+
+ const specified_backend: ?PackageInstall.Method = brk: {
+ if (args.option("--backend")) |backend_| {
+ if (strings.eqlComptime(backend_, "clonefile")) {
+ break :brk PackageInstall.Method.clonefile;
+ } else if (strings.eqlComptime(backend_, "clonefile_each_dir")) {
+ break :brk PackageInstall.Method.clonefile_each_dir;
+ } else if (strings.eqlComptime(backend_, "hardlink")) {
+ break :brk PackageInstall.Method.hardlink;
+ } else if (strings.eqlComptime(backend_, "copyfile")) {
+ break :brk PackageInstall.Method.copyfile;
+ }
+ }
+ break :brk null;
+ };
+
+ if (specified_backend) |backend| {
+ if (backend.isSupported()) {
+ cli.backend = backend;
+ }
+ }
+
+ cli.positionals = args.positionals();
+
+ return cli;
+ }
+ };
+ const latest: string = "latest";
+
+ const UpdateRequest = struct {
+ name: string = "",
+ resolved_version_buf: string = "",
+ version: Dependency.Version = Dependency.Version{},
+ version_buf: []const u8 = "",
+ resolved_version: Resolution = Resolution{},
+ resolution_string_buf: []const u8 = "",
+ missing_version: bool = false,
+ e_string: ?*JSAst.E.String = null,
+ };
+
+ fn updatePackageJSONAndInstall(
+ ctx: Command.Context,
+ comptime op: Lockfile.Package.Diff.Op,
+ comptime params: []const ParamType,
+ ) !void {
+ var manager = PackageManager.init(ctx, null, params) catch |err| brk: {
+ switch (err) {
+ error.MissingPackageJSON => {
+ if (op == .add or op == .update) {
+ var package_json_file = std.fs.cwd().createFileZ("package.json", .{
+ .read = true,
+ }) catch |err2| {
+ Output.prettyErrorln("<r><red>error:<r> {s} create package.json", .{@errorName(err2)});
+ Global.crash();
+ };
+ try package_json_file.pwriteAll("{\"dependencies\": {}}", 0);
+
+ break :brk try PackageManager.init(ctx, package_json_file, params);
+ }
+
+ Output.prettyErrorln("<r>No package.json, so nothing to remove\n", .{});
+ Global.crash();
+ },
+ else => return err,
+ }
+
+ unreachable;
+ };
+
+ if (manager.options.log_level != .silent) {
+ Output.prettyErrorln("<r><b>bun " ++ @tagName(op) ++ " <r><d>v" ++ Global.package_json_version ++ "<r>\n", .{});
+ Output.flush();
+ }
+
+ switch (manager.options.log_level) {
+ .default => try updatePackageJSONAndInstallWithManager(ctx, manager, op, .default),
+ .verbose => try updatePackageJSONAndInstallWithManager(ctx, manager, op, .verbose),
+ .silent => try updatePackageJSONAndInstallWithManager(ctx, manager, op, .silent),
+ .default_no_progress => try updatePackageJSONAndInstallWithManager(ctx, manager, op, .default_no_progress),
+ .verbose_no_progress => try updatePackageJSONAndInstallWithManager(ctx, manager, op, .verbose_no_progress),
+ }
+ }
+
+ const dependency_lists_to_check = [_]string{
+ "dependencies",
+ "devDependencies",
+ "optionalDependencies",
+ "peerDependencies",
+ };
+
+ fn updatePackageJSONAndInstallWithManager(
+ ctx: Command.Context,
+ manager: *PackageManager,
+ comptime op: Lockfile.Package.Diff.Op,
+ comptime log_level: Options.LogLevel,
+ ) !void {
+ var update_requests = try std.BoundedArray(UpdateRequest, 64).init(0);
+ var need_to_get_versions_from_npm = false;
+
+ // first one is always either:
+ // add
+ // remove
+ for (manager.options.positionals[1..]) |positional| {
+ var request = UpdateRequest{
+ .name = positional,
+ };
+ var unscoped_name = positional;
+ if (unscoped_name.len > 0 and unscoped_name[0] == '@') {
+ request.name = unscoped_name[1..];
+ }
+ if (std.mem.indexOfScalar(u8, unscoped_name, '@')) |i| {
+ request.name = unscoped_name[0..i];
+
+ if (unscoped_name.ptr != positional.ptr) {
+ request.name = request.name[0 .. i + 1];
+ }
+
+ if (positional.len > i + 1) request.version_buf = positional[i + 1 ..];
+ }
+
+ if (strings.hasPrefix("http://", request.name) or
+ strings.hasPrefix("https://", request.name))
+ {
+ if (Output.isEmojiEnabled()) {
+ Output.prettyErrorln("<r>😢 <red>error<r><d>:<r> bun {s} http://url is not implemented yet.", .{
+ @tagName(op),
+ });
+ } else {
+ Output.prettyErrorln("<r><red>error<r><d>:<r> bun {s} http://url is not implemented yet.", .{
+ @tagName(op),
+ });
+ }
+ Output.flush();
+
+ std.os.exit(1);
+ }
+
+ request.name = std.mem.trim(u8, request.name, "\n\r\t");
+ if (request.name.len == 0) continue;
+
+ request.version_buf = std.mem.trim(u8, request.version_buf, "\n\r\t");
+
+ // https://github.com/npm/npm-package-arg/blob/fbaf2fd0b72a0f38e7c24260fd4504f4724c9466/npa.js#L330
+ if (strings.hasPrefix("https://", request.version_buf) or
+ strings.hasPrefix("http://", request.version_buf))
+ {
+ if (Output.isEmojiEnabled()) {
+ Output.prettyErrorln("<r>😢 <red>error<r><d>:<r> bun {s} http://url is not implemented yet.", .{
+ @tagName(op),
+ });
+ } else {
+ Output.prettyErrorln("<r><red>error<r><d>:<r> bun {s} http://url is not implemented yet.", .{
+ @tagName(op),
+ });
+ }
+ Output.flush();
+
+ std.os.exit(1);
+ }
+
+ if (request.version_buf.len == 0) {
+ need_to_get_versions_from_npm = true;
+ request.missing_version = true;
+ } else {
+ const sliced = SlicedString.init(request.version_buf, request.version_buf);
+ request.version = Dependency.parse(ctx.allocator, request.version_buf, &sliced, ctx.log) orelse Dependency.Version{};
+ }
+
+ update_requests.append(request) catch break;
+ }
+
+ var updates: []UpdateRequest = update_requests.slice();
+
+ if (ctx.log.errors > 0) {
+ if (comptime log_level != .silent) {
+ if (Output.enable_ansi_colors) {
+ ctx.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), true) catch {};
+ } else {
+ ctx.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), false) catch {};
+ }
+ }
+
+ Output.flush();
+ Global.crash();
+ }
+
+ var current_package_json_stat = try manager.root_package_json_file.stat();
+ var current_package_json_buf = try ctx.allocator.alloc(u8, current_package_json_stat.size + 64);
+ const current_package_json_contents_len = try manager.root_package_json_file.preadAll(
+ current_package_json_buf,
+ 0,
+ );
+
+ const package_json_source = logger.Source.initPathString(
+ package_json_cwd_buf[0 .. FileSystem.instance.top_level_dir.len + "package.json".len],
+ current_package_json_buf[0..current_package_json_contents_len],
+ );
+
+ initializeStore();
+ var current_package_json = json_parser.ParseJSON(&package_json_source, ctx.log, manager.allocator) catch |err| {
+ if (Output.enable_ansi_colors) {
+ ctx.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), true) catch {};
+ } else {
+ ctx.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), false) catch {};
+ }
+
+ Output.panic("<r><red>{s}<r> parsing package.json<r>", .{
+ @errorName(err),
+ });
+ };
+
+ if (op == .remove) {
+ if (current_package_json.data != .e_object) {
+ Output.prettyErrorln("<red>error<r><d>:<r> package.json is not an Object {{}}, so there's nothing to remove!", .{});
+ Output.flush();
+ std.os.exit(1);
+ return;
+ } else if (current_package_json.data.e_object.properties.len == 0) {
+ Output.prettyErrorln("<red>error<r><d>:<r> package.json is empty {{}}, so there's nothing to remove!", .{});
+ Output.flush();
+ std.os.exit(1);
+ return;
+ } else if (current_package_json.asProperty("devDependencies") == null and
+ current_package_json.asProperty("dependencies") == null and
+ current_package_json.asProperty("optionalDependencies") == null and
+ current_package_json.asProperty("peerDependencies") == null)
+ {
+ Output.prettyErrorln("<red>error<r><d>:<r> package.json doesn't have dependencies, there's nothing to remove!", .{});
+ Output.flush();
+ std.os.exit(1);
+ return;
+ }
+ }
+
+ var any_changes = false;
+
+ var dependency_list: string = "dependencies";
+ if (manager.options.update.development) {
+ dependency_list = "devDependencies";
+ } else if (manager.options.update.optional) {
+ dependency_list = "optionalDependencies";
+ }
+
+ switch (op) {
+ .remove => {
+ // if we're removing, they don't have to specify where it is installed in the dependencies list
+ // they can even put it multiple times and we will just remove all of them
+ for (updates) |update| {
+ inline for (dependency_lists_to_check) |list| {
+ if (current_package_json.asProperty(list)) |query| {
+ if (query.expr.data == .e_object) {
+ var dependencies = query.expr.data.e_object.properties;
+ var i: usize = 0;
+ var new_len = dependencies.len;
+ while (i < dependencies.len) : (i += 1) {
+ if (dependencies[i].key.?.data == .e_string) {
+ if (dependencies[i].key.?.data.e_string.eql(string, update.name)) {
+ if (new_len > 1) {
+ dependencies[i] = dependencies[new_len - 1];
+ new_len -= 1;
+ } else {
+ new_len = 0;
+ }
+
+ any_changes = true;
+ }
+ }
+ }
+
+ const changed = new_len != dependencies.len;
+ if (changed) {
+ query.expr.data.e_object.properties = query.expr.data.e_object.properties[0..new_len];
+
+ // If the dependencies list is now empty, remove it from the package.json
+ // since we're swapRemove, we have to re-sort it
+ if (query.expr.data.e_object.properties.len == 0) {
+ var arraylist = std.ArrayListUnmanaged(JSAst.G.Property){
+ .items = current_package_json.data.e_object.properties,
+ .capacity = current_package_json.data.e_object.properties.len,
+ };
+ _ = arraylist.swapRemove(query.i);
+ current_package_json.data.e_object.properties = arraylist.items;
+ current_package_json.data.e_object.packageJSONSort();
+ } else {
+ var obj = query.expr.data.e_object;
+ obj.alphabetizeProperties();
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!any_changes) {
+ Output.prettyErrorln("\n<red>error<r><d>:<r> \"<b>{s}<r>\" is not in a package.json file", .{updates[0].name});
+ Output.flush();
+ std.os.exit(1);
+ return;
+ }
+ manager.to_remove = updates;
+ },
+ .add, .update => {
+ try PackageJSONEditor.edit(ctx.allocator, updates, &current_package_json, dependency_list);
+ manager.package_json_updates = updates;
+ },
+ }
+
+ var buffer_writer = try JSPrinter.BufferWriter.init(ctx.allocator);
+ try buffer_writer.buffer.list.ensureTotalCapacity(ctx.allocator, current_package_json_buf.len + 1);
+ var package_json_writer = JSPrinter.BufferPrinter.init(buffer_writer);
+
+ var written = JSPrinter.printJSON(@TypeOf(package_json_writer), package_json_writer, current_package_json, &package_json_source) catch |err| {
+ Output.prettyErrorln("package.json failed to write due to error {s}", .{@errorName(err)});
+ Global.crash();
+ };
+
+ // There are various tradeoffs with how we commit updates when you run `bun add` or `bun remove`
+ // The one we chose here is to effectively pretend a human did:
+ // 1. "bun add react@latest"
+ // 2. open lockfile, find what react resolved to
+ // 3. open package.json
+ // 4. replace "react" : "latest" with "react" : "^16.2.0"
+ // 5. save package.json
+ // The Smarter™ approach is you resolve ahead of time and write to disk once!
+ // But, turns out that's slower in any case where more than one package has to be resolved (most of the time!)
+ // Concurrent network requests are faster than doing one and then waiting until the next batch
+ var new_package_json_source = package_json_writer.ctx.buffer.toOwnedSliceLeaky().ptr[0 .. written + 1];
+
+ try installWithManager(ctx, manager, new_package_json_source, log_level);
+
+ if (op == .update or op == .add) {
+ const source = logger.Source.initPathString("package.json", new_package_json_source);
+ // Now, we _re_ parse our in-memory edited package.json
+ // so we can commit the version we changed from the lockfile
+ current_package_json = json_parser.ParseJSON(&source, ctx.log, manager.allocator) catch |err| {
+ Output.prettyErrorln("<red>error<r><d>:<r> package.json failed to parse due to error {s}", .{@errorName(err)});
+ Output.flush();
+ std.os.exit(1);
+ return;
+ };
+
+ try PackageJSONEditor.edit(ctx.allocator, updates, &current_package_json, dependency_list);
+ var buffer_writer_two = try JSPrinter.BufferWriter.init(ctx.allocator);
+ try buffer_writer_two.buffer.list.ensureTotalCapacity(ctx.allocator, current_package_json_buf.len + 1);
+ var package_json_writer_two = JSPrinter.BufferPrinter.init(buffer_writer_two);
+
+ written = JSPrinter.printJSON(
+ @TypeOf(package_json_writer_two),
+ package_json_writer_two,
+ current_package_json,
+ &source,
+ ) catch |err| {
+ Output.prettyErrorln("package.json failed to write due to error {s}", .{@errorName(err)});
+ Global.crash();
+ };
+
+ new_package_json_source = package_json_writer_two.ctx.buffer.toOwnedSliceLeaky().ptr[0 .. written + 1];
+ }
+
+ if (!manager.options.dry_run) {
+ // Now that we've run the install step
+ // We can save our in-memory package.json to disk
+ try manager.root_package_json_file.pwriteAll(new_package_json_source, 0);
+ std.os.ftruncate(manager.root_package_json_file.handle, written + 1) catch {};
+ manager.root_package_json_file.close();
+
+ if (op == .remove) {
+ var cwd = std.fs.cwd();
+ // This is not exactly correct
+ var node_modules_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
+ std.mem.copy(u8, &node_modules_buf, "node_modules" ++ std.fs.path.sep_str);
+ var offset_buf: []u8 = node_modules_buf["node_modules/".len..];
+ const name_hashes = manager.lockfile.packages.items(.name_hash);
+ for (updates) |update| {
+ // If the package no longer exists in the updated lockfile, delete the directory
+ // This is not thorough.
+ // It does not handle nested dependencies
+ // This is a quick & dirty cleanup intended for when deleting top-level dependencies
+ if (std.mem.indexOfScalar(PackageNameHash, name_hashes, String.Builder.stringHash(update.name)) == null) {
+ std.mem.copy(u8, offset_buf, update.name);
+ cwd.deleteTree(node_modules_buf[0 .. "node_modules/".len + update.name.len]) catch {};
+ }
+ }
+
+ // This is where we clean dangling symlinks
+ // This could be slow if there are a lot of symlinks
+ if (cwd.openDirZ("node_modules/.bin", .{
+ .iterate = true,
+ })) |node_modules_bin_| {
+ var node_modules_bin: std.fs.Dir = node_modules_bin_;
+ var iter: std.fs.Dir.Iterator = node_modules_bin.iterate();
+ iterator: while (iter.next() catch null) |entry| {
+ switch (entry.kind) {
+ std.fs.Dir.Entry.Kind.SymLink => {
+ if (std.fs.path.extension(entry.name).len == 0) {
+ // any symlinks which we are unable to open are assumed to be dangling
+ // note that using access won't work here, because access doesn't resolve symlinks
+ std.mem.copy(u8, &node_modules_buf, entry.name);
+ node_modules_buf[entry.name.len] = 0;
+ var buf: [:0]u8 = node_modules_buf[0..entry.name.len :0];
+ var file = node_modules_bin.openFileZ(buf, .{ .read = true }) catch |err| {
+ node_modules_bin.deleteFileZ(buf) catch {};
+ continue :iterator;
+ };
+
+ file.close();
+ }
+ },
+ else => {},
+ }
+ }
+ } else |_| {}
+ }
+ }
+ }
+
+ var cwd_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
+ var package_json_cwd_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
+
+ pub inline fn install(
+ ctx: Command.Context,
+ ) !void {
+ var manager = try PackageManager.init(ctx, null, &install_params);
+
+ if (manager.options.log_level != .silent) {
+ Output.prettyErrorln("<r><b>bun install <r><d>v" ++ Global.package_json_version ++ "<r>\n", .{});
+ Output.flush();
+ }
+
+ var package_json_contents = manager.root_package_json_file.readToEndAlloc(ctx.allocator, std.math.maxInt(usize)) catch |err| {
+ if (manager.options.log_level != .silent) {
+ Output.prettyErrorln("<r><red>{s} reading package.json<r> :(", .{@errorName(err)});
+ Output.flush();
+ }
+ return;
+ };
+
+ switch (manager.options.log_level) {
+ .default => try installWithManager(ctx, manager, package_json_contents, .default),
+ .verbose => try installWithManager(ctx, manager, package_json_contents, .verbose),
+ .silent => try installWithManager(ctx, manager, package_json_contents, .silent),
+ .default_no_progress => try installWithManager(ctx, manager, package_json_contents, .default_no_progress),
+ .verbose_no_progress => try installWithManager(ctx, manager, package_json_contents, .verbose_no_progress),
+ }
+ }
+
+ const PackageInstaller = struct {
+ manager: *PackageManager,
+ lockfile: *Lockfile,
+ progress: *std.Progress,
+ node_modules_folder: std.fs.Dir,
+ skip_verify: bool,
+ skip_delete: bool,
+ force_install: bool,
+ root_node_modules_folder: std.fs.Dir,
+ summary: *PackageInstall.Summary,
+ options: *const PackageManager.Options,
+ metas: []const Lockfile.Package.Meta,
+ names: []const String,
+ bins: []const Bin,
+ resolutions: []Resolution,
+ node: *Progress.Node,
+ has_created_bin: bool = false,
+ destination_dir_subpath_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined,
+ install_count: usize = 0,
+ successfully_installed: std.DynamicBitSetUnmanaged,
+
+ // For linking native binaries, we only want to link after we've installed the companion dependencies
+ // We don't want to introduce dependent callbacks like that for every single package
+ // Since this will only be a handful, it's fine to just say "run this at the end"
+ platform_binlinks: std.ArrayListUnmanaged(DeferredBinLink) = std.ArrayListUnmanaged(DeferredBinLink){},
+
+ pub const DeferredBinLink = struct {
+ package_id: PackageID,
+ node_modules_folder: std.fs.Dir,
+ };
+
+ /// Install versions of a package which are waiting on a network request
+ pub fn installEnqueuedPackages(
+ this: *PackageInstaller,
+ package_id: PackageID,
+ comptime log_level: Options.LogLevel,
+ ) void {
+ const buf = this.lockfile.buffers.string_bytes.items;
+
+ const name = this.names[package_id].slice(buf);
+ const resolution = this.resolutions[package_id];
+
+ var callbacks = this.manager.task_queue.fetchRemove(Task.Id.forNPMPackage(
+ Task.Tag.extract,
+ name,
+ resolution.value.npm,
+ )).?.value;
+ defer callbacks.deinit(this.manager.allocator);
+
+ const prev_node_modules_folder = this.node_modules_folder;
+ defer this.node_modules_folder = prev_node_modules_folder;
+ for (callbacks.items) |cb| {
+ const node_modules_folder = cb.node_modules_folder;
+ this.node_modules_folder = std.fs.Dir{ .fd = @intCast(std.os.fd_t, node_modules_folder) };
+ this.installPackageWithNameAndResolution(package_id, log_level, name, resolution);
+ }
+ }
+
+ fn installPackageWithNameAndResolution(
+ this: *PackageInstaller,
+ package_id: PackageID,
+ comptime log_level: Options.LogLevel,
+ name: string,
+ resolution: Resolution,
+ ) void {
+ std.mem.copy(u8, &this.destination_dir_subpath_buf, name);
+ this.destination_dir_subpath_buf[name.len] = 0;
+ var destination_dir_subpath: [:0]u8 = this.destination_dir_subpath_buf[0..name.len :0];
+ var resolution_buf: [512]u8 = undefined;
+ const buf = this.lockfile.buffers.string_bytes.items;
+ var resolution_label = std.fmt.bufPrint(&resolution_buf, "{}", .{resolution.fmt(buf)}) catch unreachable;
+ switch (resolution.tag) {
+ .npm => {
+ var installer = PackageInstall{
+ .cache_dir = this.manager.cache_directory,
+ .progress = this.progress,
+ .cache_dir_subpath = PackageManager.cachedNPMPackageFolderName(name, resolution.value.npm),
+ .destination_dir = this.node_modules_folder,
+ .destination_dir_subpath = destination_dir_subpath,
+ .destination_dir_subpath_buf = &this.destination_dir_subpath_buf,
+ .allocator = this.lockfile.allocator,
+ .package_name = name,
+ .package_version = resolution_label,
+ };
+
+ const needs_install = this.force_install or this.skip_verify or !installer.verify();
+ this.summary.skipped += @as(u32, @boolToInt(!needs_install));
+
+ if (needs_install) {
+ const result = installer.install(this.skip_delete);
+ switch (result) {
+ .success => {
+ const is_duplicate = this.successfully_installed.isSet(package_id);
+ this.summary.success += @as(u32, @boolToInt(!is_duplicate));
+ this.successfully_installed.set(package_id);
+
+ if (comptime log_level.showProgress()) {
+ this.node.completeOne();
+ }
+
+ const bin = this.bins[package_id];
+ if (bin.tag != .none) {
+ if (!this.has_created_bin) {
+ this.node_modules_folder.makeDirZ(".bin") catch {};
+ Bin.Linker.umask = C.umask(0);
+ this.has_created_bin = true;
+ }
+
+ const bin_task_id = Task.Id.forBinLink(package_id);
+ var task_queue = this.manager.task_queue.getOrPut(this.manager.allocator, bin_task_id) catch unreachable;
+ if (!task_queue.found_existing) {
+ run_bin_link: {
+ if (std.mem.indexOfScalar(PackageNameHash, this.options.native_bin_link_allowlist, String.Builder.stringHash(name)) != null) {
+ this.platform_binlinks.append(this.lockfile.allocator, .{
+ .package_id = package_id,
+ .node_modules_folder = this.node_modules_folder,
+ }) catch unreachable;
+ break :run_bin_link;
+ }
+
+ var bin_linker = Bin.Linker{
+ .bin = bin,
+ .package_installed_node_modules = this.node_modules_folder.fd,
+ .root_node_modules_folder = this.root_node_modules_folder.fd,
+ .package_name = strings.StringOrTinyString.init(name),
+ .string_buf = buf,
+ };
+
+ bin_linker.link();
+
+ if (comptime log_level != .silent) {
+ if (bin_linker.err) |err| {
+ const fmt = "\n<r><red>error:<r> linking <b>{s}<r>: {s}\n";
+ const args = .{ name, @errorName(err) };
+
+ if (comptime log_level.showProgress()) {
+ if (Output.enable_ansi_colors) {
+ this.progress.log(comptime Output.prettyFmt(fmt, true), args);
+ } else {
+ this.progress.log(comptime Output.prettyFmt(fmt, false), args);
+ }
+ } else {
+ Output.prettyErrorln(fmt, args);
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ .fail => |cause| {
+ if (cause.isPackageMissingFromCache()) {
+ const task_id = Task.Id.forNPMPackage(Task.Tag.extract, name, resolution.value.npm);
+ var task_queue = this.manager.task_queue.getOrPut(this.manager.allocator, task_id) catch unreachable;
+ if (!task_queue.found_existing) {
+ task_queue.value_ptr.* = .{};
+ }
+
+ task_queue.value_ptr.append(
+ this.manager.allocator,
+ .{
+ .node_modules_folder = @intCast(u32, this.node_modules_folder.fd),
+ },
+ ) catch unreachable;
+
+ if (this.manager.generateNetworkTaskForTarball(task_id, this.lockfile.packages.get(package_id)) catch unreachable) |task| {
+ task.schedule(&this.manager.network_tarball_batch);
+ if (this.manager.network_tarball_batch.len > 6) {
+ _ = this.manager.scheduleNetworkTasks();
+ }
+ }
+ } else {
+ Output.prettyErrorln(
+ "<r><red>error<r>: <b><red>{s}<r> installing <b>{s}<r>",
+ .{ @errorName(cause.err), this.names[package_id].slice(buf) },
+ );
+ this.summary.fail += 1;
+ }
+ },
+ else => {},
+ }
+ }
+ },
+ else => {},
+ }
+ }
+
+ pub fn installPackage(
+ this: *PackageInstaller,
+ package_id: PackageID,
+ comptime log_level: Options.LogLevel,
+ ) void {
+ // const package_id = ctx.package_id;
+ // const tree = ctx.trees[ctx.tree_id];
+ const meta = &this.metas[package_id];
+
+ if (meta.isDisabled()) {
+ if (comptime log_level.showProgress()) {
+ this.node.completeOne();
+ }
+ return;
+ }
+
+ const buf = this.lockfile.buffers.string_bytes.items;
+ const name = this.names[package_id].slice(buf);
+ const resolution = this.resolutions[package_id];
+
+ this.installPackageWithNameAndResolution(package_id, log_level, name, resolution);
+ }
+ };
+
+ pub fn installPackages(
+ this: *PackageManager,
+ lockfile: *Lockfile,
+ comptime log_level: PackageManager.Options.LogLevel,
+ ) !PackageInstall.Summary {
+ var root_node: *Progress.Node = undefined;
+ var download_node: Progress.Node = undefined;
+ var install_node: Progress.Node = undefined;
+ const options = &this.options;
+ var progress = &this.progress;
+
+ if (comptime log_level.showProgress()) {
+ root_node = try progress.start("", 0);
+ download_node = root_node.start(ProgressStrings.download(), 0);
+
+ install_node = root_node.start(ProgressStrings.install(), lockfile.packages.len);
+ this.downloads_node = &download_node;
+ }
+
+ defer {
+ if (comptime log_level.showProgress()) {
+ progress.root.end();
+ progress.* = .{};
+ }
+ }
+ const cache_dir = this.cache_directory;
+
+ lockfile.unique_packages.unset(0);
+
+ // If there was already a valid lockfile and so we did not resolve, i.e. there was zero network activity
+ // the packages could still not be in the cache dir
+ // this would be a common scenario in a CI environment
+ // or if you just cloned a repo
+ // we want to check lazily though
+ // no need to download packages you've already installed!!
+
+ var skip_verify = false;
+ var node_modules_folder = std.fs.cwd().openDirZ("node_modules", .{ .iterate = true }) catch brk: {
+ skip_verify = true;
+ std.fs.cwd().makeDirZ("node_modules") catch |err| {
+ Output.prettyErrorln("<r><red>error<r>: <b><red>{s}<r> creating <b>node_modules<r> folder", .{@errorName(err)});
+ Output.flush();
+ Global.crash();
+ };
+ break :brk std.fs.cwd().openDirZ("node_modules", .{ .iterate = true }) catch |err| {
+ Output.prettyErrorln("<r><red>error<r>: <b><red>{s}<r> opening <b>node_modules<r> folder", .{@errorName(err)});
+ Output.flush();
+ Global.crash();
+ };
+ };
+ var skip_delete = skip_verify;
+ const force_install = options.enable.force_install;
+ if (options.enable.force_install) {
+ skip_verify = true;
+ skip_delete = false;
+ }
+ var summary = PackageInstall.Summary{};
+
+ {
+ var parts = lockfile.packages.slice();
+ var metas = parts.items(.meta);
+ var names = parts.items(.name);
+ var dependency_lists: []const Lockfile.DependencySlice = parts.items(.dependencies);
+ var dependencies = lockfile.buffers.dependencies.items;
+ const resolutions_buffer: []const PackageID = lockfile.buffers.resolutions.items;
+ const resolution_lists: []const Lockfile.PackageIDSlice = parts.items(.resolutions);
+ var resolutions = parts.items(.resolution);
+ const end = @truncate(PackageID, names.len);
+ const pending_task_offset = this.total_tasks;
+ var iterator = Lockfile.Tree.Iterator.init(
+ lockfile.buffers.trees.items,
+ lockfile.buffers.hoisted_packages.items,
+ names,
+ lockfile.buffers.string_bytes.items,
+ );
+
+ var installer = PackageInstaller{
+ .manager = this,
+ .options = &this.options,
+ .metas = metas,
+ .bins = parts.items(.bin),
+ .root_node_modules_folder = node_modules_folder,
+ .names = names,
+ .resolutions = resolutions,
+ .lockfile = lockfile,
+ .node = &install_node,
+ .node_modules_folder = node_modules_folder,
+ .progress = progress,
+ .skip_verify = skip_verify,
+ .skip_delete = skip_delete,
+ .summary = &summary,
+ .force_install = force_install,
+ .install_count = lockfile.buffers.hoisted_packages.items.len,
+ .successfully_installed = try std.DynamicBitSetUnmanaged.initEmpty(lockfile.packages.len, this.allocator),
+ };
+
+ const cwd = std.fs.cwd();
+ while (iterator.nextNodeModulesFolder()) |node_modules| {
+ try cwd.makePath(std.mem.span(node_modules.relative_path));
+ // We deliberately do not close this folder.
+ // If the package hasn't been downloaded, we will need to install it later
+ // We use this file descriptor to know where to put it.
+ var folder = try cwd.openDirZ(node_modules.relative_path, .{
+ .iterate = true,
+ });
+
+ installer.node_modules_folder = folder;
+
+ var remaining = node_modules.packages;
+
+ // cache line is 64 bytes on ARM64 and x64
+ // PackageIDs are 4 bytes
+ // Hence, we can fit up to 64 / 4 = 16 package IDs in a cache line
+ const unroll_count = comptime 64 / @sizeOf(PackageID);
+
+ while (remaining.len > unroll_count) {
+ comptime var i: usize = 0;
+ inline while (i < unroll_count) : (i += 1) {
+ installer.installPackage(remaining[i], comptime log_level);
+ }
+ remaining = remaining[unroll_count..];
+
+ // We want to minimize how often we call this function
+ // That's part of why we unroll this loop
+ if (this.pending_tasks > 0) {
+ try this.runTasks(
+ *PackageInstaller,
+ &installer,
+ PackageInstaller.installEnqueuedPackages,
+ log_level,
+ );
+ }
+ }
+
+ for (remaining) |package_id| {
+ installer.installPackage(@truncate(PackageID, package_id), log_level);
+ }
+
+ try this.runTasks(
+ *PackageInstaller,
+ &installer,
+ PackageInstaller.installEnqueuedPackages,
+ log_level,
+ );
+ }
+
+ while (this.pending_tasks > 0) {
+ try this.runTasks(
+ *PackageInstaller,
+ &installer,
+ PackageInstaller.installEnqueuedPackages,
+ log_level,
+ );
+ }
+
+ summary.successfully_installed = installer.successfully_installed;
+ outer: for (installer.platform_binlinks.items) |deferred| {
+ const package_id = deferred.package_id;
+ const folder = deferred.node_modules_folder;
+
+ const package_dependencies: []const Dependency = dependency_lists[package_id].get(dependencies);
+ const package_resolutions: []const PackageID = resolution_lists[package_id].get(resolutions_buffer);
+ const original_bin: Bin = installer.bins[package_id];
+
+ for (package_dependencies) |dependency, i| {
+ const resolved_id = package_resolutions[i];
+ if (resolved_id >= names.len) continue;
+ const meta: Lockfile.Package.Meta = metas[resolved_id];
+
+ // This is specifically for platform-specific binaries
+ if (meta.os == .all and meta.arch == .all) continue;
+
+ // Don't attempt to link incompatible binaries
+ if (meta.isDisabled()) continue;
+
+ const name: string = installer.names[resolved_id].slice(lockfile.buffers.string_bytes.items);
+
+ if (!installer.has_created_bin) {
+ node_modules_folder.makeDirZ(".bin") catch {};
+ Bin.Linker.umask = C.umask(0);
+ installer.has_created_bin = true;
+ }
+
+ var bin_linker = Bin.Linker{
+ .bin = original_bin,
+ .package_installed_node_modules = folder.fd,
+ .root_node_modules_folder = node_modules_folder.fd,
+ .package_name = strings.StringOrTinyString.init(name),
+ .string_buf = lockfile.buffers.string_bytes.items,
+ };
+
+ bin_linker.link();
+
+ if (comptime log_level != .silent) {
+ if (bin_linker.err) |err| {
+ const fmt = "\n<r><red>error:<r> linking <b>{s}<r>: {s}\n";
+ const args = .{ name, @errorName(err) };
+
+ if (comptime log_level.showProgress()) {
+ if (Output.enable_ansi_colors) {
+ this.progress.log(comptime Output.prettyFmt(fmt, true), args);
+ } else {
+ this.progress.log(comptime Output.prettyFmt(fmt, false), args);
+ }
+ } else {
+ Output.prettyErrorln(fmt, args);
+ }
+ }
+ }
+
+ continue :outer;
+ }
+
+ if (comptime log_level != .silent) {
+ const fmt = "\n<r><yellow>warn:<r> no compatible binaries found for <b>{s}<r>\n";
+ const args = .{names[package_id]};
+
+ if (comptime log_level.showProgress()) {
+ if (Output.enable_ansi_colors) {
+ this.progress.log(comptime Output.prettyFmt(fmt, true), args);
+ } else {
+ this.progress.log(comptime Output.prettyFmt(fmt, false), args);
+ }
+ } else {
+ Output.prettyErrorln(fmt, args);
+ }
+ }
+ }
+ }
+
+ return summary;
+ }
+
+ fn installWithManager(
+ ctx: Command.Context,
+ manager: *PackageManager,
+ package_json_contents: string,
+ comptime log_level: Options.LogLevel,
+ ) !void {
+ var load_lockfile_result: Lockfile.LoadFromDiskResult = if (manager.options.do.load_lockfile)
+ manager.lockfile.loadFromDisk(
+ ctx.allocator,
+ ctx.log,
+ manager.options.lockfile_path,
+ )
+ else
+ Lockfile.LoadFromDiskResult{ .not_found = .{} };
+
+ var root = Lockfile.Package{};
+
+ var needs_new_lockfile = load_lockfile_result != .ok;
+
+ // this defaults to false
+ // but we force allowing updates to the lockfile when you do bun add
+ var had_any_diffs = false;
+ manager.progress = .{};
+
+ // Step 2. Parse the package.json file
+ //
+ var package_json_source = logger.Source.initPathString(
+ package_json_cwd_buf[0 .. FileSystem.instance.top_level_dir.len + "package.json".len],
+ package_json_contents,
+ );
+
+ switch (load_lockfile_result) {
+ .err => |cause| {
+ switch (cause.step) {
+ .open_file => Output.prettyErrorln("<r><red>error opening lockfile:<r> {s}. <b>Ignoring lockfile<r>.", .{
+ @errorName(cause.value),
+ }),
+ .parse_file => Output.prettyErrorln("<r><red>error parsing lockfile:<r> {s}. <b>Ignoring lockfile<r>.", .{
+ @errorName(cause.value),
+ }),
+ .read_file => Output.prettyErrorln("<r><red>error reading lockfile:<r> {s}. <b>Ignoring lockfile<r>.", .{
+ @errorName(cause.value),
+ }),
+ }
+ if (ctx.log.errors > 0) {
+ if (Output.enable_ansi_colors) {
+ try manager.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), true);
+ } else {
+ try manager.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), false);
+ }
+ }
+ Output.flush();
+ },
+ .ok => {
+ differ: {
+ root = load_lockfile_result.ok.rootPackage() orelse {
+ needs_new_lockfile = true;
+ break :differ;
+ };
+
+ if (root.dependencies.len == 0) {
+ needs_new_lockfile = true;
+ break :differ;
+ }
+
+ var lockfile: Lockfile = undefined;
+ try lockfile.initEmpty(ctx.allocator);
+ var new_root: Lockfile.Package = undefined;
+ if (manager.options.enable.install_dev_dependencies) {
+ try Lockfile.Package.parse(
+ &lockfile,
+ &new_root,
+ ctx.allocator,
+ ctx.log,
+ package_json_source,
+ Features{
+ .optional_dependencies = true,
+ .dev_dependencies = true,
+ .is_main = true,
+ .check_for_duplicate_dependencies = true,
+ .peer_dependencies = false,
+ },
+ );
+ } else {
+ try Lockfile.Package.parse(
+ &lockfile,
+ &new_root,
+ ctx.allocator,
+ ctx.log,
+ package_json_source,
+ Features{
+ .optional_dependencies = true,
+ .dev_dependencies = false,
+ .is_main = true,
+ .check_for_duplicate_dependencies = true,
+ .peer_dependencies = false,
+ },
+ );
+ }
+ var mapping = try manager.lockfile.allocator.alloc(PackageID, new_root.dependencies.len);
+ std.mem.set(PackageID, mapping, invalid_package_id);
+
+ manager.summary = try Package.Diff.generate(
+ ctx.allocator,
+ manager.lockfile,
+ &lockfile,
+ &root,
+ &new_root,
+ mapping,
+ );
+
+ const sum = manager.summary.add + manager.summary.remove + manager.summary.update;
+ had_any_diffs = had_any_diffs or sum > 0;
+
+ // If you changed packages, we will copy over the new package from the new lockfile
+ const new_dependencies = new_root.dependencies.get(lockfile.buffers.dependencies.items);
+
+ if (had_any_diffs) {
+ var builder_ = manager.lockfile.stringBuilder();
+ // ensure we use one pointer to reference it instead of creating new ones and potentially aliasing
+ var builder = &builder_;
+
+ for (new_dependencies) |new_dep, i| {
+ new_dep.count(lockfile.buffers.string_bytes.items, *Lockfile.StringBuilder, builder);
+ }
+
+ const off = @truncate(u32, manager.lockfile.buffers.dependencies.items.len);
+ const len = @truncate(u32, new_dependencies.len);
+ var packages = manager.lockfile.packages.slice();
+ var dep_lists = packages.items(.dependencies);
+ var resolution_lists = packages.items(.resolutions);
+ const old_dependencies_list = dep_lists[0];
+ const old_resolutions_list = resolution_lists[0];
+ dep_lists[0] = .{ .off = off, .len = len };
+ resolution_lists[0] = .{ .off = off, .len = len };
+ manager.root_dependency_list = dep_lists[0];
+ try builder.allocate();
+
+ try manager.lockfile.buffers.dependencies.ensureUnusedCapacity(manager.lockfile.allocator, len);
+ try manager.lockfile.buffers.resolutions.ensureUnusedCapacity(manager.lockfile.allocator, len);
+
+ var old_resolutions = old_resolutions_list.get(manager.lockfile.buffers.resolutions.items);
+
+ var dependencies = manager.lockfile.buffers.dependencies.items.ptr[off .. off + len];
+ var resolutions = manager.lockfile.buffers.resolutions.items.ptr[off .. off + len];
+
+ // It is too easy to accidentally undefined memory
+ std.mem.set(PackageID, resolutions, invalid_package_id);
+ std.mem.set(Dependency, dependencies, Dependency{});
+
+ manager.lockfile.buffers.dependencies.items = manager.lockfile.buffers.dependencies.items.ptr[0 .. off + len];
+ manager.lockfile.buffers.resolutions.items = manager.lockfile.buffers.resolutions.items.ptr[0 .. off + len];
+
+ for (new_dependencies) |new_dep, i| {
+ dependencies[i] = try new_dep.clone(lockfile.buffers.string_bytes.items, *Lockfile.StringBuilder, builder);
+ if (mapping[i] != invalid_package_id) {
+ resolutions[i] = old_resolutions[mapping[i]];
+ }
+ }
+
+ builder.clamp();
+
+ // Split this into two passes because the below may allocate memory or invalidate pointers
+ if (manager.summary.add > 0 or manager.summary.update > 0) {
+ var remaining = mapping;
+ var dependency_i: PackageID = off;
+ while (std.mem.indexOfScalar(PackageID, remaining, invalid_package_id)) |next_i_| {
+ remaining = remaining[next_i_ + 1 ..];
+
+ dependency_i += @intCast(PackageID, next_i_);
+ try manager.enqueueDependencyWithMain(
+ dependency_i,
+ manager.lockfile.buffers.dependencies.items[dependency_i],
+ manager.lockfile.buffers.resolutions.items[dependency_i],
+ true,
+ );
+ }
+ }
+ }
+ }
+ },
+ else => {},
+ }
+
+ if (needs_new_lockfile) {
+ root = Lockfile.Package{};
+ try manager.lockfile.initEmpty(ctx.allocator);
+
+ if (manager.options.enable.install_dev_dependencies) {
+ try Lockfile.Package.parse(
+ manager.lockfile,
+ &root,
+ ctx.allocator,
+ ctx.log,
+ package_json_source,
+ Features{
+ .optional_dependencies = true,
+ .dev_dependencies = true,
+ .is_main = true,
+ .check_for_duplicate_dependencies = true,
+ .peer_dependencies = false,
+ },
+ );
+ } else {
+ try Lockfile.Package.parse(
+ manager.lockfile,
+ &root,
+ ctx.allocator,
+ ctx.log,
+ package_json_source,
+ Features{
+ .optional_dependencies = true,
+ .dev_dependencies = false,
+ .is_main = true,
+ .check_for_duplicate_dependencies = true,
+ .peer_dependencies = false,
+ },
+ );
+ }
+
+ root = try manager.lockfile.appendPackage(root);
+
+ manager.root_dependency_list = root.dependencies;
+ manager.enqueueDependencyList(
+ root.dependencies,
+ true,
+ );
+ }
+
+ manager.flushDependencyQueue();
+
+ // Anything that needs to be downloaded from an update needs to be scheduled here
+ _ = manager.scheduleNetworkTasks();
+
+ if (manager.pending_tasks > 0) {
+ if (comptime log_level.showProgress()) {
+ manager.downloads_node = try manager.progress.start(ProgressStrings.download(), 0);
+ manager.setNodeName(manager.downloads_node.?, ProgressStrings.download_no_emoji_, ProgressStrings.download_emoji, true);
+ manager.downloads_node.?.setEstimatedTotalItems(manager.total_tasks + manager.extracted_count);
+ manager.downloads_node.?.setCompletedItems(manager.total_tasks - manager.pending_tasks);
+ manager.downloads_node.?.activate();
+ manager.progress.refresh();
+ }
+
+ while (manager.pending_tasks > 0) {
+ try manager.runTasks(void, void{}, null, log_level);
+ }
+
+ if (comptime log_level.showProgress()) {
+ manager.downloads_node.?.setEstimatedTotalItems(manager.downloads_node.?.unprotected_estimated_total_items);
+ manager.downloads_node.?.setCompletedItems(manager.downloads_node.?.unprotected_estimated_total_items);
+ manager.progress.refresh();
+ manager.progress.root.end();
+ manager.progress = .{};
+ manager.downloads_node = null;
+ }
+ }
+
+ if (Output.enable_ansi_colors) {
+ try manager.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), true);
+ } else {
+ try manager.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), false);
+ }
+
+ if (manager.log.errors > 0) {
+ Output.flush();
+ std.os.exit(1);
+ }
+
+ if (had_any_diffs or needs_new_lockfile or manager.package_json_updates.len > 0) {
+ manager.lockfile = try manager.lockfile.clean(&manager.summary.deduped, manager.package_json_updates, &manager.options);
+ }
+
+ if (manager.options.do.save_lockfile) {
+ var node: *Progress.Node = undefined;
+
+ if (comptime log_level.showProgress()) {
+ node = try manager.progress.start(ProgressStrings.save(), 0);
+ node.activate();
+
+ manager.progress.refresh();
+ }
+ manager.lockfile.saveToDisk(manager.options.save_lockfile_path);
+ if (comptime log_level.showProgress()) {
+ node.end();
+ manager.progress.refresh();
+ manager.progress.root.end();
+ manager.progress = .{};
+ }
+ }
+
+ var install_summary = PackageInstall.Summary{};
+ if (manager.options.do.install_packages) {
+ install_summary = try manager.installPackages(
+ manager.lockfile,
+ log_level,
+ );
+ }
+
+ if (needs_new_lockfile) {
+ manager.summary.add = @truncate(u32, manager.lockfile.packages.len);
+ }
+
+ if (manager.options.do.save_yarn_lock) {
+ var node: *Progress.Node = undefined;
+ if (comptime log_level.showProgress()) {
+ node = try manager.progress.start("Saving yarn.lock", 0);
+ manager.progress.refresh();
+ }
+
+ try manager.writeYarnLock();
+ if (comptime log_level.showProgress()) {
+ node.completeOne();
+ manager.progress.refresh();
+ manager.progress.root.end();
+ manager.progress = .{};
+ }
+ }
+
+ if (comptime log_level != .silent) {
+ var printer = Lockfile.Printer{
+ .lockfile = manager.lockfile,
+ .options = manager.options,
+ .successfully_installed = install_summary.successfully_installed,
+ };
+ if (Output.enable_ansi_colors) {
+ try Lockfile.Printer.Tree.print(&printer, Output.WriterType, Output.writer(), true);
+ } else {
+ try Lockfile.Printer.Tree.print(&printer, Output.WriterType, Output.writer(), false);
+ }
+
+ if (install_summary.success > 0) {
+ Output.pretty("\n <green>{d}<r> packages<r> installed ", .{install_summary.success});
+ Output.printStartEndStdout(ctx.start_time, std.time.nanoTimestamp());
+ Output.pretty("<r>\n", .{});
+
+ if (manager.summary.update > 0) {
+ Output.pretty(" Updated: <cyan>{d}<r>\n", .{manager.summary.update});
+ }
+
+ if (manager.summary.remove > 0) {
+ Output.pretty(" Removed: <cyan>{d}<r>\n", .{manager.summary.remove});
+ }
+ } else if (manager.summary.remove > 0) {
+ if (manager.to_remove.len > 0) {
+ for (manager.to_remove) |update| {
+ Output.prettyln(" <r><red>-<r> {s}", .{update.name});
+ }
+ }
+
+ Output.pretty("\n <r><b>{d}<r> packages removed ", .{manager.summary.remove});
+ Output.printStartEndStdout(ctx.start_time, std.time.nanoTimestamp());
+ Output.pretty("<r>\n", .{});
+ } else if (install_summary.skipped > 0 and install_summary.fail == 0) {
+ Output.pretty("\n", .{});
+
+ const count = @truncate(PackageID, manager.lockfile.packages.len);
+ if (count != install_summary.skipped) {
+ Output.pretty("Checked <green>{d} installs<r> across {d} packages <d>(no changes)<r> ", .{
+ install_summary.skipped,
+ count,
+ });
+ Output.printStartEndStdout(ctx.start_time, std.time.nanoTimestamp());
+ Output.pretty("<r>\n", .{});
+ } else {
+ Output.pretty("<r> Done! Checked <green>{d} packages<r> <d>(no changes)<r> ", .{
+ install_summary.skipped,
+ });
+ Output.printStartEndStdout(ctx.start_time, std.time.nanoTimestamp());
+ Output.pretty("<r>\n", .{});
+ }
+ } else if (manager.summary.update > 0) {
+ Output.prettyln(" Updated: <cyan>{d}<r>\n", .{manager.summary.update});
+ }
+
+ if (install_summary.fail > 0) {
+ Output.prettyln("<r> Failed to install <red><b>{d}<r> packages", .{install_summary.fail});
+ }
+ }
+ Output.flush();
+ }
+};
+
+const Package = Lockfile.Package;
diff --git a/src/install/integrity.zig b/src/install/integrity.zig
new file mode 100644
index 000000000..debe861a4
--- /dev/null
+++ b/src/install/integrity.zig
@@ -0,0 +1,203 @@
+const std = @import("std");
+const strings = @import("../string_immutable.zig");
+
+pub const Integrity = extern struct {
+ tag: Tag = Tag.unknown,
+ /// Possibly a [Subresource Integrity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity) value initially
+ /// We transform it though.
+ value: [digest_buf_len]u8 = undefined,
+
+ const Base64 = std.base64.standard_no_pad;
+
+ pub const digest_buf_len: usize = brk: {
+ const values = [_]usize{
+ std.crypto.hash.Sha1.digest_length,
+ std.crypto.hash.sha2.Sha512.digest_length,
+ std.crypto.hash.sha2.Sha256.digest_length,
+ std.crypto.hash.sha2.Sha384.digest_length,
+ };
+
+ var value: usize = 0;
+ for (values) |val| {
+ value = @maximum(val, value);
+ }
+
+ break :brk value;
+ };
+
+ pub fn parseSHASum(buf: []const u8) !Integrity {
+ if (buf.len == 0) {
+ return Integrity{
+ .tag = Tag.unknown,
+ .value = undefined,
+ };
+ }
+
+ // e.g. "3cd0599b099384b815c10f7fa7df0092b62d534f"
+ var integrity = Integrity{ .tag = Tag.sha1 };
+ const end: usize = @minimum("3cd0599b099384b815c10f7fa7df0092b62d534f".len, buf.len);
+ var out_i: usize = 0;
+ var i: usize = 0;
+
+ {
+ std.mem.set(u8, &integrity.value, 0);
+ }
+
+ while (i < end) {
+ const x0 = @as(u16, switch (buf[i]) {
+ '0'...'9' => buf[i] - '0',
+ 'A'...'Z' => buf[i] - 'A' + 10,
+ 'a'...'z' => buf[i] - 'a' + 10,
+ else => return error.InvalidCharacter,
+ });
+ i += 1;
+
+ const x1 = @as(u16, switch (buf[i]) {
+ '0'...'9' => buf[i] - '0',
+ 'A'...'Z' => buf[i] - 'A' + 10,
+ 'a'...'z' => buf[i] - 'a' + 10,
+ else => return error.InvalidCharacter,
+ });
+
+ // parse hex integer
+ integrity.value[out_i] = @truncate(u8, x0 << 4 | x1);
+
+ out_i += 1;
+ i += 1;
+ }
+
+ var remainder = &integrity.value[out_i..];
+
+ return integrity;
+ }
+
+ pub fn parse(buf: []const u8) !Integrity {
+ if (buf.len < "sha256-".len) {
+ return Integrity{
+ .tag = Tag.unknown,
+ .value = undefined,
+ };
+ }
+
+ var out: [digest_buf_len]u8 = undefined;
+ const tag = Tag.parse(buf);
+ if (tag == Tag.unknown) {
+ return Integrity{
+ .tag = Tag.unknown,
+ .value = undefined,
+ };
+ }
+
+ Base64.Decoder.decode(&out, std.mem.trimRight(u8, buf["sha256-".len..], "=")) catch {
+ return Integrity{
+ .tag = Tag.unknown,
+ .value = undefined,
+ };
+ };
+
+ return Integrity{ .value = out, .tag = tag };
+ }
+
+ pub const Tag = enum(u8) {
+ unknown = 0,
+ /// "shasum" in the metadata
+ sha1 = 1,
+ /// The value is a [Subresource Integrity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity) value
+ sha256 = 2,
+ /// The value is a [Subresource Integrity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity) value
+ sha384 = 3,
+ /// The value is a [Subresource Integrity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity) value
+ sha512 = 4,
+
+ _,
+
+ pub inline fn isSupported(this: Tag) bool {
+ return @enumToInt(this) >= @enumToInt(Tag.sha1) and @enumToInt(this) <= @enumToInt(Tag.sha512);
+ }
+
+ pub fn parse(buf: []const u8) Tag {
+ const Matcher = strings.ExactSizeMatcher(8);
+
+ const i = std.mem.indexOfScalar(u8, buf[0..@minimum(buf.len, 7)], '-') orelse return Tag.unknown;
+
+ return switch (Matcher.match(buf[0..i])) {
+ Matcher.case("sha1") => Tag.sha1,
+ Matcher.case("sha256") => Tag.sha256,
+ Matcher.case("sha384") => Tag.sha384,
+ Matcher.case("sha512") => Tag.sha512,
+ else => .unknown,
+ };
+ }
+
+ pub inline fn digestLen(this: Tag) usize {
+ return switch (this) {
+ .sha1 => std.crypto.hash.Sha1.digest_length,
+ .sha512 => std.crypto.hash.sha2.Sha512.digest_length,
+ .sha256 => std.crypto.hash.sha2.Sha256.digest_length,
+ .sha384 => std.crypto.hash.sha2.Sha384.digest_length,
+ else => 0,
+ };
+ }
+ };
+
+ pub fn slice(
+ this: *const Integrity,
+ ) []const u8 {
+ return this.value[0..this.tag.digestLen()];
+ }
+
+ pub fn format(this: *const Integrity, comptime layout: []const u8, opts: std.fmt.FormatOptions, writer: anytype) !void {
+ switch (this.tag) {
+ .sha1 => try writer.writeAll("sha1-"),
+ .sha256 => try writer.writeAll("sha256-"),
+ .sha384 => try writer.writeAll("sha384-"),
+ .sha512 => try writer.writeAll("sha512-"),
+ else => return,
+ }
+
+ var base64_buf: [512]u8 = undefined;
+ const bytes = this.slice();
+
+ try writer.writeAll(Base64.Encoder.encode(&base64_buf, bytes));
+
+ // consistentcy with yarn.lock
+ switch (this.tag) {
+ .sha1 => try writer.writeAll("="),
+ else => try writer.writeAll("=="),
+ }
+ }
+
+ pub fn verify(this: *const Integrity, bytes: []const u8) bool {
+ return @call(.{ .modifier = .always_inline }, verifyByTag, .{ this.tag, bytes, &this.value });
+ }
+
+ pub fn verifyByTag(tag: Tag, bytes: []const u8, sum: []const u8) bool {
+ var digest: [digest_buf_len]u8 = undefined;
+
+ switch (tag) {
+ .sha1 => {
+ var ptr = digest[0..std.crypto.hash.Sha1.digest_length];
+ std.crypto.hash.Sha1.hash(bytes, ptr, .{});
+ return strings.eqlLong(ptr, sum[0..ptr.len], true);
+ },
+ .sha512 => {
+ var ptr = digest[0..std.crypto.hash.sha2.Sha512.digest_length];
+ std.crypto.hash.sha2.Sha512.hash(bytes, ptr, .{});
+ return strings.eqlLong(ptr, sum[0..ptr.len], true);
+ },
+ .sha256 => {
+ var ptr = digest[0..std.crypto.hash.sha2.Sha256.digest_length];
+ std.crypto.hash.sha2.Sha256.hash(bytes, ptr, .{});
+ return strings.eqlLong(ptr, sum[0..ptr.len], true);
+ },
+ .sha384 => {
+ var ptr = digest[0..std.crypto.hash.sha2.Sha384.digest_length];
+ std.crypto.hash.sha2.Sha384.hash(bytes, ptr, .{});
+ return strings.eqlLong(ptr, sum[0..ptr.len], true);
+ },
+ else => return false,
+ }
+
+ unreachable;
+ }
+};
diff --git a/src/install/npm.zig b/src/install/npm.zig
new file mode 100644
index 000000000..9d12255d4
--- /dev/null
+++ b/src/install/npm.zig
@@ -0,0 +1,1383 @@
+const URL = @import("../query_string_map.zig").URL;
+const std = @import("std");
+const MutableString = @import("../string_mutable.zig").MutableString;
+const Semver = @import("./semver.zig");
+const ExternalString = Semver.ExternalString;
+const String = Semver.String;
+const string = @import("../string_types.zig").string;
+const strings = @import("../string_immutable.zig");
+const PackageManager = @import("./install.zig").PackageManager;
+const ExternalStringMap = @import("./install.zig").ExternalStringMap;
+const ExternalStringList = @import("./install.zig").ExternalStringList;
+const ExternalSlice = @import("./install.zig").ExternalSlice;
+const initializeStore = @import("./install.zig").initializeStore;
+const logger = @import("../logger.zig");
+const Output = @import("../global.zig").Output;
+const Integrity = @import("./integrity.zig").Integrity;
+const Bin = @import("./bin.zig").Bin;
+const Environment = @import("../global.zig").Environment;
+const Aligner = @import("./install.zig").Aligner;
+const HTTPClient = @import("http");
+const json_parser = @import("../json_parser.zig");
+const default_allocator = @import("../global.zig").default_allocator;
+const IdentityContext = @import("../identity_context.zig").IdentityContext;
+const ArrayIdentityContext = @import("../identity_context.zig").ArrayIdentityContext;
+const SlicedString = Semver.SlicedString;
+const FileSystem = @import("../fs.zig").FileSystem;
+
+const VersionSlice = @import("./install.zig").VersionSlice;
+fn ObjectPool(comptime Type: type, comptime Init: (fn (allocator: *std.mem.Allocator) anyerror!Type), comptime threadsafe: bool) type {
+ return struct {
+ const LinkedList = std.SinglyLinkedList(Type);
+ const Data = if (threadsafe)
+ struct {
+ pub threadlocal var list: LinkedList = undefined;
+ pub threadlocal var loaded: bool = false;
+ }
+ else
+ struct {
+ pub var list: LinkedList = undefined;
+ pub var loaded: bool = false;
+ };
+
+ const data = Data;
+
+ pub fn get(allocator: *std.mem.Allocator) *LinkedList.Node {
+ if (data.loaded) {
+ if (data.list.popFirst()) |node| {
+ node.data.reset();
+ return node;
+ }
+ }
+
+ var new_node = allocator.create(LinkedList.Node) catch unreachable;
+ new_node.* = LinkedList.Node{
+ .data = Init(
+ allocator,
+ ) catch unreachable,
+ };
+
+ return new_node;
+ }
+
+ pub fn release(node: *LinkedList.Node) void {
+ if (data.loaded) {
+ data.list.prepend(node);
+ return;
+ }
+
+ data.list = LinkedList{ .first = node };
+ data.loaded = true;
+ }
+ };
+}
+
+const Npm = @This();
+
+pub const Registry = struct {
+ url: URL = URL.parse("https://registry.npmjs.org/"),
+ scopes: Map = Map{},
+
+ token: string = "",
+ auth: string = "",
+
+ pub const BodyPool = ObjectPool(MutableString, MutableString.init2048, true);
+
+ pub const Scope = struct {
+ name: string = "",
+ // https://github.com/npm/npm-registry-fetch/blob/main/lib/auth.js#L96
+ // base64("${username}:${password}")
+ auth: string = "",
+ // URL may contain these special suffixes in the pathname:
+ // :_authToken
+ // :username
+ // :_password
+ // :_auth
+ url: URL,
+ token: string = "",
+ };
+
+ pub const Map = std.HashMapUnmanaged(u64, Scope, IdentityContext(u64), 80);
+
+ const PackageVersionResponse = union(Tag) {
+ pub const Tag = enum {
+ cached,
+ fresh,
+ not_found,
+ };
+
+ cached: PackageManifest,
+ fresh: PackageManifest,
+ not_found: void,
+ };
+
+ const Pico = @import("picohttp");
+ pub fn getPackageMetadata(
+ allocator: *std.mem.Allocator,
+ response: Pico.Response,
+ body: []const u8,
+ log: *logger.Log,
+ package_name: string,
+ loaded_manifest: ?PackageManifest,
+ ) !PackageVersionResponse {
+ switch (response.status_code) {
+ 400 => return error.BadRequest,
+ 429 => return error.TooManyRequests,
+ 404 => return PackageVersionResponse{ .not_found = .{} },
+ 500...599 => return error.HTTPInternalServerError,
+ 304 => return PackageVersionResponse{
+ .cached = loaded_manifest.?,
+ },
+ else => {},
+ }
+
+ var newly_last_modified: string = "";
+ var new_etag: string = "";
+ for (response.headers) |header| {
+ if (!(header.name.len == "last-modified".len or header.name.len == "etag".len)) continue;
+
+ const hashed = HTTPClient.hashHeaderName(header.name);
+
+ switch (hashed) {
+ HTTPClient.hashHeaderName("last-modified") => {
+ newly_last_modified = header.value;
+ },
+ HTTPClient.hashHeaderName("etag") => {
+ new_etag = header.value;
+ },
+ else => {},
+ }
+ }
+
+ initializeStore();
+ var new_etag_buf: [64]u8 = undefined;
+
+ if (new_etag.len < new_etag_buf.len) {
+ std.mem.copy(u8, &new_etag_buf, new_etag);
+ new_etag = new_etag_buf[0..new_etag.len];
+ }
+
+ if (try PackageManifest.parse(
+ allocator,
+ log,
+ body,
+ package_name,
+ newly_last_modified,
+ new_etag,
+ @truncate(u32, @intCast(u64, @maximum(0, std.time.timestamp()))) + 300,
+ )) |package| {
+ if (PackageManager.instance.options.enable.manifest_cache) {
+ var tmpdir = FileSystem.instance.tmpdir();
+
+ PackageManifest.Serializer.save(&package, tmpdir, PackageManager.instance.cache_directory) catch {};
+ }
+
+ return PackageVersionResponse{ .fresh = package };
+ }
+
+ return error.PackageFailedToParse;
+ }
+};
+
+const VersionMap = std.ArrayHashMapUnmanaged(Semver.Version, PackageVersion, Semver.Version.HashContext, false);
+const DistTagMap = extern struct {
+ tags: ExternalStringList = ExternalStringList{},
+ versions: VersionSlice = VersionSlice{},
+};
+
+const PackageVersionList = ExternalSlice(PackageVersion);
+const ExternVersionMap = extern struct {
+ keys: VersionSlice = VersionSlice{},
+ values: PackageVersionList = PackageVersionList{},
+
+ pub fn findKeyIndex(this: ExternVersionMap, buf: []const Semver.Version, find: Semver.Version) ?u32 {
+ for (this.keys.get(buf)) |key, i| {
+ if (key.eql(find)) {
+ return @truncate(u32, i);
+ }
+ }
+
+ return null;
+ }
+};
+
+/// https://nodejs.org/api/os.html#osplatform
+pub const OperatingSystem = enum(u16) {
+ none = 0,
+ all = all_value,
+
+ _,
+
+ pub const aix: u16 = 1 << 1;
+ pub const darwin: u16 = 1 << 2;
+ pub const freebsd: u16 = 1 << 3;
+ pub const linux: u16 = 1 << 4;
+ pub const openbsd: u16 = 1 << 5;
+ pub const sunos: u16 = 1 << 6;
+ pub const win32: u16 = 1 << 7;
+ pub const android: u16 = 1 << 8;
+
+ pub const all_value: u16 = aix | darwin | freebsd | linux | openbsd | sunos | win32 | android;
+
+ pub fn isMatch(this: OperatingSystem) bool {
+ if (comptime Environment.isLinux) {
+ return (@enumToInt(this) & linux) != 0;
+ } else if (comptime Environment.isMac) {
+ return (@enumToInt(this) & darwin) != 0;
+ } else {
+ return false;
+ }
+ }
+
+ const Matcher = strings.ExactSizeMatcher(8);
+
+ pub fn apply(this_: OperatingSystem, str: []const u8) OperatingSystem {
+ if (str.len == 0) {
+ return this_;
+ }
+ const this = @enumToInt(this_);
+
+ const is_not = str[0] == '!';
+ const offset: usize = if (str[0] == '!') 1 else 0;
+ const input = str[offset..];
+
+ const field: u16 = switch (Matcher.match(input)) {
+ Matcher.case("aix") => aix,
+ Matcher.case("darwin") => darwin,
+ Matcher.case("freebsd") => freebsd,
+ Matcher.case("linux") => linux,
+ Matcher.case("openbsd") => openbsd,
+ Matcher.case("sunos") => sunos,
+ Matcher.case("win32") => win32,
+ Matcher.case("android") => android,
+ else => return this_,
+ };
+
+ if (is_not) {
+ return @intToEnum(OperatingSystem, this & ~field);
+ } else {
+ return @intToEnum(OperatingSystem, this | field);
+ }
+ }
+};
+
+/// https://docs.npmjs.com/cli/v8/configuring-npm/package-json#cpu
+/// https://nodejs.org/api/os.html#osarch
+pub const Architecture = enum(u16) {
+ none = 0,
+ all = all_value,
+ _,
+
+ pub const arm: u16 = 1 << 1;
+ pub const arm64: u16 = 1 << 2;
+ pub const ia32: u16 = 1 << 3;
+ pub const mips: u16 = 1 << 4;
+ pub const mipsel: u16 = 1 << 5;
+ pub const ppc: u16 = 1 << 6;
+ pub const ppc64: u16 = 1 << 7;
+ pub const s390: u16 = 1 << 8;
+ pub const s390x: u16 = 1 << 9;
+ pub const x32: u16 = 1 << 10;
+ pub const x64: u16 = 1 << 11;
+
+ pub const all_value: u16 = arm | arm64 | ia32 | mips | mipsel | ppc | ppc64 | s390 | s390x | x32 | x64;
+
+ pub fn isMatch(this: Architecture) bool {
+ if (comptime Environment.isAarch64) {
+ return (@enumToInt(this) & arm64) != 0;
+ } else if (comptime Environment.isX64) {
+ return (@enumToInt(this) & x64) != 0;
+ } else {
+ return false;
+ }
+ }
+
+ const Matcher = strings.ExactSizeMatcher(8);
+
+ pub fn apply(this_: Architecture, str: []const u8) Architecture {
+ if (str.len == 0) {
+ return this_;
+ }
+ const this = @enumToInt(this_);
+
+ const is_not = str[0] == '!';
+ const offset: usize = if (str[0] == '!') 1 else 0;
+ const input = str[offset..];
+
+ const field: u16 = switch (Matcher.match(input)) {
+ Matcher.case("arm") => arm,
+ Matcher.case("arm64") => arm64,
+ Matcher.case("ia32") => ia32,
+ Matcher.case("mips") => mips,
+ Matcher.case("mipsel") => mipsel,
+ Matcher.case("ppc") => ppc,
+ Matcher.case("ppc64") => ppc64,
+ Matcher.case("s390") => s390,
+ Matcher.case("s390x") => s390x,
+ Matcher.case("x32") => x32,
+ Matcher.case("x64") => x64,
+ else => return this_,
+ };
+
+ if (is_not) {
+ return @intToEnum(Architecture, this & ~field);
+ } else {
+ return @intToEnum(Architecture, this | field);
+ }
+ }
+};
+const BigExternalString = Semver.BigExternalString;
+
+pub const PackageVersion = extern struct {
+ /// `"integrity"` field || `"shasum"` field
+ /// https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#dist
+ // Splitting this into it's own array ends up increasing the final size a little bit.
+ integrity: Integrity = Integrity{},
+
+ /// "dependencies"` in [package.json](https://docs.npmjs.com/cli/v8/configuring-npm/package-json#dependencies)
+ dependencies: ExternalStringMap = ExternalStringMap{},
+
+ /// `"optionalDependencies"` in [package.json](https://docs.npmjs.com/cli/v8/configuring-npm/package-json#optionaldependencies)
+ optional_dependencies: ExternalStringMap = ExternalStringMap{},
+
+ /// `"peerDependencies"` in [package.json](https://docs.npmjs.com/cli/v8/configuring-npm/package-json#peerdependencies)
+ /// if `optional_peer_dependencies_len` is > 0, then instead of alphabetical, the first N items are optional
+ peer_dependencies: ExternalStringMap = ExternalStringMap{},
+
+ /// `"devDependencies"` in [package.json](https://docs.npmjs.com/cli/v8/configuring-npm/package-json#devdependencies)
+ /// We deliberately choose not to populate this field.
+ /// We keep it in the data layout so that if it turns out we do need it, we can add it without invalidating everyone's history.
+ dev_dependencies: ExternalStringMap = ExternalStringMap{},
+
+ /// `"bin"` field in [package.json](https://docs.npmjs.com/cli/v8/configuring-npm/package-json#bin)
+ bin: Bin = Bin{},
+
+ /// `"engines"` field in package.json
+ engines: ExternalStringMap = ExternalStringMap{},
+
+ /// `"peerDependenciesMeta"` in [package.json](https://docs.npmjs.com/cli/v8/configuring-npm/package-json#peerdependenciesmeta)
+ /// if `optional_peer_dependencies_len` is > 0, then instead of alphabetical, the first N items of `peer_dependencies` are optional
+ optional_peer_dependencies_len: u32 = 0,
+
+ man_dir: ExternalString = ExternalString{},
+
+ /// can be empty!
+ /// When empty, it means that the tarball URL can be inferred
+ tarball_url: ExternalString = ExternalString{},
+
+ unpacked_size: u32 = 0,
+ file_count: u32 = 0,
+
+ /// `"os"` field in package.json
+ os: OperatingSystem = OperatingSystem.all,
+ /// `"cpu"` field in package.json
+ cpu: Architecture = Architecture.all,
+};
+
+pub const NpmPackage = extern struct {
+
+ /// HTTP response headers
+ last_modified: String = String{},
+ etag: String = String{},
+
+ /// "modified" in the JSON
+ modified: String = String{},
+ public_max_age: u32 = 0,
+
+ name: ExternalString = ExternalString{},
+
+ releases: ExternVersionMap = ExternVersionMap{},
+ prereleases: ExternVersionMap = ExternVersionMap{},
+ dist_tags: DistTagMap = DistTagMap{},
+
+ versions_buf: VersionSlice = VersionSlice{},
+ string_lists_buf: ExternalStringList = ExternalStringList{},
+ string_buf: BigExternalString = BigExternalString{},
+};
+
+pub const PackageManifest = struct {
+ pkg: NpmPackage = NpmPackage{},
+
+ string_buf: []const u8 = &[_]u8{},
+ versions: []const Semver.Version = &[_]Semver.Version{},
+ external_strings: []const ExternalString = &[_]ExternalString{},
+ // We store this in a separate buffer so that we can dedupe contiguous identical versions without an extra pass
+ external_strings_for_versions: []const ExternalString = &[_]ExternalString{},
+ package_versions: []const PackageVersion = &[_]PackageVersion{},
+
+ pub inline fn name(this: *const PackageManifest) string {
+ return this.pkg.name.slice(this.string_buf);
+ }
+
+ pub const Serializer = struct {
+ pub const version = "bun-npm-manifest-cache-v0.0.1\n";
+ const header_bytes: string = "#!/usr/bin/env bun\n" ++ version;
+
+ pub const sizes = blk: {
+ // skip name
+ const fields = std.meta.fields(Npm.PackageManifest);
+
+ const Data = struct {
+ size: usize,
+ name: []const u8,
+ alignment: usize,
+ };
+ var data: [fields.len]Data = undefined;
+ for (fields) |field_info, i| {
+ data[i] = .{
+ .size = @sizeOf(field_info.field_type),
+ .name = field_info.name,
+ .alignment = if (@sizeOf(field_info.field_type) == 0) 1 else field_info.alignment,
+ };
+ }
+ const Sort = struct {
+ fn lessThan(trash: *i32, lhs: Data, rhs: Data) bool {
+ _ = trash;
+ return lhs.alignment > rhs.alignment;
+ }
+ };
+ var trash: i32 = undefined; // workaround for stage1 compiler bug
+ std.sort.sort(Data, &data, &trash, Sort.lessThan);
+ var sizes_bytes: [fields.len]usize = undefined;
+ var names: [fields.len][]const u8 = undefined;
+ for (data) |elem, i| {
+ sizes_bytes[i] = elem.size;
+ names[i] = elem.name;
+ }
+ break :blk .{
+ .bytes = sizes_bytes,
+ .fields = names,
+ };
+ };
+
+ pub fn writeArray(comptime Writer: type, writer: Writer, comptime Type: type, array: []const Type, pos: *u64) !void {
+ const bytes = std.mem.sliceAsBytes(array);
+ if (bytes.len == 0) {
+ try writer.writeIntNative(u64, 0);
+ pos.* += 8;
+ return;
+ }
+
+ try writer.writeIntNative(u64, bytes.len);
+ pos.* += 8;
+ pos.* += try Aligner.write(Type, Writer, writer, pos.*);
+
+ try writer.writeAll(
+ bytes,
+ );
+ pos.* += bytes.len;
+ }
+
+ pub fn readArray(stream: *std.io.FixedBufferStream([]const u8), comptime Type: type) ![]const Type {
+ var reader = stream.reader();
+ const byte_len = try reader.readIntNative(u64);
+ if (byte_len == 0) {
+ return &[_]Type{};
+ }
+
+ stream.pos += Aligner.skipAmount(Type, stream.pos);
+ const result_bytes = stream.buffer[stream.pos..][0..byte_len];
+ const result = @ptrCast([*]const Type, @alignCast(@alignOf([*]const Type), result_bytes.ptr))[0 .. result_bytes.len / @sizeOf(Type)];
+ stream.pos += result_bytes.len;
+ return result;
+ }
+
+ pub fn write(this: *const PackageManifest, comptime Writer: type, writer: Writer) !void {
+ var pos: u64 = 0;
+ try writer.writeAll(header_bytes);
+ pos += header_bytes.len;
+
+ inline for (sizes.fields) |field_name| {
+ if (comptime strings.eqlComptime(field_name, "pkg")) {
+ const bytes = std.mem.asBytes(&this.pkg);
+ pos += try Aligner.write(NpmPackage, Writer, writer, pos);
+ try writer.writeAll(
+ bytes,
+ );
+ pos += bytes.len;
+ } else {
+ const field = @field(this, field_name);
+ try writeArray(Writer, writer, std.meta.Child(@TypeOf(field)), field, &pos);
+ }
+ }
+ }
+
+ pub fn save(this: *const PackageManifest, tmpdir: std.fs.Dir, cache_dir: std.fs.Dir) !void {
+ const file_id = std.hash.Wyhash.hash(0, this.name());
+ var dest_path_buf: [512 + 64]u8 = undefined;
+ var out_path_buf: ["-18446744073709551615".len + ".npm".len + 1]u8 = undefined;
+ var dest_path_stream = std.io.fixedBufferStream(&dest_path_buf);
+ var dest_path_stream_writer = dest_path_stream.writer();
+ try dest_path_stream_writer.print("{x}.npm-{x}", .{ file_id, @maximum(std.time.milliTimestamp(), 0) });
+ try dest_path_stream_writer.writeByte(0);
+ var tmp_path: [:0]u8 = dest_path_buf[0 .. dest_path_stream.pos - 1 :0];
+ {
+ var tmpfile = try tmpdir.createFileZ(tmp_path, .{
+ .truncate = true,
+ });
+ var writer = tmpfile.writer();
+ try Serializer.write(this, @TypeOf(writer), writer);
+ std.os.fdatasync(tmpfile.handle) catch {};
+ tmpfile.close();
+ }
+
+ var out_path = std.fmt.bufPrintZ(&out_path_buf, "{x}.npm", .{file_id}) catch unreachable;
+ try std.os.renameatZ(tmpdir.fd, tmp_path, cache_dir.fd, out_path);
+ }
+
+ pub fn load(allocator: *std.mem.Allocator, cache_dir: std.fs.Dir, package_name: string) !?PackageManifest {
+ const file_id = std.hash.Wyhash.hash(0, package_name);
+ var file_path_buf: [512 + 64]u8 = undefined;
+ var file_path = try std.fmt.bufPrintZ(&file_path_buf, "{x}.npm", .{file_id});
+ var cache_file = cache_dir.openFileZ(
+ file_path,
+ .{
+ .read = true,
+ },
+ ) catch return null;
+ var timer: std.time.Timer = undefined;
+ if (PackageManager.verbose_install) {
+ timer = std.time.Timer.start() catch @panic("timer fail");
+ }
+ defer cache_file.close();
+ var bytes = try cache_file.readToEndAlloc(allocator, std.math.maxInt(u32));
+ errdefer allocator.free(bytes);
+ if (bytes.len < header_bytes.len) return null;
+ const result = try readAll(bytes);
+ if (PackageManager.verbose_install) {
+ Output.prettyError("\n ", .{});
+ Output.printTimer(&timer);
+ Output.prettyErrorln("<d> [cache hit] {s}<r>", .{package_name});
+ }
+ return result;
+ }
+
+ pub fn readAll(bytes: []const u8) !PackageManifest {
+ if (!strings.eqlComptime(bytes[0..header_bytes.len], header_bytes)) {
+ return error.InvalidPackageManifest;
+ }
+ var pkg_stream = std.io.fixedBufferStream(bytes);
+ pkg_stream.pos = header_bytes.len;
+ var package_manifest = PackageManifest{};
+
+ inline for (sizes.fields) |field_name| {
+ if (comptime strings.eqlComptime(field_name, "pkg")) {
+ pkg_stream.pos = std.mem.alignForward(pkg_stream.pos, @alignOf(Npm.NpmPackage));
+ var reader = pkg_stream.reader();
+ package_manifest.pkg = try reader.readStruct(NpmPackage);
+ } else {
+ @field(package_manifest, field_name) = try readArray(
+ &pkg_stream,
+ std.meta.Child(@TypeOf(@field(package_manifest, field_name))),
+ );
+ }
+ }
+
+ return package_manifest;
+ }
+ };
+
+ pub fn str(self: *const PackageManifest, external: ExternalString) string {
+ return external.slice(self.string_buf);
+ }
+
+ pub fn reportSize(this: *const PackageManifest) void {
+ const versions = std.mem.sliceAsBytes(this.versions);
+ const external_strings = std.mem.sliceAsBytes(this.external_strings);
+ const package_versions = std.mem.sliceAsBytes(this.package_versions);
+ const string_buf = std.mem.sliceAsBytes(this.string_buf);
+
+ Output.prettyErrorln(
+ \\ Versions count: {d}
+ \\ External Strings count: {d}
+ \\ Package Versions count: {d}
+ \\
+ \\ Bytes:
+ \\
+ \\ Versions: {d}
+ \\ External: {d}
+ \\ Packages: {d}
+ \\ Strings: {d}
+ \\ Total: {d}
+ , .{
+ this.versions.len,
+ this.external_strings.len,
+ this.package_versions.len,
+
+ std.mem.sliceAsBytes(this.versions).len,
+ std.mem.sliceAsBytes(this.external_strings).len,
+ std.mem.sliceAsBytes(this.package_versions).len,
+ std.mem.sliceAsBytes(this.string_buf).len,
+ std.mem.sliceAsBytes(this.versions).len +
+ std.mem.sliceAsBytes(this.external_strings).len +
+ std.mem.sliceAsBytes(this.package_versions).len +
+ std.mem.sliceAsBytes(this.string_buf).len,
+ });
+ Output.flush();
+ }
+
+ pub const FindResult = struct {
+ version: Semver.Version,
+ package: *const PackageVersion,
+ };
+
+ pub fn findByString(this: *const PackageManifest, version: string) ?FindResult {
+ switch (Dependency.Version.Tag.infer(version)) {
+ .npm => {
+ const group = Semver.Query.parse(default_allocator, version, SlicedString.init(
+ version,
+ version,
+ )) catch return null;
+ return this.findBestVersion(group);
+ },
+ .dist_tag => {
+ return this.findByDistTag(version);
+ },
+ else => return null,
+ }
+ }
+
+ pub fn findByVersion(this: *const PackageManifest, version: Semver.Version) ?FindResult {
+ const list = if (!version.tag.hasPre()) this.pkg.releases else this.pkg.prereleases;
+ const values = list.values.get(this.package_versions);
+ const keys = list.keys.get(this.versions);
+ const index = list.findKeyIndex(this.versions, version) orelse return null;
+ return FindResult{
+ // Be sure to use the struct from the list in the NpmPackage
+ // That is the one we can correctly recover the original version string for
+ .version = keys[index],
+ .package = &values[index],
+ };
+ }
+
+ pub fn findByDistTag(this: *const PackageManifest, tag: string) ?FindResult {
+ const versions = this.pkg.dist_tags.versions.get(this.versions);
+ for (this.pkg.dist_tags.tags.get(this.external_strings)) |tag_str, i| {
+ if (strings.eql(tag_str.slice(this.string_buf), tag)) {
+ return this.findByVersion(versions[i]);
+ }
+ }
+
+ return null;
+ }
+
+ pub fn findBestVersion(this: *const PackageManifest, group: Semver.Query.Group) ?FindResult {
+ const left = group.head.head.range.left;
+ // Fast path: exact version
+ if (left.op == .eql) {
+ return this.findByVersion(left.version);
+ }
+
+ const releases = this.pkg.releases.keys.get(this.versions);
+
+ if (group.flags.isSet(Semver.Query.Group.Flags.pre)) {
+ const prereleases = this.pkg.prereleases.keys.get(this.versions);
+ var i = prereleases.len;
+ while (i > 0) : (i -= 1) {
+ const version = prereleases[i - 1];
+ const packages = this.pkg.prereleases.values.get(this.package_versions);
+
+ if (group.satisfies(version)) {
+ return FindResult{ .version = version, .package = &packages[i - 1] };
+ }
+ }
+ }
+
+ {
+ var i = releases.len;
+ // // For now, this is the dumb way
+ while (i > 0) : (i -= 1) {
+ const version = releases[i - 1];
+ const packages = this.pkg.releases.values.get(this.package_versions);
+
+ if (group.satisfies(version)) {
+ return FindResult{ .version = version, .package = &packages[i - 1] };
+ }
+ }
+ }
+
+ return null;
+ }
+
+ const ExternalStringMapDeduper = std.HashMap(u64, ExternalStringList, IdentityContext(u64), 80);
+
+ threadlocal var string_pool_: String.Builder.StringPool = undefined;
+ threadlocal var string_pool_loaded: bool = false;
+
+ threadlocal var external_string_maps_: ExternalStringMapDeduper = undefined;
+ threadlocal var external_string_maps_loaded: bool = false;
+
+ threadlocal var optional_peer_dep_names_: std.ArrayList(u64) = undefined;
+ threadlocal var optional_peer_dep_names_loaded: bool = false;
+
+ /// This parses [Abbreviated metadata](https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#abbreviated-metadata-format)
+ pub fn parse(
+ allocator: *std.mem.Allocator,
+ log: *logger.Log,
+ json_buffer: []const u8,
+ expected_name: []const u8,
+ last_modified: []const u8,
+ etag: []const u8,
+ public_max_age: u32,
+ ) !?PackageManifest {
+ const source = logger.Source.initPathString(expected_name, json_buffer);
+ initializeStore();
+ const json = json_parser.ParseJSON(&source, log, allocator) catch |err| {
+ return null;
+ };
+
+ if (json.asProperty("error")) |error_q| {
+ if (error_q.expr.asString(allocator)) |err| {
+ log.addErrorFmt(&source, logger.Loc.Empty, allocator, "npm error: {s}", .{err}) catch unreachable;
+ return null;
+ }
+ }
+
+ var result = PackageManifest{};
+
+ if (!string_pool_loaded) {
+ string_pool_ = String.Builder.StringPool.init(default_allocator);
+ string_pool_loaded = true;
+ }
+
+ if (!external_string_maps_loaded) {
+ external_string_maps_ = ExternalStringMapDeduper.initContext(default_allocator, .{});
+ external_string_maps_loaded = true;
+ }
+
+ if (!optional_peer_dep_names_loaded) {
+ optional_peer_dep_names_ = std.ArrayList(u64).init(default_allocator);
+ optional_peer_dep_names_loaded = true;
+ }
+
+ var string_pool = string_pool_;
+ string_pool.clearRetainingCapacity();
+ var external_string_maps = external_string_maps_;
+ external_string_maps.clearRetainingCapacity();
+ var optional_peer_dep_names = optional_peer_dep_names_;
+ optional_peer_dep_names.clearRetainingCapacity();
+
+ defer string_pool_ = string_pool;
+ defer external_string_maps_ = external_string_maps;
+ defer optional_peer_dep_names_ = optional_peer_dep_names;
+
+ var string_builder = String.Builder{
+ .string_pool = string_pool,
+ };
+
+ if (json.asProperty("name")) |name_q| {
+ const field = name_q.expr.asString(allocator) orelse return null;
+
+ if (!strings.eql(field, expected_name)) {
+ Output.panic("<r>internal: <red>package name mismatch<r> expected <b>\"{s}\"<r> but received <red>\"{s}\"<r>", .{ expected_name, field });
+ return null;
+ }
+
+ string_builder.count(field);
+ }
+
+ if (json.asProperty("modified")) |name_q| {
+ const field = name_q.expr.asString(allocator) orelse return null;
+
+ string_builder.count(field);
+ }
+
+ const DependencyGroup = struct { prop: string, field: string };
+ const dependency_groups = comptime [_]DependencyGroup{
+ .{ .prop = "dependencies", .field = "dependencies" },
+ .{ .prop = "optionalDependencies", .field = "optional_dependencies" },
+ .{ .prop = "peerDependencies", .field = "peer_dependencies" },
+ };
+
+ var release_versions_len: usize = 0;
+ var pre_versions_len: usize = 0;
+ var dependency_sum: usize = 0;
+ var extern_string_count: usize = 0;
+ get_versions: {
+ if (json.asProperty("versions")) |versions_q| {
+ if (versions_q.expr.data != .e_object) break :get_versions;
+
+ const versions = versions_q.expr.data.e_object.properties;
+ for (versions) |prop| {
+ const version_name = prop.key.?.asString(allocator) orelse continue;
+
+ if (std.mem.indexOfScalar(u8, version_name, '-') != null) {
+ pre_versions_len += 1;
+ extern_string_count += 1;
+ } else {
+ extern_string_count += @as(usize, @boolToInt(std.mem.indexOfScalar(u8, version_name, '+') != null));
+ release_versions_len += 1;
+ }
+
+ string_builder.count(version_name);
+
+ bin: {
+ if (prop.value.?.asProperty("bin")) |bin| {
+ switch (bin.expr.data) {
+ .e_object => |obj| {
+ if (obj.properties.len > 0) {
+ string_builder.count(obj.properties[0].key.?.asString(allocator) orelse break :bin);
+ string_builder.count(obj.properties[0].value.?.asString(allocator) orelse break :bin);
+ }
+ },
+ .e_string => |str| {
+ if (bin.expr.asString(allocator)) |str_| {
+ string_builder.count(str_);
+ break :bin;
+ }
+ },
+ else => {},
+ }
+ }
+
+ if (prop.value.?.asProperty("directories")) |dirs| {
+ if (dirs.expr.asProperty("bin")) |bin_prop| {
+ if (bin_prop.expr.asString(allocator)) |str_| {
+ string_builder.count(str_);
+ break :bin;
+ }
+ }
+ }
+ }
+
+ inline for (dependency_groups) |pair| {
+ if (prop.value.?.asProperty(pair.prop)) |versioned_deps| {
+ if (versioned_deps.expr.data == .e_object) {
+ dependency_sum += versioned_deps.expr.data.e_object.properties.len;
+ const properties = versioned_deps.expr.data.e_object.properties;
+ for (properties) |property| {
+ if (property.key.?.asString(allocator)) |key| {
+ string_builder.count(key);
+ string_builder.count(property.value.?.asString(allocator) orelse "");
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ extern_string_count += dependency_sum;
+
+ var dist_tags_count: usize = 0;
+ if (json.asProperty("dist-tags")) |dist| {
+ if (dist.expr.data == .e_object) {
+ const tags = dist.expr.data.e_object.properties;
+ for (tags) |tag| {
+ if (tag.key.?.asString(allocator)) |key| {
+ string_builder.count(key);
+ extern_string_count += 2;
+
+ string_builder.count((tag.value.?.asString(allocator) orelse ""));
+ dist_tags_count += 1;
+ }
+ }
+ }
+ }
+
+ if (last_modified.len > 0) {
+ string_builder.count(last_modified);
+ }
+
+ if (etag.len > 0) {
+ string_builder.count(etag);
+ }
+
+ var versioned_packages = try allocator.allocAdvanced(PackageVersion, null, release_versions_len + pre_versions_len, .exact);
+ var all_semver_versions = try allocator.allocAdvanced(Semver.Version, null, release_versions_len + pre_versions_len + dist_tags_count, .exact);
+ var all_extern_strings = try allocator.allocAdvanced(ExternalString, null, extern_string_count, .exact);
+ var version_extern_strings = try allocator.allocAdvanced(ExternalString, null, dependency_sum, .exact);
+
+ if (versioned_packages.len > 0) {
+ var versioned_packages_bytes = std.mem.sliceAsBytes(versioned_packages);
+ @memset(versioned_packages_bytes.ptr, 0, versioned_packages_bytes.len);
+ }
+ if (all_semver_versions.len > 0) {
+ var all_semver_versions_bytes = std.mem.sliceAsBytes(all_semver_versions);
+ @memset(all_semver_versions_bytes.ptr, 0, all_semver_versions_bytes.len);
+ }
+ if (all_extern_strings.len > 0) {
+ var all_extern_strings_bytes = std.mem.sliceAsBytes(all_extern_strings);
+ @memset(all_extern_strings_bytes.ptr, 0, all_extern_strings_bytes.len);
+ }
+ if (version_extern_strings.len > 0) {
+ var version_extern_strings_bytes = std.mem.sliceAsBytes(version_extern_strings);
+ @memset(version_extern_strings_bytes.ptr, 0, version_extern_strings_bytes.len);
+ }
+
+ var versioned_package_releases = versioned_packages[0..release_versions_len];
+ var all_versioned_package_releases = versioned_package_releases;
+ var versioned_package_prereleases = versioned_packages[release_versions_len..][0..pre_versions_len];
+ var all_versioned_package_prereleases = versioned_package_prereleases;
+ var _versions_open = all_semver_versions;
+ var all_release_versions = _versions_open[0..release_versions_len];
+ _versions_open = _versions_open[release_versions_len..];
+ var all_prerelease_versions = _versions_open[0..pre_versions_len];
+ _versions_open = _versions_open[pre_versions_len..];
+ var dist_tag_versions = _versions_open[0..dist_tags_count];
+ var release_versions = all_release_versions;
+ var prerelease_versions = all_prerelease_versions;
+
+ var extern_strings = all_extern_strings;
+ string_builder.cap += (string_builder.cap % 64) + 64;
+ string_builder.cap *= 2;
+
+ try string_builder.allocate(allocator);
+
+ var string_buf: string = "";
+ if (string_builder.ptr) |ptr| {
+ // 0 it out for better determinism
+ @memset(ptr, 0, string_builder.cap);
+
+ string_buf = ptr[0..string_builder.cap];
+ }
+
+ if (json.asProperty("name")) |name_q| {
+ const field = name_q.expr.asString(allocator) orelse return null;
+ result.pkg.name = string_builder.append(ExternalString, field);
+ }
+
+ var string_slice = SlicedString.init(string_buf, string_buf);
+ get_versions: {
+ if (json.asProperty("versions")) |versions_q| {
+ if (versions_q.expr.data != .e_object) break :get_versions;
+
+ const versions = versions_q.expr.data.e_object.properties;
+
+ var all_dependency_names_and_values = all_extern_strings[0..dependency_sum];
+
+ // versions change more often than names
+ // so names go last because we are better able to dedupe at the end
+ var dependency_values = version_extern_strings;
+ var dependency_names = all_dependency_names_and_values;
+
+ var version_string__: String = String{};
+ for (versions) |prop, version_i| {
+ const version_name = prop.key.?.asString(allocator) orelse continue;
+
+ var sliced_string = SlicedString.init(version_name, version_name);
+
+ // We only need to copy the version tags if it's a pre/post
+ if (std.mem.indexOfAny(u8, version_name, "-+") != null) {
+ version_string__ = string_builder.append(String, version_name);
+ sliced_string = version_string__.sliced(string_buf);
+ }
+
+ const parsed_version = Semver.Version.parse(sliced_string, allocator);
+ std.debug.assert(parsed_version.valid);
+
+ if (!parsed_version.valid) {
+ log.addErrorFmt(&source, prop.value.?.loc, allocator, "Failed to parse dependency {s}", .{version_name}) catch unreachable;
+ continue;
+ }
+
+ var package_version = PackageVersion{};
+
+ if (prop.value.?.asProperty("cpu")) |cpu| {
+ package_version.cpu = Architecture.all;
+
+ switch (cpu.expr.data) {
+ .e_array => |arr| {
+ if (arr.items.len > 0) {
+ package_version.cpu = Architecture.none;
+ for (arr.items) |item| {
+ if (item.asString(allocator)) |cpu_str_| {
+ package_version.cpu = package_version.cpu.apply(cpu_str_);
+ }
+ }
+ }
+ },
+ .e_string => |str| {
+ package_version.cpu = Architecture.apply(Architecture.none, str.utf8);
+ },
+ else => {},
+ }
+ }
+
+ if (prop.value.?.asProperty("os")) |os| {
+ package_version.os = OperatingSystem.all;
+
+ switch (os.expr.data) {
+ .e_array => |arr| {
+ if (arr.items.len > 0) {
+ package_version.os = OperatingSystem.none;
+ for (arr.items) |item| {
+ if (item.asString(allocator)) |cpu_str_| {
+ package_version.os = package_version.os.apply(cpu_str_);
+ }
+ }
+ }
+ },
+ .e_string => |str| {
+ package_version.os = OperatingSystem.apply(OperatingSystem.none, str.utf8);
+ },
+ else => {},
+ }
+ }
+
+ bin: {
+ if (prop.value.?.asProperty("bin")) |bin| {
+ switch (bin.expr.data) {
+ .e_object => |obj| {
+ if (obj.properties.len > 0) {
+ const bin_name = obj.properties[0].key.?.asString(allocator) orelse break :bin;
+ const value = obj.properties[0].value.?.asString(allocator) orelse break :bin;
+ // For now, we're only supporting the first bin
+ // We'll fix that later
+ package_version.bin = Bin{
+ .tag = Bin.Tag.named_file,
+ .value = .{
+ .named_file = .{
+ string_builder.append(String, bin_name),
+ string_builder.append(String, value),
+ },
+ },
+ };
+ break :bin;
+
+ // for (arr.items) |item| {
+ // if (item.asString(allocator)) |bin_str_| {
+ // package_version.bin =
+ // }
+ // }
+ }
+ },
+ .e_string => |str| {
+ if (str.utf8.len > 0) {
+ package_version.bin = Bin{
+ .tag = Bin.Tag.file,
+ .value = .{
+ .file = string_builder.append(String, str.utf8),
+ },
+ };
+ break :bin;
+ }
+ },
+ else => {},
+ }
+ }
+
+ if (prop.value.?.asProperty("directories")) |dirs| {
+ if (dirs.expr.asProperty("bin")) |bin_prop| {
+ if (bin_prop.expr.asString(allocator)) |str_| {
+ if (str_.len > 0) {
+ package_version.bin = Bin{
+ .tag = Bin.Tag.dir,
+ .value = .{
+ .dir = string_builder.append(String, str_),
+ },
+ };
+ break :bin;
+ }
+ }
+ }
+ }
+ }
+
+ integrity: {
+ if (prop.value.?.asProperty("dist")) |dist| {
+ if (dist.expr.data == .e_object) {
+ if (dist.expr.asProperty("fileCount")) |file_count_| {
+ if (file_count_.expr.data == .e_number) {
+ package_version.file_count = file_count_.expr.data.e_number.toU32();
+ }
+ }
+
+ if (dist.expr.asProperty("unpackedSize")) |file_count_| {
+ if (file_count_.expr.data == .e_number) {
+ package_version.unpacked_size = file_count_.expr.data.e_number.toU32();
+ }
+ }
+
+ if (dist.expr.asProperty("integrity")) |shasum| {
+ if (shasum.expr.asString(allocator)) |shasum_str| {
+ package_version.integrity = Integrity.parse(shasum_str) catch Integrity{};
+ if (package_version.integrity.tag.isSupported()) break :integrity;
+ }
+ }
+
+ if (dist.expr.asProperty("shasum")) |shasum| {
+ if (shasum.expr.asString(allocator)) |shasum_str| {
+ package_version.integrity = Integrity.parseSHASum(shasum_str) catch Integrity{};
+ }
+ }
+ }
+ }
+ }
+
+ var peer_dependency_len: usize = 0;
+
+ inline for (dependency_groups) |pair| {
+ if (prop.value.?.asProperty(comptime pair.prop)) |versioned_deps| {
+ const items = versioned_deps.expr.data.e_object.properties;
+ var count = items.len;
+
+ var this_names = dependency_names[0..count];
+ var this_versions = dependency_values[0..count];
+
+ var name_hasher = std.hash.Wyhash.init(0);
+ var version_hasher = std.hash.Wyhash.init(0);
+
+ const is_peer = comptime strings.eqlComptime(pair.prop, "peerDependencies");
+
+ if (comptime is_peer) {
+ optional_peer_dep_names.clearRetainingCapacity();
+
+ if (prop.value.?.asProperty("peerDependenciesMeta")) |meta| {
+ if (meta.expr.data == .e_object) {
+ const meta_props = meta.expr.data.e_object.properties;
+ try optional_peer_dep_names.ensureUnusedCapacity(meta_props.len);
+ for (meta_props) |meta_prop| {
+ if (meta_prop.value.?.asProperty("optional")) |optional| {
+ if (optional.expr.data != .e_boolean or !optional.expr.data.e_boolean.value) {
+ continue;
+ }
+
+ optional_peer_dep_names.appendAssumeCapacity(String.Builder.stringHash(meta_prop.key.?.asString(allocator) orelse unreachable));
+ }
+ }
+ }
+ }
+ }
+
+ var i: usize = 0;
+
+ for (items) |item| {
+ const name_str = item.key.?.asString(allocator) orelse if (comptime Environment.allow_assert) unreachable else continue;
+ const version_str = item.value.?.asString(allocator) orelse if (comptime Environment.allow_assert) unreachable else continue;
+
+ this_names[i] = string_builder.append(ExternalString, name_str);
+ this_versions[i] = string_builder.append(ExternalString, version_str);
+
+ if (comptime is_peer) {
+ if (std.mem.indexOfScalar(u64, optional_peer_dep_names.items, this_names[i].hash) != null) {
+ // For optional peer dependencies, we store a length instead of a whole separate array
+ // To make that work, we have to move optional peer dependencies to the front of the array
+ //
+ if (peer_dependency_len != i) {
+ const current_name = this_names[i];
+ this_names[i] = this_names[peer_dependency_len];
+ this_names[peer_dependency_len] = current_name;
+
+ const current_version = this_versions[i];
+ this_versions[i] = this_versions[peer_dependency_len];
+ this_versions[peer_dependency_len] = current_version;
+
+ peer_dependency_len += 1;
+ }
+ }
+
+ if (optional_peer_dep_names.items.len == 0) {
+ const names_hash_bytes = @bitCast([8]u8, this_names[i].hash);
+ name_hasher.update(&names_hash_bytes);
+ const versions_hash_bytes = @bitCast([8]u8, this_versions[i].hash);
+ version_hasher.update(&versions_hash_bytes);
+ }
+ } else {
+ const names_hash_bytes = @bitCast([8]u8, this_names[i].hash);
+ name_hasher.update(&names_hash_bytes);
+ const versions_hash_bytes = @bitCast([8]u8, this_versions[i].hash);
+ version_hasher.update(&versions_hash_bytes);
+ }
+
+ i += 1;
+ }
+
+ count = i;
+
+ var name_list = ExternalStringList.init(all_extern_strings, this_names);
+ var version_list = ExternalStringList.init(version_extern_strings, this_versions);
+
+ if (comptime is_peer) {
+ package_version.optional_peer_dependencies_len = @truncate(u32, peer_dependency_len);
+ }
+
+ if (count > 0 and
+ ((comptime !is_peer) or
+ optional_peer_dep_names.items.len == 0))
+ {
+ const name_map_hash = name_hasher.final();
+ const version_map_hash = version_hasher.final();
+
+ var name_entry = try external_string_maps.getOrPut(name_map_hash);
+ if (name_entry.found_existing) {
+ name_list = name_entry.value_ptr.*;
+ this_names = name_list.mut(all_extern_strings);
+ } else {
+ name_entry.value_ptr.* = name_list;
+ dependency_names = dependency_names[count..];
+ }
+
+ var version_entry = try external_string_maps.getOrPut(version_map_hash);
+ if (version_entry.found_existing) {
+ version_list = version_entry.value_ptr.*;
+ this_versions = version_list.mut(version_extern_strings);
+ } else {
+ version_entry.value_ptr.* = version_list;
+ dependency_values = dependency_values[count..];
+ }
+ }
+
+ if (comptime is_peer) {
+ if (optional_peer_dep_names.items.len > 0) {
+ dependency_names = dependency_names[count..];
+ dependency_values = dependency_values[count..];
+ }
+ }
+
+ @field(package_version, pair.field) = ExternalStringMap{
+ .name = name_list,
+ .value = version_list,
+ };
+
+ if (comptime Environment.allow_assert) {
+ const dependencies_list = @field(package_version, pair.field);
+
+ std.debug.assert(dependencies_list.name.off < all_extern_strings.len);
+ std.debug.assert(dependencies_list.value.off < all_extern_strings.len);
+ std.debug.assert(dependencies_list.name.off + dependencies_list.name.len < all_extern_strings.len);
+ std.debug.assert(dependencies_list.value.off + dependencies_list.value.len < all_extern_strings.len);
+
+ std.debug.assert(std.meta.eql(dependencies_list.name.get(all_extern_strings), this_names));
+ std.debug.assert(std.meta.eql(dependencies_list.value.get(version_extern_strings), this_versions));
+ var j: usize = 0;
+ const name_dependencies = dependencies_list.name.get(all_extern_strings);
+
+ if (comptime is_peer) {
+ if (optional_peer_dep_names.items.len == 0) {
+ while (j < name_dependencies.len) : (j += 1) {
+ const dep_name = name_dependencies[j];
+ std.debug.assert(std.mem.eql(u8, dep_name.slice(string_buf), this_names[j].slice(string_buf)));
+ std.debug.assert(std.mem.eql(u8, dep_name.slice(string_buf), items[j].key.?.asString(allocator).?));
+ }
+
+ j = 0;
+ while (j < dependencies_list.value.len) : (j += 1) {
+ const dep_name = dependencies_list.value.get(version_extern_strings)[j];
+
+ std.debug.assert(std.mem.eql(u8, dep_name.slice(string_buf), this_versions[j].slice(string_buf)));
+ std.debug.assert(std.mem.eql(u8, dep_name.slice(string_buf), items[j].value.?.asString(allocator).?));
+ }
+ }
+ } else {
+ while (j < name_dependencies.len) : (j += 1) {
+ const dep_name = name_dependencies[j];
+ std.debug.assert(std.mem.eql(u8, dep_name.slice(string_buf), this_names[j].slice(string_buf)));
+ std.debug.assert(std.mem.eql(u8, dep_name.slice(string_buf), items[j].key.?.asString(allocator).?));
+ }
+
+ j = 0;
+ while (j < dependencies_list.value.len) : (j += 1) {
+ const dep_name = dependencies_list.value.get(version_extern_strings)[j];
+
+ std.debug.assert(std.mem.eql(u8, dep_name.slice(string_buf), this_versions[j].slice(string_buf)));
+ std.debug.assert(std.mem.eql(u8, dep_name.slice(string_buf), items[j].value.?.asString(allocator).?));
+ }
+ }
+ }
+ }
+ }
+
+ if (!parsed_version.version.tag.hasPre()) {
+ release_versions[0] = parsed_version.version;
+ versioned_package_releases[0] = package_version;
+ release_versions = release_versions[1..];
+ versioned_package_releases = versioned_package_releases[1..];
+ } else {
+ prerelease_versions[0] = parsed_version.version;
+ versioned_package_prereleases[0] = package_version;
+ prerelease_versions = prerelease_versions[1..];
+ versioned_package_prereleases = versioned_package_prereleases[1..];
+ }
+ }
+
+ extern_strings = all_extern_strings[all_dependency_names_and_values.len - dependency_names.len ..];
+ version_extern_strings = version_extern_strings[0 .. version_extern_strings.len - dependency_values.len];
+ }
+ }
+
+ if (json.asProperty("dist-tags")) |dist| {
+ if (dist.expr.data == .e_object) {
+ const tags = dist.expr.data.e_object.properties;
+ var extern_strings_slice = extern_strings[0..dist_tags_count];
+ var dist_tag_i: usize = 0;
+
+ for (tags) |tag, i| {
+ if (tag.key.?.asString(allocator)) |key| {
+ extern_strings_slice[dist_tag_i] = string_builder.append(ExternalString, key);
+
+ const version_name = tag.value.?.asString(allocator) orelse continue;
+
+ const dist_tag_value_literal = string_builder.append(ExternalString, version_name);
+ const dist_tag_value_literal_slice = dist_tag_value_literal.slice(string_buf);
+
+ const sliced_string = dist_tag_value_literal.value.sliced(string_buf);
+
+ dist_tag_versions[dist_tag_i] = Semver.Version.parse(sliced_string, allocator).version;
+ dist_tag_i += 1;
+ }
+ }
+
+ result.pkg.dist_tags = DistTagMap{
+ .tags = ExternalStringList.init(all_extern_strings, extern_strings_slice[0..dist_tag_i]),
+ .versions = VersionSlice.init(all_semver_versions, dist_tag_versions[0..dist_tag_i]),
+ };
+
+ if (comptime Environment.allow_assert) {
+ std.debug.assert(std.meta.eql(result.pkg.dist_tags.versions.get(all_semver_versions), dist_tag_versions[0..dist_tag_i]));
+ std.debug.assert(std.meta.eql(result.pkg.dist_tags.tags.get(all_extern_strings), extern_strings_slice[0..dist_tag_i]));
+ }
+
+ extern_strings = extern_strings[dist_tag_i..];
+ }
+ }
+
+ if (last_modified.len > 0) {
+ result.pkg.last_modified = string_builder.append(String, last_modified);
+ }
+
+ if (etag.len > 0) {
+ result.pkg.etag = string_builder.append(String, etag);
+ }
+
+ if (json.asProperty("modified")) |name_q| {
+ const field = name_q.expr.asString(allocator) orelse return null;
+
+ result.pkg.modified = string_builder.append(String, field);
+ }
+
+ result.pkg.releases.keys = VersionSlice.init(all_semver_versions, all_release_versions);
+ result.pkg.releases.values = PackageVersionList.init(versioned_packages, all_versioned_package_releases);
+
+ result.pkg.prereleases.keys = VersionSlice.init(all_semver_versions, all_prerelease_versions);
+ result.pkg.prereleases.values = PackageVersionList.init(versioned_packages, all_versioned_package_prereleases);
+
+ if (extern_strings.len > 0) {
+ all_extern_strings = all_extern_strings[0 .. all_extern_strings.len - extern_strings.len];
+ }
+
+ result.pkg.string_lists_buf.off = 0;
+ result.pkg.string_lists_buf.len = @truncate(u32, all_extern_strings.len);
+
+ result.pkg.versions_buf.off = 0;
+ result.pkg.versions_buf.len = @truncate(u32, all_semver_versions.len);
+
+ result.versions = all_semver_versions;
+ result.external_strings = all_extern_strings;
+ result.external_strings_for_versions = version_extern_strings;
+ result.package_versions = versioned_packages;
+ result.pkg.public_max_age = public_max_age;
+
+ if (string_builder.ptr) |ptr| {
+ result.string_buf = ptr[0..string_builder.len];
+ result.pkg.string_buf = BigExternalString{
+ .off = 0,
+ .len = @truncate(u32, string_builder.len),
+ .hash = 0,
+ };
+ }
+
+ return result;
+ }
+};
diff --git a/src/install/repository.zig b/src/install/repository.zig
new file mode 100644
index 000000000..f93402ea4
--- /dev/null
+++ b/src/install/repository.zig
@@ -0,0 +1,67 @@
+const PackageManager = @import("./install.zig").PackageManager;
+const Semver = @import("./semver.zig");
+const ExternalString = Semver.ExternalString;
+const String = Semver.String;
+const std = @import("std");
+const GitSHA = String;
+const string = @import("../string_types.zig").string;
+
+pub const Repository = extern struct {
+ owner: String = String{},
+ repo: String = String{},
+ committish: GitSHA = GitSHA{},
+
+ pub fn order(lhs: *const Repository, rhs: *const Repository, lhs_buf: []const u8, rhs_buf: []const u8) std.math.Order {
+ const owner_order = lhs.owner.order(&rhs.owner, lhs_buf, rhs_buf);
+ if (owner_order != .eq) return owner_order;
+ const repo_order = lhs.repo.order(&rhs.repo, lhs_buf, rhs_buf);
+ if (repo_order != .eq) return repo_order;
+
+ return lhs.committish.order(&rhs.committish, lhs_buf, rhs_buf);
+ }
+
+ pub fn count(this: Repository, buf: []const u8, comptime StringBuilder: type, builder: StringBuilder) void {
+ builder.count(this.owner.slice(buf));
+ builder.count(this.repo.slice(buf));
+ builder.count(this.committish.slice(buf));
+ }
+
+ pub fn clone(this: Repository, buf: []const u8, comptime StringBuilder: type, builder: StringBuilder) Repository {
+ return Repository{
+ .owner = builder.append(String, this.owner.slice(buf)),
+ .repo = builder.append(String, this.repo.slice(buf)),
+ .committish = builder.append(GitSHA, this.committish.slice(buf)),
+ };
+ }
+
+ pub fn eql(lhs: Repository, rhs: Repository, lhs_buf: []const u8, rhs_buf: []const u8) bool {
+ return lhs.owner.eql(rhs.owner, lhs_buf, rhs_buf) and
+ lhs.repo.eql(rhs.repo, lhs_buf, rhs_buf) and
+ lhs.committish.eql(rhs.committish, lhs_buf, rhs_buf);
+ }
+
+ pub fn formatAs(this: Repository, label: string, buf: []const u8, comptime layout: []const u8, opts: std.fmt.FormatOptions, writer: anytype) !void {
+ const formatter = Formatter{ .label = label, .repository = this, .buf = buf };
+ return try formatter.format(layout, opts, writer);
+ }
+
+ pub const Formatter = struct {
+ label: []const u8 = "",
+ buf: []const u8,
+ repository: Repository,
+ pub fn format(formatter: Formatter, comptime layout: []const u8, opts: std.fmt.FormatOptions, writer: anytype) !void {
+ std.debug.assert(formatter.label.len > 0);
+
+ try writer.writeAll(formatter.label);
+ try writer.writeAll(":");
+
+ try writer.writeAll(formatter.repository.owner.slice(formatter.buf));
+ try writer.writeAll(formatter.repository.repo.slice(formatter.buf));
+
+ if (!formatter.repository.committish.isEmpty()) {
+ try writer.writeAll("#");
+ try writer.writeAll(formatter.repository.committish.slice(formatter.buf));
+ }
+ }
+ };
+};
diff --git a/src/install/resolution.zig b/src/install/resolution.zig
new file mode 100644
index 000000000..ea75486a7
--- /dev/null
+++ b/src/install/resolution.zig
@@ -0,0 +1,296 @@
+const PackageManager = @import("./install.zig").PackageManager;
+const Semver = @import("./semver.zig");
+const ExternalString = Semver.ExternalString;
+const String = Semver.String;
+const std = @import("std");
+const Repository = @import("./repository.zig").Repository;
+const string = @import("../string_types.zig").string;
+const ExtractTarball = @import("./extract_tarball.zig");
+const strings = @import("../string_immutable.zig");
+
+pub const Resolution = extern struct {
+ tag: Tag = Tag.uninitialized,
+ value: Value = Value{ .uninitialized = .{} },
+
+ pub fn order(
+ lhs: *const Resolution,
+ rhs: *const Resolution,
+ lhs_buf: []const u8,
+ rhs_buf: []const u8,
+ ) std.math.Order {
+ if (lhs.tag != rhs.tag) {
+ return std.math.order(@enumToInt(lhs.tag), @enumToInt(rhs.tag));
+ }
+
+ return switch (lhs.tag) {
+ .npm => lhs.value.npm.order(rhs.value.npm, lhs_buf, rhs_buf),
+ .local_tarball => lhs.value.local_tarball.order(&rhs.value.local_tarball, lhs_buf, rhs_buf),
+ .git_ssh => lhs.value.git_ssh.order(&rhs.value.git_ssh, lhs_buf, rhs_buf),
+ .git_http => lhs.value.git_http.order(&rhs.value.git_http, lhs_buf, rhs_buf),
+ .folder => lhs.value.folder.order(&rhs.value.folder, lhs_buf, rhs_buf),
+ .remote_tarball => lhs.value.remote_tarball.order(&rhs.value.remote_tarball, lhs_buf, rhs_buf),
+ .workspace => lhs.value.workspace.order(&rhs.value.workspace, lhs_buf, rhs_buf),
+ .symlink => lhs.value.symlink.order(&rhs.value.symlink, lhs_buf, rhs_buf),
+ .single_file_module => lhs.value.single_file_module.order(&rhs.value.single_file_module, lhs_buf, rhs_buf),
+ .github => lhs.value.github.order(&rhs.value.github, lhs_buf, rhs_buf),
+ .gitlab => lhs.value.gitlab.order(&rhs.value.gitlab, lhs_buf, rhs_buf),
+ else => .eq,
+ };
+ }
+
+ pub fn count(this: *const Resolution, buf: []const u8, comptime Builder: type, builder: Builder) void {
+ switch (this.tag) {
+ .npm => this.value.npm.count(buf, Builder, builder),
+ .local_tarball => builder.count(this.value.local_tarball.slice(buf)),
+ .git_ssh => builder.count(this.value.git_ssh.slice(buf)),
+ .git_http => builder.count(this.value.git_http.slice(buf)),
+ .folder => builder.count(this.value.folder.slice(buf)),
+ .remote_tarball => builder.count(this.value.remote_tarball.slice(buf)),
+ .workspace => builder.count(this.value.workspace.slice(buf)),
+ .symlink => builder.count(this.value.symlink.slice(buf)),
+ .single_file_module => builder.count(this.value.single_file_module.slice(buf)),
+ .github => this.value.github.count(buf, Builder, builder),
+ .gitlab => this.value.gitlab.count(buf, Builder, builder),
+ else => {},
+ }
+ }
+
+ pub fn clone(this: Resolution, buf: []const u8, comptime Builder: type, builder: Builder) Resolution {
+ return Resolution{
+ .tag = this.tag,
+ .value = switch (this.tag) {
+ .npm => Resolution.Value{
+ .npm = this.value.npm.clone(buf, Builder, builder),
+ },
+ .local_tarball => Resolution.Value{
+ .local_tarball = builder.append(String, this.value.local_tarball.slice(buf)),
+ },
+ .git_ssh => Resolution.Value{
+ .git_ssh = builder.append(String, this.value.git_ssh.slice(buf)),
+ },
+ .git_http => Resolution.Value{
+ .git_http = builder.append(String, this.value.git_http.slice(buf)),
+ },
+ .folder => Resolution.Value{
+ .folder = builder.append(String, this.value.folder.slice(buf)),
+ },
+ .remote_tarball => Resolution.Value{
+ .remote_tarball = builder.append(String, this.value.remote_tarball.slice(buf)),
+ },
+ .workspace => Resolution.Value{
+ .workspace = builder.append(String, this.value.workspace.slice(buf)),
+ },
+ .symlink => Resolution.Value{
+ .symlink = builder.append(String, this.value.symlink.slice(buf)),
+ },
+ .single_file_module => Resolution.Value{
+ .single_file_module = builder.append(String, this.value.single_file_module.slice(buf)),
+ },
+ .github => Resolution.Value{
+ .github = this.value.github.clone(buf, Builder, builder),
+ },
+ .gitlab => Resolution.Value{
+ .gitlab = this.value.gitlab.clone(buf, Builder, builder),
+ },
+ .root => Resolution.Value{ .root = .{} },
+ else => unreachable,
+ },
+ };
+ }
+
+ pub fn fmt(this: Resolution, buf: []const u8) Formatter {
+ return Formatter{ .resolution = this, .buf = buf };
+ }
+
+ pub fn fmtURL(this: Resolution, options: *const PackageManager.Options, name: string, buf: []const u8) URLFormatter {
+ return URLFormatter{ .resolution = this, .buf = buf, .package_name = name, .options = options };
+ }
+
+ pub fn eql(
+ lhs: Resolution,
+ rhs: Resolution,
+ lhs_string_buf: []const u8,
+ rhs_string_buf: []const u8,
+ ) bool {
+ if (lhs.tag != rhs.tag) return false;
+
+ return switch (lhs.tag) {
+ .root => true,
+ .npm => lhs.value.npm.eql(rhs.value.npm),
+ .local_tarball => lhs.value.local_tarball.eql(
+ rhs.value.local_tarball,
+ lhs_string_buf,
+ rhs_string_buf,
+ ),
+ .git_ssh => lhs.value.git_ssh.eql(
+ rhs.value.git_ssh,
+ lhs_string_buf,
+ rhs_string_buf,
+ ),
+ .git_http => lhs.value.git_http.eql(
+ rhs.value.git_http,
+ lhs_string_buf,
+ rhs_string_buf,
+ ),
+ .folder => lhs.value.folder.eql(
+ rhs.value.folder,
+ lhs_string_buf,
+ rhs_string_buf,
+ ),
+ .remote_tarball => lhs.value.remote_tarball.eql(
+ rhs.value.remote_tarball,
+ lhs_string_buf,
+ rhs_string_buf,
+ ),
+ .workspace => lhs.value.workspace.eql(
+ rhs.value.workspace,
+ lhs_string_buf,
+ rhs_string_buf,
+ ),
+ .symlink => lhs.value.symlink.eql(
+ rhs.value.symlink,
+ lhs_string_buf,
+ rhs_string_buf,
+ ),
+ .single_file_module => lhs.value.single_file_module.eql(
+ rhs.value.single_file_module,
+ lhs_string_buf,
+ rhs_string_buf,
+ ),
+ .github => lhs.value.github.eql(
+ rhs.value.github,
+ lhs_string_buf,
+ rhs_string_buf,
+ ),
+ .gitlab => lhs.value.gitlab.eql(
+ rhs.value.gitlab,
+ lhs_string_buf,
+ rhs_string_buf,
+ ),
+ else => unreachable,
+ };
+ }
+
+ pub const URLFormatter = struct {
+ resolution: Resolution,
+ options: *const PackageManager.Options,
+ package_name: string,
+
+ buf: []const u8,
+
+ pub fn format(formatter: URLFormatter, comptime layout: []const u8, opts: std.fmt.FormatOptions, writer: anytype) !void {
+ switch (formatter.resolution.tag) {
+ .npm => try ExtractTarball.buildURLWithWriter(
+ @TypeOf(writer),
+ writer,
+ formatter.options.scope.url.href,
+ strings.StringOrTinyString.init(formatter.package_name),
+ formatter.resolution.value.npm,
+ formatter.buf,
+ ),
+ .local_tarball => try writer.writeAll(formatter.resolution.value.local_tarball.slice(formatter.buf)),
+ .git_ssh => try std.fmt.format(writer, "git+ssh://{s}", .{formatter.resolution.value.git_ssh.slice(formatter.buf)}),
+ .git_http => try std.fmt.format(writer, "https://{s}", .{formatter.resolution.value.git_http.slice(formatter.buf)}),
+ .folder => try writer.writeAll(formatter.resolution.value.folder.slice(formatter.buf)),
+ .remote_tarball => try writer.writeAll(formatter.resolution.value.remote_tarball.slice(formatter.buf)),
+ .github => try formatter.resolution.value.github.formatAs("github", formatter.buf, layout, opts, writer),
+ .gitlab => try formatter.resolution.value.gitlab.formatAs("gitlab", formatter.buf, layout, opts, writer),
+ .workspace => try std.fmt.format(writer, "workspace://{s}", .{formatter.resolution.value.workspace.slice(formatter.buf)}),
+ .symlink => try std.fmt.format(writer, "link://{s}", .{formatter.resolution.value.symlink.slice(formatter.buf)}),
+ .single_file_module => try std.fmt.format(writer, "link://{s}", .{formatter.resolution.value.symlink.slice(formatter.buf)}),
+ else => {},
+ }
+ }
+ };
+
+ pub const Formatter = struct {
+ resolution: Resolution,
+ buf: []const u8,
+
+ pub fn format(formatter: Formatter, comptime layout: []const u8, opts: std.fmt.FormatOptions, writer: anytype) !void {
+ switch (formatter.resolution.tag) {
+ .npm => try formatter.resolution.value.npm.fmt(formatter.buf).format(layout, opts, writer),
+ .local_tarball => try writer.writeAll(formatter.resolution.value.local_tarball.slice(formatter.buf)),
+ .git_ssh => try std.fmt.format(writer, "git+ssh://{s}", .{formatter.resolution.value.git_ssh.slice(formatter.buf)}),
+ .git_http => try std.fmt.format(writer, "https://{s}", .{formatter.resolution.value.git_http.slice(formatter.buf)}),
+ .folder => try writer.writeAll(formatter.resolution.value.folder.slice(formatter.buf)),
+ .remote_tarball => try writer.writeAll(formatter.resolution.value.remote_tarball.slice(formatter.buf)),
+ .github => try formatter.resolution.value.github.formatAs("github", formatter.buf, layout, opts, writer),
+ .gitlab => try formatter.resolution.value.gitlab.formatAs("gitlab", formatter.buf, layout, opts, writer),
+ .workspace => try std.fmt.format(writer, "workspace://{s}", .{formatter.resolution.value.workspace.slice(formatter.buf)}),
+ .symlink => try std.fmt.format(writer, "link://{s}", .{formatter.resolution.value.symlink.slice(formatter.buf)}),
+ .single_file_module => try std.fmt.format(writer, "link://{s}", .{formatter.resolution.value.symlink.slice(formatter.buf)}),
+ else => {},
+ }
+ }
+ };
+
+ pub const Value = extern union {
+ uninitialized: void,
+ root: void,
+
+ npm: Semver.Version,
+
+ /// File path to a tarball relative to the package root
+ local_tarball: String,
+
+ git_ssh: String,
+ git_http: String,
+
+ folder: String,
+
+ /// URL to a tarball.
+ remote_tarball: String,
+
+ github: Repository,
+ gitlab: Repository,
+
+ workspace: String,
+ symlink: String,
+
+ single_file_module: String,
+ };
+
+ pub const Tag = enum(u8) {
+ uninitialized = 0,
+ root = 1,
+ npm = 2,
+
+ folder = 4,
+
+ local_tarball = 8,
+
+ github = 16,
+ gitlab = 24,
+
+ git_ssh = 32,
+ git_http = 33,
+
+ symlink = 64,
+
+ workspace = 72,
+
+ remote_tarball = 80,
+
+ // This is a placeholder for now.
+ // But the intent is to eventually support URL imports at the package manager level.
+ //
+ // There are many ways to do it, but perhaps one way to be maximally compatible is just removing the protocol part of the URL.
+ //
+ // For example, Bun would transform this input:
+ //
+ // import _ from "https://github.com/lodash/lodash/lodash.min.js";
+ //
+ // Into:
+ //
+ // import _ from "github.com/lodash/lodash/lodash.min.js";
+ //
+ // github.com would become a package, with it's own package.json
+ // This is similar to how Go does it, except it wouldn't clone the whole repo.
+ // There are more efficient ways to do this, e.g. generate a .bun file just for all URL imports.
+ // There are questions of determinism, but perhaps that's what Integrity would do.
+ single_file_module = 100,
+
+ _,
+ };
+};
diff --git a/src/install/semver.zig b/src/install/semver.zig
new file mode 100644
index 000000000..c2f2b4f43
--- /dev/null
+++ b/src/install/semver.zig
@@ -0,0 +1,1962 @@
+usingnamespace @import("../global.zig");
+const std = @import("std");
+
+/// String type that stores either an offset/length into an external buffer or a string inline directly
+pub const String = extern struct {
+ pub const max_inline_len: usize = 8;
+ /// This is three different types of string.
+ /// 1. Empty string. If it's all zeroes, then it's an empty string.
+ /// 2. If the final bit is set, then it's a string that is stored inline.
+ /// 3. If the final bit is not set, then it's a string that is stored in an external buffer.
+ bytes: [max_inline_len]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
+
+ pub const Tag = enum {
+ small,
+ big,
+ };
+
+ pub inline fn fmt(self: *const String, buf: []const u8) Formatter {
+ return Formatter{
+ .buf = buf,
+ .str = self,
+ };
+ }
+
+ pub const Formatter = struct {
+ str: *const String,
+ buf: string,
+
+ pub fn format(formatter: Formatter, comptime layout: []const u8, opts: std.fmt.FormatOptions, writer: anytype) !void {
+ const str = formatter.str;
+ try writer.writeAll(str.slice(formatter.buf));
+ }
+ };
+
+ pub inline fn order(
+ lhs: *const String,
+ rhs: *const String,
+ lhs_buf: []const u8,
+ rhs_buf: []const u8,
+ ) std.math.Order {
+ return std.mem.order(u8, lhs.slice(lhs_buf), rhs.slice(rhs_buf));
+ }
+
+ pub inline fn canInline(buf: []const u8) bool {
+ return switch (buf.len) {
+ 0...max_inline_len - 1 => true,
+ max_inline_len => buf[max_inline_len - 1] & 0x80 == 0,
+ else => false,
+ };
+ }
+
+ pub inline fn isInline(this: String) bool {
+ return this.bytes[max_inline_len - 1] & 0x80 == 0;
+ }
+
+ pub inline fn sliced(this: *const String, buf: []const u8) SlicedString {
+ return if (this.isInline())
+ SlicedString.init(this.slice(""), this.slice(""))
+ else
+ SlicedString.init(buf, this.slice(buf));
+ }
+
+ pub fn init(
+ buf: string,
+ in: string,
+ ) String {
+ switch (in.len) {
+ 0 => return String{},
+ 1...max_inline_len => {
+ var bytes: [max_inline_len]u8 = [max_inline_len]u8{ 0, 0, 0, 0, 0, 0, 0, 0 };
+ comptime var i: usize = 0;
+
+ inline while (i < bytes.len) : (i += 1) {
+ if (i < in.len) bytes[i] = in[i];
+ }
+
+ // If they use the final bit, then it's a big string.
+ // This should only happen for non-ascii strings that are exactly 8 bytes.
+ // so that's an edge-case
+ if ((bytes[max_inline_len - 1]) >= 128) {
+ const ptr_ = Pointer.init(buf, in);
+ return @bitCast(String, @as(u64, @truncate(u63, @bitCast(u64, ptr_))) | 1 << 63);
+ }
+
+ return String{ .bytes = bytes };
+ },
+ else => {
+ const ptr_ = Pointer.init(buf, in);
+ return @bitCast(String, @as(u64, @truncate(u63, @bitCast(u64, ptr_))) | 1 << 63);
+ },
+ }
+ }
+
+ pub fn eql(this: String, that: String, this_buf: []const u8, that_buf: []const u8) bool {
+ if (this.isInline() and that.isInline()) {
+ return @bitCast(u64, this.bytes) == @bitCast(u64, that.bytes);
+ } else if (this.isInline() != that.isInline()) {
+ return false;
+ } else {
+ const a = this.ptr();
+ const b = that.ptr();
+ return strings.eql(this_buf[0..a.len], that_buf[0..b.len]);
+ }
+ }
+
+ pub inline fn isEmpty(this: String) bool {
+ return @bitCast(u64, this.bytes) == @as(u64, 0);
+ }
+
+ pub fn len(this: String) usize {
+ switch (this.bytes[max_inline_len - 1] & 128) {
+ 0 => {
+ // Edgecase: string that starts with a 0 byte will be considered empty.
+ switch (this.bytes[0]) {
+ 0 => {
+ return 0;
+ },
+ else => {
+ comptime var i: usize = 0;
+
+ inline while (i < this.bytes.len) : (i += 1) {
+ if (this.bytes[i] == 0) return i;
+ }
+
+ return 8;
+ },
+ }
+ },
+ else => {
+ const ptr_ = this.ptr();
+ return ptr_.len;
+ },
+ }
+ }
+
+ pub const Pointer = extern struct {
+ off: u32 = 0,
+ len: u32 = 0,
+
+ pub inline fn init(
+ buf: string,
+ in: string,
+ ) Pointer {
+ std.debug.assert(@ptrToInt(buf.ptr) <= @ptrToInt(in.ptr) and ((@ptrToInt(in.ptr) + in.len) <= (@ptrToInt(buf.ptr) + buf.len)));
+
+ return Pointer{
+ .off = @truncate(u32, @ptrToInt(in.ptr) - @ptrToInt(buf.ptr)),
+ .len = @truncate(u32, in.len),
+ };
+ }
+ };
+
+ pub inline fn ptr(this: String) Pointer {
+ return @bitCast(Pointer, @as(u64, @truncate(u63, @bitCast(u64, this))));
+ }
+
+ // String must be a pointer because we reference it as a slice. It will become a dead pointer if it is copied.
+ pub fn slice(this: *const String, buf: string) string {
+ switch (this.bytes[max_inline_len - 1] & 128) {
+ 0 => {
+ // Edgecase: string that starts with a 0 byte will be considered empty.
+ switch (this.bytes[0]) {
+ 0 => {
+ return "";
+ },
+ else => {
+ comptime var i: usize = 0;
+
+ inline while (i < this.bytes.len) : (i += 1) {
+ if (this.bytes[i] == 0) return this.bytes[0..i];
+ }
+
+ return &this.bytes;
+ },
+ }
+ },
+ else => {
+ const ptr_ = this.*.ptr();
+ return buf[ptr_.off..][0..ptr_.len];
+ },
+ }
+ }
+
+ pub const Builder = struct {
+ const Allocator = @import("std").mem.Allocator;
+ const assert = @import("std").debug.assert;
+ const copy = @import("std").mem.copy;
+ const IdentityContext = @import("../identity_context.zig").IdentityContext;
+
+ len: usize = 0,
+ cap: usize = 0,
+ ptr: ?[*]u8 = null,
+ string_pool: StringPool = undefined,
+
+ pub const StringPool = std.HashMap(u64, String, IdentityContext(u64), 80);
+
+ pub inline fn stringHash(buf: []const u8) u64 {
+ return std.hash.Wyhash.hash(0, buf);
+ }
+
+ pub inline fn count(this: *Builder, slice_: string) void {
+ return countWithHash(this, slice_, if (slice_.len >= String.max_inline_len) stringHash(slice_) else std.math.maxInt(u64));
+ }
+
+ pub inline fn countWithHash(this: *Builder, slice_: string, hash: u64) void {
+ if (slice_.len <= String.max_inline_len) return;
+
+ if (!this.string_pool.contains(hash)) {
+ this.cap += slice_.len;
+ }
+ }
+
+ pub inline fn allocatedSlice(this: *Builder) []u8 {
+ return if (this.cap > 0)
+ this.ptr.?[0..this.cap]
+ else
+ &[_]u8{};
+ }
+ pub fn allocate(this: *Builder, allocator: *std.mem.Allocator) !void {
+ var ptr_ = try allocator.alloc(u8, this.cap);
+ this.ptr = ptr_.ptr;
+ }
+
+ pub fn append(this: *Builder, comptime Type: type, slice_: string) Type {
+ return @call(.{ .modifier = .always_inline }, appendWithHash, .{ this, Type, slice_, stringHash(slice_) });
+ }
+
+ // SlicedString is not supported due to inline strings.
+ pub fn appendWithoutPool(this: *Builder, comptime Type: type, slice_: string, hash: u64) Type {
+ if (slice_.len < String.max_inline_len) {
+ switch (Type) {
+ String => {
+ return String.init(this.allocatedSlice(), slice_);
+ },
+ ExternalString => {
+ return ExternalString.init(this.allocatedSlice(), slice_, hash);
+ },
+ else => @compileError("Invalid type passed to StringBuilder"),
+ }
+ }
+ assert(this.len <= this.cap); // didn't count everything
+ assert(this.ptr != null); // must call allocate first
+
+ copy(u8, this.ptr.?[this.len..this.cap], slice_);
+ const final_slice = this.ptr.?[this.len..this.cap][0..slice_.len];
+ this.len += slice_.len;
+
+ assert(this.len <= this.cap);
+
+ switch (Type) {
+ String => {
+ return String.init(this.allocatedSlice(), final_slice);
+ },
+ ExternalString => {
+ return ExternalString.init(this.allocatedSlice(), final_slice, hash);
+ },
+ else => @compileError("Invalid type passed to StringBuilder"),
+ }
+ }
+
+ pub fn appendWithHash(this: *Builder, comptime Type: type, slice_: string, hash: u64) Type {
+ if (slice_.len < String.max_inline_len) {
+ switch (Type) {
+ String => {
+ return String.init(this.allocatedSlice(), slice_);
+ },
+ ExternalString => {
+ return ExternalString.init(this.allocatedSlice(), slice_, hash);
+ },
+ else => @compileError("Invalid type passed to StringBuilder"),
+ }
+ }
+
+ assert(this.len <= this.cap); // didn't count everything
+ assert(this.ptr != null); // must call allocate first
+
+ var string_entry = this.string_pool.getOrPut(hash) catch unreachable;
+ if (!string_entry.found_existing) {
+ copy(u8, this.ptr.?[this.len..this.cap], slice_);
+ const final_slice = this.ptr.?[this.len..this.cap][0..slice_.len];
+ this.len += slice_.len;
+
+ string_entry.value_ptr.* = String.init(this.allocatedSlice(), final_slice);
+ }
+
+ assert(this.len <= this.cap);
+
+ switch (Type) {
+ String => {
+ return string_entry.value_ptr.*;
+ },
+ ExternalString => {
+ return ExternalString{
+ .value = string_entry.value_ptr.*,
+ .hash = hash,
+ };
+ },
+ else => @compileError("Invalid type passed to StringBuilder"),
+ }
+ }
+ };
+
+ comptime {
+ if (@sizeOf(String) != @sizeOf(Pointer)) {
+ @compileError("String types must be the same size");
+ }
+ }
+};
+
+test "String works" {
+ {
+ var buf: string = "hello world";
+ var world: string = buf[6..];
+ var str = String.init(
+ buf,
+ world,
+ );
+ try std.testing.expectEqualStrings("world", str.slice(buf));
+ }
+
+ {
+ var buf: string = "hello";
+ var world: string = buf;
+ var str = String.init(
+ buf,
+ world,
+ );
+ try std.testing.expectEqualStrings("hello", str.slice(buf));
+ try std.testing.expectEqual(@bitCast(u64, str), @bitCast(u64, [8]u8{ 'h', 'e', 'l', 'l', 'o', 0, 0, 0 }));
+ }
+
+ {
+ var buf: string = &[8]u8{ 'h', 'e', 'l', 'l', 'o', 'k', 'k', 129 };
+ var world: string = buf;
+ var str = String.init(
+ buf,
+ world,
+ );
+ try std.testing.expectEqualStrings(buf, str.slice(buf));
+ }
+}
+
+pub const ExternalString = extern struct {
+ value: String = String{},
+ hash: u64 = 0,
+
+ pub inline fn fmt(this: *const ExternalString, buf: []const u8) String.Formatter {
+ return this.value.fmt(buf);
+ }
+
+ pub fn order(lhs: *const ExternalString, rhs: *const ExternalString, lhs_buf: []const u8, rhs_buf: []const u8) std.math.Order {
+ if (lhs.hash == rhs.hash and lhs.hash > 0) return .eq;
+
+ return lhs.value.order(&rhs.value, lhs_buf, rhs_buf);
+ }
+
+ /// ExternalString but without the hash
+ pub inline fn from(in: string) ExternalString {
+ return ExternalString{
+ .value = String.init(in, in),
+ .hash = std.hash.Wyhash.hash(0, in),
+ };
+ }
+
+ pub inline fn isInline(this: ExternalString) bool {
+ return this.value.isInline();
+ }
+
+ pub inline fn isEmpty(this: ExternalString) bool {
+ return this.value.isEmpty();
+ }
+
+ pub inline fn len(this: ExternalString) usize {
+ return this.value.len();
+ }
+
+ pub inline fn init(buf: string, in: string, hash: u64) ExternalString {
+ return ExternalString{
+ .value = String.init(buf, in),
+ .hash = hash,
+ };
+ }
+
+ pub inline fn slice(this: ExternalString, buf: string) string {
+ return this.value.slice(buf);
+ }
+};
+
+pub const BigExternalString = extern struct {
+ off: u32 = 0,
+ len: u32 = 0,
+ hash: u64 = 0,
+
+ pub fn from(in: string) BigExternalString {
+ return BigExternalString{
+ .off = 0,
+ .len = @truncate(u32, in.len),
+ .hash = std.hash.Wyhash.hash(0, in),
+ };
+ }
+
+ pub inline fn init(buf: string, in: string, hash: u64) BigExternalString {
+ std.debug.assert(@ptrToInt(buf.ptr) <= @ptrToInt(in.ptr) and ((@ptrToInt(in.ptr) + in.len) <= (@ptrToInt(buf.ptr) + buf.len)));
+
+ return BigExternalString{
+ .off = @truncate(u32, @ptrToInt(in.ptr) - @ptrToInt(buf.ptr)),
+ .len = @truncate(u32, in.len),
+ .hash = hash,
+ };
+ }
+
+ pub fn slice(this: BigExternalString, buf: string) string {
+ return buf[this.off..][0..this.len];
+ }
+};
+
+pub const SlicedString = struct {
+ buf: string,
+ slice: string,
+
+ pub inline fn init(buf: string, slice: string) SlicedString {
+ return SlicedString{ .buf = buf, .slice = slice };
+ }
+
+ pub inline fn external(this: SlicedString) ExternalString {
+ if (comptime Environment.isDebug or Environment.isTest) std.debug.assert(@ptrToInt(this.buf.ptr) <= @ptrToInt(this.slice.ptr) and ((@ptrToInt(this.slice.ptr) + this.slice.len) <= (@ptrToInt(this.buf.ptr) + this.buf.len)));
+
+ return ExternalString.init(this.buf, this.slice, std.hash.Wyhash.hash(0, this.slice));
+ }
+
+ pub inline fn value(this: SlicedString) String {
+ if (comptime Environment.isDebug or Environment.isTest) std.debug.assert(@ptrToInt(this.buf.ptr) <= @ptrToInt(this.slice.ptr) and ((@ptrToInt(this.slice.ptr) + this.slice.len) <= (@ptrToInt(this.buf.ptr) + this.buf.len)));
+
+ return String.init(this.buf, this.slice);
+ }
+
+ pub inline fn sub(this: SlicedString, input: string) SlicedString {
+ std.debug.assert(@ptrToInt(this.buf.ptr) <= @ptrToInt(this.buf.ptr) and ((@ptrToInt(input.ptr) + input.len) <= (@ptrToInt(this.buf.ptr) + this.buf.len)));
+ return SlicedString{ .buf = this.buf, .slice = input };
+ }
+};
+
+const RawType = void;
+pub const Version = extern struct {
+ major: u32 = 0,
+ minor: u32 = 0,
+ patch: u32 = 0,
+ tag: Tag = Tag{},
+ // raw: RawType = RawType{},
+
+ pub fn cloneInto(this: Version, slice: []const u8, buf: *[]u8) Version {
+ return Version{
+ .major = this.major,
+ .minor = this.minor,
+ .patch = this.patch,
+ .tag = this.tag.cloneInto(slice, buf),
+ };
+ }
+
+ pub inline fn len(this: *const Version) u32 {
+ return this.tag.build.len + this.tag.pre.len;
+ }
+
+ pub fn fmt(this: Version, input: string) Formatter {
+ return Formatter{ .version = this, .input = input };
+ }
+
+ pub fn count(this: Version, buf: []const u8, comptime StringBuilder: type, builder: StringBuilder) void {
+ if (this.tag.hasPre() and !this.tag.pre.isInline()) builder.count(this.tag.pre.slice(buf));
+ if (this.tag.hasBuild() and !this.tag.build.isInline()) builder.count(this.tag.build.slice(buf));
+ }
+
+ pub fn clone(this: Version, buf: []const u8, comptime StringBuilder: type, builder: StringBuilder) Version {
+ var that = this;
+
+ if (this.tag.hasPre() and !this.tag.pre.isInline()) that.tag.pre = builder.append(ExternalString, this.tag.pre.slice(buf));
+ if (this.tag.hasBuild() and !this.tag.build.isInline()) that.tag.build = builder.append(ExternalString, this.tag.build.slice(buf));
+
+ return that;
+ }
+
+ const HashableVersion = extern struct { major: u32, minor: u32, patch: u32, pre: u64, build: u64 };
+
+ pub fn hash(this: Version) u64 {
+ const hashable = HashableVersion{ .major = this.major, .minor = this.minor, .patch = this.patch, .pre = this.tag.pre.hash, .build = this.tag.build.hash };
+ const bytes = std.mem.asBytes(&hashable);
+ return std.hash.Wyhash.hash(0, bytes);
+ }
+
+ pub const Formatter = struct {
+ version: Version,
+ input: string,
+
+ pub fn format(formatter: Formatter, comptime layout: []const u8, opts: std.fmt.FormatOptions, writer: anytype) !void {
+ const self = formatter.version;
+ try std.fmt.format(writer, "{d}.{d}.{d}", .{ self.major, self.minor, self.patch });
+
+ if (self.tag.pre.len() > 0) {
+ const pre = self.tag.pre.slice(formatter.input);
+ try writer.writeAll("-");
+ try writer.writeAll(pre);
+ }
+
+ if (self.tag.build.len() > 0) {
+ const build = self.tag.build.slice(formatter.input);
+ try writer.writeAll("+");
+ try writer.writeAll(build);
+ }
+ }
+ };
+
+ inline fn atPart(i: u8) u32 {
+ return switch (i) {
+ 0 => self.major,
+ 1 => self.minor,
+ 2 => self.patch,
+ else => unreachable,
+ };
+ }
+
+ pub fn eql(lhs: Version, rhs: Version) bool {
+ return lhs.major == rhs.major and lhs.minor == rhs.minor and lhs.patch == rhs.patch and rhs.tag.eql(lhs.tag);
+ }
+
+ pub const HashContext = struct {
+ pub fn hash(this: @This(), lhs: Version) u32 {
+ return @truncate(u32, lhs.hash());
+ }
+
+ pub fn eql(this: @This(), lhs: Version, rhs: Version) bool {
+ return lhs.eql(rhs);
+ }
+ };
+
+ pub fn orderWithoutTag(
+ lhs: Version,
+ rhs: Version,
+ ) std.math.Order {
+ if (lhs.major < rhs.major) return .lt;
+ if (lhs.major > rhs.major) return .gt;
+ if (lhs.minor < rhs.minor) return .lt;
+ if (lhs.minor > rhs.minor) return .gt;
+ if (lhs.patch < rhs.patch) return .lt;
+ if (lhs.patch > rhs.patch) return .gt;
+
+ if (lhs.tag.hasPre() != rhs.tag.hasPre())
+ return if (lhs.tag.hasPre()) .lt else .gt;
+
+ if (lhs.tag.hasBuild() != rhs.tag.hasBuild())
+ return if (lhs.tag.hasBuild()) .gt else .lt;
+
+ return .eq;
+ }
+
+ pub fn order(
+ lhs: Version,
+ rhs: Version,
+ lhs_buf: []const u8,
+ rhs_buf: []const u8,
+ ) std.math.Order {
+ const order_without_tag = orderWithoutTag(lhs, rhs);
+ if (order_without_tag != .eq) return order_without_tag;
+
+ return lhs.tag.order(rhs.tag, lhs_buf, rhs_buf);
+ }
+
+ pub const Tag = extern struct {
+ pre: ExternalString = ExternalString{},
+ build: ExternalString = ExternalString{},
+
+ pub fn order(lhs: Tag, rhs: Tag, lhs_buf: []const u8, rhs_buf: []const u8) std.math.Order {
+ const pre_order = lhs.pre.order(&rhs.pre, lhs_buf, rhs_buf);
+ if (pre_order != .eq) return pre_order;
+
+ return lhs.build.order(&rhs.build, lhs_buf, rhs_buf);
+ }
+
+ pub fn cloneInto(this: Tag, slice: []const u8, buf: *[]u8) Tag {
+ var pre: String = this.pre.value;
+ var build: String = this.build.value;
+
+ if (this.pre.isInline()) {
+ pre = this.pre.value;
+ } else {
+ const pre_slice = this.pre.slice(slice);
+ std.mem.copy(u8, buf.*, pre_slice);
+ pre = String.init(buf.*, buf.*[0..pre_slice.len]);
+ buf.* = buf.*[pre_slice.len..];
+ }
+
+ if (this.build.isInline()) {
+ build = this.pre.build;
+ } else {
+ const build_slice = this.build.slice(slice);
+ std.mem.copy(u8, buf.*, build_slice);
+ build = String.init(buf.*, buf.*[0..build_slice.len]);
+ buf.* = buf.*[build_slice.len..];
+ }
+
+ return Tag{
+ .pre = .{
+ .value = pre,
+ .hash = this.pre.hash,
+ },
+ .build = .{
+ .value = this.build,
+ .hash = this.build.hash,
+ },
+ };
+ }
+
+ pub inline fn hasPre(this: Tag) bool {
+ return !this.pre.isEmpty();
+ }
+
+ pub inline fn hasBuild(this: Tag) bool {
+ return !this.build.isEmpty();
+ }
+
+ pub fn eql(lhs: Tag, rhs: Tag) bool {
+ return lhs.build.hash == rhs.build.hash and lhs.pre.hash == rhs.pre.hash;
+ }
+
+ pub const TagResult = struct {
+ tag: Tag = Tag{},
+ len: u32 = 0,
+ };
+
+ var multi_tag_warn = false;
+ // TODO: support multiple tags
+ pub fn parse(allocator: *std.mem.Allocator, sliced_string: SlicedString) TagResult {
+ var input = sliced_string.slice;
+ var build_count: u32 = 0;
+ var pre_count: u32 = 0;
+
+ for (input) |c| {
+ switch (c) {
+ ' ' => break,
+ '+' => {
+ build_count += 1;
+ },
+ '-' => {
+ pre_count += 1;
+ },
+ else => {},
+ }
+ }
+
+ if (build_count == 0 and pre_count == 0) {
+ return TagResult{
+ .len = 0,
+ };
+ }
+
+ const State = enum { none, pre, build };
+ var result = TagResult{};
+ // Common case: no allocation is necessary.
+ var state = State.none;
+ var start: usize = 0;
+
+ var tag_i: usize = 0;
+ var had_content = false;
+
+ var i: usize = 0;
+
+ while (i < input.len) : (i += 1) {
+ const c = input[i];
+ switch (c) {
+ ' ' => {
+ switch (state) {
+ .none => {},
+ .pre => {
+ result.tag.pre = sliced_string.sub(input[start..i]).external();
+ if (comptime Environment.isDebug) {
+ std.debug.assert(!strings.containsChar(result.tag.pre.slice(sliced_string.buf), '-'));
+ }
+ state = State.none;
+ },
+ .build => {
+ result.tag.build = sliced_string.sub(input[start..i]).external();
+ if (comptime Environment.isDebug) {
+ std.debug.assert(!strings.containsChar(result.tag.build.slice(sliced_string.buf), '-'));
+ }
+ state = State.none;
+ },
+ }
+ result.len = @truncate(u32, i);
+ break;
+ },
+ '+' => {
+ // qualifier ::= ( '-' pre )? ( '+' build )?
+ if (state == .pre) {
+ result.tag.pre = sliced_string.sub(input[start..i]).external();
+ if (comptime Environment.isDebug) {
+ std.debug.assert(!strings.containsChar(result.tag.pre.slice(sliced_string.buf), '-'));
+ }
+ }
+
+ if (state != .build) {
+ state = .build;
+ start = i + 1;
+ }
+ },
+ '-' => {
+ if (state != .pre) {
+ state = .pre;
+ start = i + 1;
+ }
+ },
+ else => {},
+ }
+ }
+
+ switch (state) {
+ .none => {},
+ .pre => {
+ result.tag.pre = sliced_string.sub(input[start..i]).external();
+ // a pre can contain multiple consecutive tags
+ if (comptime Environment.isDebug) {
+ std.debug.assert(!strings.startsWithChar(result.tag.pre.slice(sliced_string.buf), '-'));
+ }
+ state = State.none;
+ },
+ .build => {
+ // a build can contain multiple consecutive tags
+ result.tag.build = sliced_string.sub(input[start..i]).external();
+ if (comptime Environment.isDebug) {
+ std.debug.assert(!strings.startsWithChar(result.tag.build.slice(sliced_string.buf), '+'));
+ }
+ state = State.none;
+ },
+ }
+ result.len = @truncate(u32, i);
+
+ return result;
+ }
+ };
+
+ pub const ParseResult = struct {
+ wildcard: Query.Token.Wildcard = Query.Token.Wildcard.none,
+ valid: bool = true,
+ version: Version = Version{},
+ stopped_at: u32 = 0,
+ };
+
+ pub fn parse(sliced_string: SlicedString, allocator: *std.mem.Allocator) ParseResult {
+ var input = sliced_string.slice;
+ var result = ParseResult{};
+
+ var part_i: u8 = 0;
+ var part_start_i: usize = 0;
+ var last_char_i: usize = 0;
+
+ if (input.len == 0) {
+ result.valid = false;
+ return result;
+ }
+ var is_done = false;
+ var stopped_at: i32 = 0;
+
+ var i: usize = 0;
+
+ // two passes :(
+ while (i < input.len) {
+ if (is_done) {
+ break;
+ }
+
+ stopped_at = @intCast(i32, i);
+ switch (input[i]) {
+ ' ' => {
+ is_done = true;
+ break;
+ },
+ '|', '^', '#', '&', '%', '!' => {
+ is_done = true;
+ stopped_at -= 1;
+ break;
+ },
+ '0'...'9' => {
+ part_start_i = i;
+ i += 1;
+
+ while (i < input.len and switch (input[i]) {
+ '0'...'9' => true,
+ else => false,
+ }) {
+ i += 1;
+ }
+
+ last_char_i = i;
+
+ switch (part_i) {
+ 0 => {
+ result.version.major = parseVersionNumber(input[part_start_i..last_char_i]);
+ part_i = 1;
+ },
+ 1 => {
+ result.version.minor = parseVersionNumber(input[part_start_i..last_char_i]);
+ part_i = 2;
+ },
+ 2 => {
+ result.version.patch = parseVersionNumber(input[part_start_i..last_char_i]);
+ part_i = 3;
+ },
+ else => {},
+ }
+
+ if (i < input.len and switch (input[i]) {
+ '.' => true,
+ else => false,
+ }) {
+ i += 1;
+ }
+ },
+ '.' => {
+ result.valid = false;
+ is_done = true;
+ break;
+ },
+ '-', '+' => {
+ // Just a plain tag with no version is invalid.
+
+ if (part_i < 2) {
+ result.valid = false;
+ is_done = true;
+ break;
+ }
+
+ part_start_i = i;
+ i += 1;
+ while (i < input.len and switch (input[i]) {
+ ' ' => true,
+ else => false,
+ }) {
+ i += 1;
+ }
+ const tag_result = Tag.parse(allocator, sliced_string.sub(input[part_start_i..]));
+ result.version.tag = tag_result.tag;
+ i += tag_result.len;
+ break;
+ },
+ 'x', '*', 'X' => {
+ part_start_i = i;
+ i += 1;
+
+ while (i < input.len and switch (input[i]) {
+ 'x', '*', 'X' => true,
+ else => false,
+ }) {
+ i += 1;
+ }
+
+ last_char_i = i;
+
+ if (i < input.len and switch (input[i]) {
+ '.' => true,
+ else => false,
+ }) {
+ i += 1;
+ }
+
+ if (result.wildcard == .none) {
+ switch (part_i) {
+ 0 => {
+ result.wildcard = Query.Token.Wildcard.major;
+ part_i = 1;
+ },
+ 1 => {
+ result.wildcard = Query.Token.Wildcard.minor;
+ part_i = 2;
+ },
+ 2 => {
+ result.wildcard = Query.Token.Wildcard.patch;
+ part_i = 3;
+ },
+ else => unreachable,
+ }
+ }
+ },
+ else => {
+ last_char_i = 0;
+ result.valid = false;
+ is_done = true;
+ break;
+ },
+ }
+ }
+
+ if (result.wildcard == .none) {
+ switch (part_i) {
+ 0 => {
+ result.wildcard = Query.Token.Wildcard.major;
+ },
+ 1 => {
+ result.wildcard = Query.Token.Wildcard.minor;
+ },
+ 2 => {
+ result.wildcard = Query.Token.Wildcard.patch;
+ },
+ else => {},
+ }
+ }
+
+ result.stopped_at = @intCast(u32, i);
+
+ if (comptime RawType != void) {
+ result.version.raw = sliced_string.sub(input[0..i]).external();
+ }
+
+ return result;
+ }
+
+ fn parseVersionNumber(input: string) u32 {
+ // max decimal u32 is 4294967295
+ var bytes: [10]u8 = undefined;
+ var byte_i: u8 = 0;
+
+ std.debug.assert(input[0] != '.');
+
+ for (input) |char, i| {
+ switch (char) {
+ 'X', 'x', '*' => return 0,
+ '0'...'9' => {
+ // out of bounds
+ if (byte_i + 1 > bytes.len) return 0;
+ bytes[byte_i] = char;
+ byte_i += 1;
+ },
+ ' ', '.' => break,
+ // ignore invalid characters
+ else => {},
+ }
+ }
+
+ // If there are no numbers, it's 0.
+ if (byte_i == 0) return 0;
+
+ if (comptime Environment.isDebug) {
+ return std.fmt.parseInt(u32, bytes[0..byte_i], 10) catch |err| {
+ Output.prettyErrorln("ERROR {s} parsing version: \"{s}\", bytes: {s}", .{
+ @errorName(err),
+ input,
+ bytes[0..byte_i],
+ });
+ return 0;
+ };
+ }
+
+ return std.fmt.parseInt(u32, bytes[0..byte_i], 10) catch 0;
+ }
+};
+
+pub const Range = struct {
+ pub const Op = enum(u8) {
+ unset = 0,
+ eql = 1,
+ lt = 3,
+ lte = 4,
+ gt = 5,
+ gte = 6,
+ };
+
+ left: Comparator = Comparator{},
+ right: Comparator = Comparator{},
+
+ pub fn initWildcard(version: Version, wildcard: Query.Token.Wildcard) Range {
+ switch (wildcard) {
+ .none => {
+ return Range{
+ .left = Comparator{
+ .op = Op.eql,
+ .version = version,
+ },
+ };
+ },
+
+ .major => {
+ return Range{
+ .left = Comparator{
+ .op = Op.gte,
+ .version = Version{
+ // .raw = version.raw
+ },
+ },
+ };
+ },
+ .minor => {
+ var lhs = Version{
+ // .raw = version.raw
+ };
+ lhs.major = version.major + 1;
+
+ var rhs = Version{
+ // .raw = version.raw
+ };
+ rhs.major = version.major;
+
+ return Range{
+ .left = Comparator{
+ .op = Op.lt,
+ .version = lhs,
+ },
+ .right = Comparator{
+ .op = Op.gte,
+ .version = rhs,
+ },
+ };
+ },
+ .patch => {
+ var lhs = Version{};
+ lhs.major = version.major;
+ lhs.minor = version.minor + 1;
+
+ var rhs = Version{};
+ rhs.major = version.major;
+ rhs.minor = version.minor;
+
+ // rhs.raw = version.raw;
+ // lhs.raw = version.raw;
+
+ return Range{
+ .left = Comparator{
+ .op = Op.lt,
+ .version = lhs,
+ },
+ .right = Comparator{
+ .op = Op.gte,
+ .version = rhs,
+ },
+ };
+ },
+ }
+ }
+
+ pub inline fn hasLeft(this: Range) bool {
+ return this.left.op != Op.unset;
+ }
+
+ pub inline fn hasRight(this: Range) bool {
+ return this.right.op != Op.unset;
+ }
+
+ /// Is the Range equal to another Range
+ /// This does not evaluate the range.
+ pub inline fn eql(lhs: Range, rhs: Range) bool {
+ return lhs.left.eql(rhs.left) and lhs.right.eql(rhs.right);
+ }
+
+ pub const Comparator = struct {
+ op: Op = Op.unset,
+ version: Version = Version{},
+
+ pub inline fn eql(lhs: Comparator, rhs: Comparator) bool {
+ return lhs.op == rhs.op and lhs.version.eql(rhs.version);
+ }
+
+ pub fn satisfies(this: Comparator, version: Version) bool {
+ const order = version.orderWithoutTag(this.version);
+
+ return switch (order) {
+ .eq => switch (this.op) {
+ .lte, .gte, .eql => true,
+ else => false,
+ },
+ .gt => switch (this.op) {
+ .gt, .gte => true,
+ else => false,
+ },
+ .lt => switch (this.op) {
+ .lt, .lte => true,
+ else => false,
+ },
+ };
+ }
+ };
+
+ pub fn satisfies(this: Range, version: Version) bool {
+ if (!this.hasLeft()) {
+ return true;
+ }
+
+ if (!this.left.satisfies(version)) {
+ return false;
+ }
+
+ if (this.hasRight() and !this.right.satisfies(version)) {
+ return false;
+ }
+
+ return true;
+ }
+};
+
+/// Linked-list of AND ranges
+/// "^1 ^2"
+/// ----|-----
+/// That is two Query
+pub const Query = struct {
+ pub const Op = enum {
+ none,
+ AND,
+ OR,
+ };
+
+ range: Range = Range{},
+
+ // AND
+ next: ?*Query = null,
+
+ /// Linked-list of Queries OR'd together
+ /// "^1 || ^2"
+ /// ----|-----
+ /// That is two List
+ pub const List = struct {
+ head: Query = Query{},
+ tail: ?*Query = null,
+
+ // OR
+ next: ?*List = null,
+
+ pub inline fn satisfies(this: *const List, version: Version) bool {
+ return this.head.satisfies(version) or (this.next orelse return false).satisfies(version);
+ }
+
+ pub inline fn eql(lhs: *const List, rhs: *const List) bool {
+ if (!lhs.head.eql(&rhs.head)) return false;
+
+ var lhs_next = lhs.next orelse return rhs.next == null;
+ var rhs_next = rhs.next orelse return false;
+
+ return lhs_next.eql(rhs_next);
+ }
+
+ pub fn andRange(self: *List, allocator: *std.mem.Allocator, range: Range) !void {
+ if (!self.head.range.hasLeft() and !self.head.range.hasRight()) {
+ self.head.range = range;
+ return;
+ }
+
+ var tail = try allocator.create(Query);
+ tail.* = Query{
+ .range = range,
+ };
+ tail.range = range;
+
+ var last_tail = self.tail orelse &self.head;
+ last_tail.next = tail;
+ self.tail = tail;
+ }
+ };
+
+ pub const Group = struct {
+ head: List = List{},
+ tail: ?*List = null,
+ allocator: *std.mem.Allocator,
+ input: string = "",
+
+ flags: FlagsBitSet = FlagsBitSet.initEmpty(),
+ pub const Flags = struct {
+ pub const pre = 1;
+ pub const build = 0;
+ };
+
+ pub const FlagsBitSet = std.bit_set.IntegerBitSet(3);
+
+ pub fn isExact(this: *const Group) bool {
+ return this.head.next == null and this.head.head.next == null and !this.head.head.range.hasRight() and this.head.head.range.left.op == .eql;
+ }
+
+ pub inline fn eql(lhs: Group, rhs: Group) bool {
+ return lhs.head.eql(&rhs.head);
+ }
+
+ pub fn orVersion(self: *Group, version: Version) !void {
+ if (self.tail == null and !self.head.head.range.hasLeft()) {
+ self.head.head.range.left.version = version;
+ self.head.head.range.left.op = .eql;
+ return;
+ }
+
+ var new_tail = try self.allocator.create(List);
+ new_tail.* = List{};
+ new_tail.head.range.left.version = version;
+ new_tail.head.range.left.op = .eql;
+
+ var prev_tail = self.tail orelse &self.head;
+ prev_tail.next = new_tail;
+ self.tail = new_tail;
+ }
+
+ pub fn andRange(self: *Group, range: Range) !void {
+ var tail = self.tail orelse &self.head;
+ try tail.andRange(self.allocator, range);
+ }
+
+ pub fn orRange(self: *Group, range: Range) !void {
+ if (self.tail == null and self.head.tail == null and !self.head.head.range.hasLeft()) {
+ self.head.head.range = range;
+ return;
+ }
+
+ var new_tail = try self.allocator.create(List);
+ new_tail.* = List{};
+ new_tail.head.range = range;
+
+ var prev_tail = self.tail orelse &self.head;
+ prev_tail.next = new_tail;
+ self.tail = new_tail;
+ }
+
+ pub inline fn satisfies(this: *const Group, version: Version) bool {
+ return this.head.satisfies(version);
+ }
+ };
+
+ pub fn eql(lhs: *const Query, rhs: *const Query) bool {
+ if (!lhs.range.eql(rhs.range)) return false;
+
+ const lhs_next = lhs.next orelse return rhs.next == null;
+ const rhs_next = rhs.next orelse return false;
+
+ return lhs_next.eql(rhs_next);
+ }
+
+ pub inline fn satisfies(this: *const Query, version: Version) bool {
+ const left = this.range.satisfies(version);
+
+ return left and (this.next orelse return true).satisfies(version);
+ }
+
+ pub const Token = struct {
+ tag: Tag = Tag.none,
+ wildcard: Wildcard = Wildcard.none,
+
+ pub fn toRange(this: Token, version: Version) Range {
+ switch (this.tag) {
+ // Allows changes that do not modify the left-most non-zero element in the [major, minor, patch] tuple
+ .caret => {
+ var right_version = version;
+ // https://github.com/npm/node-semver/blob/cb1ca1d5480a6c07c12ac31ba5f2071ed530c4ed/classes/range.js#L310-L336
+ if (right_version.major == 0) {
+ if (right_version.minor == 0) {
+ right_version.patch += 1;
+ } else {
+ right_version.minor += 1;
+ right_version.patch = 0;
+ }
+ } else {
+ right_version.major += 1;
+ right_version.patch = 0;
+ right_version.minor = 0;
+ }
+
+ return Range{
+ .left = .{
+ .op = .gte,
+ .version = version,
+ },
+ .right = .{
+ .op = .lt,
+ .version = right_version,
+ },
+ };
+ },
+ .tilda => {
+ if (this.wildcard == .minor or this.wildcard == .major) {
+ return Range.initWildcard(version, .minor);
+ }
+
+ // This feels like it needs to be tested more.
+ var right_version = version;
+ right_version.minor += 1;
+ right_version.patch = 0;
+
+ return Range{
+ .left = .{
+ .op = .gte,
+ .version = version,
+ },
+ .right = .{
+ .op = .lt,
+ .version = right_version,
+ },
+ };
+ },
+ .none => unreachable,
+ .version => {
+ if (this.wildcard != Wildcard.none) {
+ return Range.initWildcard(version, this.wildcard);
+ }
+
+ return Range{ .left = .{ .op = .eql, .version = version } };
+ },
+ else => {},
+ }
+
+ {
+ var _version = version;
+ switch (this.wildcard) {
+ .major => {
+ return Range{
+ .left = .{ .op = .gte, .version = _version },
+ .right = .{
+ .op = .lte,
+ .version = Version{
+ .major = std.math.maxInt(u32),
+ .minor = std.math.maxInt(u32),
+ .patch = std.math.maxInt(u32),
+ },
+ },
+ };
+ },
+ .minor => {
+ switch (this.tag) {
+ .lt, .lte => {
+ return Range{
+ .left = .{
+ .op = if (this.tag == .lt) .lt else .lte,
+ .version = Version{
+ .major = version.major,
+ .minor = 0,
+ .patch = 0,
+ },
+ },
+ };
+ },
+ else => {
+ return Range{
+ .left = .{
+ .op = if (this.tag == .gt) .gt else .gte,
+ .version = Version{
+ .major = version.major,
+ .minor = std.math.maxInt(u32),
+ .patch = std.math.maxInt(u32),
+ },
+ },
+ };
+ },
+ }
+ },
+ .patch => {
+ switch (this.tag) {
+ .lt, .lte => {
+ return Range{
+ .left = .{
+ .op = if (this.tag == .lt) .lt else .lte,
+ .version = Version{
+ .major = version.major,
+ .minor = version.minor,
+ .patch = 0,
+ },
+ },
+ };
+ },
+ else => {
+ return Range{
+ .left = .{
+ .op = if (this.tag == .gt) .gt else .gte,
+ .version = Version{
+ .major = version.major,
+ .minor = version.minor,
+ .patch = std.math.maxInt(u32),
+ },
+ },
+ };
+ },
+ }
+ },
+ .none => {
+ return Range{
+ .left = .{
+ .op = switch (this.tag) {
+ .gt => .gt,
+ .gte => .gte,
+ .lt => .lt,
+ .lte => .lte,
+ else => unreachable,
+ },
+ .version = version,
+ },
+ };
+ },
+ }
+ }
+ }
+
+ pub const Tag = enum {
+ none,
+ gt,
+ gte,
+ lt,
+ lte,
+ version,
+ tilda,
+ caret,
+ };
+
+ pub const Wildcard = enum {
+ none,
+ major,
+ minor,
+ patch,
+ };
+ };
+
+ pub fn parse(
+ allocator: *std.mem.Allocator,
+ input: string,
+ sliced: SlicedString,
+ ) !Group {
+ var i: usize = 0;
+ var list = Group{
+ .allocator = allocator,
+ .input = input,
+ };
+
+ var token = Token{};
+ var prev_token = Token{};
+
+ var count: u8 = 0;
+ var skip_round = false;
+ var is_or = false;
+ var enable_hyphen = false;
+
+ var last_non_whitespace: usize = 0;
+
+ while (i < input.len) {
+ skip_round = false;
+
+ switch (input[i]) {
+ '>' => {
+ if (input.len > i + 1 and input[i + 1] == '=') {
+ token.tag = .gte;
+ i += 1;
+ } else {
+ token.tag = .gt;
+ }
+
+ i += 1;
+ while (i < input.len and input[i] == ' ') : (i += 1) {}
+ },
+ '<' => {
+ if (input.len > i + 1 and input[i + 1] == '=') {
+ token.tag = .lte;
+ i += 1;
+ } else {
+ token.tag = .lt;
+ }
+
+ i += 1;
+ while (i < input.len and input[i] == ' ') : (i += 1) {}
+ },
+ '=', 'v' => {
+ token.tag = .version;
+ is_or = true;
+ i += 1;
+ while (i < input.len and input[i] == ' ') : (i += 1) {}
+ },
+ '~' => {
+ token.tag = .tilda;
+ i += 1;
+
+ if (i < input.len and input[i] == '>') i += 1;
+
+ while (i < input.len and input[i] == ' ') : (i += 1) {}
+ },
+ '^' => {
+ token.tag = .caret;
+ i += 1;
+ while (i < input.len and input[i] == ' ') : (i += 1) {}
+ },
+ '0'...'9', 'X', 'x', '*' => {
+ token.tag = .version;
+ is_or = true;
+ },
+ '|' => {
+ i += 1;
+
+ while (i < input.len and input[i] == '|') : (i += 1) {}
+ while (i < input.len and input[i] == ' ') : (i += 1) {}
+ is_or = true;
+ token.tag = Token.Tag.none;
+ skip_round = true;
+ },
+ '-' => {
+ i += 1;
+ while (i < input.len and input[i] == ' ') : (i += 1) {}
+ },
+ ' ' => {
+ i += 1;
+ while (i < input.len and input[i] == ' ') : (i += 1) {}
+ skip_round = true;
+ },
+ else => {
+ i += 1;
+ token.tag = Token.Tag.none;
+ skip_round = true;
+ },
+ }
+
+ if (!skip_round) {
+ const parse_result = Version.parse(sliced.sub(input[i..]), allocator);
+ if (parse_result.version.tag.hasBuild()) list.flags.setValue(Group.Flags.build, true);
+ if (parse_result.version.tag.hasPre()) list.flags.setValue(Group.Flags.pre, true);
+
+ token.wildcard = parse_result.wildcard;
+
+ i += parse_result.stopped_at;
+ const rollback = i;
+
+ const had_space = i < input.len and input[i] == ' ';
+
+ // TODO: can we do this without rolling back?
+ const hyphenate: bool = had_space and possibly_hyphenate: {
+ i += 1;
+ while (i < input.len and input[i] == ' ') : (i += 1) {}
+ if (!(i < input.len and input[i] == '-')) break :possibly_hyphenate false;
+ i += 1;
+ if (!(i < input.len and input[i] == ' ')) break :possibly_hyphenate false;
+ i += 1;
+ while (i < input.len and switch (input[i]) {
+ ' ', 'v', '=' => true,
+ else => false,
+ }) : (i += 1) {}
+ if (!(i < input.len and switch (input[i]) {
+ '0'...'9', 'X', 'x', '*' => true,
+ else => false,
+ })) break :possibly_hyphenate false;
+
+ break :possibly_hyphenate true;
+ };
+
+ if (!hyphenate) i = rollback;
+ i += @as(usize, @boolToInt(!hyphenate));
+
+ if (hyphenate) {
+ var second_version = Version.parse(sliced.sub(input[i..]), allocator);
+ if (second_version.version.tag.hasBuild()) list.flags.setValue(Group.Flags.build, true);
+ if (second_version.version.tag.hasPre()) list.flags.setValue(Group.Flags.pre, true);
+
+ const range: Range = brk: {
+ switch (second_version.wildcard) {
+ .major => {
+ second_version.version.major += 1;
+ break :brk Range{
+ .left = .{ .op = .gte, .version = parse_result.version },
+ .right = .{ .op = .lte, .version = second_version.version },
+ };
+ },
+ .minor => {
+ second_version.version.major += 1;
+ second_version.version.minor = 0;
+ second_version.version.patch = 0;
+
+ break :brk Range{
+ .left = .{ .op = .gte, .version = parse_result.version },
+ .right = .{ .op = .lt, .version = second_version.version },
+ };
+ },
+ .patch => {
+ second_version.version.minor += 1;
+ second_version.version.patch = 0;
+
+ break :brk Range{
+ .left = .{ .op = .gte, .version = parse_result.version },
+ .right = .{ .op = .lt, .version = second_version.version },
+ };
+ },
+ .none => {
+ break :brk Range{
+ .left = .{ .op = .gte, .version = parse_result.version },
+ .right = .{ .op = .lte, .version = second_version.version },
+ };
+ },
+ }
+ };
+
+ if (is_or) {
+ try list.orRange(range);
+ } else {
+ try list.andRange(range);
+ }
+
+ i += second_version.stopped_at + 1;
+ } else if (count == 0 and token.tag == .version) {
+ switch (parse_result.wildcard) {
+ .none => {
+ try list.orVersion(parse_result.version);
+ },
+ else => {
+ try list.orRange(token.toRange(parse_result.version));
+ },
+ }
+ } else if (count == 0) {
+ try list.andRange(token.toRange(parse_result.version));
+ } else if (is_or) {
+ try list.orRange(token.toRange(parse_result.version));
+ } else {
+ try list.andRange(token.toRange(parse_result.version));
+ }
+
+ is_or = false;
+ count += 1;
+ token.wildcard = .none;
+ prev_token.tag = token.tag;
+ }
+ }
+
+ return list;
+ }
+};
+
+const expect = struct {
+ pub var counter: usize = 0;
+ pub fn isRangeMatch(input: string, version_str: string) bool {
+ var parsed = Version.parse(SlicedString.init(version_str, version_str), default_allocator);
+ std.debug.assert(parsed.valid);
+ // std.debug.assert(strings.eql(parsed.version.raw.slice(version_str), version_str));
+
+ var list = Query.parse(
+ default_allocator,
+ input,
+ SlicedString.init(input, input),
+ ) catch |err| Output.panic("Test fail due to error {s}", .{@errorName(err)});
+
+ return list.satisfies(parsed.version);
+ }
+
+ pub fn range(input: string, version_str: string, src: std.builtin.SourceLocation) void {
+ Output.initTest();
+ defer counter += 1;
+ if (!isRangeMatch(input, version_str)) {
+ Output.panic("<r><red>Fail<r> Expected range <b>\"{s}\"<r> to match <b>\"{s}\"<r>\nAt: <blue><b>{s}:{d}:{d}<r><d> in {s}<r>", .{
+ input,
+ version_str,
+ src.file,
+ src.line,
+ src.column,
+ src.fn_name,
+ });
+ }
+ }
+ pub fn notRange(input: string, version_str: string, src: std.builtin.SourceLocation) void {
+ Output.initTest();
+ defer counter += 1;
+ if (isRangeMatch(input, version_str)) {
+ Output.panic("<r><red>Fail<r> Expected range <b>\"{s}\"<r> NOT match <b>\"{s}\"<r>\nAt: <blue><b>{s}:{d}:{d}<r><d> in {s}<r>", .{
+ input,
+ version_str,
+ src.file,
+ src.line,
+ src.column,
+ src.fn_name,
+ });
+ }
+ }
+
+ pub fn done(src: std.builtin.SourceLocation) void {
+ Output.prettyErrorln("<r><green>{d} passed expectations <d>in {s}<r>", .{ counter, src.fn_name });
+ Output.flush();
+ counter = 0;
+ }
+
+ pub fn version(input: string, v: [3]u32, src: std.builtin.SourceLocation) void {
+ Output.initTest();
+ defer counter += 1;
+ var result = Version.parse(SlicedString.init(input, input), default_allocator);
+ var other = Version{ .major = v[0], .minor = v[1], .patch = v[2] };
+ std.debug.assert(result.valid);
+
+ if (!other.eql(result.version)) {
+ Output.panic("<r><red>Fail<r> Expected version <b>\"{s}\"<r> to match <b>\"{d}.{d}.{d}\" but received <red>\"{d}.{d}.{d}\"<r>\nAt: <blue><b>{s}:{d}:{d}<r><d> in {s}<r>", .{
+ input,
+ v[0],
+ v[1],
+ v[2],
+ result.version.major,
+ result.version.minor,
+ result.version.patch,
+ src.file,
+ src.line,
+ src.column,
+ src.fn_name,
+ });
+ }
+ }
+
+ pub fn versionT(input: string, v: Version, src: std.builtin.SourceLocation) void {
+ Output.initTest();
+ defer counter += 1;
+
+ var result = Version.parse(SlicedString.init(input, input), default_allocator);
+ if (!v.eql(result.version)) {
+ Output.panic("<r><red>Fail<r> Expected version <b>\"{s}\"<r> to match <b>\"{s}\" but received <red>\"{}\"<r>\nAt: <blue><b>{s}:{d}:{d}<r><d> in {s}<r>", .{
+ input,
+ v,
+ result.version,
+ src.file,
+ src.line,
+ src.column,
+ src.fn_name,
+ });
+ }
+ }
+};
+
+test "Version parsing" {
+ defer expect.done(@src());
+
+ expect.version("1.0.0", .{ 1, 0, 0 }, @src());
+ expect.version("1.1.0", .{ 1, 1, 0 }, @src());
+ expect.version("1.1.1", .{ 1, 1, 1 }, @src());
+ expect.version("1.1.0", .{ 1, 1, 0 }, @src());
+ expect.version("0.1.1", .{ 0, 1, 1 }, @src());
+ expect.version("0.0.1", .{ 0, 0, 1 }, @src());
+ expect.version("0.0.0", .{ 0, 0, 0 }, @src());
+
+ expect.version("1.x", .{ 1, 0, 0 }, @src());
+ expect.version("2.2.x", .{ 2, 2, 0 }, @src());
+ expect.version("2.x.2", .{ 2, 0, 2 }, @src());
+
+ expect.version("1.X", .{ 1, 0, 0 }, @src());
+ expect.version("2.2.X", .{ 2, 2, 0 }, @src());
+ expect.version("2.X.2", .{ 2, 0, 2 }, @src());
+
+ expect.version("1.*", .{ 1, 0, 0 }, @src());
+ expect.version("2.2.*", .{ 2, 2, 0 }, @src());
+ expect.version("2.*.2", .{ 2, 0, 2 }, @src());
+ expect.version("3", .{ 3, 0, 0 }, @src());
+ expect.version("3.x", .{ 3, 0, 0 }, @src());
+ expect.version("3.x.x", .{ 3, 0, 0 }, @src());
+ expect.version("3.*.*", .{ 3, 0, 0 }, @src());
+ expect.version("3.X.x", .{ 3, 0, 0 }, @src());
+
+ expect.version("0.0.0", .{ 0, 0, 0 }, @src());
+
+ {
+ var v = Version{
+ .major = 1,
+ .minor = 0,
+ .patch = 0,
+ };
+ var input: string = "1.0.0-beta";
+ v.tag.pre = SlicedString.init(input, input["1.0.0-".len..]).external();
+ expect.versionT(input, v, @src());
+ }
+
+ {
+ var v = Version{
+ .major = 1,
+ .minor = 0,
+ .patch = 0,
+ };
+ var input: string = "1.0.0-build101";
+ v.tag.pre = SlicedString.init(input, input["1.0.0-".len..]).external();
+ expect.versionT(input, v, @src());
+ }
+
+ {
+ var v = Version{
+ .major = 0,
+ .minor = 21,
+ .patch = 0,
+ };
+ var input: string = "0.21.0-beta-96ca8d915-20211115";
+ v.tag.pre = SlicedString.init(input, input["0.21.0-".len..]).external();
+ expect.versionT(input, v, @src());
+ }
+
+ {
+ var v = Version{
+ .major = 1,
+ .minor = 0,
+ .patch = 0,
+ };
+ var input: string = "1.0.0-beta+build101";
+ v.tag.build = SlicedString.init(input, input["1.0.0-beta+".len..]).external();
+ v.tag.pre = SlicedString.init(input, input["1.0.0-".len..][0..4]).external();
+ expect.versionT(input, v, @src());
+ }
+
+ var buf: [1024]u8 = undefined;
+
+ var triplet = [3]u32{ 0, 0, 0 };
+ var x: u32 = 0;
+ var y: u32 = 0;
+ var z: u32 = 0;
+
+ while (x < 32) : (x += 1) {
+ while (y < 32) : (y += 1) {
+ while (z < 32) : (z += 1) {
+ triplet[0] = x;
+ triplet[1] = y;
+ triplet[2] = z;
+ expect.version(try std.fmt.bufPrint(&buf, "{d}.{d}.{d}", .{ x, y, z }), triplet, @src());
+ triplet[0] = z;
+ triplet[1] = x;
+ triplet[2] = y;
+ expect.version(try std.fmt.bufPrint(&buf, "{d}.{d}.{d}", .{ z, x, y }), triplet, @src());
+
+ triplet[0] = y;
+ triplet[1] = x;
+ triplet[2] = z;
+ expect.version(try std.fmt.bufPrint(&buf, "{d}.{d}.{d}", .{ y, x, z }), triplet, @src());
+ }
+ }
+ }
+}
+
+test "Range parsing" {
+ defer expect.done(@src());
+
+ expect.range("~1.2.3", "1.2.3", @src());
+ expect.range("~1.2", "1.2.0", @src());
+ expect.range("~1", "1.0.0", @src());
+ expect.range("~1", "1.2.0", @src());
+ expect.range("~1", "1.2.999", @src());
+ expect.range("~0.2.3", "0.2.3", @src());
+ expect.range("~0.2", "0.2.0", @src());
+ expect.range("~0.2", "0.2.1", @src());
+
+ expect.range("~0 ", "0.0.0", @src());
+
+ expect.notRange("~1.2.3", "1.3.0", @src());
+ expect.notRange("~1.2", "1.3.0", @src());
+ expect.notRange("~1", "2.0.0", @src());
+ expect.notRange("~0.2.3", "0.3.0", @src());
+ expect.notRange("~0.2.3", "1.0.0", @src());
+ expect.notRange("~0 ", "1.0.0", @src());
+ expect.notRange("~0.2", "0.1.0", @src());
+ expect.notRange("~0.2", "0.3.0", @src());
+
+ expect.notRange("~3.0.5", "3.3.0", @src());
+
+ expect.range("^1.1.4", "1.1.4", @src());
+
+ expect.range(">2", "3", @src());
+ expect.notRange(">2", "2.1", @src());
+ expect.notRange(">2", "2", @src());
+ expect.notRange(">2", "1.0", @src());
+ expect.notRange(">1.3", "1.3.1", @src());
+ expect.range(">1.3", "2.0.0", @src());
+ expect.range(">2.1.0", "2.2.0", @src());
+ expect.range("<=2.2.99999", "2.2.0", @src());
+ expect.range(">=2.1.99999", "2.2.0", @src());
+ expect.range("<2.2.99999", "2.2.0", @src());
+ expect.range(">2.1.99999", "2.2.0", @src());
+ expect.range(">1.0.0", "2.0.0", @src());
+ expect.range("1.0.0", "1.0.0", @src());
+ expect.notRange("1.0.0", "2.0.0", @src());
+
+ expect.range("1.0.0 || 2.0.0", "1.0.0", @src());
+ expect.range("2.0.0 || 1.0.0", "1.0.0", @src());
+ expect.range("1.0.0 || 2.0.0", "2.0.0", @src());
+ expect.range("2.0.0 || 1.0.0", "2.0.0", @src());
+ expect.range("2.0.0 || >1.0.0", "2.0.0", @src());
+
+ expect.range(">1.0.0 <2.0.0 <2.0.1 >1.0.1", "1.0.2", @src());
+
+ expect.range("2.x", "2.0.0", @src());
+ expect.range("2.x", "2.1.0", @src());
+ expect.range("2.x", "2.2.0", @src());
+ expect.range("2.x", "2.3.0", @src());
+ expect.range("2.x", "2.1.1", @src());
+ expect.range("2.x", "2.2.2", @src());
+ expect.range("2.x", "2.3.3", @src());
+
+ expect.range("<2.0.1 >1.0.0", "2.0.0", @src());
+ expect.range("<=2.0.1 >=1.0.0", "2.0.0", @src());
+
+ expect.range("^2", "2.0.0", @src());
+ expect.range("^2", "2.9.9", @src());
+ expect.range("~2", "2.0.0", @src());
+ expect.range("~2", "2.1.0", @src());
+ expect.range("~2.2", "2.2.1", @src());
+
+ {
+ const passing = [_]string{ "2.4.0", "2.4.1", "3.0.0", "3.0.1", "3.1.0", "3.2.0", "3.3.0", "3.3.1", "3.4.0", "3.5.0", "3.6.0", "3.7.0", "2.4.2", "3.8.0", "3.9.0", "3.9.1", "3.9.2", "3.9.3", "3.10.0", "3.10.1", "4.0.0", "4.0.1", "4.1.0", "4.2.0", "4.2.1", "4.3.0", "4.4.0", "4.5.0", "4.5.1", "4.6.0", "4.6.1", "4.7.0", "4.8.0", "4.8.1", "4.8.2", "4.9.0", "4.10.0", "4.11.0", "4.11.1", "4.11.2", "4.12.0", "4.13.0", "4.13.1", "4.14.0", "4.14.1", "4.14.2", "4.15.0", "4.16.0", "4.16.1", "4.16.2", "4.16.3", "4.16.4", "4.16.5", "4.16.6", "4.17.0", "4.17.1", "4.17.2", "4.17.3", "4.17.4", "4.17.5", "4.17.9", "4.17.10", "4.17.11", "2.0.0", "2.1.0" };
+
+ for (passing) |item| {
+ expect.range("^2 <2.2 || > 2.3", item, @src());
+ expect.range("> 2.3 || ^2 <2.2", item, @src());
+ }
+
+ const not_passing = [_]string{
+ "0.1.0",
+ "0.10.0",
+ "0.2.0",
+ "0.2.1",
+ "0.2.2",
+ "0.3.0",
+ "0.3.1",
+ "0.3.2",
+ "0.4.0",
+ "0.4.1",
+ "0.4.2",
+ "0.5.0",
+ // "0.5.0-rc.1",
+ "0.5.1",
+ "0.5.2",
+ "0.6.0",
+ "0.6.1",
+ "0.7.0",
+ "0.8.0",
+ "0.8.1",
+ "0.8.2",
+ "0.9.0",
+ "0.9.1",
+ "0.9.2",
+ "1.0.0",
+ "1.0.1",
+ "1.0.2",
+ "1.1.0",
+ "1.1.1",
+ "1.2.0",
+ "1.2.1",
+ "1.3.0",
+ "1.3.1",
+ "2.2.0",
+ "2.2.1",
+ "2.3.0",
+ // "1.0.0-rc.1",
+ // "1.0.0-rc.2",
+ // "1.0.0-rc.3",
+ };
+
+ for (not_passing) |item| {
+ expect.notRange("^2 <2.2 || > 2.3", item, @src());
+ expect.notRange("> 2.3 || ^2 <2.2", item, @src());
+ }
+ }
+ expect.range("2.1.0 || > 2.2 || >3", "2.1.0", @src());
+ expect.range(" > 2.2 || >3 || 2.1.0", "2.1.0", @src());
+ expect.range(" > 2.2 || 2.1.0 || >3", "2.1.0", @src());
+ expect.range("> 2.2 || 2.1.0 || >3", "2.3.0", @src());
+ expect.notRange("> 2.2 || 2.1.0 || >3", "2.2.1", @src());
+ expect.notRange("> 2.2 || 2.1.0 || >3", "2.2.0", @src());
+ expect.range("> 2.2 || 2.1.0 || >3", "2.3.0", @src());
+ expect.range("> 2.2 || 2.1.0 || >3", "3.0.1", @src());
+ expect.range("~2", "2.0.0", @src());
+ expect.range("~2", "2.1.0", @src());
+
+ expect.range("1.2.0 - 1.3.0", "1.2.2", @src());
+ expect.range("1.2 - 1.3", "1.2.2", @src());
+ expect.range("1 - 1.3", "1.2.2", @src());
+ expect.range("1 - 1.3", "1.3.0", @src());
+ expect.range("1.2 - 1.3", "1.3.1", @src());
+ expect.notRange("1.2 - 1.3", "1.4.0", @src());
+ expect.range("1 - 1.3", "1.3.1", @src());
+
+ expect.notRange("1.2 - 1.3 || 5.0", "6.4.0", @src());
+ expect.range("1.2 - 1.3 || 5.0", "1.2.1", @src());
+ expect.range("5.0 || 1.2 - 1.3", "1.2.1", @src());
+ expect.range("1.2 - 1.3 || 5.0", "5.0", @src());
+ expect.range("5.0 || 1.2 - 1.3", "5.0", @src());
+ expect.range("1.2 - 1.3 || 5.0", "5.0.2", @src());
+ expect.range("5.0 || 1.2 - 1.3", "5.0.2", @src());
+ expect.range("1.2 - 1.3 || 5.0", "5.0.2", @src());
+ expect.range("5.0 || 1.2 - 1.3", "5.0.2", @src());
+ expect.range("5.0 || 1.2 - 1.3 || >8", "9.0.2", @src());
+}
diff --git a/src/io/fifo.zig b/src/io/fifo.zig
new file mode 100644
index 000000000..b9b3bc961
--- /dev/null
+++ b/src/io/fifo.zig
@@ -0,0 +1,104 @@
+const std = @import("std");
+const assert = std.debug.assert;
+
+/// An intrusive first in/first out linked list.
+/// The element type T must have a field called "next" of type ?*T
+pub fn FIFO(comptime T: type) type {
+ return struct {
+ const Self = @This();
+
+ in: ?*T = null,
+ out: ?*T = null,
+
+ pub fn push(self: *Self, elem: *T) void {
+ assert(elem.next == null);
+ if (self.in) |in| {
+ in.next = elem;
+ self.in = elem;
+ } else {
+ assert(self.out == null);
+ self.in = elem;
+ self.out = elem;
+ }
+ }
+
+ pub fn pop(self: *Self) ?*T {
+ const ret = self.out orelse return null;
+ self.out = ret.next;
+ ret.next = null;
+ if (self.in == ret) self.in = null;
+ return ret;
+ }
+
+ pub fn peek(self: Self) ?*T {
+ return self.out;
+ }
+
+ /// Remove an element from the FIFO. Asserts that the element is
+ /// in the FIFO. This operation is O(N), if this is done often you
+ /// probably want a different data structure.
+ pub fn remove(self: *Self, to_remove: *T) void {
+ if (to_remove == self.out) {
+ _ = self.pop();
+ return;
+ }
+ var it = self.out;
+ while (it) |elem| : (it = elem.next) {
+ if (to_remove == elem.next) {
+ if (to_remove == self.in) self.in = elem;
+ elem.next = to_remove.next;
+ to_remove.next = null;
+ break;
+ }
+ } else unreachable;
+ }
+ };
+}
+
+test "push/pop/peek/remove" {
+ const testing = @import("std").testing;
+
+ const Foo = struct { next: ?*@This() = null };
+
+ var one: Foo = .{};
+ var two: Foo = .{};
+ var three: Foo = .{};
+
+ var fifo: FIFO(Foo) = .{};
+
+ fifo.push(&one);
+ try testing.expectEqual(@as(?*Foo, &one), fifo.peek());
+
+ fifo.push(&two);
+ fifo.push(&three);
+ try testing.expectEqual(@as(?*Foo, &one), fifo.peek());
+
+ fifo.remove(&one);
+ try testing.expectEqual(@as(?*Foo, &two), fifo.pop());
+ try testing.expectEqual(@as(?*Foo, &three), fifo.pop());
+ try testing.expectEqual(@as(?*Foo, null), fifo.pop());
+
+ fifo.push(&one);
+ fifo.push(&two);
+ fifo.push(&three);
+ fifo.remove(&two);
+ try testing.expectEqual(@as(?*Foo, &one), fifo.pop());
+ try testing.expectEqual(@as(?*Foo, &three), fifo.pop());
+ try testing.expectEqual(@as(?*Foo, null), fifo.pop());
+
+ fifo.push(&one);
+ fifo.push(&two);
+ fifo.push(&three);
+ fifo.remove(&three);
+ try testing.expectEqual(@as(?*Foo, &one), fifo.pop());
+ try testing.expectEqual(@as(?*Foo, &two), fifo.pop());
+ try testing.expectEqual(@as(?*Foo, null), fifo.pop());
+
+ fifo.push(&one);
+ fifo.push(&two);
+ fifo.remove(&two);
+ fifo.push(&three);
+ try testing.expectEqual(@as(?*Foo, &one), fifo.pop());
+ try testing.expectEqual(@as(?*Foo, &three), fifo.pop());
+ try testing.expectEqual(@as(?*Foo, null), fifo.pop());
+}
diff --git a/src/io/io_darwin.zig b/src/io/io_darwin.zig
new file mode 100644
index 000000000..2042a38ea
--- /dev/null
+++ b/src/io/io_darwin.zig
@@ -0,0 +1,781 @@
+const std = @import("std");
+const os = struct {
+ pub usingnamespace std.os;
+ pub const EINTR = 4;
+ pub const EAGAIN = 35;
+ pub const EBADF = 9;
+ pub const ECONNRESET = 54;
+ pub const EFAULT = 14;
+ pub const EINVAL = 22;
+ pub const EIO = 5;
+ pub const EISDIR = 21;
+ pub const ENOBUFS = 55;
+ pub const ENOMEM = 12;
+ pub const ENXIO = 6;
+ pub const EOVERFLOW = 84;
+ pub const ESPIPE = 29;
+};
+const mem = std.mem;
+const assert = std.debug.assert;
+
+const FIFO = @import("./fifo.zig").FIFO;
+const Time = @import("./time.zig").Time;
+
+const IO = @This();
+
+kq: os.fd_t,
+time: Time = .{},
+io_inflight: usize = 0,
+timeouts: FIFO(Completion) = .{},
+completed: FIFO(Completion) = .{},
+io_pending: FIFO(Completion) = .{},
+last_event_fd: std.atomic.Atomic(u32) = std.atomic.Atomic(u32).init(32),
+
+pub fn init(entries: u12, flags: u32) !IO {
+ const kq = try os.kqueue();
+ assert(kq > -1);
+ return IO{ .kq = kq };
+}
+
+pub fn deinit(self: *IO) void {
+ assert(self.kq > -1);
+ os.close(self.kq);
+ self.kq = -1;
+}
+
+/// Pass all queued submissions to the kernel and peek for completions.
+pub fn tick(self: *IO) !void {
+ return self.flush(false);
+}
+
+/// Pass all queued submissions to the kernel and run for `nanoseconds`.
+/// The `nanoseconds` argument is a u63 to allow coercion to the i64 used
+/// in the __kernel_timespec struct.
+pub fn run_for_ns(self: *IO, nanoseconds: u63) !void {
+ var timed_out = false;
+ var completion: Completion = undefined;
+ const on_timeout = struct {
+ fn callback(
+ timed_out_ptr: *bool,
+ _completion: *Completion,
+ _result: TimeoutError!void,
+ ) void {
+ timed_out_ptr.* = true;
+ }
+ }.callback;
+
+ // Submit a timeout which sets the timed_out value to true to terminate the loop below.
+ self.timeout(
+ *bool,
+ &timed_out,
+ on_timeout,
+ &completion,
+ nanoseconds,
+ );
+
+ // Loop until our timeout completion is processed above, which sets timed_out to true.
+ // LLVM shouldn't be able to cache timed_out's value here since its address escapes above.
+ while (!timed_out) {
+ try self.flush(true);
+ }
+}
+
+fn flush(self: *IO, wait_for_completions: bool) !void {
+ var io_pending = self.io_pending.peek();
+ var events: [256]os.Kevent = undefined;
+
+ // Check timeouts and fill events with completions in io_pending
+ // (they will be submitted through kevent).
+ // Timeouts are expired here and possibly pushed to the completed queue.
+ const next_timeout = self.flush_timeouts();
+ const change_events = self.flush_io(&events, &io_pending);
+
+ // Only call kevent() if we need to submit io events or if we need to wait for completions.
+ if (change_events > 0 or self.completed.peek() == null) {
+ // Zero timeouts for kevent() implies a non-blocking poll
+ var ts = std.mem.zeroes(os.timespec);
+
+ // We need to wait (not poll) on kevent if there's nothing to submit or complete.
+ // We should never wait indefinitely (timeout_ptr = null for kevent) given:
+ // - tick() is non-blocking (wait_for_completions = false)
+ // - run_for_ns() always submits a timeout
+ if (change_events == 0 and self.completed.peek() == null) {
+ if (wait_for_completions) {
+ const timeout_ns = next_timeout orelse @panic("kevent() blocking forever");
+ ts.tv_nsec = @intCast(@TypeOf(ts.tv_nsec), timeout_ns % std.time.ns_per_s);
+ ts.tv_sec = @intCast(@TypeOf(ts.tv_sec), timeout_ns / std.time.ns_per_s);
+ } else if (self.io_inflight == 0) {
+ return;
+ }
+ }
+
+ const new_events = try os.kevent(
+ self.kq,
+ events[0..change_events],
+ events[0..events.len],
+ &ts,
+ );
+
+ // Mark the io events submitted only after kevent() successfully processed them
+ self.io_pending.out = io_pending;
+ if (io_pending == null) {
+ self.io_pending.in = null;
+ }
+
+ self.io_inflight += change_events;
+ self.io_inflight -= new_events;
+
+ for (events[0..new_events]) |kevent| {
+ const completion = @intToPtr(*Completion, kevent.udata);
+ completion.next = null;
+ self.completed.push(completion);
+ }
+ }
+
+ var completed = self.completed;
+ self.completed = .{};
+ while (completed.pop()) |completion| {
+ (completion.callback)(self, completion);
+ }
+}
+
+fn flush_io(self: *IO, events: []os.Kevent, io_pending_top: *?*Completion) usize {
+ for (events) |*kevent, flushed| {
+ const completion = io_pending_top.* orelse return flushed;
+ io_pending_top.* = completion.next;
+
+ const event_info = switch (completion.operation) {
+ .accept => |op| [3]c_int{
+ op.socket,
+ os.EVFILT_READ,
+ os.EV_ADD | os.EV_ENABLE | os.EV_ONESHOT,
+ },
+ .connect => |op| [3]c_int{
+ op.socket,
+ os.EVFILT_WRITE,
+ os.EV_ADD | os.EV_ENABLE | os.EV_ONESHOT,
+ },
+ .read => |op| [3]c_int{
+ op.fd,
+ os.EVFILT_READ,
+ os.EV_ADD | os.EV_ENABLE | os.EV_ONESHOT,
+ },
+ .write => |op| [3]c_int{
+ op.fd,
+ os.EVFILT_WRITE,
+ os.EV_ADD | os.EV_ENABLE | os.EV_ONESHOT,
+ },
+ .recv => |op| [3]c_int{
+ op.socket,
+ os.EVFILT_READ,
+ os.EV_ADD | os.EV_ENABLE | os.EV_ONESHOT,
+ },
+ .send => |op| [3]c_int{
+ op.socket,
+ os.EVFILT_WRITE,
+ os.EV_ADD | os.EV_ENABLE | os.EV_ONESHOT,
+ },
+ .event => |op| [3]c_int{
+ op.fd,
+ os.EVFILT_USER,
+ os.EV_ADD | os.EV_ENABLE | os.EV_ONESHOT,
+ },
+ else => @panic("invalid completion operation queued for io"),
+ };
+
+ kevent.* = .{
+ .ident = @intCast(u32, event_info[0]),
+ .filter = @intCast(i16, event_info[1]),
+ .flags = @intCast(u16, event_info[2]),
+ .fflags = 0,
+ .data = 0,
+ .udata = @ptrToInt(completion),
+ };
+ }
+
+ return events.len;
+}
+
+fn flush_timeouts(self: *IO) ?u64 {
+ var min_timeout: ?u64 = null;
+ var timeouts: ?*Completion = self.timeouts.peek();
+ while (timeouts) |completion| {
+ timeouts = completion.next;
+
+ // NOTE: We could cache `now` above the loop but monotonic() should be cheap to call.
+ const now = self.time.monotonic();
+ const expires = completion.operation.timeout.expires;
+
+ // NOTE: remove() could be O(1) here with a doubly-linked-list
+ // since we know the previous Completion.
+ if (now >= expires) {
+ self.timeouts.remove(completion);
+ self.completed.push(completion);
+ continue;
+ }
+
+ const timeout_ns = expires - now;
+ if (min_timeout) |min_ns| {
+ min_timeout = std.math.min(min_ns, timeout_ns);
+ } else {
+ min_timeout = timeout_ns;
+ }
+ }
+ return min_timeout;
+}
+
+/// This struct holds the data needed for a single IO operation
+pub const Completion = struct {
+ next: ?*Completion,
+ context: ?*c_void,
+ callback: fn (*IO, *Completion) void,
+ operation: Operation,
+};
+
+const Operation = union(enum) {
+ accept: struct {
+ socket: os.socket_t,
+ },
+ close: struct {
+ fd: os.fd_t,
+ },
+ connect: struct {
+ socket: os.socket_t,
+ address: std.net.Address,
+ initiated: bool,
+ },
+ fsync: struct {
+ fd: os.fd_t,
+ },
+ read: struct {
+ fd: os.fd_t,
+ buf: [*]u8,
+ len: u32,
+ offset: u64,
+ },
+ recv: struct {
+ socket: os.socket_t,
+ buf: [*]u8,
+ len: u32,
+ },
+ send: struct {
+ socket: os.socket_t,
+ buf: [*]const u8,
+ len: u32,
+ flags: u32 = 0,
+ },
+ timeout: struct {
+ expires: u64,
+ },
+ write: struct {
+ fd: os.fd_t,
+ buf: [*]const u8,
+ len: u32,
+ offset: u64,
+ },
+ event: struct {
+ fd: os.fd_t,
+ },
+};
+
+fn submit(
+ self: *IO,
+ context: anytype,
+ comptime callback: anytype,
+ completion: *Completion,
+ comptime operation_tag: std.meta.Tag(Operation),
+ operation_data: anytype,
+ comptime OperationImpl: type,
+) void {
+ const Context = @TypeOf(context);
+ const onCompleteFn = struct {
+ fn onComplete(io: *IO, _completion: *Completion) void {
+ // Perform the actual operaton
+ const op_data = &@field(_completion.operation, @tagName(operation_tag));
+ const result = OperationImpl.doOperation(op_data);
+
+ // Requeue onto io_pending if error.WouldBlock
+ switch (operation_tag) {
+ .accept, .connect, .read, .write, .send, .recv => {
+ _ = result catch |err| switch (err) {
+ error.WouldBlock => {
+ _completion.next = null;
+ io.io_pending.push(_completion);
+ return;
+ },
+ else => {},
+ };
+ },
+ else => {},
+ }
+
+ // Complete the Completion
+ return callback(
+ @intToPtr(Context, @ptrToInt(_completion.context)),
+ _completion,
+ result,
+ );
+ }
+ }.onComplete;
+
+ completion.* = .{
+ .next = null,
+ .context = context,
+ .callback = onCompleteFn,
+ .operation = @unionInit(Operation, @tagName(operation_tag), operation_data),
+ };
+
+ switch (operation_tag) {
+ .timeout => self.timeouts.push(completion),
+ else => self.completed.push(completion),
+ }
+}
+
+pub const AcceptError = os.AcceptError || os.SetSockOptError;
+
+// -- NOT DONE YET
+pub fn eventfd(self: *IO) os.fd_t {
+ return @intCast(os.fd_t, self.last_event_fd.fetchAdd(1, .Monotonic));
+}
+
+pub fn triggerEvent(event_fd: os.fd_t, completion: *Completion) !void {
+ var kevents = [1]os.Kevent{
+ .{
+ .ident = @intCast(usize, event_fd),
+ .filter = os.EVFILT_USER,
+ .flags = os.EV_ADD | os.EV_ENABLE | os.EV_ONESHOT,
+ .fflags = 0,
+ .data = 0,
+ .udata = @ptrToInt(completion),
+ },
+ };
+
+ var change_events = [1]os.Kevent{
+ .{
+ .ident = @intCast(usize, event_fd),
+ .filter = os.EVFILT_USER,
+ .flags = os.EV_ADD | os.EV_ENABLE | os.EV_ONESHOT,
+ .fflags = 0,
+ .data = 0,
+ .udata = @ptrToInt(completion),
+ },
+ };
+
+ const ret = try os.kevent(global.kq, &kevents, &change_events, null);
+ if (ret != 1) {
+ @panic("failed to trigger event");
+ }
+}
+
+// -- NOT DONE YET
+pub fn event(
+ self: *IO,
+ comptime Context: type,
+ context: Context,
+ comptime callback: fn (
+ context: Context,
+ completion: *Completion,
+ result: void,
+ ) void,
+ completion: *Completion,
+ fd: os.fd_t,
+) void {
+ self.submit(
+ context,
+ callback,
+ completion,
+ .event,
+ .{
+ .fd = fd,
+ },
+ struct {
+ fn doOperation(op: anytype) void {}
+ },
+ );
+}
+
+pub fn accept(
+ self: *IO,
+ comptime Context: type,
+ context: Context,
+ comptime callback: fn (
+ context: Context,
+ completion: *Completion,
+ result: AcceptError!os.socket_t,
+ ) void,
+ completion: *Completion,
+ socket: os.socket_t,
+) void {
+ self.submit(
+ context,
+ callback,
+ completion,
+ .accept,
+ .{
+ .socket = socket,
+ },
+ struct {
+ fn doOperation(op: anytype) AcceptError!os.socket_t {
+ const fd = try os.accept(
+ op.socket,
+ null,
+ null,
+ os.SOCK_NONBLOCK | os.SOCK_CLOEXEC,
+ );
+ errdefer os.close(fd);
+
+ // darwin doesn't support os.MSG_NOSIGNAL,
+ // but instead a socket option to avoid SIGPIPE.
+ os.setsockopt(fd, os.SOL_SOCKET, os.SO_NOSIGPIPE, &mem.toBytes(@as(c_int, 1))) catch |err| return switch (err) {
+ error.TimeoutTooBig => unreachable,
+ error.PermissionDenied => error.NetworkSubsystemFailed,
+ error.AlreadyConnected => error.NetworkSubsystemFailed,
+ error.InvalidProtocolOption => error.ProtocolFailure,
+ else => |e| e,
+ };
+
+ return fd;
+ }
+ },
+ );
+}
+
+pub const CloseError = error{
+ FileDescriptorInvalid,
+ DiskQuota,
+ InputOutput,
+ NoSpaceLeft,
+} || os.UnexpectedError;
+
+pub fn close(
+ self: *IO,
+ comptime Context: type,
+ context: Context,
+ comptime callback: fn (
+ context: Context,
+ completion: *Completion,
+ result: CloseError!void,
+ ) void,
+ completion: *Completion,
+ fd: os.fd_t,
+) void {
+ self.submit(
+ context,
+ callback,
+ completion,
+ .close,
+ .{
+ .fd = fd,
+ },
+ struct {
+ fn doOperation(op: anytype) CloseError!void {
+ return switch (os.system.close(op.fd)) {
+ 0 => {},
+ os.EBADF => error.FileDescriptorInvalid,
+ os.EINTR => {}, // A success, see https://github.com/ziglang/zig/issues/2425
+ os.EIO => error.InputOutput,
+ else => |errno| os.unexpectedErrno(os.errno(errno)),
+ };
+ }
+ },
+ );
+}
+
+pub const ConnectError = os.ConnectError;
+
+pub fn connect(
+ self: *IO,
+ comptime Context: type,
+ context: Context,
+ comptime callback: fn (
+ context: Context,
+ completion: *Completion,
+ result: ConnectError!void,
+ ) void,
+ completion: *Completion,
+ socket: os.socket_t,
+ address: std.net.Address,
+) void {
+ self.submit(
+ context,
+ callback,
+ completion,
+ .connect,
+ .{
+ .socket = socket,
+ .address = address,
+ .initiated = false,
+ },
+ struct {
+ fn doOperation(op: anytype) ConnectError!void {
+ // Don't call connect after being rescheduled by io_pending as it gives EISCONN.
+ // Instead, check the socket error to see if has been connected successfully.
+ const result = switch (op.initiated) {
+ true => os.getsockoptError(op.socket),
+ else => os.connect(op.socket, &op.address.any, op.address.getOsSockLen()),
+ };
+
+ op.initiated = true;
+ return result;
+ }
+ },
+ );
+}
+
+pub const FsyncError = os.SyncError;
+
+pub fn fsync(
+ self: *IO,
+ comptime Context: type,
+ context: Context,
+ comptime callback: fn (
+ context: Context,
+ completion: *Completion,
+ result: FsyncError!void,
+ ) void,
+ completion: *Completion,
+ fd: os.fd_t,
+) void {
+ self.submit(
+ context,
+ callback,
+ completion,
+ .fsync,
+ .{
+ .fd = fd,
+ },
+ struct {
+ fn doOperation(op: anytype) FsyncError!void {
+ _ = os.fcntl(op.fd, os.F_FULLFSYNC, 1) catch return os.fsync(op.fd);
+ }
+ },
+ );
+}
+
+pub const ReadError = error{
+ WouldBlock,
+ NotOpenForReading,
+ ConnectionResetByPeer,
+ Alignment,
+ InputOutput,
+ IsDir,
+ SystemResources,
+ Unseekable,
+} || os.UnexpectedError;
+
+pub fn read(
+ self: *IO,
+ comptime Context: type,
+ context: Context,
+ comptime callback: fn (
+ context: Context,
+ completion: *Completion,
+ result: ReadError!usize,
+ ) void,
+ completion: *Completion,
+ fd: os.fd_t,
+ buffer: []u8,
+ offset: u64,
+) void {
+ self.submit(
+ context,
+ callback,
+ completion,
+ .read,
+ .{
+ .fd = fd,
+ .buf = buffer.ptr,
+ .len = @intCast(u32, buffer_limit(buffer.len)),
+ .offset = offset,
+ },
+ struct {
+ fn doOperation(op: anytype) ReadError!usize {
+ while (true) {
+ const rc = os.system.pread(
+ op.fd,
+ op.buf,
+ op.len,
+ @bitCast(isize, op.offset),
+ );
+ return switch (@enumToInt(os.errno(rc))) {
+ 0 => @intCast(usize, rc),
+ os.EINTR => continue,
+ os.EAGAIN => error.WouldBlock,
+ os.EBADF => error.NotOpenForReading,
+ os.ECONNRESET => error.ConnectionResetByPeer,
+ os.EFAULT => unreachable,
+ os.EINVAL => error.Alignment,
+ os.EIO => error.InputOutput,
+ os.EISDIR => error.IsDir,
+ os.ENOBUFS => error.SystemResources,
+ os.ENOMEM => error.SystemResources,
+ os.ENXIO => error.Unseekable,
+ os.EOVERFLOW => error.Unseekable,
+ os.ESPIPE => error.Unseekable,
+ else => error.Unexpected,
+ };
+ }
+ }
+ },
+ );
+}
+
+pub const RecvError = os.RecvFromError;
+
+pub fn recv(
+ self: *IO,
+ comptime Context: type,
+ context: Context,
+ comptime callback: fn (
+ context: Context,
+ completion: *Completion,
+ result: RecvError!usize,
+ ) void,
+ completion: *Completion,
+ socket: os.socket_t,
+ buffer: []u8,
+) void {
+ self.submit(
+ context,
+ callback,
+ completion,
+ .recv,
+ .{
+ .socket = socket,
+ .buf = buffer.ptr,
+ .len = @intCast(u32, buffer_limit(buffer.len)),
+ },
+ struct {
+ fn doOperation(op: anytype) RecvError!usize {
+ return os.recv(op.socket, op.buf[0..op.len], 0);
+ }
+ },
+ );
+}
+
+pub const SendError = os.SendToError;
+
+pub fn send(
+ self: *IO,
+ comptime Context: type,
+ context: Context,
+ comptime callback: fn (
+ context: Context,
+ completion: *Completion,
+ result: SendError!usize,
+ ) void,
+ completion: *Completion,
+ socket: os.socket_t,
+ buffer: []const u8,
+ _: u32,
+) void {
+ self.submit(
+ context,
+ callback,
+ completion,
+ .send,
+ .{
+ .socket = socket,
+ .buf = buffer.ptr,
+ .len = @intCast(u32, buffer_limit(buffer.len)),
+ .flags = 0,
+ },
+ struct {
+ fn doOperation(op: anytype) SendError!usize {
+ return os.sendto(op.socket, op.buf[0..op.len], op.flags, null, 0);
+ }
+ },
+ );
+}
+
+pub const TimeoutError = error{Canceled} || os.UnexpectedError;
+
+pub fn timeout(
+ self: *IO,
+ comptime Context: type,
+ context: Context,
+ comptime callback: fn (
+ context: Context,
+ completion: *Completion,
+ result: TimeoutError!void,
+ ) void,
+ completion: *Completion,
+ nanoseconds: u63,
+) void {
+ self.submit(
+ context,
+ callback,
+ completion,
+ .timeout,
+ .{
+ .expires = self.time.monotonic() + nanoseconds,
+ },
+ struct {
+ fn doOperation(_: anytype) TimeoutError!void {
+ return; // timeouts don't have errors for now
+ }
+ },
+ );
+}
+
+pub const WriteError = os.PWriteError;
+
+pub fn write(
+ self: *IO,
+ comptime Context: type,
+ context: Context,
+ comptime callback: fn (
+ context: Context,
+ completion: *Completion,
+ result: WriteError!usize,
+ ) void,
+ completion: *Completion,
+ fd: os.fd_t,
+ buffer: []const u8,
+ offset: u64,
+) void {
+ self.submit(
+ context,
+ callback,
+ completion,
+ .write,
+ .{
+ .fd = fd,
+ .buf = buffer.ptr,
+ .len = @intCast(u32, buffer_limit(buffer.len)),
+ .offset = offset,
+ },
+ struct {
+ fn doOperation(op: anytype) WriteError!usize {
+ return os.pwrite(op.fd, op.buf[0..op.len], op.offset);
+ }
+ },
+ );
+}
+
+pub fn openSocket(family: u32, sock_type: u32, protocol: u32) !os.socket_t {
+ const fd = try os.socket(family, sock_type | os.SOCK_NONBLOCK, protocol);
+ errdefer os.close(fd);
+
+ // darwin doesn't support os.MSG_NOSIGNAL, but instead a socket option to avoid SIGPIPE.
+ try os.setsockopt(fd, os.SOL_SOCKET, os.SO_NOSIGPIPE, &mem.toBytes(@as(c_int, 1)));
+ return fd;
+}
+
+fn buffer_limit(buffer_len: usize) usize {
+
+ // Linux limits how much may be written in a `pwrite()/pread()` call, which is `0x7ffff000` on
+ // both 64-bit and 32-bit systems, due to using a signed C int as the return value, as well as
+ // stuffing the errno codes into the last `4096` values.
+ // Darwin limits writes to `0x7fffffff` bytes, more than that returns `EINVAL`.
+ // The corresponding POSIX limit is `std.math.maxInt(isize)`.
+ const limit = switch (std.Target.current.os.tag) {
+ .linux => 0x7ffff000,
+ .macos, .ios, .watchos, .tvos => std.math.maxInt(i32),
+ else => std.math.maxInt(isize),
+ };
+ return std.math.min(limit, buffer_len);
+}
+
+pub var global: IO = undefined;
+pub var global_loaded: bool = false;
diff --git a/src/io/io_linux.zig b/src/io/io_linux.zig
new file mode 100644
index 000000000..f69f70c5b
--- /dev/null
+++ b/src/io/io_linux.zig
@@ -0,0 +1,937 @@
+const std = @import("std");
+const assert = std.debug.assert;
+const os = struct {
+ pub usingnamespace std.os;
+ pub const ETIME = 62;
+ pub const EINTR = 4;
+ pub const EAGAIN = 11;
+ pub const EBADF = 9;
+ pub const ECONNABORTED = 103;
+ pub const EFAULT = 14;
+ pub const EINVAL = 22;
+ pub const EMFILE = 24;
+ pub const ENFILE = 23;
+ pub const ENOBUFS = 105;
+ pub const ENOMEM = 12;
+ pub const ENOTSOCK = 88;
+ pub const EOPNOTSUPP = 95;
+ pub const EPERM = 1;
+ pub const EPROTO = 71;
+ pub const EDQUOT = 69;
+ pub const EIO = 5;
+ pub const ENOSPC = 28;
+ pub const EACCES = 13;
+ pub const EADDRINUSE = 98;
+ pub const EADDRNOTAVAIL = 99;
+ pub const EAFNOSUPPORT = 97;
+ pub const EINPROGRESS = 115;
+ pub const EALREADY = 114;
+ pub const ECONNREFUSED = 111;
+ pub const ECONNRESET = 104;
+ pub const EISCONN = 106;
+ pub const ENETUNREACH = 101;
+ pub const ENOENT = 2;
+ pub const EPROTOTYPE = 91;
+ pub const ETIMEDOUT = 110;
+ pub const EROFS = 30;
+ pub const EISDIR = 21;
+ pub const ENXIO = 6;
+ pub const EOVERFLOW = 84;
+ pub const ESPIPE = 29;
+ pub const ENOTCONN = 107;
+ pub const EDESTADDRREQ = 89;
+ pub const EMSGSIZE = 90;
+ pub const EPIPE = 32;
+ pub const ECANCELED = 125;
+ pub const EFBIG = 27;
+};
+const linux = os.linux;
+const IO_Uring = linux.IO_Uring;
+const io_uring_cqe = linux.io_uring_cqe;
+const io_uring_sqe = linux.io_uring_sqe;
+
+const FIFO = @import("./fifo.zig").FIFO;
+const IO = @This();
+
+ring: IO_Uring,
+
+/// Operations not yet submitted to the kernel and waiting on available space in the
+/// submission queue.
+unqueued: FIFO(Completion) = .{},
+
+/// Completions that are ready to have their callbacks run.
+completed: FIFO(Completion) = .{},
+
+pub fn init(entries: u12, flags: u32) !IO {
+ return IO{ .ring = try IO_Uring.init(entries, flags) };
+}
+
+pub fn deinit(self: *IO) void {
+ self.ring.deinit();
+}
+
+/// Pass all queued submissions to the kernel and peek for completions.
+pub fn tick(self: *IO) !void {
+ // We assume that all timeouts submitted by `run_for_ns()` will be reaped by `run_for_ns()`
+ // and that `tick()` and `run_for_ns()` cannot be run concurrently.
+ // Therefore `timeouts` here will never be decremented and `etime` will always be false.
+ var timeouts: usize = 0;
+ var etime = false;
+
+ try self.flush(0, &timeouts, &etime);
+ assert(etime == false);
+
+ // Flush any SQEs that were queued while running completion callbacks in `flush()`:
+ // This is an optimization to avoid delaying submissions until the next tick.
+ // At the same time, we do not flush any ready CQEs since SQEs may complete synchronously.
+ // We guard against an io_uring_enter() syscall if we know we do not have any queued SQEs.
+ // We cannot use `self.ring.sq_ready()` here since this counts flushed and unflushed SQEs.
+ const queued = self.ring.sq.sqe_tail -% self.ring.sq.sqe_head;
+ if (queued > 0) {
+ try self.flush_submissions(0, &timeouts, &etime);
+ assert(etime == false);
+ }
+}
+
+/// Pass all queued submissions to the kernel and run for `nanoseconds`.
+/// The `nanoseconds` argument is a u63 to allow coercion to the i64 used
+/// in the __kernel_timespec struct.
+pub fn run_for_ns(self: *IO, nanoseconds: u63) !void {
+ // We must use the same clock source used by io_uring (CLOCK_MONOTONIC) since we specify the
+ // timeout below as an absolute value. Otherwise, we may deadlock if the clock sources are
+ // dramatically different. Any kernel that supports io_uring will support CLOCK_MONOTONIC.
+ var current_ts: os.timespec = undefined;
+ os.clock_gettime(os.CLOCK_MONOTONIC, &current_ts) catch unreachable;
+ // The absolute CLOCK_MONOTONIC time after which we may return from this function:
+ const timeout_ts: os.__kernel_timespec = .{
+ .tv_sec = current_ts.tv_sec,
+ .tv_nsec = current_ts.tv_nsec + nanoseconds,
+ };
+ var timeouts: usize = 0;
+ var etime = false;
+ while (!etime) {
+ const timeout_sqe = self.ring.get_sqe() catch blk: {
+ // The submission queue is full, so flush submissions to make space:
+ try self.flush_submissions(0, &timeouts, &etime);
+ break :blk self.ring.get_sqe() catch unreachable;
+ };
+ // Submit an absolute timeout that will be canceled if any other SQE completes first:
+ linux.io_uring_prep_timeout(timeout_sqe, &timeout_ts, 1, os.IORING_TIMEOUT_ABS);
+ timeout_sqe.user_data = 0;
+ timeouts += 1;
+ // The amount of time this call will block is bounded by the timeout we just submitted:
+ try self.flush(1, &timeouts, &etime);
+ }
+ // Reap any remaining timeouts, which reference the timespec in the current stack frame.
+ // The busy loop here is required to avoid a potential deadlock, as the kernel determines
+ // when the timeouts are pushed to the completion queue, not us.
+ while (timeouts > 0) _ = try self.flush_completions(0, &timeouts, &etime);
+}
+
+fn flush(self: *IO, wait_nr: u32, timeouts: *usize, etime: *bool) !void {
+ // Flush any queued SQEs and reuse the same syscall to wait for completions if required:
+ try self.flush_submissions(wait_nr, timeouts, etime);
+ // We can now just peek for any CQEs without waiting and without another syscall:
+ try self.flush_completions(0, timeouts, etime);
+ // Run completions only after all completions have been flushed:
+ // Loop on a copy of the linked list, having reset the list first, so that any synchronous
+ // append on running a completion is executed only the next time round the event loop,
+ // without creating an infinite loop.
+ {
+ var copy = self.completed;
+ self.completed = .{};
+ while (copy.pop()) |completion| completion.complete();
+ }
+ // Again, loop on a copy of the list to avoid an infinite loop:
+ {
+ var copy = self.unqueued;
+ self.unqueued = .{};
+ while (copy.pop()) |completion| self.enqueue(completion);
+ }
+}
+
+fn flush_completions(self: *IO, wait_nr: u32, timeouts: *usize, etime: *bool) !void {
+ var cqes: [256]io_uring_cqe = undefined;
+ var wait_remaining = wait_nr;
+ while (true) {
+ // Guard against waiting indefinitely (if there are too few requests inflight),
+ // especially if this is not the first time round the loop:
+ const completed = self.ring.copy_cqes(&cqes, wait_remaining) catch |err| switch (err) {
+ error.SignalInterrupt => continue,
+ else => return err,
+ };
+ if (completed > wait_remaining) wait_remaining = 0 else wait_remaining -= completed;
+ for (cqes[0..completed]) |cqe| {
+ if (cqe.user_data == 0) {
+ timeouts.* -= 1;
+ // We are only done if the timeout submitted was completed due to time, not if
+ // it was completed due to the completion of an event, in which case `cqe.res`
+ // would be 0. It is possible for multiple timeout operations to complete at the
+ // same time if the nanoseconds value passed to `run_for_ns()` is very short.
+ if (-cqe.res == os.ETIME) etime.* = true;
+ continue;
+ }
+ const completion = @intToPtr(*Completion, @intCast(usize, cqe.user_data));
+ completion.result = cqe.res;
+ // We do not run the completion here (instead appending to a linked list) to avoid:
+ // * recursion through `flush_submissions()` and `flush_completions()`,
+ // * unbounded stack usage, and
+ // * confusing stack traces.
+ self.completed.push(completion);
+ }
+ if (completed < cqes.len) break;
+ }
+}
+
+fn flush_submissions(self: *IO, wait_nr: u32, timeouts: *usize, etime: *bool) !void {
+ while (true) {
+ _ = self.ring.submit_and_wait(wait_nr) catch |err| switch (err) {
+ error.SignalInterrupt => continue,
+ // Wait for some completions and then try again:
+ // See https://github.com/axboe/liburing/issues/281 re: error.SystemResources.
+ // Be careful also that copy_cqes() will flush before entering to wait (it does):
+ // https://github.com/axboe/liburing/commit/35c199c48dfd54ad46b96e386882e7ac341314c5
+ error.CompletionQueueOvercommitted, error.SystemResources => {
+ try self.flush_completions(1, timeouts, etime);
+ continue;
+ },
+ else => return err,
+ };
+ break;
+ }
+}
+
+fn enqueue(self: *IO, completion: *Completion) void {
+ const sqe = self.ring.get_sqe() catch |err| switch (err) {
+ error.SubmissionQueueFull => {
+ self.unqueued.push(completion);
+ return;
+ },
+ };
+ completion.prep(sqe);
+}
+
+/// This struct holds the data needed for a single io_uring operation
+pub const Completion = struct {
+ io: *IO,
+ result: i32 = undefined,
+ next: ?*Completion = null,
+ operation: Operation,
+ // This is one of the usecases for c_void outside of C code and as such c_void will
+ // be replaced with anyopaque eventually: https://github.com/ziglang/zig/issues/323
+ context: ?*c_void,
+ callback: fn (context: ?*c_void, completion: *Completion, result: *const c_void) void,
+
+ fn prep(completion: *Completion, sqe: *io_uring_sqe) void {
+ switch (completion.operation) {
+ .accept => |*op| {
+ linux.io_uring_prep_accept(
+ sqe,
+ op.socket,
+ &op.address,
+ &op.address_size,
+ os.SOCK_CLOEXEC,
+ );
+ },
+ .close => |op| {
+ linux.io_uring_prep_close(sqe, op.fd);
+ },
+ .connect => |*op| {
+ linux.io_uring_prep_connect(
+ sqe,
+ op.socket,
+ &op.address.any,
+ op.address.getOsSockLen(),
+ );
+ },
+ .fsync => |op| {
+ linux.io_uring_prep_fsync(sqe, op.fd, 0);
+ },
+ .read => |op| {
+ linux.io_uring_prep_read(
+ sqe,
+ op.fd,
+ op.buffer[0..buffer_limit(op.buffer.len)],
+ op.offset,
+ );
+ },
+ .recv => |op| {
+ linux.io_uring_prep_recv(sqe, op.socket, op.buffer, os.MSG_NOSIGNAL);
+ },
+ .send => |op| {
+ linux.io_uring_prep_send(sqe, op.socket, op.buffer, os.MSG_NOSIGNAL);
+ },
+ .timeout => |*op| {
+ linux.io_uring_prep_timeout(sqe, &op.timespec, 0, 0);
+ },
+ .write => |op| {
+ linux.io_uring_prep_write(
+ sqe,
+ op.fd,
+ op.buffer[0..buffer_limit(op.buffer.len)],
+ op.offset,
+ );
+ },
+ }
+ sqe.user_data = @ptrToInt(completion);
+ }
+
+ fn complete(completion: *Completion) void {
+ switch (completion.operation) {
+ .accept => {
+ const result = if (completion.result < 0) switch (-completion.result) {
+ os.EINTR => {
+ completion.io.enqueue(completion);
+ return;
+ },
+ os.EAGAIN => error.WouldBlock,
+ os.EBADF => error.FileDescriptorInvalid,
+ os.ECONNABORTED => error.ConnectionAborted,
+ os.EFAULT => unreachable,
+ os.EINVAL => error.SocketNotListening,
+ os.EMFILE => error.ProcessFdQuotaExceeded,
+ os.ENFILE => error.SystemFdQuotaExceeded,
+ os.ENOBUFS => error.SystemResources,
+ os.ENOMEM => error.SystemResources,
+ os.ENOTSOCK => error.FileDescriptorNotASocket,
+ os.EOPNOTSUPP => error.OperationNotSupported,
+ os.EPERM => error.PermissionDenied,
+ os.EPROTO => error.ProtocolFailure,
+ else => error.Unexpected,
+ } else @intCast(os.socket_t, completion.result);
+ completion.callback(completion.context, completion, &result);
+ },
+ .close => {
+ const result = if (completion.result < 0) switch (-completion.result) {
+ os.EINTR => {}, // A success, see https://github.com/ziglang/zig/issues/2425
+ os.EBADF => error.FileDescriptorInvalid,
+ os.EDQUOT => error.DiskQuota,
+ os.EIO => error.InputOutput,
+ os.ENOSPC => error.NoSpaceLeft,
+ else => error.Unexpected,
+ } else assert(completion.result == 0);
+ completion.callback(completion.context, completion, &result);
+ },
+ .connect => {
+ const result = if (completion.result < 0) switch (-completion.result) {
+ os.EINTR => {
+ completion.io.enqueue(completion);
+ return;
+ },
+ os.EACCES => error.AccessDenied,
+ os.EADDRINUSE => error.AddressInUse,
+ os.EADDRNOTAVAIL => error.AddressNotAvailable,
+ os.EAFNOSUPPORT => error.AddressFamilyNotSupported,
+ os.EAGAIN, os.EINPROGRESS => error.WouldBlock,
+ os.EALREADY => error.OpenAlreadyInProgress,
+ os.EBADF => error.FileDescriptorInvalid,
+ os.ECONNREFUSED => error.ConnectionRefused,
+ os.ECONNRESET => error.ConnectionResetByPeer,
+ os.EFAULT => unreachable,
+ os.EISCONN => error.AlreadyConnected,
+ os.ENETUNREACH => error.NetworkUnreachable,
+ os.ENOENT => error.FileNotFound,
+ os.ENOTSOCK => error.FileDescriptorNotASocket,
+ os.EPERM => error.PermissionDenied,
+ os.EPROTOTYPE => error.ProtocolNotSupported,
+ os.ETIMEDOUT => error.ConnectionTimedOut,
+ else => error.Unexpected,
+ } else assert(completion.result == 0);
+ completion.callback(completion.context, completion, &result);
+ },
+ .fsync => {
+ const result = if (completion.result < 0) switch (-completion.result) {
+ os.EINTR => {
+ completion.io.enqueue(completion);
+ return;
+ },
+ os.EBADF => error.FileDescriptorInvalid,
+ os.EDQUOT => error.DiskQuota,
+ os.EINVAL => error.ArgumentsInvalid,
+ os.EIO => error.InputOutput,
+ os.ENOSPC => error.NoSpaceLeft,
+ os.EROFS => error.ReadOnlyFileSystem,
+ else => error.Unexpected,
+ } else assert(completion.result == 0);
+ completion.callback(completion.context, completion, &result);
+ },
+ .read => {
+ const result = if (completion.result < 0) switch (-completion.result) {
+ os.EINTR => {
+ completion.io.enqueue(completion);
+ return;
+ },
+ os.EAGAIN => error.WouldBlock,
+ os.EBADF => error.NotOpenForReading,
+ os.ECONNRESET => error.ConnectionResetByPeer,
+ os.EFAULT => unreachable,
+ os.EINVAL => error.Alignment,
+ os.EIO => error.InputOutput,
+ os.EISDIR => error.IsDir,
+ os.ENOBUFS => error.SystemResources,
+ os.ENOMEM => error.SystemResources,
+ os.ENXIO => error.Unseekable,
+ os.EOVERFLOW => error.Unseekable,
+ os.ESPIPE => error.Unseekable,
+ else => error.Unexpected,
+ } else @intCast(usize, completion.result);
+ completion.callback(completion.context, completion, &result);
+ },
+ .recv => {
+ const result = if (completion.result < 0) switch (-completion.result) {
+ os.EINTR => {
+ completion.io.enqueue(completion);
+ return;
+ },
+ os.EAGAIN => error.WouldBlock,
+ os.EBADF => error.FileDescriptorInvalid,
+ os.ECONNREFUSED => error.ConnectionRefused,
+ os.EFAULT => unreachable,
+ os.EINVAL => unreachable,
+ os.ENOMEM => error.SystemResources,
+ os.ENOTCONN => error.SocketNotConnected,
+ os.ENOTSOCK => error.FileDescriptorNotASocket,
+ os.ECONNRESET => error.ConnectionResetByPeer,
+ else => error.Unexpected,
+ } else @intCast(usize, completion.result);
+ completion.callback(completion.context, completion, &result);
+ },
+ .send => {
+ const result = if (completion.result < 0) switch (-completion.result) {
+ os.EINTR => {
+ completion.io.enqueue(completion);
+ return;
+ },
+ os.EACCES => error.AccessDenied,
+ os.EAGAIN => error.WouldBlock,
+ os.EALREADY => error.FastOpenAlreadyInProgress,
+ os.EAFNOSUPPORT => error.AddressFamilyNotSupported,
+ os.EBADF => error.FileDescriptorInvalid,
+ os.ECONNRESET => error.ConnectionResetByPeer,
+ os.EDESTADDRREQ => unreachable,
+ os.EFAULT => unreachable,
+ os.EINVAL => unreachable,
+ os.EISCONN => unreachable,
+ os.EMSGSIZE => error.MessageTooBig,
+ os.ENOBUFS => error.SystemResources,
+ os.ENOMEM => error.SystemResources,
+ os.ENOTCONN => error.SocketNotConnected,
+ os.ENOTSOCK => error.FileDescriptorNotASocket,
+ os.EOPNOTSUPP => error.OperationNotSupported,
+ os.EPIPE => error.BrokenPipe,
+ else => error.Unexpected,
+ } else @intCast(usize, completion.result);
+ completion.callback(completion.context, completion, &result);
+ },
+ .timeout => {
+ const result = if (completion.result < 0) switch (-completion.result) {
+ os.EINTR => {
+ completion.io.enqueue(completion);
+ return;
+ },
+ os.ECANCELED => error.Canceled,
+ os.ETIME => {}, // A success.
+ else => error.Unexpected,
+ } else unreachable;
+ completion.callback(completion.context, completion, &result);
+ },
+ .write => {
+ const result = if (completion.result < 0) switch (-completion.result) {
+ os.EINTR => {
+ completion.io.enqueue(completion);
+ return;
+ },
+ os.EAGAIN => error.WouldBlock,
+ os.EBADF => error.NotOpenForWriting,
+ os.EDESTADDRREQ => error.NotConnected,
+ os.EDQUOT => error.DiskQuota,
+ os.EFAULT => unreachable,
+ os.EFBIG => error.FileTooBig,
+ os.EINVAL => error.Alignment,
+ os.EIO => error.InputOutput,
+ os.ENOSPC => error.NoSpaceLeft,
+ os.ENXIO => error.Unseekable,
+ os.EOVERFLOW => error.Unseekable,
+ os.EPERM => error.AccessDenied,
+ os.EPIPE => error.BrokenPipe,
+ os.ESPIPE => error.Unseekable,
+ else => error.Unexpected,
+ } else @intCast(usize, completion.result);
+ completion.callback(completion.context, completion, &result);
+ },
+ }
+ }
+};
+
+/// This union encodes the set of operations supported as well as their arguments.
+const Operation = union(enum) {
+ accept: struct {
+ socket: os.socket_t,
+ address: os.sockaddr = undefined,
+ address_size: os.socklen_t = @sizeOf(os.sockaddr),
+ },
+ close: struct {
+ fd: os.fd_t,
+ },
+ connect: struct {
+ socket: os.socket_t,
+ address: std.net.Address,
+ },
+ fsync: struct {
+ fd: os.fd_t,
+ },
+ read: struct {
+ fd: os.fd_t,
+ buffer: []u8,
+ offset: u64,
+ },
+ recv: struct {
+ socket: os.socket_t,
+ buffer: []u8,
+ },
+ send: struct {
+ socket: os.socket_t,
+ buffer: []const u8,
+ },
+ timeout: struct {
+ timespec: os.__kernel_timespec,
+ },
+ write: struct {
+ fd: os.fd_t,
+ buffer: []const u8,
+ offset: u64,
+ },
+};
+
+pub const AcceptError = error{
+ WouldBlock,
+ FileDescriptorInvalid,
+ ConnectionAborted,
+ SocketNotListening,
+ ProcessFdQuotaExceeded,
+ SystemFdQuotaExceeded,
+ SystemResources,
+ FileDescriptorNotASocket,
+ OperationNotSupported,
+ PermissionDenied,
+ ProtocolFailure,
+} || os.UnexpectedError;
+
+pub fn accept(
+ self: *IO,
+ comptime Context: type,
+ context: Context,
+ comptime callback: fn (
+ context: Context,
+ completion: *Completion,
+ result: AcceptError!os.socket_t,
+ ) void,
+ completion: *Completion,
+ socket: os.socket_t,
+) void {
+ completion.* = .{
+ .io = self,
+ .context = context,
+ .callback = struct {
+ fn wrapper(ctx: ?*c_void, comp: *Completion, res: *const c_void) void {
+ callback(
+ @intToPtr(Context, @ptrToInt(ctx)),
+ comp,
+ @intToPtr(*const AcceptError!os.socket_t, @ptrToInt(res)).*,
+ );
+ }
+ }.wrapper,
+ .operation = .{
+ .accept = .{
+ .socket = socket,
+ .address = undefined,
+ .address_size = @sizeOf(os.sockaddr),
+ },
+ },
+ };
+ self.enqueue(completion);
+}
+
+pub const CloseError = error{
+ FileDescriptorInvalid,
+ DiskQuota,
+ InputOutput,
+ NoSpaceLeft,
+} || os.UnexpectedError;
+
+pub fn close(
+ self: *IO,
+ comptime Context: type,
+ context: Context,
+ comptime callback: fn (
+ context: Context,
+ completion: *Completion,
+ result: CloseError!void,
+ ) void,
+ completion: *Completion,
+ fd: os.fd_t,
+) void {
+ completion.* = .{
+ .io = self,
+ .context = context,
+ .callback = struct {
+ fn wrapper(ctx: ?*c_void, comp: *Completion, res: *const c_void) void {
+ callback(
+ @intToPtr(Context, @ptrToInt(ctx)),
+ comp,
+ @intToPtr(*const CloseError!void, @ptrToInt(res)).*,
+ );
+ }
+ }.wrapper,
+ .operation = .{
+ .close = .{ .fd = fd },
+ },
+ };
+ self.enqueue(completion);
+}
+
+pub const ConnectError = error{
+ AccessDenied,
+ AddressInUse,
+ AddressNotAvailable,
+ AddressFamilyNotSupported,
+ WouldBlock,
+ OpenAlreadyInProgress,
+ FileDescriptorInvalid,
+ ConnectionRefused,
+ AlreadyConnected,
+ NetworkUnreachable,
+ FileNotFound,
+ FileDescriptorNotASocket,
+ PermissionDenied,
+ ProtocolNotSupported,
+ ConnectionTimedOut,
+} || os.UnexpectedError;
+
+pub fn connect(
+ self: *IO,
+ comptime Context: type,
+ context: Context,
+ comptime callback: fn (
+ context: Context,
+ completion: *Completion,
+ result: ConnectError!void,
+ ) void,
+ completion: *Completion,
+ socket: os.socket_t,
+ address: std.net.Address,
+) void {
+ completion.* = .{
+ .io = self,
+ .context = context,
+ .callback = struct {
+ fn wrapper(ctx: ?*c_void, comp: *Completion, res: *const c_void) void {
+ callback(
+ @intToPtr(Context, @ptrToInt(ctx)),
+ comp,
+ @intToPtr(*const ConnectError!void, @ptrToInt(res)).*,
+ );
+ }
+ }.wrapper,
+ .operation = .{
+ .connect = .{
+ .socket = socket,
+ .address = address,
+ },
+ },
+ };
+ self.enqueue(completion);
+}
+
+pub const FsyncError = error{
+ FileDescriptorInvalid,
+ DiskQuota,
+ ArgumentsInvalid,
+ InputOutput,
+ NoSpaceLeft,
+ ReadOnlyFileSystem,
+} || os.UnexpectedError;
+
+pub fn fsync(
+ self: *IO,
+ comptime Context: type,
+ context: Context,
+ comptime callback: fn (
+ context: Context,
+ completion: *Completion,
+ result: FsyncError!void,
+ ) void,
+ completion: *Completion,
+ fd: os.fd_t,
+) void {
+ completion.* = .{
+ .io = self,
+ .context = context,
+ .callback = struct {
+ fn wrapper(ctx: ?*c_void, comp: *Completion, res: *const c_void) void {
+ callback(
+ @intToPtr(Context, @ptrToInt(ctx)),
+ comp,
+ @intToPtr(*const FsyncError!void, @ptrToInt(res)).*,
+ );
+ }
+ }.wrapper,
+ .operation = .{
+ .fsync = .{
+ .fd = fd,
+ },
+ },
+ };
+ self.enqueue(completion);
+}
+
+pub const ReadError = error{
+ WouldBlock,
+ NotOpenForReading,
+ ConnectionResetByPeer,
+ Alignment,
+ InputOutput,
+ IsDir,
+ SystemResources,
+ Unseekable,
+} || os.UnexpectedError;
+
+pub fn read(
+ self: *IO,
+ comptime Context: type,
+ context: Context,
+ comptime callback: fn (
+ context: Context,
+ completion: *Completion,
+ result: ReadError!usize,
+ ) void,
+ completion: *Completion,
+ fd: os.fd_t,
+ buffer: []u8,
+ offset: u64,
+) void {
+ completion.* = .{
+ .io = self,
+ .context = context,
+ .callback = struct {
+ fn wrapper(ctx: ?*c_void, comp: *Completion, res: *const c_void) void {
+ callback(
+ @intToPtr(Context, @ptrToInt(ctx)),
+ comp,
+ @intToPtr(*const ReadError!usize, @ptrToInt(res)).*,
+ );
+ }
+ }.wrapper,
+ .operation = .{
+ .read = .{
+ .fd = fd,
+ .buffer = buffer,
+ .offset = offset,
+ },
+ },
+ };
+ self.enqueue(completion);
+}
+
+pub const RecvError = error{
+ WouldBlock,
+ FileDescriptorInvalid,
+ ConnectionRefused,
+ SystemResources,
+ SocketNotConnected,
+ FileDescriptorNotASocket,
+} || os.UnexpectedError;
+
+pub fn recv(
+ self: *IO,
+ comptime Context: type,
+ context: Context,
+ comptime callback: fn (
+ context: Context,
+ completion: *Completion,
+ result: RecvError!usize,
+ ) void,
+ completion: *Completion,
+ socket: os.socket_t,
+ buffer: []u8,
+) void {
+ completion.* = .{
+ .io = self,
+ .context = context,
+ .callback = struct {
+ fn wrapper(ctx: ?*c_void, comp: *Completion, res: *const c_void) void {
+ callback(
+ @intToPtr(Context, @ptrToInt(ctx)),
+ comp,
+ @intToPtr(*const RecvError!usize, @ptrToInt(res)).*,
+ );
+ }
+ }.wrapper,
+ .operation = .{
+ .recv = .{
+ .socket = socket,
+ .buffer = buffer,
+ },
+ },
+ };
+ self.enqueue(completion);
+}
+
+pub const SendError = error{
+ AccessDenied,
+ WouldBlock,
+ FastOpenAlreadyInProgress,
+ AddressFamilyNotSupported,
+ FileDescriptorInvalid,
+ ConnectionResetByPeer,
+ MessageTooBig,
+ SystemResources,
+ SocketNotConnected,
+ FileDescriptorNotASocket,
+ OperationNotSupported,
+ BrokenPipe,
+} || os.UnexpectedError;
+
+pub fn send(
+ self: *IO,
+ comptime Context: type,
+ context: Context,
+ comptime callback: fn (
+ context: Context,
+ completion: *Completion,
+ result: SendError!usize,
+ ) void,
+ completion: *Completion,
+ socket: os.socket_t,
+ buffer: []const u8,
+ _: u32,
+) void {
+ completion.* = .{
+ .io = self,
+ .context = context,
+ .callback = struct {
+ fn wrapper(ctx: ?*c_void, comp: *Completion, res: *const c_void) void {
+ callback(
+ @intToPtr(Context, @ptrToInt(ctx)),
+ comp,
+ @intToPtr(*const SendError!usize, @ptrToInt(res)).*,
+ );
+ }
+ }.wrapper,
+ .operation = .{
+ .send = .{
+ .socket = socket,
+ .buffer = buffer,
+ },
+ },
+ };
+ self.enqueue(completion);
+}
+
+pub const TimeoutError = error{Canceled} || os.UnexpectedError;
+
+pub fn timeout(
+ self: *IO,
+ comptime Context: type,
+ context: Context,
+ comptime callback: fn (
+ context: Context,
+ completion: *Completion,
+ result: TimeoutError!void,
+ ) void,
+ completion: *Completion,
+ nanoseconds: u63,
+) void {
+ completion.* = .{
+ .io = self,
+ .context = context,
+ .callback = struct {
+ fn wrapper(ctx: ?*c_void, comp: *Completion, res: *const c_void) void {
+ callback(
+ @intToPtr(Context, @ptrToInt(ctx)),
+ comp,
+ @intToPtr(*const TimeoutError!void, @ptrToInt(res)).*,
+ );
+ }
+ }.wrapper,
+ .operation = .{
+ .timeout = .{
+ .timespec = .{ .tv_sec = 0, .tv_nsec = nanoseconds },
+ },
+ },
+ };
+ self.enqueue(completion);
+}
+
+pub const WriteError = error{
+ WouldBlock,
+ NotOpenForWriting,
+ NotConnected,
+ DiskQuota,
+ FileTooBig,
+ Alignment,
+ InputOutput,
+ NoSpaceLeft,
+ Unseekable,
+ AccessDenied,
+ BrokenPipe,
+} || os.UnexpectedError;
+
+pub fn write(
+ self: *IO,
+ comptime Context: type,
+ context: Context,
+ comptime callback: fn (
+ context: Context,
+ completion: *Completion,
+ result: WriteError!usize,
+ ) void,
+ completion: *Completion,
+ fd: os.fd_t,
+ buffer: []const u8,
+ offset: u64,
+) void {
+ completion.* = .{
+ .io = self,
+ .context = context,
+ .callback = struct {
+ fn wrapper(ctx: ?*c_void, comp: *Completion, res: *const c_void) void {
+ callback(
+ @intToPtr(Context, @ptrToInt(ctx)),
+ comp,
+ @intToPtr(*const WriteError!usize, @ptrToInt(res)).*,
+ );
+ }
+ }.wrapper,
+ .operation = .{
+ .write = .{
+ .fd = fd,
+ .buffer = buffer,
+ .offset = offset,
+ },
+ },
+ };
+ self.enqueue(completion);
+}
+
+pub fn openSocket(family: u32, sock_type: u32, protocol: u32) !os.socket_t {
+ return os.socket(family, sock_type, protocol);
+}
+
+pub var global: IO = undefined;
+pub var global_loaded: bool = false;
+
+fn buffer_limit(buffer_len: usize) usize {
+
+ // Linux limits how much may be written in a `pwrite()/pread()` call, which is `0x7ffff000` on
+ // both 64-bit and 32-bit systems, due to using a signed C int as the return value, as well as
+ // stuffing the errno codes into the last `4096` values.
+ // Darwin limits writes to `0x7fffffff` bytes, more than that returns `EINVAL`.
+ // The corresponding POSIX limit is `std.math.maxInt(isize)`.
+ const limit = switch (std.Target.current.os.tag) {
+ .linux => 0x7ffff000,
+ .macos, .ios, .watchos, .tvos => std.math.maxInt(i32),
+ else => std.math.maxInt(isize),
+ };
+ return std.math.min(limit, buffer_len);
+}
diff --git a/src/io/time.zig b/src/io/time.zig
new file mode 100644
index 000000000..2bfe24da0
--- /dev/null
+++ b/src/io/time.zig
@@ -0,0 +1,64 @@
+const std = @import("std");
+const assert = std.debug.assert;
+const is_darwin = std.Target.current.isDarwin();
+
+pub const Time = struct {
+ const Self = @This();
+
+ /// Hardware and/or software bugs can mean that the monotonic clock may regress.
+ /// One example (of many): https://bugzilla.redhat.com/show_bug.cgi?id=448449
+ /// We crash the process for safety if this ever happens, to protect against infinite loops.
+ /// It's better to crash and come back with a valid monotonic clock than get stuck forever.
+ monotonic_guard: u64 = 0,
+
+ /// A timestamp to measure elapsed time, meaningful only on the same system, not across reboots.
+ /// Always use a monotonic timestamp if the goal is to measure elapsed time.
+ /// This clock is not affected by discontinuous jumps in the system time, for example if the
+ /// system administrator manually changes the clock.
+ pub fn monotonic(self: *Self) u64 {
+ const m = blk: {
+ // Uses mach_continuous_time() instead of mach_absolute_time() as it counts while suspended.
+ // https://developer.apple.com/documentation/kernel/1646199-mach_continuous_time
+ // https://opensource.apple.com/source/Libc/Libc-1158.1.2/gen/clock_gettime.c.auto.html
+ if (is_darwin) {
+ const darwin = struct {
+ const mach_timebase_info_t = std.os.darwin.mach_timebase_info_data;
+ extern "c" fn mach_timebase_info(info: *mach_timebase_info_t) std.os.darwin.kern_return_t;
+ extern "c" fn mach_continuous_time() u64;
+ };
+
+ const now = darwin.mach_continuous_time();
+ var info: darwin.mach_timebase_info_t = undefined;
+ if (darwin.mach_timebase_info(&info) != 0) @panic("mach_timebase_info() failed");
+ return (now * info.numer) / info.denom;
+ }
+
+ // The true monotonic clock on Linux is not in fact CLOCK_MONOTONIC:
+ // CLOCK_MONOTONIC excludes elapsed time while the system is suspended (e.g. VM migration).
+ // CLOCK_BOOTTIME is the same as CLOCK_MONOTONIC but includes elapsed time during a suspend.
+ // For more detail and why CLOCK_MONOTONIC_RAW is even worse than CLOCK_MONOTONIC,
+ // see https://github.com/ziglang/zig/pull/933#discussion_r656021295.
+ var ts: std.os.timespec = undefined;
+ std.os.clock_gettime(std.os.CLOCK_BOOTTIME, &ts) catch @panic("CLOCK_BOOTTIME required");
+ break :blk @intCast(u64, ts.tv_sec) * std.time.ns_per_s + @intCast(u64, ts.tv_nsec);
+ };
+
+ // "Oops!...I Did It Again"
+ if (m < self.monotonic_guard) @panic("a hardware/kernel bug regressed the monotonic clock");
+ self.monotonic_guard = m;
+ return m;
+ }
+
+ /// A timestamp to measure real (i.e. wall clock) time, meaningful across systems, and reboots.
+ /// This clock is affected by discontinuous jumps in the system time.
+ pub fn realtime(self: *Self) i64 {
+ // macos has supported clock_gettime() since 10.12:
+ // https://opensource.apple.com/source/Libc/Libc-1158.1.2/gen/clock_gettime.3.auto.html
+
+ var ts: std.os.timespec = undefined;
+ std.os.clock_gettime(std.os.CLOCK_REALTIME, &ts) catch unreachable;
+ return @as(i64, ts.tv_sec) * std.time.ns_per_s + ts.tv_nsec;
+ }
+
+ pub fn tick(self: *Self) void {}
+};
diff --git a/src/javascript/jsc/JavascriptCore.zig b/src/javascript/jsc/JavascriptCore.zig
index e6ac23bb7..807ea0053 100644
--- a/src/javascript/jsc/JavascriptCore.zig
+++ b/src/javascript/jsc/JavascriptCore.zig
@@ -174,7 +174,7 @@ pub extern "c" fn JSObjectMakeArray(ctx: JSContextRef, argumentCount: usize, arg
pub extern "c" fn JSObjectMakeDate(ctx: JSContextRef, argumentCount: usize, arguments: [*c]const JSValueRef, exception: ExceptionRef) JSObjectRef;
pub extern "c" fn JSObjectMakeError(ctx: JSContextRef, argumentCount: usize, arguments: [*c]const JSValueRef, exception: ExceptionRef) JSObjectRef;
pub extern "c" fn JSObjectMakeRegExp(ctx: JSContextRef, argumentCount: usize, arguments: [*c]const JSValueRef, exception: ExceptionRef) JSObjectRef;
-pub extern "c" fn JSObjectMakeDeferredPromise(ctx: JSContextRef, resolve: [*c]JSObjectRef, reject: [*c]JSObjectRef, exception: ExceptionRef) JSObjectRef;
+pub extern "c" fn JSObjectMakeDeferredPromise(ctx: JSContextRef, resolve: ?*JSObjectRef, reject: ?*JSObjectRef, exception: ExceptionRef) JSObjectRef;
pub extern "c" fn JSObjectMakeFunction(ctx: JSContextRef, name: JSStringRef, parameterCount: c_uint, parameterNames: [*c]const JSStringRef, body: JSStringRef, sourceURL: JSStringRef, startingLineNumber: c_int, exception: ExceptionRef) JSObjectRef;
pub extern "c" fn JSObjectGetPrototype(ctx: JSContextRef, object: JSObjectRef) JSValueRef;
pub extern "c" fn JSObjectSetPrototype(ctx: JSContextRef, object: JSObjectRef, value: JSValueRef) void;
diff --git a/src/javascript/jsc/api/router.zig b/src/javascript/jsc/api/router.zig
index 35bd2a865..3b3cf8f99 100644
--- a/src/javascript/jsc/api/router.zig
+++ b/src/javascript/jsc/api/router.zig
@@ -31,7 +31,9 @@ pub fn importRoute(
exception: js.ExceptionRef,
) js.JSObjectRef {
const prom = JSModuleLoader.loadAndEvaluateModule(VirtualMachine.vm.global, ZigString.init(this.route.file_path));
- VirtualMachine.vm.global.vm().drainMicrotasks();
+
+ VirtualMachine.vm.tick();
+
return prom.result(VirtualMachine.vm.global.vm()).asRef();
}
diff --git a/src/javascript/jsc/base.zig b/src/javascript/jsc/base.zig
index 63e07b635..64a0f15a3 100644
--- a/src/javascript/jsc/base.zig
+++ b/src/javascript/jsc/base.zig
@@ -1552,6 +1552,7 @@ pub fn castObj(obj: js.JSObjectRef, comptime Type: type) *Type {
const JSNode = @import("../../js_ast.zig").Macro.JSNode;
const LazyPropertiesObject = @import("../../js_ast.zig").Macro.LazyPropertiesObject;
const ModuleNamespace = @import("../../js_ast.zig").Macro.ModuleNamespace;
+const FetchTaskletContext = Fetch.FetchTasklet.FetchTaskletContext;
pub const JSPrivateDataPtr = TaggedPointerUnion(.{
ResolveError,
BuildError,
@@ -1564,6 +1565,7 @@ pub const JSPrivateDataPtr = TaggedPointerUnion(.{
JSNode,
LazyPropertiesObject,
ModuleNamespace,
+ FetchTaskletContext,
});
pub inline fn GetJSPrivateData(comptime Type: type, ref: js.JSObjectRef) ?*Type {
diff --git a/src/javascript/jsc/bindings/ZigGlobalObject.cpp b/src/javascript/jsc/bindings/ZigGlobalObject.cpp
index b8470ce4b..4d8a2a6da 100644
--- a/src/javascript/jsc/bindings/ZigGlobalObject.cpp
+++ b/src/javascript/jsc/bindings/ZigGlobalObject.cpp
@@ -5,7 +5,7 @@
#include <JavaScriptCore/AggregateError.h>
#include <JavaScriptCore/BytecodeIndex.h>
#include <JavaScriptCore/CallFrameInlines.h>
-#include <JavaScriptCore/CatchScope.h>
+
#include <JavaScriptCore/ClassInfo.h>
#include <JavaScriptCore/CodeBlock.h>
#include <JavaScriptCore/CodeCache.h>
@@ -27,6 +27,7 @@
#include <JavaScriptCore/JSCast.h>
#include <JavaScriptCore/JSClassRef.h>
// #include <JavaScriptCore/JSContextInternal.h>
+#include <JavaScriptCore/CatchScope.h>
#include <JavaScriptCore/JSInternalPromise.h>
#include <JavaScriptCore/JSLock.h>
#include <JavaScriptCore/JSMap.h>
@@ -50,6 +51,7 @@
#include <JavaScriptCore/VM.h>
#include <JavaScriptCore/VMEntryScope.h>
#include <JavaScriptCore/WasmFaultSignalHandler.h>
+#include <wtf/Gigacage.h>
#include <wtf/StdLibExtras.h>
#include <wtf/URL.h>
#include <wtf/text/ExternalStringImpl.h>
@@ -58,8 +60,6 @@
#include <wtf/text/StringView.h>
#include <wtf/text/WTFString.h>
-#include <wtf/Gigacage.h>
-
#include <cstdlib>
#include <exception>
#include <iostream>
@@ -130,7 +130,7 @@ const JSC::GlobalObjectMethodTable GlobalObject::s_globalObjectMethodTable = {
&supportsRichSourceInfo,
&shouldInterruptScript,
&javaScriptRuntimeFlags,
- nullptr, // queueTaskToEventLoop
+ &queueMicrotaskToEventLoop, // queueTaskToEventLoop
nullptr, // &shouldInterruptScriptBeforeTimeout,
&moduleLoaderImportModule, // moduleLoaderImportModule
&moduleLoaderResolve, // moduleLoaderResolve
@@ -454,4 +454,11 @@ JSC::JSValue GlobalObject::moduleLoaderEvaluate(JSGlobalObject *globalObject,
return result;
}
+void GlobalObject::queueMicrotaskToEventLoop(JSC::JSGlobalObject &global,
+ Ref<JSC::Microtask> &&task) {
+
+ Zig__GlobalObject__queueMicrotaskToEventLoop(
+ &global, &JSMicrotaskCallback::create(global, WTFMove(task)).leakRef());
+}
+
} // namespace Zig \ No newline at end of file
diff --git a/src/javascript/jsc/bindings/ZigGlobalObject.h b/src/javascript/jsc/bindings/ZigGlobalObject.h
index 4b1e1e935..64ece0c64 100644
--- a/src/javascript/jsc/bindings/ZigGlobalObject.h
+++ b/src/javascript/jsc/bindings/ZigGlobalObject.h
@@ -10,10 +10,10 @@ class Identifier;
} // namespace JSC
#include "ZigConsoleClient.h"
+#include <JavaScriptCore/CatchScope.h>
#include <JavaScriptCore/JSGlobalObject.h>
#include <JavaScriptCore/JSTypeInfo.h>
#include <JavaScriptCore/Structure.h>
-
namespace Zig {
class GlobalObject : public JSC::JSGlobalObject {
@@ -45,6 +45,7 @@ class GlobalObject : public JSC::JSGlobalObject {
static void reportUncaughtExceptionAtEventLoop(JSGlobalObject *, JSC::Exception *);
+ static void queueMicrotaskToEventLoop(JSC::JSGlobalObject &global, Ref<JSC::Microtask> &&task);
static JSC::JSInternalPromise *moduleLoaderImportModule(JSGlobalObject *, JSC::JSModuleLoader *,
JSC::JSString *moduleNameValue,
JSC::JSValue parameters,
@@ -69,4 +70,29 @@ class GlobalObject : public JSC::JSGlobalObject {
: JSC::JSGlobalObject(vm, structure, &s_globalObjectMethodTable) {}
};
+class JSMicrotaskCallback : public RefCounted<JSMicrotaskCallback> {
+ public:
+ static Ref<JSMicrotaskCallback> create(JSC::JSGlobalObject &globalObject,
+ Ref<JSC::Microtask> &&task) {
+ return adoptRef(*new JSMicrotaskCallback(globalObject, WTFMove(task)));
+ }
+
+ void call() {
+ auto protectedThis{makeRef(*this)};
+ JSC::VM &vm = m_globalObject->vm();
+ JSC::JSLockHolder lock(vm);
+ auto scope = DECLARE_CATCH_SCOPE(vm);
+ auto task = &m_task.get();
+ task->run(m_globalObject.get());
+ scope.assertNoExceptionExceptTermination();
+ }
+
+ private:
+ JSMicrotaskCallback(JSC::JSGlobalObject &globalObject, Ref<JSC::Microtask> &&task)
+ : m_globalObject{globalObject.vm(), &globalObject}, m_task{WTFMove(task)} {}
+
+ JSC::Strong<JSC::JSGlobalObject> m_globalObject;
+ Ref<JSC::Microtask> m_task;
+};
+
} // namespace Zig
diff --git a/src/javascript/jsc/bindings/bindings.cpp b/src/javascript/jsc/bindings/bindings.cpp
index 674849fc6..f29cfe1e9 100644
--- a/src/javascript/jsc/bindings/bindings.cpp
+++ b/src/javascript/jsc/bindings/bindings.cpp
@@ -23,6 +23,7 @@
#include <JavaScriptCore/JSObject.h>
#include <JavaScriptCore/JSSet.h>
#include <JavaScriptCore/JSString.h>
+#include <JavaScriptCore/Microtask.h>
#include <JavaScriptCore/ObjectConstructor.h>
#include <JavaScriptCore/ParserError.h>
#include <JavaScriptCore/ScriptExecutable.h>
@@ -37,6 +38,7 @@
#include <wtf/text/WTFString.h>
extern "C" {
+
JSC__JSValue
JSC__JSObject__create(JSC__JSGlobalObject *globalObject, size_t initialCapacity, void *arg2,
void (*ArgFn3)(void *arg0, JSC__JSObject *arg1, JSC__JSGlobalObject *arg2)) {
@@ -283,6 +285,10 @@ bWTF__String JSC__JSString__value(JSC__JSString *arg0, JSC__JSGlobalObject *arg1
// arg2->depen
// }
+void Microtask__run(void *microtask, void *global) {
+ reinterpret_cast<Zig::JSMicrotaskCallback *>(microtask)->call();
+}
+
bool JSC__JSModuleLoader__checkSyntax(JSC__JSGlobalObject *arg0, const JSC__SourceCode *arg1,
bool arg2) {
JSC::ParserError error;
diff --git a/src/javascript/jsc/bindings/bindings.zig b/src/javascript/jsc/bindings/bindings.zig
index 02f026ea5..4973a0400 100644
--- a/src/javascript/jsc/bindings/bindings.zig
+++ b/src/javascript/jsc/bindings/bindings.zig
@@ -314,6 +314,12 @@ pub fn NewGlobalObject(comptime Type: type) type {
return JSValue.jsUndefined();
}
+ pub fn queueMicrotaskToEventLoop(global: *JSGlobalObject, microtask: *Microtask) callconv(.C) void {
+ if (comptime @hasDecl(Type, "queueMicrotaskToEventLoop")) {
+ @call(.{ .modifier = .always_inline }, Type.queueMicrotaskToEventLoop, .{ global, microtask });
+ }
+ }
+
pub fn onCrash() callconv(.C) void {
if (comptime @hasDecl(Type, "onCrash")) {
return @call(.{ .modifier = .always_inline }, Type.onCrash, .{});
@@ -1504,6 +1510,20 @@ pub const JSValue = enum(i64) {
pub const Extern = [_][]const u8{ "getLengthOfArray", "toZigString", "createStringArray", "createEmptyObject", "putRecord", "asPromise", "isClass", "getNameProperty", "getClassName", "getErrorsProperty", "toInt32", "toBoolean", "isInt32", "isIterable", "forEach", "isAggregateError", "toZigException", "isException", "toWTFString", "hasProperty", "getPropertyNames", "getDirect", "putDirect", "get", "getIfExists", "asString", "asObject", "asNumber", "isError", "jsNull", "jsUndefined", "jsTDZValue", "jsBoolean", "jsDoubleNumber", "jsNumberFromDouble", "jsNumberFromChar", "jsNumberFromU16", "jsNumberFromInt32", "jsNumberFromInt64", "jsNumberFromUint64", "isUndefined", "isNull", "isUndefinedOrNull", "isBoolean", "isAnyInt", "isUInt32AsAnyInt", "isInt32AsAnyInt", "isNumber", "isString", "isBigInt", "isHeapBigInt", "isBigInt32", "isSymbol", "isPrimitive", "isGetterSetter", "isCustomGetterSetter", "isObject", "isCell", "asCell", "toString", "toStringOrNull", "toPropertyKey", "toPropertyKeyValue", "toObject", "toString", "getPrototype", "getPropertyByPropertyName", "eqlValue", "eqlCell", "isCallable" };
};
+extern "c" fn Microtask__run(*Microtask, *JSGlobalObject) void;
+
+pub const Microtask = opaque {
+ pub const name = "Zig::JSMicrotaskCallback";
+
+ pub fn run(this: *Microtask, global_object: *JSGlobalObject) void {
+ if (comptime is_bindgen) {
+ return;
+ }
+
+ return Microtask__run(this, global_object);
+ }
+};
+
pub const PropertyName = extern struct {
pub const shim = Shimmer("JSC", "PropertyName", @This());
bytes: shim.Bytes,
diff --git a/src/javascript/jsc/bindings/exports.zig b/src/javascript/jsc/bindings/exports.zig
index b325a1208..00f58e745 100644
--- a/src/javascript/jsc/bindings/exports.zig
+++ b/src/javascript/jsc/bindings/exports.zig
@@ -109,6 +109,13 @@ pub const ZigGlobalObject = extern struct {
return @call(.{ .modifier = .always_inline }, Interface.onCrash, .{});
}
+ pub fn queueMicrotaskToEventLoop(global: *JSGlobalObject, microtask: *Microtask) callconv(.C) void {
+ if (comptime is_bindgen) {
+ unreachable;
+ }
+ return @call(.{ .modifier = .always_inline }, Interface.queueMicrotaskToEventLoop, .{ global, microtask });
+ }
+
pub const Export = shim.exportFunctions(
.{
.@"import" = import,
@@ -119,6 +126,7 @@ pub const ZigGlobalObject = extern struct {
.@"reportUncaughtException" = reportUncaughtException,
.@"createImportMetaProperties" = createImportMetaProperties,
.@"onCrash" = onCrash,
+ .@"queueMicrotaskToEventLoop" = queueMicrotaskToEventLoop,
},
);
@@ -132,6 +140,7 @@ pub const ZigGlobalObject = extern struct {
@export(reportUncaughtException, .{ .name = Export[4].symbol_name });
@export(createImportMetaProperties, .{ .name = Export[5].symbol_name });
@export(onCrash, .{ .name = Export[6].symbol_name });
+ @export(queueMicrotaskToEventLoop, .{ .name = Export[7].symbol_name });
}
};
diff --git a/src/javascript/jsc/bindings/headers-cpp.h b/src/javascript/jsc/bindings/headers-cpp.h
index 8b050bbfe..c57f02fe9 100644
--- a/src/javascript/jsc/bindings/headers-cpp.h
+++ b/src/javascript/jsc/bindings/headers-cpp.h
@@ -1,4 +1,4 @@
-//-- AUTOGENERATED FILE -- 1636158703
+//-- AUTOGENERATED FILE -- 1639884060
// clang-format off
#pragma once
diff --git a/src/javascript/jsc/bindings/headers-handwritten.h b/src/javascript/jsc/bindings/headers-handwritten.h
index a8d53f6e3..e07eca6b6 100644
--- a/src/javascript/jsc/bindings/headers-handwritten.h
+++ b/src/javascript/jsc/bindings/headers-handwritten.h
@@ -97,4 +97,5 @@ const JSErrorCode JSErrorCodeUserErrorCode = 254;
extern "C" ZigErrorCode Zig_ErrorCodeParserError;
extern "C" void ZigString__free(const unsigned char *ptr, size_t len, void *allocator);
+extern "C" void Microtask__run(void *ptr, void *global);
#endif
diff --git a/src/javascript/jsc/bindings/headers.h b/src/javascript/jsc/bindings/headers.h
index 8c2586ba8..95c6b78ad 100644
--- a/src/javascript/jsc/bindings/headers.h
+++ b/src/javascript/jsc/bindings/headers.h
@@ -1,5 +1,5 @@
// clang-format: off
-//-- AUTOGENERATED FILE -- 1636158703
+//-- AUTOGENERATED FILE -- 1639884060
#pragma once
#include <stddef.h>
@@ -108,6 +108,7 @@ typedef void* JSClassRef;
typedef ZigException ZigException;
typedef struct JSC__SetIteratorPrototype JSC__SetIteratorPrototype; // JSC::SetIteratorPrototype
typedef bJSC__SourceCode JSC__SourceCode; // JSC::SourceCode
+ typedef struct Zig__JSMicrotaskCallback Zig__JSMicrotaskCallback; // Zig::JSMicrotaskCallback
typedef bJSC__JSCell JSC__JSCell; // JSC::JSCell
typedef struct JSC__BigIntPrototype JSC__BigIntPrototype; // JSC::BigIntPrototype
typedef struct JSC__GeneratorFunctionPrototype JSC__GeneratorFunctionPrototype; // JSC::GeneratorFunctionPrototype
@@ -175,6 +176,9 @@ typedef void* JSClassRef;
class StringView;
class ExternalStringImpl;
}
+ namespace Zig {
+ class JSMicrotaskCallback;
+ }
namespace Inspector {
class ScriptArguments;
}
@@ -226,6 +230,7 @@ typedef void* JSClassRef;
using WTF__String = WTF::String;
using WTF__StringView = WTF::StringView;
using WTF__ExternalStringImpl = WTF::ExternalStringImpl;
+ using Zig__JSMicrotaskCallback = Zig::JSMicrotaskCallback;
using Inspector__ScriptArguments = Inspector::ScriptArguments;
#endif
@@ -588,6 +593,7 @@ ZIG_DECL void Zig__GlobalObject__fetch(ErrorableResolvedSource* arg0, JSC__JSGlo
ZIG_DECL ErrorableZigString Zig__GlobalObject__import(JSC__JSGlobalObject* arg0, ZigString* arg1, ZigString* arg2);
ZIG_DECL void Zig__GlobalObject__onCrash();
ZIG_DECL JSC__JSValue Zig__GlobalObject__promiseRejectionTracker(JSC__JSGlobalObject* arg0, JSC__JSPromise* arg1, uint32_t JSPromiseRejectionOperation2);
+ZIG_DECL void Zig__GlobalObject__queueMicrotaskToEventLoop(JSC__JSGlobalObject* arg0, Zig__JSMicrotaskCallback* arg1);
ZIG_DECL JSC__JSValue Zig__GlobalObject__reportUncaughtException(JSC__JSGlobalObject* arg0, JSC__Exception* arg1);
ZIG_DECL void Zig__GlobalObject__resolve(ErrorableZigString* arg0, JSC__JSGlobalObject* arg1, ZigString* arg2, ZigString* arg3);
diff --git a/src/javascript/jsc/bindings/headers.zig b/src/javascript/jsc/bindings/headers.zig
index e02044721..070d2ad05 100644
--- a/src/javascript/jsc/bindings/headers.zig
+++ b/src/javascript/jsc/bindings/headers.zig
@@ -48,6 +48,8 @@ pub const JSC__JSPromise = bJSC__JSPromise;
pub const JSC__SetIteratorPrototype = struct_JSC__SetIteratorPrototype;
pub const JSC__SourceCode = bJSC__SourceCode;
+
+pub const Zig__JSMicrotaskCallback = struct_Zig__JSMicrotaskCallback;
pub const JSC__JSCell = bJSC__JSCell;
pub const JSC__BigIntPrototype = struct_JSC__BigIntPrototype;
diff --git a/src/javascript/jsc/javascript.zig b/src/javascript/jsc/javascript.zig
index 03ef373f7..d864c2d17 100644
--- a/src/javascript/jsc/javascript.zig
+++ b/src/javascript/jsc/javascript.zig
@@ -727,6 +727,13 @@ pub const Module = struct {
reload_pending: bool = false,
};
+const FetchTasklet = Fetch.FetchTasklet;
+const TaggedPointerUnion = @import("../../tagged_pointer.zig").TaggedPointerUnion;
+pub const Task = TaggedPointerUnion(.{
+ FetchTasklet,
+ Microtask,
+});
+
// If you read JavascriptCore/API/JSVirtualMachine.mm - https://github.com/WebKit/WebKit/blob/acff93fb303baa670c055cb24c2bad08691a01a0/Source/JavaScriptCore/API/JSVirtualMachine.mm#L101
// We can see that it's sort of like std.mem.Allocator but for JSGlobalContextRef, to support Automatic Reference Counting
// Its unavailable on Linux
@@ -762,6 +769,52 @@ pub const VirtualMachine = struct {
origin_timer: std.time.Timer = undefined,
+ ready_tasks_count: std.atomic.Atomic(u32) = std.atomic.Atomic(u32).init(0),
+ pending_tasks_count: std.atomic.Atomic(u32) = std.atomic.Atomic(u32).init(0),
+ microtasks_queue: std.ArrayList(Task) = std.ArrayList(Task).init(default_allocator),
+
+ pub fn enqueueTask(this: *VirtualMachine, task: Task) !void {
+ _ = this.pending_tasks_count.fetchAdd(1, .Monotonic);
+ try this.microtasks_queue.append(task);
+ }
+
+ pub fn tick(this: *VirtualMachine) void {
+ this.global.vm().drainMicrotasks();
+ _ = this.eventLoopTick();
+ }
+
+ // 👶👶👶 event loop 👶👶👶
+ pub fn eventLoopTick(this: *VirtualMachine) u32 {
+ var finished: u32 = 0;
+ var i: usize = 0;
+ while (i < this.microtasks_queue.items.len) {
+ var task: Task = this.microtasks_queue.items[i];
+ switch (task.tag()) {
+ .Microtask => {
+ var micro: *Microtask = task.get(Microtask).?;
+ _ = this.microtasks_queue.swapRemove(i);
+ micro.run(this.global);
+
+ finished += 1;
+ continue;
+ },
+ .FetchTasklet => {
+ var fetch_task: *Fetch.FetchTasklet = task.get(Fetch.FetchTasklet).?;
+ if (fetch_task.status == .done) {
+ _ = this.ready_tasks_count.fetchSub(1, .Monotonic);
+ _ = this.microtasks_queue.swapRemove(i);
+ fetch_task.onDone();
+ finished += 1;
+ continue;
+ }
+ },
+ else => unreachable,
+ }
+ i += 1;
+ }
+ return finished;
+ }
+
pub const MacroMap = std.AutoArrayHashMap(i32, js.JSObjectRef);
pub threadlocal var vm_loaded = false;
@@ -1212,7 +1265,15 @@ pub const VirtualMachine = struct {
ret.path = result_path.text;
}
+ pub fn queueMicrotaskToEventLoop(
+ global: *JSGlobalObject,
+ microtask: *Microtask,
+ ) void {
+ std.debug.assert(VirtualMachine.vm_loaded);
+ std.debug.assert(VirtualMachine.vm.global == global);
+ vm.enqueueTask(Task.init(microtask)) catch unreachable;
+ }
pub fn resolve(res: *ErrorableZigString, global: *JSGlobalObject, specifier: ZigString, source: ZigString) void {
var result = ResolveFunctionResult{ .path = "", .result = null };
@@ -1411,10 +1472,10 @@ pub const VirtualMachine = struct {
if (this.node_modules != null) {
promise = JSModuleLoader.loadAndEvaluateModule(this.global, ZigString.init(std.mem.span(bun_file_import_path)));
- this.global.vm().drainMicrotasks();
+ this.tick();
while (promise.status(this.global.vm()) == JSPromise.Status.Pending) {
- this.global.vm().drainMicrotasks();
+ this.tick();
}
if (promise.status(this.global.vm()) == JSPromise.Status.Rejected) {
@@ -1426,10 +1487,10 @@ pub const VirtualMachine = struct {
promise = JSModuleLoader.loadAndEvaluateModule(this.global, ZigString.init(std.mem.span(main_file_name)));
- this.global.vm().drainMicrotasks();
+ this.tick();
while (promise.status(this.global.vm()) == JSPromise.Status.Pending) {
- this.global.vm().drainMicrotasks();
+ this.tick();
}
return promise;
@@ -1446,30 +1507,13 @@ pub const VirtualMachine = struct {
var entry_point = entry_point_entry.value_ptr.*;
var promise: *JSInternalPromise = undefined;
- // We first import the node_modules bundle. This prevents any potential TDZ issues.
- // The contents of the node_modules bundle are lazy, so hopefully this should be pretty quick.
- // if (this.node_modules != null) {
- // promise = JSModuleLoader.loadAndEvaluateModule(this.global, ZigString.init(std.mem.span(bun_file_import_path)));
-
- // this.global.vm().drainMicrotasks();
-
- // while (promise.status(this.global.vm()) == JSPromise.Status.Pending) {
- // this.global.vm().drainMicrotasks();
- // }
-
- // if (promise.status(this.global.vm()) == JSPromise.Status.Rejected) {
- // return promise;
- // }
-
- // _ = promise.result(this.global.vm());
- // }
promise = JSModuleLoader.loadAndEvaluateModule(this.global, ZigString.init(entry_point.source.path.text));
- this.global.vm().drainMicrotasks();
+ this.tick();
while (promise.status(this.global.vm()) == JSPromise.Status.Pending) {
- this.global.vm().drainMicrotasks();
+ this.tick();
}
return promise;
@@ -1907,7 +1951,7 @@ pub const EventListenerMixin = struct {
var result = js.JSObjectCallAsFunctionReturnValue(vm.global.ref(), listener_ref, null, 1, &fetch_args);
var promise = JSPromise.resolvedPromise(vm.global, result);
- vm.global.vm().drainMicrotasks();
+ vm.tick();
if (fetch_event.rejected) return;
@@ -1918,7 +1962,7 @@ pub const EventListenerMixin = struct {
_ = promise.result(vm.global.vm());
}
- vm.global.vm().drainMicrotasks();
+ vm.tick();
if (fetch_event.request_context.has_called_done) {
break;
diff --git a/src/javascript/jsc/webcore/response.zig b/src/javascript/jsc/webcore/response.zig
index 8a5a0c1c1..248c3a4a7 100644
--- a/src/javascript/jsc/webcore/response.zig
+++ b/src/javascript/jsc/webcore/response.zig
@@ -5,9 +5,13 @@ const http = @import("../../../http.zig");
usingnamespace @import("../javascript.zig");
usingnamespace @import("../bindings/bindings.zig");
const ZigURL = @import("../../../query_string_map.zig").URL;
-const HTTPClient = @import("../../../http_client.zig");
+const HTTPClient = @import("http");
+const NetworkThread = @import("network_thread");
+
const Method = @import("../../../http/method.zig").Method;
+const ObjectPool = @import("../../../pool.zig").ObjectPool;
+
const picohttp = @import("picohttp");
pub const Response = struct {
pub const Class = NewClass(
@@ -411,6 +415,207 @@ pub const Fetch = struct {
);
const fetch_error_cant_fetch_same_origin = "fetch to same-origin on the server is not supported yet - sorry! (it would just hang forever)";
+
+ pub const FetchTasklet = struct {
+ promise: *JSInternalPromise = undefined,
+ http: HTTPClient.AsyncHTTP = undefined,
+ status: Status = Status.pending,
+ javascript_vm: *VirtualMachine = undefined,
+ global_this: *JSGlobalObject = undefined,
+
+ empty_request_body: MutableString = undefined,
+ pooled_body: *BodyPool.Node = undefined,
+ this_object: js.JSObjectRef = null,
+ resolve: js.JSObjectRef = null,
+ reject: js.JSObjectRef = null,
+ context: FetchTaskletContext = undefined,
+
+ const Pool = ObjectPool(FetchTasklet, init);
+ const BodyPool = ObjectPool(MutableString, MutableString.init2048);
+ pub const FetchTaskletContext = struct {
+ tasklet: *FetchTasklet,
+ };
+
+ pub fn init(allocator: *std.mem.Allocator) anyerror!FetchTasklet {
+ return FetchTasklet{};
+ }
+
+ pub const Status = enum(u8) {
+ pending,
+ running,
+ done,
+ };
+
+ pub fn onDone(this: *FetchTasklet) void {
+ var args = [1]js.JSValueRef{undefined};
+
+ var callback_object = switch (this.http.state.load(.Monotonic)) {
+ .success => this.resolve,
+ .fail => this.reject,
+ else => unreachable,
+ };
+
+ args[0] = switch (this.http.state.load(.Monotonic)) {
+ .success => this.onResolve().asObjectRef(),
+ .fail => this.onReject().asObjectRef(),
+ else => unreachable,
+ };
+
+ _ = js.JSObjectCallAsFunction(this.global_this.ref(), callback_object, null, 1, &args, null);
+
+ this.release();
+ }
+
+ pub fn reset(this: *FetchTasklet) void {}
+
+ pub fn release(this: *FetchTasklet) void {
+ js.JSValueUnprotect(this.global_this.ref(), this.resolve);
+ js.JSValueUnprotect(this.global_this.ref(), this.reject);
+ js.JSValueUnprotect(this.global_this.ref(), this.this_object);
+
+ this.global_this = undefined;
+ this.javascript_vm = undefined;
+ this.promise = undefined;
+ this.status = Status.pending;
+ var pooled = this.pooled_body;
+ BodyPool.release(pooled);
+ this.pooled_body = undefined;
+ this.http = undefined;
+ this.this_object = null;
+ this.resolve = null;
+ this.reject = null;
+ Pool.release(@fieldParentPtr(Pool.Node, "data", this));
+ }
+
+ pub const FetchResolver = struct {
+ pub fn call(
+ ctx: js.JSContextRef,
+ function: js.JSObjectRef,
+ thisObject: js.JSObjectRef,
+ arguments_len: usize,
+ arguments: [*c]const js.JSValueRef,
+ exception: js.ExceptionRef,
+ ) callconv(.C) js.JSObjectRef {
+ return JSPrivateDataPtr.from(js.JSObjectGetPrivate(arguments[0]))
+ .get(FetchTaskletContext).?.tasklet.onResolve().asObjectRef();
+ // return js.JSObjectGetPrivate(arguments[0]).? .tasklet.onResolve().asObjectRef();
+ }
+ };
+
+ pub const FetchRejecter = struct {
+ pub fn call(
+ ctx: js.JSContextRef,
+ function: js.JSObjectRef,
+ thisObject: js.JSObjectRef,
+ arguments_len: usize,
+ arguments: [*c]const js.JSValueRef,
+ exception: js.ExceptionRef,
+ ) callconv(.C) js.JSObjectRef {
+ return JSPrivateDataPtr.from(js.JSObjectGetPrivate(arguments[0]))
+ .get(FetchTaskletContext).?.tasklet.onReject().asObjectRef();
+ }
+ };
+
+ pub fn onReject(this: *FetchTasklet) JSValue {
+ const fetch_error = std.fmt.allocPrint(
+ default_allocator,
+ "Fetch error: {s}\nURL: \"{s}\"",
+ .{
+ @errorName(this.http.err orelse error.HTTPFail),
+ this.http.url.href,
+ },
+ ) catch unreachable;
+ return ZigString.init(fetch_error).toErrorInstance(this.global_this);
+ }
+
+ pub fn onResolve(this: *FetchTasklet) JSValue {
+ var allocator = default_allocator;
+ var http_response = this.http.response.?;
+ var response_headers = Headers.fromPicoHeaders(allocator, http_response.headers) catch unreachable;
+ response_headers.guard = .immutable;
+ var response = allocator.create(Response) catch unreachable;
+ var duped = allocator.dupe(u8, this.http.response_buffer.toOwnedSlice()) catch unreachable;
+
+ response.* = Response{
+ .allocator = allocator,
+ .status_text = allocator.dupe(u8, http_response.status) catch unreachable,
+ .body = .{
+ .init = .{
+ .headers = response_headers,
+ .status_code = @truncate(u16, http_response.status_code),
+ },
+ .value = .{
+ .Unconsumed = 0,
+ },
+ .ptr = duped.ptr,
+ .len = duped.len,
+ .ptr_allocator = allocator,
+ },
+ };
+ return JSValue.fromRef(Response.Class.make(@ptrCast(js.JSContextRef, this.global_this), response));
+ }
+
+ pub fn get(
+ allocator: *std.mem.Allocator,
+ method: Method,
+ url: ZigURL,
+ headers: Headers.Entries,
+ headers_buf: string,
+ request_body: ?*MutableString,
+ timeout: usize,
+ ) !*FetchTasklet.Pool.Node {
+ var linked_list = FetchTasklet.Pool.get(allocator);
+ linked_list.data.javascript_vm = VirtualMachine.vm;
+ linked_list.data.empty_request_body = MutableString.init(allocator, 0) catch unreachable;
+ linked_list.data.pooled_body = BodyPool.get(allocator);
+ linked_list.data.http = try HTTPClient.AsyncHTTP.init(
+ allocator,
+ method,
+ url,
+ headers,
+ headers_buf,
+ &linked_list.data.pooled_body.data,
+ request_body orelse &linked_list.data.empty_request_body,
+
+ timeout,
+ );
+ linked_list.data.context = .{ .tasklet = &linked_list.data };
+
+ return linked_list;
+ }
+
+ pub fn queue(
+ allocator: *std.mem.Allocator,
+ global: *JSGlobalObject,
+ method: Method,
+ url: ZigURL,
+ headers: Headers.Entries,
+ headers_buf: string,
+ request_body: ?*MutableString,
+ timeout: usize,
+ ) !*FetchTasklet.Pool.Node {
+ var node = try get(allocator, method, url, headers, headers_buf, request_body, timeout);
+ node.data.promise = JSInternalPromise.create(global);
+
+ node.data.global_this = global;
+ node.data.http.callback = callback;
+ var batch = NetworkThread.Batch{};
+ node.data.http.schedule(allocator, &batch);
+ NetworkThread.global.pool.schedule(batch);
+
+ try VirtualMachine.vm.enqueueTask(Task.init(&node.data));
+ return node;
+ }
+
+ pub fn callback(http_: *HTTPClient.AsyncHTTP, sender: *HTTPClient.AsyncHTTP.HTTPSender) void {
+ var task: *FetchTasklet = @fieldParentPtr(FetchTasklet, "http", http_);
+ @atomicStore(Status, &task.status, Status.done, .Monotonic);
+ _ = task.javascript_vm.ready_tasks_count.fetchAdd(1, .Monotonic);
+ _ = task.javascript_vm.pending_tasks_count.fetchSub(1, .Monotonic);
+ sender.release();
+ }
+ };
+
pub fn call(
this: void,
ctx: js.JSContextRef,
@@ -444,17 +649,17 @@ pub const Fetch = struct {
url_str = getAllocator(ctx).dupe(u8, url_str) catch unreachable;
}
- defer getAllocator(ctx).free(url_str);
+ NetworkThread.init() catch @panic("Failed to start network thread");
+ const url = ZigURL.parse(url_str);
- var http_client = HTTPClient.init(getAllocator(ctx), .GET, ZigURL.parse(url_str), .{}, "");
-
- if (http_client.url.origin.len > 0 and strings.eql(http_client.url.origin, VirtualMachine.vm.bundler.options.origin.origin)) {
+ if (url.origin.len > 0 and strings.eql(url.origin, VirtualMachine.vm.bundler.options.origin.origin)) {
const fetch_error = fetch_error_cant_fetch_same_origin;
return JSPromise.rejectedPromiseValue(VirtualMachine.vm.global, ZigString.init(fetch_error).toErrorInstance(VirtualMachine.vm.global)).asRef();
}
var headers: ?Headers = null;
var body: string = "";
+ var method = Method.GET;
if (arguments.len >= 2 and js.JSValueIsObject(ctx, arguments[1])) {
var array = js.JSObjectCopyPropertyNames(ctx, arguments[1]);
@@ -501,7 +706,7 @@ pub const Fetch = struct {
defer js.JSStringRelease(string_ref);
var method_name_buf: [16]u8 = undefined;
var method_name = method_name_buf[0..js.JSStringGetUTF8CString(string_ref, &method_name_buf, method_name_buf.len)];
- http_client.method = Method.which(method_name) orelse http_client.method;
+ method = Method.which(method_name) orelse method;
}
}
},
@@ -510,56 +715,39 @@ pub const Fetch = struct {
}
}
+ var header_entries: Headers.Entries = .{};
+ var header_buf: string = "";
+
if (headers) |head| {
- http_client.header_entries = head.entries;
- http_client.header_buf = head.buf.items;
+ header_entries = head.entries;
+ header_buf = head.buf.items;
}
+ var resolve = js.JSObjectMakeFunctionWithCallback(ctx, null, Fetch.FetchTasklet.FetchResolver.call);
+ var reject = js.JSObjectMakeFunctionWithCallback(ctx, null, Fetch.FetchTasklet.FetchRejecter.call);
- if (fetch_body_string_loaded) {
- fetch_body_string.reset();
- } else {
- fetch_body_string = MutableString.init(VirtualMachine.vm.allocator, 0) catch unreachable;
- fetch_body_string_loaded = true;
- }
+ js.JSValueProtect(ctx, resolve);
+ js.JSValueProtect(ctx, reject);
- var http_response = http_client.send(body, &fetch_body_string) catch |err| {
- const fetch_error = std.fmt.allocPrint(
- getAllocator(ctx),
- "Fetch error: {s}\nURL: \"{s}\"",
- .{
- @errorName(err),
- url_str,
- },
- ) catch unreachable;
- return JSPromise.rejectedPromiseValue(VirtualMachine.vm.global, ZigString.init(fetch_error).toErrorInstance(VirtualMachine.vm.global)).asRef();
- };
+ // var resolve = FetchTasklet.FetchResolver.Class.make(ctx: js.JSContextRef, ptr: *ZigType)
+ var queued = FetchTasklet.queue(
+ default_allocator,
+ VirtualMachine.vm.global,
+ method,
+ url,
+ header_entries,
+ header_buf,
+ null,
+ std.time.ns_per_hour,
+ ) catch unreachable;
+ queued.data.this_object = js.JSObjectMake(ctx, null, JSPrivateDataPtr.init(&queued.data.context).ptr());
+ js.JSValueProtect(ctx, queued.data.this_object);
- var response_headers = Headers.fromPicoHeaders(getAllocator(ctx), http_response.headers) catch unreachable;
- response_headers.guard = .immutable;
- var response = getAllocator(ctx).create(Response) catch unreachable;
- var allocator = getAllocator(ctx);
- var duped = allocator.dupeZ(u8, fetch_body_string.list.items) catch unreachable;
- response.* = Response{
- .allocator = allocator,
- .status_text = allocator.dupe(u8, http_response.status) catch unreachable,
- .body = .{
- .init = .{
- .headers = response_headers,
- .status_code = @truncate(u16, http_response.status_code),
- },
- .value = .{
- .Unconsumed = 0,
- },
- .ptr = duped.ptr,
- .len = duped.len,
- .ptr_allocator = allocator,
- },
- };
+ var promise = js.JSObjectMakeDeferredPromise(ctx, &resolve, &reject, exception);
+ queued.data.reject = reject;
+ queued.data.resolve = resolve;
- return JSPromise.resolvedPromiseValue(
- VirtualMachine.vm.global,
- JSValue.fromRef(Response.Class.make(ctx, response)),
- ).asRef();
+ return promise;
+ // queued.data.promise.create(globalThis: *JSGlobalObject)
}
};
@@ -1488,6 +1676,7 @@ pub const FetchEvent = struct {
response: ?*Response = null,
request_context: *http.RequestContext,
request: Request,
+ pending_promise: ?*JSInternalPromise = null,
onPromiseRejectionCtx: *c_void = undefined,
onPromiseRejectionHandler: ?fn (ctx: *c_void, err: anyerror, fetch_event: *FetchEvent, value: JSValue) void = null,
@@ -1566,47 +1755,56 @@ pub const FetchEvent = struct {
if (this.request_context.has_called_done) return js.JSValueMakeUndefined(ctx);
// A Response or a Promise that resolves to a Response. Otherwise, a network error is returned to Fetch.
- if (arguments.len == 0 or !Response.Class.loaded) {
+ if (arguments.len == 0 or !Response.Class.loaded or !js.JSValueIsObject(ctx, arguments[0])) {
JSError(getAllocator(ctx), "event.respondWith() must be a Response or a Promise<Response>.", .{}, ctx, exception);
this.request_context.sendInternalError(error.respondWithWasEmpty) catch {};
return js.JSValueMakeUndefined(ctx);
}
- var resolved = JSInternalPromise.resolvedPromise(VirtualMachine.vm.global, JSValue.fromRef(arguments[0]));
-
- var status = resolved.status(VirtualMachine.vm.global.vm());
+ var arg = arguments[0];
- if (status == .Pending) {
- VirtualMachine.vm.global.vm().drainMicrotasks();
+ if (!js.JSValueIsObjectOfClass(ctx, arg, Response.Class.ref)) {
+ this.pending_promise = this.pending_promise orelse JSInternalPromise.resolvedPromise(VirtualMachine.vm.global, JSValue.fromRef(arguments[0]));
}
- status = resolved.status(VirtualMachine.vm.global.vm());
+ if (this.pending_promise) |promise| {
+ var status = promise.status(VirtualMachine.vm.global.vm());
- switch (status) {
- .Fulfilled => {},
- else => {
- this.rejected = true;
- this.onPromiseRejectionHandler.?(
- this.onPromiseRejectionCtx,
- error.PromiseRejection,
- this,
- resolved.result(VirtualMachine.vm.global.vm()),
- );
- return js.JSValueMakeUndefined(ctx);
- },
- }
+ if (status == .Pending) {
+ VirtualMachine.vm.tick();
+ status = promise.status(VirtualMachine.vm.global.vm());
+ }
- var arg = resolved.result(VirtualMachine.vm.global.vm()).asObjectRef();
+ switch (status) {
+ .Fulfilled => {},
+ else => {
+ this.rejected = true;
+ this.pending_promise = null;
+ this.onPromiseRejectionHandler.?(
+ this.onPromiseRejectionCtx,
+ error.PromiseRejection,
+ this,
+ promise.result(VirtualMachine.vm.global.vm()),
+ );
+ return js.JSValueMakeUndefined(ctx);
+ },
+ }
+
+ arg = promise.result(VirtualMachine.vm.global.vm()).asRef();
+ }
if (!js.JSValueIsObjectOfClass(ctx, arg, Response.Class.ref)) {
this.rejected = true;
+ this.pending_promise = null;
JSError(getAllocator(ctx), "event.respondWith() must be a Response or a Promise<Response>.", .{}, ctx, exception);
this.onPromiseRejectionHandler.?(this.onPromiseRejectionCtx, error.RespondWithInvalidType, this, JSValue.fromRef(exception.*));
+
return js.JSValueMakeUndefined(ctx);
}
var response: *Response = GetJSPrivateData(Response, arg) orelse {
this.rejected = true;
+ this.pending_promise = null;
JSError(getAllocator(ctx), "event.respondWith()'s Response object was invalid. This may be an internal error.", .{}, ctx, exception);
this.onPromiseRejectionHandler.?(this.onPromiseRejectionCtx, error.RespondWithInvalidTypeInternal, this, JSValue.fromRef(exception.*));
return js.JSValueMakeUndefined(ctx);
@@ -1627,6 +1825,7 @@ pub const FetchEvent = struct {
}
}
+ defer this.pending_promise = null;
var needs_mime_type = true;
var content_length: ?usize = null;
if (response.body.init.headers) |*headers| {
diff --git a/src/js_ast.zig b/src/js_ast.zig
index 132ff1e05..cebad7115 100644
--- a/src/js_ast.zig
+++ b/src/js_ast.zig
@@ -1058,6 +1058,16 @@ pub const E = struct {
pub const Number = struct {
value: f64,
+ pub inline fn toU64(self: Number) u64 {
+ @setRuntimeSafety(false);
+ return @floatToInt(u64, @maximum(@trunc(self.value), 0));
+ }
+
+ pub inline fn toU32(self: Number) u32 {
+ @setRuntimeSafety(false);
+ return @floatToInt(u32, @maximum(@trunc(self.value), 0));
+ }
+
pub fn jsonStringify(self: *const Number, opts: anytype, o: anytype) !void {
return try std.json.stringify(self.value, opts, o);
}
@@ -1078,6 +1088,65 @@ pub const E = struct {
comma_after_spread: ?logger.Loc = null,
is_single_line: bool = false,
is_parenthesized: bool = false,
+
+ pub fn alphabetizeProperties(this: *Object) void {
+ std.sort.sort(G.Property, this.properties, void{}, Sorter.isLessThan);
+ }
+
+ pub fn packageJSONSort(this: *Object) void {
+ std.sort.sort(G.Property, this.properties, void{}, PackageJSONSort.Fields.isLessThan);
+ }
+
+ const PackageJSONSort = struct {
+ const Fields = struct {
+ const name: u8 = 0;
+ const version: u8 = 1;
+ const main: u8 = 2;
+ const module: u8 = 3;
+ const dependencies: u8 = 3;
+ const devDependencies: u8 = 4;
+ const optionalDependencies: u8 = 5;
+ const peerDependencies: u8 = 6;
+ const exports: u8 = 7;
+
+ pub const Map = std.ComptimeStringMap(u8, .{
+ .{ "name", name },
+ .{ "version", version },
+ .{ "main", main },
+ .{ "module", module },
+ .{ "dependencies", dependencies },
+ .{ "devDependencies", devDependencies },
+ .{ "optionalDependencies", optionalDependencies },
+ .{ "peerDependencies", peerDependencies },
+ .{ "exports", exports },
+ });
+
+ pub fn isLessThan(ctx: void, lhs: G.Property, rhs: G.Property) bool {
+ var lhs_key_size: u8 = 8;
+ var rhs_key_size: u8 = 8;
+
+ if (lhs.key != null and lhs.key.?.data == .e_string) {
+ lhs_key_size = Map.get(lhs.key.?.data.e_string.utf8) orelse 8;
+ }
+
+ if (rhs.key != null and rhs.key.?.data == .e_string) {
+ rhs_key_size = Map.get(rhs.key.?.data.e_string.utf8) orelse 8;
+ }
+
+ return switch (std.math.order(lhs_key_size, rhs_key_size)) {
+ .lt => true,
+ .gt => false,
+ .eq => strings.cmpStringsAsc(ctx, lhs.key.?.data.e_string.utf8, rhs.key.?.data.e_string.utf8),
+ };
+ }
+ };
+ };
+
+ const Sorter = struct {
+ pub fn isLessThan(ctx: void, lhs: G.Property, rhs: G.Property) bool {
+ return strings.cmpStringsAsc(ctx, lhs.key.?.data.e_string.utf8, rhs.key.?.data.e_string.utf8);
+ }
+ };
};
pub const Spread = struct { value: ExprNodeIndex };
@@ -1110,16 +1179,20 @@ pub const E = struct {
}
}
+ pub inline fn len(s: *const String) usize {
+ return @maximum(s.utf8.len, s.value.len);
+ }
+
pub inline fn isUTF8(s: *const String) bool {
- return @maximum(s.utf8.len, s.value.len) == s.utf8.len;
+ return s.len() == s.utf8.len;
}
pub inline fn isBlank(s: *const String) bool {
- return @maximum(s.utf8.len, s.value.len) == 0;
+ return s.len() == 0;
}
pub inline fn isPresent(s: *const String) bool {
- return @maximum(s.utf8.len, s.value.len) > 0;
+ return s.len() > 0;
}
pub fn eql(s: *const String, comptime _t: type, other: anytype) bool {
@@ -1947,7 +2020,7 @@ pub const Expr = struct {
pub fn isEmpty(expr: *Expr) bool {
return std.meta.activeTag(expr.data) == .e_missing;
}
- pub const Query = struct { expr: Expr, loc: logger.Loc };
+ pub const Query = struct { expr: Expr, loc: logger.Loc, i: u32 = 0 };
pub fn getArray(exp: *const Expr) *E.Array {
return exp.data.e_array;
@@ -2072,13 +2145,17 @@ pub const Expr = struct {
const obj = expr.data.e_object;
if (@ptrToInt(obj.properties.ptr) == 0) return null;
- for (obj.properties) |prop| {
+ for (obj.properties) |prop, i| {
const value = prop.value orelse continue;
const key = prop.key orelse continue;
if (std.meta.activeTag(key.data) != .e_string) continue;
const key_str = key.data.e_string;
if (key_str.eql(string, name)) {
- return Query{ .expr = value, .loc = key.loc };
+ return Query{
+ .expr = value,
+ .loc = key.loc,
+ .i = @truncate(u32, i),
+ };
}
}
@@ -2106,7 +2183,7 @@ pub const Expr = struct {
return ArrayIterator{ .array = array, .index = 0 };
}
- pub fn asString(expr: *const Expr, allocator: *std.mem.Allocator) ?string {
+ pub inline fn asString(expr: *const Expr, allocator: *std.mem.Allocator) ?string {
if (std.meta.activeTag(expr.data) != .e_string) return null;
const key_str = expr.data.e_string;
@@ -7024,7 +7101,7 @@ pub const Macro = struct {
js.JSValueProtect(macro.vm.global.ref(), result.asRef());
defer js.JSValueUnprotect(macro.vm.global.ref(), result.asRef());
var promise = JSC.JSPromise.resolvedPromise(macro.vm.global, result);
- macro.vm.global.vm().drainMicrotasks();
+ _ = macro.vm.tick();
if (promise.status(macro.vm.global.vm()) == .Rejected) {
macro.vm.defaultErrorHandler(promise.result(macro.vm.global.vm()), null);
diff --git a/src/js_lexer_tables.zig b/src/js_lexer_tables.zig
index b594fbc2e..ac71ed7e7 100644
--- a/src/js_lexer_tables.zig
+++ b/src/js_lexer_tables.zig
@@ -1,12 +1,10 @@
usingnamespace @import("string_types.zig");
-const default_allocator = @import("./global.zig").default_allocator;
const std = @import("std");
const expectString = std.testing.expectEqualStrings;
const expect = std.testing.expect;
const logger = @import("logger.zig");
const unicode = std.unicode;
-const alloc = @import("alloc.zig");
-
+const default_allocator = @import("./global.zig").default_allocator;
pub const T = enum(u8) {
t_end_of_file,
t_syntax_error,
diff --git a/src/json_parser.zig b/src/json_parser.zig
index 79cec2ef9..e68796c29 100644
--- a/src/json_parser.zig
+++ b/src/json_parser.zig
@@ -211,7 +211,7 @@ fn JSONLikeParser(opts: js_lexer.JSONOptions) type {
}
}
- var str = p.lexer.toEString();
+ const str = p.lexer.toEString();
const key_range = p.lexer.range();
if (comptime opts.json_warn_duplicate_keys) {
@@ -225,11 +225,11 @@ fn JSONLikeParser(opts: js_lexer.JSONOptions) type {
}
}
- var key = p.e(str, key_range.loc);
+ const key = p.e(str, key_range.loc);
try p.lexer.expect(.t_string_literal);
try p.lexer.expect(.t_colon);
- var value = try p.parseExpr(false);
+ const value = try p.parseExpr(false);
properties.append(G.Property{ .key = key, .value = value }) catch unreachable;
}
@@ -251,6 +251,11 @@ fn JSONLikeParser(opts: js_lexer.JSONOptions) type {
try p.lexer.unexpected();
if (comptime isDebug) {
+ std.io.getStdErr().writeAll("\nThis range: \n") catch {};
+ std.io.getStdErr().writeAll(
+ p.lexer.source.contents[p.lexer.range().loc.toUsize()..p.lexer.range().end().toUsize()],
+ ) catch {};
+
@breakpoint();
}
return error.ParserError;
@@ -274,6 +279,193 @@ fn JSONLikeParser(opts: js_lexer.JSONOptions) type {
};
}
+// This is a special JSON parser that stops as soon as it finds
+// {
+// "name": "NAME_IN_HERE",
+// "version": "VERSION_IN_HERE",
+// }
+// and then returns the name and version.
+// More precisely, it stops as soon as it finds a top-level "name" and "version" property which are strings
+// In most cases, it should perform zero heap allocations because it does not create arrays or objects (It just skips them)
+pub const PackageJSONVersionChecker = struct {
+ const Lexer = js_lexer.NewLexer(opts);
+
+ lexer: Lexer,
+ source: *const logger.Source,
+ log: *logger.Log,
+ allocator: *std.mem.Allocator,
+ depth: usize = 0,
+
+ found_version_buf: [1024]u8 = undefined,
+ found_name_buf: [1024]u8 = undefined,
+
+ found_name: []const u8 = "",
+ found_version: []const u8 = "",
+
+ has_found_name: bool = false,
+ has_found_version: bool = false,
+
+ const opts = if (LEXER_DEBUGGER_WORKAROUND) js_lexer.JSONOptions{} else js_lexer.JSONOptions{
+ .is_json = true,
+ .json_warn_duplicate_keys = false,
+ .allow_trailing_commas = true,
+ };
+
+ pub fn init(allocator: *std.mem.Allocator, source: *const logger.Source, log: *logger.Log) !Parser {
+ return Parser{
+ .lexer = try Lexer.init(log, source, allocator),
+ .allocator = allocator,
+ .log = log,
+ .source = source,
+ };
+ }
+
+ const Parser = @This();
+
+ pub fn e(p: *Parser, t: anytype, loc: logger.Loc) Expr {
+ const Type = @TypeOf(t);
+ if (@typeInfo(Type) == .Pointer) {
+ return Expr.init(std.meta.Child(Type), t.*, loc);
+ } else {
+ return Expr.init(Type, t, loc);
+ }
+ }
+ pub fn parseExpr(p: *Parser) anyerror!Expr {
+ const loc = p.lexer.loc();
+
+ if (p.has_found_name and p.has_found_version) return p.e(E.Missing{}, loc);
+
+ switch (p.lexer.token) {
+ .t_false => {
+ try p.lexer.next();
+ return p.e(E.Boolean{
+ .value = false,
+ }, loc);
+ },
+ .t_true => {
+ try p.lexer.next();
+ return p.e(E.Boolean{
+ .value = true,
+ }, loc);
+ },
+ .t_null => {
+ try p.lexer.next();
+ return p.e(E.Null{}, loc);
+ },
+ .t_string_literal => {
+ var str: E.String = p.lexer.toEString();
+
+ try p.lexer.next();
+ return p.e(str, loc);
+ },
+ .t_numeric_literal => {
+ const value = p.lexer.number;
+ try p.lexer.next();
+ return p.e(E.Number{ .value = value }, loc);
+ },
+ .t_minus => {
+ try p.lexer.next();
+ const value = p.lexer.number;
+ try p.lexer.expect(.t_numeric_literal);
+ return p.e(E.Number{ .value = -value }, loc);
+ },
+ .t_open_bracket => {
+ try p.lexer.next();
+ var has_exprs = false;
+
+ while (p.lexer.token != .t_close_bracket) {
+ if (has_exprs) {
+ if (!try p.parseMaybeTrailingComma(.t_close_bracket)) {
+ break;
+ }
+ }
+
+ _ = try p.parseExpr();
+ has_exprs = true;
+ }
+
+ try p.lexer.expect(.t_close_bracket);
+ return p.e(E.Missing{}, loc);
+ },
+ .t_open_brace => {
+ try p.lexer.next();
+ p.depth += 1;
+ defer p.depth -= 1;
+
+ var has_properties = false;
+ while (p.lexer.token != .t_close_brace) {
+ if (has_properties) {
+ if (!try p.parseMaybeTrailingComma(.t_close_brace)) {
+ break;
+ }
+ }
+
+ const str = p.lexer.toEString();
+ const key_range = p.lexer.range();
+
+ const key = p.e(str, key_range.loc);
+ try p.lexer.expect(.t_string_literal);
+
+ try p.lexer.expect(.t_colon);
+ const value = try p.parseExpr();
+
+ if (p.depth == 1) {
+ // if you have multiple "name" fields in the package.json....
+ // first one wins
+ if (key.data == .e_string and value.data == .e_string) {
+ if (!p.has_found_name and strings.eqlComptime(key.data.e_string.utf8, "name")) {
+ const len = @minimum(
+ value.data.e_string.utf8.len,
+ p.found_name_buf.len,
+ );
+
+ std.mem.copy(u8, &p.found_name_buf, value.data.e_string.utf8[0..len]);
+ p.found_name = p.found_name_buf[0..len];
+ p.has_found_name = true;
+ } else if (!p.has_found_version and strings.eqlComptime(key.data.e_string.utf8, "version")) {
+ const len = @minimum(
+ value.data.e_string.utf8.len,
+ p.found_version_buf.len,
+ );
+ std.mem.copy(u8, &p.found_version_buf, value.data.e_string.utf8[0..len]);
+ p.found_version = p.found_version_buf[0..len];
+ p.has_found_version = true;
+ }
+ }
+ }
+
+ if (p.has_found_name and p.has_found_version) return p.e(E.Missing{}, loc);
+ has_properties = true;
+ }
+
+ try p.lexer.expect(.t_close_brace);
+ return p.e(E.Missing{}, loc);
+ },
+ else => {
+ try p.lexer.unexpected();
+ if (comptime isDebug) {
+ @breakpoint();
+ }
+ return error.ParserError;
+ },
+ }
+ }
+
+ pub fn parseMaybeTrailingComma(p: *Parser, closer: T) !bool {
+ const comma_range = p.lexer.range();
+ try p.lexer.expect(.t_comma);
+
+ if (p.lexer.token == closer) {
+ if (comptime !opts.allow_trailing_commas) {
+ p.log.addRangeError(p.source, comma_range, "JSON does not support trailing commas") catch unreachable;
+ }
+ return false;
+ }
+
+ return true;
+ }
+};
+
const JSONParser = JSONLikeParser(js_lexer.JSONOptions{ .is_json = true });
const RemoteJSONParser = JSONLikeParser(js_lexer.JSONOptions{ .is_json = true, .json_warn_duplicate_keys = false });
const DotEnvJSONParser = JSONLikeParser(js_lexer.JSONOptions{
diff --git a/src/libarchive/libarchive.zig b/src/libarchive/libarchive.zig
index ef8a2acfa..94342c1e9 100644
--- a/src/libarchive/libarchive.zig
+++ b/src/libarchive/libarchive.zig
@@ -266,7 +266,10 @@ pub const BufferReadStream = struct {
pub fn deinit(this: *BufferReadStream) void {
_ = lib.archive_read_close(this.archive);
- _ = lib.archive_read_free(this.archive);
+ // don't free it if we never actually read it
+ // if (this.reading) {
+ // _ = lib.archive_read_free(this.archive);
+ // }
}
pub fn openRead(this: *BufferReadStream) c_int {
@@ -278,15 +281,15 @@ pub const BufferReadStream = struct {
// // lib.archive_read_set_switch_callback(this.archive, this.archive_s);
// _ = lib.archive_read_set_callback_data(this.archive, this);
- this.reading = true;
-
_ = lib.archive_read_support_format_tar(this.archive);
_ = lib.archive_read_support_format_gnutar(this.archive);
- _ = lib.archive_read_support_filter_gzip(this.archive);
- _ = lib.archive_read_support_filter_none(this.archive);
+ _ = lib.archive_read_support_compression_gzip(this.archive);
+ // _ = lib.archive_read_support_filter_none(this.archive);
const rc = lib.archive_read_open_memory(this.archive, this.buf.ptr, this.buf.len);
+ this.reading = rc > -1;
+
// _ = lib.archive_read_support_compression_all(this.archive);
return rc;
@@ -540,7 +543,7 @@ pub const Archive = struct {
var archive = stream.archive;
var count: u32 = 0;
- const dir: std.fs.Dir = brk: {
+ var dir: std.fs.Dir = brk: {
const cwd = std.fs.cwd();
cwd.makePath(
root,
@@ -574,7 +577,7 @@ pub const Archive = struct {
pathname = @intToPtr([*]const u8, @ptrToInt(pathname_.ptr))[0..pathname_.len :0];
const mask = lib.archive_entry_filetype(entry);
- const size = @intCast(usize, std.math.max(lib.archive_entry_size(entry), 0));
+ const size = @intCast(usize, @maximum(lib.archive_entry_size(entry), 0));
if (size > 0) {
const slice = std.mem.span(pathname);
diff --git a/src/lock.zig b/src/lock.zig
index 16f28bc1e..23552f6ed 100644
--- a/src/lock.zig
+++ b/src/lock.zig
@@ -46,9 +46,7 @@ pub const Mutex = struct {
// Give up spinning if the Mutex is contended.
// This helps acquire() latency under micro-contention.
//
- // Only spin on x86 as other platforms are assumed to
- // prioritize power efficiency over strict performance.
- var spin: u8 = comptime if (is_x86) 100 else 0;
+ var spin: u8 = 100;
while (spin > 0) : (spin -= 1) {
std.atomic.spinLoopHint();
diff --git a/src/main.zig b/src/main.zig
index 1635f5ad1..d70602827 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -17,6 +17,8 @@ pub const MainPanicHandler = panicky.NewPanicHandler(std.builtin.default_panic);
const js = @import("javascript/jsc/bindings/bindings.zig");
usingnamespace @import("javascript/jsc/javascript.zig");
+pub const io_mode = .blocking;
+
pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) noreturn {
MainPanicHandler.handle_panic(msg, error_return_trace);
}
diff --git a/src/memory_allocator.zig b/src/memory_allocator.zig
index bc15c55bf..9f6642bd5 100644
--- a/src/memory_allocator.zig
+++ b/src/memory_allocator.zig
@@ -24,10 +24,9 @@ const CAllocator = struct {
if (supports_posix_memalign) {
// The posix_memalign only accepts alignment values that are a
// multiple of the pointer size
- const eff_alignment = std.math.max(alignment, @sizeOf(usize));
var aligned_ptr: ?*c_void = undefined;
- if (mimalloc.mi_posix_memalign(&aligned_ptr, eff_alignment, len) != 0)
+ if (mimalloc.mi_posix_memalign(&aligned_ptr, @maximum(alignment, @sizeOf(usize)), len) != 0)
return null;
return @ptrCast([*]u8, aligned_ptr);
diff --git a/src/pool.zig b/src/pool.zig
new file mode 100644
index 000000000..f37b62162
--- /dev/null
+++ b/src/pool.zig
@@ -0,0 +1,39 @@
+const std = @import("std");
+
+pub fn ObjectPool(comptime Type: type, comptime Init: (fn (allocator: *std.mem.Allocator) anyerror!Type)) type {
+ return struct {
+ const LinkedList = std.SinglyLinkedList(Type);
+ // mimalloc crashes on realloc across threads
+ threadlocal var list: LinkedList = undefined;
+ threadlocal var loaded: bool = false;
+
+ pub const Node = LinkedList.Node;
+ pub fn get(allocator: *std.mem.Allocator) *Node {
+ if (loaded) {
+ if (list.popFirst()) |node| {
+ node.data.reset();
+ return node;
+ }
+ }
+
+ var new_node = allocator.create(Node) catch unreachable;
+ new_node.* = Node{
+ .data = Init(
+ allocator,
+ ) catch unreachable,
+ };
+
+ return new_node;
+ }
+
+ pub fn release(node: *Node) void {
+ if (loaded) {
+ list.prepend(node);
+ return;
+ }
+
+ list = LinkedList{ .first = node };
+ loaded = true;
+ }
+ };
+}
diff --git a/src/resolver/package_json.zig b/src/resolver/package_json.zig
index 825254fa1..ad7f5490b 100644
--- a/src/resolver/package_json.zig
+++ b/src/resolver/package_json.zig
@@ -445,6 +445,7 @@ pub const PackageJSON = struct {
dirname_fd: StoredFileDescriptorType,
comptime generate_hash: bool,
comptime include_scripts: bool,
+
) ?PackageJSON {
// TODO: remove this extra copy
diff --git a/src/runtime.version b/src/runtime.version
index b5f16523a..936ae3d67 100644
--- a/src/runtime.version
+++ b/src/runtime.version
@@ -1 +1 @@
-3f5763ef0f32f299 \ No newline at end of file
+b79c80cf594c185e \ No newline at end of file
diff --git a/src/s2n.zig b/src/s2n.zig
deleted file mode 100644
index 6f7be069d..000000000
--- a/src/s2n.zig
+++ /dev/null
@@ -1,793 +0,0 @@
-pub usingnamespace @import("std").zig.c_builtins;
-const std = @import("std");
-
-const Output = @import("./global.zig").Output;
-
-const alpn_protocols = "http/1.1";
-
-pub inline fn s2nassert(value: c_int) void {
- std.debug.assert(value == 0);
-}
-
-pub fn boot(allcoator: *std.mem.Allocator) void {
- if (booted) return;
- booted = true;
- Allocator.allocator = allcoator;
- CacheStore.instance = CacheStore{ .allocator = allcoator, .map = @TypeOf(CacheStore.instance.map).init(allcoator) };
-
- // Important for any website using Cloudflare.
- // Do to our modifications in the library, this must be called _first_
- // Before we initialize s2n.
- // It can never be changed after initialization or we risk undefined memory bugs.
- if (s2n_get_highest_fully_supported_tls_version() == S2N_TLS13) {
- // This conditional should always return true since we statically compile libCrypto.
- // _ = s2n_enable_tls13();
-
- // Sadly, this TLS 1.3 implementation is slower than TLS 1.2.
- // ❯ hyperfine "./fetch https://example.com" "./fetchtls13 https://example.com"
- // Benchmark #1: ./fetch https://example.com
- // Time (mean ± σ): 83.6 ms ± 5.4 ms [User: 15.1 ms, System: 4.7 ms]
- // Range (min … max): 73.5 ms … 97.5 ms 35 runs
-
- // Benchmark #2: ./fetchtls13 https://example.com
- // Time (mean ± σ): 94.9 ms ± 3.2 ms [User: 15.8 ms, System: 4.8 ms]
- // Range (min … max): 90.7 ms … 104.6 ms 29 runs
-
- // Summary
- // './fetch https://example.com' ran
- // 1.14 ± 0.08 times faster than './fetchtls13 https://example.com'
-
- }
-
- // We don't actually need the memory allocator, it will automatically use mimalloc...I don't know how!
- // Also, the implementation
- // s2nassert(s2n_mem_set_callbacks(Allocator.initCallback, Allocator.deinitCallback, Allocator.mallocCallback, Allocator.freeCallback));
-
- s2nassert(s2n_disable_atexit());
- s2nassert(s2n_init());
- global_s2n_config = s2n_fetch_default_config();
- // s2nassert(s2n_config_set_verify_host_callback(global_s2n_config, verify_host_callback, null));
- // s2nassert(s2n_config_set_check_stapled_ocsp_response(global_s2n_config, 0));
- // s2nassert(s2n_config_set_cipher_preferences(global_s2n_config, "default"));
- // s2nassert(s2n_config_disable_x509_verification(global_s2n_config));
- var protocol: [*c]const u8 = "http/1.1";
- var protocols = &protocol;
- s2nassert(s2n_config_set_protocol_preferences(global_s2n_config, protocols, 1));
- s2nassert(s2n_config_send_max_fragment_length(global_s2n_config, S2N_TLS_MAX_FRAG_LEN_4096));
- // s2nassert(s2n_config_set_cipher_preferences(global_s2n_config, "default_tls13"));
- // s2n_config_set_ticket_decrypt_key_lifetime(global_s2n_config, 9999999);
-
- s2nassert(
- s2n_config_set_cache_store_callback(global_s2n_config, CacheStore.store, &CacheStore.instance),
- );
- s2nassert(
- s2n_config_set_cache_retrieve_callback(global_s2n_config, CacheStore.retrieve, &CacheStore.instance),
- );
- s2nassert(
- s2n_config_set_cache_delete_callback(global_s2n_config, CacheStore.delete, &CacheStore.instance),
- );
- s2nassert(
- s2n_config_set_session_cache_onoff(global_s2n_config, 1),
- );
-
- // s2nassert(s2n_config_init_session_ticket_keys());
- // s2nassert(s2n_config_set_client_auth_type(global_s2n_config, S2N_STATUS_REQUEST_NONE));
-}
-
-pub const CacheStore = struct {
- const CacheEntry = struct {
- key: []u8,
- value: []u8,
- seconds: u64,
-
- pub fn init(
- allocator: *std.mem.Allocator,
- key: *const c_void,
- size: u64,
- value: *const c_void,
- value_size: u64,
- seconds: u64,
- ) CacheEntry {
- const key_bytes = keyBytes(key, size);
- const value_bytes = keyBytes(key, value_size);
-
- var total_bytes = allocator.alloc(u8, key_bytes.len + value_bytes.len) catch unreachable;
- @memcpy(total_bytes.ptr, key_bytes.ptr, key_bytes.len);
- @memcpy(total_bytes[key_bytes.len..].ptr, value_bytes.ptr, value_bytes.len);
-
- return CacheEntry{ .key = total_bytes[0..key_bytes.len], .value = total_bytes[key_bytes.len..], .seconds = seconds };
- }
- };
-
- const Context = struct {
- pub fn hash(this: @This(), key: u64) u64 {
- return key;
- }
-
- pub fn eql(this: @This(), a: u64, b: u64) bool {
- return a == b;
- }
- };
-
- allocator: *std.mem.Allocator,
- map: std.HashMap(u64, CacheEntry, Context, 80),
-
- pub inline fn keyBytes(key: *const c_void, size: u64) []u8 {
- const ptr = @intToPtr([*]u8, @ptrToInt(key));
-
- return ptr[0..size];
- }
-
- inline fn hashKey(key: *const c_void, size: u64) u64 {
- const bytes = keyBytes(key, size);
- return std.hash.Wyhash.hash(0, bytes);
- }
-
- pub fn retrieve(
- conn: *s2n_connection,
- ctx: ?*c_void,
- key: *const c_void,
- key_size: u64,
- value: *c_void,
- value_size: *u64,
- ) callconv(.C) c_int {
- const hash = hashKey(key, key_size);
-
- if (instance.map.getAdapted(hash, Context{})) |entry| {
- const now = @intCast(usize, std.time.timestamp());
- if (now > entry.seconds) {
- _ = instance.map.removeAdapted(hash, Context{});
- return 0;
- }
-
- var value_bytes = keyBytes(value, value_size.*);
- if (value_bytes.len < entry.value.len) return -1;
- std.mem.copy(u8, value_bytes, entry.value);
- value_size.* = entry.value.len;
- return 0;
- }
-
- return 0;
- }
-
- pub fn store(
- conn: *s2n_connection,
- ctx: ?*c_void,
- seconds: u64,
- key: *const c_void,
- key_size: u64,
- value: *const c_void,
- value_size: u64,
- ) callconv(.C) c_int {
- var map_entry = instance.map.getOrPutAdapted(hashKey(key, key_size), Context{}) catch unreachable;
-
- if (!map_entry.found_existing) {
- map_entry.value_ptr.* = CacheEntry.init(instance.allocator, key, key_size, value, value_size, @intCast(usize, std.time.timestamp()) + seconds);
- }
-
- return S2N_SUCCESS;
- }
-
- pub fn delete(
- conn: *s2n_connection,
- ctx: ?*c_void,
- key: *const c_void,
- key_size: u64,
- ) callconv(.C) c_int {
- _ = instance.map.remove(hashKey(key, key_size));
- return 0;
- }
-
- pub var instance: CacheStore = undefined;
-};
-
-pub fn verify_host_callback(ptr: [*c]const u8, len: usize, ctx: ?*c_void) callconv(.C) u8 {
- return 1;
-}
-
-pub extern fn s2n_enable_tls13() c_int;
-pub extern fn s2n_fetch_default_config() *s2n_config;
-pub extern fn s2n_get_highest_fully_supported_tls_version() c_int;
-pub extern fn s2n_errno_location() [*c]c_int;
-pub const S2N_ERR_T_OK: c_int = 0;
-pub const S2N_ERR_T_IO: c_int = 1;
-pub const S2N_ERR_T_CLOSED: c_int = 2;
-pub const S2N_ERR_T_BLOCKED: c_int = 3;
-pub const S2N_ERR_T_ALERT: c_int = 4;
-pub const S2N_ERR_T_PROTO: c_int = 5;
-pub const S2N_ERR_T_INTERNAL: c_int = 6;
-pub const S2N_ERR_T_USAGE: c_int = 7;
-pub const s2n_error_type = c_uint;
-pub extern fn s2n_error_get_type(@"error": c_int) c_int;
-pub const struct_s2n_config = opaque {};
-pub const struct_s2n_connection = opaque {};
-pub extern fn s2n_crypto_disable_init() c_int;
-pub extern fn s2n_disable_atexit() c_int;
-pub extern fn s2n_get_openssl_version() c_ulong;
-pub extern fn s2n_init() c_int;
-pub extern fn s2n_cleanup() c_int;
-pub extern fn s2n_config_new() *struct_s2n_config;
-pub extern fn s2n_config_free(config: *struct_s2n_config) c_int;
-pub extern fn s2n_config_free_dhparams(config: *struct_s2n_config) c_int;
-pub extern fn s2n_config_free_cert_chain_and_key(config: *struct_s2n_config) c_int;
-pub const s2n_clock_time_nanoseconds = ?fn (?*c_void, [*c]u64) callconv(.C) c_int;
-pub const s2n_cache_retrieve_callback = ?fn (*struct_s2n_connection, ?*c_void, *const c_void, u64, *c_void, *u64) callconv(.C) c_int;
-pub const s2n_cache_store_callback = ?fn (*struct_s2n_connection, ?*c_void, u64, *const c_void, u64, *const c_void, u64) callconv(.C) c_int;
-pub const s2n_cache_delete_callback = ?fn (*struct_s2n_connection, ?*c_void, *const c_void, u64) callconv(.C) c_int;
-pub extern fn s2n_config_set_wall_clock(config: *struct_s2n_config, clock_fn: s2n_clock_time_nanoseconds, ctx: ?*c_void) c_int;
-pub extern fn s2n_config_set_monotonic_clock(config: *struct_s2n_config, clock_fn: s2n_clock_time_nanoseconds, ctx: ?*c_void) c_int;
-pub extern fn s2n_strerror(@"error": c_int, lang: [*c]const u8) [*c]const u8;
-pub extern fn s2n_strerror_debug(@"error": c_int, lang: [*c]const u8) [*c]const u8;
-pub extern fn s2n_strerror_name(@"error": c_int) [*c]const u8;
-pub const struct_s2n_stacktrace = opaque {};
-pub extern fn s2n_stack_traces_enabled() bool;
-pub extern fn s2n_stack_traces_enabled_set(newval: bool) c_int;
-pub extern fn s2n_calculate_stacktrace() c_int;
-// pub extern fn s2n_print_stacktrace(fptr: [*c]FILE) c_int;
-pub extern fn s2n_free_stacktrace() c_int;
-pub extern fn s2n_get_stacktrace(trace: *struct_s2n_stacktrace) c_int;
-pub extern fn s2n_config_set_cache_store_callback(config: *struct_s2n_config, cache_store_callback: s2n_cache_store_callback, data: ?*c_void) c_int;
-pub extern fn s2n_config_set_cache_retrieve_callback(config: *struct_s2n_config, cache_retrieve_callback: s2n_cache_retrieve_callback, data: ?*c_void) c_int;
-pub extern fn s2n_config_set_cache_delete_callback(config: *struct_s2n_config, cache_delete_callback: s2n_cache_delete_callback, data: ?*c_void) c_int;
-pub const s2n_mem_init_callback = ?fn () callconv(.C) c_int;
-pub const s2n_mem_cleanup_callback = ?fn () callconv(.C) c_int;
-pub const s2n_mem_malloc_callback = ?fn (**c_void, u32, *u32) callconv(.C) c_int;
-pub const s2n_mem_free_callback = ?fn (?*c_void, u32) callconv(.C) c_int;
-pub extern fn s2n_mem_set_callbacks(mem_init_callback: s2n_mem_init_callback, mem_cleanup_callback: s2n_mem_cleanup_callback, mem_malloc_callback: s2n_mem_malloc_callback, mem_free_callback: s2n_mem_free_callback) c_int;
-pub const s2n_rand_init_callback = ?fn () callconv(.C) c_int;
-pub const s2n_rand_cleanup_callback = ?fn () callconv(.C) c_int;
-pub const s2n_rand_seed_callback = ?fn (?*c_void, u32) callconv(.C) c_int;
-pub const s2n_rand_mix_callback = ?fn (?*c_void, u32) callconv(.C) c_int;
-pub extern fn s2n_rand_set_callbacks(rand_init_callback: s2n_rand_init_callback, rand_cleanup_callback: s2n_rand_cleanup_callback, rand_seed_callback: s2n_rand_seed_callback, rand_mix_callback: s2n_rand_mix_callback) c_int;
-pub const S2N_EXTENSION_SERVER_NAME: c_int = 0;
-pub const S2N_EXTENSION_MAX_FRAG_LEN: c_int = 1;
-pub const S2N_EXTENSION_OCSP_STAPLING: c_int = 5;
-pub const S2N_EXTENSION_SUPPORTED_GROUPS: c_int = 10;
-pub const S2N_EXTENSION_EC_POINT_FORMATS: c_int = 11;
-pub const S2N_EXTENSION_SIGNATURE_ALGORITHMS: c_int = 13;
-pub const S2N_EXTENSION_ALPN: c_int = 16;
-pub const S2N_EXTENSION_CERTIFICATE_TRANSPARENCY: c_int = 18;
-pub const S2N_EXTENSION_RENEGOTIATION_INFO: c_int = 65281;
-pub const s2n_tls_extension_type = c_uint;
-pub const S2N_TLS_MAX_FRAG_LEN_512: c_int = 1;
-pub const S2N_TLS_MAX_FRAG_LEN_1024: c_int = 2;
-pub const S2N_TLS_MAX_FRAG_LEN_2048: c_int = 3;
-pub const S2N_TLS_MAX_FRAG_LEN_4096: c_int = 4;
-pub const s2n_max_frag_len = c_uint;
-pub const struct_s2n_cert = opaque {};
-pub const struct_s2n_cert_chain_and_key = opaque {};
-pub const struct_s2n_pkey = opaque {};
-pub const s2n_cert_public_key = struct_s2n_pkey;
-pub const s2n_cert_private_key = struct_s2n_pkey;
-pub extern fn s2n_cert_chain_and_key_new() *struct_s2n_cert_chain_and_key;
-pub extern fn s2n_cert_chain_and_key_load_pem(chain_and_key: *struct_s2n_cert_chain_and_key, chain_pem: [*c]const u8, private_key_pem: [*c]const u8) c_int;
-pub extern fn s2n_cert_chain_and_key_load_pem_bytes(chain_and_key: *struct_s2n_cert_chain_and_key, chain_pem: [*c]u8, chain_pem_len: u32, private_key_pem: [*c]u8, private_key_pem_len: u32) c_int;
-pub extern fn s2n_cert_chain_and_key_load_public_pem_bytes(chain_and_key: *struct_s2n_cert_chain_and_key, chain_pem: [*c]u8, chain_pem_len: u32) c_int;
-pub extern fn s2n_cert_chain_and_key_free(cert_and_key: *struct_s2n_cert_chain_and_key) c_int;
-pub extern fn s2n_cert_chain_and_key_set_ctx(cert_and_key: *struct_s2n_cert_chain_and_key, ctx: ?*c_void) c_int;
-pub extern fn s2n_cert_chain_and_key_get_ctx(cert_and_key: *struct_s2n_cert_chain_and_key) ?*c_void;
-pub extern fn s2n_cert_chain_and_key_get_private_key(cert_and_key: *struct_s2n_cert_chain_and_key) ?*s2n_cert_private_key;
-pub const s2n_cert_tiebreak_callback = ?fn (*struct_s2n_cert_chain_and_key, *struct_s2n_cert_chain_and_key, [*c]u8, u32) callconv(.C) *struct_s2n_cert_chain_and_key;
-pub extern fn s2n_config_set_cert_tiebreak_callback(config: *struct_s2n_config, cert_tiebreak_cb: s2n_cert_tiebreak_callback) c_int;
-pub extern fn s2n_config_add_cert_chain_and_key(config: *struct_s2n_config, cert_chain_pem: [*c]const u8, private_key_pem: [*c]const u8) c_int;
-pub extern fn s2n_config_add_cert_chain_and_key_to_store(config: *struct_s2n_config, cert_key_pair: *struct_s2n_cert_chain_and_key) c_int;
-pub extern fn s2n_config_set_cert_chain_and_key_defaults(config: *struct_s2n_config, cert_key_pairs: [*c]*struct_s2n_cert_chain_and_key, num_cert_key_pairs: u32) c_int;
-pub extern fn s2n_config_set_verification_ca_location(config: *struct_s2n_config, ca_pem_filename: [*c]const u8, ca_dir: [*c]const u8) c_int;
-pub extern fn s2n_config_add_pem_to_trust_store(config: *struct_s2n_config, pem: [*c]const u8) c_int;
-pub extern fn s2n_config_wipe_trust_store(config: *struct_s2n_config) c_int;
-pub const s2n_verify_host_fn = ?fn ([*c]const u8, usize, ?*c_void) callconv(.C) u8;
-pub extern fn s2n_config_set_verify_host_callback(config: *struct_s2n_config, s2n_verify_host_fn, data: ?*c_void) c_int;
-pub extern fn s2n_config_set_check_stapled_ocsp_response(config: *struct_s2n_config, check_ocsp: u8) c_int;
-pub extern fn s2n_config_disable_x509_verification(config: *struct_s2n_config) c_int;
-pub extern fn s2n_config_set_max_cert_chain_depth(config: *struct_s2n_config, max_depth: u16) c_int;
-pub extern fn s2n_config_add_dhparams(config: *struct_s2n_config, dhparams_pem: [*c]const u8) c_int;
-pub extern fn s2n_config_set_cipher_preferences(config: *struct_s2n_config, version: [*c]const u8) c_int;
-pub extern fn s2n_config_append_protocol_preference(config: *struct_s2n_config, protocol: [*c]const u8, protocol_len: u8) c_int;
-pub extern fn s2n_config_set_protocol_preferences(config: *struct_s2n_config, protocols: [*c]const [*c]const u8, protocol_count: c_int) c_int;
-pub const S2N_STATUS_REQUEST_NONE: c_int = 0;
-pub const S2N_STATUS_REQUEST_OCSP: c_int = 1;
-pub const s2n_status_request_type = c_uint;
-pub extern fn s2n_config_set_status_request_type(config: *struct_s2n_config, @"type": s2n_status_request_type) c_int;
-pub const S2N_CT_SUPPORT_NONE: c_int = 0;
-pub const S2N_CT_SUPPORT_REQUEST: c_int = 1;
-pub const s2n_ct_support_level = c_uint;
-pub extern fn s2n_config_set_ct_support_level(config: *struct_s2n_config, level: s2n_ct_support_level) c_int;
-pub const S2N_ALERT_FAIL_ON_WARNINGS: c_int = 0;
-pub const S2N_ALERT_IGNORE_WARNINGS: c_int = 1;
-pub const s2n_alert_behavior = c_uint;
-pub extern fn s2n_config_set_alert_behavior(config: *struct_s2n_config, alert_behavior: s2n_alert_behavior) c_int;
-pub extern fn s2n_config_set_extension_data(config: *struct_s2n_config, @"type": s2n_tls_extension_type, data: [*c]const u8, length: u32) c_int;
-pub extern fn s2n_config_send_max_fragment_length(config: *struct_s2n_config, mfl_code: s2n_max_frag_len) c_int;
-pub extern fn s2n_config_accept_max_fragment_length(config: *struct_s2n_config) c_int;
-pub extern fn s2n_config_set_session_state_lifetime(config: *struct_s2n_config, lifetime_in_secs: u64) c_int;
-pub extern fn s2n_config_set_session_tickets_onoff(config: *struct_s2n_config, enabled: u8) c_int;
-pub extern fn s2n_config_set_session_cache_onoff(config: *struct_s2n_config, enabled: u8) c_int;
-pub extern fn s2n_config_set_ticket_encrypt_decrypt_key_lifetime(config: *struct_s2n_config, lifetime_in_secs: u64) c_int;
-pub extern fn s2n_config_set_ticket_decrypt_key_lifetime(config: *struct_s2n_config, lifetime_in_secs: u64) c_int;
-pub extern fn s2n_config_add_ticket_crypto_key(config: *struct_s2n_config, name: [*c]const u8, name_len: u32, key: [*c]u8, key_len: u32, intro_time_in_seconds_from_epoch: u64) c_int;
-pub const S2N_SERVER: c_int = 0;
-pub const S2N_CLIENT: c_int = 1;
-pub const s2n_mode = c_uint;
-pub extern fn s2n_connection_new(mode: s2n_mode) *struct_s2n_connection;
-pub extern fn s2n_connection_set_config(conn: *struct_s2n_connection, config: *struct_s2n_config) c_int;
-pub extern fn s2n_connection_set_ctx(conn: *struct_s2n_connection, ctx: ?*c_void) c_int;
-pub extern fn s2n_connection_get_ctx(conn: *struct_s2n_connection) ?*c_void;
-pub const s2n_client_hello_fn = fn (*struct_s2n_connection, ?*c_void) callconv(.C) c_int;
-pub const S2N_CLIENT_HELLO_CB_BLOCKING: c_int = 0;
-pub const S2N_CLIENT_HELLO_CB_NONBLOCKING: c_int = 1;
-pub const s2n_client_hello_cb_mode = c_uint;
-pub extern fn s2n_config_set_client_hello_cb(config: *struct_s2n_config, client_hello_callback: ?s2n_client_hello_fn, ctx: ?*c_void) c_int;
-pub extern fn s2n_config_set_client_hello_cb_mode(config: *struct_s2n_config, cb_mode: s2n_client_hello_cb_mode) c_int;
-pub extern fn s2n_client_hello_cb_done(conn: *struct_s2n_connection) c_int;
-pub extern fn s2n_connection_server_name_extension_used(conn: *struct_s2n_connection) c_int;
-pub const struct_s2n_client_hello = opaque {};
-pub extern fn s2n_connection_get_client_hello(conn: *struct_s2n_connection) *struct_s2n_client_hello;
-pub extern fn s2n_client_hello_get_raw_message_length(ch: *struct_s2n_client_hello) isize;
-pub extern fn s2n_client_hello_get_raw_message(ch: *struct_s2n_client_hello, out: [*c]u8, max_length: u32) isize;
-pub extern fn s2n_client_hello_get_cipher_suites_length(ch: *struct_s2n_client_hello) isize;
-pub extern fn s2n_client_hello_get_cipher_suites(ch: *struct_s2n_client_hello, out: [*c]u8, max_length: u32) isize;
-pub extern fn s2n_client_hello_get_extensions_length(ch: *struct_s2n_client_hello) isize;
-pub extern fn s2n_client_hello_get_extensions(ch: *struct_s2n_client_hello, out: [*c]u8, max_length: u32) isize;
-pub extern fn s2n_client_hello_get_extension_length(ch: *struct_s2n_client_hello, extension_type: s2n_tls_extension_type) isize;
-pub extern fn s2n_client_hello_get_extension_by_id(ch: *struct_s2n_client_hello, extension_type: s2n_tls_extension_type, out: [*c]u8, max_length: u32) isize;
-pub extern fn s2n_client_hello_get_session_id_length(ch: *struct_s2n_client_hello, out_length: [*c]u32) c_int;
-pub extern fn s2n_client_hello_get_session_id(ch: *struct_s2n_client_hello, out: [*c]u8, out_length: [*c]u32, max_length: u32) c_int;
-pub extern fn s2n_connection_set_fd(conn: *struct_s2n_connection, fd: c_int) c_int;
-pub extern fn s2n_connection_set_read_fd(conn: *struct_s2n_connection, readfd: c_int) c_int;
-pub extern fn s2n_connection_set_write_fd(conn: *struct_s2n_connection, writefd: c_int) c_int;
-pub extern fn s2n_connection_get_read_fd(conn: *struct_s2n_connection, readfd: [*c]c_int) c_int;
-pub extern fn s2n_connection_get_write_fd(conn: *struct_s2n_connection, writefd: [*c]c_int) c_int;
-pub extern fn s2n_connection_use_corked_io(conn: *struct_s2n_connection) c_int;
-pub const s2n_recv_fn = fn (*s2n_connection, [*c]u8, u32) callconv(.C) c_int;
-pub const s2n_send_fn = fn (*s2n_connection, [*c]const u8, u32) callconv(.C) c_int;
-pub extern fn s2n_connection_set_recv_ctx(conn: *struct_s2n_connection, ctx: ?*c_void) c_int;
-pub extern fn s2n_connection_set_send_ctx(conn: *struct_s2n_connection, ctx: ?*c_void) c_int;
-pub extern fn s2n_connection_set_recv_cb(conn: *struct_s2n_connection, recv: ?s2n_recv_fn) c_int;
-pub extern fn s2n_connection_set_send_cb(conn: *struct_s2n_connection, send: ?s2n_send_fn) c_int;
-pub extern fn s2n_connection_prefer_throughput(conn: *struct_s2n_connection) c_int;
-pub extern fn s2n_connection_prefer_low_latency(conn: *struct_s2n_connection) c_int;
-pub extern fn s2n_connection_set_dynamic_record_threshold(conn: *struct_s2n_connection, resize_threshold: u32, timeout_threshold: u16) c_int;
-pub extern fn s2n_connection_set_verify_host_callback(config: *struct_s2n_connection, host_fn: s2n_verify_host_fn, data: ?*c_void) c_int;
-pub const S2N_BUILT_IN_BLINDING: c_int = 0;
-pub const S2N_SELF_SERVICE_BLINDING: c_int = 1;
-pub const s2n_blinding = c_uint;
-pub extern fn s2n_connection_set_blinding(conn: *struct_s2n_connection, blinding: s2n_blinding) c_int;
-pub extern fn s2n_connection_get_delay(conn: *struct_s2n_connection) u64;
-pub extern fn s2n_connection_set_cipher_preferences(conn: *struct_s2n_connection, version: [*c]const u8) c_int;
-pub extern fn s2n_connection_append_protocol_preference(conn: *struct_s2n_connection, protocol: [*c]const u8, protocol_len: u8) c_int;
-pub extern fn s2n_connection_set_protocol_preferences(conn: *struct_s2n_connection, protocols: [*c]const [*c]const u8, protocol_count: c_int) c_int;
-pub extern fn s2n_set_server_name(conn: *struct_s2n_connection, server_name: [*c]const u8) c_int;
-pub extern fn s2n_get_server_name(conn: *struct_s2n_connection) [*c]const u8;
-pub extern fn s2n_get_application_protocol(conn: *struct_s2n_connection) [*c]const u8;
-pub extern fn s2n_connection_get_ocsp_response(conn: *struct_s2n_connection, length: [*c]u32) [*c]const u8;
-pub extern fn s2n_connection_get_sct_list(conn: *struct_s2n_connection, length: [*c]u32) [*c]const u8;
-pub const S2N_NOT_BLOCKED: c_int = 0;
-pub const S2N_BLOCKED_ON_READ: c_int = 1;
-pub const S2N_BLOCKED_ON_WRITE: c_int = 2;
-pub const S2N_BLOCKED_ON_APPLICATION_INPUT: c_int = 3;
-pub const S2N_BLOCKED_ON_EARLY_DATA: c_int = 4;
-pub const s2n_blocked_status = c_uint;
-pub extern fn s2n_negotiate(conn: *struct_s2n_connection, blocked: [*c]s2n_blocked_status) c_int;
-pub extern fn s2n_send(conn: *struct_s2n_connection, buf: *const c_void, size: isize, blocked: [*c]s2n_blocked_status) isize;
-// pub extern fn s2n_sendv(conn: *struct_s2n_connection, bufs: [*c]const struct_iovec, count: isize, blocked: [*c]s2n_blocked_status) isize;
-// pub extern fn s2n_sendv_with_offset(conn: *struct_s2n_connection, bufs: [*c]const struct_iovec, count: isize, offs: isize, blocked: [*c]s2n_blocked_status) isize;
-pub extern fn s2n_recv(conn: *struct_s2n_connection, buf: *c_void, size: isize, blocked: [*c]s2n_blocked_status) isize;
-pub extern fn s2n_peek(conn: *struct_s2n_connection) u32;
-pub extern fn s2n_connection_free_handshake(conn: *struct_s2n_connection) c_int;
-pub extern fn s2n_connection_release_buffers(conn: *struct_s2n_connection) c_int;
-pub extern fn s2n_connection_wipe(conn: *struct_s2n_connection) c_int;
-pub extern fn s2n_connection_free(conn: *struct_s2n_connection) c_int;
-pub extern fn s2n_shutdown(conn: *struct_s2n_connection, blocked: [*c]s2n_blocked_status) c_int;
-pub const S2N_CERT_AUTH_NONE: c_int = 0;
-pub const S2N_CERT_AUTH_REQUIRED: c_int = 1;
-pub const S2N_CERT_AUTH_OPTIONAL: c_int = 2;
-pub const s2n_cert_auth_type = c_uint;
-pub extern fn s2n_config_get_client_auth_type(config: *struct_s2n_config, client_auth_type: [*c]s2n_cert_auth_type) c_int;
-pub extern fn s2n_config_set_client_auth_type(config: *struct_s2n_config, client_auth_type: s2n_cert_auth_type) c_int;
-pub extern fn s2n_connection_get_client_auth_type(conn: *struct_s2n_connection, client_auth_type: [*c]s2n_cert_auth_type) c_int;
-pub extern fn s2n_connection_set_client_auth_type(conn: *struct_s2n_connection, client_auth_type: s2n_cert_auth_type) c_int;
-pub extern fn s2n_connection_get_client_cert_chain(conn: *struct_s2n_connection, der_cert_chain_out: [*c][*c]u8, cert_chain_len: [*c]u32) c_int;
-pub extern fn s2n_config_set_initial_ticket_count(config: *struct_s2n_config, num: u8) c_int;
-pub extern fn s2n_connection_add_new_tickets_to_send(conn: *struct_s2n_connection, num: u8) c_int;
-pub extern fn s2n_connection_get_tickets_sent(conn: *struct_s2n_connection, num: [*c]u16) c_int;
-pub extern fn s2n_connection_set_server_keying_material_lifetime(conn: *struct_s2n_connection, lifetime_in_secs: u32) c_int;
-pub const struct_s2n_session_ticket = opaque {};
-pub const s2n_session_ticket_fn = ?fn (*struct_s2n_connection, ?*c_void, *struct_s2n_session_ticket) callconv(.C) c_int;
-pub extern fn s2n_config_set_session_ticket_cb(config: *struct_s2n_config, callback: s2n_session_ticket_fn, ctx: ?*c_void) c_int;
-pub extern fn s2n_session_ticket_get_data_len(ticket: *struct_s2n_session_ticket, data_len: [*c]usize) c_int;
-pub extern fn s2n_session_ticket_get_data(ticket: *struct_s2n_session_ticket, max_data_len: usize, data: [*c]u8) c_int;
-pub extern fn s2n_session_ticket_get_lifetime(ticket: *struct_s2n_session_ticket, session_lifetime: [*c]u32) c_int;
-pub extern fn s2n_connection_set_session(conn: *struct_s2n_connection, session: [*c]const u8, length: usize) c_int;
-pub extern fn s2n_connection_get_session(conn: *struct_s2n_connection, session: [*c]u8, max_length: usize) c_int;
-pub extern fn s2n_connection_get_session_ticket_lifetime_hint(conn: *struct_s2n_connection) c_int;
-pub extern fn s2n_connection_get_session_length(conn: *struct_s2n_connection) c_int;
-pub extern fn s2n_connection_get_session_id_length(conn: *struct_s2n_connection) c_int;
-pub extern fn s2n_connection_get_session_id(conn: *struct_s2n_connection, session_id: [*c]u8, max_length: usize) c_int;
-pub extern fn s2n_connection_is_session_resumed(conn: *struct_s2n_connection) c_int;
-pub extern fn s2n_connection_is_ocsp_stapled(conn: *struct_s2n_connection) c_int;
-pub const S2N_TLS_SIGNATURE_ANONYMOUS: c_int = 0;
-pub const S2N_TLS_SIGNATURE_RSA: c_int = 1;
-pub const S2N_TLS_SIGNATURE_ECDSA: c_int = 3;
-pub const S2N_TLS_SIGNATURE_RSA_PSS_RSAE: c_int = 224;
-pub const S2N_TLS_SIGNATURE_RSA_PSS_PSS: c_int = 225;
-pub const s2n_tls_signature_algorithm = c_uint;
-pub const S2N_TLS_HASH_NONE: c_int = 0;
-pub const S2N_TLS_HASH_MD5: c_int = 1;
-pub const S2N_TLS_HASH_SHA1: c_int = 2;
-pub const S2N_TLS_HASH_SHA224: c_int = 3;
-pub const S2N_TLS_HASH_SHA256: c_int = 4;
-pub const S2N_TLS_HASH_SHA384: c_int = 5;
-pub const S2N_TLS_HASH_SHA512: c_int = 6;
-pub const S2N_TLS_HASH_MD5_SHA1: c_int = 224;
-pub const s2n_tls_hash_algorithm = c_uint;
-pub extern fn s2n_connection_get_selected_signature_algorithm(conn: *struct_s2n_connection, chosen_alg: [*c]s2n_tls_signature_algorithm) c_int;
-pub extern fn s2n_connection_get_selected_digest_algorithm(conn: *struct_s2n_connection, chosen_alg: [*c]s2n_tls_hash_algorithm) c_int;
-pub extern fn s2n_connection_get_selected_client_cert_signature_algorithm(conn: *struct_s2n_connection, chosen_alg: [*c]s2n_tls_signature_algorithm) c_int;
-pub extern fn s2n_connection_get_selected_client_cert_digest_algorithm(conn: *struct_s2n_connection, chosen_alg: [*c]s2n_tls_hash_algorithm) c_int;
-pub extern fn s2n_connection_get_selected_cert(conn: *struct_s2n_connection) *struct_s2n_cert_chain_and_key;
-pub extern fn s2n_cert_chain_get_length(chain_and_key: ?*const struct_s2n_cert_chain_and_key, cert_length: [*c]u32) c_int;
-pub extern fn s2n_cert_chain_get_cert(chain_and_key: ?*const struct_s2n_cert_chain_and_key, out_cert: [*c]*struct_s2n_cert, cert_idx: u32) c_int;
-pub extern fn s2n_cert_get_der(cert: ?*const struct_s2n_cert, out_cert_der: [*c][*c]const u8, cert_length: [*c]u32) c_int;
-pub extern fn s2n_connection_get_peer_cert_chain(conn: *const struct_s2n_connection, cert_chain: *struct_s2n_cert_chain_and_key) c_int;
-pub extern fn s2n_cert_get_x509_extension_value_length(cert: *struct_s2n_cert, oid: [*c]const u8, ext_value_len: [*c]u32) c_int;
-pub extern fn s2n_cert_get_x509_extension_value(cert: *struct_s2n_cert, oid: [*c]const u8, ext_value: [*c]u8, ext_value_len: [*c]u32, critical: [*c]bool) c_int;
-pub extern fn s2n_cert_get_utf8_string_from_extension_data_length(extension_data: [*c]const u8, extension_len: u32, utf8_str_len: [*c]u32) c_int;
-pub extern fn s2n_cert_get_utf8_string_from_extension_data(extension_data: [*c]const u8, extension_len: u32, out_data: [*c]u8, out_len: [*c]u32) c_int;
-pub const S2N_PSK_HMAC_SHA256: c_int = 0;
-pub const S2N_PSK_HMAC_SHA384: c_int = 1;
-pub const s2n_psk_hmac = c_uint;
-pub const struct_s2n_psk = opaque {};
-pub extern fn s2n_external_psk_new() *struct_s2n_psk;
-pub extern fn s2n_psk_free(psk: [*c]*struct_s2n_psk) c_int;
-pub extern fn s2n_psk_set_identity(psk: *struct_s2n_psk, identity: [*c]const u8, identity_size: u16) c_int;
-pub extern fn s2n_psk_set_secret(psk: *struct_s2n_psk, secret: [*c]const u8, secret_size: u16) c_int;
-pub extern fn s2n_psk_set_hmac(psk: *struct_s2n_psk, hmac: s2n_psk_hmac) c_int;
-pub extern fn s2n_connection_append_psk(conn: *struct_s2n_connection, psk: *struct_s2n_psk) c_int;
-pub const S2N_PSK_MODE_RESUMPTION: c_int = 0;
-pub const S2N_PSK_MODE_EXTERNAL: c_int = 1;
-pub const s2n_psk_mode = c_uint;
-pub extern fn s2n_config_set_psk_mode(config: *struct_s2n_config, mode: s2n_psk_mode) c_int;
-pub extern fn s2n_connection_set_psk_mode(conn: *struct_s2n_connection, mode: s2n_psk_mode) c_int;
-pub extern fn s2n_connection_get_negotiated_psk_identity_length(conn: *struct_s2n_connection, identity_length: [*c]u16) c_int;
-pub extern fn s2n_connection_get_negotiated_psk_identity(conn: *struct_s2n_connection, identity: [*c]u8, max_identity_length: u16) c_int;
-pub const struct_s2n_offered_psk = opaque {};
-pub extern fn s2n_offered_psk_new() *struct_s2n_offered_psk;
-pub extern fn s2n_offered_psk_free(psk: [*c]*struct_s2n_offered_psk) c_int;
-pub extern fn s2n_offered_psk_get_identity(psk: *struct_s2n_offered_psk, identity: [*c][*c]u8, size: [*c]u16) c_int;
-pub const struct_s2n_offered_psk_list = opaque {};
-pub extern fn s2n_offered_psk_list_has_next(psk_list: *struct_s2n_offered_psk_list) bool;
-pub extern fn s2n_offered_psk_list_next(psk_list: *struct_s2n_offered_psk_list, psk: *struct_s2n_offered_psk) c_int;
-pub extern fn s2n_offered_psk_list_reread(psk_list: *struct_s2n_offered_psk_list) c_int;
-pub extern fn s2n_offered_psk_list_choose_psk(psk_list: *struct_s2n_offered_psk_list, psk: *struct_s2n_offered_psk) c_int;
-pub const s2n_psk_selection_callback = ?fn (*struct_s2n_connection, ?*c_void, *struct_s2n_offered_psk_list) callconv(.C) c_int;
-pub extern fn s2n_config_set_psk_selection_callback(config: *struct_s2n_config, cb: s2n_psk_selection_callback, context: ?*c_void) c_int;
-pub extern fn s2n_connection_get_wire_bytes_in(conn: *struct_s2n_connection) u64;
-pub extern fn s2n_connection_get_wire_bytes_out(conn: *struct_s2n_connection) u64;
-pub extern fn s2n_connection_get_client_protocol_version(conn: *struct_s2n_connection) c_int;
-pub extern fn s2n_connection_get_server_protocol_version(conn: *struct_s2n_connection) c_int;
-pub extern fn s2n_connection_get_actual_protocol_version(conn: *struct_s2n_connection) c_int;
-pub extern fn s2n_connection_get_client_hello_version(conn: *struct_s2n_connection) c_int;
-pub extern fn s2n_connection_client_cert_used(conn: *struct_s2n_connection) c_int;
-pub extern fn s2n_connection_get_cipher(conn: *struct_s2n_connection) [*c]const u8;
-pub extern fn s2n_connection_get_cipher_iana_value(conn: *struct_s2n_connection, first: [*c]u8, second: [*c]u8) c_int;
-pub extern fn s2n_connection_is_valid_for_cipher_preferences(conn: *struct_s2n_connection, version: [*c]const u8) c_int;
-pub extern fn s2n_connection_get_curve(conn: *struct_s2n_connection) [*c]const u8;
-pub extern fn s2n_connection_get_kem_name(conn: *struct_s2n_connection) [*c]const u8;
-pub extern fn s2n_connection_get_kem_group_name(conn: *struct_s2n_connection) [*c]const u8;
-pub extern fn s2n_connection_get_alert(conn: *struct_s2n_connection) c_int;
-pub extern fn s2n_connection_get_handshake_type_name(conn: *struct_s2n_connection) [*c]const u8;
-pub extern fn s2n_connection_get_last_message_name(conn: *struct_s2n_connection) [*c]const u8;
-pub const struct_s2n_async_pkey_op = opaque {};
-pub const S2N_ASYNC_PKEY_VALIDATION_FAST: c_int = 0;
-pub const S2N_ASYNC_PKEY_VALIDATION_STRICT: c_int = 1;
-pub const s2n_async_pkey_validation_mode = c_uint;
-pub const S2N_ASYNC_DECRYPT: c_int = 0;
-pub const S2N_ASYNC_SIGN: c_int = 1;
-pub const s2n_async_pkey_op_type = c_uint;
-pub const s2n_async_pkey_fn = ?fn (*struct_s2n_connection, *struct_s2n_async_pkey_op) callconv(.C) c_int;
-pub extern fn s2n_config_set_async_pkey_callback(config: *struct_s2n_config, @"fn": s2n_async_pkey_fn) c_int;
-pub extern fn s2n_async_pkey_op_perform(op: *struct_s2n_async_pkey_op, key: ?*s2n_cert_private_key) c_int;
-pub extern fn s2n_async_pkey_op_apply(op: *struct_s2n_async_pkey_op, conn: *struct_s2n_connection) c_int;
-pub extern fn s2n_async_pkey_op_free(op: *struct_s2n_async_pkey_op) c_int;
-pub extern fn s2n_config_set_async_pkey_validation_mode(config: *struct_s2n_config, mode: s2n_async_pkey_validation_mode) c_int;
-pub extern fn s2n_async_pkey_op_get_op_type(op: *struct_s2n_async_pkey_op, @"type": [*c]s2n_async_pkey_op_type) c_int;
-pub extern fn s2n_async_pkey_op_get_input_size(op: *struct_s2n_async_pkey_op, data_len: [*c]u32) c_int;
-pub extern fn s2n_async_pkey_op_get_input(op: *struct_s2n_async_pkey_op, data: [*c]u8, data_len: u32) c_int;
-pub extern fn s2n_async_pkey_op_set_output(op: *struct_s2n_async_pkey_op, data: [*c]const u8, data_len: u32) c_int;
-pub const s2n_key_log_fn = ?fn (?*c_void, *struct_s2n_connection, [*c]u8, usize) callconv(.C) c_int;
-pub extern fn s2n_config_set_key_log_cb(config: *struct_s2n_config, callback: s2n_key_log_fn, ctx: ?*c_void) c_int;
-pub extern fn s2n_config_enable_cert_req_dss_legacy_compat(config: *struct_s2n_config) c_int;
-pub extern fn s2n_config_set_server_max_early_data_size(config: *struct_s2n_config, max_early_data_size: u32) c_int;
-pub extern fn s2n_connection_set_server_max_early_data_size(conn: *struct_s2n_connection, max_early_data_size: u32) c_int;
-pub extern fn s2n_connection_set_server_early_data_context(conn: *struct_s2n_connection, context: [*c]const u8, context_size: u16) c_int;
-pub extern fn s2n_psk_configure_early_data(psk: *struct_s2n_psk, max_early_data_size: u32, cipher_suite_first_byte: u8, cipher_suite_second_byte: u8) c_int;
-pub extern fn s2n_psk_set_application_protocol(psk: *struct_s2n_psk, application_protocol: [*c]const u8, size: u8) c_int;
-pub extern fn s2n_psk_set_early_data_context(psk: *struct_s2n_psk, context: [*c]const u8, size: u16) c_int;
-pub const S2N_EARLY_DATA_STATUS_OK: c_int = 0;
-pub const S2N_EARLY_DATA_STATUS_NOT_REQUESTED: c_int = 1;
-pub const S2N_EARLY_DATA_STATUS_REJECTED: c_int = 2;
-pub const S2N_EARLY_DATA_STATUS_END: c_int = 3;
-pub const s2n_early_data_status_t = c_uint;
-pub extern fn s2n_connection_get_early_data_status(conn: *struct_s2n_connection, status: [*c]s2n_early_data_status_t) c_int;
-pub extern fn s2n_connection_get_remaining_early_data_size(conn: *struct_s2n_connection, allowed_early_data_size: [*c]u32) c_int;
-pub extern fn s2n_connection_get_max_early_data_size(conn: *struct_s2n_connection, max_early_data_size: [*c]u32) c_int;
-pub extern fn s2n_send_early_data(conn: *struct_s2n_connection, data: [*c]const u8, data_len: isize, data_sent: [*c]isize, blocked: [*c]s2n_blocked_status) c_int;
-pub extern fn s2n_recv_early_data(conn: *struct_s2n_connection, data: [*c]u8, max_data_len: isize, data_received: [*c]isize, blocked: [*c]s2n_blocked_status) c_int;
-pub const struct_s2n_offered_early_data = opaque {};
-pub const s2n_early_data_cb = ?fn (*struct_s2n_connection, *struct_s2n_offered_early_data) callconv(.C) c_int;
-pub extern fn s2n_config_set_early_data_cb(config: *struct_s2n_config, cb: s2n_early_data_cb) c_int;
-pub extern fn s2n_offered_early_data_get_context_length(early_data: *struct_s2n_offered_early_data, context_len: [*c]u16) c_int;
-pub extern fn s2n_offered_early_data_get_context(early_data: *struct_s2n_offered_early_data, context: [*c]u8, max_len: u16) c_int;
-pub extern fn s2n_offered_early_data_reject(early_data: *struct_s2n_offered_early_data) c_int;
-pub extern fn s2n_offered_early_data_accept(early_data: *struct_s2n_offered_early_data) c_int;
-pub const S2N_SUCCESS = @as(c_int, 0);
-pub const S2N_FAILURE = -@as(c_int, 1);
-pub const S2N_CALLBACK_BLOCKED = -@as(c_int, 2);
-pub const S2N_MINIMUM_SUPPORTED_TLS_RECORD_MAJOR_VERSION = @as(c_int, 2);
-pub const S2N_MAXIMUM_SUPPORTED_TLS_RECORD_MAJOR_VERSION = @as(c_int, 3);
-pub const S2N_SSLv2 = @as(c_int, 20);
-pub const S2N_SSLv3 = @as(c_int, 30);
-pub const S2N_TLS10 = @as(c_int, 31);
-pub const S2N_TLS11 = @as(c_int, 32);
-pub const S2N_TLS12 = @as(c_int, 33);
-pub const S2N_TLS13 = @as(c_int, 34);
-pub const S2N_UNKNOWN_PROTOCOL_VERSION = @as(c_int, 0);
-pub const s2n_config = struct_s2n_config;
-pub const s2n_connection = struct_s2n_connection;
-pub const s2n_stacktrace = struct_s2n_stacktrace;
-pub const s2n_cert = struct_s2n_cert;
-pub const s2n_cert_chain_and_key = struct_s2n_cert_chain_and_key;
-pub const s2n_pkey = struct_s2n_pkey;
-pub const s2n_client_hello = struct_s2n_client_hello;
-pub const s2n_session_ticket = struct_s2n_session_ticket;
-pub const s2n_psk = struct_s2n_psk;
-pub const s2n_offered_psk = struct_s2n_offered_psk;
-pub const s2n_offered_psk_list = struct_s2n_offered_psk_list;
-pub const s2n_async_pkey_op = struct_s2n_async_pkey_op;
-pub const s2n_offered_early_data = struct_s2n_offered_early_data;
-
-var booted = false;
-pub var global_s2n_config: *s2n_config = undefined;
-const unexpectedErrno = std.os.unexpectedErrno;
-const S2NError = error{ Closed, WouldBlock, Alert, Protocol, Internal, Usage };
-pub inline fn s2nErrorNo(rc: c_int) S2NError!std.os.system.E {
- switch (s2n_error_get_type(rc)) {
- -1 => return error.Internal,
- S2N_ERR_T_OK => return .SUCCESS,
- S2N_ERR_T_IO => return std.os.errno(rc),
- S2N_ERR_T_CLOSED => return error.Closed,
- S2N_ERR_T_BLOCKED => return error.WouldBlock,
- S2N_ERR_T_ALERT => return error.Alert,
- S2N_ERR_T_PROTO => return error.Protocol,
- S2N_ERR_T_INTERNAL => return error.Internal,
- S2N_ERR_T_USAGE => return error.Usage,
- else => return std.os.errno(rc),
- }
-}
-
-pub const Connection = struct {
- conn: *s2n_connection = undefined,
- fd: std.os.socket_t,
- node: *Pool.List.Node,
- disable_shutdown: bool = false,
-
- pub const Pool = struct {
- pub const List = std.SinglyLinkedList(*s2n_connection);
- pub var list = List{};
-
- pub fn get() *Pool.List.Node {
- if (list.first) |first| {
- return first;
- } else {
- var node = Allocator.allocator.create(Pool.List.Node) catch unreachable;
- node.* = Pool.List.Node{ .data = s2n_connection_new(S2N_CLIENT) };
- return node;
- }
- }
-
- pub fn put(conn: *Pool.List.Node) void {
- _ = s2n_connection_wipe(conn.data);
- list.prepend(conn);
- }
- };
-
- // var pool = std.SinglyLinkedList();
- // var pool_used: std.atomic.Atomic(u32) = std.atomic.Atomic(u32).init(0);
-
- pub fn init(fd: std.os.socket_t) Connection {
- return Connection{
- .fd = fd,
- .conn = undefined,
- .node = undefined,
- };
- }
-
- const errno = s2nErrorNo;
-
- // pub fn s2n_recv_function(conn: *s2n_connection, buf: [*c]u8, len: u32) callconv(.C) c_int {
- // if (buf == null) return 0;
- // var fd: c_int = 0;
- // _ = s2n_connection_get_read_fd(conn, &fd);
- // return @intCast(c_int, std.os.system.recvfrom(fd, buf, len, std.os.SOCK_CLOEXEC, null, null));
- // }
- // pub fn s2n_send_function(conn: *s2n_connection, buf: [*c]const u8, len: u32) callconv(.C) c_int {
- // if (buf == null) return 0;
- // var fd: c_int = 0;
- // _ = s2n_connection_get_write_fd(conn, &fd);
-
- // return @intCast(c_int, std.os.system.sendto(fd, buf.?, len, std.os.SOCK_CLOEXEC, null, 0));
- // }
-
- pub fn start(this: *Connection, server_name: [:0]const u8) !void {
- this.node = Pool.get();
- this.conn = this.node.data;
- s2nassert(s2n_connection_set_ctx(this.conn, this));
- s2nassert(s2n_connection_set_config(this.conn, global_s2n_config));
- s2nassert(s2n_connection_set_read_fd(this.conn, @intCast(c_int, this.fd)));
- s2nassert(s2n_connection_set_fd(this.conn, @intCast(c_int, this.fd)));
- s2nassert(s2n_connection_set_write_fd(this.conn, @intCast(c_int, this.fd)));
- s2nassert(s2n_connection_set_blinding(this.conn, S2N_SELF_SERVICE_BLINDING));
- // s2nassert(s2n_connection_set_dynamic_record(this.conn));
- s2nassert(s2n_set_server_name(this.conn, server_name.ptr));
-
- // _ = s2n_connection_set_recv_cb(this.conn, s2n_recv_function);
- // _ = s2n_connection_set_send_cb(this.conn, s2n_send_function);
- const rc = s2n_negotiate(this.conn, &blocked_status);
- if (rc < 0) {
- Output.printErrorln("Alert: {d}", .{s2n_connection_get_alert(this.conn)});
- Output.prettyErrorln("ERROR: {s}", .{s2n_strerror_debug(rc, "EN")});
- }
-
- defer s2nassert(s2n_connection_free_handshake(this.conn));
-
- switch (try s2nErrorNo(rc)) {
- .SUCCESS => return,
- .BADF => unreachable, // always a race condition
- .FAULT => unreachable,
- .INVAL => unreachable,
- .NOTCONN => unreachable,
- .NOTSOCK => unreachable,
- .INTR => return error.Interrupted,
- .AGAIN => return error.WouldBlock,
- .NOMEM => return error.SystemResources,
- .CONNREFUSED => return error.ConnectionRefused,
- .CONNRESET => return error.ConnectionResetByPeer,
- else => |err| return unexpectedErrno(err),
- }
- }
-
- pub fn close(this: *Connection) !void {
- if (!this.disable_shutdown) {
- _ = s2n_shutdown(this.conn, &blocked_status);
- }
- std.os.closeSocket(this.fd);
- Pool.put(this.node);
- }
-
- pub const Writer = std.io.Writer(*Connection, WriteError, write);
- pub const Reader = std.io.Reader(*Connection, ReadError, read);
-
- pub fn writer(this: *Connection) Writer {
- return Writer{ .context = this };
- }
-
- pub fn reader(this: *Connection) Reader {
- return Reader{ .context = this };
- }
-
- pub const ReadError = error{
- WouldBlock,
- SystemResources,
- ConnectionRefused,
- ConnectionResetByPeer,
- Unexpected,
- Interrupted,
- } || S2NError;
-
- pub fn read(this: *Connection, buf: []u8) ReadError!usize {
- const rc = s2n_recv(this.conn, buf.ptr, @intCast(isize, buf.len), &blocked_status);
-
- switch (try errno(@intCast(c_int, rc))) {
- .SUCCESS => return @intCast(usize, rc),
- .BADF => unreachable, // always a race condition
- .FAULT => unreachable,
- .INVAL => unreachable,
- .NOTCONN => unreachable,
- .NOTSOCK => unreachable,
- .INTR => return error.Interrupted,
- .AGAIN => return error.WouldBlock,
- .NOMEM => return error.SystemResources,
- .CONNREFUSED => return error.ConnectionRefused,
- .CONNRESET => return error.ConnectionResetByPeer,
- else => |err| return unexpectedErrno(err),
- }
- }
-
- pub fn peek(this: *Connection) u32 {
- return s2n_peek(this.conn);
- }
-
- var blocked_status: s2n_blocked_status = 0;
- pub const WriteError = error{
- AccessDenied,
- AddressFamilyNotSupported,
- BrokenPipe,
- ConnectionResetByPeer,
- FastOpenAlreadyInProgress,
- FileNotFound,
- MessageTooBig,
- NameTooLong,
- NetworkSubsystemFailed,
- NetworkUnreachable,
- NotDir,
- SocketNotConnected,
- SymLinkLoop,
- SystemResources,
- WouldBlock,
- Unexpected,
- } || S2NError;
- pub fn write(this: *Connection, buf: []const u8) WriteError!usize {
- const rc = s2n_send(this.conn, buf.ptr, @intCast(isize, buf.len), &blocked_status);
- // std.os.sendto(
- switch (try errno(@intCast(c_int, rc))) {
- .SUCCESS => return buf.len,
- .ACCES => return error.AccessDenied,
- .AGAIN => return error.WouldBlock,
- .ALREADY => return error.FastOpenAlreadyInProgress,
- .BADF => unreachable, // always a race condition
- .CONNRESET => return error.ConnectionResetByPeer,
- .DESTADDRREQ => unreachable, // The socket is not connection-mode, and no peer address is set.
- .FAULT => unreachable, // An invalid user space address was specified for an argument.
- .INTR => unreachable,
- .INVAL => unreachable, // Invalid argument passed.
- .ISCONN => unreachable, // connection-mode socket was connected already but a recipient was specified
- .MSGSIZE => return error.MessageTooBig,
- .NOBUFS => return error.SystemResources,
- .NOMEM => return error.SystemResources,
- .NOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket.
- .OPNOTSUPP => unreachable, // Some bit in the flags argument is inappropriate for the socket type.
- .PIPE => return error.BrokenPipe,
- .AFNOSUPPORT => return error.AddressFamilyNotSupported,
- .LOOP => return error.SymLinkLoop,
- .NAMETOOLONG => return error.NameTooLong,
- .NOENT => return error.FileNotFound,
- .NOTDIR => return error.NotDir,
- .HOSTUNREACH => return error.NetworkUnreachable,
- .NETUNREACH => return error.NetworkUnreachable,
- .NOTCONN => return error.SocketNotConnected,
- .NETDOWN => return error.NetworkSubsystemFailed,
- else => |err| return std.os.unexpectedErrno(err),
- }
- }
-};
-
-pub const Allocator = struct {
- pub var allocator: *std.mem.Allocator = undefined;
-
- pub fn initCallback() callconv(.C) c_int {
- return S2N_SUCCESS;
- }
-
- pub fn deinitCallback() callconv(.C) c_int {
- return S2N_SUCCESS;
- }
-
- pub fn mallocCallback(ptr: **c_void, requested: u32, allocated: *u32) callconv(.C) c_int {
- const bytes = allocator.allocAdvanced(u8, null, requested, .at_least) catch return S2N_FAILURE;
- @memset(bytes.ptr, 0, bytes.len);
- allocated.* = @intCast(u32, bytes.len);
- ptr.* = bytes.ptr;
- return S2N_SUCCESS;
- }
-
- pub fn freeCallback(ptr_: ?*c_void, size: u32) callconv(.C) c_int {
- var ptr = ptr_ orelse return S2N_SUCCESS;
- if (size == 0)
- return S2N_SUCCESS;
-
- var slice_ptr = @ptrCast([*]u8, ptr);
- var slice = slice_ptr[0..size];
- allocator.free(slice);
- return S2N_SUCCESS;
- }
-};
diff --git a/src/string_immutable.zig b/src/string_immutable.zig
index cb33e9d59..2f14d7e28 100644
--- a/src/string_immutable.zig
+++ b/src/string_immutable.zig
@@ -91,6 +91,14 @@ pub const StringOrTinyString = struct {
// allocator.free(slice_);
}
+ pub fn initAppendIfNeeded(stringy: string, comptime Appender: type, appendy: Appender) !StringOrTinyString {
+ if (stringy.len <= StringOrTinyString.Max) {
+ return StringOrTinyString.init(stringy);
+ }
+
+ return StringOrTinyString.init(try appendy.append(string, stringy));
+ }
+
pub fn init(stringy: string) StringOrTinyString {
switch (stringy.len) {
0 => {
@@ -102,7 +110,7 @@ pub const StringOrTinyString = struct {
.is_tiny_string = 1,
.remainder_len = @truncate(u7, stringy.len),
};
- std.mem.copy(u8, &tiny.remainder_buf, stringy);
+ @memcpy(&tiny.remainder_buf, stringy.ptr, tiny.remainder_len);
return tiny;
},
else => {
@@ -233,6 +241,7 @@ test "StringOrTinyString Lowercase" {
try std.testing.expectEqualStrings("hello!!!!!", str.slice());
}
+/// startsWith except it checks for non-empty strings
pub fn hasPrefix(self: string, str: string) bool {
return str.len > 0 and startsWith(self, str);
}
@@ -257,6 +266,10 @@ pub inline fn endsWith(self: string, str: string) bool {
return str.len == 0 or @call(.{ .modifier = .always_inline }, std.mem.endsWith, .{ u8, self, str });
}
+pub inline fn endsWithComptime(self: string, comptime str: anytype) bool {
+ return self.len >= str.len and eqlComptimeIgnoreLen(self[self.len - str.len .. self.len], comptime str);
+}
+
pub inline fn startsWithChar(self: string, char: u8) bool {
return self.len > 0 and self[0] == char;
}
@@ -400,6 +413,57 @@ inline fn eqlComptimeCheckLen(a: string, comptime b: anytype, comptime check_len
return true;
}
+pub fn eqlLong(a_: string, b: string, comptime check_len: bool) bool {
+ if (comptime check_len) {
+ if (a_.len == 0) {
+ return b.len == 0;
+ }
+
+ if (a_.len != b.len) {
+ return false;
+ }
+ }
+
+ const len = b.len;
+ var dword_length = b.len >> 3;
+ var b_ptr: usize = 0;
+ const a = a_.ptr;
+
+ while (dword_length > 0) : (dword_length -= 1) {
+ const slice = b.ptr;
+ if (@bitCast(usize, a[b_ptr..len][0..@sizeOf(usize)].*) != @bitCast(usize, (slice[b_ptr..b.len])[0..@sizeOf(usize)].*))
+ return false;
+ b_ptr += @sizeOf(usize);
+ if (b_ptr == b.len) return true;
+ }
+
+ if (comptime @sizeOf(usize) == 8) {
+ if ((len & 4) != 0) {
+ const slice = b.ptr;
+ if (@bitCast(u32, a[b_ptr..len][0..@sizeOf(u32)].*) != @bitCast(u32, (slice[b_ptr..b.len])[0..@sizeOf(u32)].*))
+ return false;
+
+ b_ptr += @sizeOf(u32);
+
+ if (b_ptr == b.len) return true;
+ }
+ }
+
+ if ((len & 2) != 0) {
+ const slice = b.ptr;
+ if (@bitCast(u16, a[b_ptr..len][0..@sizeOf(u16)].*) != @bitCast(u16, b.ptr[b_ptr..len][0..@sizeOf(u16)].*))
+ return false;
+
+ b_ptr += @sizeOf(u16);
+
+ if (b_ptr == b.len) return true;
+ }
+
+ if (((len & 1) != 0) and a[b_ptr] != b[b_ptr]) return false;
+
+ return true;
+}
+
pub inline fn append(allocator: *std.mem.Allocator, self: string, other: string) !string {
return std.fmt.allocPrint(allocator, "{s}{s}", .{ self, other });
}
diff --git a/src/string_mutable.zig b/src/string_mutable.zig
index 5dc153c99..acbecba94 100644
--- a/src/string_mutable.zig
+++ b/src/string_mutable.zig
@@ -9,6 +9,10 @@ pub const MutableString = struct {
allocator: *std.mem.Allocator,
list: std.ArrayListUnmanaged(u8),
+ pub fn init2048(allocator: *std.mem.Allocator) !MutableString {
+ return MutableString.init(allocator, 2048);
+ }
+
pub const Writer = std.io.Writer(*@This(), anyerror, MutableString.writeAll);
pub fn writer(self: *MutableString) Writer {
return Writer{
diff --git a/src/tagged_pointer.zig b/src/tagged_pointer.zig
index ee1af487f..0b75b0f29 100644
--- a/src/tagged_pointer.zig
+++ b/src/tagged_pointer.zig
@@ -4,7 +4,7 @@ usingnamespace @import("./global.zig");
const TagSize = u15;
const AddressableSize = u49;
-const TaggedPointer = packed struct {
+pub const TaggedPointer = packed struct {
_ptr: AddressableSize,
data: TagSize,
diff --git a/src/thread_pool.zig b/src/thread_pool.zig
new file mode 100644
index 000000000..4df199006
--- /dev/null
+++ b/src/thread_pool.zig
@@ -0,0 +1,827 @@
+// Thank you @kprotty.
+// https://github.com/kprotty/zap/blob/blog/src/thread_pool.zig
+
+const std = @import("std");
+const ThreadPool = @This();
+const Futex = @import("./futex.zig");
+const AsyncIO = @import("io");
+
+const assert = std.debug.assert;
+const Atomic = std.atomic.Atomic;
+
+io: ?*AsyncIO = null,
+
+stack_size: u32,
+max_threads: u32,
+sync: Atomic(u32) = Atomic(u32).init(@bitCast(u32, Sync{})),
+idle_event: Event = .{},
+join_event: Event = .{},
+run_queue: Node.Queue = .{},
+threads: Atomic(?*Thread) = Atomic(?*Thread).init(null),
+name: []const u8 = "",
+
+const Sync = packed struct {
+ /// Tracks the number of threads not searching for Tasks
+ idle: u14 = 0,
+ /// Tracks the number of threads spawned
+ spawned: u14 = 0,
+ /// What you see is what you get
+ unused: bool = false,
+ /// Used to not miss notifications while state = waking
+ notified: bool = false,
+ /// The current state of the thread pool
+ state: enum(u2) {
+ /// A notification can be issued to wake up a sleeping as the "waking thread".
+ pending = 0,
+ /// The state was notifiied with a signal. A thread is woken up.
+ /// The first thread to transition to `waking` becomes the "waking thread".
+ signaled,
+ /// There is a "waking thread" among us.
+ /// No other thread should be woken up until the waking thread transitions the state.
+ waking,
+ /// The thread pool was terminated. Start decremented `spawned` so that it can be joined.
+ shutdown,
+ } = .pending,
+};
+
+/// Configuration options for the thread pool.
+/// TODO: add CPU core affinity?
+pub const Config = struct {
+ stack_size: u32 = (std.Thread.SpawnConfig{}).stack_size,
+ max_threads: u32,
+};
+
+/// Statically initialize the thread pool using the configuration.
+pub fn init(config: Config) ThreadPool {
+ return .{
+ .stack_size = std.math.max(1, config.stack_size),
+ .max_threads = std.math.max(1, config.max_threads),
+ };
+}
+
+/// Wait for a thread to call shutdown() on the thread pool and kill the worker threads.
+pub fn deinit(self: *ThreadPool) void {
+ self.join();
+ self.* = undefined;
+}
+
+/// A Task represents the unit of Work / Job / Execution that the ThreadPool schedules.
+/// The user provides a `callback` which is invoked when the *Task can run on a thread.
+pub const Task = struct {
+ node: Node = .{},
+ callback: fn (*Task) void,
+};
+
+/// An unordered collection of Tasks which can be submitted for scheduling as a group.
+pub const Batch = struct {
+ len: usize = 0,
+ head: ?*Task = null,
+ tail: ?*Task = null,
+
+ /// Create a batch from a single task.
+ pub fn from(task: *Task) Batch {
+ return Batch{
+ .len = 1,
+ .head = task,
+ .tail = task,
+ };
+ }
+
+ /// Another batch into this one, taking ownership of its tasks.
+ pub fn push(self: *Batch, batch: Batch) void {
+ if (batch.len == 0) return;
+ if (self.len == 0) {
+ self.* = batch;
+ } else {
+ self.tail.?.node.next = if (batch.head) |h| &h.node else null;
+ self.tail = batch.tail;
+ self.len += batch.len;
+ }
+ }
+};
+
+/// Schedule a batch of tasks to be executed by some thread on the thread pool.
+pub fn schedule(self: *ThreadPool, batch: Batch) void {
+ // Sanity check
+ if (batch.len == 0) {
+ return;
+ }
+
+ // Extract out the Node's from the Tasks
+ var list = Node.List{
+ .head = &batch.head.?.node,
+ .tail = &batch.tail.?.node,
+ };
+
+ // Push the task Nodes to the most approriate queue
+ if (Thread.current) |thread| {
+ thread.run_buffer.push(&list) catch thread.run_queue.push(list);
+ } else {
+ self.run_queue.push(list);
+ }
+
+ // Try to notify a thread
+ const is_waking = false;
+ return self.notify(is_waking);
+}
+
+inline fn notify(self: *ThreadPool, is_waking: bool) void {
+ // Fast path to check the Sync state to avoid calling into notifySlow().
+ // If we're waking, then we need to update the state regardless
+ if (!is_waking) {
+ const sync = @bitCast(Sync, self.sync.load(.Monotonic));
+ if (sync.notified) {
+ return;
+ }
+ }
+
+ return self.notifySlow(is_waking);
+}
+
+noinline fn notifySlow(self: *ThreadPool, is_waking: bool) void {
+ var sync = @bitCast(Sync, self.sync.load(.Monotonic));
+ while (sync.state != .shutdown) {
+ const can_wake = is_waking or (sync.state == .pending);
+ if (is_waking) {
+ assert(sync.state == .waking);
+ }
+
+ var new_sync = sync;
+ new_sync.notified = true;
+ if (can_wake and sync.idle > 0) { // wake up an idle thread
+ new_sync.state = .signaled;
+ } else if (can_wake and sync.spawned < self.max_threads) { // spawn a new thread
+ new_sync.state = .signaled;
+ new_sync.spawned += 1;
+ } else if (is_waking) { // no other thread to pass on "waking" status
+ new_sync.state = .pending;
+ } else if (sync.notified) { // nothing to update
+ return;
+ }
+
+ // Release barrier synchronizes with Acquire in wait()
+ // to ensure pushes to run queues happen before observing a posted notification.
+ sync = @bitCast(Sync, self.sync.tryCompareAndSwap(
+ @bitCast(u32, sync),
+ @bitCast(u32, new_sync),
+ .Release,
+ .Monotonic,
+ ) orelse {
+ // We signaled to notify an idle thread
+ if (can_wake and sync.idle > 0) {
+ return self.idle_event.notify();
+ }
+
+ // We signaled to spawn a new thread
+ if (can_wake and sync.spawned < self.max_threads) {
+ const spawn_config = std.Thread.SpawnConfig{ .stack_size = self.stack_size };
+ const thread = std.Thread.spawn(spawn_config, Thread.run, .{self}) catch return self.unregister(null);
+ // if (self.name.len > 0) thread.setName(self.name) catch {};
+ return thread.detach();
+ }
+
+ return;
+ });
+ }
+}
+
+noinline fn wait(self: *ThreadPool, _is_waking: bool) error{Shutdown}!bool {
+ var is_idle = false;
+ var is_waking = _is_waking;
+ var sync = @bitCast(Sync, self.sync.load(.Monotonic));
+
+ while (true) {
+ if (sync.state == .shutdown) return error.Shutdown;
+ if (is_waking) assert(sync.state == .waking);
+
+ // Consume a notification made by notify().
+ if (sync.notified) {
+ var new_sync = sync;
+ new_sync.notified = false;
+ if (is_idle)
+ new_sync.idle -= 1;
+ if (sync.state == .signaled)
+ new_sync.state = .waking;
+
+ // Acquire barrier synchronizes with notify()
+ // to ensure that pushes to run queue are observed after wait() returns.
+ sync = @bitCast(Sync, self.sync.tryCompareAndSwap(
+ @bitCast(u32, sync),
+ @bitCast(u32, new_sync),
+ .Acquire,
+ .Monotonic,
+ ) orelse {
+ if (self.io) |io| {
+ io.tick() catch {};
+ }
+
+ return is_waking or (sync.state == .signaled);
+ });
+
+ // No notification to consume.
+ // Mark this thread as idle before sleeping on the idle_event.
+ if (self.io) |io| {
+ io.tick() catch {};
+ }
+ } else if (!is_idle) {
+ var new_sync = sync;
+ new_sync.idle += 1;
+ if (is_waking)
+ new_sync.state = .pending;
+
+ sync = @bitCast(Sync, self.sync.tryCompareAndSwap(
+ @bitCast(u32, sync),
+ @bitCast(u32, new_sync),
+ .Monotonic,
+ .Monotonic,
+ ) orelse {
+ is_waking = false;
+ is_idle = true;
+ continue;
+ });
+
+ // Wait for a signal by either notify() or shutdown() without wasting cpu cycles.
+ // TODO: Add I/O polling here.
+ if (self.io) |io| {
+ io.tick() catch {};
+ }
+ } else {
+ if (self.io) |io| {
+ const HTTP = @import("http");
+ io.run_for_ns(std.time.ns_per_us * 100) catch {};
+ while (HTTP.AsyncHTTP.active_requests_count.load(.Monotonic) > 255) {
+ io.tick() catch {};
+ }
+ sync = @bitCast(Sync, self.sync.load(.Monotonic));
+ continue;
+ }
+
+ self.idle_event.wait();
+ sync = @bitCast(Sync, self.sync.load(.Monotonic));
+ }
+ }
+}
+
+/// Marks the thread pool as shutdown
+pub noinline fn shutdown(self: *ThreadPool) void {
+ var sync = @bitCast(Sync, self.sync.load(.Monotonic));
+ while (sync.state != .shutdown) {
+ var new_sync = sync;
+ new_sync.notified = true;
+ new_sync.state = .shutdown;
+ new_sync.idle = 0;
+
+ // Full barrier to synchronize with both wait() and notify()
+ sync = @bitCast(Sync, self.sync.tryCompareAndSwap(
+ @bitCast(u32, sync),
+ @bitCast(u32, new_sync),
+ .AcqRel,
+ .Monotonic,
+ ) orelse {
+ // Wake up any threads sleeping on the idle_event.
+ // TODO: I/O polling notification here.
+ if (sync.idle > 0) self.idle_event.shutdown();
+ return;
+ });
+ }
+}
+
+fn register(noalias self: *ThreadPool, noalias thread: *Thread) void {
+ // Push the thread onto the threads stack in a lock-free manner.
+ var threads = self.threads.load(.Monotonic);
+ while (true) {
+ thread.next = threads;
+ threads = self.threads.tryCompareAndSwap(
+ threads,
+ thread,
+ .Release,
+ .Monotonic,
+ ) orelse break;
+ }
+}
+
+fn unregister(noalias self: *ThreadPool, noalias maybe_thread: ?*Thread) void {
+ // Un-spawn one thread, either due to a failed OS thread spawning or the thread is exitting.
+ const one_spawned = @bitCast(u32, Sync{ .spawned = 1 });
+ const sync = @bitCast(Sync, self.sync.fetchSub(one_spawned, .Release));
+ assert(sync.spawned > 0);
+
+ // The last thread to exit must wake up the thread pool join()er
+ // who will start the chain to shutdown all the threads.
+ if (sync.state == .shutdown and sync.spawned == 1) {
+ self.join_event.notify();
+ }
+
+ // If this is a thread pool thread, wait for a shutdown signal by the thread pool join()er.
+ const thread = maybe_thread orelse return;
+ thread.join_event.wait();
+
+ // After receiving the shutdown signal, shutdown the next thread in the pool.
+ // We have to do that without touching the thread pool itself since it's memory is invalidated by now.
+ // So just follow our .next link.
+ const next_thread = thread.next orelse return;
+ next_thread.join_event.notify();
+}
+
+fn join(self: *ThreadPool) void {
+ // Wait for the thread pool to be shutdown() then for all threads to enter a joinable state
+ var sync = @bitCast(Sync, self.sync.load(.Monotonic));
+ if (!(sync.state == .shutdown and sync.spawned == 0)) {
+ self.join_event.wait();
+ sync = @bitCast(Sync, self.sync.load(.Monotonic));
+ }
+
+ assert(sync.state == .shutdown);
+ assert(sync.spawned == 0);
+
+ // If there are threads, start off the chain sending it the shutdown signal.
+ // The thread receives the shutdown signal and sends it to the next thread, and the next..
+ const thread = self.threads.load(.Acquire) orelse return;
+ thread.join_event.notify();
+}
+
+const Output = @import("./global.zig").Output;
+
+const Thread = struct {
+ next: ?*Thread = null,
+ target: ?*Thread = null,
+ join_event: Event = .{},
+ run_queue: Node.Queue = .{},
+ run_buffer: Node.Buffer = .{},
+
+ threadlocal var current: ?*Thread = null;
+
+ /// Thread entry point which runs a worker for the ThreadPool
+ fn run(thread_pool: *ThreadPool) void {
+ Output.Source.configureThread();
+
+ var self = Thread{};
+ current = &self;
+
+ thread_pool.register(&self);
+ defer thread_pool.unregister(&self);
+
+ var is_waking = false;
+ while (true) {
+ is_waking = thread_pool.wait(is_waking) catch return;
+
+ while (self.pop(thread_pool)) |result| {
+ if (result.pushed or is_waking)
+ thread_pool.notify(is_waking);
+ is_waking = false;
+
+ const task = @fieldParentPtr(Task, "node", result.node);
+ (task.callback)(task);
+ }
+ Output.flush();
+ }
+ }
+
+ /// Try to dequeue a Node/Task from the ThreadPool.
+ /// Spurious reports of dequeue() returning empty are allowed.
+ fn pop(noalias self: *Thread, noalias thread_pool: *ThreadPool) ?Node.Buffer.Stole {
+ // Check our local buffer first
+ if (self.run_buffer.pop()) |node| {
+ return Node.Buffer.Stole{
+ .node = node,
+ .pushed = false,
+ };
+ }
+
+ // Then check our local queue
+ if (self.run_buffer.consume(&self.run_queue)) |stole| {
+ return stole;
+ }
+
+ // Then the global queue
+ if (self.run_buffer.consume(&thread_pool.run_queue)) |stole| {
+ return stole;
+ }
+
+ // TODO: add optimistic I/O polling here
+ if (thread_pool.io) |io| {
+ io.tick() catch {};
+ }
+
+ // Then try work stealing from other threads
+ var num_threads: u32 = @bitCast(Sync, thread_pool.sync.load(.Monotonic)).spawned;
+ while (num_threads > 0) : (num_threads -= 1) {
+ // Traverse the stack of registered threads on the thread pool
+ const target = self.target orelse thread_pool.threads.load(.Acquire) orelse unreachable;
+ self.target = target.next;
+
+ // Try to steal from their queue first to avoid contention (the target steal's from queue last).
+ if (self.run_buffer.consume(&target.run_queue)) |stole| {
+ return stole;
+ }
+
+ // Skip stealing from the buffer if we're the target.
+ // We still steal from our own queue above given it may have just been locked the first time we tried.
+ if (target == self) {
+ continue;
+ }
+
+ // Steal from the buffer of a remote thread as a last resort
+ if (self.run_buffer.steal(&target.run_buffer)) |stole| {
+ return stole;
+ }
+ }
+
+ return null;
+ }
+};
+
+/// An event which stores 1 semaphore token and is multi-threaded safe.
+/// The event can be shutdown(), waking up all wait()ing threads and
+/// making subsequent wait()'s return immediately.
+const Event = struct {
+ state: Atomic(u32) = Atomic(u32).init(EMPTY),
+
+ const EMPTY = 0;
+ const WAITING = 1;
+ const NOTIFIED = 2;
+ const SHUTDOWN = 3;
+
+ /// Wait for and consume a notification
+ /// or wait for the event to be shutdown entirely
+ noinline fn wait(self: *Event) void {
+ var acquire_with: u32 = EMPTY;
+ var state = self.state.load(.Monotonic);
+
+ while (true) {
+ // If we're shutdown then exit early.
+ // Acquire barrier to ensure operations before the shutdown() are seen after the wait().
+ // Shutdown is rare so it's better to have an Acquire barrier here instead of on CAS failure + load which are common.
+ if (state == SHUTDOWN) {
+ std.atomic.fence(.Acquire);
+ return;
+ }
+
+ // Consume a notification when it pops up.
+ // Acquire barrier to ensure operations before the notify() appear after the wait().
+ if (state == NOTIFIED) {
+ state = self.state.tryCompareAndSwap(
+ state,
+ acquire_with,
+ .Acquire,
+ .Monotonic,
+ ) orelse return;
+ continue;
+ }
+
+ // There is no notification to consume, we should wait on the event by ensuring its WAITING.
+ if (state != WAITING) blk: {
+ state = self.state.tryCompareAndSwap(
+ state,
+ WAITING,
+ .Monotonic,
+ .Monotonic,
+ ) orelse break :blk;
+ continue;
+ }
+
+ // Wait on the event until a notify() or shutdown().
+ // If we wake up to a notification, we must acquire it with WAITING instead of EMPTY
+ // since there may be other threads sleeping on the Futex who haven't been woken up yet.
+ //
+ // Acquiring to WAITING will make the next notify() or shutdown() wake a sleeping futex thread
+ // who will either exit on SHUTDOWN or acquire with WAITING again, ensuring all threads are awoken.
+ // This unfortunately results in the last notify() or shutdown() doing an extra futex wake but that's fine.
+ Futex.wait(&self.state, WAITING, null) catch unreachable;
+ state = self.state.load(.Monotonic);
+ acquire_with = WAITING;
+ }
+ }
+
+ /// Post a notification to the event if it doesn't have one already
+ /// then wake up a waiting thread if there is one as well.
+ fn notify(self: *Event) void {
+ return self.wake(NOTIFIED, 1);
+ }
+
+ /// Marks the event as shutdown, making all future wait()'s return immediately.
+ /// Then wakes up any threads currently waiting on the Event.
+ fn shutdown(self: *Event) void {
+ return self.wake(SHUTDOWN, std.math.maxInt(u32));
+ }
+
+ fn wake(self: *Event, release_with: u32, wake_threads: u32) void {
+ // Update the Event to notifty it with the new `release_with` state (either NOTIFIED or SHUTDOWN).
+ // Release barrier to ensure any operations before this are this to happen before the wait() in the other threads.
+ const state = self.state.swap(release_with, .Release);
+
+ // Only wake threads sleeping in futex if the state is WAITING.
+ // Avoids unnecessary wake ups.
+ if (state == WAITING) {
+ Futex.wake(&self.state, wake_threads);
+ }
+ }
+};
+
+/// Linked list intrusive memory node and lock-free data structures to operate with it
+const Node = struct {
+ next: ?*Node = null,
+
+ /// A linked list of Nodes
+ const List = struct {
+ head: *Node,
+ tail: *Node,
+ };
+
+ /// An unbounded multi-producer-(non blocking)-multi-consumer queue of Node pointers.
+ const Queue = struct {
+ stack: Atomic(usize) = Atomic(usize).init(0),
+ cache: ?*Node = null,
+
+ const HAS_CACHE: usize = 0b01;
+ const IS_CONSUMING: usize = 0b10;
+ const PTR_MASK: usize = ~(HAS_CACHE | IS_CONSUMING);
+
+ comptime {
+ assert(@alignOf(Node) >= ((IS_CONSUMING | HAS_CACHE) + 1));
+ }
+
+ fn push(noalias self: *Queue, list: List) void {
+ var stack = self.stack.load(.Monotonic);
+ while (true) {
+ // Attach the list to the stack (pt. 1)
+ list.tail.next = @intToPtr(?*Node, stack & PTR_MASK);
+
+ // Update the stack with the list (pt. 2).
+ // Don't change the HAS_CACHE and IS_CONSUMING bits of the consumer.
+ var new_stack = @ptrToInt(list.head);
+ assert(new_stack & ~PTR_MASK == 0);
+ new_stack |= (stack & ~PTR_MASK);
+
+ // Push to the stack with a release barrier for the consumer to see the proper list links.
+ stack = self.stack.tryCompareAndSwap(
+ stack,
+ new_stack,
+ .Release,
+ .Monotonic,
+ ) orelse break;
+ }
+ }
+
+ fn tryAcquireConsumer(self: *Queue) error{ Empty, Contended }!?*Node {
+ var stack = self.stack.load(.Monotonic);
+ while (true) {
+ if (stack & IS_CONSUMING != 0)
+ return error.Contended; // The queue already has a consumer.
+ if (stack & (HAS_CACHE | PTR_MASK) == 0)
+ return error.Empty; // The queue is empty when there's nothing cached and nothing in the stack.
+
+ // When we acquire the consumer, also consume the pushed stack if the cache is empty.
+ var new_stack = stack | HAS_CACHE | IS_CONSUMING;
+ if (stack & HAS_CACHE == 0) {
+ assert(stack & PTR_MASK != 0);
+ new_stack &= ~PTR_MASK;
+ }
+
+ // Acquire barrier on getting the consumer to see cache/Node updates done by previous consumers
+ // and to ensure our cache/Node updates in pop() happen after that of previous consumers.
+ stack = self.stack.tryCompareAndSwap(
+ stack,
+ new_stack,
+ .Acquire,
+ .Monotonic,
+ ) orelse return self.cache orelse @intToPtr(*Node, stack & PTR_MASK);
+ }
+ }
+
+ fn releaseConsumer(noalias self: *Queue, noalias consumer: ?*Node) void {
+ // Stop consuming and remove the HAS_CACHE bit as well if the consumer's cache is empty.
+ // When HAS_CACHE bit is zeroed, the next consumer will acquire the pushed stack nodes.
+ var remove = IS_CONSUMING;
+ if (consumer == null)
+ remove |= HAS_CACHE;
+
+ // Release the consumer with a release barrier to ensure cache/node accesses
+ // happen before the consumer was released and before the next consumer starts using the cache.
+ self.cache = consumer;
+ const stack = self.stack.fetchSub(remove, .Release);
+ assert(stack & remove != 0);
+ }
+
+ fn pop(noalias self: *Queue, noalias consumer_ref: *?*Node) ?*Node {
+ // Check the consumer cache (fast path)
+ if (consumer_ref.*) |node| {
+ consumer_ref.* = node.next;
+ return node;
+ }
+
+ // Load the stack to see if there was anything pushed that we could grab.
+ var stack = self.stack.load(.Monotonic);
+ assert(stack & IS_CONSUMING != 0);
+ if (stack & PTR_MASK == 0) {
+ return null;
+ }
+
+ // Nodes have been pushed to the stack, grab then with an Acquire barrier to see the Node links.
+ stack = self.stack.swap(HAS_CACHE | IS_CONSUMING, .Acquire);
+ assert(stack & IS_CONSUMING != 0);
+ assert(stack & PTR_MASK != 0);
+
+ const node = @intToPtr(*Node, stack & PTR_MASK);
+ consumer_ref.* = node.next;
+ return node;
+ }
+ };
+
+ /// A bounded single-producer, multi-consumer ring buffer for node pointers.
+ const Buffer = struct {
+ head: Atomic(Index) = Atomic(Index).init(0),
+ tail: Atomic(Index) = Atomic(Index).init(0),
+ array: [capacity]Atomic(*Node) = undefined,
+
+ const Index = u32;
+ const capacity = 256; // Appears to be a pretty good trade-off in space vs contended throughput
+ comptime {
+ assert(std.math.maxInt(Index) >= capacity);
+ assert(std.math.isPowerOfTwo(capacity));
+ }
+
+ fn push(noalias self: *Buffer, noalias list: *List) error{Overflow}!void {
+ var head = self.head.load(.Monotonic);
+ var tail = self.tail.loadUnchecked(); // we're the only thread that can change this
+
+ while (true) {
+ var size = tail -% head;
+ assert(size <= capacity);
+
+ // Push nodes from the list to the buffer if it's not empty..
+ if (size < capacity) {
+ var nodes: ?*Node = list.head;
+ while (size < capacity) : (size += 1) {
+ const node = nodes orelse break;
+ nodes = node.next;
+
+ // Array written atomically with weakest ordering since it could be getting atomically read by steal().
+ self.array[tail % capacity].store(node, .Unordered);
+ tail +%= 1;
+ }
+
+ // Release barrier synchronizes with Acquire loads for steal()ers to see the array writes.
+ self.tail.store(tail, .Release);
+
+ // Update the list with the nodes we pushed to the buffer and try again if there's more.
+ list.head = nodes orelse return;
+ std.atomic.spinLoopHint();
+ head = self.head.load(.Monotonic);
+ continue;
+ }
+
+ // Try to steal/overflow half of the tasks in the buffer to make room for future push()es.
+ // Migrating half amortizes the cost of stealing while requiring future pops to still use the buffer.
+ // Acquire barrier to ensure the linked list creation after the steal only happens after we succesfully steal.
+ var migrate = size / 2;
+ head = self.head.tryCompareAndSwap(
+ head,
+ head +% migrate,
+ .Acquire,
+ .Monotonic,
+ ) orelse {
+ // Link the migrated Nodes together
+ const first = self.array[head % capacity].loadUnchecked();
+ while (migrate > 0) : (migrate -= 1) {
+ const prev = self.array[head % capacity].loadUnchecked();
+ head +%= 1;
+ prev.next = self.array[head % capacity].loadUnchecked();
+ }
+
+ // Append the list that was supposed to be pushed to the end of the migrated Nodes
+ const last = self.array[(head -% 1) % capacity].loadUnchecked();
+ last.next = list.head;
+ list.tail.next = null;
+
+ // Return the migrated nodes + the original list as overflowed
+ list.head = first;
+ return error.Overflow;
+ };
+ }
+ }
+
+ fn pop(self: *Buffer) ?*Node {
+ var head = self.head.load(.Monotonic);
+ var tail = self.tail.loadUnchecked(); // we're the only thread that can change this
+
+ while (true) {
+ // Quick sanity check and return null when not empty
+ var size = tail -% head;
+ assert(size <= capacity);
+ if (size == 0) {
+ return null;
+ }
+
+ // Dequeue with an acquire barrier to ensure any writes done to the Node
+ // only happen after we succesfully claim it from the array.
+ head = self.head.tryCompareAndSwap(
+ head,
+ head +% 1,
+ .Acquire,
+ .Monotonic,
+ ) orelse return self.array[head % capacity].loadUnchecked();
+ }
+ }
+
+ const Stole = struct {
+ node: *Node,
+ pushed: bool,
+ };
+
+ fn consume(noalias self: *Buffer, noalias queue: *Queue) ?Stole {
+ var consumer = queue.tryAcquireConsumer() catch return null;
+ defer queue.releaseConsumer(consumer);
+
+ const head = self.head.load(.Monotonic);
+ const tail = self.tail.loadUnchecked(); // we're the only thread that can change this
+
+ const size = tail -% head;
+ assert(size <= capacity);
+ assert(size == 0); // we should only be consuming if our array is empty
+
+ // Pop nodes from the queue and push them to our array.
+ // Atomic stores to the array as steal() threads may be atomically reading from it.
+ var pushed: Index = 0;
+ while (pushed < capacity) : (pushed += 1) {
+ const node = queue.pop(&consumer) orelse break;
+ self.array[(tail +% pushed) % capacity].store(node, .Unordered);
+ }
+
+ // We will be returning one node that we stole from the queue.
+ // Get an extra, and if that's not possible, take one from our array.
+ const node = queue.pop(&consumer) orelse blk: {
+ if (pushed == 0) return null;
+ pushed -= 1;
+ break :blk self.array[(tail +% pushed) % capacity].loadUnchecked();
+ };
+
+ // Update the array tail with the nodes we pushed to it.
+ // Release barrier to synchronize with Acquire barrier in steal()'s to see the written array Nodes.
+ if (pushed > 0) self.tail.store(tail +% pushed, .Release);
+ return Stole{
+ .node = node,
+ .pushed = pushed > 0,
+ };
+ }
+
+ fn steal(noalias self: *Buffer, noalias buffer: *Buffer) ?Stole {
+ const head = self.head.load(.Monotonic);
+ const tail = self.tail.loadUnchecked(); // we're the only thread that can change this
+
+ const size = tail -% head;
+ assert(size <= capacity);
+ assert(size == 0); // we should only be stealing if our array is empty
+
+ while (true) : (std.atomic.spinLoopHint()) {
+ const buffer_head = buffer.head.load(.Acquire);
+ const buffer_tail = buffer.tail.load(.Acquire);
+
+ // Overly large size indicates the the tail was updated a lot after the head was loaded.
+ // Reload both and try again.
+ const buffer_size = buffer_tail -% buffer_head;
+ if (buffer_size > capacity) {
+ continue;
+ }
+
+ // Try to steal half (divCeil) to amortize the cost of stealing from other threads.
+ const steal_size = buffer_size - (buffer_size / 2);
+ if (steal_size == 0) {
+ return null;
+ }
+
+ // Copy the nodes we will steal from the target's array to our own.
+ // Atomically load from the target buffer array as it may be pushing and atomically storing to it.
+ // Atomic store to our array as other steal() threads may be atomically loading from it as above.
+ var i: Index = 0;
+ while (i < steal_size) : (i += 1) {
+ const node = buffer.array[(buffer_head +% i) % capacity].load(.Unordered);
+ self.array[(tail +% i) % capacity].store(node, .Unordered);
+ }
+
+ // Try to commit the steal from the target buffer using:
+ // - an Acquire barrier to ensure that we only interact with the stolen Nodes after the steal was committed.
+ // - a Release barrier to ensure that the Nodes are copied above prior to the committing of the steal
+ // because if they're copied after the steal, the could be getting rewritten by the target's push().
+ _ = buffer.head.compareAndSwap(
+ buffer_head,
+ buffer_head +% steal_size,
+ .AcqRel,
+ .Monotonic,
+ ) orelse {
+ // Pop one from the nodes we stole as we'll be returning it
+ const pushed = steal_size - 1;
+ const node = self.array[(tail +% pushed) % capacity].loadUnchecked();
+
+ // Update the array tail with the nodes we pushed to it.
+ // Release barrier to synchronize with Acquire barrier in steal()'s to see the written array Nodes.
+ if (pushed > 0) self.tail.store(tail +% pushed, .Release);
+ return Stole{
+ .node = node,
+ .pushed = pushed > 0,
+ };
+ };
+ }
+ }
+ };
+};
diff --git a/src/which_npm_client.zig b/src/which_npm_client.zig
index 56dd752c1..aa90622ca 100644
--- a/src/which_npm_client.zig
+++ b/src/which_npm_client.zig
@@ -1,6 +1,5 @@
usingnamespace @import("./global.zig");
-const which = @import("./which.zig").which;
const std = @import("std");
pub const NPMClient = struct {
@@ -8,96 +7,10 @@ pub const NPMClient = struct {
tag: Tag,
pub const Tag = enum {
- npm,
- yarn,
- pnpm,
+ bun,
};
- // This check adds around 150ms
- // so...if we do do this, we should do it in a separate thread
- pub fn isYarnBerry(allocator: *std.mem.Allocator, cwd_dir: string, yarn_path: string) bool {
- var args = [_]string{ yarn_path, "--version" };
- var term = std.ChildProcess.exec(.{
- .argv = &args,
- .allocator = allocator,
- .cwd = if (cwd_dir.len > 1) std.mem.trimRight(u8, cwd_dir, "/") else cwd_dir,
- }) catch return true;
- defer allocator.free(term.stderr);
- defer allocator.free(term.stdout);
-
- if (term.stdout.len == 0) return true;
- return term.stdout[0] != '1';
- }
-
- pub fn detect(allocator: *std.mem.Allocator, realpath_buf: *[std.fs.MAX_PATH_BYTES]u8, PATH: string, cwd: string, comptime allow_yarn: bool) !?NPMClient {
-
- // We say:
- // - pnpm if it exists, is the default. its most esoteric, so if you have it installed, you prob want it.
- // - yarn if it exists and it is yarn 1, its the default (yarn 2 or later is not supported)
- // - else npm
-
- const out_path = brk: {
- var path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
-
- const path: [:0]const u8 = if (comptime allow_yarn)
- which(
- &path_buf,
- PATH,
- cwd,
- "pnpm",
- ) orelse which(
- &path_buf,
- PATH,
- cwd,
- "yarn",
- ) orelse which(
- &path_buf,
- PATH,
- cwd,
- "npm",
- ) orelse ""
- else
- which(
- &path_buf,
- PATH,
- cwd,
- "pnpm",
- ) orelse which(
- &path_buf,
- PATH,
- cwd,
- "npm",
- ) orelse "";
-
- std.mem.copy(u8, realpath_buf, std.mem.span(path));
- // It's important we don't resolve the symlink
- // That breaks volta.
- break :brk realpath_buf[0..path.len];
- };
-
- const basename = std.fs.path.basename(std.mem.span(out_path));
- if (basename.len == 0) return null;
-
- // if (comptime allow_yarn) {
- // if (std.mem.indexOf(u8, basename, "yarn") != null) {
- // if (isYarnBerry(allocator, cwd, out_path)) {
- // return try detect(allocator, realpath_buf, PATH, cwd, false);
- // }
- // }
- // }
-
- if (strings.contains(basename, "pnpm")) {
- return NPMClient{ .bin = out_path, .tag = .pnpm };
- }
-
- if (strings.contains(basename, "yarn")) {
- return NPMClient{ .bin = out_path, .tag = .yarn };
- }
-
- if (strings.contains(basename, "npm")) {
- return NPMClient{ .bin = out_path, .tag = .npm };
- }
-
- return null;
+ pub fn detect(allocator: *std.mem.Allocator, realpath_buf: *[std.fs.MAX_PATH_BYTES]u8, PATH: string, cwd: string, comptime allow_yarn: bool) !NPMClient {
+
}
};
diff --git a/src/zlib.zig b/src/zlib.zig
index a8b219b50..67979972b 100644
--- a/src/zlib.zig
+++ b/src/zlib.zig
@@ -398,8 +398,16 @@ pub fn NewZlibReader(comptime Writer: type, comptime buffer_size: usize) type {
};
}
+pub const ZlibError = error{
+ OutOfMemory,
+ InvalidArgument,
+ ZlibError,
+ ShortRead,
+};
+
pub const ZlibReaderArrayList = struct {
const ZlibReader = ZlibReaderArrayList;
+
pub const State = enum {
Uninitialized,
Inflating,
@@ -438,7 +446,7 @@ pub const ZlibReaderArrayList = struct {
}
}
- pub fn init(input: []const u8, list: *std.ArrayListUnmanaged(u8), allocator: *std.mem.Allocator) !*ZlibReader {
+ pub fn init(input: []const u8, list: *std.ArrayListUnmanaged(u8), allocator: *std.mem.Allocator) ZlibError!*ZlibReader {
var zlib_reader = try allocator.create(ZlibReader);
zlib_reader.* = ZlibReader{
.input = input,
@@ -496,7 +504,7 @@ pub const ZlibReaderArrayList = struct {
return null;
}
- pub fn readAll(this: *ZlibReader) !void {
+ pub fn readAll(this: *ZlibReader) ZlibError!void {
defer {
this.list.shrinkRetainingCapacity(this.zlib.total_out);
this.list_ptr.* = this.list;