1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
|
/*
* strfn.h - String functions
*
* Copyright (C) 1999-2001 by Roman Khnykin <romaroma@rr.org.ua>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* Created: 22.06.1999 romaroma Initial revision.
* Changed: 05.03.2000 romaroma Documentation added.
* Changed: 30.03.2000 romaroma Changed to version 1.2.0.
* Changed: 20.06.2000 romaroma Some new functions added.
* strchrs function was removed
* Changed: 07.07.2000 romaroma Some new functions was added.
* Changed: 10.07.2000 romaroma Some new functions was added.
* Changed: 08.09.2000 romaroma Some new functions was added.
*
*/
#ifndef _STRFN_H
#define _STRFN_H
/*****************************************************************************/
/* Functions for manipulate strings */
/*****************************************************************************/
/*
* strndup - Duplicate string with maximum length specified.
*
* WARNING: This function can process memory allocation.
*
* Parameters:
* char *src - source string
* int size - new string maximum size
*
* Return value:
* char * - new string
*/
char *strndup(const char *src, int size);
/*
* strappend - Append source string to destination.
*
* WARNING: This function can process memory allocation.
*
* Parameters:
* char *dst - destination string
* char *src - source string
*
* Return value:
* char * - new destination location
*/
char *strappend(char *dst, const char *src);
/*
* strnappend - Append source string to destination with maximum length
* specified.
*
* WARNING: This function can process memory allocation.
*
* Parameters:
* char *dst - destination string
* char *src - source string
* int size - maximum append string size
*
* Return value:
* char * - new destination location
*/
char *strnappend(char *dst, const char *src, int size);
/*
* strdel - Delete part of string
*
* Parameters:
* char *src - source string
* int start - start position to delete
* int len - length to delete
*
* Return value:
* char * - new string location
*/
char *strdel(char *src, int start, int len);
/*
* strrmstr - Remove substring from string
*
* Parameters:
* char *src - source string
* char *sub - substring to remove
*
* Return value:
* char * - new string location
*/
char *strrmstr(char *src, char *sub);
/*
* strreplacechars - Replace charecters in string
*
* Parameters:
* char *src - source string
* char chr - character that will be replaced
* char nchr - new character
*
* Return value:
* char * - string location
*/
char *strreplacechars(char *src, char chr, char nchr);
/*
* strend - returns pointer to the end of string
*
* Parameters:
* char *src - source string
*
* Return value:
* char * - pointer to the end of source string
*/
char *strend(const char* src);
/*
* strcasestr - search substring in string, ignore case
*
* Parameters:
* char *haystack - source string
* char *needle - substring
*
* Return value:
* char * - pointer to the found substring or zero if not found
*/
char *strcasestr(const char *haystack, const char *needle);
/*
* loadFromFile - load text from file to string
*
* WARNING: This function can process memory allocation.
*
* Parameters:
* char *fname - file name
*
* Return value:
* char * - text location
*/
char *loadFromFile(const char *fname);
/*
* strtriml - Trim left.
* This function don't change source string.
*
* Parameters:
* char *st - string
*
* Return value:
* char * - new string location
*/
char *strtriml(char *st);
/*
* strtrimr - Trim right.
*
* WARNING: This function can change source string.
*
* Parameters:
* char *st - string
*
* Return value:
* char * - new string location
*/
char *strtrimr(char *st);
/*
* strtrimr - Trim left and right.
*
* WARNING: This function can change source string.
*
* Parameters:
* char *st - string
*
* Return value:
* char * - new string location
*/
char *strtrim(char *st);
/*
* itoa - Convert integer to string.
*
* Parameters:
* int i - integer to convert
*
* Return value:
* char * - string location
*/
char *itoa(int i);
/*
* isdecnum - Check for string contains decimal number.
*
* Parameters:
* char *str - string to check
*
* Return value:
* int - non zero value if string contains decimal number
*/
int strisdecnumber(const char *str);
/*
* ishexnum - Check for string contains hexadecimal number.
*
* Parameters:
* char *str - string to check
*
* Return value:
* int - non zero value if string contains hexadecimal number
*/
int strishexnumber(const char *str);
/*
* strsepword - Separate first word and return pointer to second word in string
*
* Parameters:
* char *str - string to separate
*
* Return value:
* char * - pointer to second word in string
*/
char *strsepword(char *str);
/*****************************************************************************/
/* MIME/HTML string conversion function */
/*****************************************************************************/
/*
* get_real_text - MIME decode source string.
* get_mime_text - MIME encode source string.
* get_js_text - Decode source string for JavaScript use.
* get_nobr_text - Change all spaces in source string to "&nobr;" string.
* get_noquot_text - Change all "\"" and "'" in source string to spaces
* get_nohtml_text - Change all special html characters to its html alternatives.
* Skip all '\n' and '\r' characters.
* get_nohtml_br_text - Same to get_nohtml, but don't removed '\n' characters
* get_html_text - Same to get_nohtml, but don't replaced '\'' char and replaced
* '\n' char to "<br>"
*
* WARNING: This functions can process memory allocation.
*
* Parameters:
* char *src - string to convert
*
* Return value:
* char * - converted string location
*/
char *get_real_text(const char *src);
char *get_mime_text(const char *src);
char *get_js_text(const char *src);
char *get_nobr_text(const char *src);
char *get_noquot_text(const char *src);
char *get_nohtml_text(const char *src);
char *get_nohtml_br_text(const char *src);
char *get_html_text(const char *src);
#endif
|