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