Mstdlib-1.24.0
|
Enumerations | |
enum | M_str_justify_type_t { M_STR_JUSTIFY_RIGHT = 0 , M_STR_JUSTIFY_LEFT = 1 , M_STR_JUSTIFY_RIGHT_TRUNC_RIGHT = 2 , M_STR_JUSTIFY_LEFT_TRUNC_RIGHT = 3 , M_STR_JUSTIFY_RIGHT_NOTRUNC = 4 , M_STR_JUSTIFY_LEFT_NOTRUNC = 5 , M_STR_JUSTIFY_TRUNC_RIGHT = 6 , M_STR_JUSTIFY_TRUNC_LEFT = 7 , M_STR_JUSTIFY_CENTER = 8 , M_STR_JUSTIFY_CENTER_TRUNC_RIGHT = 9 , M_STR_JUSTIFY_CENTER_NO_TRUNC = 10 , M_STR_JUSTIFY_END = 11 } |
Functions | |
char * | M_strdup (const char *s) M_WARN_UNUSED_RESULT M_MALLOC |
char * | M_strdup_upper (const char *s) M_WARN_UNUSED_RESULT M_MALLOC |
char * | M_strdup_lower (const char *s) M_WARN_UNUSED_RESULT M_MALLOC |
char * | M_strdup_title (const char *s) M_WARN_UNUSED_RESULT M_MALLOC |
char * | M_strdup_trim (const char *s) M_WARN_UNUSED_RESULT M_MALLOC |
char * | M_strdup_unquote (const char *s, unsigned char quote, unsigned char escape) M_WARN_UNUSED_RESULT M_MALLOC |
char * | M_strdup_max (const char *s, size_t max) M_ALLOC_SIZE(2) M_WARN_UNUSED_RESULT M_MALLOC |
char * | M_strdup_upper_max (const char *s, size_t max) M_ALLOC_SIZE(2) M_WARN_UNUSED_RESULT M_MALLOC |
char * | M_strdup_lower_max (const char *s, size_t max) M_ALLOC_SIZE(2) M_WARN_UNUSED_RESULT M_MALLOC |
char * | M_strdup_title_max (const char *s, size_t max) M_ALLOC_SIZE(2) M_WARN_UNUSED_RESULT M_MALLOC |
char * | M_strdup_trim_max (const char *s, size_t max) M_ALLOC_SIZE(2) M_WARN_UNUSED_RESULT M_MALLOC |
char * | M_strdup_unquote_max (const char *s, unsigned char quote, unsigned char escape, size_t max) M_ALLOC_SIZE(2) M_WARN_UNUSED_RESULT M_MALLOC |
char * | M_strdup_justify (const char *src, M_str_justify_type_t justtype, unsigned char justchar, size_t justlen) M_WARN_UNUSED_RESULT M_MALLOC |
char * | M_strdup_replace_charset (const char *s, const unsigned char *bcs, size_t bcs_len, const char *a) |
char * | M_strdup_replace_str (const char *s, const char *b, const char *a) |
String Manipulation (and Duplication) Functions
enum M_str_justify_type_t |
Justify Flags
char * M_strdup | ( | const char * | s | ) |
Create a duplicate of the NULL-terminated string s.
s must be passed to M_free to release the memory space associated with it.
[in] | s | NULL-terminated string. |
char * M_strdup_upper | ( | const char * | s | ) |
Create a duplicate of the NULL-terminated string s and additionally applies M_str_upper to the new string.
Later s can be passed to M_free to release the memory space associated with it.
[in] | s | NULL-terminated string. |
char * M_strdup_lower | ( | const char * | s | ) |
Create a duplicate of the NULL-terminated string s and additionally applies M_str_lower to the new string.
s must be passed to M_free to release the memory space associated with it.
[in] | s | NULL-terminated string. |
char * M_strdup_title | ( | const char * | s | ) |
Create new string with all characters converted to title case.
Title case is where the first letter of each word is converted to uppercase, and all other letters are converted to lowercase.
Ex: "This Sentence Is In Title Case"
[in] | s | null-terminated string to duplicate and convert. |
NULL
on failure. char * M_strdup_trim | ( | const char * | s | ) |
Create a duplicate of the NULL-terminated string s and additionally applies M_str_trim to the new string.
s must be passed to M_free to release the memory space associated with it.
[in] | s | NULL-terminated string. |
char * M_strdup_unquote | ( | const char * | s, |
unsigned char | quote, | ||
unsigned char | escape | ||
) |
Create a duplicate of the NULL-terminated string s and additionally applies M_str_unquote to the new string.
s must be passed to M_free to release the memory space associated with it.
[in] | s | NULL-terminated string. |
[in] | quote | Quote character that should be removed. |
[in] | escape | Character that escapes a quote that is within the quoted string. |
char * M_strdup_max | ( | const char * | s, |
size_t | max | ||
) |
Create a duplicate of the NULL-terminated string s, but copy at most max bytes.
If s is longer than max, only max bytes are copied. The returned string will always be NULL-terminated.
s must be passed to M_free to release the memory space associated with it.
[in] | s | NULL-terminated string (or up to max bytes of s). |
[in] | max | Maximum number of bytes to copy from s. |
char * M_strdup_upper_max | ( | const char * | s, |
size_t | max | ||
) |
Create a duplicate of the NULL-terminated string s, but copy at most max bytes and additionally applies M_str_lower_max to the new string.
If s is longer than max, only max bytes are copied. The returned string will always be NULL-terminated.
s must be passed to M_free to release the memory space associated with it.
[in] | s | NULL-terminated string (or up to max bytes of s). |
[in] | max | Maximum number of bytes to copy from s. |
char * M_strdup_lower_max | ( | const char * | s, |
size_t | max | ||
) |
Create a duplicate of the NULL-terminated string s, but copy at most max bytes and additionally applies M_str_lower_max to the new string.
If s is longer than max, only max bytes are copied. The returned string will always be NULL-terminated.
s must be passed to M_free to release the memory space associated with it.
[in] | s | NULL-terminated string (or up to max bytes of s). |
[in] | max | Maximum number of bytes to copy from s. |
char * M_strdup_title_max | ( | const char * | s, |
size_t | max | ||
) |
Create new string with a given number of characters converted to title case.
Only copies up to max characters from the source string.
Title case is where the first letter of each word is converted to uppercase, and all other letters are converted to lowercase.
Ex: "This Sentence Is In Title Case"
[in] | s | null-terminated string to duplicate and convert. |
[in] | max | max number of characters to copy from s, may be less if s contains a null character |
NULL
on failure. char * M_strdup_trim_max | ( | const char * | s, |
size_t | max | ||
) |
Create a duplicate of the NULL-terminated string s, but copy at most max bytes and additionally applies M_str_trim_max to the new string.
If s is longer than max, only max bytes are copied. The returned string will always be NULL-terminated.
s must be passed to M_free to release the memory space associated with it.
[in] | s | NULL-terminated string (or up to max bytes of s). |
[in] | max | Maximum number of bytes to copy from s. |
char * M_strdup_unquote_max | ( | const char * | s, |
unsigned char | quote, | ||
unsigned char | escape, | ||
size_t | max | ||
) |
Create a duplicate of the NULL-terminated string s, but copy at most max bytes and additionally applies M_str_unquote_max to the new string.
If s is longer than max, only max bytes are copied. The returned string will always be NULL-terminated.
s must be passed to M_free to release the memory space associated with it.
[in] | s | NULL-terminated string (or up to max bytes of s). |
[in] | quote | Quote character that should be removed. |
[in] | escape | Character that escapes a quote that is within the quoted string. |
[in] | max | Maximum number of bytes to copy from s. |
char * M_strdup_justify | ( | const char * | src, |
M_str_justify_type_t | justtype, | ||
unsigned char | justchar, | ||
size_t | justlen | ||
) |
Justifies the input source as specified by the parameters and writes it to a new duplicate string.
[in] | src | Null-terminated input string to be justified. |
[in] | justtype | Type of justification to be performed. |
[in] | justchar | Character to use as padding/filler for justification. (ignored if M_JUSTIFY_TRUNC_RIGHT or M_JUSTIFY_TRUNC_LEFT) |
[in] | justlen | Length requested for justification (or truncation). |
char * M_strdup_replace_charset | ( | const char * | s, |
const unsigned char * | bcs, | ||
size_t | bcs_len, | ||
const char * | a | ||
) |
Replace all characters matching a given character set with a string.
[in] | s | NULL-terminated string. |
[in] | bcs | Character set. |
[in] | bcs_len | Number of characters in the given set. |
[in] | a | Replacement string for every character in the character set. |
char * M_strdup_replace_str | ( | const char * | s, |
const char * | b, | ||
const char * | a | ||
) |
Replace a string with another string.
[in] | s | NULL-terminated string. |
[in] | b | NULL-terminated string to replace. |
[in] | a | NULL-terminated string o replace with. b is replaced with a. |