9 Examples
gullradriel edited this page 2026-11-02 12:42:25 +01:00

Examples

  • example ex_accept_pool_client.c
    Client for accept pool testing: connects repeatedly to stress the server.
  • example ex_accept_pool_server.c
    Accept pool example: three modes of accept + client handling.
  • example ex_allegro_4.c
    Allegro 4 compatibility layer: a scene drawn with Allegro 4 calls.
  • example ex_atlas.c
    n_atlas multi-page sprite atlas test (headless).
  • example ex_base64.c
    Nilorea Library crypto base64 api test.
  • example ex_clock_sync.c
    Clock synchronization demo using UDP networking.
  • example ex_common.c
    Nilorea Library common api test.
  • example ex_configfile.c
    Nilorea Library config api test.
  • example ex_cookies.c
    n_cookies regression: Set-Cookie parsing, domain/path/secure/expiry matching.
  • example ex_crypto.c
    Nilorea Library crypto vigenere api test.
  • example ex_diff.c
    n_diff regression: line diff, hunk rendering and the edit ceiling.
  • example ex_digest.c
    n_digest regression: MD5/SHA/HMAC/PBKDF2 and constant-time-compare vectors.
  • example ex_disk_cache.c
    a bounded on-disk cache keyed by content
  • example ex_dns.c
    n_dns regression: parse a DNS query question and build an A-record response.
  • example ex_ecc.c
    n_ecc regression: X25519 agreement + Ed25519 sign/verify round-trips.
  • example ex_entropy.c
    N_ENTROPY randomness metrics regression (headless).
  • example ex_exceptions.c
    Nilorea Library exception api test.
  • example ex_file.c
    Nilorea Library N_FILE api test.
  • example ex_file_copy.c
    n_file_copy_verified(), n_file_same_content() and n_file_free_space()
  • example ex_fluid.c
    ex_fluids Main File
  • example ex_fluid_config.c
    functions for fluid configuration
  • example ex_fluid_config.h
    Config file for ex_fluid.
  • example ex_git.c
    Nilorea Library n_git module test.
  • example ex_gui.c
    Nilorea Library GUI system demo - all widget types including dropdown menus, show/hide windows, auto-sizing, scrollbars, resizable windows, and bitmap skinning.
  • example ex_gui_bench.c
    Headless-friendly performance benchmark for the n_gui system.
  • example ex_gui_button_keys.c
    n_gui buttons from the keyboard
  • example ex_gui_checkbox_label.c
    n_gui checkbox relabelling
  • example ex_gui_checkbox_release.c
    n_gui checkbox toggles on release, not on press
  • example ex_gui_color_picker.c
    the colour picker dialog and the colour swatch
  • example ex_gui_colorwheel.c
    the colour wheel widget: dragged, clamped to its disc, reset by a right press, set from code, painted with the caller's colours
  • example ex_gui_combobox_items.c
    n_gui combobox item count and removal
  • example ex_gui_combobox_wheel.c
    The mouse wheel scrolls an open combobox list (headless).
  • example ex_gui_cursor.c
    The application's mouse cursor, kept by the GUI (headless).
  • example ex_gui_curve.c
    the curve editor widget
  • example ex_gui_custom.c
    N_GUI_TYPE_CUSTOM owner-draw widget: the paint callback fires during n_gui_draw with the widget's absolute rectangle (headless, memory bitmap).
  • example ex_gui_custom_mouse.c
    a custom widget that takes the mouse, and one that owns its state
  • example ex_gui_datagrid.c
    N_GUI_DATAGRID rows, numeric sort, selection and right-click context callback regression (headless).
  • example ex_gui_datagrid_keys.c
    Datagrid keyboard navigation (headless).
  • example ex_gui_datagrid_sort.c
    n_gui_datagrid_get_sort: read back the order a grid is showing (headless).
  • example ex_gui_detach.c
    Interactive N_GUI native (detached) window demo.
  • example ex_gui_dictionary.c
    Nilorea Library gui dictionary search using n_gui widgets.
  • example ex_gui_display_fallback.c
    n_gui takes the display size from the draw target until one is set
  • example ex_gui_double_click.c
    Double click reporting (headless).
  • example ex_gui_dropmenu.c
    N_GUI_TYPE_DROPMENU entry, label, and clear regression test (headless).
  • example ex_gui_frameless_drag.c
    A press on a widget in a movable frameless window is not a window drag (headless).
  • example ex_gui_global_scroll.c
    the display's own scrollbars: shown for windows that reach past the display, not for a rounding error of a layout computed in floats
  • example ex_gui_glyph.c
    Button glyph regression test (headless): n_gui_button_set_glyph draws a primitive icon instead of the label on the small square buttons where a label does not fit, keeps the label for a later switch back, and ignores out-of-range values and non-button widgets.
  • example ex_gui_grid.c
    a virtualised, vertically scrolled grid of cells
  • example ex_gui_hexview.c
    N_GUI_HEXVIEW data round-trip and byte-editing regression test (headless).
  • example ex_gui_hover.c
    n_gui_hovered_widget() query test (headless).
  • example ex_gui_isometric.c
    Nilorea Library: Isometric tile engine with GUI controls.
  • example ex_gui_kvtable.c
    N_GUI_KVTABLE adaptive-resize regression test.
  • example ex_gui_label_fits.c
    Label overflow regression test (headless): n_gui_label_fits reports a single-line label whose text is drawn truncated and a justified label whose wrapped text is drawn clipped, and hands back the size that shows all of it.
  • example ex_gui_label_lines.c
    labels honour a line break, in every alignment
  • example ex_gui_layout_persist.c
    Widget-state persistence round-trip for n_gui_save/load_layout_json: a keyed splitpane's ratio and a keyed datagrid's column layout survive a save + reload into a fresh context, including the lazily-created-widget path (n_gui_widget_set_persist_key applies the pending state).
  • example ex_gui_listbox.c
    Listbox horizontal-scroll regression test (headless): the content width tracks the widest item, the scroll offset clamps to it, a press on the horizontal track scrolls instead of selecting a row, and clearing the list resets the offset.
  • example ex_gui_md.c
    n_gui_md regression: measure equals draw, every block kind lays out, a link can be found, a narrower column is a taller one, and the N_GUI_TYPE_MARKDOWNVIEW widget over it scrolls and follows its theme.
  • example ex_gui_multiwin.c
    N_GUI native (detached) window regression: a pop-up promoted to a real OS window keeps working, and the resources shared with the main display (font glyphs, bitmaps, clipboard) stay valid on both.
  • example ex_gui_network.c
    GUI network chat demo using the n_gui and n_network modules.
  • example ex_gui_particles.c
    Nilorea Library gui particle api test with info GUI.
  • example ex_gui_placeholder.c
    N_GUI textarea placeholder/hint set, replace, and clear (headless).
  • example ex_gui_popup.c
    a popup menu with submenus
  • example ex_gui_progressbar.c
    N_GUI_PROGRESSBAR value set/get and clamping regression (headless).
  • example ex_gui_reentrant.c
    n_gui_process_event re-entrancy regression test (headless).
  • example ex_gui_round.c
    n_gui: a round GUI rounds the widgets that have no shape of their own
  • example ex_gui_sectionlist.c
    N_GUI_SECTIONLIST folding, offsets and hidden members (headless).
  • example ex_gui_slider_default.c
    A slider's default, put back by a double click (headless).
  • example ex_gui_slider_handle.c
    A slider's handle stays inside the widget at every value (headless).
  • example ex_gui_slider_step.c
    A slider's keyboard and wheel increment, apart from its snapping step (headless).
  • example ex_gui_splitpane.c
    N_GUI_SPLITPANE ratio and clamping regression test (headless).
  • example ex_gui_suggest.c
    Completions offered under a textarea while it is typed in (headless).
  • example ex_gui_syntaxview.c
    N_GUI_SYNTAXVIEW line-count, mode, and text-selection/copy regression test (headless).
  • example ex_gui_text_shorten.c
    shortening text to a width, at the end, at the start, or a path
  • example ex_gui_textarea_selection.c
    n_gui text area selection query
  • example ex_gui_tooltip.c
    Tooltip bubble regression (headless): an in-app window does not narrow the bubble, style.tooltip_max_w caps how wide it runs, and a window opened over the pointer hides it instead of being drawn over.
  • example ex_gui_tree_lazy.c
    a tree filled one node at a time, as it is opened
  • example ex_gui_tree_order.c
    Tree view row-order regression test (headless): a child added after its parent's siblings is drawn under its parent, not at the bottom of the tree.
  • example ex_gui_tree_state.c
    Tree view-state regression test (headless): unfolded branches, the selection and the scroll position survive a rebuild that replaces every node, which is what a model reloaded from disk does.
  • example ex_gui_window_rect.c
    Runtime window relayout regression test (headless): n_gui_window_set_rect moves/resizes a window and rescales its widgets from their normalized coordinates, and the window's norms follow so a later adaptive resize keeps the new proportions.
  • example ex_gui_zorder.c
    N_GUI mouse dispatch hits the topmost overlapping widget (headless).
  • example ex_hash.c
    Nilorea Library hash table api test.
  • example ex_hex.c
    n_hex regression: hexadecimal encode/decode round-trips and error paths.
  • example ex_html.c
    n_html regression: link, form, and sitemap extraction.
  • example ex_http2.c
    n_http2 regression: frame codec, SETTINGS, and HPACK (RFC 7541 vectors).
  • example ex_http2_server.c
    n_http2_server regression: preface, SETTINGS, requests, flow control.
  • example ex_http_cookie.c
    n_http_cookie: reading a Cookie header (first occurrence wins) and building Set-Cookie values, with header injection and broken prefixes refused
  • example ex_http_form.c
    n_http_form: strict percent-decoding, query strings and urlencoded forms; malformed escapes, NUL bytes, ill-formed UTF-8 and field floods refused
  • example ex_http_mime.c
    n_http_mime: media types from extensions, last segment only, query ignored, case-insensitive, NULL when unknown
  • example ex_http_req.c
    n_http_req regression: valid requests parse, and the smuggling / malformed / oversized cases are rejected.
  • example ex_http_response.c
    n_http_response: header validation (no response splitting), framing (Content-Length, Connection, Date), HEAD and bodiless statuses, memory and file bodies written through a write function that takes a few bytes at a time, single-range parsing
  • example ex_http_router.c
    n_http_router: a blog's route table, typed placeholders checked on the raw path, specificity instead of table order, 404 / 405 / 400, HEAD on GET routes, ambiguity and pattern checks
  • example ex_http_server.c
    n_http_server over real sockets, plain and TLS: keep-alive, pipelining, HEAD, HTTP/1.0, bodies in memory and in a file, unread bodies, 413 / 417 / 400 / 501 / 431 / 408 / 503 / 500, Expect: 100-continue, deadlines against slow peers, the connection cap, a clean stop
  • example ex_icc.c
    n_icc: embed a small profile in JPEG, PNG, WebP and TIFF shaped buffers and files, find it again, and refuse broken ones.
  • example ex_iso_astar.c
    Nilorea Library: Isometric engine + A* pathfinding + Dead Reckoning demo.
  • example ex_json.c
    n_json wrapper: parse, typed getters, arrays, and file parsing.
  • example ex_kafka.c
    Nilorea Library kafka event test.
  • example ex_linalg.c
    n_linalg_solve()
  • example ex_list.c
    Nilorea Library list api test.
  • example ex_log.c
    Nilorea Library log api test.
  • example ex_markdown.c
    n_markdown regression: the safe subset, the opt-in block kinds, and the hostile-input safety cases.
  • example ex_module.c
    open a shared library at runtime, find a symbol, call it
  • example ex_monolith.c
    Nilorea Library monolith api test.
  • example ex_network.c
    Network module example.
  • example ex_network.h
    Nilorea Library n_network api test.
  • example ex_network_accept.c
    What netw_accept_from_ex() hands back about the accepted connection.
  • example ex_network_alpn.c
    TLS ALPN negotiation, and a real HTTP/2 exchange over the "h2" it selects.
  • example ex_network_connect_abort.c
    Interrupt an in-progress connect with netw_set_connect_abort_cb.
  • example ex_network_mock.c
    Mock HTTP server example using Nilorea network module.
  • example ex_network_proxy.c
    Demonstrates n_proxy_cfg_parse / n_proxy_cfg_free and netw_adopt_client_fd.
  • example ex_network_reactor.c
    Single-threaded epoll reactor demo (n_reactor + netw_accept_into_reactor).
  • example ex_network_sni.c
    MITM-style SNI accept: server mints a per-host leaf, client checks it and evaluates its trust.
  • example ex_network_sse.c
    SSE (Server-Sent Events) client example using Nilorea network module.
  • example ex_network_ssl.c
    Network module example, interacting with SSL.
  • example ex_network_ssl_hardened.c
    Hardened HTTPS server example with SSL/TLS security best practices.
  • example ex_network_ssl_hostname.c
    netw_ssl_do_handshake checks the NAME on the peer certificate, not only that its chain is trusted.
  • example ex_network_ssl_nonblock.c
    Non-blocking (resumable) TLS: both peers drive netw_ssl_handshake_once / netw_ssl_server_handshake_once + the *_once movers from their own poll() loop, never the thread engine.
  • example ex_network_tls_defaults.c
    server TLS defaults: a context from netw_set_crypto_pem() and the per-connection context of the SNI accept path both refuse TLS 1.1, ciphers without forward secrecy and CBC ciphers, and accept TLS 1.2 ECDHE-GCM and TLS 1.3
  • example ex_network_ws.c
    WebSocket client example using Nilorea network module.
  • example ex_network_ws_limits.c
    n_ws_recv frame-length bound: a peer-declared payload length is read straight off the wire, so it is bounded BEFORE it sizes an allocation.
  • example ex_nstr.c
    Nilorea Library string api test.
  • example ex_parallel_for.c
    n_parallel_for(): a loop over a range on several cores
  • example ex_parallel_team.c
    N_PARALLEL_TEAM: many parallel loops on threads that stay alive.
  • example ex_pcre.c
    Nilorea Library pcre api test.
  • example ex_pretty.c
    n_pretty regression: JSON, XML/HTML and JavaScript reformatting.
  • example ex_pth.c
    reading a PyTorch checkpoint's tensors: a small checkpoint written here (a float32 storage, a float16 one, a transposed view, an offset view, metadata that is not a tensor) and read back; damaged ones refused
  • example ex_query.c
    N_QUERY language regression (headless): operators, AND/OR/NOT, errors.
  • example ex_random.c
    n_random regression: secure random bytes and hex token generation.
  • example ex_sha256.c
    portable SHA-256: the FIPS 180-4 test vectors, pieces of every size against one call, and a file
  • example ex_signals.c
    Nilorea Library signals api test.
  • example ex_spawn.c
    start a program detached or waited for, with arguments no shell touches
  • example ex_ssrf.c
    n_ssrf regression: public addresses pass, private/reserved are blocked, and a private IPv4 smuggled inside IPv6 is still blocked.
  • example ex_stack.c
    Nilorea Library stack API.
  • example ex_threads.c
    Nilorea Library thread pool api example.
  • example ex_tiff.c
    n_tiff: build small TIFF structured buffers in both byte orders, read their tags back, follow a pointer to a sub-directory, and refuse broken ones.
  • example ex_time_formats.c
    n_time date formats: HTTP dates (format and strict parse), RFC 2822 for RSS, RFC 3339 (format and parse); expected strings from PHP 8.4
  • example ex_trajectory.c
    Nilorea Library trajectory API graphical demo (Allegro5).
  • example ex_trees.c
    Nilorea Library tree test.
  • example ex_url.c
    n_url_canonicalize regression test (scheme/host case, default port, dot segments).
  • example ex_url_safe.c
    n_url_safe regression: URL parse (incl.
  • example ex_wrap.c
    n_wrap regression: where the lines break, and the properties a height cache depends on (measure == draw, always >= 1 line, no infinite loop on an over-wide item).
  • example ex_x509.c
    Nilorea Library n_x509 CA generation and per-host leaf minting test.
  • example ex_zip.c
    reading members out of a ZIP archive: a stored one and a deflated one written here, extracted and compared, a missing one and a damaged one refused
  • example ex_zlib.c
    Nilorea Library zlib compression api test.