diff --git a/web/about/about.md b/web/about/about.md index b2af41d..1be1916 100644 --- a/web/about/about.md +++ b/web/about/about.md @@ -5,7 +5,7 @@ subtitle: More information about having fun... :) description: About _date: 2023-09-20 metasub: news -noToc: true +noToc: false noDate: false tags: - fun @@ -210,15 +210,16 @@ Written primarily in Fun itself (lib/): Enabled via CMake flags, each wrapping a mature C library: -- **JSON** (`FUN_WITH_JSON` / json-c) — parse, stringify, file I/O ☑ -- **cURL** (`FUN_WITH_CURL` / libcurl) — HTTP GET, POST, download ☑ -- **SQLite** (`FUN_WITH_SQLITE` / libsqlite3) — open, query, exec, close ☑ -- **PCRE2** (`FUN_WITH_PCRE2` / libpcre2) — Perl-compatible regex with flags ☑ -- **OpenSSL** (`FUN_WITH_OPENSSL` / libcrypto) — MD5, SHA-256, SHA-512, RIPEMD-160 hashing ☑ -- **INI** (`FUN_WITH_INI` / iniparser 4.2.6) — load, get/set, save config files ☑ -- **XML** (`FUN_WITH_XML2` / libxml2) — parse, navigate, query XML documents ☑ -- **PC/SC** (`FUN_WITH_PCSC` / libpcsclite) — smart card communication ☑ -- **KCGI** (`FUN_WITH_KCGI` / libkcgi) — CGI web applications ☑ +- **[JSON](/documentation/extensions/json/)** (`FUN_WITH_JSON` / [json-c](https://json-c.github.io/json-c/){:class="ext"}) — parse, stringify, file I/O ☑ +- **[cURL](/documentation/extensions/curl/)** (`FUN_WITH_CURL` / [libcurl](https://curl.se/libcurl/){:class="ext"}) — HTTP GET, POST, download ☑ +- **[SQLite](/documentation/extensions/sqlite/)** (`FUN_WITH_SQLITE` / [libsqlite3](https://www.sqlite.org/){:class="ext"}) — open, query, exec, close ☑ +- **[PCRE2](/documentation/extensions/pcre2/)** (`FUN_WITH_PCRE2` / [libpcre2](https://www.pcre.org/){:class="ext"}) — Perl-compatible regex with flags ☑ +- **[OpenSSL](/documentation/extensions/openssl/)** (`FUN_WITH_OPENSSL` / [libcrypto](https://www.openssl.org/){:class="ext"}) — MD5, SHA-256, SHA-512, RIPEMD-160 hashing ☑ +- **[INI](/documentation/extensions/ini/)** (`FUN_WITH_INI` / [iniparser](https://github.com/ndevilla/iniparser){:class="ext"}) — load, get/set, save config files ☑ +- **[XML](/documentation/extensions/xml2/)** (`FUN_WITH_XML2` / [libxml2](http://xmlsoft.org/){:class="ext"}) — parse, navigate, query XML documents ☑ +- **[PC/SC](/documentation/extensions/pcsc/)** (`FUN_WITH_PCSC` / [libpcsclite](https://pcsclite.apdu.fr/){:class="ext"}) — smart card communication ☑ +- **[KCGI](/documentation/extensions/kcgi/)** (`FUN_WITH_KCGI` / [libkcgi](https://kristaps.bsd.lv/kcgi/){:class="ext"}) — CGI web applications ☑ +- **[Redis/Valkey](/documentation/extensions/redis/)** (`FUN_WITH_REDIS` / [hiredis](https://github.com/redis/hiredis){:class="ext"}) — Redis and Valkey support ☑ ☑ = Done @@ -244,3 +245,4 @@ Each extension also has a corresponding stdlib wrapper class (e.g., `JSON`, `INI ## Code - [https://git.xw3.org/fun/fun/](https://git.xw3.org/fun/fun/){:class="git"} + diff --git a/web/documentation/examples/examples.md b/web/documentation/examples/examples.md index 1e16476..8c71574 100644 --- a/web/documentation/examples/examples.md +++ b/web/documentation/examples/examples.md @@ -27,21 +27,21 @@ All commands assume you are in the repository root. ## Prerequisites -- Build the interpreter (see handbook/). You’ll have `build/fun` (paths may vary by your setup/IDE). +- Build the interpreter (see [handbook](/documentation/handbook/). You’ll have `build/fun` (paths may vary by your setup/IDE). - Set FUN_LIB_DIR to the repo’s lib directory when running without installation so `#include <...>` can find the standard library. -Example (Linux/macOS/BSD): +### Linux/macOS/BSD: -
FUN_LIB_DIR="$(pwd)/lib" ./build/fun examples/include_lib.fun+
FUN_LIB_DIR="$(pwd)/lib" ./build/fun ./examples/include_lib.fun-Windows (PowerShell): +### Windows (PowerShell):
$env:FUN_LIB_DIR = "$PWD/lib" ./build/fun.exe .\examples\include_lib.fun## Interactive showcase: play.fun -The script `./scripts/play.fun` discovers all `.fun` files under `./examples` and offers to run them one by one: +The script `./scripts/play.fun` discovers all `.fun` files in `./examples` and offers to run them one by one:
./scripts/play.fun@@ -52,7 +52,7 @@ Notes: Tip: you can run specific examples directly too: -
FUN_LIB_DIR="$(pwd)/lib" fun examples/crypto/openssl_md5.fun+
FUN_LIB_DIR="$(pwd)/lib" ./build/fun ./examples/extensions/openssl/openssl_md5.fun## Example categories @@ -72,3 +72,4 @@ Place your `.fun` files anywhere under `examples/` to have them picked up by `pl #include
cmake -S . -B build_release -DCMAKE_BUILD_TYPE=Release \ - -DFUN_WITH_REDIS=ON -DFUN_WITH_OPENSSL=ON+ -DFUN_WITH_REDIS=ON When configured, the build summary will include a line:
Redis (FUN_WITH_REDIS): ENABLED-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):
build_debug/fun examples/extensions/redis/basic_ping.fun-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`. + diff --git a/web/features/features.md b/web/features/features.md index 467e7a8..d7449e0 100644 --- a/web/features/features.md +++ b/web/features/features.md @@ -330,16 +330,16 @@ Enabled via CMake flags; each wraps a mature C library: | Extension | CMake Flag | Library | Features | |-----------|-----------|---------|----------| -| **JSON** | `FUN_WITH_JSON` | json-c | `json_parse()`, `json_stringify()`, `json_from_file()`, `json_to_file()` | -| **cURL** | `FUN_WITH_CURL` | libcurl | `curl_get()`, `curl_post()`, `curl_download()` | -| **SQLite** | `FUN_WITH_SQLITE` | libsqlite3 | `sqlite_open()`, `sqlite_close()`, `sqlite_exec()`, `sqlite_query()` | -| **PCRE2** | `FUN_WITH_PCRE2` | libpcre2 | `pcre2_test()`, `pcre2_match()`, `pcre2_find_all()` — with flags (i, m, s, u, x) | -| **OpenSSL** | `FUN_WITH_OPENSSL` | libcrypto | `openssl_md5()`, `openssl_sha256()`, `openssl_sha512()`, `openssl_ripemd160()` | -| **INI** | `FUN_WITH_INI` | iniparser 4.2.6 | `ini_load()`, `ini_get_string/int/double/bool()`, `ini_set()`, `ini_unset()`, `ini_save()` | -| **XML** | `FUN_WITH_XML2` | libxml2 | `xml_parse()`, `xml_root()`, `xml_name()`, `xml_text()` | -| **PC/SC** | `FUN_WITH_PCSC` | libpcsclite | `pcsc_establish()`, `pcsc_list_readers()`, `pcsc_connect()`, `pcsc_transmit()`, etc. | -| **KCGI** | `FUN_WITH_KCGI` | libkcgi | `kcgi_parse()`, `kcgi_reply_start()`, `kcgi_write()`, `kcgi_end()` | -| **Redis** | `FUN_WITH_REDIS` | hiredis | `redis_connect()`, `redis_cmd()`, `redis_close()` | +| **[JSON](/documentation/extensions/json/)** | `FUN_WITH_JSON` | [json-c](https://json-c.github.io/json-c/){:class="ext"} | `json_parse()`, `json_stringify()`, `json_from_file()`, `json_to_file()` | +| **[cURL](/documentation/extensions/curl/)** | `FUN_WITH_CURL` | [libcurl](https://curl.se/libcurl/){:class="ext"} | `curl_get()`, `curl_post()`, `curl_download()` | +| **[SQLite](/documentation/extensions/sqlite/)** | `FUN_WITH_SQLITE` | [libsqlite3](https://www.sqlite.org/){:class="ext"} | `sqlite_open()`, `sqlite_close()`, `sqlite_exec()`, `sqlite_query()` | +| **[PCRE2](/documentation/extensions/pcre2/)** | `FUN_WITH_PCRE2` | [libpcre2](https://www.pcre.org/){:class="ext"} | `pcre2_test()`, `pcre2_match()`, `pcre2_find_all()` — with flags (i, m, s, u, x) | +| **[OpenSSL](/documentation/extensions/openssl/)** | `FUN_WITH_OPENSSL` | [libcrypto](https://www.openssl.org/){:class="ext"} | `openssl_md5()`, `openssl_sha256()`, `openssl_sha512()`, `openssl_ripemd160()` | +| **[INI](/documentation/extensions/ini/)** | `FUN_WITH_INI` | [iniparser](https://github.com/ndevilla/iniparser){:class="ext"} | `ini_load()`, `ini_get_string/int/double/bool()`, `ini_set()`, `ini_unset()`, `ini_save()` | +| **[XML](/documentation/extensions/xml2/)** | `FUN_WITH_XML2` | [libxml2](http://xmlsoft.org/){:class="ext"} | `xml_parse()`, `xml_root()`, `xml_name()`, `xml_text()` | +| **[PC/SC](/documentation/extensions/pcsc/)** | `FUN_WITH_PCSC` | [libpcsclite](https://pcsclite.apdu.fr/){:class="ext"} | `pcsc_establish()`, `pcsc_list_readers()`, `pcsc_connect()`, `pcsc_transmit()`, etc. | +| **[KCGI](/documentation/extensions/kcgi/)** | `FUN_WITH_KCGI` | [libkcgi](https://kristaps.bsd.lv/kcgi/){:class="ext"} | `kcgi_parse()`, `kcgi_reply_start()`, `kcgi_write()`, `kcgi_end()` | +| **[Redis/Valkey](/documentation/extensions/redis/)** | `FUN_WITH_REDIS` | [hiredis](https://github.com/redis/hiredis){:class="ext"} | `redis_connect()`, `redis_cmd()`, `redis_close()` | Some extensions also have a corresponding **stdlib wrapper class** in `lib/io/` or `lib/net/`: @@ -426,3 +426,4 @@ Some extensions also have a corresponding **stdlib wrapper class** in `lib/io/` ## Licensing - **Apache 2.0** — fully open source, freely usable and modifiable +