aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi92@disroot.org>2025-10-09 11:18:03 +0200
committerXavier Del Campo Romero <xavi92@disroot.org>2025-10-09 11:28:59 +0200
commitde7f4b2ffcd92dfeada9235ce857b801a4851da7 (patch)
treefb42b5f79f1ce3b1486de9883ee0305055b1b470
parente85d90fbf37cbd5a3264a2debd9b51438836c729 (diff)
Add man3 pages for the form APIv0.5.0
-rw-r--r--doc/man3/Makefile4
-rw-r--r--doc/man3/form_alloc.359
-rw-r--r--doc/man3/form_foreach.354
-rw-r--r--doc/man3/form_free.343
-rw-r--r--doc/man3/form_value.347
5 files changed, 207 insertions, 0 deletions
diff --git a/doc/man3/Makefile b/doc/man3/Makefile
index 6c0d414..cdfff3d 100644
--- a/doc/man3/Makefile
+++ b/doc/man3/Makefile
@@ -5,6 +5,10 @@ datarootdir = $(prefix)/share
mandir = $(datarootdir)/man
man3dir = $(mandir)/man3
OBJECTS = \
+ $(DESTDIR)$(man3dir)/form_alloc.3 \
+ $(DESTDIR)$(man3dir)/form_foreach.3 \
+ $(DESTDIR)$(man3dir)/form_free.3 \
+ $(DESTDIR)$(man3dir)/form_value.3 \
$(DESTDIR)$(man3dir)/handler_add.3 \
$(DESTDIR)$(man3dir)/handler_alloc.3 \
$(DESTDIR)$(man3dir)/handler_free.3 \
diff --git a/doc/man3/form_alloc.3 b/doc/man3/form_alloc.3
new file mode 100644
index 0000000..33ba4d5
--- /dev/null
+++ b/doc/man3/form_alloc.3
@@ -0,0 +1,59 @@
+.TH FORM_ALLOC 3 2025-10-09 0.5.0 "libweb Library Reference"
+
+.SH NAME
+form_alloc \- parse application/x-www-form-urlencoded data
+
+.SH SYNOPSIS
+.LP
+.nf
+#include <libweb/form.h>
+.P
+int form_alloc(const char *\fIdata\fP, struct form **\fIf\fP);
+.fi
+
+.SH DESCRIPTION
+The
+.IR form_alloc (3)
+function parses a
+.I application/x-www-form-urlencoded
+human-readable string from
+.I data
+and, if successful, allocates a
+.I struct form
+instance into
+.IR f ,
+which can then be used by other functions from this library.
+
+.SH RETURN VALUE
+On success, zero is returned and
+.I f
+is initialized to a valid pointer.
+If
+.I data
+contains invalid data,
+a positive integer is returned and
+.I f
+is not modified.
+On fatal errors (e.g.: a failed memory allocation),
+a negative integer is returned and
+.I f
+is not modified.
+
+.SH EXAMPLE
+See
+.IR libweb_form (7)
+for a complete example on how to use this library.
+
+.SH SEE ALSO
+.BR form_value (3),
+.BR form_foreach (3),
+.BR form_free (3),
+.BR libweb_form (7).
+
+.SH COPYRIGHT
+Copyright (C) 2023-2025 libweb contributors
+.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/form_foreach.3 b/doc/man3/form_foreach.3
new file mode 100644
index 0000000..1c28600
--- /dev/null
+++ b/doc/man3/form_foreach.3
@@ -0,0 +1,54 @@
+.TH FORM_FOREACH 3 2025-10-09 0.5.0 "libweb Library Reference"
+
+.SH NAME
+form_foreach \- parse application/x-www-form-urlencoded data
+
+.SH SYNOPSIS
+.LP
+.nf
+#include <libweb/form.h>
+.P
+typedef int (*\fIform_iter\fP)(const char *\fIkey\fP, const char *\fIvalue\fP, void *\fIuser\fP);
+
+int form_foreach(const struct form *\fIf\fP, form_iter \fIit\fP, void *\fIuser\fP);
+.fi
+
+.SH DESCRIPTION
+The
+.IR form_foreach (3)
+function takes a
+.I struct form
+instance previously allocated by
+.IR form_alloc (3),
+pointed to by
+.IR f ,
+and iterates over the object, calling the user-defined function pointed to by
+.I it
+for every key-value pair.
+
+.SH RETURN VALUE
+On success, zero is returned.
+Any non-zero return value coming from
+.I it
+makes
+.IR form_foreach (3)
+to stop its execution and propagate the return value to the caller.
+
+.SH EXAMPLE
+See
+.IR libweb_form (7)
+for a complete example on how to use this library.
+
+.SH SEE ALSO
+.BR form_alloc (3),
+.BR form_value (3),
+.BR form_free (3),
+.BR libweb_form (7).
+
+.SH COPYRIGHT
+Copyright (C) 2023-2025 libweb contributors
+.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/form_free.3 b/doc/man3/form_free.3
new file mode 100644
index 0000000..b0f5f65
--- /dev/null
+++ b/doc/man3/form_free.3
@@ -0,0 +1,43 @@
+.TH FORM_FREE 3 2025-10-09 0.5.0 "libweb Library Reference"
+
+.SH NAME
+form_free \- parse application/x-www-form-urlencoded data
+
+.SH SYNOPSIS
+.LP
+.nf
+#include <libweb/form.h>
+.P
+void form_free(struct form *\fIf\fP);
+.fi
+
+.SH DESCRIPTION
+The
+.IR form_free (3)
+function deallocates a
+.I struct form
+instance previously allocated by
+.IR form_alloc (3),
+pointed to by
+.IR f .
+.IR form_free (3)
+does nothing on a null pointer.
+
+.SH EXAMPLE
+See
+.IR libweb_form (7)
+for a complete example on how to use this library.
+
+.SH SEE ALSO
+.BR form_alloc (3),
+.BR form_value (3),
+.BR form_foreach (3),
+.BR libweb_form (7).
+
+.SH COPYRIGHT
+Copyright (C) 2023-2025 libweb contributors
+.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/form_value.3 b/doc/man3/form_value.3
new file mode 100644
index 0000000..1eaf46b
--- /dev/null
+++ b/doc/man3/form_value.3
@@ -0,0 +1,47 @@
+.TH FORM_VALUE 3 2025-10-09 0.5.0 "libweb Library Reference"
+
+.SH NAME
+form_value \- parse application/x-www-form-urlencoded data
+
+.SH SYNOPSIS
+.LP
+.nf
+#include <libweb/form.h>
+.P
+const char *form_value(const struct form *\fIf\fP, const char *\fIkey\fP);
+.fi
+
+.SH DESCRIPTION
+The
+.IR form_value (3)
+function takes a
+.I struct form
+instance previously allocated by
+.IR form_alloc (3),
+pointed to by
+.IR f ,
+and returns the value for a given
+.IR key .
+
+.SH RETURN VALUE
+On success, a valid pointer with the pair value is returned.
+Otherwise, a null pointer is returned.
+
+.SH EXAMPLE
+See
+.IR libweb_form (7)
+for a complete example on how to use this library.
+
+.SH SEE ALSO
+.BR form_alloc (3),
+.BR form_foreach (3),
+.BR form_free (3),
+.BR libweb_form (7).
+
+.SH COPYRIGHT
+Copyright (C) 2023-2025 libweb contributors
+.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.