Update lots of documentation.

This commit is contained in:
Jordan Bancino 2023-02-15 01:32:44 +00:00
parent f7d581538d
commit a7c1ccd3f1
5 changed files with 29 additions and 73 deletions

View file

@ -27,12 +27,13 @@ Milestone: v0.2.0
[x] Document MemoryHexDump() [x] Document MemoryHexDump()
[x] Document DbExists() [x] Document DbExists()
[ ] Document UserInteractiveAuth (move docs from Matrix)
[x] Document User [x] Document User
[ ] Move docs from Matrix to User for UserValidate [x] Document Str and remove old functions from Util docs.
[ ] Document Str and remove old functions from Util docs. [x] Move docs from Matrix to User for UserValidate
[ ] Document UserInteractiveAuth (move docs from Matrix)
[ ] Clean up scripts (make tools/lib/matrix.sh) [ ] Clean up scripts (make tools/lib/matrix.sh)
[ ] Scripts to generate index with list of man pages and releases?
[x] Update changelog [x] Update changelog
[x] Fix man page links on website [x] Fix man page links on website

View file

@ -1,4 +1,4 @@
.Dd $Mdocdate: December 18 2022 $ .Dd $Mdocdate: February 15 2023 $
.Dt MATRIX 3 .Dt MATRIX 3
.Os Telodendria Project .Os Telodendria Project
.Sh NAME .Sh NAME
@ -16,10 +16,6 @@
.Fn MatrixAuthenticate "HttpServerContext *" "Db *" .Fn MatrixAuthenticate "HttpServerContext *" "Db *"
.Ft HashMap * .Ft HashMap *
.Fn MatrixRateLimit "HttpServerContext *" "Db *" .Fn MatrixRateLimit "HttpServerContext *" "Db *"
.Ft int
.Fn MatrixUserValidate "char *" "char *"
.Ft int
.Fn MatrixHistoricalUserValidate "char *" "char *"
.Sh DESCRIPTION .Sh DESCRIPTION
.Nm .Nm
provides some helper functions that bind to the provides some helper functions that bind to the
@ -104,18 +100,6 @@ user is authenticated.
determines whether or not the request should be rate limited. It is determines whether or not the request should be rate limited. It is
expected that this will occur before most, if not all of the caller's expected that this will occur before most, if not all of the caller's
logic. logic.
.Pp
.Fn MatrixUserValidate
and
.Fn MatrixHistoricalUserValidate
take a Matrix ID local part and a domain name, in that order, and
check to see if it is valid according to the specification.
.Fn MatrixUserValidate
checks for a strictly spec-compliant user ID, but the specification
also requires historical usernames which do not meet the requirements
of the latest speck to also be supported, so
.Fn MatrixHistoricalUserValidate
can be used in cases where historical usernames may be dealt with.
.Sh RETURN VALUES .Sh RETURN VALUES
.Pp .Pp
.Fn MatrixErrorCreate .Fn MatrixErrorCreate
@ -131,12 +115,6 @@ return NULL, then the caller can proceed assuming that all is well
and no further action needs to be taken. If these functions do not and no further action needs to be taken. If these functions do not
return NULL, then the returned JSON object should be passed along to the return NULL, then the returned JSON object should be passed along to the
client immediately without continuing. client immediately without continuing.
.Pp
.Fn MatrixUserValidate
and
.Fn MatrixHistoricalUserValidate
return a boolean value, where 0 indicates the provided ID is
not valid, and non-zero values indicate the provided ID is valid.
.Sh SEE ALSO .Sh SEE ALSO
.Xr HttpServer 3 , .Xr HttpServer 3 ,
.Xr Log 3 , .Xr Log 3 ,

View file

@ -1,4 +1,4 @@
.Dd $Mdocdate: February 14 2023 $ .Dd $Mdocdate: February 15 2023 $
.Dt STR 3 .Dt STR 3
.Os Telodendria Project .Os Telodendria Project
.Sh NAME .Sh NAME
@ -43,4 +43,13 @@ strings may be NULL. If a string is NULL, it is treated like an empty string.
.Fn StrRandom .Fn StrRandom
generates a random string of the specified length. generates a random string of the specified length.
.Sh RETURN VALUES .Sh RETURN VALUES
.Pp
.Fn StrUtf8Encode ,
.Fn StrDuplicate ,
.Fn StrConcat ,
and
.Fn StrRandom
return a pointer to a NULL-terminated C string on the heap, or NULL if a memory
allocation error occurs. Returned pointers should be freed using the Memory API.
.Sh SEE ALSO .Sh SEE ALSO
.Xr Memory 3

View file

@ -1,4 +1,4 @@
.Dd $Mdocdate: December 15 2022 $ .Dd $Mdocdate: February 15 2023 $
.Dt UTIL 3 .Dt UTIL 3
.Os Telodendria Project .Os Telodendria Project
.Sh NAME .Sh NAME
@ -12,12 +12,6 @@
.Fn UtilLastModified "char *" .Fn UtilLastModified "char *"
.Ft int .Ft int
.Fn UtilMkdir "const char *" "const mode_t" .Fn UtilMkdir "const char *" "const mode_t"
.Ft char *
.Fn UtilUtf8Encode "unsigned long"
.Ft char *
.Fn UtilStringDuplicate "char *"
.Ft char *
.Fn UtilStringConcat "char *" "char *"
.Ft int .Ft int
.Fn UtilSleepMillis "long" .Fn UtilSleepMillis "long"
.Ft size_t .Ft size_t
@ -26,8 +20,6 @@
.Fn UtilGetDelim "char **" "size_t *" "int" "FILE *" .Fn UtilGetDelim "char **" "size_t *" "int" "FILE *"
.Ft ssize_t .Ft ssize_t
.Fn UtilGetLine "char **" "size_t *" "FILE *" .Fn UtilGetLine "char **" "size_t *" "FILE *"
.Ft char *
.Fn UtilRandomString "size_t"
.Sh DESCRIPTION .Sh DESCRIPTION
.Pp .Pp
This header holds a number of random functions related to strings, This header holds a number of random functions related to strings,
@ -55,17 +47,6 @@ behaves just like the system call
but it creates any intermediate directories if necessary, unlike but it creates any intermediate directories if necessary, unlike
.Xr mkdir 2 . .Xr mkdir 2 .
.Pp .Pp
.Fn UtilUtf8Encode
takes a UTF-8 codepoint and encodes it into a string buffer
containing between 1 and 4 bytes. The string buffer is allocated
on the heap, so it should be freed when it is no longer needed.
.Pp
.Fn UtilStringDuplicate
duplicates a NULL-terminated string, and returns a new string on the
heap. This is useful when a function takes in a string that it needs
to store for for long amounts of time, even perhaps after the
original string is long gone.
.Pp
.Fn UtilSleepMillis .Fn UtilSleepMillis
sleeps the calling thread for the given number of milliseconds. It sleeps the calling thread for the given number of milliseconds. It
occurred to me that POSIX does not specify a super friendly way to occurred to me that POSIX does not specify a super friendly way to
@ -79,14 +60,6 @@ uses
to get the last modified time of the given file. This is used to get the last modified time of the given file. This is used
primarily for caching file data. primarily for caching file data.
.Pp .Pp
.Fn UtilStringConcat
takes in two NULL-terminated strings and returns their concatenation.
It works a lot like
.Xr strcat 3 ,
but it takes care of allocating memory big enough to hold both
strings. One or both strings may be NULL. If a string is NULL, it
is treated like an empty string.
.Pp
.Fn UtilParseBytes .Fn UtilParseBytes
is a highly specialized function used in parsing the configuration file. is a highly specialized function used in parsing the configuration file.
It takes in a string which is supposed to represent a number of bytes. It takes in a string which is supposed to represent a number of bytes.
@ -100,12 +73,6 @@ work identically to the POSIX equivalents, documented in
.Xr getdelim 3 , .Xr getdelim 3 ,
except it assumes pointers were allocated using the Memory API, and it except it assumes pointers were allocated using the Memory API, and it
uses the Memory API itself to reallocate necessary pointers. uses the Memory API itself to reallocate necessary pointers.
.Pp
.Fn UtilRandomString
generates a random string of the given length. At the moment, it only
selects from uppercase and lowercase numbers, but the character set may
be expanded in the future, or a function may be added to specify an
arbitrary character set.
.Sh RETURN VALUES .Sh RETURN VALUES
.Pp .Pp
.Fn UtilServerTs .Fn UtilServerTs
@ -124,13 +91,6 @@ It also sets errno as appropriate.
returns the result of calling returns the result of calling
.Xr nanosleep 2 . .Xr nanosleep 2 .
.Pp .Pp
.Fn UtilUtf8Encode ,
.Fn UtilStringDuplicate ,
and
.Fn UtilStringConcat
return a NULL-terminated string on the heap if they succeed, or NULL on failure.
Typically a failure in these functions indicate an error allocating memory.
.Pp
.Fn UtilParseBytes .Fn UtilParseBytes
returns a number of bytes, or 0 if there was an error parsing the byte string. returns a number of bytes, or 0 if there was an error parsing the byte string.
.Pp .Pp
@ -139,7 +99,3 @@ and
.Fn UtilGetLine .Fn UtilGetLine
return the same value as their POSIX equivalents, documented in return the same value as their POSIX equivalents, documented in
.Xr getdelim 3 . .Xr getdelim 3 .
.Pp
.Fn UtilRandomString
returns a string, allocated on the heap, of the given length, or NULL if there
was an error allocating memory.

View file

@ -287,11 +287,23 @@ A simple implementation of the SHA2 hashing functions.
A basic periodic job scheduler. A basic periodic job scheduler.
</td> </td>
</tr> </tr>
<tr>
<td><a href="man/man3/User.3.html">User(3)</a></td>
<td>
Convenience functions for working with local users.
</td>
</tr>
<tr>
<td><a href="man/man3/Str.3.html">Str(3)</a></td>
<td>
Functions for manipulating and creating strings.
</td>
</tr>
</table> </table>
</details> </details>
<hr> <hr>
<p> <p>
&copy; 2022 Jordan Bancino &lt;@jordan:bancino.net&gt; &copy; 2023 Jordan Bancino &lt;@jordan:bancino.net&gt;
<br> <br>
Updated on ${DATE}. Updated on ${DATE}.
</p> </p>