Drizzled Public API Documentation

CSStrUtil.h

00001 /* Copyright (C) 2008 PrimeBase Technologies GmbH, Germany
00002  *
00003  * PrimeBase Media Stream for MySQL
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 2 of the License, or
00008  * (at 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
00013  * GNU 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, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00018  *
00019  * Original author: Paul McCullagh (H&G2JCtL)
00020  * Continued development: Barry Leslie
00021  *
00022  * 2007-05-21
00023  *
00024  * CORE SYSTEM:
00025  * Simple utility functions.
00026  *
00027  */
00028 
00029 #pragma once
00030 #ifndef __CSUTIL_H__
00031 #define __CSUTIL_H__
00032 
00033 #include "CSDefs.h"
00034 
00035 const char  *cs_version();
00036 
00037 void    cs_strcpy(size_t size, char *d, const char *s, size_t len);
00038 void    cs_strcpy(size_t size, char *d, const char *s);
00039 void    cs_strcpy_dottt(size_t size, char *d, const char *s, size_t len);
00040 void    cs_strcpy_left(size_t size, char *d, const char *s, char ch);
00041 void    cs_strcpy_right(size_t size, char *d, const char *s, char ch);
00042 void    cs_strcat(size_t size, char *d, const char *s);
00043 void    cs_strcat_left(size_t size, char *d, const char *s, char ch);
00044 void    cs_strcat_right(size_t size, char *d, const char *s, char ch);
00045 void    cs_strcat(size_t size, char *d, char ch);
00046 void    cs_strcat(char **to, const char *to_cat);
00047 void    cs_strcat(size_t size, char *to, int i);
00048 void    cs_strcat(size_t size, char *to, uint32_t i);
00049 void    cs_strcat(size_t size, char *to, uint64_t i);
00050 void    cs_strcat_hex(size_t size, char *to, uint64_t i);
00051 void    cs_format_context(size_t size, char *buffer, const char *func, const char *file, int line);
00052 int     cs_path_depth(const char *path);
00053 bool    cs_fixed_pattern(const char *path);
00054 bool    cs_match_patern(const char *pattern, const char *str, bool ignore_case);
00055 char    *cs_last_name_of_path(const char *path, int count);
00056 char    *cs_last_name_of_path(const char *path);
00057 char    *cs_last_directory_of_path(const char *path);
00058 const char  *cs_find_extension(const char *file_name);
00059 void    cs_remove_extension(char *file_name);
00060 bool    cs_is_extension(const char *file_name, const char *ext);
00061 bool    cs_remove_dir_char(char *dir_name);
00062 void    cs_remove_last_name_of_path(char *path);
00063 bool    cs_add_dir_char(size_t max, char *path);
00064 bool    cs_is_absolute(const char *path);
00065 void    cs_add_name_to_path(size_t max, char *path, const char *name);
00066 const char  *cs_next_name_of_path(const char *path);
00067 void    cs_adjust_path(size_t max, char *path, const char *rel_path);
00068 char    *cs_strdup(const char *in_str);
00069 char    *cs_strdup(int value);
00070 char    *cs_strdup(const char *in_str, size_t len);
00071 bool    cs_starts_with(const char *cstr, const char *w_cstr);
00072 bool    cs_ends_with(const char *cstr, const char *w_cstr);
00073 void    cs_make_absolute_path(size_t max, char *path, const char *rel_path, const char *cwd);
00074 void    cs_replace_string(size_t size, char *into, const char *find_str, const char *str);
00075 void    cs_replace_string(size_t size, char *into, const char ch, const char *str);
00076 int64_t   cs_str_to_int8(const char *ptr, bool *overflow);
00077 int64_t   cs_byte_size_to_int8(const char *ptr, bool *invalid = NULL);
00078 uint64_t  cs_str_to_word8(const char *ptr, bool *overflow = NULL);
00079 size_t    cs_hex_to_bin(size_t size, void *bin, const char *hex);
00080 size_t    cs_hex_to_bin(size_t size, void *bin, size_t len, const char *hex);
00081 // NOTE: cs_bin_to_hex() Always null terminates the result.
00082 void    cs_bin_to_hex(size_t size, char *hex, size_t len, const void *bin);
00083 void    cs_strToUpper(char *ptr);
00084 void    cs_strToLower(char *ptr);
00085 
00086 const char *cs_version();
00087 bool    cs_str_to_value(const char *ptr, uint32_t *value, uint8_t base);
00088 #endif