aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_strings_lib.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_strings_lib.h')
-rw-r--r--src/include/gnunet_strings_lib.h55
1 files changed, 42 insertions, 13 deletions
diff --git a/src/include/gnunet_strings_lib.h b/src/include/gnunet_strings_lib.h
index 955a3afca..977c2ead7 100644
--- a/src/include/gnunet_strings_lib.h
+++ b/src/include/gnunet_strings_lib.h
@@ -327,7 +327,7 @@ GNUNET_STRINGS_data_to_string_alloc (const void *buf,
327 * @param out_size size of the output buffer @a out 327 * @param out_size size of the output buffer @a out
328 * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong encoding 328 * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong encoding
329 */ 329 */
330int 330enum GNUNET_GenericReturnValue
331GNUNET_STRINGS_string_to_data (const char *enc, 331GNUNET_STRINGS_string_to_data (const char *enc,
332 size_t enclen, 332 size_t enclen,
333 void *out, 333 void *out,
@@ -335,6 +335,24 @@ GNUNET_STRINGS_string_to_data (const char *enc,
335 335
336 336
337/** 337/**
338 * Convert CrockfordBase32 encoding back to data.
339 * @a out_size will be determined from @a enc and
340 * @a out will be allocated to be large enough.
341 *
342 * @param enc the encoding
343 * @param enclen number of characters in @a enc (without 0-terminator, which can be missing)
344 * @param[out] out location where to allocate and store the decoded data
345 * @param[out] out_size set to the size of the output buffer @a out
346 * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong encoding
347 */
348enum GNUNET_GenericReturnValue
349GNUNET_STRINGS_string_to_data_alloc (const char *enc,
350 size_t enclen,
351 void **out,
352 size_t *out_size);
353
354
355/**
338 * Encode into Base64. 356 * Encode into Base64.
339 * 357 *
340 * @param data the data to encode 358 * @param data the data to encode
@@ -359,7 +377,10 @@ GNUNET_STRINGS_base64_encode (const void *in,
359 * @return the size of the output 377 * @return the size of the output
360 */ 378 */
361size_t 379size_t
362GNUNET_STRINGS_urlencode (const char *data, size_t len, char **out); 380GNUNET_STRINGS_urlencode (const char *data,
381 size_t len,
382 char **out);
383
363 384
364/** 385/**
365 * Encode into Base64url. RFC7515 386 * Encode into Base64url. RFC7515
@@ -371,7 +392,9 @@ GNUNET_STRINGS_urlencode (const char *data, size_t len, char **out);
371 * @return the size of the output 392 * @return the size of the output
372 */ 393 */
373size_t 394size_t
374GNUNET_STRINGS_base64url_encode (const void *in, size_t len, char **output); 395GNUNET_STRINGS_base64url_encode (const void *in,
396 size_t len,
397 char **output);
375 398
376 399
377/** 400/**
@@ -399,7 +422,9 @@ GNUNET_STRINGS_base64_decode (const char *data,
399 * @return the size of the output 422 * @return the size of the output
400 */ 423 */
401size_t 424size_t
402GNUNET_STRINGS_base64url_decode (const char *data, size_t len, void **out); 425GNUNET_STRINGS_base64url_decode (const char *data,
426 size_t len,
427 void **out);
403 428
404/** 429/**
405 * url/percent encode (RFC3986). 430 * url/percent encode (RFC3986).
@@ -411,7 +436,9 @@ GNUNET_STRINGS_base64url_decode (const char *data, size_t len, void **out);
411 * @return the size of the output 436 * @return the size of the output
412 */ 437 */
413size_t 438size_t
414GNUNET_STRINGS_urldecode (const char *data, size_t len, char **out); 439GNUNET_STRINGS_urldecode (const char *data,
440 size_t len,
441 char **out);
415 442
416 443
417/** 444/**
@@ -442,7 +469,7 @@ GNUNET_STRINGS_pp2s (const struct GNUNET_PeerIdentity *pids,
442 * an URI, '* scheme_part' and '*path_part' will remain unchanged 469 * an URI, '* scheme_part' and '*path_part' will remain unchanged
443 * (if they weren't NULL). 470 * (if they weren't NULL).
444 */ 471 */
445int 472enum GNUNET_GenericReturnValue
446GNUNET_STRINGS_parse_uri (const char *path, 473GNUNET_STRINGS_parse_uri (const char *path,
447 char **scheme_part, 474 char **scheme_part,
448 const char **path_part); 475 const char **path_part);
@@ -462,7 +489,7 @@ GNUNET_STRINGS_parse_uri (const char *path,
462 * GNUNET_free (). Can be NULL. 489 * GNUNET_free (). Can be NULL.
463 * @return #GNUNET_YES if 'filename' is absolute, #GNUNET_NO otherwise. 490 * @return #GNUNET_YES if 'filename' is absolute, #GNUNET_NO otherwise.
464 */ 491 */
465int 492enum GNUNET_GenericReturnValue
466GNUNET_STRINGS_path_is_absolute (const char *filename, 493GNUNET_STRINGS_path_is_absolute (const char *filename,
467 int can_be_uri, 494 int can_be_uri,
468 int *r_is_uri, 495 int *r_is_uri,
@@ -505,7 +532,7 @@ enum GNUNET_STRINGS_FilenameCheck
505 * @return #GNUNET_YES if all checks pass, #GNUNET_NO if at least one of them 532 * @return #GNUNET_YES if all checks pass, #GNUNET_NO if at least one of them
506 * fails, #GNUNET_SYSERR when a check can't be performed 533 * fails, #GNUNET_SYSERR when a check can't be performed
507 */ 534 */
508int 535enum GNUNET_GenericReturnValue
509GNUNET_STRINGS_check_filename (const char *filename, 536GNUNET_STRINGS_check_filename (const char *filename,
510 enum GNUNET_STRINGS_FilenameCheck checks); 537 enum GNUNET_STRINGS_FilenameCheck checks);
511 538
@@ -521,7 +548,7 @@ GNUNET_STRINGS_check_filename (const char *filename,
521 * @return #GNUNET_OK if conversion succeeded. #GNUNET_SYSERR otherwise, in which 548 * @return #GNUNET_OK if conversion succeeded. #GNUNET_SYSERR otherwise, in which
522 * case the contents of r_buf are undefined. 549 * case the contents of r_buf are undefined.
523 */ 550 */
524int 551enum GNUNET_GenericReturnValue
525GNUNET_STRINGS_to_address_ipv6 (const char *zt_addr, 552GNUNET_STRINGS_to_address_ipv6 (const char *zt_addr,
526 uint16_t addrlen, 553 uint16_t addrlen,
527 struct sockaddr_in6 *r_buf); 554 struct sockaddr_in6 *r_buf);
@@ -537,7 +564,7 @@ GNUNET_STRINGS_to_address_ipv6 (const char *zt_addr,
537 * @return #GNUNET_OK if conversion succeeded. #GNUNET_SYSERR otherwise, in which case 564 * @return #GNUNET_OK if conversion succeeded. #GNUNET_SYSERR otherwise, in which case
538 * the contents of r_buf are undefined. 565 * the contents of r_buf are undefined.
539 */ 566 */
540int 567enum GNUNET_GenericReturnValue
541GNUNET_STRINGS_to_address_ipv4 (const char *zt_addr, 568GNUNET_STRINGS_to_address_ipv4 (const char *zt_addr,
542 uint16_t addrlen, 569 uint16_t addrlen,
543 struct sockaddr_in *r_buf); 570 struct sockaddr_in *r_buf);
@@ -569,7 +596,7 @@ GNUNET_STRINGS_parse_socket_addr (const char *addr,
569 * @return #GNUNET_OK if conversion succeeded. #GNUNET_SYSERR otherwise, in which 596 * @return #GNUNET_OK if conversion succeeded. #GNUNET_SYSERR otherwise, in which
570 * case the contents of r_buf are undefined. 597 * case the contents of r_buf are undefined.
571 */ 598 */
572int 599enum GNUNET_GenericReturnValue
573GNUNET_STRINGS_to_address_ip (const char *addr, 600GNUNET_STRINGS_to_address_ip (const char *addr,
574 uint16_t addrlen, 601 uint16_t addrlen,
575 struct sockaddr_storage *r_buf); 602 struct sockaddr_storage *r_buf);
@@ -587,7 +614,7 @@ GNUNET_STRINGS_to_address_ip (const char *addr,
587 * @param u8argv a location to store new argv in 614 * @param u8argv a location to store new argv in
588 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure 615 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
589 */ 616 */
590int 617enum GNUNET_GenericReturnValue
591GNUNET_STRINGS_get_utf8_args (int argc, 618GNUNET_STRINGS_get_utf8_args (int argc,
592 char *const *argv, 619 char *const *argv,
593 int *u8argc, 620 int *u8argc,
@@ -610,7 +637,9 @@ GNUNET_STRINGS_get_utf8_args (int argc,
610 * null byte 637 * null byte
611 */ 638 */
612size_t 639size_t
613GNUNET_strlcpy (char *dst, const char *src, size_t n); 640GNUNET_strlcpy (char *dst,
641 const char *src,
642 size_t n);
614 643
615 644
616/* ***************** IPv4/IPv6 parsing ****************** */ 645/* ***************** IPv4/IPv6 parsing ****************** */