code wiki / (root) / ico_header.nx

ico_header.nx

buildroot/runtime/ico_header.nx

5011 B160 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic ico
docsdependenciesstructsconstsfunctions

about

ico_header.nx -- parse Windows ICO / CUR icon container headers. ICO is a container for multiple icon images of different sizes + color depths. Every browser needs ICO parsing for favicon.ico. Every Windows app ships one. Nishi sites need to emit and detect their own. Format: ICONDIR (6 bytes, fixed) 0 2 reserved (0) 2 2 image_type (1 = ICO, 2 = CUR cursor) 4 2 num_images then num_images × ICONDIRENTRY (16 bytes): 0 1 width (0 means 256) 1 1 height (0 means 256) 2 1 color_count (0 if >= 256 colors) 3 1 reserved (0) 4 2 planes (ICO) / hotspot_x (CUR) 6 2 bpp (ICO) / hotspot_y (CUR) 8 4 data_size 12 4 data_offset Image payloads are then either: - BMP without the BITMAPFILEHEADER (just DIB + pixel data), OR - complete PNG (detect via PNG signature) Invariants: I1 image_type must be 1 (ICO) or 2 (CUR). I2 num_images >= 1. I3 Zero-alloc: entries[] passes in by caller; we fill offsets.

dependencies 1 imports · 0 importers

syscalls.nx ico_header.nx

imports: syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main ico_parse ico_read_u16 ico_read_u32

structs

42struct IcoEntry {

consts

36const ICO_ERR_FORMAT: i64 = -1
37const ICO_ERR_SHORT: i64 = -2
39const ICO_TYPE_ICON: i64 = 1
40const ICO_TYPE_CURSOR: i64 = 2

functions

52func ico_read_u16(buf: *u8, off: i64) -> i64 {
called by 1: ico_parse
56func ico_read_u32(buf: *u8, off: i64) -> i64 {
called by 1: ico_parse
66func ico_parse(buf: *u8, n: i64,
called by 1: main calls 2: ico_read_u16ico_read_u32
111func ico_is_png_payload(buf: *u8, n: i64, off: i64) -> i64 {
119func main() -> i64 {
calls 1: ico_parse