Begin documenting Str.

This commit is contained in:
Jordan Bancino 2023-02-14 11:56:22 +00:00
parent 653d282bcd
commit f7d581538d
2 changed files with 49 additions and 4 deletions

46
man/man3/Str.3 Normal file
View file

@ -0,0 +1,46 @@
.Dd $Mdocdate: February 14 2023 $
.Dt STR 3
.Os Telodendria Project
.Sh NAME
.Nm Str
.Nd Functions for manipulating and creating strings.
.Sh SYNOPSIS
.In Str.h
.Ft char *
.Fn StrUtf8Encode "unsigned long"
.Ft char *
.Fn StrDuplicate "const char *"
.Ft char *
.Fn StrConcat "size_t" "..."
.Ft char *
.Fn StrRandom "size_t"
.Sh DESCRIPTION
.Nm
provides string-related functions. It is called
.Nm ,
not String, because some platforms (Windows) do not have
case-sensitive filesystems, so String and string are the same thing, which poses
a problem because string is a standard library header.
.Pp
.Fn StrUtf8Encode
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 StrDuplicate
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 long amounts
of time, even perhaps after the original string is gone.
.Pp
.Fn StrConcat
is a var-args function that takes the number of NULL-terminated strings specified
by the first argument, and returns a new string that contains their concatenation.
It works a lot like
.Xr strcat 3 ,
but it takes care of allocating memory big enough to hold all the strings. Any
strings may be NULL. If a string is NULL, it is treated like an empty string.
.Pp
.Fn StrRandom
generates a random string of the specified length.
.Sh RETURN VALUES
.Sh SEE ALSO

View file

@ -49,17 +49,16 @@ extern User *
UserCreate(Db *, char *, char *); UserCreate(Db *, char *, char *);
extern User * extern User *
UserLock(Db *, char *name); UserLock(Db *, char *);
extern User * extern User *
UserAuthenticate(Db *, char *accessToken); UserAuthenticate(Db *, char *);
extern int extern int
UserUnlock(User *); UserUnlock(User *);
extern UserLoginInfo * extern UserLoginInfo *
UserLogin(User *, char *password, char *deviceId, char *deviceDisplayName, UserLogin(User *, char *, char *, char *, int);
int withRefresh);
extern char * extern char *
UserGetName(User *); UserGetName(User *);