00001 #ifndef VSFTP_STR_H
00002 #define VSFTP_STR_H
00003
00004
00005
00006 #ifndef VSF_FILESIZE_H
00007 #include "filesize.h"
00008 #endif
00009
00010 struct mystr
00011 {
00012 char* PRIVATE_HANDS_OFF_p_buf;
00013
00014 unsigned int PRIVATE_HANDS_OFF_len;
00015 unsigned int PRIVATE_HANDS_OFF_alloc_bytes;
00016 };
00017
00018 #define INIT_MYSTR \
00019 { (void*)0, 0, 0 }
00020
00021 #ifdef VSFTP_STRING_HELPER
00022 #define str_alloc_memchunk private_str_alloc_memchunk
00023 #endif
00024 void private_str_alloc_memchunk(struct mystr* p_str, const char* p_src,
00025 unsigned int len);
00026
00027 void str_alloc_text(struct mystr* p_str, const char* p_src);
00028
00029 void str_alloc_alt_term(struct mystr* p_str, const char* p_src, char term);
00030 void str_alloc_ulong(struct mystr* p_str, unsigned long the_ulong);
00031 void str_alloc_filesize_t(struct mystr* p_str, filesize_t the_filesize);
00032 void str_copy(struct mystr* p_dest, const struct mystr* p_src);
00033 const char* str_strdup(const struct mystr* p_str);
00034 void str_empty(struct mystr* p_str);
00035 void str_free(struct mystr* p_str);
00036 void str_trunc(struct mystr* p_str, unsigned int trunc_len);
00037 void str_reserve(struct mystr* p_str, unsigned int res_len);
00038
00039 int str_isempty(const struct mystr* p_str);
00040 unsigned int str_getlen(const struct mystr* p_str);
00041 const char* str_getbuf(const struct mystr* p_str);
00042
00043 int str_strcmp(const struct mystr* p_str1, const struct mystr* p_str2);
00044 int str_equal(const struct mystr* p_str1, const struct mystr* p_str2);
00045 int str_equal_text(const struct mystr* p_str, const char* p_text);
00046
00047 void str_append_str(struct mystr* p_str, const struct mystr* p_other);
00048 void str_append_text(struct mystr* p_str, const char* p_src);
00049 void str_append_ulong(struct mystr* p_str, unsigned long the_long);
00050 void str_append_filesize_t(struct mystr* p_str, filesize_t the_filesize);
00051 void str_append_char(struct mystr* p_str, char the_char);
00052 void str_append_double(struct mystr* p_str, double the_double);
00053
00054 void str_upper(struct mystr* p_str);
00055 void str_rpad(struct mystr* p_str, const unsigned int min_width);
00056 void str_lpad(struct mystr* p_str, const unsigned int min_width);
00057 void str_replace_char(struct mystr* p_str, char from, char to);
00058 void str_replace_text(struct mystr* p_str, const char* p_from,
00059 const char* p_to);
00060
00061 void str_split_char(struct mystr* p_src, struct mystr* p_rhs, char c);
00062 void str_split_char_reverse(struct mystr* p_src, struct mystr* p_rhs, char c);
00063 void str_split_text(struct mystr* p_src, struct mystr* p_rhs,
00064 const char* p_text);
00065 void str_split_text_reverse(struct mystr* p_src, struct mystr* p_rhs,
00066 const char* p_text);
00067
00068 struct str_locate_result
00069 {
00070 int found;
00071 unsigned int index;
00072 char char_found;
00073 };
00074
00075 struct str_locate_result str_locate_char(
00076 const struct mystr* p_str, char look_char);
00077 struct str_locate_result str_locate_str(
00078 const struct mystr* p_str, const struct mystr* p_look_str);
00079 struct str_locate_result str_locate_str_reverse(
00080 const struct mystr* p_str, const struct mystr* p_look_str);
00081 struct str_locate_result str_locate_text(
00082 const struct mystr* p_str, const char* p_text);
00083 struct str_locate_result str_locate_text_reverse(
00084 const struct mystr* p_str, const char* p_text);
00085 struct str_locate_result str_locate_chars(
00086 const struct mystr* p_str, const char* p_chars);
00087
00088 void str_left(const struct mystr* p_str, struct mystr* p_out,
00089 unsigned int chars);
00090 void str_right(const struct mystr* p_str, struct mystr* p_out,
00091 unsigned int chars);
00092 void str_mid_to_end(const struct mystr* p_str, struct mystr* p_out,
00093 unsigned int indexx);
00094
00095 char str_get_char_at(const struct mystr* p_str, const unsigned int indexx);
00096 int str_contains_space(const struct mystr* p_str);
00097 int str_contains_unprintable(const struct mystr* p_str);
00098 void str_replace_unprintable(struct mystr* p_str, char new_char);
00099 void str_basename (struct mystr* d_str, const struct mystr* path);
00100
00101 int str_atoi(const struct mystr* p_str);
00102 filesize_t str_a_to_filesize_t(const struct mystr* p_str);
00103 unsigned int str_octal_to_uint(const struct mystr* p_str);
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114 int str_getline(const struct mystr* p_str, struct mystr* p_line_str,
00115 unsigned int* p_pos);
00116
00117
00118
00119
00120
00121
00122 int str_contains_line(const struct mystr* p_str,
00123 const struct mystr* p_line_str);
00124
00125 #endif
00126