1 /* strfncs.h header for strfncs.c */
2 
3 /*
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; either version 2 of the License, or
7    (at your option) any later version.
8 
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13 
14    You should have received a copy of the GNU General Public License
15    along with this program; if not, write to the Free Software
16    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17 
18   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
19 
20 /* this is from readline/chardefs.h. */
21 #ifndef whitespace
22 #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
23 #endif
24 
25 /* this is different from whitespace in readline/chardefs.h */
26 #define full_whitespace(c) (((c) == ' ') || ((c) == '\t') || ((c) == '\n') || ((c) == '\r'))
27 
28 /* this defines a log print facility. This prevents that a costly function
29    call to log_print() is made just to find out that the log level does
30    not call for any actions. Don't use this macro in another expression,
31    just put "LOG_PRINT(level, your_string)" on its own line.
32    Arguments: char* s  string to print
33               int   l  minimum log level to get the string printed*/
34 #define LOG_PRINT(l,s) if (n_log_level >= l) {log_print(l,s);}
35 
36 /* the mstr* functions use this value to reallocate memory for an autogrowing string. They will simply reallocate the existing size plus realloc_chunk if the requested size is not larger than that. This prevents that during string assembly where lots of small bits and pieces like commas, quotation marks, and brackets are appended, each one or two-byte increase in size needs an expensive call to realloc(). The higher the value for realloc_chunk, the less realloc() calls are necessary, but we may waste memory */
37 #define realloc_chunk 512
38 
39 /* structure used in letter->entity replacements */
40 struct charent {
41   char letter[5];  /* a string containing the (possibly multibyte) */
42                    /* letter */
43   size_t len;      /* length in bytes of letter */
44   char entity[16]; /* null-terminated string containing the replacement */
45                    /* entity string */
46 };
47 
48 struct VERSIONINFO {
49   int major;
50   int minor;
51   int minuscule;
52 };
53 
54 int check_ip (char* server_ip);
55 int is_port(char *port);
56 int is_number(char *string);
57 int is_real_number(const char *string);
58 char *stripwhite(char *string, int mode, int type);
59 char* strup(char* string);
60 char* strdn(char* string);
61 char* stricap(char* string);
62 int compare_ptr(const void* ptr_one, const void* ptr_two);
63 char* mstrcat(char* destination, char* source, size_t* ptr_dest_len, size_t offset);
64 char* mstrcpy(char* destination, char* source, size_t* ptr_dest_len);
65 char* mstrncpy(char* destination, char* source, size_t n, size_t* ptr_dest_len);
66 char* mstrdup(char *buffer);
67 void free_all(void*** ptr_mem);
68 void insert_string(char *buffer, char *insert);
69 void remove_substring(char *buffer, size_t sublen);
70 char* sgml_entitize(char** buffer, struct charent* ptr_myents);
71 char *canonicalize_path(char *the_path);
72 char *strip_quote(char *the_string);
73 char *truncate_quoted_string(char *the_string, size_t len);
74 size_t escape_chars(char *dest, const char *orig, size_t orig_size, const char *toescape);
75 size_t unescape_chars(char *dest, const char *orig, size_t orig_size);
76 size_t escape_latex_chars(char *dest, const char *orig, size_t orig_size);
77 char* escape_latex_chars_copy(const char *orig, size_t orig_size);
78 int increment_suffix(char* suffix, int max_depth, int upper);
79 int parse_versioninfo(const char* version, struct VERSIONINFO* ver);
80 size_t count_the_flowers(const char *buffer, const char *letter, size_t len);
81 void replace_char_string(char *buffer, char *insert, size_t len);
82 size_t min_token_length(const char* string, const char* sep);
83 int replace_regexp_chars(char* string, char* regexp_chars, char replacement);
84