annotate common/strhelp.h @ 152:dbbd761959ae

Include line endings in check
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 24 Mar 2014 17:45:59 +0000
parents c719d3fdbc15
children bf4bfd8843bd
rev   line source
60
6acb1dae6185 Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents: 59
diff changeset
1 #ifndef STRHELP_H
6acb1dae6185 Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents: 59
diff changeset
2 #define STRHELP_H
118
d6a74464430b Fix doxygen documentation.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
3
131
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 120
diff changeset
4 #include <stdbool.h>
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 120
diff changeset
5
118
d6a74464430b Fix doxygen documentation.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
6 /**
d6a74464430b Fix doxygen documentation.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
7 * @file strhelp.h
d6a74464430b Fix doxygen documentation.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
8 * @brief Helper functions for c strings and memory management
d6a74464430b Fix doxygen documentation.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
9 * @details strhelp contains terminating memory allocation functions and
d6a74464430b Fix doxygen documentation.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
10 * some conveniance functions to work with c strings or arrays of c
d6a74464430b Fix doxygen documentation.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
11 * strings.
59
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
12 */
118
d6a74464430b Fix doxygen documentation.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
13
59
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
14 void *xmalloc( size_t n );
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
15 void *xrealloc( void *a, size_t n );
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
16 void *xcalloc( size_t n, size_t m );
60
6acb1dae6185 Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents: 59
diff changeset
17 char *xstrndup( const char *string, const size_t len );
59
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
18
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
19 /**
118
d6a74464430b Fix doxygen documentation.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
20 * @brief Returns the length of the given %NULL-terminated
d6a74464430b Fix doxygen documentation.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
21 * string array str_array.
120
702033705bb8 Removed trailing whitespace.
Sascha Wilde <wilde@intevation.de>
parents: 118
diff changeset
22 * @param[in] str_array a %NULL-terminated array of strings
118
d6a74464430b Fix doxygen documentation.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
23 * @returns length of str_array.
59
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
24 */
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
25 unsigned int strv_length (char **str_array);
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
26
118
d6a74464430b Fix doxygen documentation.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
27 /**
d6a74464430b Fix doxygen documentation.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
28 * @brief append a string to a NULL terminated array of strings.
59
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
29 *
118
d6a74464430b Fix doxygen documentation.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
30 * @param[inout] pArray pointer to the NULL terminated list of string pointers.
59
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
31 * @param[in] string pointer to the string to append to the list.
60
6acb1dae6185 Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents: 59
diff changeset
32 * @param[in] len length of the string to append to the list
118
d6a74464430b Fix doxygen documentation.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
33 */
116
c602d8cfa619 Refactoring: unified naming of string vector functions.
Sascha Wilde <wilde@intevation.de>
parents: 91
diff changeset
34 void strv_append (char ***pArray, const char *string, const size_t len);
59
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
35
118
d6a74464430b Fix doxygen documentation.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
36 /**
d6a74464430b Fix doxygen documentation.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
37 * @brief append a string to another string.
59
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
38 *
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
39 * @param[inout] pDst pointer to the string to be extended.
91
80ab2168760f Also add output size handling to str_append_str
Andre Heinecke <aheinecke@intevation.de>
parents: 60
diff changeset
40 * @param[inout] dst_len length of the dst string. Will be modified.
59
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
41 * @param[in] appendage pointer to the string to append.
60
6acb1dae6185 Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents: 59
diff changeset
42 * @param[in] len length of the string to append.
118
d6a74464430b Fix doxygen documentation.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
43 */
116
c602d8cfa619 Refactoring: unified naming of string vector functions.
Sascha Wilde <wilde@intevation.de>
parents: 91
diff changeset
44 void str_append_str (char **pDst, size_t *dst_len, const char *appendage,
91
80ab2168760f Also add output size handling to str_append_str
Andre Heinecke <aheinecke@intevation.de>
parents: 60
diff changeset
45 const size_t len);
59
3f6378647371 Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
46
118
d6a74464430b Fix doxygen documentation.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
47 /**
d6a74464430b Fix doxygen documentation.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
48 * @brief Frees the given %NULL-terminated string array.
120
702033705bb8 Removed trailing whitespace.
Sascha Wilde <wilde@intevation.de>
parents: 118
diff changeset
49 * @param[inout] str_array a %NULL-terminated array of strings
118
d6a74464430b Fix doxygen documentation.
Sascha Wilde <wilde@intevation.de>
parents: 116
diff changeset
50 */
116
c602d8cfa619 Refactoring: unified naming of string vector functions.
Sascha Wilde <wilde@intevation.de>
parents: 91
diff changeset
51 void strv_free (char **str_array);
131
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 120
diff changeset
52
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 120
diff changeset
53 /**
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 120
diff changeset
54 * @brief Checks whether two strings exactly match
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 120
diff changeset
55 * @param[in] s1 the first string
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 120
diff changeset
56 * @param[in] s2 the second string
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 120
diff changeset
57 * @returns true if s1 and s2 are equal
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 120
diff changeset
58 */
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 120
diff changeset
59 bool str_equal (char *s1, char *s2);
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 120
diff changeset
60
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 120
diff changeset
61 /**
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 120
diff changeset
62 * @brief Checks whether s2 exactly matches the beginning of s1.
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 120
diff changeset
63 * @param[in] s1 the string who's beginning is searched
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 120
diff changeset
64 * @param[in] s2 the string which is searched for
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 120
diff changeset
65 * @returns true if s1 starts with s2, false otherwise
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 120
diff changeset
66 */
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 120
diff changeset
67 bool str_starts_with (char *s1, char *s2);
9104b1b2e4da Added string comparison functions.
Sascha Wilde <wilde@intevation.de>
parents: 120
diff changeset
68
133
c719d3fdbc15 Added functrion to trim white space from string.
Sascha Wilde <wilde@intevation.de>
parents: 131
diff changeset
69 /**
c719d3fdbc15 Added functrion to trim white space from string.
Sascha Wilde <wilde@intevation.de>
parents: 131
diff changeset
70 * @brief Trims all white space from the start and end of string.
c719d3fdbc15 Added functrion to trim white space from string.
Sascha Wilde <wilde@intevation.de>
parents: 131
diff changeset
71 * @details the start of the string is trimmed by setting *s to the
c719d3fdbc15 Added functrion to trim white space from string.
Sascha Wilde <wilde@intevation.de>
parents: 131
diff changeset
72 * first non white space character. The end is trimmed by setting the
c719d3fdbc15 Added functrion to trim white space from string.
Sascha Wilde <wilde@intevation.de>
parents: 131
diff changeset
73 * first character after the last non white space character to \0.
c719d3fdbc15 Added functrion to trim white space from string.
Sascha Wilde <wilde@intevation.de>
parents: 131
diff changeset
74 * @param[inout] s ponter to the string to strip
c719d3fdbc15 Added functrion to trim white space from string.
Sascha Wilde <wilde@intevation.de>
parents: 131
diff changeset
75 */
c719d3fdbc15 Added functrion to trim white space from string.
Sascha Wilde <wilde@intevation.de>
parents: 131
diff changeset
76 bool str_trim (char **s);
c719d3fdbc15 Added functrion to trim white space from string.
Sascha Wilde <wilde@intevation.de>
parents: 131
diff changeset
77
60
6acb1dae6185 Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents: 59
diff changeset
78 #endif

http://wald.intevation.org/projects/trustbridge/