1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @defgroup libmisc_conv_help Conversion Helpers |
---|
5 | * |
---|
6 | * @ingroup libmisc |
---|
7 | * @brief Convert String to Pointer (with validation) |
---|
8 | * |
---|
9 | * This file defines the interface to a set of string conversion helpers. |
---|
10 | */ |
---|
11 | |
---|
12 | /* |
---|
13 | * COPYRIGHT (c) 2009-2011. |
---|
14 | * On-Line Applications Research Corporation (OAR). |
---|
15 | * |
---|
16 | * The license and distribution terms for this file may be |
---|
17 | * found in the file LICENSE in this distribution or at |
---|
18 | * http://www.rtems.org/license/LICENSE. |
---|
19 | */ |
---|
20 | |
---|
21 | #ifndef _RTEMS_STRINGTO_H |
---|
22 | #define _RTEMS_STRINGTO_H |
---|
23 | /** |
---|
24 | * @defgroup libmisc_conv_help Conversion Helpers |
---|
25 | * |
---|
26 | * @ingroup libmisc |
---|
27 | */ |
---|
28 | /**@{*/ |
---|
29 | |
---|
30 | #include <rtems.h> |
---|
31 | |
---|
32 | /** |
---|
33 | * @brief Convert String to Pointer (with validation). |
---|
34 | * |
---|
35 | * This method converts a string to a pointer (void *) with |
---|
36 | * basic numeric validation. |
---|
37 | * |
---|
38 | * @param[in] s is the string to convert |
---|
39 | * @param[in] n points to the variable to place the converted output in |
---|
40 | * @param[in] endptr is used to keep track of the position in the string |
---|
41 | * |
---|
42 | * @retval This method returns RTEMS_SUCCESSFUL on successful conversion |
---|
43 | * and *n is filled in. Otherwise, the status indicates the |
---|
44 | * source of the error. |
---|
45 | */ |
---|
46 | rtems_status_code rtems_string_to_pointer( |
---|
47 | const char *s, |
---|
48 | void **n, |
---|
49 | char **endptr |
---|
50 | ); |
---|
51 | |
---|
52 | /** |
---|
53 | * @brief Convert String to Unsigned Character (with validation). |
---|
54 | * |
---|
55 | * This method converts a string to an unsigned character with |
---|
56 | * range validation. |
---|
57 | * |
---|
58 | * @param[in] s is the string to convert |
---|
59 | * @param[in] n points to the variable to place the converted output in |
---|
60 | * @param[in] endptr is used to keep track of the position in the string |
---|
61 | * @param[in] base is the expected base of the number |
---|
62 | * |
---|
63 | * @retval This method returns RTEMS_SUCCESSFUL on successful conversion |
---|
64 | * and *n is filled in. Otherwise, the status indicates the |
---|
65 | * source of the error. |
---|
66 | */ |
---|
67 | rtems_status_code rtems_string_to_unsigned_char( |
---|
68 | const char *s, |
---|
69 | unsigned char *n, |
---|
70 | char **endptr, |
---|
71 | int base |
---|
72 | ); |
---|
73 | |
---|
74 | /** |
---|
75 | * @brief Convert String to Int (with validation). |
---|
76 | * |
---|
77 | * This method converts a string to an int with range validation. |
---|
78 | * |
---|
79 | * @param[in] s is the string to convert |
---|
80 | * @param[in] n points to the variable to place the converted output in |
---|
81 | * @param[in] endptr is used to keep track of the position in the string |
---|
82 | * @param[in] base is the expected base of the number |
---|
83 | * |
---|
84 | * @retval This method returns RTEMS_SUCCESSFUL on successful conversion |
---|
85 | * and *n is filled in. Otherwise, the status indicates the |
---|
86 | * source of the error. |
---|
87 | */ |
---|
88 | rtems_status_code rtems_string_to_int( |
---|
89 | const char *s, |
---|
90 | int *n, |
---|
91 | char **endptr, |
---|
92 | int base |
---|
93 | ); |
---|
94 | |
---|
95 | /** |
---|
96 | * @brief Convert String to Unsigned Int (with validation). |
---|
97 | * |
---|
98 | * This method converts a string to an unsigned int with range validation. |
---|
99 | * |
---|
100 | * @param[in] s is the string to convert |
---|
101 | * @param[in] n points to the variable to place the converted output in |
---|
102 | * @param[in] endptr is used to keep track of the position in the string |
---|
103 | * @param[in] base is the expected base of the number |
---|
104 | * |
---|
105 | * @retval This method returns RTEMS_SUCCESSFUL on successful conversion |
---|
106 | * and *n is filled in. Otherwise, the status indicates the |
---|
107 | * source of the error. |
---|
108 | */ |
---|
109 | rtems_status_code rtems_string_to_unsigned_int( |
---|
110 | const char *s, |
---|
111 | unsigned int *n, |
---|
112 | char **endptr, |
---|
113 | int base |
---|
114 | ); |
---|
115 | |
---|
116 | /** |
---|
117 | * @brief Convert String to Long (with validation). |
---|
118 | * |
---|
119 | * This method converts a string to a long with |
---|
120 | * range validation. |
---|
121 | * |
---|
122 | * @param[in] s is the string to convert |
---|
123 | * @param[in] n points to the variable to place the converted output in |
---|
124 | * @param[in] endptr is used to keep track of the position in the string |
---|
125 | * @param[in] base is the expected base of the number |
---|
126 | * |
---|
127 | * @retval This method returns RTEMS_SUCCESSFUL on successful conversion |
---|
128 | * and *n is filled in. Otherwise, the status indicates the |
---|
129 | * source of the error. |
---|
130 | */ |
---|
131 | rtems_status_code rtems_string_to_long( |
---|
132 | const char *s, |
---|
133 | long *n, |
---|
134 | char **endptr, |
---|
135 | int base |
---|
136 | ); |
---|
137 | |
---|
138 | /** |
---|
139 | * @brief Convert String to Unsigned Long (with validation). |
---|
140 | * |
---|
141 | * This method converts a string to an unsigned long with |
---|
142 | * range validation. |
---|
143 | * |
---|
144 | * @param[in] s is the string to convert |
---|
145 | * @param[in] n points to the variable to place the converted output in |
---|
146 | * @param[in] endptr is used to keep track of the position in the string |
---|
147 | * @param[in] base is the expected base of the number |
---|
148 | * |
---|
149 | * @retval This method returns RTEMS_SUCCESSFUL on successful conversion |
---|
150 | * and *n is filled in. Otherwise, the status indicates the |
---|
151 | * source of the error. |
---|
152 | */ |
---|
153 | rtems_status_code rtems_string_to_unsigned_long( |
---|
154 | const char *s, |
---|
155 | unsigned long *n, |
---|
156 | char **endptr, |
---|
157 | int base |
---|
158 | ); |
---|
159 | |
---|
160 | /** |
---|
161 | * @brief Convert String to Long Long (with validation). |
---|
162 | * |
---|
163 | * This method converts a string to a long long with |
---|
164 | * range validation. |
---|
165 | * |
---|
166 | * @param[in] s is the string to convert |
---|
167 | * @param[in] n points to the variable to place the converted output in |
---|
168 | * @param[in] endptr is used to keep track of the position in the string |
---|
169 | * @param[in] base is the expected base of the number |
---|
170 | * |
---|
171 | * @retval This method returns RTEMS_SUCCESSFUL on successful conversion |
---|
172 | * and *n is filled in. Otherwise, the status indicates the |
---|
173 | * source of the error. |
---|
174 | */ |
---|
175 | rtems_status_code rtems_string_to_long_long( |
---|
176 | const char *s, |
---|
177 | long long *n, |
---|
178 | char **endptr, |
---|
179 | int base |
---|
180 | ); |
---|
181 | |
---|
182 | /** |
---|
183 | * @brief Convert String to Unsigned Long Long (with validation). |
---|
184 | * |
---|
185 | * This method converts a string to an unsigned character with |
---|
186 | * range validation. |
---|
187 | * |
---|
188 | * @param[in] s is the string to convert |
---|
189 | * @param[in] n points to the variable to place the converted output in |
---|
190 | * @param[in] endptr is used to keep track of the position in the string |
---|
191 | * @param[in] base is the expected base of the number |
---|
192 | * |
---|
193 | * @retval This method returns RTEMS_SUCCESSFUL on successful conversion |
---|
194 | * and *n is filled in. Otherwise, the status indicates the |
---|
195 | * source of the error. |
---|
196 | */ |
---|
197 | rtems_status_code rtems_string_to_unsigned_long_long( |
---|
198 | const char *s, |
---|
199 | unsigned long long *n, |
---|
200 | char **endptr, |
---|
201 | int base |
---|
202 | ); |
---|
203 | |
---|
204 | /** |
---|
205 | * @brief Convert String to Float (with validation). |
---|
206 | * |
---|
207 | * This method converts a string to a float with range validation. |
---|
208 | * |
---|
209 | * @param[in] s is the string to convert |
---|
210 | * @param[in] n points to the variable to place the converted output in |
---|
211 | * @param[in] endptr is used to keep track of the position in the string |
---|
212 | * |
---|
213 | * @retval This method returns RTEMS_SUCCESSFUL on successful conversion |
---|
214 | * and *n is filled in. Otherwise, the status indicates the |
---|
215 | * source of the error. |
---|
216 | */ |
---|
217 | rtems_status_code rtems_string_to_float( |
---|
218 | const char *s, |
---|
219 | float *n, |
---|
220 | char **endptr |
---|
221 | ); |
---|
222 | |
---|
223 | /** |
---|
224 | * @brief Convert String to Double (with validation). |
---|
225 | * |
---|
226 | * This method converts a string to a double with range validation. |
---|
227 | * |
---|
228 | * @param[in] s is the string to convert |
---|
229 | * @param[in] n points to the variable to place the converted output in |
---|
230 | * @param[in] endptr is used to keep track of the position in the string |
---|
231 | * |
---|
232 | * @retval This method returns RTEMS_SUCCESSFUL on successful conversion |
---|
233 | * and *n is filled in. Otherwise, the status indicates the |
---|
234 | * source of the error. |
---|
235 | */ |
---|
236 | rtems_status_code rtems_string_to_double( |
---|
237 | const char *s, |
---|
238 | double *n, |
---|
239 | char **endptr |
---|
240 | ); |
---|
241 | |
---|
242 | /** |
---|
243 | * @brief Convert String to long double (with validation). |
---|
244 | * |
---|
245 | * This method converts a string to a long double with range validation. |
---|
246 | * |
---|
247 | * @param[in] s is the string to convert |
---|
248 | * @param[in] n points to the variable to place the converted output in |
---|
249 | * @param[in] endptr is used to keep track of the position in the string |
---|
250 | * |
---|
251 | * @retval This method returns RTEMS_SUCCESSFUL on successful conversion |
---|
252 | * and *n is filled in. Otherwise, the status indicates the |
---|
253 | * source of the error. |
---|
254 | */ |
---|
255 | rtems_status_code rtems_string_to_long_double( |
---|
256 | const char *s, |
---|
257 | long double *n, |
---|
258 | char **endptr |
---|
259 | ); |
---|
260 | |
---|
261 | #endif |
---|
262 | /**@}*/ |
---|