1 /* This program is free software; you can redistribute it and/or modify 2 * it under the terms of the GNU General Public License as published by 3 * the Free Software Foundation; version 2 of the License. For a copy, 4 * see http://www.gnu.org/licenses/gpl-2.0.html. 5 * 6 * This program is distributed in the hope that it will be useful, 7 * but WITHOUT ANY WARRANTY; without even the implied warranty of 8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 * GNU General Public License for more details. 10 */ 11 12 #ifndef _LIBSTR_H 13 #define _LIBSTR_H 14 15 #include "config.h" 16 #include <sys/types.h> 17 #include <stdbool.h> 18 #include <regex.h> 19 20 #define CHECK_USE_STRLEN -1 21 #define str_to_off str_to_int 22 23 void check_free(void *ptr); 24 void clear_free(void *ptr, int size); 25 void check_clear_free(void *ptr, int size); 26 27 int parse_yesno(char *yesno, bool *result); 28 int str_to_int(char *str); 29 int time_str_to_int(char *str); 30 bool empty_string(char *str); 31 short hex_char_to_int(char c); 32 int hex_to_int(char *str); 33 int str_count(char *str, char c); 34 char *remove_spaces(char *str); 35 char *uncomment(char *str); 36 char *strlower(char *str); 37 int split_string(const char *str, char **key, char **value, char c); 38 int split_configline(const char *str, char **key, char **value); 39 bool valid_uri(char *uri, bool allow_dot_files); 40 int url_encode(char *str, char **encoded); 41 void url_decode(char *str); 42 bool forbidden_chars_present(char *str); 43 int str_replace(char *src, char *from, char *to, char **dst); 44 bool min_strlen(char *str, int n); 45 int header_to_variable(char *header, char *variable, int size); 46 int filesize2str(char *buffer, int len, off_t fsize); 47 int add_str(char **buffer, int *size, int extra_size, int *len, char *str); 48 int strpcmp(char *str, regex_t *regexp); 49 int strcmp_rtap(const char *s1, const char *s2); 50 void md5_bin2hex(unsigned char bin[16], char hex[33]); 51 void sha256_bin2hex(unsigned char bin[32], char hex[65]); 52 bool hostname_match(char *hostname, char *pattern); 53 bool extension_from_uri(char *line, char *extension, size_t size); 54 55 #endif 56