aboutsummaryrefslogtreecommitdiff
path: root/doc/man3
diff options
context:
space:
mode:
Diffstat (limited to 'doc/man3')
-rw-r--r--doc/man3/handler_add.388
-rw-r--r--doc/man3/handler_alloc.359
-rw-r--r--doc/man3/handler_free.340
-rw-r--r--doc/man3/handler_listen.373
-rw-r--r--doc/man3/html_node_add_attr.377
-rw-r--r--doc/man3/html_node_add_child.3124
-rw-r--r--doc/man3/html_node_add_sibling.355
-rw-r--r--doc/man3/html_node_alloc.375
-rw-r--r--doc/man3/html_node_free.348
-rw-r--r--doc/man3/html_node_set_value.380
-rw-r--r--doc/man3/html_node_set_value_unescaped.381
-rw-r--r--doc/man3/html_serialize.352
-rw-r--r--doc/man3/http_alloc.362
-rw-r--r--doc/man3/http_cookie_create.368
-rw-r--r--doc/man3/http_encode_url.338
-rw-r--r--doc/man3/http_free.341
-rw-r--r--doc/man3/http_response_add_header.353
-rw-r--r--doc/man3/http_update.376
18 files changed, 1190 insertions, 0 deletions
diff --git a/doc/man3/handler_add.3 b/doc/man3/handler_add.3
new file mode 100644
index 0000000..4c93f7a
--- /dev/null
+++ b/doc/man3/handler_add.3
@@ -0,0 +1,88 @@
+.TH HANDLER_ADD 3 2023-09-13 0.1.0 "slweb Library Reference"
+
+.SH NAME
+handler_add \- add an endpoint to a web server handler object
+
+.SH SYNOPSIS
+.LP
+.nf
+#include <slweb/handler.h>
+.P
+int handler_add(struct handler *\fIh\fP, const char *\fIurl\fP, enum http_op \fIop\fP, handler_fn \fIf\fP, void *\fIuser\fP);
+.fi
+
+.SH DESCRIPTION
+The
+.IR handler_add ()
+function adds an endpoint to a
+.I struct handler
+object previously allocated by
+.IR handler_alloc (3),
+pointed to by
+.IR h .
+
+.I url
+is a null-terminated string that defines the target resource. The
+metacharacter
+.B *
+can be used to match any number of characters. For example,
+.B "/user/*/file"
+shall match resources such as
+.B /user/alice/file
+or
+.BR /user/bob/nested/file .
+
+.I op
+describes the HTTP/1.1 operation supported by the endpoint. See the
+definition for
+.I "enum http_op"
+for an exhaustive list of supported operations.
+
+.I f
+is a function pointer that shall be executed by
+.I slweb
+if an incoming request matches the resource and operation defined by
+.I url
+and
+.IR op ,
+respectively. See
+.IR slweb_handler (7)
+for the definition for
+.IR handler_fn .
+
+.I user
+is an opaque pointer to a user-defined object that shall be passed to
+the function pointed to by
+.IR f .
+.I user
+can be a null pointer.
+
+.SH RETURN VALUE
+On success, zero is returned. On error, a negative integer is returned,
+and
+.I errno
+might be set by the internal calls to
+.IR realloc (3)
+or
+.IR strdup (3).
+
+.SH ERRORS
+Refer to
+.IR malloc (3)
+and
+.IR strdup (3)
+for a list of possible errors.
+
+.SH SEE ALSO
+.BR handler_alloc (3),
+.BR handler_free (3),
+.BR handler_listen (3),
+.BR slweb_handler (7).
+
+.SH COPYRIGHT
+Copyright (C) 2023 Xavier Del Campo Romero.
+.P
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
diff --git a/doc/man3/handler_alloc.3 b/doc/man3/handler_alloc.3
new file mode 100644
index 0000000..e71b569
--- /dev/null
+++ b/doc/man3/handler_alloc.3
@@ -0,0 +1,59 @@
+.TH HANDLER_ALLOC 3 2023-09-13 0.1.0 "slweb Library Reference"
+
+.SH NAME
+handler_alloc \- allocate a web server handler object
+
+.SH SYNOPSIS
+.LP
+.nf
+#include <slweb/handler.h>
+.P
+struct handler *handler_alloc(const struct handler_cfg *\fIcfg\fP);
+.fi
+
+.SH DESCRIPTION
+The
+.IR handler_alloc (3)
+function allocates a
+.I "struct handler"
+object, containing the required data by
+.I slweb
+to handle a web server. This object is meant to be consumed by
+other functions from
+.IR slweb_handler (7).
+.I cfg
+defines the initial configuration, whose structure is defined by
+.IR slweb_handler (7).
+
+.I "struct handler"
+is an opaque object internal to
+.I slweb
+and therefore is not accessible to callers.
+
+.SH RETURN VALUE
+On success, an opaque pointer to a
+.I struct handler
+object is returned. On error,
+a null pointer is returned, and
+.I errno
+might be set by the internal call to
+.IR malloc (3).
+
+.SH ERRORS
+Refer to
+.IR malloc (3)
+for a list of possible errors.
+
+.SH SEE ALSO
+.BR handler_free (3),
+.BR handler_add (3),
+.BR handler_listen (3),
+.BR slweb_handler (7).
+
+.SH COPYRIGHT
+Copyright (C) 2023 Xavier Del Campo Romero.
+.P
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
diff --git a/doc/man3/handler_free.3 b/doc/man3/handler_free.3
new file mode 100644
index 0000000..1a89fa9
--- /dev/null
+++ b/doc/man3/handler_free.3
@@ -0,0 +1,40 @@
+.TH HANDLER_FREE 3 2023-09-14 0.1.0 "slweb Library Reference"
+
+.SH NAME
+handler_free \- free a web server handler object
+
+.SH SYNOPSIS
+.LP
+.nf
+#include <slweb/handler.h>
+.P
+void handler_free(struct handler *\fIh\fP);
+.fi
+
+.SH DESCRIPTION
+The
+.IR handler_free (3)
+function frees the memory space pointed to by
+.IR h ,
+which must have been returned by a previous call to
+.IR handler_alloc (3).
+
+.SH RETURN VALUE
+The
+.IR handler_free (3)
+function returns no value.
+
+.SH ERRORS
+No errors are defined.
+
+.SH SEE ALSO
+.BR handler_alloc (3),
+.BR slweb_handler (7).
+
+.SH COPYRIGHT
+Copyright (C) 2023 Xavier Del Campo Romero.
+.P
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
diff --git a/doc/man3/handler_listen.3 b/doc/man3/handler_listen.3
new file mode 100644
index 0000000..cc2cfbb
--- /dev/null
+++ b/doc/man3/handler_listen.3
@@ -0,0 +1,73 @@
+.TH HANDLER_LISTEN 3 2023-09-14 0.1.0 "slweb Library Reference"
+
+.SH NAME
+handler_listen \- listen to and handle incoming connections on a web
+server
+
+.SH SYNOPSIS
+.LP
+.nf
+#include <slweb/handler.h>
+.P
+int handler_listen(struct handler *\fIh\fP, unsigned short \fIport\fP);
+.fi
+
+.SH DESCRIPTION
+The
+.IR handler_listen (3)
+function listens for connections on the TCP port number given by
+.I port
+on a
+.I struct handler
+object pointed to by
+.IR h ,
+which must be previously allocated by a call to
+.IR handler_alloc (3).
+
+Also, the
+.IR handler_listen (3)
+function validates incoming requests and calls the configured
+callbacks previously given by one or more calls to
+.IR handler_add (3).
+
+The
+.IR handler_listen (3)
+function blocks until either
+.I SIGTERM
+or
+.I SIGINT
+are triggered.
+
+.SH RETURN VALUE
+On success, zero is returned. On error, a negative integer is returned.
+
+.SH ERRORS
+No errors are defined.
+
+.SH FUTURE DIRECTIONS
+When no configured endpoint matches the incoming request,
+.I slweb
+shall respond with a
+.B 404 Not Found
+HTTP status code with no payload. Since some library users might want
+to provide custom pages for such error condition, future versions of
+this library shall replace the harcoded response with an additional
+callback on
+.IR "struct handler_cfg" ,
+similarly to its member
+.IR length .
+
+.SH SEE ALSO
+.BR handler_alloc (3),
+.BR handler_free (3),
+.BR handler_add (3),
+.BR slweb_handler (7),
+.BR signal (7).
+
+.SH COPYRIGHT
+Copyright (C) 2023 Xavier Del Campo Romero.
+.P
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
diff --git a/doc/man3/html_node_add_attr.3 b/doc/man3/html_node_add_attr.3
new file mode 100644
index 0000000..d6d3bf0
--- /dev/null
+++ b/doc/man3/html_node_add_attr.3
@@ -0,0 +1,77 @@
+.TH HTML_NODE_ADD_ATTR 3 2023-09-24 0.1.0 "slweb Library Reference"
+
+.SH NAME
+html_node_add_attr \- add attribute to a HTML node
+
+.SH SYNOPSIS
+.LP
+.nf
+#include <slweb/html.h>
+.P
+int html_node_add_attr(struct html_node *\fIn\fP, const char *\fIattr\fP, const char *\fIval\fP);
+.fi
+
+.SH DESCRIPTION
+The
+.IR html_node_add_attr (3)
+function adds an attribute to a
+.I struct html_node
+object pointed to by
+.IR n ,
+previously returned by
+.IR html_node_alloc (3)
+or
+.IR html_node_add_child (3).
+.I attr
+is a null-terminated string with the name of the attribute.
+.I val
+is a null-terminated string with the value for the attribute.
+
+.I slweb
+allocates copies of the null-terminated strings defined by
+.I attr
+and
+.IR val .
+
+.SH RETURN VALUE
+On success,
+.IR html_node_add_attr (3)
+returns zero. On failure, a negative integer is returned.
+
+.SH EXAMPLE
+A
+.I struct html_node
+object with
+.B example
+as tag name, no value and
+.B name
+as its attribute with value
+.B john
+would be translated by the HTML
+serializer to:
+
+.PP
+.in +4n
+.EX
+<example name="john"/>
+.EE
+.in
+.PP
+
+.SH ERRORS
+No errors are defined.
+
+.SH SEE ALSO
+.BR html_node_alloc (3),
+.BR html_node_free (3),
+.BR html_node_set_value (3),
+.BR html_node_set_value_unescaped (3),
+.BR slweb_http (7).
+
+.SH COPYRIGHT
+Copyright (C) 2023 Xavier Del Campo Romero.
+.P
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
diff --git a/doc/man3/html_node_add_child.3 b/doc/man3/html_node_add_child.3
new file mode 100644
index 0000000..360f968
--- /dev/null
+++ b/doc/man3/html_node_add_child.3
@@ -0,0 +1,124 @@
+.TH HTML_NODE_ADD_CHILD 3 2023-09-25 0.1.0 "slweb Library Reference"
+
+.SH NAME
+html_node_add_child \- add child to a HTML node
+
+.SH SYNOPSIS
+.LP
+.nf
+#include <slweb/html.h>
+.P
+struct html_node *html_node_add_child(struct html_node *\fIn\fP, const char *\fIelem\fP);
+.fi
+
+.SH DESCRIPTION
+The
+.IR html_node_add_child (3)
+function allocates a child
+.I struct html_node
+object into another
+.I struct html_node
+object, previously allocated by a call to
+.IR html_node_alloc (3)
+or
+.IR html_node_add_child (3),
+and pointed to by
+.IR n .
+The tag name for the child node is defined by
+.IR elem .
+
+.SH RETURN VALUE
+On success,
+.IR html_node_add_child (3)
+returns zero. On failure, a negative integer is returned.
+
+.SH EXAMPLE
+
+The following example shall print a tree structure with a root node
+and one child node:
+
+.PP
+.in +4n
+.EX
+#include <dynstr.h>
+#include <slweb/html.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(void)
+{
+ int ret = EXIT_FAILURE;
+ struct html_node *const root = html_node_alloc("root"), *child;
+ struct dynstr d;
+
+ dynstr_init(&d);
+
+ if (!root)
+ {
+ fprintf(stderr, "html_node_alloc failed\en");
+ goto end;
+ }
+ else if (!(child = html_node_add_child(root, "child")))
+ {
+ fprintf(stderr, "html_node_add_child failed\en");
+ goto end;
+ }
+ else if (html_serialize(root, &d))
+ {
+ fprintf(stderr, "html_serialize failed\en");
+ goto end;
+ }
+
+ printf("%s", d.str);
+ ret = EXIT_SUCCESS;
+
+end:
+ html_node_free(root);
+ dynstr_free(&d);
+ return ret;
+}
+.EE
+.in
+.PP
+
+The following results shall be written to the standard output:
+
+.PP
+.in +4n
+.EX
+<root>
+ <child/>
+</root>
+.EE
+.in
+.PP
+
+.SH ERRORS
+No errors are defined.
+
+.SH NOTES
+Adding a child to an existing
+.I struct html_node
+object is an atomic operation, which means no changes are applied to it
+if
+.IR html_node_add_child (3)
+fails.
+
+Internally,
+.I slweb
+calls
+.IR html_node_add_sibling (3)
+from a child node when a node already has one.
+
+.SH SEE ALSO
+.BR html_node_alloc (3),
+.BR html_node_add_sibling (3),
+.BR slweb_http (7).
+
+.SH COPYRIGHT
+Copyright (C) 2023 Xavier Del Campo Romero.
+.P
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
diff --git a/doc/man3/html_node_add_sibling.3 b/doc/man3/html_node_add_sibling.3
new file mode 100644
index 0000000..951242f
--- /dev/null
+++ b/doc/man3/html_node_add_sibling.3
@@ -0,0 +1,55 @@
+.TH HTML_NODE_ADD_SIBLING 3 2023-09-25 0.1.0 "slweb Library Reference"
+
+.SH NAME
+html_node_add_sibling \- add sibling to a HTML node
+
+.SH SYNOPSIS
+.LP
+.nf
+#include <slweb/html.h>
+.P
+void html_node_add_sibling(struct html_node *\fIn\fP, struct html_node *\fIsibling\fP);
+.fi
+
+.SH DESCRIPTION
+The
+.IR html_node_add_sibling (3)
+function adds a sibling node, pointed to by
+.IR sibling ,
+to a
+.I struct html_node
+object, previously allocated by a call to
+.IR html_node_alloc (3)
+or
+.IR html_node_add_child (3),
+and pointed to by
+.IR n .
+
+.SH RETURN VALUE
+The
+.IR html_node_add_sibling (3)
+function always succeeds.
+
+.SH ERRORS
+No errors are defined.
+
+.SH NOTES
+This function is mostly meant for internal use. Library users should
+only need
+.IR html_node_add_child (3)
+to create tree structures. Nonetheless,
+.IR html_node_add_sibling (3)
+was still made public so as to cover possibly less common use cases.
+
+.SH SEE ALSO
+.BR html_node_alloc (3),
+.BR html_node_add_child (3),
+.BR slweb_http (7).
+
+.SH COPYRIGHT
+Copyright (C) 2023 Xavier Del Campo Romero.
+.P
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
diff --git a/doc/man3/html_node_alloc.3 b/doc/man3/html_node_alloc.3
new file mode 100644
index 0000000..9551bd3
--- /dev/null
+++ b/doc/man3/html_node_alloc.3
@@ -0,0 +1,75 @@
+.TH HTML_NODE_ALLOC 3 2023-09-15 0.1.0 "slweb Library Reference"
+
+.SH NAME
+html_node_alloc \- allocate a HTML node
+
+.SH SYNOPSIS
+.LP
+.nf
+#include <slweb/html.h>
+.P
+struct html_node *html_node_alloc(const char *\fIelement\fP);
+.fi
+
+.SH DESCRIPTION
+The
+.IR html_node_alloc (3)
+function allocates a
+.I "struct html_node"
+object, which represents a node in a HTML tree.
+.I element
+is the name of the HTML tag.
+
+.I "struct html_node"
+is an opaque object internal to
+.I slweb
+and therefore is not accessible to callers.
+
+.SH RETURN VALUE
+On success, an opaque pointer to a
+.I struct html_node
+object is returned. On error,
+a null pointer is returned, and
+.I errno
+might be set by the internal call to
+.IR malloc (3).
+
+.SH ERRORS
+Refer to
+.IR malloc (3)
+for a list of possible errors.
+
+.SH EXAMPLE
+A
+.I struct html_node
+object with
+.B example
+as
+.I element
+with no attributes or value would be translated by the HTML serializer
+to
+.BR <example/> .
+
+.SH NOTES
+Typically,
+.IR html_node_alloc (3)
+is used to allocate the root node, whereas children can be appended to
+it via
+.IR html_node_add_child (3).
+
+.SH SEE ALSO
+.BR html_node_free (3),
+.BR html_node_set_value (3),
+.BR html_node_set_value_unescaped (3),
+.BR html_node_add_attr (3),
+.BR html_node_add_child (3),
+.BR html_node_add_sibling (3),
+.BR slweb_html (7).
+
+.SH COPYRIGHT
+Copyright (C) 2023 Xavier Del Campo Romero.
+.P
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
diff --git a/doc/man3/html_node_free.3 b/doc/man3/html_node_free.3
new file mode 100644
index 0000000..6efc9ed
--- /dev/null
+++ b/doc/man3/html_node_free.3
@@ -0,0 +1,48 @@
+.TH HTML_NODE_FREE 3 2023-09-16 0.1.0 "slweb Library Reference"
+
+.SH NAME
+html_node_free \- free a HTML node and its children
+
+.SH SYNOPSIS
+.LP
+.nf
+#include <slweb/html.h>
+.P
+void html_node_free(struct html_node *\fIn\fP);
+.fi
+
+.SH DESCRIPTION
+The
+.IR html_node_free (3)
+function frees the memory space pointed to by
+.IR n ,
+which must have been returned by a previous call to
+.IR html_node_alloc (3).
+Children nodes are freed recursively.
+
+.SH RETURN VALUE
+The
+.IR html_node_free ()
+function returns no value.
+
+.SH ERRORS
+No errors are defined.
+
+.SH NOTES
+Since
+.IR html_node_free (3)
+frees nodes recursively, library users must not attempt to call
+.IR html_node_free (3)
+for a child node.
+
+.SH SEE ALSO
+.BR html_node_alloc (3),
+.BR slweb_html (7).
+
+.SH COPYRIGHT
+Copyright (C) 2023 Xavier Del Campo Romero.
+.P
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
diff --git a/doc/man3/html_node_set_value.3 b/doc/man3/html_node_set_value.3
new file mode 100644
index 0000000..bc6dc9c
--- /dev/null
+++ b/doc/man3/html_node_set_value.3
@@ -0,0 +1,80 @@
+.TH HTML_NODE_SET_VALUE 3 2023-09-24 0.1.0 "slweb Library Reference"
+
+.SH NAME
+html_node_set_value \- set value to a HTML node
+
+.SH SYNOPSIS
+.LP
+.nf
+#include <slweb/html.h>
+.P
+int html_node_set_value(struct html_node *\fIn\fP, const char *\fIval\fP);
+.fi
+
+.SH DESCRIPTION
+The
+.IR html_node_set_value (3)
+function sets a value to a
+.I struct html_node
+object pointed to by
+.IR n ,
+previously returned by
+.IR html_node_alloc (3)
+or
+.IR html_node_add_child (3).
+.I val
+is a null-terminated string with the value to be assigned to the node.
+
+.I slweb
+allocates a copy of the null-terminated string defined by
+.IR val .
+
+As opposed to
+.IR html_node_set_value_unescaped (3),
+.IR html_node_set_value (3)
+escapes characters that could case syntax errors, such as
+.B <
+.BR "" ( "LESS-THAN SIGN" )
+being translated to
+.BR &lt; .
+
+.SH RETURN VALUE
+On success,
+.IR html_node_set_value (3)
+returns zero. On failure, a negative integer is returned.
+
+.SH EXAMPLE
+A
+.I struct html_node
+object with
+.B example
+as tag name and
+.B hello
+as its value and no attributes would be translated by the HTML
+serializer to:
+
+.PP
+.in +4n
+.EX
+<example>hello</example>
+.EE
+.in
+.PP
+
+.SH ERRORS
+No errors are defined.
+
+.SH SEE ALSO
+.BR html_node_alloc (3),
+.BR html_node_free (3),
+.BR html_node_set_value_unescaped (3),
+.BR html_node_add_attr (3),
+.BR slweb_http (7).
+
+.SH COPYRIGHT
+Copyright (C) 2023 Xavier Del Campo Romero.
+.P
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
diff --git a/doc/man3/html_node_set_value_unescaped.3 b/doc/man3/html_node_set_value_unescaped.3
new file mode 100644
index 0000000..7c3a897
--- /dev/null
+++ b/doc/man3/html_node_set_value_unescaped.3
@@ -0,0 +1,81 @@
+.TH HTML_NODE_SET_VALUE_UNESCAPED 3 2023-09-24 0.1.0 "slweb Library Reference"
+
+.SH NAME
+html_node_set_value_unescaped \- set value to a HTML node
+
+.SH SYNOPSIS
+.LP
+.nf
+#include <slweb/html.h>
+.P
+int html_node_set_value_unescaped(struct html_node *\fIn\fP, const char *\fIval\fP);
+.fi
+
+.SH DESCRIPTION
+The
+.IR html_node_set_value_unescaped (3)
+function sets a value to a
+.I struct html_node
+object pointed to by
+.IR n ,
+previously returned by
+.IR html_node_alloc (3)
+or
+.IR html_node_add_child (3).
+.I val
+is a null-terminated string with the value to be assigned to the node.
+
+.I slweb
+allocates a copy of the null-terminated string defined by
+.IR val .
+
+As opposed to
+.IR html_node_set_value (3),
+.IR html_node_set_value_unescaped (3)
+does not escape characters that could case syntax errors, such as
+.BR <
+.BR "" ( "LESS-THAN SIGN" ).
+This might make
+.IR html_node_set_value_unescaped (3)
+interesting to insert serialized HTML nodes as a value.
+
+.SH RETURN VALUE
+On success,
+.IR html_node_set_value_unescaped (3)
+returns zero. On failure, a negative integer is returned.
+
+.SH EXAMPLE
+A
+.I struct html_node
+object with
+.B example
+as tag name and
+.B hello
+as its value and no attributes would be translated by the HTML
+serializer to:
+
+.PP
+.in +4n
+.EX
+<example>hello</example>
+.EE
+.in
+.PP
+
+.SH ERRORS
+No errors are defined.
+
+.SH SEE ALSO
+.BR html_node_alloc (3),
+.BR html_node_free (3),
+.BR html_node_set_value (3),
+.BR html_node_add_attr (3),
+.BR slweb_http (7).
+
+.SH COPYRIGHT
+Copyright (C) 2023 Xavier Del Campo Romero.
+.P
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
diff --git a/doc/man3/html_serialize.3 b/doc/man3/html_serialize.3
new file mode 100644
index 0000000..59700f1
--- /dev/null
+++ b/doc/man3/html_serialize.3
@@ -0,0 +1,52 @@
+.TH HTML_SERIALIZE 3 2023-09-24 0.1.0 "slweb Library Reference"
+
+.SH NAME
+html_serialize \- add attribute to a HTML node
+
+.SH SYNOPSIS
+.LP
+.nf
+#include <slweb/html.h>
+.P
+int html_serialize(const struct html_node *\fIn\fP, struct dynstr *\fId\fP);
+.fi
+
+.SH DESCRIPTION
+The
+.IR html_serialize (3)
+function takes a
+.I struct html_node
+object pointed to by
+.I n
+and serializes it as a HTML file, as well as all of its children nodes,
+into a null-terminated string.
+.I d
+is a
+.I struct dynstr
+object that must be previously initialized by a call to
+.IR dynstr_init (3),
+to which the null-terminated string shall be written.
+
+.SH RETURN VALUE
+On success,
+.IR html_serialize (3)
+returns zero. On failure, a negative integer is returned.
+
+.SH ERRORS
+No errors are defined.
+
+.SH SEE ALSO
+.BR html_node_alloc (3),
+.BR html_node_free (3),
+.BR html_node_add_attr (3),
+.BR html_node_set_value (3),
+.BR html_node_set_value_unescaped (3),
+.BR slweb_http (7).
+
+.SH COPYRIGHT
+Copyright (C) 2023 Xavier Del Campo Romero.
+.P
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
diff --git a/doc/man3/http_alloc.3 b/doc/man3/http_alloc.3
new file mode 100644
index 0000000..4b9e19b
--- /dev/null
+++ b/doc/man3/http_alloc.3
@@ -0,0 +1,62 @@
+.TH HTTP_ALLOC 3 2023-09-06 0.1.0 "slweb Library Reference"
+
+.SH NAME
+http_alloc \- allocate a HTTP context object
+
+.SH SYNOPSIS
+.LP
+.nf
+#include <slweb/http.h>
+.P
+struct http *http_alloc(const struct http_cfg *\fIcfg\fP);
+.fi
+
+.SH DESCRIPTION
+The
+.IR http_alloc (3)
+function allocates a
+.I "struct http_ctx"
+object, containing the required data by
+.I slweb
+to handle a HTTP connection. This object is meant to be consumed by
+other functions from
+.IR slweb .
+.I cfg
+defines the configuration for the HTTP context, whose structure is defined by
+.IR slweb_http (7).
+
+.I "struct http_ctx"
+is an opaque object internal to
+.I slweb
+and therefore is not accessible to callers.
+
+.SH RETURN VALUE
+On success, an opaque pointer to a
+.I struct http_ctx
+object is returned. On error,
+a null pointer is returned, and
+.I errno
+might be set by the internal call to
+.IR malloc (3).
+
+.SH ERRORS
+Refer to
+.IR malloc (3)
+for a list of possible errors.
+
+.SH NOTES
+This function is designed for internal use by
+\fIslweb\fR.
+
+.SH SEE ALSO
+.BR http_free (3),
+.BR http_update (3),
+.BR slweb_http (7).
+
+.SH COPYRIGHT
+Copyright (C) 2023 Xavier Del Campo Romero.
+.P
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
diff --git a/doc/man3/http_cookie_create.3 b/doc/man3/http_cookie_create.3
new file mode 100644
index 0000000..6587b24
--- /dev/null
+++ b/doc/man3/http_cookie_create.3
@@ -0,0 +1,68 @@
+.TH HTTP_COOKIE_CREATE 3 2023-09-07 0.1.0 "slweb Library Reference"
+
+.SH NAME
+http_cookie_create \- creates a HTTP/1.1 cookie
+
+.SH SYNOPSIS
+.LP
+.nf
+#include <slweb/http.h>
+.P
+char *http_cookie_create(const char *\fIkey\fP, const char *\fIvalue\fP);
+.fi
+
+.SH DESCRIPTION
+The
+.IR http_cookie_create ()
+function allocates a null-terminated string with a HTTP/1.1 cookie
+defined by
+.I key
+and
+.IR value ,
+which are null-terminated strings.
+
+.SH RETURN VALUE
+On success, a null-terminated string with the newly HTTP/1.1 cookie is
+returned. Otherwise, a null pointer is returned.
+
+.SH ERRORS
+No errors are defined.
+
+.SH EXAMPLE
+A successful call to
+.IR http_cookie_create (3)
+with
+.I ExampleValue
+as
+.I key
+and
+.I ExampleValue
+as
+.I value
+might return a null-terminated string such as the one below:
+
+.LP
+.in +4n
+.EX
+ExampleHeader=ExampleValue; HttpOnly; Expires Wed, 07 Sep 2023 00:00:00 GMT
+.EE
+.in
+
+.SH FUTURE DIRECTIONS
+
+.I slweb
+sets a 1-year expiration date for HTTP cookies due to arbitrary design
+limitations. Future versions of this library shall allow a custom
+expiration date as an additional parameter to
+.IR http_cookie_create (3).
+
+.SH SEE ALSO
+.BR slweb_http (7).
+
+.SH COPYRIGHT
+Copyright (C) 2023 Xavier Del Campo Romero.
+.P
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
diff --git a/doc/man3/http_encode_url.3 b/doc/man3/http_encode_url.3
new file mode 100644
index 0000000..94bd7f8
--- /dev/null
+++ b/doc/man3/http_encode_url.3
@@ -0,0 +1,38 @@
+.TH HTTP_ENCODE_URL 3 2023-09-07 0.1.0 "slweb Library Reference"
+
+.SH NAME
+http_encode_url \- allocates a percent-encoded null-terminated string
+
+.SH SYNOPSIS
+.LP
+.nf
+#include <slweb/http.h>
+.P
+char *http_encode_url(const char *\fIurl\fP);
+.fi
+
+.SH DESCRIPTION
+The
+.IR http_encode_url ()
+function encodes the null-terminated string given by
+.I url
+using percent-encoding as defined by RFC 3986.
+
+.SH RETURN VALUE
+On success, a valid pointer to a percent-encoded, null-terminated
+string is returned. On failure, a null pointer is returned.
+
+.SH ERRORS
+No errors are defined.
+
+.SH SEE ALSO
+.BR http_decode_url (3),
+.BR slweb_http (7).
+
+.SH COPYRIGHT
+Copyright (C) 2023 Xavier Del Campo Romero.
+.P
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
diff --git a/doc/man3/http_free.3 b/doc/man3/http_free.3
new file mode 100644
index 0000000..3b8b61d
--- /dev/null
+++ b/doc/man3/http_free.3
@@ -0,0 +1,41 @@
+.TH HTTP_FREE 3 2023-09-06 0.1.0 "slweb Library Reference"
+
+.SH NAME
+http_free \- free a HTTP context object
+
+.SH SYNOPSIS
+.LP
+.nf
+#include <slweb/http.h>
+.P
+void http_free(struct http_ctx *\fIh\fP);
+.fi
+
+.SH DESCRIPTION
+The
+.IR http_free (3)
+function frees the memory space pointed to by
+.IR h ,
+which must have been returned by a previous call to
+.IR http_alloc (3).
+
+.SH RETURN VALUE
+The
+.IR http_free (3)
+function returns no value.
+
+.SH ERRORS
+No errors are defined.
+
+.SH SEE ALSO
+.BR http_alloc (3),
+.BR http_update (3),
+.BR slweb_http (7).
+
+.SH COPYRIGHT
+Copyright (C) 2023 Xavier Del Campo Romero.
+.P
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
diff --git a/doc/man3/http_response_add_header.3 b/doc/man3/http_response_add_header.3
new file mode 100644
index 0000000..4f033ea
--- /dev/null
+++ b/doc/man3/http_response_add_header.3
@@ -0,0 +1,53 @@
+.TH HTTP_RESPONSE_ADD_HEADER 3 2023-09-07 0.1.0 "slweb Library Reference"
+
+.SH NAME
+http_response_add_header \- adds a HTTP/1.1 header to a response
+
+.SH SYNOPSIS
+.LP
+.nf
+#include <slweb/http.h>
+.P
+int http_response_add_header(struct http_response *\fIr\fP, const char *\fIheader\fP, const char *\fIvalue\fP);
+.fi
+
+.SH DESCRIPTION
+The
+.IR http_response_add_header ()
+function updates a
+.I "struct http_response"
+object pointed to by
+.IR r
+by adding a new HTTP response to it, defined by
+.I header
+and
+.IR value ,
+which are null-terminated strings defining the key
+and value for the HTTP header, respectively.
+
+.SH RETURN VALUE
+On success, zero is returned. If a fatal error ocurrs, a negative
+integer is returned, and
+.I errno
+might be set by the internal calls to
+.IR realloc (3)
+or
+.IR strdup (3).
+
+.SH ERRORS
+Refer to
+.IR realloc (3)
+and
+.IR strdup (3)
+for a list of possible errors.
+
+.SH SEE ALSO
+.BR slweb_http (7).
+
+.SH COPYRIGHT
+Copyright (C) 2023 Xavier Del Campo Romero.
+.P
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
diff --git a/doc/man3/http_update.3 b/doc/man3/http_update.3
new file mode 100644
index 0000000..7f54608
--- /dev/null
+++ b/doc/man3/http_update.3
@@ -0,0 +1,76 @@
+.TH HTTP_UPDATE 3 2023-09-06 0.1.0 "slweb Library Reference"
+
+.SH NAME
+http_update \- updates a HTTP context object
+
+.SH SYNOPSIS
+.LP
+.nf
+#include <slweb/http.h>
+.P
+int http_update(struct http_ctx *\fIh\fP, bool *\fIwrite\fP, bool *\fIclose\fP);
+.fi
+
+.SH DESCRIPTION
+The
+.IR http_update ()
+function updates a
+.I "struct http_ctx"
+object previously allocated by
+.IR http_alloc (3),
+handling any pending data to be received/sent from/to a client.
+This function might call one or more of the callbacks defined by the
+.I "struct http_cfg"
+object given by the previous call to
+.IR http_alloc (3).
+
+.I http_update
+shall assign the
+.I bool
+object pointed to by
+.I write
+to
+.I true
+if there is pending data to be sent to the client. Otherwise, it shall
+assigned to
+.IR false .
+
+.IR http_update ()
+shall assign the
+.I bool
+object pointed to by
+.I close
+to
+.I true
+if the connection must be closed by the caller. Otherwise, it shall be
+assigned to
+.IR false .
+
+This function should be called anytime there is available data for
+input or output.
+
+.SH RETURN VALUE
+On success, zero is returned. If a fatal error ocurrs, a negative
+integer is returned. If a non-fatal error caused by malformed client
+input occurs, a positive integer is returned and the connection against
+the client shall be closed.
+
+.SH ERRORS
+No errors are defined.
+
+.SH NOTES
+This function is designed for internal use by
+.IR slweb .
+
+.SH SEE ALSO
+.BR http_free (3),
+.BR http_update (3),
+.BR slweb_http (7).
+
+.SH COPYRIGHT
+Copyright (C) 2023 Xavier Del Campo Romero.
+.P
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.