|
myMPD
Internal API documentation
|
Extra functions for sds strings. More...
#include "compile_time.h"#include "src/lib/sds_extras.h"#include "dist/mongoose/mongoose.h"#include "dist/sds/sds.h"#include "dist/utf8/utf8.h"#include <ctype.h>#include <openssl/buffer.h>#include <openssl/evp.h>#include <openssl/sha.h>#include <string.h>
Macros | |
| #define | HEXTOI(x) ((x) >= '0' && (x) <= '9' ? (x) - '0' : (x) - 'W') |
Functions | |
| sds | sds_basename (sds s) |
| sds | sds_dirname (sds s) |
| sds * | sds_split_comma_trim (const char *p, int *count) |
| sds | sds_hash_md5 (const char *p) |
| sds | sds_hash_sha1 (const char *p) |
| sds | sds_hash_sha1_sds (sds s) |
| sds | sds_hash_sha256 (const char *p) |
| sds | sds_hash_sha256_sds (sds s) |
| void | sds_utf8_tolower (sds s) |
| static const char * | escape_char (char c) |
| sds | sds_catjson_plain (sds s, const char *p, size_t len) |
| sds | sds_catjson (sds s, const char *p, size_t len) |
| sds | sds_catjsonchar (sds s, const char c) |
| sds | sds_catchar (sds s, const char c) |
| bool | sds_json_unescape (const char *src, size_t slen, sds *dst) |
| static bool | is_url_safe (char c) |
| sds | sds_urlencode (sds s, const char *p, size_t len) |
| sds | sds_urldecode (sds s, const char *p, size_t len, bool is_form_url_encoded) |
| sds | sds_replacelen (sds s, const char *p, size_t len) |
| sds | sds_replace (sds s, const char *p) |
| sds | sds_catbool (sds s, bool v) |
| sds | sds_pad_int (int64_t value, sds buffer) |
| void | sds_free_void (void *p) |
Extra functions for sds strings.
| #define HEXTOI | ( | x | ) | ((x) >= '0' && (x) <= '9' ? (x) - '0' : (x) - 'W') |
Converts hex to integer
|
static |
JSON escapes special chars
| c | char to escape |
|
static |
Checks for url safe characters
| c | char to check |
| sds sds_basename | ( | sds | s | ) |
Replacement for basename function. Modifies the sds string in place.
| s | sds string to apply basename function |
| sds sds_catbool | ( | sds | s, |
| bool | v | ||
| ) |
Converts a bool value to a sds string
| s | string to append the value |
| v | bool value to convert |
| sds sds_catchar | ( | sds | s, |
| const char | c | ||
| ) |
Appends a char to sds string s, this is faster than using sdscatfmt
| s | sds string |
| c | char to append |
| sds sds_catjson | ( | sds | s, |
| const char * | p, | ||
| size_t | len | ||
| ) |
Append to the sds string "s" a quoted json escaped string After the call, the modified sds string is no longer valid and all the references must be substituted with the new pointer returned by the call.
| s | sds string |
| p | string to append json escaped |
| len | length of the string to append |
| sds sds_catjson_plain | ( | sds | s, |
| const char * | p, | ||
| size_t | len | ||
| ) |
Append to the sds string "s" a json escaped string After the call, the modified sds string is no longer valid and all the references must be substituted with the new pointer returned by the call.
| s | sds string |
| p | string to append json escaped |
| len | length of the string to append |
| sds sds_catjsonchar | ( | sds | s, |
| const char | c | ||
| ) |
Append to the sds string "s" an json escaped character After the call, the modified sds string is no longer valid and all the references must be substituted with the new pointer returned by the call.
| s | sds string |
| c | char to escape and append |
| sds sds_dirname | ( | sds | s | ) |
Replacement for dirname function. Modifies the sds string in place.
| s | sds string to apply dirname function |
| void sds_free_void | ( | void * | p | ) |
Frees an sds string pointed by void pointer
| p | Void pointer to sds string |
| sds sds_hash_md5 | ( | const char * | p | ) |
Hashes a string with md5
| p | string to hash |
| sds sds_hash_sha1 | ( | const char * | p | ) |
Hashes a string with sha1
| p | string to hash |
| sds sds_hash_sha1_sds | ( | sds | s | ) |
Hashes a sds string with sha1 inplace
| s | string to hash |
| sds sds_hash_sha256 | ( | const char * | p | ) |
Hashes a string with sha256
| p | string to hash |
| sds sds_hash_sha256_sds | ( | sds | s | ) |
Hashes a sds string with sha256 inplace
| s | string to hash |
| bool sds_json_unescape | ( | const char * | src, |
| size_t | slen, | ||
| sds * | dst | ||
| ) |
Json unescapes "src" and appends the result to the sds string "dst" "dst" must be a pointer to a allocated sds string.
| src | string to unescape |
| slen | string length to unescape |
| dst | pointer to sds string to append the unescaped string |
| sds sds_pad_int | ( | int64_t | value, |
| sds | buffer | ||
| ) |
Prints a zero padded value
| value | mpd song struct |
| buffer | already allocated sds string to append |
| sds sds_replace | ( | sds | s, |
| const char * | p | ||
| ) |
Replaces a sds string with a new value, allocates the string if it is NULL
| s | sds string to replace |
| p | replacement string |
| sds sds_replacelen | ( | sds | s, |
| const char * | p, | ||
| size_t | len | ||
| ) |
Replaces a sds string with a new value, allocates the string if it is NULL
| s | sds string to replace |
| p | replacement string |
| len | replacement string length |
| sds * sds_split_comma_trim | ( | const char * | p, |
| int * | count | ||
| ) |
Splits a comma separated string and trims whitespaces from single values
| p | string to split |
| count | pointer to int representing the count of values |
| sds sds_urldecode | ( | sds | s, |
| const char * | p, | ||
| size_t | len, | ||
| bool | is_form_url_encoded | ||
| ) |
Url decodes a string
| s | sds string to append the url decoded string |
| p | string to url decode |
| len | string length to url decode |
| is_form_url_encoded | true decodes + chars to spaces |
| sds sds_urlencode | ( | sds | s, |
| const char * | p, | ||
| size_t | len | ||
| ) |
Url encodes a string
| s | sds string to append the encoded string |
| p | string to url encode |
| len | string length to url encode |
| void sds_utf8_tolower | ( | sds | s | ) |
Makes the string lower case (utf8 aware)
| s | sds string to modify in place |