summaryrefslogtreecommitdiff
path: root/xs.h
diff options
context:
space:
mode:
Diffstat (limited to 'xs.h')
-rw-r--r--xs.h26
1 files changed, 13 insertions, 13 deletions
diff --git a/xs.h b/xs.h
index 89f2ca9..45abfae 100644
--- a/xs.h
+++ b/xs.h
@@ -41,7 +41,7 @@ void _xs_destroy(char **var);
41#define xs_debug() raise(SIGTRAP) 41#define xs_debug() raise(SIGTRAP)
42xstype xs_type(const char *data); 42xstype xs_type(const char *data);
43int xs_size(const char *data); 43int xs_size(const char *data);
44int xs_is_null(char *data); 44int xs_is_null(const char *data);
45d_char *xs_dup(const char *data); 45d_char *xs_dup(const char *data);
46void *xs_realloc(void *ptr, size_t size); 46void *xs_realloc(void *ptr, size_t size);
47d_char *xs_expand(d_char *data, int offset, int size); 47d_char *xs_expand(d_char *data, int offset, int size);
@@ -54,9 +54,9 @@ d_char *xs_str_new(const char *str);
54d_char *xs_replace_i(d_char *str, const char *sfrom, const char *sto); 54d_char *xs_replace_i(d_char *str, const char *sfrom, const char *sto);
55#define xs_replace(str, sfrom, sto) xs_replace_i(xs_dup(str), sfrom, sto) 55#define xs_replace(str, sfrom, sto) xs_replace_i(xs_dup(str), sfrom, sto)
56d_char *xs_fmt(const char *fmt, ...); 56d_char *xs_fmt(const char *fmt, ...);
57int xs_str_in(char *haystack, char *needle); 57int xs_str_in(const char *haystack, const char *needle);
58int xs_startswith(char *str, char *prefix); 58int xs_startswith(const char *str, const char *prefix);
59int xs_endswith(char *str, char *postfix); 59int xs_endswith(const char *str, const char *postfix);
60d_char *xs_crop(d_char *str, int start, int end); 60d_char *xs_crop(d_char *str, int start, int end);
61d_char *xs_strip(d_char *str); 61d_char *xs_strip(d_char *str);
62d_char *xs_tolower(d_char *str); 62d_char *xs_tolower(d_char *str);
@@ -79,8 +79,8 @@ d_char *xs_dict_del(d_char *dict, const char *key);
79d_char *xs_dict_set(d_char *dict, const char *key, const char *data); 79d_char *xs_dict_set(d_char *dict, const char *key, const char *data);
80d_char *xs_val_new(xstype t); 80d_char *xs_val_new(xstype t);
81d_char *xs_number_new(double f); 81d_char *xs_number_new(double f);
82double xs_number_get(char *v); 82double xs_number_get(const char *v);
83char *xs_number_str(char *v); 83const char *xs_number_str(const char *v);
84 84
85extern int _xs_debug; 85extern int _xs_debug;
86 86
@@ -189,7 +189,7 @@ int xs_size(const char *data)
189} 189}
190 190
191 191
192int xs_is_null(char *data) 192int xs_is_null(const char *data)
193/* checks for null */ 193/* checks for null */
194{ 194{
195 return !!(data == NULL || xs_type(data) == XSTYPE_NULL); 195 return !!(data == NULL || xs_type(data) == XSTYPE_NULL);
@@ -323,7 +323,7 @@ d_char *xs_fmt(const char *fmt, ...)
323} 323}
324 324
325 325
326int xs_str_in(char *haystack, char *needle) 326int xs_str_in(const char *haystack, const char *needle)
327/* finds needle in haystack and returns the offset or -1 */ 327/* finds needle in haystack and returns the offset or -1 */
328{ 328{
329 char *s; 329 char *s;
@@ -336,14 +336,14 @@ int xs_str_in(char *haystack, char *needle)
336} 336}
337 337
338 338
339int xs_startswith(char *str, char *prefix) 339int xs_startswith(const char *str, const char *prefix)
340/* returns true if str starts with prefix */ 340/* returns true if str starts with prefix */
341{ 341{
342 return !!(xs_str_in(str, prefix) == 0); 342 return !!(xs_str_in(str, prefix) == 0);
343} 343}
344 344
345 345
346int xs_endswith(char *str, char *postfix) 346int xs_endswith(const char *str, const char *postfix)
347/* returns true if str ends with postfix */ 347/* returns true if str ends with postfix */
348{ 348{
349 int ssz = strlen(str); 349 int ssz = strlen(str);
@@ -732,7 +732,7 @@ d_char *xs_number_new(double f)
732} 732}
733 733
734 734
735double xs_number_get(char *v) 735double xs_number_get(const char *v)
736/* gets the number as a double */ 736/* gets the number as a double */
737{ 737{
738 double f = 0.0; 738 double f = 0.0;
@@ -744,10 +744,10 @@ double xs_number_get(char *v)
744} 744}
745 745
746 746
747char *xs_number_str(char *v) 747const char *xs_number_str(const char *v)
748/* gets the number as a string */ 748/* gets the number as a string */
749{ 749{
750 char *p = NULL; 750 const char *p = NULL;
751 751
752 if (v[0] == XSTYPE_NUMBER) 752 if (v[0] == XSTYPE_NUMBER)
753 p = &v[1]; 753 p = &v[1];