diff --git a/man/man3/Str.3 b/man/man3/Str.3 new file mode 100644 index 0000000..48efaff --- /dev/null +++ b/man/man3/Str.3 @@ -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 diff --git a/src/include/User.h b/src/include/User.h index 9d2930c..195adee 100644 --- a/src/include/User.h +++ b/src/include/User.h @@ -49,17 +49,16 @@ extern User * UserCreate(Db *, char *, char *); extern User * - UserLock(Db *, char *name); + UserLock(Db *, char *); extern User * - UserAuthenticate(Db *, char *accessToken); + UserAuthenticate(Db *, char *); extern int UserUnlock(User *); extern UserLoginInfo * -UserLogin(User *, char *password, char *deviceId, char *deviceDisplayName, - int withRefresh); + UserLogin(User *, char *, char *, char *, int); extern char * UserGetName(User *);