This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Function
pubfnverifyHostName(parsed_subject: Parsed, host_name: []constu8) VerifyHostNameError!void {
// If the Subject Alternative Names extension is present, this is// what to check. Otherwise, only the common name is checked.constsubject_alt_name = parsed_subject.subjectAltName();
if (subject_alt_name.len == 0) {
// note: checkIpAddress is intentionally omitted, as it is not permitted in the common name field anyway.if (checkHostName(host_name, parsed_subject.commonName())) {
return;
} else {
returnerror.CertificateHostMismatch;
}
}
constgeneral_names = tryder.Element.parse(subject_alt_name, 0);
varname_i = general_names.slice.start;
while (name_i < general_names.slice.end) {
constgeneral_name = tryder.Element.parse(subject_alt_name, name_i);
name_i = general_name.slice.end;
switch (@as(GeneralNameTag, @fromBackingInt(@intCast(@backingInt(general_name.identifier.tag))))) {
.dNSName => {
constdns_name = subject_alt_name[general_name.slice.start..general_name.slice.end];
if (checkHostName(host_name, dns_name)) return;
},
.iPAddress => {
constip_address = subject_alt_name[general_name.slice.start..general_name.slice.end];
if (checkIpAddress(host_name, ip_address)) return;
},
else => {},
}
}
returnerror.CertificateHostMismatch;
}