|
ELinks 0.19.1
|
#include <ctype.h>#include <string.h>#include "osdep/ascii.h"#include "util/error.h"#include "util/lists.h"#include "util/memdebug.h"#include "util/memory.h"
Data Structures | |
| struct | string |
| struct | string_list_item |
| struct | ecmascript_string_list_item |
Macros | |
| #define | isspace elinks_isspace |
| #define | skip_space(S) |
| #define | skip_nonspace(S) |
| #define | isdigit(c) |
| #define | isquote(c) |
| #define | isasciialpha(c) |
| #define | isasciialnum(c) |
| #define | isident(c) |
| #define | isscreensafe(c) |
| Char is safe to write to the terminal screen. | |
| #define | isscreensafe_ucs(c) |
| Like isscreensafe() but takes Unicode values and so can check for C1. | |
| #define | DEBUG_STRING |
| String debugging using magic number, it may catch some errors. | |
| #define | STRING_GRANULARITY 0xFF |
| The granularity used for the struct string based utilities. | |
| #define | STRING_MAGIC 0x2E5BF271 |
| #define | check_string_magic(x) |
| #define | set_string_magic(x) |
| #define | NULL_STRING { STRING_MAGIC, {NULL}, 0 } |
| #define | INIT_STRING(s, l) |
| #define | realloc_string(str, size) |
| #define | add_bytes_to_string(string, bytes, length) |
| #define | debug_realloc_string(str, size) |
| #define | empty_string_or_(str) |
| Returns an empty C string or str if different from NULL. | |
| #define | null_or_stracpy(str) |
| Allocated copy if not NULL or returns NULL. | |
Functions | |
| void | add_to_strn (char **str, const char *src) |
| Concatenates src to str. | |
| char * | insert_in_string (char **dst, int pos, const char *seq, int seqlen) |
| Inserts seqlen chars from seq at position pos in the dst string. | |
| char * | straconcat (const char *str,...) |
| Takes a list of strings where the last parameter must be (char *) NULL and concatenates them. | |
| int | elinks_isspace (int c) |
| struct string * | add_to_string (struct string *string, const char *source) |
| struct string * | add_char_to_string (struct string *string, unsigned char character) |
| struct string * | add_string_to_string (struct string *to, const struct string *from) |
| struct string * | add_file_to_string (struct string *string, const char *filename) |
| struct string * | add_crlf_to_string (struct string *string) |
| static char * | squeezastring (struct string *string) |
| static struct string * | add_bytes_to_string__ (struct string *string, const char *bytes, int length) |
| void | free_string_list (struct string_list_item list *list) |
| struct string * | add_to_ecmascript_string_list (struct ecmascript_string_list_item list *list, const char *string, int length, int element_offset) |
| void | free_ecmascript_string_list (struct ecmascript_string_list_item list *list) |
| void | el_string_replace (struct string *res, struct string *inp, struct string *what, struct string *repl) |
Autoallocation string constructors: | |
Note that, contrary to the utilities using the string struct, these functions are NOT granular, thus you can't simply reuse strings allocated by these in add_to_string()-style functions. | |
| char * | memacpy (const char *src, int len) |
| Allocates NUL terminated string with len bytes from src. | |
| char * | stracpy (const char *src) |
| Allocated NUL terminated string with the content of src. | |
Misc. utility string functions. | |
| #define | strlcmp(a, b, c, d) |
| This routine compares string s1 of length n1 with string s2 of length n2. | |
| #define | strlcasecmp(a, b, c, d) |
| Acts identically to strlcmp(), except for being case insensitive. | |
| #define | c_strlcasecmp(a, b, c, d) |
| #define | strlcasestr(a, b, c, d) |
| int | xstrcmp (const char *s1, const char *s2) |
| Compare two strings, handling correctly s1 or s2 being NULL. | |
| char * | safe_strncpy (char *dst, const char *src, size_t len) |
| Copies at most len chars into dst. | |
| int | elinks_strlcmp (const char *s1, size_t n1, const char *s2, size_t n2) |
| int | elinks_strlcasecmp (const char *s1, size_t n1, const char *s2, size_t n2, const int locale_indep) |
| char * | elinks_strlcasestr (const char *haystack, const int haystackl, const char *needle, const int needlel) |
| int | c_strcasecmp (const char *s1, const char *s2) |
| int | c_strncasecmp (const char *s1, const char *s2, size_t n) |
| char * | c_strcasestr (const char *haystack, const char *needle) |
| #define add_bytes_to_string | ( | string, | |
| bytes, | |||
| length ) |
| #define c_strlcasecmp | ( | a, | |
| b, | |||
| c, | |||
| d ) |
| #define check_string_magic | ( | x | ) |
| #define debug_realloc_string | ( | str, | |
| size ) |
| #define DEBUG_STRING |
String debugging using magic number, it may catch some errors.
| #define empty_string_or_ | ( | str | ) |
Returns an empty C string or str if different from NULL.
| #define INIT_STRING | ( | s, | |
| l ) |
| #define isasciialnum | ( | c | ) |
| #define isasciialpha | ( | c | ) |
| #define isdigit | ( | c | ) |
| #define isident | ( | c | ) |
| #define isquote | ( | c | ) |
| #define isscreensafe | ( | c | ) |
| #define isscreensafe_ucs | ( | c | ) |
Like isscreensafe() but takes Unicode values and so can check for C1.
| #define isspace elinks_isspace |
| #define null_or_stracpy | ( | str | ) |
| #define NULL_STRING { STRING_MAGIC, {NULL}, 0 } |
| #define realloc_string | ( | str, | |
| size ) |
| #define set_string_magic | ( | x | ) |
| #define skip_nonspace | ( | S | ) |
| #define skip_space | ( | S | ) |
| #define STRING_GRANULARITY 0xFF |
The granularity used for the struct string based utilities.
| #define STRING_MAGIC 0x2E5BF271 |
| #define strlcasecmp | ( | a, | |
| b, | |||
| c, | |||
| d ) |
Acts identically to strlcmp(), except for being case insensitive.
| #define strlcasestr | ( | a, | |
| b, | |||
| c, | |||
| d ) |
| #define strlcmp | ( | a, | |
| b, | |||
| c, | |||
| d ) |
This routine compares string s1 of length n1 with string s2 of length n2.
This acts identically to strcmp() but for non-zero-terminated strings, rather than being similiar to strncmp(). That means, it fails if n1 != n2, thus you may use it for testing whether s2 matches full s1, not only its start (which can be a security hole, e.g. in the cookies domain checking).
n1 or n2 may be -1, which is same as strlen(s1 or s2) but possibly more effective (in the future ;-).
|
inlinestatic |
| struct string * add_to_ecmascript_string_list | ( | struct ecmascript_string_list_item list * | list, |
| const char * | string, | ||
| int | length, | ||
| int | element_offset ) |
| void add_to_strn | ( | char ** | str, |
| const char * | src ) |
Concatenates src to str.
If reallocation of str fails str is not touched.
| int c_strcasecmp | ( | const char * | s1, |
| const char * | s2 ) |
| char * c_strcasestr | ( | const char * | haystack, |
| const char * | needle ) |
| int c_strncasecmp | ( | const char * | s1, |
| const char * | s2, | ||
| size_t | n ) |
| void el_string_replace | ( | struct string * | res, |
| struct string * | inp, | ||
| struct string * | what, | ||
| struct string * | repl ) |
| int elinks_isspace | ( | int | c | ) |
| int elinks_strlcasecmp | ( | const char * | s1, |
| size_t | n1, | ||
| const char * | s2, | ||
| size_t | n2, | ||
| const int | locale_indep ) |
| char * elinks_strlcasestr | ( | const char * | haystack, |
| const int | haystackl, | ||
| const char * | needle, | ||
| const int | needlel ) |
| int elinks_strlcmp | ( | const char * | s1, |
| size_t | n1, | ||
| const char * | s2, | ||
| size_t | n2 ) |
| void free_ecmascript_string_list | ( | struct ecmascript_string_list_item list * | list | ) |
|
| char * insert_in_string | ( | char ** | dst, |
| int | pos, | ||
| const char * | seq, | ||
| int | seqlen ) |
Inserts seqlen chars from seq at position pos in the dst string.
If reallocation of dst fails it is not touched and NULL is returned.
| char * memacpy | ( | const char * | src, |
| int | len ) |
Allocates NUL terminated string with len bytes from src.
If src == NULL or len < 0 only one byte is allocated and set it to 0.
| char * safe_strncpy | ( | char * | dst, |
| const char * | src, | ||
| size_t | len ) |
Copies at most len chars into dst.
Ensures null termination of dst.
|
| char * straconcat | ( | const char * | str, |
| ... ) |
Takes a list of strings where the last parameter must be (char *) NULL and concatenates them.
Example:
| char * stracpy | ( | const char * | src | ) |
Allocated NUL terminated string with the content of src.
| int xstrcmp | ( | const char * | s1, |
| const char * | s2 ) |
Compare two strings, handling correctly s1 or s2 being NULL.