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.h168
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 */
63int 63int
64GNUNET_STRINGS_fancy_size_to_bytes(const char *fancy_size, 64GNUNET_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 */
76int 76int
77GNUNET_STRINGS_fancy_time_to_relative(const char *fancy_time, 77GNUNET_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 */
91int 91int
92GNUNET_STRINGS_fancy_time_to_absolute(const char *fancy_time, 92GNUNET_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 */
102char * 102char *
103GNUNET_STRINGS_byte_size_fancy(unsigned long long size); 103GNUNET_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 */
119char * 119char *
120GNUNET_STRINGS_conv(const char *input, size_t len, 120GNUNET_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 */
135char * 135char *
136GNUNET_STRINGS_to_utf8(const char *input, 136GNUNET_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 */
152char * 152char *
153GNUNET_STRINGS_from_utf8(const char *input, 153GNUNET_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 */
165void 165void
166GNUNET_STRINGS_utf8_tolower(const char *input, 166GNUNET_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 */
177void 177void
178GNUNET_STRINGS_utf8_toupper(const char *input, 178GNUNET_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 */
190char * 190char *
191GNUNET_STRINGS_filename_expand(const char *fil); 191GNUNET_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 */
213size_t 213size_t
214GNUNET_STRINGS_buffer_fill(char *buffer, 214GNUNET_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 */
232unsigned int 232unsigned int
233GNUNET_STRINGS_buffer_tokenize(const char *buffer, 233GNUNET_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 */
249const char * 249const char *
250GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t); 250GNUNET_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 */
263const char * 263const char *
264GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, 264GNUNET_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 */
279const char * 279const char *
280GNUNET_STRINGS_get_short_name(const char *filename); 280GNUNET_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 */
295char * 295char *
296GNUNET_STRINGS_data_to_string(const void *data, 296GNUNET_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 */
312char * 312char *
313GNUNET_STRINGS_data_to_string_alloc(const void *buf, 313GNUNET_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 */
327int 327int
328GNUNET_STRINGS_string_to_data(const char *enc, 328GNUNET_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 */
343size_t 343size_t
344GNUNET_STRINGS_base64_encode(const void *in, 344GNUNET_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 */
358size_t 358size_t
359GNUNET_STRINGS_base64_decode(const char *data, 359GNUNET_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 */
371char * 371char *
372GNUNET_STRINGS_pp2s(const struct GNUNET_PeerIdentity *pids, 372GNUNET_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 */
392int 392int
393GNUNET_STRINGS_parse_uri(const char *path, 393GNUNET_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 */
412int 412int
413GNUNET_STRINGS_path_is_absolute(const char *filename, 413GNUNET_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 */
422enum GNUNET_STRINGS_FilenameCheck { 422enum 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 */
454int 455int
455GNUNET_STRINGS_check_filename(const char *filename, 456GNUNET_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 */
470int 471int
471GNUNET_STRINGS_to_address_ipv6(const char *zt_addr, 472GNUNET_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 */
486int 487int
487GNUNET_STRINGS_to_address_ipv4(const char *zt_addr, 488GNUNET_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 */
501size_t 502size_t
502GNUNET_STRINGS_parse_socket_addr(const char *addr, 503GNUNET_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 */
518int 519int
519GNUNET_STRINGS_to_address_ip(const char *addr, 520GNUNET_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 */
536int 537int
537GNUNET_STRINGS_get_utf8_args(int argc, 538GNUNET_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 */
558size_t 559size_t
559GNUNET_strlcpy(char *dst, const char *src, size_t n); 560GNUNET_strlcpy (char *dst, const char *src, size_t n);
560 561
561 562
562/* ***************** IPv4/IPv6 parsing ****************** */ 563/* ***************** IPv4/IPv6 parsing ****************** */
563 564
564struct GNUNET_STRINGS_PortPolicy { 565struct 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 */
586struct GNUNET_STRINGS_IPv4NetworkPolicy { 588struct 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 */
607struct GNUNET_STRINGS_IPv6NetworkPolicy { 610struct 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 */
636struct GNUNET_STRINGS_IPv4NetworkPolicy * 640struct GNUNET_STRINGS_IPv4NetworkPolicy *
637GNUNET_STRINGS_parse_ipv4_policy(const char *routeListX); 641GNUNET_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 */
651struct GNUNET_STRINGS_IPv6NetworkPolicy * 655struct GNUNET_STRINGS_IPv6NetworkPolicy *
652GNUNET_STRINGS_parse_ipv6_policy(const char *routeListX); 656GNUNET_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 */