diff options
Diffstat (limited to 'src/include/gnunet_strings_lib.h')
-rw-r--r-- | src/include/gnunet_strings_lib.h | 168 |
1 files changed, 86 insertions, 82 deletions
diff --git a/src/include/gnunet_strings_lib.h b/src/include/gnunet_strings_lib.h index 25dfada42..7f532c97a 100644 --- a/src/include/gnunet_strings_lib.h +++ b/src/include/gnunet_strings_lib.h | |||
@@ -61,8 +61,8 @@ extern "C" | |||
61 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 61 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
62 | */ | 62 | */ |
63 | int | 63 | int |
64 | GNUNET_STRINGS_fancy_size_to_bytes(const char *fancy_size, | 64 | GNUNET_STRINGS_fancy_size_to_bytes (const char *fancy_size, |
65 | unsigned long long *size); | 65 | unsigned long long *size); |
66 | 66 | ||
67 | 67 | ||
68 | /** | 68 | /** |
@@ -74,8 +74,8 @@ GNUNET_STRINGS_fancy_size_to_bytes(const char *fancy_size, | |||
74 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 74 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
75 | */ | 75 | */ |
76 | int | 76 | int |
77 | GNUNET_STRINGS_fancy_time_to_relative(const char *fancy_time, | 77 | GNUNET_STRINGS_fancy_time_to_relative (const char *fancy_time, |
78 | struct GNUNET_TIME_Relative *rtime); | 78 | struct GNUNET_TIME_Relative *rtime); |
79 | 79 | ||
80 | 80 | ||
81 | /** | 81 | /** |
@@ -89,8 +89,8 @@ GNUNET_STRINGS_fancy_time_to_relative(const char *fancy_time, | |||
89 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 89 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
90 | */ | 90 | */ |
91 | int | 91 | int |
92 | GNUNET_STRINGS_fancy_time_to_absolute(const char *fancy_time, | 92 | GNUNET_STRINGS_fancy_time_to_absolute (const char *fancy_time, |
93 | struct GNUNET_TIME_Absolute *atime); | 93 | struct GNUNET_TIME_Absolute *atime); |
94 | 94 | ||
95 | 95 | ||
96 | /** | 96 | /** |
@@ -100,7 +100,7 @@ GNUNET_STRINGS_fancy_time_to_absolute(const char *fancy_time, | |||
100 | * @return fancy representation of the size (possibly rounded) for humans | 100 | * @return fancy representation of the size (possibly rounded) for humans |
101 | */ | 101 | */ |
102 | char * | 102 | char * |
103 | GNUNET_STRINGS_byte_size_fancy(unsigned long long size); | 103 | GNUNET_STRINGS_byte_size_fancy (unsigned long long size); |
104 | 104 | ||
105 | 105 | ||
106 | /** | 106 | /** |
@@ -117,9 +117,9 @@ GNUNET_STRINGS_byte_size_fancy(unsigned long long size); | |||
117 | * string is returned. | 117 | * string is returned. |
118 | */ | 118 | */ |
119 | char * | 119 | char * |
120 | GNUNET_STRINGS_conv(const char *input, size_t len, | 120 | GNUNET_STRINGS_conv (const char *input, size_t len, |
121 | const char *input_charset, | 121 | const char *input_charset, |
122 | const char *output_charset); | 122 | const char *output_charset); |
123 | 123 | ||
124 | 124 | ||
125 | /** | 125 | /** |
@@ -133,9 +133,9 @@ GNUNET_STRINGS_conv(const char *input, size_t len, | |||
133 | * @return the converted string (0-terminated) | 133 | * @return the converted string (0-terminated) |
134 | */ | 134 | */ |
135 | char * | 135 | char * |
136 | GNUNET_STRINGS_to_utf8(const char *input, | 136 | GNUNET_STRINGS_to_utf8 (const char *input, |
137 | size_t len, | 137 | size_t len, |
138 | const char *charset); | 138 | const char *charset); |
139 | 139 | ||
140 | 140 | ||
141 | /** | 141 | /** |
@@ -150,9 +150,9 @@ GNUNET_STRINGS_to_utf8(const char *input, | |||
150 | * string is returned. | 150 | * string is returned. |
151 | */ | 151 | */ |
152 | char * | 152 | char * |
153 | GNUNET_STRINGS_from_utf8(const char *input, | 153 | GNUNET_STRINGS_from_utf8 (const char *input, |
154 | size_t len, | 154 | size_t len, |
155 | const char *charset); | 155 | const char *charset); |
156 | 156 | ||
157 | 157 | ||
158 | /** | 158 | /** |
@@ -163,8 +163,8 @@ GNUNET_STRINGS_from_utf8(const char *input, | |||
163 | * @param output output buffer | 163 | * @param output output buffer |
164 | */ | 164 | */ |
165 | void | 165 | void |
166 | GNUNET_STRINGS_utf8_tolower(const char *input, | 166 | GNUNET_STRINGS_utf8_tolower (const char *input, |
167 | char *output); | 167 | char *output); |
168 | 168 | ||
169 | 169 | ||
170 | /** | 170 | /** |
@@ -175,8 +175,8 @@ GNUNET_STRINGS_utf8_tolower(const char *input, | |||
175 | * @param output output buffer | 175 | * @param output output buffer |
176 | */ | 176 | */ |
177 | void | 177 | void |
178 | GNUNET_STRINGS_utf8_toupper(const char *input, | 178 | GNUNET_STRINGS_utf8_toupper (const char *input, |
179 | char *output); | 179 | char *output); |
180 | 180 | ||
181 | 181 | ||
182 | /** | 182 | /** |
@@ -188,7 +188,7 @@ GNUNET_STRINGS_utf8_toupper(const char *input, | |||
188 | * NULL is returned on error | 188 | * NULL is returned on error |
189 | */ | 189 | */ |
190 | char * | 190 | char * |
191 | GNUNET_STRINGS_filename_expand(const char *fil); | 191 | GNUNET_STRINGS_filename_expand (const char *fil); |
192 | 192 | ||
193 | 193 | ||
194 | /** | 194 | /** |
@@ -211,10 +211,10 @@ GNUNET_STRINGS_filename_expand(const char *fil); | |||
211 | * (or number of bytes that would have been written) | 211 | * (or number of bytes that would have been written) |
212 | */ | 212 | */ |
213 | size_t | 213 | size_t |
214 | GNUNET_STRINGS_buffer_fill(char *buffer, | 214 | GNUNET_STRINGS_buffer_fill (char *buffer, |
215 | size_t size, | 215 | size_t size, |
216 | unsigned int count, | 216 | unsigned int count, |
217 | ...); | 217 | ...); |
218 | 218 | ||
219 | 219 | ||
220 | /** | 220 | /** |
@@ -230,9 +230,9 @@ GNUNET_STRINGS_buffer_fill(char *buffer, | |||
230 | * in the buffer, or 0 on error. | 230 | * in the buffer, or 0 on error. |
231 | */ | 231 | */ |
232 | unsigned int | 232 | unsigned int |
233 | GNUNET_STRINGS_buffer_tokenize(const char *buffer, | 233 | GNUNET_STRINGS_buffer_tokenize (const char *buffer, |
234 | size_t size, | 234 | size_t size, |
235 | unsigned int count, ...); | 235 | unsigned int count, ...); |
236 | 236 | ||
237 | 237 | ||
238 | 238 | ||
@@ -247,7 +247,7 @@ GNUNET_STRINGS_buffer_tokenize(const char *buffer, | |||
247 | * @return timestamp in human-readable form in local time | 247 | * @return timestamp in human-readable form in local time |
248 | */ | 248 | */ |
249 | const char * | 249 | const char * |
250 | GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t); | 250 | GNUNET_STRINGS_absolute_time_to_string (struct GNUNET_TIME_Absolute t); |
251 | 251 | ||
252 | 252 | ||
253 | /** | 253 | /** |
@@ -261,8 +261,8 @@ GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t); | |||
261 | * @return string in human-readable form | 261 | * @return string in human-readable form |
262 | */ | 262 | */ |
263 | const char * | 263 | const char * |
264 | GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, | 264 | GNUNET_STRINGS_relative_time_to_string (struct GNUNET_TIME_Relative delta, |
265 | int do_round); | 265 | int do_round); |
266 | 266 | ||
267 | 267 | ||
268 | /** | 268 | /** |
@@ -277,7 +277,7 @@ GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, | |||
277 | * itself. | 277 | * itself. |
278 | */ | 278 | */ |
279 | const char * | 279 | const char * |
280 | GNUNET_STRINGS_get_short_name(const char *filename); | 280 | GNUNET_STRINGS_get_short_name (const char *filename); |
281 | 281 | ||
282 | 282 | ||
283 | /** | 283 | /** |
@@ -293,10 +293,10 @@ GNUNET_STRINGS_get_short_name(const char *filename); | |||
293 | * @return pointer to the next byte in 'out' or NULL on error. | 293 | * @return pointer to the next byte in 'out' or NULL on error. |
294 | */ | 294 | */ |
295 | char * | 295 | char * |
296 | GNUNET_STRINGS_data_to_string(const void *data, | 296 | GNUNET_STRINGS_data_to_string (const void *data, |
297 | size_t size, | 297 | size_t size, |
298 | char *out, | 298 | char *out, |
299 | size_t out_size); | 299 | size_t out_size); |
300 | 300 | ||
301 | 301 | ||
302 | /** | 302 | /** |
@@ -310,8 +310,8 @@ GNUNET_STRINGS_data_to_string(const void *data, | |||
310 | * @return freshly allocated, null-terminated string | 310 | * @return freshly allocated, null-terminated string |
311 | */ | 311 | */ |
312 | char * | 312 | char * |
313 | GNUNET_STRINGS_data_to_string_alloc(const void *buf, | 313 | GNUNET_STRINGS_data_to_string_alloc (const void *buf, |
314 | size_t size); | 314 | size_t size); |
315 | 315 | ||
316 | 316 | ||
317 | /** | 317 | /** |
@@ -325,10 +325,10 @@ GNUNET_STRINGS_data_to_string_alloc(const void *buf, | |||
325 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong encoding | 325 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong encoding |
326 | */ | 326 | */ |
327 | int | 327 | int |
328 | GNUNET_STRINGS_string_to_data(const char *enc, | 328 | GNUNET_STRINGS_string_to_data (const char *enc, |
329 | size_t enclen, | 329 | size_t enclen, |
330 | void *out, | 330 | void *out, |
331 | size_t out_size); | 331 | size_t out_size); |
332 | 332 | ||
333 | 333 | ||
334 | /** | 334 | /** |
@@ -341,9 +341,9 @@ GNUNET_STRINGS_string_to_data(const char *enc, | |||
341 | * @return the size of the output | 341 | * @return the size of the output |
342 | */ | 342 | */ |
343 | size_t | 343 | size_t |
344 | GNUNET_STRINGS_base64_encode(const void *in, | 344 | GNUNET_STRINGS_base64_encode (const void *in, |
345 | size_t len, | 345 | size_t len, |
346 | char **output); | 346 | char **output); |
347 | 347 | ||
348 | 348 | ||
349 | /** | 349 | /** |
@@ -356,9 +356,9 @@ GNUNET_STRINGS_base64_encode(const void *in, | |||
356 | * @return the size of the output | 356 | * @return the size of the output |
357 | */ | 357 | */ |
358 | size_t | 358 | size_t |
359 | GNUNET_STRINGS_base64_decode(const char *data, | 359 | GNUNET_STRINGS_base64_decode (const char *data, |
360 | size_t len, | 360 | size_t len, |
361 | void **output); | 361 | void **output); |
362 | 362 | ||
363 | 363 | ||
364 | /** | 364 | /** |
@@ -369,8 +369,8 @@ GNUNET_STRINGS_base64_decode(const char *data, | |||
369 | * @return string representing the array of @a pids | 369 | * @return string representing the array of @a pids |
370 | */ | 370 | */ |
371 | char * | 371 | char * |
372 | GNUNET_STRINGS_pp2s(const struct GNUNET_PeerIdentity *pids, | 372 | GNUNET_STRINGS_pp2s (const struct GNUNET_PeerIdentity *pids, |
373 | unsigned int num_pids); | 373 | unsigned int num_pids); |
374 | 374 | ||
375 | 375 | ||
376 | /** | 376 | /** |
@@ -390,9 +390,9 @@ GNUNET_STRINGS_pp2s(const struct GNUNET_PeerIdentity *pids, | |||
390 | * (if they weren't NULL). | 390 | * (if they weren't NULL). |
391 | */ | 391 | */ |
392 | int | 392 | int |
393 | GNUNET_STRINGS_parse_uri(const char *path, | 393 | GNUNET_STRINGS_parse_uri (const char *path, |
394 | char **scheme_part, | 394 | char **scheme_part, |
395 | const char **path_part); | 395 | const char **path_part); |
396 | 396 | ||
397 | 397 | ||
398 | /** | 398 | /** |
@@ -410,16 +410,17 @@ GNUNET_STRINGS_parse_uri(const char *path, | |||
410 | * @return #GNUNET_YES if 'filename' is absolute, #GNUNET_NO otherwise. | 410 | * @return #GNUNET_YES if 'filename' is absolute, #GNUNET_NO otherwise. |
411 | */ | 411 | */ |
412 | int | 412 | int |
413 | GNUNET_STRINGS_path_is_absolute(const char *filename, | 413 | GNUNET_STRINGS_path_is_absolute (const char *filename, |
414 | int can_be_uri, | 414 | int can_be_uri, |
415 | int *r_is_uri, | 415 | int *r_is_uri, |
416 | char **r_uri_scheme); | 416 | char **r_uri_scheme); |
417 | 417 | ||
418 | 418 | ||
419 | /** | 419 | /** |
420 | * Flags for what we should check a file for. | 420 | * Flags for what we should check a file for. |
421 | */ | 421 | */ |
422 | enum GNUNET_STRINGS_FilenameCheck { | 422 | enum GNUNET_STRINGS_FilenameCheck |
423 | { | ||
423 | /** | 424 | /** |
424 | * Check that it exists. | 425 | * Check that it exists. |
425 | */ | 426 | */ |
@@ -452,8 +453,8 @@ enum GNUNET_STRINGS_FilenameCheck { | |||
452 | * fails, #GNUNET_SYSERR when a check can't be performed | 453 | * fails, #GNUNET_SYSERR when a check can't be performed |
453 | */ | 454 | */ |
454 | int | 455 | int |
455 | GNUNET_STRINGS_check_filename(const char *filename, | 456 | GNUNET_STRINGS_check_filename (const char *filename, |
456 | enum GNUNET_STRINGS_FilenameCheck checks); | 457 | enum GNUNET_STRINGS_FilenameCheck checks); |
457 | 458 | ||
458 | 459 | ||
459 | /** | 460 | /** |
@@ -468,9 +469,9 @@ GNUNET_STRINGS_check_filename(const char *filename, | |||
468 | * case the contents of r_buf are undefined. | 469 | * case the contents of r_buf are undefined. |
469 | */ | 470 | */ |
470 | int | 471 | int |
471 | GNUNET_STRINGS_to_address_ipv6(const char *zt_addr, | 472 | GNUNET_STRINGS_to_address_ipv6 (const char *zt_addr, |
472 | uint16_t addrlen, | 473 | uint16_t addrlen, |
473 | struct sockaddr_in6 *r_buf); | 474 | struct sockaddr_in6 *r_buf); |
474 | 475 | ||
475 | 476 | ||
476 | /** | 477 | /** |
@@ -484,9 +485,9 @@ GNUNET_STRINGS_to_address_ipv6(const char *zt_addr, | |||
484 | * the contents of r_buf are undefined. | 485 | * the contents of r_buf are undefined. |
485 | */ | 486 | */ |
486 | int | 487 | int |
487 | GNUNET_STRINGS_to_address_ipv4(const char *zt_addr, | 488 | GNUNET_STRINGS_to_address_ipv4 (const char *zt_addr, |
488 | uint16_t addrlen, | 489 | uint16_t addrlen, |
489 | struct sockaddr_in *r_buf); | 490 | struct sockaddr_in *r_buf); |
490 | 491 | ||
491 | 492 | ||
492 | /** | 493 | /** |
@@ -499,9 +500,9 @@ GNUNET_STRINGS_to_address_ipv4(const char *zt_addr, | |||
499 | * @return 0 on error, otherwise number of bytes in @a sa | 500 | * @return 0 on error, otherwise number of bytes in @a sa |
500 | */ | 501 | */ |
501 | size_t | 502 | size_t |
502 | GNUNET_STRINGS_parse_socket_addr(const char *addr, | 503 | GNUNET_STRINGS_parse_socket_addr (const char *addr, |
503 | uint8_t *af, | 504 | uint8_t *af, |
504 | struct sockaddr **sa); | 505 | struct sockaddr **sa); |
505 | 506 | ||
506 | 507 | ||
507 | /** | 508 | /** |
@@ -516,9 +517,9 @@ GNUNET_STRINGS_parse_socket_addr(const char *addr, | |||
516 | * case the contents of r_buf are undefined. | 517 | * case the contents of r_buf are undefined. |
517 | */ | 518 | */ |
518 | int | 519 | int |
519 | GNUNET_STRINGS_to_address_ip(const char *addr, | 520 | GNUNET_STRINGS_to_address_ip (const char *addr, |
520 | uint16_t addrlen, | 521 | uint16_t addrlen, |
521 | struct sockaddr_storage *r_buf); | 522 | struct sockaddr_storage *r_buf); |
522 | 523 | ||
523 | 524 | ||
524 | /** | 525 | /** |
@@ -534,10 +535,10 @@ GNUNET_STRINGS_to_address_ip(const char *addr, | |||
534 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure | 535 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure |
535 | */ | 536 | */ |
536 | int | 537 | int |
537 | GNUNET_STRINGS_get_utf8_args(int argc, | 538 | GNUNET_STRINGS_get_utf8_args (int argc, |
538 | char *const *argv, | 539 | char *const *argv, |
539 | int *u8argc, | 540 | int *u8argc, |
540 | char *const **u8argv); | 541 | char *const **u8argv); |
541 | 542 | ||
542 | 543 | ||
543 | /** | 544 | /** |
@@ -556,12 +557,13 @@ GNUNET_STRINGS_get_utf8_args(int argc, | |||
556 | * null byte | 557 | * null byte |
557 | */ | 558 | */ |
558 | size_t | 559 | size_t |
559 | GNUNET_strlcpy(char *dst, const char *src, size_t n); | 560 | GNUNET_strlcpy (char *dst, const char *src, size_t n); |
560 | 561 | ||
561 | 562 | ||
562 | /* ***************** IPv4/IPv6 parsing ****************** */ | 563 | /* ***************** IPv4/IPv6 parsing ****************** */ |
563 | 564 | ||
564 | struct GNUNET_STRINGS_PortPolicy { | 565 | struct GNUNET_STRINGS_PortPolicy |
566 | { | ||
565 | /** | 567 | /** |
566 | * Starting port range (0 if none given). | 568 | * Starting port range (0 if none given). |
567 | */ | 569 | */ |
@@ -583,7 +585,8 @@ struct GNUNET_STRINGS_PortPolicy { | |||
583 | /** | 585 | /** |
584 | * @brief IPV4 network in CIDR notation. | 586 | * @brief IPV4 network in CIDR notation. |
585 | */ | 587 | */ |
586 | struct GNUNET_STRINGS_IPv4NetworkPolicy { | 588 | struct GNUNET_STRINGS_IPv4NetworkPolicy |
589 | { | ||
587 | /** | 590 | /** |
588 | * IPv4 address. | 591 | * IPv4 address. |
589 | */ | 592 | */ |
@@ -604,7 +607,8 @@ struct GNUNET_STRINGS_IPv4NetworkPolicy { | |||
604 | /** | 607 | /** |
605 | * @brief network in CIDR notation for IPV6. | 608 | * @brief network in CIDR notation for IPV6. |
606 | */ | 609 | */ |
607 | struct GNUNET_STRINGS_IPv6NetworkPolicy { | 610 | struct GNUNET_STRINGS_IPv6NetworkPolicy |
611 | { | ||
608 | /** | 612 | /** |
609 | * IPv6 address. | 613 | * IPv6 address. |
610 | */ | 614 | */ |
@@ -634,7 +638,7 @@ struct GNUNET_STRINGS_IPv6NetworkPolicy { | |||
634 | * NULL if the synatx is flawed | 638 | * NULL if the synatx is flawed |
635 | */ | 639 | */ |
636 | struct GNUNET_STRINGS_IPv4NetworkPolicy * | 640 | struct GNUNET_STRINGS_IPv4NetworkPolicy * |
637 | GNUNET_STRINGS_parse_ipv4_policy(const char *routeListX); | 641 | GNUNET_STRINGS_parse_ipv4_policy (const char *routeListX); |
638 | 642 | ||
639 | 643 | ||
640 | /** | 644 | /** |
@@ -649,7 +653,7 @@ GNUNET_STRINGS_parse_ipv4_policy(const char *routeListX); | |||
649 | * @return the converted list, 0-terminated, NULL if the synatx is flawed | 653 | * @return the converted list, 0-terminated, NULL if the synatx is flawed |
650 | */ | 654 | */ |
651 | struct GNUNET_STRINGS_IPv6NetworkPolicy * | 655 | struct GNUNET_STRINGS_IPv6NetworkPolicy * |
652 | GNUNET_STRINGS_parse_ipv6_policy(const char *routeListX); | 656 | GNUNET_STRINGS_parse_ipv6_policy (const char *routeListX); |
653 | 657 | ||
654 | 658 | ||
655 | #if 0 /* keep Emacsens' auto-indent happy */ | 659 | #if 0 /* keep Emacsens' auto-indent happy */ |