Zig 0.17.0-dev (Split by item) 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.
std › crypto › Certificate › Bundle › macos › scanReader Private Function scanReader Doc Source Private Function std.crypto.Certificate.Bundle.macos.scanReader
fn scanReader (cb : *Bundle , gpa : Allocator , reader : *Io .Reader , now_sec : i64 ) !void Params File crypto/Certificate/Bundle/macos.zig: 37
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88 fn scanReader (cb : *Bundle , gpa : Allocator , reader : *Io .Reader , now_sec : i64 ) !void {
const db_header = try reader .takeStruct (ApplDbHeader , .big );
assert (mem .eql (u8 , &db_header .signature , "kych" ));
reader .seek = db_header .schema_offset ;
const db_schema = try reader .takeStruct (ApplDbSchema , .big );
var table_list = try gpa .alloc (u32 , db_schema .table_count );
defer gpa .free (table_list );
var table_idx : u32 = 0 ;
while (table_idx < table_list .len ) : (table_idx += 1 ) {
table_list [table_idx ] = try reader .takeInt (u32 , .big );
}
for (table_list ) |table_offset | {
reader .seek = db_header .schema_offset + table_offset ;
const table_header = try reader .takeStruct (TableHeader , .big );
if (@as (std .c .DB_RECORDTYPE , @fromBackingInt (@intCast (table_header .table_id ))) != .X509_CERTIFICATE ) {
continue ;
}
var record_list = try gpa .alloc (u32 , table_header .record_count );
defer gpa .free (record_list );
var record_idx : u32 = 0 ;
while (record_idx < record_list .len ) : (record_idx += 1 ) {
record_list [record_idx ] = try reader .takeInt (u32 , .big );
}
for (record_list ) |record_offset | {
// An offset of zero means that the record is not present.
// An offset that is not 4-byte-aligned is invalid.
if (record_offset == 0 or record_offset % 4 != 0 ) continue ;
reader .seek = db_header .schema_offset + table_offset + record_offset ;
const cert_header = try reader .takeStruct (X509CertHeader , .big );
if (cert_header .cert_size == 0 ) continue ;
const cert_start : u32 = @intCast (cb .bytes .items .len );
const dest_buf = try cb .bytes .addManyAsSlice (gpa , cert_header .cert_size );
try reader .readSliceAll (dest_buf );
try cb .parseCert (gpa , cert_start , now_sec );
}
}
}