source: trunk/include/sh_string.h@ 179

Last change on this file since 179 was 169, checked in by katerina, 17 years ago

Fixes for tickes #93 to #104 (yes, big commit, bad, bad,...).

File size: 1.3 KB
Line 
1#ifndef SH_STRING_H
2#define SH_STRING_H
3
4
5/* String definition and utility functions.
6 */
7typedef struct sh_str_struct
8{
9 char * str; /* always NULL terminated */
10 size_t len; /* without terminating \0 */
11 size_t siz; /* size of allocated buffer */
12} sh_string;
13
14sh_string * sh_string_new(size_t size);
15void sh_string_destroy(sh_string ** s);
16#define sh_string_str(a) ((a)->str)
17#define sh_string_len(a) ((a)->len)
18
19/* concat string to sh_string
20 */
21sh_string * sh_string_cat_lchar(sh_string * s, char * str, size_t len);
22
23/* set sh_string from string
24 */
25sh_string * sh_string_set_from_char(sh_string * s, char * str);
26
27/* create new sh_string from array of given length
28 */
29sh_string * sh_string_new_from_lchar(char * str, size_t len);
30
31#define sh_string_copy(a) ((a) ? sh_string_new_from_lchar(((a)->str), ((a)->len)) : NULL)
32
33/* create new sh_string from three arrays of given length
34 */
35sh_string * sh_string_new_from_lchar3(char * str1, size_t len1,
36 char * str2, size_t len2,
37 char * str3, size_t len3);
38
39/* Truncate to desired length.
40 */
41sh_string * sh_string_truncate(sh_string * s, size_t len);
42
43/* If requested increase is zero, increase by default amount.
44 */
45sh_string * sh_string_grow(sh_string * s, size_t increase);
46
47#endif
Note: See TracBrowser for help on using the repository browser.