|
gmerlin
|
String utilities. More...
Functions | |
| char * | bg_strdup (char *old_string, const char *new_string) |
| Duplicate a string. | |
| char * | bg_strndup (char *old_string, const char *new_start, const char *new_end) |
| Duplicate a string from a part of a source string. | |
| char * | bg_strcat (char *old_string, const char *tail) |
| Concatenate two strings. | |
| char * | bg_strncat (char *old_string, const char *start, const char *end) |
| Append a part of a string to another string. | |
| char * | bg_toupper (const char *str) |
| Convert an UTF-8 string to uppercase. | |
| int | bg_string_is_url (const char *str) |
| Check if a string looks like an URL. | |
| int | bg_url_split (const char *url, char **protocol, char **user, char **password, char **hostname, int *port, char **path) |
| Split an URL into their parts. | |
| void | bg_get_filename_hash (const char *gml, char ret[33]) |
| Get MD5 hash of a filename. | |
| char * | bg_sprintf (const char *format,...) __attribute__((format(printf |
| Print into a string. | |
| char char ** | bg_strbreak (const char *str, char delim) |
| Break a string into substrings. | |
| void | bg_strbreak_free (char **retval) |
| Free a substrings array. | |
| char * | bg_scramble_string (const char *str) |
| Scramble a string. | |
| char * | bg_descramble_string (const char *str) |
| Descramble a string. | |
| char * | bg_string_to_uri (const char *pos1, int len) |
| Convert a binary string (in system charset) to an URI. | |
| char * | bg_uri_to_string (const char *pos1, int len) |
| Convert an URI to a a binary string (in system charset) | |
| char ** | bg_urilist_decode (const char *str, int len) |
| Decode an URI list. | |
| void | bg_urilist_free (char **uri_list) |
| Free an URI list. | |
| char * | bg_system_to_utf8 (const char *str, int len) |
| Convert a string from the system character set to UTF-8. | |
| char * | bg_utf8_to_system (const char *str, int len) |
| Convert a string from UTF-8 to the system character set. | |
| const char * | bg_get_language_name (const char *iso) |
| Get a language name. | |
| int | bg_string_match (const char *str, const char *key_list) |
| Check if a string occurs in a space-separated list of strings. | |
String utilities.
| char* bg_strdup | ( | char * | old_string, |
| const char * | new_string | ||
| ) |
Duplicate a string.
| old_string | (will eventually be freed) |
| new_string | New string |
Both old_string and new_string can be NULL. If new string is the empty string (""), if will be treated like NULL.
| char* bg_strndup | ( | char * | old_string, |
| const char * | new_start, | ||
| const char * | new_end | ||
| ) |
Duplicate a string from a part of a source string.
| old_string | (will eventually be freed) |
| new_start | Start of the new string |
| new_end | Points to the first character after the end of the new string |
Any combination of old_string, new_start and new_end can be NULL. If new_start is the empty string (""), if will be treated like NULL. If new_end is NULL, it will be obtained with strlen().
| char* bg_strcat | ( | char * | old_string, |
| const char * | tail | ||
| ) |
Concatenate two strings.
| old_string | Old string (will be freed) |
| tail | Will be appended to old_string |
| char* bg_strncat | ( | char * | old_string, |
| const char * | start, | ||
| const char * | end | ||
| ) |
Append a part of a string to another string.
| old_string | Old string (will be freed) |
| start | Start of the string to be appended |
| end | Points to the first character after the end of the string to be appended |
| char* bg_toupper | ( | const char * | str | ) |
Convert an UTF-8 string to uppercase.
| str | String |
| int bg_string_is_url | ( | const char * | str | ) |
Check if a string looks like an URL.
| str | A string |
This checks mostly for the occurrence of "://" at a location, where it makes sense.
| int bg_url_split | ( | const char * | url, |
| char ** | protocol, | ||
| char ** | user, | ||
| char ** | password, | ||
| char ** | hostname, | ||
| int * | port, | ||
| char ** | path | ||
| ) |
Split an URL into their parts.
| url | An URL |
| protocol | Protocol (returned) |
| user | Username (returned) |
| password | Password (returned) |
| hostname | Hostname (returned) |
| port | Port (returned) |
| path | Path (returned) |
This parses an url in the form <protocol>://<user@password><host><:port><path>. All arguments for returning the path can be NULL. port will be set to -1 if if doesn't occur in the URL. All strings must be freed when non-NULL after the call.
| void bg_get_filename_hash | ( | const char * | gml, |
| char | ret[33] | ||
| ) |
Get MD5 hash of a filename.
| gml | Returns the MD5 sum |
This creates an MD5 hash of a gml. For regular files this is compatible with the thumbnailing specification
| char* bg_sprintf | ( | const char * | format, |
| ... | |||
| ) |
Print into a string.
| format | printf like format |
All other arguments must match the format like in printf. This function allocates the returned string, thus it must be freed by the caller.
| char char** bg_strbreak | ( | const char * | str, |
| char | delim | ||
| ) |
Break a string into substrings.
| str | String |
| delim | Delimiter for the substrings |
Free the result with bg_strbreak_free.
| void bg_strbreak_free | ( | char ** | retval | ) |
Free a substrings array.
| retval | Array |
Use this for substring arrays returned by bg_strbreak.
| char* bg_scramble_string | ( | const char * | str | ) |
Scramble a string.
| str | String to be scrambled |
Note: Don't even think about using this for security sensitive stuff. It's for saving passwords in files, which should be readable by the the owner only.
| char* bg_descramble_string | ( | const char * | str | ) |
Descramble a string.
| str | String to be descrambled |
Note: Don't even think about using this for security sensitive stuff. It's for saving passwords in files, which should be readable by the the owner only.
| char* bg_string_to_uri | ( | const char * | pos1, |
| int | len | ||
| ) |
Convert a binary string (in system charset) to an URI.
| pos1 | The string |
| len | or -1 |
This e.g. replaces " " by "%20".
| char* bg_uri_to_string | ( | const char * | pos1, |
| int | len | ||
| ) |
Convert an URI to a a binary string (in system charset)
| pos1 | The string |
| len | or -1 |
This e.g. replaces "%20" by " ".
| char** bg_urilist_decode | ( | const char * | str, |
| int | len | ||
| ) |
Decode an URI list.
| str | String |
| len | Length of the string or -1 |
This one decodes a string of MIME type text/urilist into a gmerlin usable array of location strings. The returned array is NULL terminated, it must be freed by the caller with bg_urilist_free.
| void bg_urilist_free | ( | char ** | uri_list | ) |
Free an URI list.
| uri_list | Decoded URI list returned by bg_uri_to_string |
| char* bg_system_to_utf8 | ( | const char * | str, |
| int | len | ||
| ) |
Convert a string from the system character set to UTF-8.
| str | String |
| len | Length or -1 |
The "system charset" is obtained with nl_langinfo().
| char* bg_utf8_to_system | ( | const char * | str, |
| int | len | ||
| ) |
Convert a string from UTF-8 to the system character set.
| str | String |
| len | Length or -1 |
The "system charset" is obtained with nl_langinfo().
| const char* bg_get_language_name | ( | const char * | iso | ) |
Get a language name.
| iso | An iso-639 3 character code |
| int bg_string_match | ( | const char * | str, |
| const char * | key_list | ||
| ) |
Check if a string occurs in a space-separated list of strings.
| str | String |
| key_list | Space separated list of keys |
1.7.5.1