1
0
Fork 0
forked from fun/fun

Documentation and Web update. No code changes. (0.42.1)

This commit is contained in:
Johannes Findeisen 2026-06-06 18:52:16 +02:00
commit 42e702f9e8
11 changed files with 74 additions and 60 deletions

View file

@ -20,13 +20,14 @@ tags:
- Purpose: HTTP helpers using libcurl.
- Homepage: [https://curl.se/libcurl/](https://curl.se/libcurl/){:class="ext"}
## Opcodes:
## Opcodes
- OP_CURL_GET: GET; pops url:string; pushes body:string (empty on error/disabled)
- OP_CURL_POST: POST; pops body:string, url:string; pushes response:string
- OP_CURL_DOWNLOAD: Download to file; pops path:string, url:string; pushes 1/0
## Notes:
## Notes
- Requires libcurl development headers/libs.
- When disabled, helpers return empty strings/0 to match optional behavior.

View file

@ -20,7 +20,7 @@ tags:
- Purpose: Read/write simple INI configuration files.
- Homepage: [https://github.com/ndevilla/iniparser](https://github.com/ndevilla/iniparser){:class="ext"}
## Opcodes:
## Opcodes
- OP_INI_LOAD: pops path; pushes handle (>0) or 0
- OP_INI_FREE: pops handle; pushes 1/0
@ -32,7 +32,8 @@ tags:
- OP_INI_UNSET: pops key, section, handle; pushes 1/0
- OP_INI_SAVE: pops path, handle; pushes 1/0
## Notes:
## Notes
- Requires iniparser development headers/libs.
- When disabled, helpers return neutral values (0/empty strings) like other optional extensions.

View file

@ -19,14 +19,15 @@ tags:
- Purpose: JSON parse/stringify and file helpers via json-c.
- Homepage: [https://json-c.github.io/json-c/](https://json-c.github.io/json-c/){:class="ext"}
## Opcodes:
## Opcodes
- OP_JSON_PARSE: pops text; pushes value or Nil on error
- OP_JSON_STRINGIFY: pops pretty:int(0/1), value; pushes string
- OP_JSON_FROM_FILE: pops path; pushes value or Nil
- OP_JSON_TO_FILE: pops pretty:int(0/1), value, path; pushes 1/0
## Notes:
## Notes
- Requires json-c development headers/libs.
- When disabled, functions push empty/neutral values similar to other optional modules.

View file

@ -18,12 +18,12 @@ tags:
- Purpose: integrate the kcgi (CGI/FastCGI) C library; provide request parsing and response helpers for building CGI apps in Fun.
- Homepage: [https://kristaps.bsd.lv/kcgi/](https://kristaps.bsd.lv/kcgi/){:class="ext"}
## Build notes:
## Build notes
- Requires system kcgi development headers and libraries (pkg-config name: kcgi).
- If pkg-config is not available, build falls back to linking against libkcgi and zlib (as configured in cmake/Extensions/KCGI.cmake).
## Provided helper/opcodes:
## Provided helper/opcodes
- Function: kcgi_parse(data: none) -> Map | Nil. Parses the current CGI/FastCGI request via kcgi and returns a Map with keys like method, scheme, host, port, path, suffix, query, and fields (GET/POST map). Returns Nil on failure or when the extension is disabled.
- Function: kcgi_reply_start(code:int, content_type:string) -> 1/0. Starts the HTTP reply (sets Content-Type and opens the body).
@ -31,19 +31,20 @@ tags:
- Function: kcgi_end() -> 1/0. Finalizes the response and frees request resources.
- Opcodes: OP_KCGI_PARSE, OP_KCGI_REPLY_START, OP_KCGI_WRITE, OP_KCGI_END (internal mappings for the functions above).
## Quickstart:
## Quickstart
- Configure: cmake -S . -B build -DFUN_WITH_KCGI=ON
- Build: cmake --build build --target fun
- Run example:
- FUN_LIB_DIR="$(pwd)/lib" ./build/fun examples/cgi/hello_kcgi.fun
## Example output:
## Example output
- Content-Type: text/html; charset=utf-8
- <h1>Hello, Fun!</h1>
## Notes:
## Notes
- Running outside a real CGI/FastCGI environment may emit RFC warnings (e.g., missing REMOTE_ADDR); these are benign for local testing.
- When FUN_WITH_KCGI is OFF, the helpers behave as no-ops (returning Nil/0) to keep scripts portable.

View file

@ -19,12 +19,12 @@ tags:
- Purpose: provide small crypto helpers backed by OpenSSL. Includes md5, sha256, sha512, ripemd160 helpers.
- Homepage: [https://www.openssl.org/](https://www.openssl.org/){:class="ext"}
## Build notes:
## Build notes
- Requires system OpenSSL development headers and libraries.
- On OpenSSL 3.x, legacy MD5_* APIs are deprecated; you may see warnings during build.
## Provided helper/opcodes:
## Provided helper/opcodes
- Function: openssl_md5(data:string) -> string (lowercase hex). Falls back to empty string when the extension is disabled, mirroring other optional modules.
- Function: openssl_sha256(data:string) -> string (lowercase hex).
@ -32,7 +32,7 @@ tags:
- Function: openssl_ripemd160(data:string) -> string (lowercase hex). Note: On OpenSSL 3.x this may require the legacy provider; if the digest is unavailable, the helper returns an empty string.
- Opcodes: OP_OPENSSL_MD5, OP_OPENSSL_SHA256, OP_OPENSSL_SHA512, OP_OPENSSL_RIPEMD160 (internal mappings for the functions above).
## Quickstart:
## Quickstart
- Configure: cmake -S . -B build -DFUN_WITH_OPENSSL=ON
- Build: cmake --build build --target fun
@ -42,7 +42,7 @@ tags:
- ./build/fun examples/crypto/openssl_sha512.fun
- ./build/fun examples/crypto/openssl_ripemd160.fun
## Example output:
## Example output
- md5(abc) = 900150983cd24fb0d6963f7d28e17f72
- md5("") = d41d8cd98f00b204e9800998ecf8427e
@ -53,6 +53,7 @@ tags:
- ripemd160(abc) = 8eb208f7e05d987a9b044a8e98c6b087f15a0bfc
- ripemd160("") = 9c1185a5c5e9fc54612808977ee8f548b2258d31
## Notes:
## Notes
- The OpenSSL 3.x provider configuration on your system determines availability of RIPEMD-160. If the legacy provider is not enabled, openssl_ripemd160() will return an empty string.

View file

@ -22,13 +22,14 @@ tags:
- Purpose: Advanced regular expressions via PCRE2.
- Homepage: [https://www.pcre.org/](https://www.pcre.org/){:class="ext"}
## Opcodes:
## Opcodes
- OP_PCRE2_TEST: pops flags, text, pattern; pushes 1/0
- OP_PCRE2_MATCH: pops flags, text, pattern; pushes match map or Nil
- OP_PCRE2_FINDALL: pops flags, text, pattern; pushes array of match maps
## Notes:
## Notes
- Requires PCRE2 development headers/libs.
- Flags are backend-specific; see implementation for supported bits.

View file

@ -20,7 +20,7 @@ tags:
- Purpose: Access smart card readers/cards via PC/SC (pcsclite).
- Homepage: [https://pcsclite.apdu.fr/](https://pcsclite.apdu.fr/){:class="ext"}
## Opcodes:
## Opcodes
- OP_PCSC_ESTABLISH: returns context id (>0) or 0
- OP_PCSC_RELEASE: pops ctx id; returns 1/0
@ -29,7 +29,8 @@ tags:
- OP_PCSC_DISCONNECT: pops handle id; returns 1/0
- OP_PCSC_TRANSMIT: pops apdu, handle id; returns map with data/SW/rc
## Notes:
## Notes
- Requires PC/SC lite development headers/libs.
- Behavior and availability depend on platform and reader drivers.

View file

@ -5,12 +5,13 @@ noToc: false
noComments: false
noDate: false
title: Redis (hiredis) Extension
subtitle: Redis client integration for Fun using the hiredis C library.
subtitle: Redis/Valkey client integration for Fun using the hiredis C library.
description: Documentation for the optional Redis extension in Fun. Provides redis_connect, redis_cmd, and redis_close builtins backed by hiredis.
permalink: /documentation/extensions/redis/
lang: en
tags:
- redis
- valkey
- hiredis
- database
- cache
@ -21,25 +22,25 @@ tags:
The Redis extension adds a minimal client for Redis-compatible servers using the [hiredis](https://github.com/redis/hiredis){:class="ext"} C library. It currently exposes a simple synchronous API; Async I/O through Fun's event loop will be added later.
Requirements
------------
## Requirements
- Build-time option: `-DFUN_WITH_REDIS=ON`
- System libraries: `hiredis` headers and library available (via pkg-config or default linker search paths)
- Runtime: a Redis-compatible server (e.g., on `127.0.0.1:6379`)
Enabling the extension
----------------------
## Enabling the extension
Example CMake configure line enabling Redis along with other options:
<pre>cmake -S . -B build_release -DCMAKE_BUILD_TYPE=Release \
-DFUN_WITH_REDIS=ON -DFUN_WITH_OPENSSL=ON</pre>
-DFUN_WITH_REDIS=ON</pre>
When configured, the build summary will include a line:
<pre>Redis (FUN_WITH_REDIS): ENABLED</pre>
Provided builtins/opcodes
-------------------------
## Provided builtins/opcodes
- `redis_connect(host: string, port: int) -> int`
- Establishes a TCP connection and returns a positive handle id on success, or `0` on error.
- Example: `h = redis_connect('127.0.0.1', 6379)`
@ -56,26 +57,28 @@ Provided builtins/opcodes
- `redis_close(handle: int) -> Nil`
- Closes the connection associated with the handle and frees resources.
Notes and limitations
---------------------
## Notes and limitations
- Error handling: invalid handles or failed commands yield `nil` or an empty/neutral value depending on context.
- Security: this initial version does not include TLS; TLS support may be added in a future iteration once hiredis SSL is wired in.
- Async: the current API is synchronous. Integration with Fun's asyncio is planned.
Examples
--------
## Examples
Runnable examples are included in the source tree:
- `examples/extensions/redis/basic_ping.fun`
- `examples/extensions/redis/kv_set_get.fun`
- `examples/extensions/redis/list_ops.fun`
- `examples/extensions/redis/hash_ops.fun`
- `examples/extensions/redis/redis_test.fun`
Quick start (from repo root, using a built Fun executable):
<pre>build_debug/fun examples/extensions/redis/basic_ping.fun</pre>
Troubleshooting
---------------
## Troubleshooting
- Ensure a Redis server is reachable at the host/port you pass to `redis_connect`.
- If `redis_connect` returns `0`, verify the hiredis library and headers are installed and that Fun was configured with `-DFUN_WITH_REDIS=ON`.