# Headers

Everything you `#include` lives under `libc/include/`.

## Standard C

| Header | Source | Provides |
|---|---|---|
| `<stdio.h>` | our libc + SDCC | `printf`, `puts`, `putchar`, `getchar`, `sprintf`, `FILE *`, `fopen`/`fread`/.../`fclose`, plus `hex8/16/32`, `dec8/16/32`, `gets` |
| `<stdlib.h>` | SDCC z80.lib | `malloc`, `free`, `calloc`, `realloc`, `atoi`, `atof`, `atol`, `strtol`, `qsort`, `bsearch`, `rand`, `srand`, `abs`, `div`, `exit`, ... |
| `<string.h>` | SDCC z80.lib | `memcpy`, `memcmp`, `memset`, `memchr`, `memmove`, full `strXxx` family |
| `<ctype.h>` | SDCC z80.lib | `tolower`, `toupper`, `isalnum`, `isdigit`, ... |
| `<math.h>` | SDCC z80.lib | `sinf`, `cosf`, `sqrtf`, ... |
| `<errno.h>` | our libc | `errno` + error constants + `strerror` |
| `<setjmp.h>` | our libc | `setjmp` / `longjmp` |
| `<assert.h>` | SDCC | `assert` macro |
| `<unistd.h>` | our libc | `read`, `write`, `close`, `lseek`, `unlink`, `SEEK_SET`/`CUR`/`END` |
| `<fcntl.h>` | our libc | `open`, `creat`, `O_RDONLY`/`O_WRONLY`/`O_CREAT`/etc. |
| `<sys/stat.h>` | our libc | `stat`, `fstat`, `struct stat` |
| `<time.h>` | our libc | `getdatetime`, `setdatetime` + POSIX `time`/`localtime`/`gmtime`/`mktime`/`asctime`/`ctime` |

## Sprinter-specific

| Header | Provides |
|---|---|
| `<conio.h>` | `putch`, `cputs`, `cprintf`, `kbhit`, `getch`, `getche`, `clrscr`, `gotoxy`, `wherex/y`, `wrchar`, `rdchar`, `textcolor`, `textbackground`, `textattr`, `get_videomode`, `set_videomode`, `COLOR_*` enum, `KEEP_EXIST_ATTR` |
| `<gfx.h>`   | Graphics for 320×256×256 and 640×256×16: `gfx_init`/`gfx_done`, `gfx_pal_load`/`gfx_pal_set`, `gfx_clear`, `gfx_putpixel`, `gfx_hline`/`gfx_vline`, `gfx_rect`/`gfx_fill_rect`, `gfx_line`, `gfx_text`/`gfx_putchar`, plus all `*16` variants for 16-color mode, font management via `gfx_load_default_font`/`gfx_set_font` |
| `<mouse.h>` | Full 14-function driver wrapper: `mouse_init`/`mouse_show`/`mouse_hide`/`mouse_read`/`mouse_goto`/`mouse_bounds_*`/`mouse_text_cursor`/`mouse_load_cursor`/`mouse_get_cursor`/`mouse_set_sensitivity`/`mouse_get_sensitivity_*`/`mouse_video_mode_changed`/`mouse_refresh`, plus `mouse_cursor_t` and `mouse_state_t` structs |
| `<dir.h>`   | `chdir`, `getcwd`, `mkdir`, `rmdir`, `ffirst`, `fnext`, `ffblk` struct |
| `<sprinter.h>`       | Raw port numbers, ESTEX/BIOS function-number constants, `__sfr` intrinsics for paging, `print_hex`, `getenv`, `putenv` |
| `<sprinter_exit.h>`  | `exit`, `_exit`, `atexit` |
| `<sprinter_mem.h>`   | `mem_alloc_pages`, `mem_free_block`, `mem_get_page`, `mem_info`, `bank_read`, `bank_write`, `bank_load_byte`, `bank_store_byte` |
| `<sprinter_compat.h>` | Solid-C compatibility shims — pulls in standard headers and adds `BOOL`/`uint`/`WORD`/`f_point` types, `setmem`/`movmem` aliases, `inp`/`outp`, `enable`/`disable`, `min`/`max`, `home()`, `seek`/`tell`/`remove`, `_ffirst`, `ms_*` mouse aliases, etc. |

## Quick lookup: I want to ...

* **Print text** → `<stdio.h>` (`printf` / `puts` — fast, no colour) or
  `<conio.h>` (`cprintf` / `cputs` — applies `textcolor`).
* **Read a key** → `<conio.h>`: `getch()` (blocking, no echo), `getche()` (echo),
  `kbhit()` (non-blocking poll).
* **Open / read / write files** → `<unistd.h>` + `<fcntl.h>` (POSIX) or
  `<stdio.h>` (`fopen` family).
* **List a directory** → `<dir.h>`: `ffirst` / `fnext`.
* **Draw pixels** → `<gfx.h>`.
* **Allocate memory** → `<stdlib.h>`: `malloc` / `free` / `calloc` / `realloc`.
* **Get current time** → `<time.h>`: `getdatetime` or POSIX `time`/`localtime`.
* **Read mouse** → `<mouse.h>`.
* **Read an env var** → `<sprinter.h>`: `getenv` / `putenv`.
* **Set text colour** → `<conio.h>`: `textcolor(COLOR_YELLOW)`,
  `textbackground(COLOR_BLUE)`, or `textattr(COLOR(fg, bg))`.
