Compare commits

...

No commits in common. "master" and "main" have entirely different histories.
master ... main

818 changed files with 378451 additions and 3356 deletions

59
.gitignore vendored
View File

@ -1,4 +1,7 @@
# ---> C++
.fuse*
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
@ -9,8 +12,6 @@
*.gch
*.pch
.fuse*
# Compiled Dynamic libraries
*.so
*.dylib
@ -18,6 +19,7 @@
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
@ -29,39 +31,24 @@
*.exe
*.out
*.app
.fuse*
# ---> C
# Object files
*.o
*.ko
*.obj
*.elf
tmp/*
bin/*
pkg/*
dist/*
# Precompiled Headers
*.gch
*.pch
# Python cache artifacts
__pycache__/
*.py[cod]
*$py.class
.pytest_cache/
.mypy_cache/
.ruff_cache/
.coverage
htmlcov/
site/doc/examples/_gen/
# Libraries
*.lib
*.a
*.la
*.lo
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
# Debug files
*.dSYM/
work/
# Editor swap artifacts
*.swp
*.swo

176
DOCS-TODO.md Normal file
View File

@ -0,0 +1,176 @@
# DOCS-TODO — `/doc` documentation overhaul
Briefing for the doc-system overhaul. Read this fully before touching anything.
The approved design and the two locked decisions are: **(1) examples are LIVE and
SELF-VERIFYING** — real UCE code executed at render time, showing source + actual
captured output, gated by the test suite; **(2) FULL SWEEP** of all 257 pages.
The docs live under `site/doc/`:
- `index.uce` — the renderer (index + per-page detail view).
- `lib/doc_page.h` — page parsing (`load_doc_page`) + label/kind helpers.
- `style.css` — theme + layout.
- `pages/*.txt` — 257 page source files (the corpus).
- `areas/*.txt` — area groupings; first line is the area title, following lines
are page slugs (or `>area` references) that populate the index sidebar.
- `search.uce`, `singlepage.uce` — search + single-page render.
## Why this work exists (the problems)
- **Title bug:** 15 pages carry a `:title` that literally repeats the raw filename,
so `0_StringList` renders as "0_StringList" instead of "StringList". The `:title`
override defeats the prefix-stripping label logic already in `doc_page.h`
(`doc_default_title` / `doc_index_label` / `doc_method_label`).
- **31 slop/stub pages:** the newest APIs (`file_*`, `crypto_equal`, `sha256*`,
`hmac*`, `random_bytes`, `http_request*`, `job_*`, `shell_spawn`) are throwaway
`# name` + one-line markdown with NO `:sig`/`:params`/`:see`/`:content`.
- **134 of 257 pages have no code example.** We want PHP-manual-style
code-to-output examples on EVERY page.
- **Sidebar overflow:** long monospace identifiers in the 280px index sidebar and
220px detail sidebar have no wrapping → they spill.
- **Relevancy:** pages lead with cross-membrane mechanics and "Related Concepts"
PHP/JS filler instead of usage; cross-references between related pages are missing.
## Principles for every page
1. **Usage first.** The opening `:content` sentence says what the function does and
when you'd reach for it — in plain terms. No membrane/ABI talk up top.
2. **A real example, always.** Every page has at least one `:example` whose output
is produced by actually running it. Examples are the primary teaching tool.
3. **Cross-link.** Every page's `:see` references its area (`>area`) and its closest
sibling APIs, so the reader is never left to search alone.
4. **Demote the drivel.** Cross-membrane behavior, lock semantics, and PHP/JS
equivalents are at most a short trailing note — never the body. Delete filler
that teaches nothing.
---
## Phase 1 — Infrastructure (do this FIRST, verify on host before any content)
### 1a. Title bug
- In `lib/doc_page.h` `load_doc_page`: when a `:title` value, trimmed, **equals the
page slug**, ignore it (leave `result.title` empty) so the renderer falls through
to `doc_default_title`, which already strips `0_/1_/2_/3_` prefixes and renders
`Class::method` for `2_*`.
- Strip the 15 redundant `:title` blocks from their pages (`0_StringList`, `cli_arg`,
`cli_input`, `list_filter`, `list_map`, `map`, `request_base_url`,
`request_query_path`, `request_query_route`, `request_script_url`,
`route_path_is_safe`, `route_path_normalize`, `route_path_sanitize`, `ucb_encode`,
`ucb_decode`).
- Fix garbage `:sig` lines on struct pages (e.g. `0_StringList`'s sig is literally
`0_StringList`): give struct pages a real one-line type summary or drop the sig box.
### 1b. Live example mechanism — EXACT SPEC
Primitives (already confirmed to exist): `unit_compile(path)`, `unit_render(path)`,
`ob_start()`, `ob_get_close()`. Relative paths in the doc unit resolve against
`site/doc/`.
- **Parse:** add `:example` handling to `load_doc_page``DocPage.examples`
(a list; multiple `:example` blocks per page allowed). Capture the raw body lines
verbatim (this is both the displayed source AND the executed code).
- **Materialize:** for each example, write the body wrapped in a minimal unit to a
**stable** path `examples/_gen/<slug>_<n>.uce`:
```
RENDER(Request& context)
{
<example body>
}
```
Write **only if the content changed** (compare to existing file) so the runtime's
compiled-unit cache stays warm. The `_gen` dir must be writable by the worker
(www-data) — created/`chown`ed once on the host (see Setup below).
- **Execute + capture:** `unit_compile("examples/_gen/<slug>_<n>.uce");` then
`ob_start(); unit_render("examples/_gen/<slug>_<n>.uce"); String out = ob_get_close();`
- **Render:** an "Example" `doc-section` showing the source block, then the captured
output beneath it under an "Output" label (PHP-manual style). If the example
traps or output is empty, **surface that visibly** (do not swallow it) — a broken
example must be obvious so the gate catches it.
- Examples must be **self-contained and deterministic** — no wall-clock/random output
shown as canonical (if a function is inherently non-deterministic, show a
representative call and describe the shape, or seed it). The gate asserts presence
of an output block + absence of an error marker, not an exact value, EXCEPT where
the value is deterministic.
### 1c. Sidebar + example CSS (`style.css`)
- Add `overflow-wrap: anywhere; word-break: break-word;` to `.category li a`,
`.func-item a`, and `.sidebar-card div`.
- Style the example Output block so it's visually distinct from the source (subtle
border + an "Output" label), reusing existing `--bg-code`/`--border` tokens.
### 1d. Format spec page
- Create `pages/3_Documentation format.txt` (an `info` page) documenting the canonical
page template below, so the format is self-describing inside the docs.
### Canonical page template
```
:sig
<one or more real C++ signatures, exactly as declared>
:params
<name> : <what it is>
return value : <what comes back>
:content
<Usage-first prose. What it does, when to use it. 25 tight sentences.>
:example
<runnable UCE code that print()s something illustrative>
:see
><area>
<closest sibling API slugs>
```
Optional short trailing note in `:content` for membrane/PHP-JS equivalence — one line,
not a section. No `:title` unless it differs from the derived label.
### Setup (host, one-time, before content work)
```sh
ssh root@10.4.2.110 'cd /Code/uce.openfu.com/uce && mkdir -p site/doc/examples/_gen && chown -R www-data:www-data site/doc/examples/_gen && chmod 775 site/doc/examples/_gen'
```
---
## Phase 2 — Content sweep (batched by area; one area = one reviewable batch)
For each area file in `site/doc/areas/` (string, sys, types, sqlite, mysql, memcache,
session, websocket, task, time, uri, regex, ob, markup, socket, noise, runtime), bring
every listed page to the canonical template:
1. **Convert the 31 stubs** to full structured pages.
2. **Add a live `:example`** to every page missing one (≈134), each verified to render
real output.
3. **Repair `:see`** — area link + sibling links on every page; demote membrane / PHP-JS
filler to a one-line note.
4. **Cull dead pages** — remove `concat.txt` ("Removed. Not a current API") and audit
internal-only helpers (e.g. `json_consume_space`) for removal; also remove culled
slugs from the relevant `areas/*.txt`.
Per-batch bar: every touched page renders cleanly, its example produces real output,
and the suite stays green.
---
## Phase 3 — Gate
- Add a `site/tests/cli_runner.uce` regression test that renders **every** `?p=` page
and asserts HTTP 200, no error/trap marker, and (for pages with `:example`) presence
of a non-error Output block.
- Full host gate (this is the ONLY place builds/tests run — the sshfs mount is
edit-only, no WASI SDK on the client):
```sh
ssh root@10.4.2.110 'cd /Code/uce.openfu.com/uce && bash scripts/build_core_wasm.sh && bash scripts/build_linux.sh && systemctl restart uce.service && sleep 3 && bash scripts/run_cli_tests.sh --include-wasm-kill'
```
Expect the current 91 to grow by the new doc gate(s), 0 failed.
## Hard rules (non-negotiable)
- **NEVER `git commit`/push/tag.** Not pi, not its subagents, not anyone. Leave a clean
working tree and report.
- **Always run the real host gate** (`bash scripts/build_core_wasm.sh && bash
scripts/build_linux.sh && systemctl restart uce.service && ...`) and trust only its
output. `g++ -fsyntax-only` / client-side builds do NOT count — there is no WASI SDK
on the client and the doc unit must actually render.
- Sub-delegation model is exactly `gpt-5.3-codex-spark`.
- Verify the example mechanism end-to-end on the host BEFORE authoring content against
it — content written against an unproven mechanism is wasted.

674
LICENSE Normal file
View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

547
README.md
View File

@ -1,3 +1,548 @@
# uce
Udo's C++ Entry Points
## Current State
This is in the early stages of development. Don't use this for anything important!
## Overview
UCE is a PHP-inspired server-side runtime that lets you build web pages and handlers in C++ using a small `.uce` preprocessor plus a FastCGI application server.
- `.uce` pages compile to WebAssembly side modules on demand
- normal HTTP pages expose `RENDER(Request& context)`
- WebSocket pages can additionally expose `WS(Request& context)`
- local CLI/admin/test entrypoints can expose `CLI(Request& context)` and are invoked through the Unix CLI socket
- sub-rendering and components pass structured data through `context.props`
- nginx can forward normal `.uce` requests to the FastCGI socket, while WebSocket upgrade requests for `.uce` endpoints go to the built-in HTTP/WebSocket listener
- the example application tree lives under `site/`; deployments should publish app files to a normal web root such as `/var/www/html`
- you can include C++ code as much as you want, but only .uce files called via API functions and entry points will be pre-processed
- the preprocessor has two jobs:
- allow for inline HTML within C++ and the use of templating tags inside of that HTML
- convenience directive and macro parsing so UCE files don't need a lot of boiler plate
The abolition of boilerplate was a major design factor, resulting in a page as small as this:
```uce
RENDER(Request& context)
{
<>hello world</>
}
```
*The runtime is still experimental. This is not production-ready. Use at your own risk!*
## Build
Build the runtime with:
```bash
bash scripts/build_linux.sh
```
The current build expects:
- `clang++`
- `mysql_config`
- PCRE2 development headers and library (`libpcre2-dev` on Debian / Ubuntu)
- standard Linux development headers for `dl`, `pthread`, sockets, and backtrace support
- Wasmtime C API / C++ headers, defaulting to `/opt/wasmtime` or `WASMTIME_HOME`
- WASI SDK tools, defaulting to `/opt/wasi-sdk` or `WASI_SDK`, for `scripts/build_core_wasm.sh` and unit compilation
SQLite and miniz are vendored under `src/3rdparty/`; no system SQLite or zlib package is required for those helpers.
The binary is written to:
```bash
bin/uce_fastcgi.linux.bin
```
## Runtime Model
UCE pages use explicit request handlers instead of implicit globals:
- `RENDER(Request& context)` for normal HTTP rendering
- `WS(Request& context)` for inbound WebSocket messages
- `CLI(Request& context)` for local command-line/admin/test invocations through `CLI_SOCKET_PATH`
Useful related runtime patterns:
- `unit_render(String file_name)` or `unit_render(String file_name, Request& context)` to invoke another page
- `context.cfg` for request-local structured configuration
- `context.props` for invocation-local structured input such as component props
- `context.connection` for broker-owned per-WebSocket-connection state shared across `WS(Request& context)` calls
- `context.params["UCE_CLI"] == "1"` while handling a local CLI socket request
- `context.in` for the current request body, including the current WebSocket message payload inside `WS(Request& context)`
- `context.params["WS_..."]` for direct WebSocket message metadata on the request parameter map
- `context.params`, `context.get`, `context.post`, `context.cookies`, `context.session`, and `context.header` for request/response state
- `context.set_status(code[, reason])` to set the HTTP response status
Useful helpers for that data model include:
- `DValue::get_by_path("a/b/c")` for path-style config traversal without creating missing keys
- `DValue::has("key")` / `key("key")` for non-mutating child lookup, and `get_or_create("key")` when creation is intended
- `DValue::to_u64()`, `to_s64()`, `to_f64()`, `to_bool()`, and `to_stringmap()` for typed reads from structured values
- `json_encode(String)` for emitting JavaScript-safe string literals directly
- `ascii_safe_name(String)` for conservative ASCII identifier normalization
- `path_join(base, child)` for filesystem-style path assembly
- `sqlite_connect()`, `sqlite_query()`, and related helpers for embedded SQLite storage with named prepared parameters
- `zip_create()`, `zip_list()`, `zip_read()`, and `zip_extract()` for minimal ZIP archive workflows
- `gz_compress()` and `gz_uncompress()` for gzip-format byte strings
- `server_start_http()` / `server_stop()` for runtime-managed custom HTTP listeners backed by `SERVE_HTTP` handlers
- `map()`, `filter()`, `dv_filter()`, `dv_map()`, `dv_pick()`, and related helpers for route/menu/card data shaping near render code
Named component handlers are also supported:
```cpp
COMPONENT:BODY(Request& context)
{
<>
<p><?= context.props["body"].to_string() ?></p>
</>
}
```
Those are intended for sub-rendering through helpers such as `component("components/card:BODY", props, context)` rather than direct page entry.
Additional lifecycle hooks are also available on ordinary `.uce` units:
- `INIT(Request& context)` runs once when a worker instantiates that unit's wasm module
- `ONCE(Request& context)` runs once per request before the first `RENDER()`, `CLI()`, or `COMPONENT...` entrypoint from that file
CLI units can be invoked locally with the convenience wrapper or directly over HTTP-over-Unix:
```bash
scripts/uce-cli /tests/cli.uce action=echo message=hello
scripts/uce-cli --json '{"action":"echo","message":"hello"}' /tests/cli.uce
curl --unix-socket /run/uce/cli.sock http://localhost/tests/cli.uce
```
For structured CLI commands, prefer JSON POST bodies and read them with `cli_input(context)`.
## Template Output
UCE treats template parsing as one shared code-vs-literal state machine.
- `<>` and `?>` both enter literal output mode
- `</>` and `<?` both return to code mode
- the delimiter pairs are interchangeable, so either style can be used consistently or mixed locally
Inside literal output, UCE supports three inline forms:
- `<? ... ?>` to emit raw C++ statements
- `<?= expression ?>` to print HTML-escaped output
- `<?: expression ?>` to print unescaped output
Use `<?= ... ?>` by default for user-visible text. Use `<?: ... ?>` only for trusted markup or content that has already been escaped.
The parser treats C++ `//` and `/* ... */` comments as comments in both normal code and `<? ... ?>` islands, so quotes or delimiter markers inside comments do not confuse template parsing.
The preprocessing implementation is split between `src/lib/compiler.cpp` and `src/lib/compiler-parser.cpp`. `compiler.cpp` owns unit compilation and cache orchestration, while `compiler-parser.cpp` owns source rewriting and template parsing.
## Components
UCE includes a native component layer built on top of ordinary `.uce` files:
- `component(name[, props[, context]])`
- `component_render(name[, props[, context]])`
- `component_exists(name)`
- `component_resolve(name)`
Component props are passed through `context.props`.
Component names resolve:
1. as the exact file name you supplied
2. as that same name plus `.uce`
3. as those same two forms under `components/`
When you want returned component markup inside a literal block, prefer:
```cpp
<>
<div class="panel"><?: component("components/card", props, context) ?></div>
</>
```
because `<?= ... ?>` HTML-escapes the returned markup. For direct output from C++ code, use `component_render(...)`.
Components expose `COMPONENT(Request& context)` as their default entrypoint and may expose additional named handlers with `COMPONENT:NAME(Request& context)`.
The component helpers call only `COMPONENT...` handlers. A file meant purely for component use can define `COMPONENT()` without defining `RENDER()`, which keeps direct page entry and component entry cleanly separated. Inside a component file, `component(":NAME", props, context)` and `component_render(":NAME", props, context)` target another named component handler in that same file.
If the component file also defines `ONCE(Request& context)`, that hook runs once per request before the file's first component/render entrypoint. If it defines `INIT(Request& context)`, that hook runs once when the worker loads the unit.
## WebSockets
The runtime keeps the socket lifecycle in-process and exposes a low-boilerplate API to page code:
- `ws_message()`
- `ws_connection_id()`
- `ws_scope()`
- `ws_opcode()`
- `ws_is_binary()`
- `ws_connections([scope])`
- `ws_connection_count([scope])`
- `ws_send(message[, binary[, scope]])`
- `ws_send_to(connection_id, message[, binary])`
- `ws_close([connection_id])`
By default, the WebSocket scope is the current page file, so `ws_send()` queues a message for clients connected to that same `.uce` endpoint.
Each live WebSocket connection owns a broker-side `DValue` exposed to page code as `context.connection`. Mutations to that tree persist for the life of the socket and are visible on later `WS(Request& context)` calls for the same client.
The current inbound payload is available directly as `context.in`, and the runtime mirrors message metadata into `context.params` using keys such as `WS_CONNECTION_ID`, `WS_SCOPE`, `WS_CONNECTION_COUNT`, `WS_OPCODE`, `WS_MESSAGE_TYPE`, and `WS_DOCUMENT_URI`.
`ws_message()` may still be used when you want the payload through a helper API. Use `ws_opcode()` / `ws_is_binary()` to inspect the current inbound message type.
Set `binary = true` on `ws_send()` or `ws_send_to()` to queue a binary frame instead of a text frame.
The runtime accepts fragmented messages, validates reserved bits and UTF-8 for text payloads, and delivers both text and binary message frames into `WS(Request& context)`.
## Error Reporting
Unhandled exceptions and recovered fatal request signals return a `500 Internal Server Error` response with a plain-text trace instead of simply dropping the upstream connection and leaving nginx to show a generic `502`.
The demo page `site/test/error-reporting.uce` can be used to exercise:
- uncaught exception handling
- recovered `SIGABRT`
- recovered `SIGSEGV`
The current error page includes:
- request URI
- resolved script path
- generated C++ path when available
- high-level error summary
- source/generated excerpts and raw compiler output paths for template/component/unit failure modes
- signal number and name when applicable
- a native backtrace
Compile failures are also formatted with the source path, generated C++ path, compile-output artifact path, a nearby source/generated excerpt when a line can be identified, and the raw compiler output.
This recovery path currently covers normal request handling. It is not yet the universal recovery path for every runtime subsystem.
## Docs And Tests
The most current user-facing reference lives under `site/doc/`, and the demo pages live under `site/test/`. Developers coming from React, Next, or Remix should start with `site/doc/pages/coming_from_react.txt` / `/doc/index.uce?p=coming_from_react` for the concept map and starter-router notes.
Useful entry points:
- repo files:
- `site/doc/index.uce`
- `site/doc/singlepage.uce`
- `site/test/index.uce`
- published URLs:
- `/doc/index.uce`
- `/doc/singlepage.uce`
- `/test/index.uce`
Representative test pages:
- `site/test/components.uce`
- `site/test/websockets.ws.uce`
- `site/test/error-reporting.uce`
- `site/test/post-multipart.uce`
- `site/test/session.uce`
## Deploy Behind Nginx
The intended production shape is:
- nginx serves static files directly
- nginx forwards ordinary `.uce` page loads to the UCE FastCGI Unix socket
- nginx proxies WebSocket upgrade requests for `.uce` endpoints to the runtime's built-in HTTP/WebSocket listener
- systemd keeps the runtime built, started, and restarted on failure
The repository ships the pieces used for this:
- `scripts/systemd/uce.service`
- `scripts/systemd/manage-uce-service.sh`
- `etc/uce/settings.cfg`
### 1. Install build and runtime dependencies
On a Debian or Ubuntu host, start with the packages needed to build and run UCE behind nginx:
```bash
apt update
apt install -y nginx clang mariadb-client libmariadb-dev libpcre2-dev build-essential curl rsync ca-certificates
```
The exact package names may vary by distro. The important requirements are:
- `nginx`
- `clang++`
- `mysql_config`
- PCRE2 development headers and library (`libpcre2-dev` on Debian / Ubuntu)
- normal Linux development headers for threads, sockets, `dl`, and backtrace support
- Wasmtime C API / C++ headers installed at `/opt/wasmtime` or configured with `WASMTIME_HOME`
- WASI SDK installed at `/opt/wasi-sdk` or configured with `WASI_SDK`
### 2. Put the repo on the server
This README assumes the repository lives at:
```bash
/opt/uce
```
The examples below use that path for the runtime. Publish public application files under the normal web root, for example:
```bash
cd /opt/uce
mkdir -p /var/www/html
rsync -a site/ /var/www/html/
```
If you deploy somewhere else, update the systemd unit's `WorkingDirectory`, build path, and `ExecStart` path before enabling the service.
### 3. Configure `/etc/uce/settings.cfg`
The runtime reads its server settings from:
```bash
/etc/uce/settings.cfg
```
The example contains the filesystem and FastCGI settings:
```ini
BIN_DIRECTORY=/var/cache/uce/work
TMP_UPLOAD_PATH=/var/lib/uce/uploads
SESSION_PATH=/var/lib/uce/sessions
SESSION_COOKIE_SECURE=1
FCGI_SOCKET_PATH=/run/uce/fastcgi.sock
FCGI_SOCKET_MODE=0666
FCGI_PORT=9993
CLI_SOCKET_PATH=/run/uce/cli.sock
CLI_SOCKET_MODE=0600
PRECOMPILE_FILES_IN=
SITE_DIRECTORY=/var/www/html
PROACTIVE_COMPILE_CHECK_INTERVAL=60
WORKER_COUNT=4
MAX_MEMORY=16777216
SESSION_TIME=2592000
```
For nginx deployments, the most important setting is:
- `FCGI_SOCKET_PATH=/run/uce/fastcgi.sock`
That is the Unix socket nginx should use for normal `.uce` requests. `CLI_SOCKET_PATH` is for local admin/test execution through `scripts/uce-cli`; keep `CLI_SOCKET_MODE=0600` unless a trusted Unix group explicitly needs access.
`FCGI_PORT` is optional if nginx is talking to the Unix socket. Leave it set if you also want a TCP FastCGI listener, or remove it if you want the socket to be the only FastCGI entry point.
If you want WebSocket support through nginx, also make sure the built-in HTTP listener is available. The runtime currently defaults `HTTP_PORT` to `8080` even if it is not present in the config file, but it is clearer to set it explicitly:
```ini
HTTP_PORT=8080
```
Proactive compilation settings:
- `SITE_DIRECTORY=/var/www/html` tells the runtime which public web tree to scan on startup for `.uce` files when `PRECOMPILE_FILES_IN` is left empty.
- `PRECOMPILE_FILES_IN=` can override that startup scan root with a different absolute or runtime-relative directory.
- `PROACTIVE_COMPILE_CHECK_INTERVAL=60` controls how often the low-priority background compiler rechecks known `.uce` files for stale or missing wasm modules.
The runtime keeps a shared known-file registry under `BIN_DIRECTORY` and updates it as request handling discovers new `.uce` files, so proactive recompiles are not limited to the initial startup scan.
Recommended deployment notes:
- keep `HTTP_PORT` bound to localhost only at the firewall or by network policy; nginx should be the public entry point
- keep `BIN_DIRECTORY`, `TMP_UPLOAD_PATH`, and `SESSION_PATH` on writable local storage
- use `SESSION_COOKIE_SECURE=1` for HTTPS-only deployments; leave it `0` only for local/plain-HTTP development
- after editing `/etc/uce/settings.cfg`, restart `uce.service`
### 4. Install and enable the systemd service
As root, from the repository root:
```bash
scripts/systemd/manage-uce-service.sh setup
```
That script:
- installs `scripts/systemd/uce.service` as `/etc/systemd/system/uce.service`, rewriting the repository-root path in the unit to the checkout you ran it from
- installs `etc/uce/settings.cfg` to `/etc/uce/settings.cfg` if it does not already exist, likewise rewriting checkout-root paths
- reloads systemd
- enables the service at boot
- starts the runtime immediately
Useful follow-up commands:
```bash
scripts/systemd/manage-uce-service.sh status
scripts/systemd/manage-uce-service.sh restart
scripts/systemd/manage-uce-service.sh logs 200
```
The unit currently:
- uses systemd-managed runtime/state/cache roots under:
- `/run/uce`
- `/var/lib/uce`
- `/var/cache/uce`
- prepares:
- `/var/cache/uce/work`
- `/var/lib/uce/uploads`
- `/var/lib/uce/sessions`
- removes any stale `/run/uce/fastcgi.sock`
- rebuilds the runtime before start
- runs the binary from the repo root so `COMPILER_SYS_PATH` resolves correctly
### Debian package build
To build a Debian package from the repository root:
```bash
bash scripts/make_deb.sh 0.1.2
```
That script:
- rebuilds the runtime first
- stages the current runtime tree under `/usr/lib/uce`
- installs `/etc/uce/settings.cfg` as a package conffile
- installs a packaged `uce.service` under `/lib/systemd/system/`
- writes Debian maintainer scripts for systemd reload/enable handling
- follows a more PHP-like/FHS deployment shape with immutable runtime files under `/usr/lib`, config under `/etc`, cache/state under `/var`, and the FastCGI socket under `/run/uce/`
### 5. Configure nginx for `.uce` and WebSocket upgrades
Any `.uce` unit can expose `WS(Request& context)`. WebSocket upgrade requests for `.uce` paths should be routed to the runtime's HTTP/WebSocket listener.
You need two transport paths for `.uce` endpoints:
- FastCGI for ordinary `.uce` page renders
- HTTP proxying only for WebSocket upgrade traffic on `.uce` endpoints
If you use WebSockets, add this `map` in the nginx `http` block:
```nginx
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
```
Then use a server block along these lines:
```nginx
server {
listen 80;
server_name example.com;
root /var/www/html;
index index.uce index.html;
location / {
try_files $uri $uri/ =404;
}
location ~ \.uce$ {
error_page 418 = @uce_websocket;
if ($http_upgrade = "websocket") {
return 418;
}
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param DOCUMENT_URI $uri;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_pass unix:/run/uce/fastcgi.sock;
}
location @uce_websocket {
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_pass http://127.0.0.1:8080;
}
}
```
Important details:
- `fastcgi_pass` should point at the same socket path as `FCGI_SOCKET_PATH`
- `proxy_pass` should point at the runtime's `HTTP_PORT`
- ordinary `GET /page.uce` page renders should stay on FastCGI
- only upgrade requests for `/page.uce` should go through the HTTP/WebSocket listener
- `SCRIPT_FILENAME` should resolve to the requested `.uce` file on disk
- `proxy_http_version 1.1` and the `Upgrade` / `Connection` headers are required for WebSockets
- socket-capable pages are ordinary `.uce` units; route client WebSocket upgrade requests to the HTTP/WebSocket listener
The `location /` block only serves files from `/var/www/html`. If your app uses a front-controller pattern such as routing everything through `/index.uce`, change that block accordingly.
### 6. Think about document root and private files
Point nginx at `/var/www/html`, not the runtime repository root. The repo still contains source, scripts, packaging files, and operational assets that are not meant to be public.
At minimum, explicitly block internal directories that should never be served directly. For example:
```nginx
location ~ ^/(src|scripts|etc|bin|work|dist|pkg)/ {
return 404;
}
```
If nginx is rooted at `/var/www/html`, most of those paths will not be reachable anyway, which is the preferred setup.
### 7. Reload nginx and verify the deployment
After writing the nginx config:
```bash
nginx -t
systemctl reload nginx
```
Then verify:
```bash
systemctl status uce.service
curl -i http://127.0.0.1/test/index.uce
curl -i http://127.0.0.1/doc/index.uce
```
If WebSockets are enabled, also verify a `.uce` endpoint that defines `WS(Request& context)` through nginx rather than talking to the runtime directly.
### 8. Troubleshooting
Common failure modes:
- `502 Bad Gateway`
Usually means `uce.service` is down, the Unix socket path does not match, or the request crashed before sending a valid response.
- WebSocket upgrade fails
Check that nginx is routing WebSocket upgrade requests to `proxy_pass`, not `fastcgi_pass`, and that `HTTP_PORT` is reachable on localhost.
- Requests compile but immediately crash
Check `journalctl -u uce.service`. Generated units carry an ABI metadata sidecar and should be recompiled automatically after runtime ABI changes, but clearing stale artifacts under `BIN_DIRECTORY` is still a useful last-resort recovery step if the cache has been damaged manually.
- nginx serves raw source or internal files
Tighten the server root and add explicit deny rules for non-public directories.
## Repo Helpers
- `./codesearch <pattern> [rg options...]`
This is a small repo-root wrapper around `rg` that searches from the project root and skips generated/build directories such as `.git/`, `bin/`, `dist/`, and `work/`.
## Reference Notes
For up-to-date usage, prefer:
- the live docs under `site/doc/`
- the declarations in `src/lib/compiler.h`, `src/lib/sys.h`, and `src/lib/functionlib.h`
- the example pages under `site/test/`
## AI Disclosure
This project is largely human-made, with all the typical idiosyncracies of my projects clearly visible. However, OpenAI Codex was used for code review, debugging, API integration work, and documentation. Claude Opus was used for UI design work, and I used VS Code's git commit message generator.

Binary file not shown.

View File

@ -1,33 +0,0 @@
#!/bin/bash
cd "$(dirname "$0")"
BUILDMODE=${2:-"debug"}
OPT_FLAG="O2"
GF="uce_fastcgi"
if [ "$BUILDMODE" == "debug" ]; then
OPT_FLAG="O0"
fi
echo "Build mode: $BUILDMODE"
mkdir bin > /dev/null 2>&1
mkdir bin/tmp > /dev/null 2>&1
mkdir bin/assets > /dev/null 2>&1
mkdir work > /dev/null 2>&1
COMPILER="clang++"
FLAGS="-g -rdynamic -w -Wall -$OPT_FLAG -std=c++17 -fpermissive -ffast-math"
LIBS="-ldl -lm -lpthread `mysql_config --cflags --libs`"
SRCFLAGS="-D EXEC_NAME=\"$GF\" -D PLATFORM_NAME=\"linux\""
echo "Compliling executable..."
time -p $COMPILER src/linux_fastcgi.cpp $SRCFLAGS $FLAGS $LIBS -o bin/$GF.$BUILDMODE.linux.bin 2>&1
if [ $? -eq 0 ]
then
ls -lh bin/ | grep $GF
exit 0
else
exit 1
fi

15
changelog/2022-01-21.log Normal file
View File

@ -0,0 +1,15 @@
commit ad3d65cdacdcc5aed72fe12354f66190d7be454d
Initial commit
commit c047927b189860220428b42400ed18942150882c
initial import
commit 3e8f0f1fa780da7836128fdbc39bbe8c2ba97de8
initial import
commit 939009f9a11d0934226c830375057491f088d362
shell stuff, preprocessor directive

4
changelog/2022-01-28.log Normal file
View File

@ -0,0 +1,4 @@
commit 18ca2368bc1d4a5ef7e4c8470a9b3e32f496fc86
VERY basic UTF8 parser

12
changelog/2022-01-30.log Normal file
View File

@ -0,0 +1,12 @@
commit 17336fe649c52c162a4541968c8d24c0c2ab3eb9
Unicode stuff
commit 5df52146be3f5a45759459d5716aec4ef8d3c33a
split_space
commit 3a9dfba86cb7dadb1268fcfd689b14066779e6aa
fixed bug in #load

4
changelog/2022-01-31.log Normal file
View File

@ -0,0 +1,4 @@
commit 0a6ebc60f0b8aacf8b01e14bd9b6447c750edeb5
precompile on startup

14
changelog/2022-02-11.log Normal file
View File

@ -0,0 +1,14 @@
commit 6f6919f3f01686175001251e2fca215bccc4806f
backage builder
commit defc628204f95d0cdd16c95c89ea30efe922b31a
packaging
commit 9e5b7d39e3b8be9f4ad537a134b1081564ae4abc
Basic readme
commit 21fdeafb6c5b8bc80a9d93ed61c36e05fbe7b267
Basic documentation

8
changelog/2022-04-18.log Normal file
View File

@ -0,0 +1,8 @@
commit 364d83b199afa6a341173a80791060a42c169f0c
doc update
commit 392b7224b16e41198b0425c5ae04f46e014e78c7
Merge branch 'main' of github.com:ThingamaNet/uce

4
changelog/2022-12-22.log Normal file
View File

@ -0,0 +1,4 @@
commit 984453f336a9b2ad47689d161c89d7020006f75a
update sigh

26
changelog/2026-04-18.log Normal file
View File

@ -0,0 +1,26 @@
commit cd8f07aaa78fc488eba3b0e435350e5c2823e53e
Refactor FastCGI server and compiler, enhance HTTP header parsing, and add WebSocket support
- Refactored FastCGIServer class to improve socket handling and added shutdown functionality.
- Updated compiler functions to streamline HTML and text literal processing.
- Enhanced split_kv function to support uppercase keys and added split_http_headers for better HTTP header parsing.
- Introduced new session management functions to validate and handle session IDs.
- Added WebSocket frame parsing and handling in the URI module.
- Created systemd service scripts for easier deployment and management of the UCE FastCGI runtime.
- Added new test cases for header handling, time parsing, and WebSocket functionality.
commit 86dc93864e8eab9227ac50b16f1fc7f561383f5b
Add WebSocket support and enhance chat functionality
- Implement WebSocket handling in the FastCGI server, allowing for real-time communication.
- Introduce functions for managing WebSocket connections, broadcasting messages, and sending to specific connections.
- Create a chat interface in the `websockets.ws.uce` file, including message handling and user notifications.
- Refactor existing code to accommodate WebSocket integration, ensuring compatibility with HTTP requests.
- Update documentation to reflect new features and usage instructions for WebSocket functionality.
commit 46d98a092fb606c87ab4b9eef32fe68eeca2b2cb
Enhance WebSocket support: add opcode handling, binary message support, and improve connection validation

20
changelog/2026-04-19.log Normal file
View File

@ -0,0 +1,20 @@
commit be514d63d6ed709a40441db9dc809837081d54f6
trying to port web app starter from PHP
commit 2b5586d7dfffc5c1c40cac97e6d4d0e1f86f151a
decided in favor of dedicated COMPONENT() macro, updates to documentation
commit d1167aec3b4d7870db0b289ee0ea690f8e7e5cc9
getting closer to full port of web app starter
commit af642c8167383f9acf99274d3b3c94017d860dcf
getting closer to full port of web app starter
commit dc05f9faa5eab980f1f1fd44cee06f811cc748ff
PHP familiarity shortcuts

9
changelog/2026-04-20.log Normal file
View File

@ -0,0 +1,9 @@
commit b53eb6e4f1b5fa4e2a4907022f591eb9a1860c33
Enhance template parser to handle C++ comments and refactor preprocessing logic
- Updated parser to correctly interpret C++ `//` and `/* ... */` comments within template code.
- Split preprocessing implementation into separate files for better organization.
- Added regression test for comment parsing in templates.
- Adjusted CSS styles for improved layout and readability in documentation.

16
changelog/2026-04-22.log Normal file
View File

@ -0,0 +1,16 @@
commit 8223dcc6b3cb7f4d26c69097fac973c2671f0938
I think I need to change the documentation format
commit f7b066b374f1031d38e3d2b344f6680534c3a2b2
changing doc format and HTML literals
commit 14ebf10a229021bb5d0fb1eae42a69c042699318
changing doc format and HTML literals
commit 223cf4c6e1c7a205bf1a27bebdc6d04fd7557df0
website with slop placeholders

4
changelog/2026-04-28.log Normal file
View File

@ -0,0 +1,4 @@
commit cd445f3c9b6aa079a969351d6eb742b8a4d24f6b
some cleanup

4
changelog/2026-04-29.log Normal file
View File

@ -0,0 +1,4 @@
commit 9f7625c7fdd6a9d2a184dc2cdf9f8a719d219ec2
working on documentation and more API functions

24
changelog/2026-05-21.log Normal file
View File

@ -0,0 +1,24 @@
commit 02e153a6a78bf8ded1c7380713023b4f9c3b656f
Add archive helpers and harden task runtime
commit d37517041de0c5ebe4dfd232093a78ff49cff383
Add custom server API and runtime limits
commit 0d8b74930c74cc8018cb1c0cfc7cfe6740b49cf6
Harden HTTP path headers sessions and archives
commit 41e9ca219fd684c75e78a5493e20c754c7899105
Streamline hardening helpers and expand coverage
commit 8b37e7ea1e58e36c97852f79ec121947a1ffea08
Fix direct HTTP status sanitizer fallback
commit 71ddcaf7d48ffd1343e597e4715b570c922a306c
Consolidate config and base64 helpers

12
changelog/2026-06-11.log Normal file
View File

@ -0,0 +1,12 @@
commit 7f757654b658d049564f1725f54fde781575e304
fix: harden UCE runtime and starter
commit 20db6695890a3ac274217fd0ed9e0edf7c5eb093
fix: stabilize runtime follow-up regressions
commit b957a2373b8464ffcb7791cc6b0031c441d5b09c
chore: ignore Python cache artifacts

28
changelog/2026-06-12.log Normal file
View File

@ -0,0 +1,28 @@
commit 941f5aea08941327eecbc43128d8f171a4064616
feat: add configurable UCE error pages
commit 7066da3cdef08b01dda64bca34caadc7000587b2
refactor: rename DTree to DValue
commit 7e2faf1472c84f302ce5b7f9674091a1a2b3930f
spike: validate WASM phase 0
commit 80285b7fb4acd15850218ee87c72ec8272332c05
feat: implement WASM phase 1 DValue ABI
commit 961df2d542ff6554e32da9ee28e73f5fc59b5975
phase 5
commit 89b5499c8f4e1a8acc8748e66c9dba9eb9679369
fix: harden WASM phase 5 harness
commit eb8f303f94f0f43699eca7cd6474eedaef1ed711
docs: remove unsupported second-plane language roadmap

36
changelog/2026-06-13.log Normal file
View File

@ -0,0 +1,36 @@
commit 577aae076e3603137265332adfdded3c15cfa8f4
W3
commit afaa4dd7c0203f322d625593a0d1c96c37130005
feat: cut over to WASM backend
commit 5a56d4f39e4b30a9a4e43985d64906aa16a642e6
W5
commit c84fc86e6cdfe254a59d57b909f647e6c254ef76
W6
commit fe83c524118722c062295bc9575cb71eff64dacb
feat: membrane remaining wasm host surfaces
commit d6421cb8f3721e69e999b84335e9094ad96356e9
feat: extend wasm backend entrypoints
commit af6500d1343581abdac475dcb6855821afd8c8d0
fix: harden wasm w7 entrypoint paths
commit b1856c1725970b31027383a7ae79c2140a62a896
chore: narrow wasm backend entrypoint API
commit 6bb4f7f0ad801a0127956f49e54d2be722c6537f
test: port network suite to uce cli runner

111
changelog/2026-06-14.log Normal file
View File

@ -0,0 +1,111 @@
commit 15e8d092bc13c425b5c7f7a19dfaf3c9728104f5
W7+
commit 8587fbc5aa0f38739182fa50383bb94c8d821ed7
wasm runtime: central WS broker, unified handlers, W7d holdouts, membrane completeness
- WS: a dedicated broker process owns HTTP_PORT + every connection; it forwards
renders to the worker pool over uce.sock (non-blocking) and applies ws_*
command batches flushed back at workspace teardown. Removes the now-dead
per-worker websocket executor (-509 lines).
- Dispatch: unify CLI / WebSocket / serve_http / page render through one
serve_via_wasm(entry_unit, handler) path; handler string -> __uce_<handler>
export symbol.
- W7d: rewrite zip.uce to the membrane return-value error contract (no C++
try/catch), error-reporting.uce to genuine wasm traps instead of throw, and
sharedunit.uce to unit_info(); empty the native-only token gate.
- Membrane: wire ls / mkdir / file_mtime through new uce_host_file_list /
uce_host_file_mkdir / uce_host_file_mtime hostcalls (resolve_guest_file gains
directory support). Fixes /doc/index.uce listing nothing; adds a regression
assertion that the index enumerates items.
- Docs: add docs/wasm-runtime-architecture.md; record the W7e staged native-
deletion plan in WASM-PROPOSAL.md.
commit 2debd338040cf97e82bb8ccbb5ec09caee089c17
W7e: wasm-preferred dispatch + compile-on-demand; harden unit ABI validator
- Dispatch (linux_fastcgi.cpp): route every request through wasm. On a
cold/stale artifact, compile the unit on demand (get_shared_unit, forced) and
serve wasm; native compiler_invoke* remains only as a fallback when wasm
cannot be made ready (compile failure / backend disabled). Applies to the 4
handle_complete branches and the CLI socket path.
- backend.cpp: delete the now-vestigial native-only fallback token gate
(wasm_backend_native_fallback_*), empty since W7d; should_handle now gates on
config + current artifact + healthy worker only.
- check_unit_wasm.py: skip the defense-in-depth llvm-nm allocator scan when
llvm-nm SIGSEGVs on a degenerate-but-valid module (e.g. a unit with no
exported handlers). Fixes site/demo/empty.uce, the last unit that could not
produce a .wasm; forbidden allocator *exports* are still rejected.
A pi-assisted review caught that the compile-freshness check keys off the .so
mtime only, so force_recompile is required to rebuild a missing/stale .wasm; a
unit already cached in-process whose .wasm later vanished still uses native
fallback (closed in W7e stage B). Native execution is otherwise bypassed for
all real traffic.
commit fb728d63bcd0d80bd5161537e81c30d27eb4df7b
W7e stage B: factor the .wasm artifact into unit compile-freshness
inspect_shared_unit_filesystem() tracked only the .so mtime, so a missing or
stale .wasm with a current .so never triggered a rebuild and the unit fell to
native indefinitely (the in-process cache also never invalidated). Account for
su->wasm_name when wasm unit compilation is enabled: a unit counts as compiled
only as of the OLDER of the two artifacts; a missing .wasm forces a recompile.
Closes the cached-vanished-.wasm gap noted in the stage A review.
commit cf513368730e5f337e64a9c9f1456e6a64f49d9c
W7e: delete the native unit pipeline (.so compile + dlopen execution)
Units now run exclusively on wasm; the native generated-C++ -> clang -> .so ->
dlopen path and its request-time fallback are removed.
- Dispatch (linux_fastcgi.cpp): the 4 handle_complete branches + the CLI-socket
path route every request through wasm (wasm_ready compiles cold/stale on
demand); a wasm-unavailable unit now yields a clean error page
(fail_wasm_unavailable / render_request_failure) instead of native execution.
compiler_invoke / _cli / _websocket / _serve_http deleted.
- compiler.cpp (-1274): removed the native .so compile (COMPILE_SCRIPT),
load_shared_unit, dlopen/dlsym/dlclose, compiler_load_shared_unit, and the
SharedUnit .so function-pointer fields (on_setup/on_render/on_component/
on_websocket/on_cli/on_once/on_init) in types.h/types.cpp. compile_shared_unit
now builds only the .wasm side-module; the .uce preprocessor/parser front-end
is kept (it emits the C++ the wasm compile consumes).
- unit_call()/component()/once/init now resolve across units through the wasm
host component resolver (uce_host_component_resolve) instead of native dlsym;
configured runtime error pages render through the wasm backend.
- Dropped the WASM_BACKEND_ENABLED feature flag and dead COMPILE_SCRIPT /
COMPILE_WASM_UNITS config; unit ABI freshness tied to UCE_UNIT_ABI_VERSION;
guard against serving a stale .wasm for a deleted source; retired the obsolete
W5 native-vs-wasm toggle script. Docs updated.
commit bfd6d338299dd9001fe2d4a66f82bbc2b3b07ed9
W7f: sweep dead/legacy/fallback leftovers after native-pipeline removal
Post-deletion cleanup (units run only on wasm):
- types.h/compiler.cpp: drop the native-era SharedUnit fields so_name,
bin_file_name, and the opt_so_optional cache-mode plumbing (no native
optional .so path remains). The per-unit compile lock is re-keyed from
so_name+.lock to wasm_name+.lock (still per-unit).
- unit_info() and to_string(SharedUnit*) no longer expose .so artifact fields.
- backend.h: drop the stale "+ fallback-token gate" comment.
- Docs/comments corrected to wasm-only reality: README, tests/README,
site/doc C++ preprocessor + error_pages + unit_info pages, site/info intro,
site/demo/unit-browser artifact card; the Phase-5 native-vs-wasm benchmark
harness (tests/wasm_benchmark.py) reframed for the wasm-only backend.
Audit confirmed no live references remain to so_handle, load_shared_unit,
compiler_load_shared_unit, compiler_invoke*/_cli/_websocket/_serve_http,
COMPILE_SCRIPT/COMPILE_WASM_UNITS, or the native export-symbol constants;
request_ref_handler/dv_call_handler are kept (live wasm funcref casts).
Swept via the pi agent (delegated to a gpt-5.3-codex-spark sub-model);
independently re-verified on the host: run_cli_tests --include-wasm-kill =>
87 passed, 0 failed, 0 skipped.

58
changelog/2026-06-15.log Normal file
View File

@ -0,0 +1,58 @@
commit 560290ca1d18d4d5a0d204bb187d1aa68c3b5ac7
perf: cache the compiled core module so fresh workers deserialize, not recompile
Workers recycle every 8 requests (calls_until_termination=8). Each fresh worker
ran wasmtime::Module::compile() on the 6.8MB bin/wasm/core.wasm — a ~1.3s
Cranelift JIT — on its first request, so every ~8th request spiked to ~1.3s and
dominated suite wall-clock.
Cache the compiled artifact: on worker core-module load, if bin/wasm/core.cwasm
exists and is newer than core.wasm, load it via Module::deserialize_file() (mmap,
~ms); otherwise Module::compile() as before and atomically (temp+rename) write
the serialized artifact for the next worker. Deserialize failure / stale cache
falls back to a normal compile, so it is self-healing; rebuilding core.wasm
(newer mtime) invalidates the cache. Engine config (epoch_interruption,
signals_based_traps(false)) is unchanged, which the serialized format requires.
commit 83ab9e10f7c0f17805e40a9a3d2b4a3357e5280f
perf: extend the compiled-module disk cache to per-unit modules
Follow-up to 560290c. Per-unit .wasm modules were still Cranelift-compiled per
worker on first use (~40-70ms each), so with 8-call worker recycling fresh
workers re-JIT every unit they touch.
Refactor the core cache logic into a shared WasmWorker helper:
- cached_wasm_path(p): maps <...>.wasm -> <...>.cwasm.
- load_or_compile_cached_module(engine, cached, wasm, bytes, err): deserialize_file
the .cwasm when it is newer than the .wasm; otherwise Module::compile + serialize,
written atomically (temp+rename); deserialize failure falls back to compile.
Both the core module load and unit_module() now go through this helper, so unit
artifacts get the same <unit>.uce.cwasm cache the core got.
commit 4f84ac544d9c91a66d068d372055eec8e1723def
feat: request_perf() worker-side timing hostcall; restore demo System Info
Units run in the wasm sandbox, so my_pid/parent_pid/context.server->request_count
read as sandbox stubs — the demo System Info counters were broken, and there was
no authoritative server-side request timing available to unit code (client-side
measurement cannot see queue/dispatch latency).
Add a request_perf() unit API backed by a new uce_host_request_perf hostcall.
The native worker answers it live, returning a DValue:
worker_pid, parent_pid, request_count,
accept_us = (time_start - time_init)*1e6 (entry -> dispatch wait),
running_us = (now - time_start)*1e6 (since dispatch, live),
total_us = (now - time_init)*1e6 (since the request entered UCE),
workspace_birth_us.
time_init is captured at request entry (handle_request, with a handle_complete
fallback); a RequestPerfSnapshot {pids, request_count, time_init, time_start} is
threaded from wasm_backend_serve through wasm_worker_serve onto the workspace,
and the hostcall computes the live deltas at call time. Wired like uce_host_units
(sized DValue hostcall): core_hostcalls.syms + sys.cpp/sys.h request_perf().
site/demo/index.uce System Info now uses request_perf() and shows the real worker
PID, an incrementing per-worker request count, and the timing counters.

58
codesearch Executable file
View File

@ -0,0 +1,58 @@
#!/bin/bash
set -euo pipefail
cd "$(dirname "$0")"
show_help() {
cat <<'EOF'
Usage:
./codesearch <pattern> [rg options...]
Examples:
./codesearch "ws_send"
./codesearch "RENDER\\(Request& context\\)"
./codesearch -tcpp "compiler_invoke"
./codesearch -g '*.uce' "context.call"
Notes:
- This is a thin wrapper around ripgrep (`rg`).
- It searches from the repository root.
- Generated/build directories are excluded by default:
`.git/`, `bin/`, `dist/`, and `work/`.
EOF
}
if [[ $# -eq 0 ]]; then
show_help
exit 1
fi
case "${1:-}" in
-h|--help|help)
show_help
exit 0
;;
esac
if command -v rg >/dev/null 2>&1; then
exec rg \
--line-number \
--column \
--smart-case \
--glob '!.git/**' \
--glob '!bin/**' \
--glob '!dist/**' \
--glob '!work/**' \
"$@"
fi
pattern="$1"
shift || true
echo "ripgrep (rg) is not installed; falling back to grep." >&2
exec grep -RIn \
--exclude-dir=.git \
--exclude-dir=bin \
--exclude-dir=dist \
--exclude-dir=work \
-- "$pattern" .

View File

@ -1,6 +0,0 @@
Output Buffer Functions
ob_clear
ob_get
ob_get_clear
ob_start

View File

@ -1,10 +0,0 @@
String Functions
filter
first
join
nibble
split
str_to_lower
str_to_upper
trim

View File

@ -1,17 +0,0 @@
File System Functions
basename
dirname
expand_path
file_append
file_exists
file_get_contents
file_mtime
file_put_contents
get_cwd
ls
mkdir
set_cwd
shell_escape
shell_exec
unlink

View File

@ -1,7 +0,0 @@
Time and Date Functions
microtime
time
date
gmdate
parse_time

View File

@ -1,7 +0,0 @@
URI Functions
encode_query
make_session_id
parse_query
uri_decode
uri_encode

View File

@ -1,150 +0,0 @@
void render_see_section(String name)
{
StringList lines = split(file_get_contents("areas/"+name+".txt"), "\n");
s32 idx = 0;
for(auto line : lines)
{
if(idx == 0)
{
<><h3><?= line ?></h3><ul></>
}
else if(line != "")
{
<><li><a href="index.uce?p=<?= line ?>"><?= line ?><span style="opacity:0.5">()</span></a></li></>
}
idx += 1;
}
<></ul></>
}
RENDER()
{
String page = first(context->get["p"], "index");
<><html>
<head>
<link rel="stylesheet" href='style.css?v=<?= time() ?>'></link>
</head>
<body>
<h1>
<a href="index.uce">UCE Docs</a>:
<?= page ?>
</h1>
<?
if(page == "index")
{
?><div style="display:flex;"><?
?><div style="flex:1"><?
?><h3>All API Functions</h3><?
for(auto file_name : ls("pages/"))
{
String ft = nibble(file_name, ".");
if(ft[1] == '_')
{
String fn = ft;
String pre = nibble(fn, "_");
?>
<div><a href="?p=<?= ft ?>"><?= fn ?></a><span style="opacity:0.5"> : struct</span></div>
<?
}
else
{
?>
<div><a href="?p=<?= ft ?>"><?= ft ?><span style="opacity:0.5">()</span></a></div>
<?
}
}
?></div><?
?><div style="flex:1"><?
for(auto file_name : ls("areas/"))
{
String ft = nibble(file_name, ".");
render_see_section(ft);
}
?></div><?
?></div><?
}
else
{
auto doc = split(file_get_contents("pages/"+page+".txt"), "\n");
String layout_class = "text";
u32 line_idx = 0;
for(auto s : doc)
{
line_idx++;
if(s == "")
{
}
else if(s.substr(0, 1) == ":")
{
layout_class = s.substr(1);
if(line_idx > 1)
{
?></div><?
}
?><div class="<?= layout_class ?>"><?
if(layout_class == "params")
{
?><h3>Parameters</h3><?
}
else if(layout_class == "sig")
{
?><h3>Signature</h3><?
}
else if(layout_class == "pre")
{
layout_class = "sig";
}
else if(layout_class == "desc")
{
?><h3>Description</h3><?
}
else if(layout_class == "see")
{
/*?><h3>Related</h3><?*/
}
else
{
?><h3><?= layout_class ?></h3><?
}
}
else
{
if(s.substr(0, 1) == "-")
{
nibble(s, "-");
?><li><?= (s) ?></li><?
}
else if(layout_class == "params")
{
?><div><b><?= trim(nibble(s, ":")) ?></b> : <?= trim(s) ?></div><?
}
else if(layout_class == "see")
{
if(s[0] == '>')
{
render_see_section(s.substr(1));
}
else
{
?><div><a href="index.uce?p=<?= trim(s) ?>"><?= trim(s) ?><span style="opacity:0.5">()</span></a></div><?
}
}
else
{
?><div><?= (s) ?></div><?
}
}
}
}
?>
</body>
</html></>
}

View File

@ -1,63 +0,0 @@
:sig
Request* context;
:ServerState* server
Contains the current server state
:StringMap params
All FastCGI server parameters
:StringMap get
The current request's GET variables
:StringMap post
The current request's POST variables
:StringMap cookies
Cookies that have been transmitted by the browser
:StringMap session
The current session
:String session_id
ID of the session cookie
String session_name
Name of the session cookie
:DTree var
Variable user-defined data
:std::vector<UploadedFile> uploaded_files
Files that have been uploaded in the current request
:StringMap header
Headers to be sent back to the browser
:StringList set_cookies;
Cookies that should be sent back to the browser
:u64 random_seed
The current request's "random" noise generator seed
:u64 random_index
The current request's "random" noise generator index position
:MemoryArena* mem
Contains the current request's memory arena
:bool flags.log_request
Whether the request should be logged
:Stats
u32 stats.bytes_written
f64 stats.time_init
f64 stats.time_start
f64 stats.time_end
:invoke(String file_name, [DTree& call_param])
Invokes the UCE file 'file_name'

View File

@ -1,12 +0,0 @@
:sig
String basename(String fn)
:params
fn : raw filename
return value : the file's name
:desc
Isolates the file name component from a path/file name.
:see
>sys

View File

@ -1,125 +0,0 @@
:sig
String date(String format = "", u64 timestamp = 0)
:params
format : formatting string specifying the date format
timestamp : optional timestamp value, defaults to current time
return value : a formatted date
:desc
Returns a formatted date. This is based on the Linux date() command. The formatting string supports the following sequences:
:pre
%% a literal %
%a locale's abbreviated weekday name (e.g., Sun)
%A locale's full weekday name (e.g., Sunday)
%b locale's abbreviated month name (e.g., Jan)
%B locale's full month name (e.g., January)
%c locale's date and time (e.g., Thu Mar 3 23:05:25 2005)
%C century; like %Y, except omit last two digits (e.g., 20)
%d day of month (e.g., 01)
%D date; same as %m/%d/%y
%e day of month, space padded; same as %_d
%F full date; like %+4Y-%m-%d
%g last two digits of year of ISO week number (see %G)
%G year of ISO week number (see %V); normally useful only
with %V
%h same as %b
%H hour (00..23)
%I hour (01..12)
%j day of year (001..366)
%k hour, space padded ( 0..23); same as %_H
%l hour, space padded ( 1..12); same as %_I
%m month (01..12)
%M minute (00..59)
%n a newline
%N nanoseconds (000000000..999999999)
%p locale's equivalent of either AM or PM; blank if not known
%P like %p, but lower case
%q quarter of year (1..4)
%r locale's 12-hour clock time (e.g., 11:11:04 PM)
%R 24-hour hour and minute; same as %H:%M
%s seconds since 1970-01-01 00:00:00 UTC
%S second (00..60)
%t a tab
%T time; same as %H:%M:%S
%u day of week (1..7); 1 is Monday
%U week number of year, with Sunday as first day of week
(00..53)
%V ISO week number, with Monday as first day of week (01..53)
%w day of week (0..6); 0 is Sunday
%W week number of year, with Monday as first day of week
(00..53)
%x locale's date representation (e.g., 12/31/99)
%X locale's time representation (e.g., 23:13:48)
%y last two digits of year (00..99)
%Y year
%z +hhmm numeric time zone (e.g., -0400)
%:z +hh:mm numeric time zone (e.g., -04:00)
%::z +hh:mm:ss numeric time zone (e.g., -04:00:00)
%:::z numeric time zone with : to necessary precision (e.g.,
-04, +05:30)
%Z alphabetic time zone abbreviation (e.g., EDT)
By default, date pads numeric fields with zeroes. The following
optional flags may follow '%':
- (hyphen) do not pad the field
_ (underscore) pad with spaces
0 (zero) pad with zeros
+ pad with zeros, and put '+' before future years with >4
digits
^ use upper case if possible
# use opposite case if possible
:see
>time

View File

@ -1,12 +0,0 @@
:sig
String dirname(String fn)
:params
fn : raw filename
return value : the directory's name
:desc
Isolates the directory name component from a path/file name.
:see
>sys

View File

@ -1,13 +0,0 @@
:sig
f64 draw_float(f64 from, f64 to)
:params
from : minimum value
to : maximum value
return value : a noise value between 'from' and 'to'
:desc
This function works exactly like generate_float(), but context->random_index is used for the 'index' value and context->random_seed is used for the seed. After this function has been called, the context->random_index is increased by one. At the start of every request, context->random_seed is automatically populated with a new seed value.
:see
>noise

View File

@ -1,13 +0,0 @@
:sig
u64 draw_int(u64 from, u64 to)
:params
from : minimum value
to : maximum value
return value : a noise value between 'from' and 'to'
:desc
This function works exactly like generate_int(), but context->random_index is used for the 'index' value and context->random_seed is used for the seed. After this function has been called, the context->random_index is increased by one. At the start of every request, context->random_seed is automatically populated with a new seed value.
:see
>noise

View File

@ -1,12 +0,0 @@
:sig
String encode_query(StringMap map)
:params
q : StringMap containing URL parameters to be encoded
return value : a string with the encoded parameters
:desc
Encodes a StringMap containing URL parameters into a single String.
:see
>uri

View File

@ -1,12 +0,0 @@
:sig
String expand_path(String path)
:params
path : a relative path
return value : expanded version of the 'path'
:desc
Converts a relative path name into an absolute path, using the current working directory as a base.
:see
>sys

View File

@ -1,12 +0,0 @@
:sig
void file_append(String file_name, ...val)
:params
file_name : file name of file that should be written to
...val : one or more values that should be written into the file
:desc
Opens or creates a given file and appends data to it.
:see
>sys

View File

@ -1,12 +0,0 @@
:sig
bool file_exists(String path)
:params
path : the path name to be checked
return value : true if the file exists
:desc
Checks whether the file or path specified by 'path' exists.
:see
>sys

View File

@ -1,12 +0,0 @@
:sig
String file_get_contents(String file_name)
:params
file_name : file name of file that should be read
return value : String containing the file's contents
:desc
Reads the file identified by 'file_name' and returns it as a String. If the file cannot be read, this function will return an empty string.
:see
>sys

View File

@ -1,13 +0,0 @@
:sig
time_t file_mtime(String file_name)
:params
file_name : name of the file
return value : Unix time stamp of the file's last modification
:desc
Retrieves the last modification date of 'file_name' as a Unix timestamp.
:see
>sys
>time

View File

@ -1,13 +0,0 @@
:sig
bool file_put_contents(String file_name, String content)
:params
file_name : file name of file that should be written
content : content that should be written
return value : true if write was successful
:desc
Writes the String 'content' into a file identified by 'file_name'. Any pre-existing content of the file will be overwritten.
:see
>sys

View File

@ -1,14 +0,0 @@
:sig
StringList filter(StringList items, function<bool (String)> f)
vector<T> filter(vector<T> items, function<bool (T)> f)
:params
items : list of items to be filtered
f : a function that decides which items should be in the new list
return value : a new list
:desc
Returns a list containing the members of 'items' for which 'f' returned boolean true.
:see
>string

View File

@ -1,12 +0,0 @@
:sig
String first(String... args)
:params
args : a variable number of String arguments
return value : first of the 'args' that was not empty.
:desc
Given a variable number of String parameters, the first() function returns the first of these parameters that was not empty. Leading and trailing whitespace characters are not considered, resulting in a string that contains only whitespace characters being considered empty.
:see
>string

View File

@ -1,16 +0,0 @@
:sig
f64 generate_float(f64 from, f64 to, u64 index, u64 seed = 0)
:params
from : minimum result
to : maximum result
index : index position to generate number from
seed : seed position to generate number from (defaults to 0)
return value : noise value
:desc
Generates a noise value between 'from' and 'to', given the 'index' and 'seed' numbers.
:see
>noise

View File

@ -1,16 +0,0 @@
:sig
u64 generate_int(u64 from, u64 to, u64 index, u64 seed = 0)
:params
from : minimum result
to : maximum result
index : index position to generate number from
seed : seed position to generate number from (defaults to 0)
return value : noise value
:desc
Generates a noise value between 'from' and 'to', given the 'index' and 'seed' numbers.
:see
>noise

View File

@ -1,13 +0,0 @@
:sig
u32 noise01(u64 index, u64 seed = 0)
:params
index : index position
seed : seed set (defaults to 0)
return value : a noise value from 0 to 1
:desc
Generates a noise value in the range from 0 to 1 for the given 'index' and 'seed' values.
:see
>noise

View File

@ -1,13 +0,0 @@
:sig
u32 noise32(u32 index, u32 seed = 0)
:params
index : index position
seed : seed set (defaults to 0)
return value : a noise value given the 'index' and 'seed' values.
:desc
Generates a noise value for the given 'index' and 'seed' values.
:see
>noise

View File

@ -1,13 +0,0 @@
:sig
u32 noise64(u64 index, u64 seed = 0)
:params
index : index position
seed : seed set (defaults to 0)
return value : a noise value given the 'index' and 'seed' values.
:desc
Generates a noise value for the given 'index' and 'seed' values.
:see
>noise

View File

@ -1,10 +0,0 @@
:sig
String sha1(String s, bool as_binary = false)
:params
s : data to be hashed
as_binary : when set to false, returns hash in hexadecimal notation (defaults to false)
return value : the resulting hash value
:desc
Returns the sha1 hash of 's'.

View File

@ -1,125 +0,0 @@
:sig
String gmdate(String format = "", u64 timestamp = 0)
:params
format : formatting string specifying the date format
timestamp : optional timestamp value, defaults to current time
return value : a formatted date
:desc
Returns a formatted date in the GMT/UTC timezone. This is based on the Linux date() command. The formatting string supports the following sequences:
:pre
%% a literal %
%a locale's abbreviated weekday name (e.g., Sun)
%A locale's full weekday name (e.g., Sunday)
%b locale's abbreviated month name (e.g., Jan)
%B locale's full month name (e.g., January)
%c locale's date and time (e.g., Thu Mar 3 23:05:25 2005)
%C century; like %Y, except omit last two digits (e.g., 20)
%d day of month (e.g., 01)
%D date; same as %m/%d/%y
%e day of month, space padded; same as %_d
%F full date; like %+4Y-%m-%d
%g last two digits of year of ISO week number (see %G)
%G year of ISO week number (see %V); normally useful only
with %V
%h same as %b
%H hour (00..23)
%I hour (01..12)
%j day of year (001..366)
%k hour, space padded ( 0..23); same as %_H
%l hour, space padded ( 1..12); same as %_I
%m month (01..12)
%M minute (00..59)
%n a newline
%N nanoseconds (000000000..999999999)
%p locale's equivalent of either AM or PM; blank if not known
%P like %p, but lower case
%q quarter of year (1..4)
%r locale's 12-hour clock time (e.g., 11:11:04 PM)
%R 24-hour hour and minute; same as %H:%M
%s seconds since 1970-01-01 00:00:00 UTC
%S second (00..60)
%t a tab
%T time; same as %H:%M:%S
%u day of week (1..7); 1 is Monday
%U week number of year, with Sunday as first day of week
(00..53)
%V ISO week number, with Monday as first day of week (01..53)
%w day of week (0..6); 0 is Sunday
%W week number of year, with Monday as first day of week
(00..53)
%x locale's date representation (e.g., 12/31/99)
%X locale's time representation (e.g., 23:13:48)
%y last two digits of year (00..99)
%Y year
%z +hhmm numeric time zone (e.g., -0400)
%:z +hh:mm numeric time zone (e.g., -04:00)
%::z +hh:mm:ss numeric time zone (e.g., -04:00:00)
%:::z numeric time zone with : to necessary precision (e.g.,
-04, +05:30)
%Z alphabetic time zone abbreviation (e.g., EDT)
By default, date pads numeric fields with zeroes. The following
optional flags may follow '%':
- (hyphen) do not pad the field
_ (underscore) pad with spaces
0 (zero) pad with zeros
+ pad with zeros, and put '+' before future years with >4
digits
^ use upper case if possible
# use opposite case if possible
:see
>time

View File

@ -1,13 +0,0 @@
:sig
String html_escape(String s)
:params
s : string to be escaped
return value : an HTML-safe escaped version of 's'
:desc
Returns a version of the input string where the following characters have been replace by HTML entities:
- & → &amp
- < → lt;
- > → &gt;
- " → &quot;

View File

@ -1,11 +0,0 @@
:sig
u64 int_val(String s, u32 base = 10)
:params
s : string to be converted
base : number system base (default 10)
return value : a u64 containing the number (0 if no number could be identified).
:desc
Extracts an integer from a String.

View File

@ -1,13 +0,0 @@
:sig
String join(StringList l, String delim = "\n")
:params
l : list of strings to be joined
delim : delimiter (defaults to newline character)
return value : a string containing items joined by 'delim'
:desc
Joins the items contained in 'l' into a single String.
:see
>string

View File

@ -1,10 +0,0 @@
:sig
DTree json_decode(String s)
:params
s : string containing JSON data
return value : a DTree object containing the deserialized JSON data
:desc
Deserializes 's' into a DTree structure.

View File

@ -1,10 +0,0 @@
:sig
String json_encode(DTree t)
:params
t : DTree object to be serialized
return value : string containing the JSON result
:desc
Serializes a DTree structure 't' into a String in JSON notation.

View File

@ -1,15 +0,0 @@
:sig
s64 kill(pid_t pid, s64 sig)
:params
pid : PID of the process
sig : signal number
return value : 0 if signal was sent, -1 otherwise
:desc
This is the standard POSIX kill() function, provided here for reference.
Possible signal numbers are: SIGABND, SIGABRT, SIGALRM, SIGBUS, SIGFPE, SIGHUP, SIGILL, SIGINT, SIGKILL, SIGPIPE, SIGPOLL, SIGPROF, SIGQUIT, SIGSEGV, SIGSYS, SIGTERM, SIGTRAP, SIGURG, SIGUSR1, SIGUSR2, SIGVTALRM, SIGXCPU, SIGXFSZ, SIGCHLD, SIGIO, SIGIOERR, SIGWINCH, SIGSTOP, SIGTSTP, SIGTTIN, SIGTTOU, SIGCONT.
:see
>task

View File

@ -1,12 +0,0 @@
:sig
StringList ls(String path)
:params
path : a filesystem path
return value : list of directory entries
:desc
Returns a list of files and subdirectories within the given 'path'.
:see
>sys

View File

@ -1,11 +0,0 @@
:sig
String make_session_id()
:params
return value : a new session ID
:desc
Creates a session ID
:see
>session

View File

@ -1,13 +0,0 @@
:sig
String memcache_command(u64 connection, String command)
:params
connection : connection handle
command : string containing the Memcache command
return value : string containing the Memcache server's response
:desc
Executes a command on an open memcache connection.
:see
>memcache

View File

@ -1,13 +0,0 @@
:sig
u64 memcache_connect(String host = "127.0.0.1", short port = 11211)
:params
host : optional host name of the memcache server, defaults to local address 127.0.0.1
port : optional memcache server's port, defaults to 11211
return value : the connection handle (or -1 if an error occurred)
:desc
Connects to a memcache server instance.
:see
>memcache

View File

@ -1,13 +0,0 @@
:sig
bool memcache_delete(u64 connection, String key)
:params
connection : connection handle
key : key string
return value : true if the operation was successful
:desc
Deletes entry specified by the 'key'.
:see
>memcache

View File

@ -1,14 +0,0 @@
:sig
String memcache_get(u64 connection, String key, String default_value = "")
:params
connection : connection handle
key : key string
default_value : optional default value
return value : value that was returned by the Memcache server
:desc
Retrieves a value from an existing connection to a Memcache server.
:see
>memcache

View File

@ -1,13 +0,0 @@
:sig
StringMap memcache_get_multiple(u64 connection, StringList keys)
:params
connection : connection handle
keys : a list of strings containing the keys to be retrieved
return value : a StringMap with the retrieved entries
:desc
Retrieves a bunch of entries all at once.
:see
>memcache

View File

@ -1,15 +0,0 @@
:sig
bool memcache_set(u64 connection, String key, String value, u64 expires_in = 60*60)
:params
connection : connection handle
key : the entry's key
value : the value to be set
expires_in : optional expiration timeout, defaults to one hour
return value : true if the operation was successful
:desc
Stores a 'value' on the Memcache server.
:see
>memcache

View File

@ -1,11 +0,0 @@
:sig
f64 microtime()
:params
return value : current Unix timestamp
:desc
Returns a 64 bit float containing the current Unix timestamp with millisecond accuracy or better.
:see
>time

View File

@ -1,12 +0,0 @@
:sig
bool mkdir(String path)
:params
path : the path name to be created
return value : returns true if the directory was successfully created
:desc
Creates a directory stated by 'path'
:see
>sys

View File

@ -1,14 +0,0 @@
:sig
MySQL* mysql_connect(String host = "localhost", String username = "root", String password = "")
:params
host : host name of the MySQL server
username : user name
password : password
return value : pointer to the MySQL connection struct
:desc
Establishes a connection to a MySQL server.
:see
>mysql

View File

@ -1,11 +0,0 @@
:sig
void mysql_disconnect(MySQL* m)
:params
m : pointer to an existing MySQL connection struct
:desc
Closes a connection to a MySQL server.
:see
>mysql

View File

@ -1,12 +0,0 @@
:sig
String mysql_error(MySQL* m)
:params
m : pointer to a MySQL connection struct
return value : MySQL error message (if present, otherwise empty string)
:desc
Returns the last error message from a connection to a MySQL server.
:see
>mysql

View File

@ -1,13 +0,0 @@
:sig
String mysql_escape(String raw, char quote_char)
:params
raw : the string to be escaped
quote_char : the character that should be used to wrap the string (pass NULL for no wrapping)
return value : the safe version of the 'raw' string
:desc
Escapes a string such that it can be passed as a safe value into an SQL expression.
:see
>mysql

View File

@ -1,12 +0,0 @@
:sig
u64 mysql_insert_id(MySQL* m)
:params
m : pointer to an active MySQL connection
return value : the last used automatic row ID
:desc
This retrieves the last row ID that was used for a column with an AUTO_INCREMENT row key.
:see
>mysql

View File

@ -1,17 +0,0 @@
:sig
DTree mysql_query(MySQL* m, String q, StringMap params)
:params
m : pointer to an active MySQL connection struct
q : a string containing a MySQL query
params : optional, a list of query parameter keys and values
return value : a list of rows returned from executing the query
:desc
Executes a MySQL query and returns the resulting data (if any).
:Examples
(tbd)
:see
>mysql

View File

@ -1,13 +0,0 @@
:sig
String nibble(String& haystack, String delim)
:params
haystack : string to be nibbled at
delim : delimiter
return value : string before first occurrence of 'delim'
:desc
Returns the part of 'haystack' before the first occurrence of 'delim', removing the corresponding part from 'haystack' (including 'delim'). If the substring 'delim' does not occurr in 'haystack', the entire string is returned and 'haystack' is set to an empty string.
:see
>string

View File

@ -1,11 +0,0 @@
:sig
void ob_clear()
:params
(none)
:desc
Discard the current output buffer.
:see
>ob

View File

@ -1,11 +0,0 @@
:sig
String ob_get()
:params
return value : content of the current output buffer
:desc
Returns the contents of the current output buffer.
:see
>ob

View File

@ -1,11 +0,0 @@
:sig
String ob_get_clear()
:params
return value : content of the current output buffer
:desc
Returns the contents of the current output buffer and then discards the buffer.
:see
>ob

View File

@ -1,11 +0,0 @@
:sig
void ob_start()
:params
(none)
:desc
Starts a new output buffer. All subsequent output will be directed into this buffer.
:see
>ob

View File

@ -1,12 +0,0 @@
:sig
StringMap parse_query(String q)
:params
q : string containing URL parameters
return value : a StringMap containing the parameters
:desc
Decodes a string of the format 'a=b&c=d' into a StringMap containing keyed entries.
:see
>uri

View File

@ -1,12 +0,0 @@
:sig
u64 parse_time(String time_string)
:params
time_string : a string containing a date and/or time in text form
return value : the interpreted 'time_string' as a Unix timestamp
:desc
Attempts to parse the given 'time_string' into a Unix timestamp.
:see
>time

View File

@ -1,10 +0,0 @@
:sig
void print(...val)
:params
...val : one or more values that should be output
:desc
Appends data to the current request's output stream.

View File

@ -1,11 +0,0 @@
:sig
void session_destroy(String session_name)
:params
session_name : the name of the session
:desc
Deletes the cookie specified by 'session_name' and clears the data stored under the session ID. This empties the 'context->session_id' and 'context->session' variables.
:see
>session

View File

@ -1,17 +0,0 @@
:sig
String session_start(String session_name)
:params
return value : the session ID, defaults to "uce-session"
:desc
Starts session or connects to existing session. This function sets a cookie with the name contained in 'session_name' if it does not exist and fills that cookie with a new unique session ID. It then loads the session data for that session ID. Afterwards, the following fields are populated in the 'context' variable:
context->session_id : the current session ID
context->session_name : the current session cookie name
context->session : the current session data. The session data is automatically saved after a request completes.
:see
>session

View File

@ -1,11 +0,0 @@
:sig
void set_cwd(String path)
:params
path : the new working directory
:desc
Sets a new working directory.
:see
>sys

View File

@ -1,12 +0,0 @@
:sig
String shell_escape(String raw)
:params
raw : string that should be escaped
return value : escaped version of 'raw'
:desc
Escapes a parameter for shell_exec
:see
>sys

View File

@ -1,12 +0,0 @@
:sig
String shell_exec(String cmd)
:params
cmd : string that contains the shell command line to be executed
return value : output of the command execution
:desc
Executes a Linux shell command and returns the generated output
:see
>sys

View File

@ -1,11 +0,0 @@
:sig
void socket_close(u64 sockfd)
:params
sockfd : socket handle
:desc
Closes an existing socket connection.
:see
>socket

View File

@ -1,13 +0,0 @@
:sig
u64 socket_connect(String host, short port)
:params
host : host name
port : port number
return value : the socket handle
:desc
Opens a socket connection to the given 'host' and 'port'.
:see
>socket

View File

@ -1,14 +0,0 @@
:sig
String socket_read(u64 sockfd, u32 max_length = 1024*128, u32 timeout = 1);
:params
sockfd : socket handle
max_length : optional maximum data size, defaults to 128kBytes
timeout : optional operation timeout, defaults to one second
return value : string containing the data that was read
:desc
Reads data from a socket connection.
:see
>socket

View File

@ -1,13 +0,0 @@
:sig
bool socket_write(u64 sockfd, String data)
:params
sockfd : socket handle
data : a string containing the data to be written to the socket
return value : true if the write operation was successful
:desc
Writes a string of 'data' to the given socket.
:see
>socket

View File

@ -1,13 +0,0 @@
:sig
StringList split(String str, String delim = "\n")
:params
str : string to be split
delim : delimiter (defaults to newline character)
return value : a list of strings
:desc
Splits 'str' into multiple strings based on the given delimiter 'delim'.
:see
>string

View File

@ -1,13 +0,0 @@
:sig
pid_t task(String key, std::function<void()> exec_func)
:params
key : string uniquely identifying the task
exec_func : function to execute
return value : the process ID of the started (or still running) task
:desc
task() starts the 'exec_func' in a new process and returns that process' ID. If a process with the same 'key' is already running, task will not start a new process but instead just return the PID of the process that is already running.
:see
>task

View File

@ -1,12 +0,0 @@
:sig
pid_t task_pid(String key)
:params
key : string uniquely identifying the task
return value : the process ID of the task
:desc
Checks whether a process with the given 'key' is running and returns its PID if it is. Returns 0 otherwise.
:see
>task

View File

@ -1,11 +0,0 @@
:sig
u64 time()
:params
return value : second-accurate current Unix timestamp
:desc
Returns a 64 bit integer containing the current Unix timestamp.
:see
>time

View File

@ -1,11 +0,0 @@
:sig
void unlink(String file_name)
:params
file_name : name of the file
:desc
Deletes the file identified by 'file_name'.
:see
>sys

View File

@ -1,12 +0,0 @@
:sig
String var_dump(StringMap t, String prefix = "", String postfix = "\n")
String var_dump(StringList t, String prefix = "", String postfix = "\n")
String var_dump(DTree t, String prefix = "", String postfix = "\n")
:params
t : object to be dumped into a string
return value : string containing a human-friendly representation of 't'
:desc
Returns a string representation of 't' intended for debugging.

View File

@ -1,105 +0,0 @@
* {
font-family: inherit;
font-size: inherit;
box-sizing: inherit;
color: inherit;
line-height: inherit;
}
h1 {
font-family: monospace;
font-size: 200%;
padding-top: 8px;
padding-bottom: 8px;
}
body {
max-width: 1024px;
margin-left: auto;
margin-right: auto;
padding-left: 16px;
padding-right: 16px;
font-family: Tahoma, Helvetica, Arial;
font-size: 1.2em;
box-sizing: border-box;
background: #139;
color: white;
line-height: 150%;
}
body > * {
background: rgba(255,255,255,0.1);
padding: 32px;
margin: 16px;
}
a {
color: yellow;
}
form > div, label {
display: block;
padding-top: 8px;
padding-bottom: 8px;
}
input, textarea {
background: rgba(0,0,0,0.2);
border: 2px solid rgba(255,255,255,0.2);
}
input[type=submit], button {
padding: 8px;
cursor: pointer;
}
input[type=submit]:hover, button:hover {
color: yellow;
background: rgba(0,0,0,0.5);
}
input[type=text], textarea {
padding: 8px;
width: 100%;
}
input[type=text]:hover, textarea:hover {
background: rgba(0,0,0,0.25);
}
textarea {
height: 20%;
}
pre {
height: 20%;
overflow: auto;
padding: 8px;
border: 2px solid rgba(0,0,0,0.2);
background: rgba(100,100,100,0.15);
font-family: monospace;
white-space: pre-wrap;
}
h3 {
margin: 0;
font-family: monospace;
font-size: 1.4em;
margin-bottom: 0.8em;
opacity: 0.7;
}
.sig {
font-family: monospace;
white-space: pre;
font-size: 120%;
}
.params {
}
.params b {
font-family: monospace;
white-space: pre;
}

Some files were not shown because too many files have changed in this diff Show More