doc
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
src
std
c_string.h
Go to the documentation of this file.
1
/*
2
* cynapses libc functions
3
*
4
* Copyright (c) 2008 by Andreas Schneider <mail@cynapses.org>
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software Foundation,
18
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
*
20
* vim: ts=2 sw=2 et cindent
21
*/
22
23
/**
24
* @file c_string.h
25
*
26
* @brief Interface of the cynapses string implementations
27
*
28
* @defgroup cynStringInternals cynapses libc string functions
29
* @ingroup cynLibraryAPI
30
*
31
* @{
32
*/
33
#ifndef _C_STR_H
34
#define _C_STR_H
35
36
struct
c_strlist_s
;
typedef
struct
c_strlist_s
c_strlist_t
;
37
38
/**
39
* @brief Structure for a stringlist
40
*
41
* Using a for loop you can access the strings saved in the vector.
42
*
43
* c_strlist_t strlist;
44
* int i;
45
* for (i = 0; i < strlist->count; i++) {
46
* printf("value: %s", strlist->vector[i];
47
* }
48
*/
49
struct
c_strlist_s
{
50
/** The string vector */
51
char
**
vector
;
52
/** The count of the strings saved in the vector */
53
size_t
count
;
54
/** Size of strings allocated */
55
size_t
size
;
56
};
57
58
/**
59
* @brief Compare to strings if they are equal.
60
*
61
* @param a First string to compare.
62
* @param b Second string to compare.
63
*
64
* @return 1 if they are equal, 0 if not.
65
*/
66
int
c_streq
(
const
char
*a,
const
char
*b);
67
68
/**
69
* @brief Create a new stringlist.
70
*
71
* @param size Size to allocate.
72
*
73
* @return Pointer to the newly allocated stringlist. NULL if an error occured.
74
*/
75
c_strlist_t
*
c_strlist_new
(
size_t
size);
76
77
/**
78
* @brief Expand the stringlist
79
*
80
* @param strlist Stringlist to expand
81
* @param size New size of the strlinglist to expand
82
*
83
* @return Pointer to the expanded stringlist. NULL if an error occured.
84
*/
85
c_strlist_t
*
c_strlist_expand
(
c_strlist_t
*strlist,
size_t
size);
86
87
/**
88
* @brief Add a string to the stringlist.
89
*
90
* Duplicates the string and stores it in the stringlist.
91
*
92
* @param strlist Stringlist to add the string.
93
* @param string String to add.
94
*
95
* @return 0 on success, less than 0 and errno set if an error occured.
96
* ENOBUFS if the list is full.
97
*/
98
int
c_strlist_add
(
c_strlist_t
*strlist,
const
char
*
string
);
99
100
/**
101
* @brief Destroy the memory of the stringlist.
102
*
103
* Frees the strings and the stringlist.
104
*
105
* @param strlist Stringlist to destroy
106
*/
107
void
c_strlist_destroy
(
c_strlist_t
*strlist);
108
109
/**
110
* @breif Replace a string with another string in a source string.
111
*
112
* @param src String to search for pattern.
113
*
114
* @param pattern Pattern to search for in the source string.
115
*
116
* @param repl The string which which should replace pattern if found.
117
*
118
* @return Return a pointer to the source string.
119
*/
120
char
*
c_strreplace
(
char
*src,
const
char
*pattern,
const
char
*repl);
121
122
/**
123
* @brief Uppercase a string.
124
*
125
* @param str The String to uppercase.
126
*
127
* @return The malloced uppered string or NULL on error.
128
*/
129
char
*
c_uppercase
(
const
char
* str);
130
131
/**
132
* @brief Lowercase a string.
133
*
134
* @param str The String to lowercase.
135
*
136
* @return The malloced lowered string or NULL on error.
137
*/
138
char
*
c_lowercase
(
const
char
* str);
139
140
/**
141
* }@
142
*/
143
#endif
/* _C_STR_H */
144
Generated by
1.8.2