29
29
#ifndef __CSUTIL_H__
30
30
#define __CSUTIL_H__
34
32
#include "CSDefs.h"
34
const char *cs_version();
36
36
void cs_strcpy(size_t size, char *d, const char *s, size_t len);
37
37
void cs_strcpy(size_t size, char *d, const char *s);
38
void cs_strcpy_dottt(size_t size, char *d, const char *s, size_t len);
38
39
void cs_strcpy_left(size_t size, char *d, const char *s, char ch);
39
40
void cs_strcpy_right(size_t size, char *d, const char *s, char ch);
40
41
void cs_strcat(size_t size, char *d, const char *s);
47
48
void cs_strcat(size_t size, char *to, uint64_t i);
48
49
void cs_strcat_hex(size_t size, char *to, uint64_t i);
49
50
void cs_format_context(size_t size, char *buffer, const char *func, const char *file, int line);
51
int cs_path_depth(const char *path);
52
bool cs_fixed_pattern(const char *path);
53
bool cs_match_patern(const char *pattern, const char *str, bool ignore_case);
50
54
char *cs_last_name_of_path(const char *path, int count);
51
55
char *cs_last_name_of_path(const char *path);
52
char *cs_last_directory_of_path(char *path);
56
char *cs_last_directory_of_path(const char *path);
53
57
const char *cs_find_extension(const char *file_name);
54
58
void cs_remove_extension(char *file_name);
55
59
bool cs_is_extension(const char *file_name, const char *ext);
64
68
char *cs_strdup(int value);
65
69
char *cs_strdup(const char *in_str, size_t len);
66
70
bool cs_starts_with(const char *cstr, const char *w_cstr);
71
bool cs_ends_with(const char *cstr, const char *w_cstr);
67
72
void cs_make_absolute_path(size_t max, char *path, const char *rel_path, const char *cwd);
73
void cs_replace_string(size_t size, char *into, const char *find_str, const char *str);
68
74
void cs_replace_string(size_t size, char *into, const char ch, const char *str);
69
75
int64_t cs_str_to_int8(const char *ptr, bool *overflow);
70
int64_t cs_byte_size_to_int8(const char *ptr);
71
uint64_t cs_str_to_word8(const char *ptr, bool *overflow);
76
int64_t cs_byte_size_to_int8(const char *ptr, bool *invalid = NULL);
77
uint64_t cs_str_to_word8(const char *ptr, bool *overflow = NULL);
78
size_t cs_hex_to_bin(size_t size, void *bin, const char *hex);
72
79
size_t cs_hex_to_bin(size_t size, void *bin, size_t len, const char *hex);
73
size_t cs_bin_to_hex(size_t size, char *hex, size_t len, const void *bin);
80
void cs_bin_to_hex(size_t size, char *hex, size_t len, const void *bin);
74
81
void cs_strToUpper(char *ptr);
75
82
void cs_strToLower(char *ptr);
84
const char *cs_version();
85
bool cs_str_to_value(const char *ptr, uint32_t *value, uint8_t base);