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 › Io › net › HostName › ResolvConf › init Public Function init Doc Source Public Function std.Io.net.HostName.ResolvConf.init
pub fn init (io : Io ) !ResolvConf Params File Io/net/HostName.zig: 421
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452 pub fn init (io : Io ) !ResolvConf {
var rc : ResolvConf = .{
.nameservers_buffer = undefined ,
.nameservers_len = 0 ,
.search_buffer = undefined ,
.search_len = 0 ,
.ndots = 1 ,
.timeout_seconds = 5 ,
.attempts = 2 ,
};
const file = Io .Dir .openFileAbsolute (io , "/etc/resolv.conf" , .{}) catch |err | switch (err ) {
error .FileNotFound ,
error .NotDir ,
error .AccessDenied ,
=> {
try addNumeric (&rc , io , "127.0.0.1" , 53 );
return rc ;
},
else => |e | return e ,
};
defer file .close (io );
var line_buf : [512 ]u8 = undefined ;
var file_reader = file .reader (io , &line_buf );
parse (&rc , io , &file_reader .interface ) catch |err | switch (err ) {
error .ReadFailed => return file_reader .err .?,
else => |e | return e ,
};
return rc ;
}
Returns
error.StreamTooLongif a line is longer than 512 bytes.