|
libwebsockets
Lightweight C library for HTML5 websockets
|
Go to the source code of this file.
Macros | |
| #define | LWS_JSON_PURIFY_FLAG_HTML_SAFE 1 |
Functions | |
| LWS_VISIBLE LWS_EXTERN const char * | lws_sql_purify (char *escaped, const char *string, size_t len) |
| int | lws_sql_purify_len (const char *p) |
| LWS_VISIBLE LWS_EXTERN const char * | lws_json_purify (char *escaped, const char *string, int len, int *in_used) |
| LWS_VISIBLE LWS_EXTERN const char * | lws_json_purify_flags (char *escaped, const char *string, int len, int *in_used, int flags) |
| LWS_VISIBLE LWS_EXTERN int | lws_json_purify_len (const char *string) |
| LWS_VISIBLE LWS_EXTERN void | lws_filename_purify_inplace (char *filename) |
| LWS_VISIBLE LWS_EXTERN int | lws_plat_write_cert (struct lws_vhost *vhost, int is_key, int fd, void *buf, size_t len) |
| LWS_VISIBLE LWS_EXTERN int | lws_plat_write_file (const char *filename, void *buf, size_t len) |
| LWS_VISIBLE LWS_EXTERN int | lws_plat_read_file (const char *filename, void *buf, size_t len) |
| LWS_VISIBLE LWS_EXTERN int | lws_plat_recommended_rsa_bits (void) |
| #define LWS_JSON_PURIFY_FLAG_HTML_SAFE 1 |
Definition at line 104 of file lws-purify.h.
| LWS_VISIBLE LWS_EXTERN const char * lws_sql_purify | ( | char * | escaped, |
| const char * | string, | ||
| size_t | len ) |
lws_sql_purify() - like strncpy but with escaping for sql quotes
| escaped | output buffer |
| string | input buffer ('/0' terminated) |
| len | output buffer max length |
Because escaping expands the output string, it's not possible to do it in-place, ie, with escaped == string
| int lws_sql_purify_len | ( | const char * | p | ) |
lws_sql_purify_len() - return length of purified version of input string
| p | input buffer ('/0' terminated) |
Calculates any character escaping without writing it anywhere and returns the calculated length of the purified string.
References LWS_EXTERN, and LWS_VISIBLE.
| LWS_VISIBLE LWS_EXTERN const char * lws_json_purify | ( | char * | escaped, |
| const char * | string, | ||
| int | len, | ||
| int * | in_used ) |
lws_json_purify() - like strncpy but with escaping for json chars
| escaped | output buffer |
| string | input buffer ('/0' terminated) |
| len | output buffer max length |
| in_used | NULL, or pointer to input cap on entry and the number of bytes of string we could escape in len on output |
Because escaping expands the output string, it's not possible to do it in-place, ie, with escaped == string
If in_used is non-NULL, then on entry a positive value is taken as a cap on the number of bytes of string that may be processed; this allows processing non-NUL-terminated data like blobs in bounded chunks. A zero or negative value on entry means no cap. On return, it's set to the number of input bytes that were actually processed.
Escaped output is always truncated on an escape boundary, so the output is always syntactically valid however small len is.
References LWS_EXTERN, and LWS_VISIBLE.
| LWS_VISIBLE LWS_EXTERN const char * lws_json_purify_flags | ( | char * | escaped, |
| const char * | string, | ||
| int | len, | ||
| int * | in_used, | ||
| int | flags ) |
lws_json_purify_flags() - lws_json_purify() with additional options
| escaped | output buffer |
| string | input buffer ('/0' terminated) |
| len | output buffer max length |
| in_used | NULL, or pointer to input cap on entry and the number of bytes of string we could escape in len on output |
| flags | OR of LWS_JSON_PURIFY_FLAG_* |
Performs the same job as lws_json_purify() with extra behaviours selected using flags.
| LWS_VISIBLE LWS_EXTERN int lws_json_purify_len | ( | const char * | string | ) |
lws_json_purify_len() - find out the escaped length of a string
| string | input buffer ('/0' terminated) |
JSON may have to expand escapes by up to 6x the original depending on what it is. This doesn't actually do the escaping but goes through the motions and computes the length of the escaped string.
References LWS_EXTERN, and LWS_VISIBLE.
| LWS_VISIBLE LWS_EXTERN void lws_filename_purify_inplace | ( | char * | filename | ) |
lws_filename_purify_inplace() - replace scary filename chars with underscore
| filename | filename to be purified |
Replace scary characters in the filename (it should not be a path) with underscore, so it's safe to use.
References LWS_EXTERN, and LWS_VISIBLE.
| LWS_VISIBLE LWS_EXTERN int lws_plat_write_cert | ( | struct lws_vhost * | vhost, |
| int | is_key, | ||
| int | fd, | ||
| void * | buf, | ||
| size_t | len ) |
References LWS_EXTERN, and LWS_VISIBLE.
| LWS_VISIBLE LWS_EXTERN int lws_plat_write_file | ( | const char * | filename, |
| void * | buf, | ||
| size_t | len ) |
References LWS_EXTERN, and LWS_VISIBLE.
| LWS_VISIBLE LWS_EXTERN int lws_plat_read_file | ( | const char * | filename, |
| void * | buf, | ||
| size_t | len ) |
References LWS_EXTERN, and LWS_VISIBLE.
| LWS_VISIBLE LWS_EXTERN int lws_plat_recommended_rsa_bits | ( | void | ) |