DSL
|
Classes | |
class | StrTokenizer |
Macros | |
#define | sstrcpy(x, y) strlcpy(x,y,sizeof(x)) |
#define | sstrcat(x, y) strlcat(x,y,sizeof(x)) |
#define | TRIM_LEFT 0x01 |
#define | TRIM_RIGHT 0x02 |
#define | TRIM_BOTH (TRIM_LEFT|TRIM_RIGHT) |
#define | str_replace str_replaceA |
#define | tchar2char tchar2charA |
#define | tcstombs tcstombsA |
#define | tcstowcs tcstowcsA |
#define | mbstotcs mbstotcsA |
#define | wcstotcs wcstotcsA |
#define | nopath nopathA |
#define | GetUserConfigFolder GetUserConfigFolderA |
#define | GetUserConfigFile GetUserConfigFileA |
#define | GetUserDocumentsFolder GetUserDocumentsFolderA |
Functions | |
DSL_API_CLASS const char *DSL_CC | nopathA (const char *filename) |
Returns just the file portion of the full path and filename. | |
DSL_API_CLASS const wchar_t *DSL_CC | nopathW (const wchar_t *filename) |
Returns just the file portion of the full path and filename. | |
DSL_API_CLASS char *DSL_CC | nopathA (char *filename) |
Returns just the file portion of the full path and filename. | |
DSL_API_CLASS wchar_t *DSL_CC | nopathW (wchar_t *filename) |
Returns just the file portion of the full path and filename. | |
DSL_API_CLASS char *DSL_CC | bin2hex (const uint8_t *data, size_t datalen, char *out, size_t outsize) |
DSL_API_CLASS string DSL_CC | bin2hex (const uint8_t *data, size_t datalen) |
DSL_API_CLASS bool DSL_CC | hex2bin (const char *instr, size_t inlen, uint8 *out, size_t outsize) |
DSL_API_CLASS bool DSL_CC | hex2bin (const char *instr, uint8 *out, size_t outsize) |
DSL_API_CLASS bool DSL_CC | hex2bin (const string instr, vector< uint8_t > &out) |
DSL_API void DSL_CC | PrintData (FILE *fp, const uint8 *ptr, size_t len) |
Prints binary data in a pretty format. | |
DSL_API char *DSL_CC | strlwr (char *str) |
Linux version of strlwr. | |
DSL_API uint32 DSL_CC | GetTickCount () |
Linux version of GetTickCount. | |
DSL_API uint64 DSL_CC | GetTickCount64 () |
Linux version of GetTickCount64. | |
DSL_API bool DSL_CC | dsl_mkdir_r (const char *p, int mode) |
Cross-platform recursive mkdir() | |
DSL_API bool DSL_CC | strempty (const char *p) |
Returns true if a string is empty (p == NULL || *p == 0) | |
DSL_API int64 DSL_CC | dsl_clamp (int64 value, int64 vMin, int64 vMax) |
Clamps a given value to the range of vMin to vMax (inclusive) | |
DSL_API_CLASS char *DSL_CC | escapeshellarg (const char *p, char *out, size_t outSize) |
Escapes an argument for passing to shell functions, only escapes quotes atm so keep that in mind. | |
DSL_API_CLASS string DSL_CC | escapeshellarg (const string &str) |
Escapes an argument for passing to shell functions, only escapes quotes atm so keep that in mind. | |
DSL_API size_t DSL_CC | strlcpy (char *dst, const char *src, size_t siz) |
DSL_API size_t DSL_CC | strlcat (char *dst, const char *src, size_t siz) |
DSL_API char *DSL_CC | strtrim (char *buf, const char *trim="\r\n\t ", uint8 sides=TRIM_BOTH) |
DSL_API int DSL_CC | wildcmp (const char *wild, const char *string) |
DSL_API int DSL_CC | wildicmp (const char *wild, const char *string) |
DSL_API int DSL_CC | wildicmp_multi (const char *wild, const char *string, const char *sep="|") |
DSL_API int64 DSL_CC | fseek64 (FILE *fp, int64 offset, int whence) |
Cross-platform 64-bit fseek. | |
DSL_API int64 DSL_CC | ftell64 (FILE *fp) |
Cross-platform 64-bit ftell. | |
DSL_API int64 DSL_CC | filesize (const char *fn) |
Get the size in bytes of a file. | |
DSL_API_CLASS bool DSL_CC | file_get_contents (const string &fn, vector< uint8 > &data, int64 maxSize=INT32_MAX) |
DSL_API_CLASS bool DSL_CC | file_get_contents (const string &fn, string &data, int64 maxSize=INT32_MAX) |
DSL_API_CLASS bool DSL_CC | file_get_contents (const string &fn, uint8 **data, int64 &fileSize, int64 maxSize=INT32_MAX) |
free data with dsl_free() More... | |
DSL_API_CLASS bool DSL_CC | file_put_contents (const string &fn, const vector< uint8 > &data, bool append=false) |
DSL_API_CLASS bool DSL_CC | file_put_contents (const string &fn, const string &data, bool append=false) |
DSL_API_CLASS bool DSL_CC | file_put_contents (const string &fn, const uint8 *data, size_t fileSize, bool append=false) |
DSL_API int64 DSL_CC | copy_file (const string &src, const string &dest, bool allow_overwrite=false) |
DSL_API_CLASS int DSL_CC | str_replaceA (char *Str, size_t BufSize, const char *FindStr, const char *ReplStr) |
Simple string replacement. | |
DSL_API_CLASS int DSL_CC | str_replaceW (wchar_t *Str, size_t BufSize, const wchar_t *FindStr, const wchar_t *ReplStr) |
Simple string replacement. | |
DSL_API_CLASS string DSL_CC | str_replaceA (const string &str, const string &FindStr, const string &ReplStr) |
Simple string replacement. | |
DSL_API_CLASS wstring DSL_CC | str_replaceW (const wstring &str, const wstring &FindStr, const wstring &ReplStr) |
Simple string replacement. | |
DSL_API char *DSL_CC | tchar2charA (char *str) |
DSL_API char *DSL_CC | tchar2charW (wchar_t *str) |
DSL_API_CLASS char *DSL_CC | GetUserConfigFolderA (const char *name) |
DSL_API_CLASS string DSL_CC | GetUserConfigFolderA (const string &name) |
DSL_API_CLASS char *DSL_CC | GetUserConfigFileA (const char *name, const char *fn) |
DSL_API_CLASS string DSL_CC | GetUserConfigFileA (const string &name, const string &fn) |
DSL_API wchar_t *DSL_CC | GetUserConfigFolderW (const wchar_t *name) |
Unicode version of... More... | |
DSL_API wchar_t *DSL_CC | GetUserConfigFileW (const wchar_t *name, const wchar_t *fn) |
Unicode version of... More... | |
DSL_API char *DSL_CC | GetUserDocumentsFolderA (const char *name) |
DSL_API char *DSL_CC | tcstombsA (const char *str) |
DSL_API char *DSL_CC | tcstombsW (const wchar_t *str) |
DSL_API wchar_t *DSL_CC | tcstowcsW (const wchar_t *str) |
DSL_API wchar_t *DSL_CC | tcstowcsA (const char *str) |
DSL_API char *DSL_CC | mbstotcsA (const char *str) |
DSL_API char *DSL_CC | wcstotcsA (const wchar_t *str) |
DSL_API wchar_t *DSL_CC | mbstotcsW (const char *str) |
DSL_API wchar_t *DSL_CC | wcstotcsW (const wchar_t *str) |
DSL_API size_t DSL_CC | wcscnt (const wchar_t *ptr) |
template<typename T > | |
T | scale_ranges (T value, T srcmin, T srcmax, T destmin, T destmax) |
template<typename T > | |
T | clamp (T v, T vMin, T vMax) |
DSL_API bool DSL_CC | IsValidUTF8 (const char *s) |
Checks if the string is valid UTF-8 (no invalid UTF-8 sequences, etc.) | |
DSL_API const char *DSL_CC | FirstInvalidUTF8 (const char *s) |
#define sstrcat | ( | x, | |
y | |||
) | strlcat(x,y,sizeof(x)) |
#define sstrcpy | ( | x, | |
y | |||
) | strlcpy(x,y,sizeof(x)) |
DSL_API_CLASS string DSL_CC bin2hex | ( | const uint8_t * | data, |
size_t | datalen | ||
) |
This function takes binary data and converts it to a hex string.
data | a pointer to the binary data |
datalen | the length of the binary data |
Definition at line 162 of file GenLib.cpp.
DSL_API_CLASS char* DSL_CC bin2hex | ( | const uint8_t * | data, |
size_t | datalen, | ||
char * | out, | ||
size_t | outsize | ||
) |
This function takes binary data and converts it to a hex string.
data | a pointer to the binary data |
datalen | the length of the binary data |
out | pointer to a char buffer to put the hex string in. |
outsize | The size of the buffer pointed to by out. It should have a minimum size of (datalen*2)+1 |
Definition at line 129 of file GenLib.cpp.
T clamp | ( | T | v, |
T | vMin, | ||
T | vMax | ||
) |
DSL_API int64 DSL_CC copy_file | ( | const string & | src, |
const string & | dest, | ||
bool | allow_overwrite = false |
||
) |
Copy a file from src to dest
allow_overwrite | Don't overwrite dest if it exists |
Definition at line 1050 of file GenLib.cpp.
References filesize().
DSL_API_CLASS bool DSL_CC file_get_contents | ( | const string & | fn, |
string & | data, | ||
int64 | maxSize = INT32_MAX |
||
) |
Read a file into memory
fn | The filename to read |
data | The buffer to read in to |
maxSize | The maximum size of file to read, if the file is larger than this we will return false and read nothing |
Definition at line 985 of file GenLib.cpp.
DSL_API_CLASS bool DSL_CC file_get_contents | ( | const string & | fn, |
uint8 ** | data, | ||
int64 & | fileSize, | ||
int64 | maxSize = INT32_MAX |
||
) |
free data with dsl_free()
Read a file into memory
fn | The filename to read |
data | Pointer to a pointer for a uint8 buffer we will allocate if the function returns true. Free with @dsl_free |
fileSize | Reference to an int64 to receive the size of the data read |
maxSize | The maximum size of file to read, if the file is larger than this we will return false and read nothing |
Definition at line 998 of file GenLib.cpp.
DSL_API_CLASS bool DSL_CC file_get_contents | ( | const string & | fn, |
vector< uint8 > & | data, | ||
int64 | maxSize = INT32_MAX |
||
) |
Read a file into memory
fn | The filename to read |
data | The buffer to read in to |
maxSize | The maximum size of file to read, if the file is larger than this we will return false and read nothing |
Definition at line 972 of file GenLib.cpp.
DSL_API_CLASS char* DSL_CC GetUserConfigFileA | ( | const char * | name, |
const char * | fn | ||
) |
Gets an appropriate filename to store config files/data for the current user. The directory will be created for you.
Windows: APPDATA%\name\fn
Linux: /home/username/.name/fn
Definition at line 702 of file GenLib.cpp.
References dsl_free(), dsl_mprintf(), and GetUserConfigFolderA().
DSL_API wchar_t* DSL_CC GetUserConfigFileW | ( | const wchar_t * | name, |
const wchar_t * | fn | ||
) |
Unicode version of...
Definition at line 749 of file GenLib.cpp.
References dsl_free(), dsl_wmprintf(), and GetUserConfigFolderW().
DSL_API_CLASS char* DSL_CC GetUserConfigFolderA | ( | const char * | name | ) |
Gets an appropriate directory to store config files/data for the current user. The directory will be created for you.
Windows: APPDATA%\name<br> Linux: /home/username/.name/
Definition at line 656 of file GenLib.cpp.
References sstrcpy.
Referenced by GetUserConfigFileA().
DSL_API wchar_t* DSL_CC GetUserConfigFolderW | ( | const wchar_t * | name | ) |
Unicode version of...
Definition at line 716 of file GenLib.cpp.
Referenced by GetUserConfigFileW().
DSL_API char* DSL_CC GetUserDocumentsFolderA | ( | const char * | name | ) |
Gets an appropriate directory to store user documents for the current user. The directory will be created for you.
Windows: USERPROFILE%\Documents\name
Linux: /home/username/name/
Definition at line 756 of file GenLib.cpp.
References strlcpy().
DSL_API_CLASS bool DSL_CC hex2bin | ( | const char * | instr, |
size_t | inlen, | ||
uint8 * | out, | ||
size_t | outsize | ||
) |
This function takes a hex string and converts it to binary data.
instr | a pointer to the hex-encoded data (should be a multiple of 2) |
inlen | length of string instr |
outsize | the length of the output buffer, should be (inlen/2) |
out | pointer to a buffer to put the binary data in string in. |
Definition at line 184 of file GenLib.cpp.
Referenced by hex2bin().
DSL_API_CLASS bool DSL_CC hex2bin | ( | const char * | instr, |
uint8 * | out, | ||
size_t | outsize | ||
) |
This function takes a hex string and converts it to binary data.
instr | a pointer to the hex-encoded data (should be a multiple of 2). Length is determined by doing a strlen() on the string. |
outsize | the length of the output buffer, should be (inlen/2) |
out | pointer to a buffer to put the binary data in string in. |
Definition at line 202 of file GenLib.cpp.
References hex2bin().
DSL_API_CLASS bool DSL_CC hex2bin | ( | const string | instr, |
vector< uint8_t > & | out | ||
) |
This function takes a hex string and converts it to binary data, putting it into a vector.
instr | a pointer to the hex-encoded data (should be a multiple of 2). |
Definition at line 207 of file GenLib.cpp.
References hex2bin().
T scale_ranges | ( | T | value, |
T | srcmin, | ||
T | srcmax, | ||
T | destmin, | ||
T | destmax | ||
) |
DSL_API size_t DSL_CC strlcat | ( | char * | dst, |
const char * | src, | ||
size_t | siz | ||
) |
Like strncat but always null terminates and doesn't fill the whole buffer with zeros needlessly. See https://linux.die.net/man/3/strlcpy for details
Definition at line 879 of file GenLib.cpp.
Referenced by escapeshellarg().
DSL_API size_t DSL_CC strlcpy | ( | char * | dst, |
const char * | src, | ||
size_t | siz | ||
) |
Like strncpy but always null terminates and doesn't fill the whole buffer with zeros needlessly. See https://linux.die.net/man/3/strlcpy for details
Definition at line 905 of file GenLib.cpp.
Referenced by DSL_Sockets3_Base::BindToAddr(), escapeshellarg(), GetUserDocumentsFolderA(), and Directory::Read().
DSL_API char* DSL_CC strtrim | ( | char * | buf, |
const char * | trim = "\r\n\t " , |
||
uint8 | sides = TRIM_BOTH |
||
) |
Trims unwanted characters from the beginning and/or end of a string.
trim | The characters to trim. Default: CR, LF, tabs, spaces. |
sides | The sides to trim. Default: Both |
Definition at line 294 of file GenLib.cpp.
DSL_API int DSL_CC wildcmp | ( | const char * | wild, |
const char * | string | ||
) |
Case-sensitive wildcard string comparison.
Definition at line 433 of file GenLib.cpp.
DSL_API int DSL_CC wildicmp | ( | const char * | wild, |
const char * | string | ||
) |
Case-insensitive wildcard string comparison.
Definition at line 469 of file GenLib.cpp.
DSL_API int DSL_CC wildicmp_multi | ( | const char * | wild, |
const char * | string, | ||
const char * | sep = "|" |
||
) |
Case-insensitive wildcard string comparison with multiple patterns.
sep | The characters the patterns are delimited with (ala strtok). Default: | |
Definition at line 505 of file GenLib.cpp.