Collection of verious utilities that do not have a place of their own, yet.
More...
|
| size_t | util_strlcpy (char *dst, const char *src, size_t dst_size) |
| |
| size_t | util_strlncat (char *dst, const char *src, size_t dst_size, size_t nchars) |
| |
| size_t | util_strlcat (char *dst, const char *src, size_t dst_size) |
| |
| void | util_strrep (char *out, size_t outsz, char *in, char *findstr, char *replacestr) |
| |
| char * | util_strsep (char **pinputstr, const char *delim) |
| |
| void | util_chomp (char *str) |
| |
| void | util_cp1252_to_utf8 (char *utf8, ssize_t utf8_sz, char *cp1252) |
| |
|
bool | clipboard_set_text (char *text) |
| |
|
bool | clipboard_get_text (char *text, size_t text_sz) |
| |
|
bool | sys_is_admin (bool *isadmin) |
| |
|
bool | sys_runas_admin (char *path) |
| |
|
bool | sys_self_exe (char *path, size_t pathsz) |
| |
|
bool | sys_self_elevate (void) |
| |
|
bool | sys_perm_grant (char *path) |
| |
|
FILE * | sys_fopen_force (char *path, char *mode) |
| |
|
bool | sys_appdata_path (char *path, size_t pathsz) |
| |
|
uint64_t | sys_monotime (void) |
| |
|
bool | reg_read_key (char *key, char *val, void *buf, size_t buflen) |
| |
| #define | UTIL_MAX_PATH PATH_MAX |
| |
Collection of verious utilities that do not have a place of their own, yet.
- Note
- Only Windows specific functions are documented
| #define UTIL_MAX_PATH PATH_MAX |
| void util_chomp |
( |
char * |
str) | |
|
This function this function removes new-lines characters and blanks from the end of the string
- Parameters
-
| [in] | str | String to be chomped |
| void util_cp1252_to_utf8 |
( |
char * |
utf8, |
|
|
ssize_t |
utf8_sz, |
|
|
char * |
cp1252 |
|
) |
| |
Convert a string from the CP-1252(aka Windows-1252, Latin1) codeset to UTF8, yay!
- Parameters
-
| [in] | cp1252 | Input string in the CP-1252 encoding |
| [out] | utf8 | Output UTF8 string |
| [out] | utf8_sz | Maximum size of the UTF8 string |
| size_t util_strlcat |
( |
char * |
dst, |
|
|
const char * |
src, |
|
|
size_t |
dst_size |
|
) |
| |
Equivalent of the strlcat() function from the *BSD world. See util_strlcpy() for the rant.
- Note
- This function is just a wrapper for util_strlncat()
- Parameters
-
| [in,out] | dst | String that we're appending to |
| [in] | src | String that will be appended |
| [in] | dst_size | Maximum size of dst |
- Returns
- Number of bytes stored to
dst
| size_t util_strlcpy |
( |
char * |
dst, |
|
|
const char * |
src, |
|
|
size_t |
dst_size |
|
) |
| |
This is a safe string copy function, it never overflows. In the *BSD world it's know as strlcpy().
Thansk to Ulrich Drepper, these two functions probably get the re-inventing-the-wheel-over-and-over-again award.
- Note
- If dst is too small to hold src, it is safely truncated.
- Parameters
-
| [out] | dst | Buffer that will receive the string from src |
| [in] | src | Input string |
| [in] | dst_size | Maximum size of dst; if a larger string is copied it is truncated and padded with '\0' |
- Returns
- Number of bytes stored to dst (not counting the ending null char)
| size_t util_strlncat |
( |
char * |
dst, |
|
|
const char * |
src, |
|
|
size_t |
dst_size, |
|
|
size_t |
nchars |
|
) |
| |
Equivalent of the strncat() except it copies the string safely while padding it with '\0'
- Parameters
-
| [in,out] | dst | String that we're appending to |
| [in] | src | String that will be appended |
| [in] | dst_size | Maximum size of dst |
| [in] | nchars | Maximum number of characters to copy from src |
- Returns
- Number of bytes stored to
dst
| void util_strrep |
( |
char * |
out, |
|
|
size_t |
outsz, |
|
|
char * |
in, |
|
|
char * |
findstr, |
|
|
char * |
replacestr |
|
) |
| |
Stirng replace: Find all occurences of string findstr in string in and replace them with the string replacestr. Store the result to out
- Parameters
-
| [out] | out | Output buffer where the result will be stored |
| [in] | outsz | Maximum size of the output buffer |
| [in] | in | Input string, this string will be searched for findstr |
| [in] | findstr | String to find |
| [in] | replacestr | String to replace findstr with |
| char* util_strsep |
( |
char ** |
pinputstr, |
|
|
const char * |
delim |
|
) |
| |
There's no strsep() on MinGW, so we have to implement our own
- Note
- This function should be equivalent to a POSIX strsep()
- Parameters
-
| [in,out] | pinputstr | String to scan for delim |
| [in] | delim | Delimiters |