ucx/string.h

Tue, 02 Oct 2012 11:18:47 +0200

author
Mike Becker <universe@uap-core.de>
date
Tue, 02 Oct 2012 11:18:47 +0200
changeset 38
35f67a8ef875
parent 31
91ac86557290
child 39
bf8ab7bb74ff
permissions
-rw-r--r--

added missing stddef includes

added no break comments

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

mercurial