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 › elf › Header › read Public Function read Doc Source Public Function std.elf.Header.read
pub fn read (r : *Io .Reader ) ReadError !Header Params File elf.zig: 756
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773 pub fn read (r : *Io .Reader ) ReadError !Header {
const buf = try r .peek (@sizeOf (Elf64_Ehdr ));
if (!mem .eql (u8 , buf [0 ..4 ], MAGIC )) return error .InvalidElfMagic ;
if (buf [EI .VERSION ] != 1 ) return error .InvalidElfVersion ;
const endian : Endian = switch (buf [EI .DATA ]) {
ELFDATA2LSB => .little ,
ELFDATA2MSB => .big ,
else => return error .InvalidElfEndian ,
};
return switch (buf [EI .CLASS ]) {
ELFCLASS32 => .init (try r .takeStruct (Elf32_Ehdr , endian ), endian ),
ELFCLASS64 => .init (try r .takeStruct (Elf64_Ehdr , endian ), endian ),
else => return error .InvalidElfClass ,
};
}
If this function fails, seek position of
ris unchanged.