5 * Arbitrary size string struct
6 * Note: only use with the functions defined herein,
7 * unless you want to just *READ* from the string
9 typedef struct mystring
{
18 * Note: use mystring_unset() on the return value once you're done with it
20 * initial_size: initial available size for the string
21 * size_increment: by how much the allocated size should grow when needed
22 * Returns: a pointer to an initialized mystring struct
24 MString
mystring_new(int, int);
28 * Note: this only sets the first character to '\0', as well as mystring->cursize to 0
30 * string: string to be reset
32 void mystring_clear(MString
);
35 * Enlarges the allocated memory for the string by exactly mystring->incr
37 * string: string to be enlarged
39 void mystring_enlarge(MString
);
42 * Appends a string to the mystring struct
43 * Note: it actually copies toinsert, so you can free it afterwards if appropriate
45 * string: string to append toinsert to
46 * toinsert: the string to be appended to string
48 void mystring_str_append(MString
, char *);
51 * Appends a single character to the mystring struct
53 * string: string to append toinsert to
54 * toinsert: character to append to string
56 void mystring_char_append(MString
, char);
59 * Frees a mystring struct
60 * Note: also frees the string held in the struct, so it can't be used anymore either
62 * string: string to be freed
64 void mystring_free(MString
);
67 * Gets a line from a file (everything up to a '\n' or EOF) and appends it to a mystring struct
68 * Note: this may not work on \r\n newlines
70 * string: string to append to
71 * file: filehandle to read from
73 int mystring_getline(MString
, FILE *);
75 void mystring_truncate(MString
, int);
77 void mystring_erase(MString
, int, int);
79 int mystring_has_prefix(MString
, char *);
81 int mystring_has_suffix(MString
, char *);
83 int mystring_strip(MString
);