Tue, 02 Oct 2012 11:18:47 +0200
added missing stddef includes
added no break comments
1 /*
2 * File: sstring.h
3 * Author: olaf
4 *
5 * Created on 17. Juni 2010, 13:26
6 */
8 #ifndef _SSTRING_H
9 #define _SSTRING_H
11 #include <stddef.h>
13 #define S(s) { s, sizeof(s)-1 }
14 #define ST(s) sstrn(s, sizeof(s)-1)
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
20 typedef struct sstring {
21 char *ptr;
22 size_t length;
23 } sstr_t;
25 /*
26 * creates a new sstr_t from a null terminated string
27 *
28 * s null terminated string
29 */
30 sstr_t sstr (char *s);
32 /*
33 * creates a new sstr_t from a string and length
34 *
35 * s string
36 * n length of string
37 */
38 sstr_t sstrn (char *s, size_t n);
41 /*
42 * gets the length of n sstr_t strings
43 *
44 * n number of strings
45 * s string
46 * ... strings
47 */
48 size_t sstrnlen (size_t n, sstr_t s, ...);
51 /*
52 * concatenates n strings
53 *
54 * n number of strings
55 * s new string with enough memory allocated
56 * ... strings
57 */
58 sstr_t sstrncat (size_t n, sstr_t s, sstr_t c1, ...);
61 /*
62 *
63 */
64 sstr_t sstrsubs (sstr_t s, size_t start);
66 /*
67 *
68 */
69 sstr_t sstrsubsl (sstr_t s, size_t start, size_t end);
72 int sstrcmp(sstr_t s1, sstr_t s2);
74 sstr_t sstrdup(sstr_t s);
76 #ifdef __cplusplus
77 }
78 #endif
80 #endif /* _SSTRING_H */