libwebsockets
Lightweight C library for HTML5 websockets
lws-purify.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

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 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)
 

Function Documentation

◆ lws_sql_purify()

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

Parameters
escapedoutput buffer
stringinput buffer ('/0' terminated)
lenoutput buffer max length

Because escaping expands the output string, it's not possible to do it in-place, ie, with escaped == string

◆ lws_sql_purify_len()

int lws_sql_purify_len ( const char *  p)

lws_sql_purify_len() - return length of purified version of input string

Parameters
stringinput buffer ('/0' terminated)

Calculates any character escaping without writing it anywhere and returns the calculated length of the purified string.

◆ lws_json_purify()

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

Parameters
escapedoutput buffer
stringinput buffer ('/0' terminated)
lenoutput buffer max length
in_usednumber of bytes of string we could escape in len

Because escaping expands the output string, it's not possible to do it in-place, ie, with escaped == string

◆ lws_json_purify_len()

LWS_VISIBLE LWS_EXTERN int lws_json_purify_len ( const char *  string)

lws_json_purify_len() - find out the escaped length of a string

Parameters
stringinput 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.

◆ lws_filename_purify_inplace()

LWS_VISIBLE LWS_EXTERN void lws_filename_purify_inplace ( char *  filename)

lws_filename_purify_inplace() - replace scary filename chars with underscore

Parameters
filenamefilename to be purified

Replace scary characters in the filename (it should not be a path) with underscore, so it's safe to use.

◆ lws_plat_write_cert()

LWS_VISIBLE LWS_EXTERN int lws_plat_write_cert ( struct lws_vhost *  vhost,
int  is_key,
int  fd,
void *  buf,
size_t  len 
)

◆ lws_plat_write_file()

LWS_VISIBLE LWS_EXTERN int lws_plat_write_file ( const char *  filename,
void *  buf,
size_t  len 
)

◆ lws_plat_read_file()

LWS_VISIBLE LWS_EXTERN int lws_plat_read_file ( const char *  filename,
void *  buf,
size_t  len 
)

◆ lws_plat_recommended_rsa_bits()

LWS_VISIBLE LWS_EXTERN int lws_plat_recommended_rsa_bits ( void  )