initial import

This commit is contained in:
udo
2022-01-21 09:10:38 +00:00
parent ad3d65cdac
commit c047927b18
171 changed files with 16540 additions and 1 deletions
+8
View File
@@ -0,0 +1,8 @@
Memcache Functions
memcache_command
memcache_connect
memcache_delete
memcache_get
memcache_get_multiple
memcache_set
+8
View File
@@ -0,0 +1,8 @@
MySQL Functions
mysql_connect
mysql_disconnect
mysql_error
mysql_escape
mysql_insert_id
mysql_query
+9
View File
@@ -0,0 +1,9 @@
Noise/Hash Functions
draw_float
draw_int
gen_noise01
gen_noise32
gen_noise64
gen_float
gen_int
+6
View File
@@ -0,0 +1,6 @@
Output Buffer Functions
ob_clear
ob_get
ob_get_clear
ob_start
+5
View File
@@ -0,0 +1,5 @@
Sessions
make_session_id
session_destroy
session_start
+6
View File
@@ -0,0 +1,6 @@
Socket Functions
socket_close
socket_connect
socket_read
socket_write
+10
View File
@@ -0,0 +1,10 @@
String Functions
filter
first
join
nibble
split
str_to_lower
str_to_upper
trim
+17
View File
@@ -0,0 +1,17 @@
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
+5
View File
@@ -0,0 +1,5 @@
Task API
kill
task
task_pid
+7
View File
@@ -0,0 +1,7 @@
Time and Date Functions
microtime
time
date
gmdate
parse_time
+7
View File
@@ -0,0 +1,7 @@
URI Functions
encode_query
make_session_id
parse_query
uri_decode
uri_encode
+150
View File
@@ -0,0 +1,150 @@
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></>
}
+63
View File
@@ -0,0 +1,63 @@
: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'
+12
View File
@@ -0,0 +1,12 @@
: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
+125
View File
@@ -0,0 +1,125 @@
: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
+12
View File
@@ -0,0 +1,12 @@
: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
+13
View File
@@ -0,0 +1,13 @@
: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
+13
View File
@@ -0,0 +1,13 @@
: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
+12
View File
@@ -0,0 +1,12 @@
: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
+12
View File
@@ -0,0 +1,12 @@
: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
+12
View File
@@ -0,0 +1,12 @@
: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
+12
View File
@@ -0,0 +1,12 @@
: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
+12
View File
@@ -0,0 +1,12 @@
: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
+13
View File
@@ -0,0 +1,13 @@
: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
+13
View File
@@ -0,0 +1,13 @@
: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
+14
View File
@@ -0,0 +1,14 @@
: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
+12
View File
@@ -0,0 +1,12 @@
: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
+16
View File
@@ -0,0 +1,16 @@
: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
+16
View File
@@ -0,0 +1,16 @@
: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
+13
View File
@@ -0,0 +1,13 @@
: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
+13
View File
@@ -0,0 +1,13 @@
: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
+13
View File
@@ -0,0 +1,13 @@
: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
+10
View File
@@ -0,0 +1,10 @@
: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'.
+11
View File
@@ -0,0 +1,11 @@
:sig
String get_cwd()
:params
return value : the current working directory
:desc
Returns the current working directory.
:see
>sys
+125
View File
@@ -0,0 +1,125 @@
: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
+13
View File
@@ -0,0 +1,13 @@
: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;
+11
View File
@@ -0,0 +1,11 @@
: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.
+13
View File
@@ -0,0 +1,13 @@
: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
+10
View File
@@ -0,0 +1,10 @@
: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.
+10
View File
@@ -0,0 +1,10 @@
: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.
+15
View File
@@ -0,0 +1,15 @@
: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
+12
View File
@@ -0,0 +1,12 @@
: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
+11
View File
@@ -0,0 +1,11 @@
:sig
String make_session_id()
:params
return value : a new session ID
:desc
Creates a session ID
:see
>session
+13
View File
@@ -0,0 +1,13 @@
: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
+13
View File
@@ -0,0 +1,13 @@
: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
+13
View File
@@ -0,0 +1,13 @@
: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
+14
View File
@@ -0,0 +1,14 @@
: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
+13
View File
@@ -0,0 +1,13 @@
: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
+15
View File
@@ -0,0 +1,15 @@
: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
+11
View File
@@ -0,0 +1,11 @@
: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
+12
View File
@@ -0,0 +1,12 @@
: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
+14
View File
@@ -0,0 +1,14 @@
: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
+11
View File
@@ -0,0 +1,11 @@
: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
+12
View File
@@ -0,0 +1,12 @@
: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
+13
View File
@@ -0,0 +1,13 @@
: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
+12
View File
@@ -0,0 +1,12 @@
: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
+17
View File
@@ -0,0 +1,17 @@
: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
+13
View File
@@ -0,0 +1,13 @@
: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
+11
View File
@@ -0,0 +1,11 @@
:sig
void ob_clear()
:params
(none)
:desc
Discard the current output buffer.
:see
>ob
+11
View File
@@ -0,0 +1,11 @@
:sig
String ob_get()
:params
return value : content of the current output buffer
:desc
Returns the contents of the current output buffer.
:see
>ob
+11
View File
@@ -0,0 +1,11 @@
: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
+11
View File
@@ -0,0 +1,11 @@
:sig
void ob_start()
:params
(none)
:desc
Starts a new output buffer. All subsequent output will be directed into this buffer.
:see
>ob
+12
View File
@@ -0,0 +1,12 @@
: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
+12
View File
@@ -0,0 +1,12 @@
: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
+10
View File
@@ -0,0 +1,10 @@
:sig
void print(...val)
:params
...val : one or more values that should be output
:desc
Appends data to the current request's output stream.
+11
View File
@@ -0,0 +1,11 @@
: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
+17
View File
@@ -0,0 +1,17 @@
: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
+11
View File
@@ -0,0 +1,11 @@
:sig
void set_cwd(String path)
:params
path : the new working directory
:desc
Sets a new working directory.
:see
>sys
+12
View File
@@ -0,0 +1,12 @@
: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
+12
View File
@@ -0,0 +1,12 @@
: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
+11
View File
@@ -0,0 +1,11 @@
:sig
void socket_close(u64 sockfd)
:params
sockfd : socket handle
:desc
Closes an existing socket connection.
:see
>socket
+13
View File
@@ -0,0 +1,13 @@
: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
+14
View File
@@ -0,0 +1,14 @@
: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
+13
View File
@@ -0,0 +1,13 @@
: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
+13
View File
@@ -0,0 +1,13 @@
: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
+14
View File
@@ -0,0 +1,14 @@
:sig
String str_to_lower(String s)
:params
s : the string to be converted
return value : returns a version of 's' where all upper case characters have been changed into lower case
:desc
Returns a lower case version of the input string 's'.
Note: this function is not yet Unicode-aware.
:see
>string
+14
View File
@@ -0,0 +1,14 @@
:sig
String str_to_upper(String s)
:params
s : the string to be converted
return value : returns a version of 's' where all lower case characters have been changed into upper case
:desc
Returns a upper case version of the input string 's'.
Note: this function is not yet Unicode-aware.
:see
>string
+13
View File
@@ -0,0 +1,13 @@
: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
+12
View File
@@ -0,0 +1,12 @@
: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
+11
View File
@@ -0,0 +1,11 @@
:sig
u64 time()
:params
return value : second-accurate current Unix timestamp
:desc
Returns a 64 bit integer containing the current Unix timestamp.
:see
>time
+12
View File
@@ -0,0 +1,12 @@
:sig
String trim(String raw)
:params
raw : string to be trimmed
return value : string with leading and trailing whitespace characters removed
:desc
Returns a string where leading an trailing whitespace characters have been trimmed off.
:see
>string
+11
View File
@@ -0,0 +1,11 @@
:sig
void unlink(String file_name)
:params
file_name : name of the file
:desc
Deletes the file identified by 'file_name'.
:see
>sys
+12
View File
@@ -0,0 +1,12 @@
:sig
String uri_decode(String s)
:params
s : string containing URI encoded data
return value : a string that contains the decoded version of 's'
:desc
Decodes an URI-encoded string 's'.
:see
>uri
+12
View File
@@ -0,0 +1,12 @@
:sig
String uri_encode(String s)
:params
s : string that should be encoded
return value : an URI-encoded version of 's'
:desc
URI-encodes a string.
:see
>uri
+12
View File
@@ -0,0 +1,12 @@
: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.
+105
View File
@@ -0,0 +1,105 @@
* {
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;
}