|
Aegis
4.25.D505
|
00001 // 00002 // aegis - project change supervisor 00003 // Copyright (C) 1991-1995, 1998, 1999, 2001-2006, 2008, 2012 Peter Miller 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation; either version 3 of the License, or (at 00008 // your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 // 00018 00019 #ifndef STR_H 00020 #define STR_H 00021 00027 #include <common/ac/stddef.h> 00028 #include <common/ac/stdarg.h> 00029 #include <common/gcc-attribute.h> 00030 00031 typedef unsigned long str_hash_ty; 00032 00051 struct string_ty 00052 { 00057 str_hash_ty str_hash; 00058 00063 string_ty *str_next; 00064 00072 long str_references; 00073 00078 size_t str_length; 00079 00085 char str_text[1]; 00086 }; 00087 00088 void str_release(void); 00089 00105 string_ty *str_from_c(const char *str); 00106 00125 string_ty *str_n_from_c(const char *str, size_t len); 00126 00141 string_ty *str_copy(string_ty *str); 00142 00157 void str_free(string_ty *str); 00158 00176 string_ty *str_catenate(string_ty *str1, string_ty *str2); 00177 00197 string_ty *str_cat_three(string_ty *str1, string_ty *str2, string_ty *str3); 00198 00215 int str_bool(string_ty *str); 00216 00234 string_ty *str_upcase(string_ty *str); 00235 00253 string_ty *str_downcase(string_ty *str); 00254 00273 string_ty *str_capitalize(string_ty *str); 00274 00285 void str_dump(void); 00286 00308 string_ty *str_field(string_ty *str, int sep, int nth); 00309 00321 void slow_to_fast(const char *const *, string_ty **, size_t); 00322 00342 string_ty *str_format(const char *fmt, ...) ATTR_PRINTF(1, 2); 00343 00365 string_ty *str_vformat(const char *fmt, va_list ap); 00366 00387 int str_equal(string_ty *str1, string_ty *str2); 00388 00399 #define str_equal(s1, s2) ((s1) == (s2)) 00400 00417 string_ty *str_quote_shell(string_ty *str); 00418 00436 string_ty *str_trim(string_ty *str); 00437 00452 string_ty *str_snip(string_ty *str); 00453 00468 int str_validate(const string_ty *str); 00469 00485 int str_leading_prefix(string_ty *haystack, string_ty *needle); 00486 00502 int str_trailing_suffix(string_ty *haystack, string_ty *needle); 00503 00512 string_ty *str_identifier(string_ty *str); 00513 00534 string_ty *str_replace(string_ty *str, string_ty *lhs, string_ty *rhs, 00535 int maximum = -1); 00536 00539 #endif // STR_H 00540 // vim: set ts=8 sw=4 et :
1.7.6.1