00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef STR_H
00021 #define STR_H
00022
00028 #include <common/ac/stddef.h>
00029 #include <common/ac/stdarg.h>
00030 #include <common/main.h>
00031
00032 typedef unsigned long str_hash_ty;
00033
00052 struct string_ty
00053 {
00058 str_hash_ty str_hash;
00059
00064 string_ty *str_next;
00065
00073 long str_references;
00074
00079 size_t str_length;
00080
00086 char str_text[1];
00087 };
00088
00089 void str_release(void);
00090
00106 string_ty *str_from_c(const char *str);
00107
00126 string_ty *str_n_from_c(const char *str, size_t len);
00127
00142 string_ty *str_copy(string_ty *str);
00143
00158 void str_free(string_ty *str);
00159
00177 string_ty *str_catenate(string_ty *str1, string_ty *str2);
00178
00198 string_ty *str_cat_three(string_ty *str1, string_ty *str2, string_ty *str3);
00199
00216 int str_bool(string_ty *str);
00217
00235 string_ty *str_upcase(string_ty *str);
00236
00254 string_ty *str_downcase(string_ty *str);
00255
00274 string_ty *str_capitalize(string_ty *str);
00275
00286 void str_dump(void);
00287
00309 string_ty *str_field(string_ty *str, int sep, int nth);
00310
00322 void slow_to_fast(const char *const *, string_ty **, size_t);
00323
00343 string_ty *str_format(const char *fmt, ...) ATTR_PRINTF(1, 2);
00344
00366 string_ty *str_vformat(const char *fmt, va_list ap);
00367
00388 int str_equal(string_ty *str1, string_ty *str2);
00389
00400 #define str_equal(s1, s2) ((s1) == (s2))
00401
00418 string_ty *str_quote_shell(string_ty *str);
00419
00437 string_ty *str_trim(string_ty *str);
00438
00453 string_ty *str_snip(string_ty *str);
00454
00469 int str_validate(const string_ty *str);
00470
00486 int str_leading_prefix(string_ty *haystack, string_ty *needle);
00487
00503 int str_trailing_suffix(string_ty *haystack, string_ty *needle);
00504
00513 string_ty *str_identifier(string_ty *str);
00514
00535 string_ty *str_replace(string_ty *str, string_ty *lhs, string_ty *rhs,
00536 int maximum = -1);
00537
00540 #endif // STR_H