aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-03-15 14:25:40 +0000
committerChristian Grothoff <christian@grothoff.org>2012-03-15 14:25:40 +0000
commit5af7f409b4947ee6daa18590ed3bed15a18ad00b (patch)
treeb5ab499b8312190ac364e23846fc4f0edbf347d0
parentd6e09d02cc47caa5189af6da003e4bcb037193a0 (diff)
downloadgnunet-5af7f409b4947ee6daa18590ed3bed15a18ad00b.tar.gz
gnunet-5af7f409b4947ee6daa18590ed3bed15a18ad00b.zip
-doxygen fixes, add 'const'
-rw-r--r--src/include/gnunet_strings_lib.h48
-rw-r--r--src/util/strings.c30
2 files changed, 45 insertions, 33 deletions
diff --git a/src/include/gnunet_strings_lib.h b/src/include/gnunet_strings_lib.h
index 2beaa9534..1772b03bf 100644
--- a/src/include/gnunet_strings_lib.h
+++ b/src/include/gnunet_strings_lib.h
@@ -284,39 +284,43 @@ int
284GNUNET_STRINGS_parse_uri (const char *path, char **scheme_part, 284GNUNET_STRINGS_parse_uri (const char *path, char **scheme_part,
285 const char **path_part); 285 const char **path_part);
286 286
287
287/** 288/**
288 * Check whether @filename is absolute or not, and if it's an URI 289 * Check whether filename is absolute or not, and if it's an URI
289 * 290 *
290 * @param filename filename to check 291 * @param filename filename to check
291 * @param can_be_uri GNUNET_YES to check for being URI, GNUNET_NO - to 292 * @param can_be_uri GNUNET_YES to check for being URI, GNUNET_NO - to
292 * assume it's not URI 293 * assume it's not URI
293 * @param r_is_uri a pointer to an int that is set to GNUNET_YES if @filename 294 * @param r_is_uri a pointer to an int that is set to GNUNET_YES if 'filename'
294 * is URI and to GNUNET_NO otherwise. Can be NULL. If @can_be_uri is 295 * is URI and to GNUNET_NO otherwise. Can be NULL. If 'can_be_uri' is
295 * not GNUNET_YES, *r_is_uri is set to GNUNET_NO. 296 * not GNUNET_YES, *r_is_uri is set to GNUNET_NO.
296 * @param r_uri a pointer to a char * that is set to a pointer to URI scheme. 297 * @param r_uri a pointer to a char * that is set to a pointer to URI scheme.
297 * The string is allocated by the function, and should be freed with 298 * The string is allocated by the function, and should be freed with
298 * GNUNET_free (). Can be NULL. 299 * GNUNET_free (). Can be NULL.
299 * @return GNUNET_YES if @filaneme is absolute, GNUNET_NO otherwise. 300 * @return GNUNET_YES if 'filaname' is absolute, GNUNET_NO otherwise.
300 */ 301 */
301int 302int
302GNUNET_STRINGS_path_is_absolute (const char *filename, int can_be_uri, 303GNUNET_STRINGS_path_is_absolute (const char *filename,
303 int *r_is_uri, char **r_uri_scheme); 304 int can_be_uri,
305 int *r_is_uri,
306 char **r_uri_scheme);
307
304 308
305/** 309/**
306 * Perform @checks on @filename 310 * Perform checks on 'filename;
307 * 311 *
308 * @param filename file to check 312 * @param filename file to check
309 * @param checks checks to perform 313 * @param checks checks to perform
310 * @return GNUNET_YES if all @checks pass, GNUNET_NO if at least one of them 314 * @return GNUNET_YES if all checks pass, GNUNET_NO if at least one of them
311 * fails, GNUNET_SYSERR when a check can't be performed 315 * fails, GNUNET_SYSERR when a check can't be performed
312 */ 316 */
313int 317int
314GNUNET_STRINGS_check_filename (const char *filename, 318GNUNET_STRINGS_check_filename (const char *filename,
315 enum GNUNET_STRINGS_FilenameCheck checks); 319 enum GNUNET_STRINGS_FilenameCheck checks);
316 320
317 321
318/** 322/**
319 * Tries to convert @zt_addr string to an IPv6 address. 323 * Tries to convert 'zt_addr' string to an IPv6 address.
320 * 324 *
321 * @param zt_addr 0-terminated string. May be mangled by the function. 325 * @param zt_addr 0-terminated string. May be mangled by the function.
322 * @param addrlen length of zt_addr (not counting 0-terminator). 326 * @param addrlen length of zt_addr (not counting 0-terminator).
@@ -326,11 +330,13 @@ GNUNET_STRINGS_check_filename (const char *filename,
326 * case the contents of r_buf are undefined. 330 * case the contents of r_buf are undefined.
327 */ 331 */
328int 332int
329GNUNET_STRINGS_to_address_ipv6 (char *zt_addr, uint16_t addrlen, 333GNUNET_STRINGS_to_address_ipv6 (const char *zt_addr,
330 struct sockaddr_in6 *r_buf); 334 uint16_t addrlen,
335 struct sockaddr_in6 *r_buf);
336
331 337
332/** 338/**
333 * Tries to convert @zt_addr string to an IPv4 address. 339 * Tries to convert 'zt_addr' string to an IPv4 address.
334 * 340 *
335 * @param zt_addr 0-terminated string. May be mangled by the function. 341 * @param zt_addr 0-terminated string. May be mangled by the function.
336 * @param addrlen length of zt_addr (not counting 0-terminator). 342 * @param addrlen length of zt_addr (not counting 0-terminator).
@@ -339,14 +345,16 @@ GNUNET_STRINGS_to_address_ipv6 (char *zt_addr, uint16_t addrlen,
339 * the contents of r_buf are undefined. 345 * the contents of r_buf are undefined.
340 */ 346 */
341int 347int
342GNUNET_STRINGS_to_address_ipv4 (char *zt_addr, uint16_t addrlen, 348GNUNET_STRINGS_to_address_ipv4 (const char *zt_addr,
343 struct sockaddr_in *r_buf); 349 uint16_t addrlen,
350 struct sockaddr_in *r_buf);
351
344 352
345/** 353/**
346 * Tries to convert @addr string to an IP (v4 or v6) address. 354 * Tries to convert 'addr' string to an IP (v4 or v6) address.
347 * IPv6 address must have its address part enclosed in '()' parens 355 * IPv6 address must have its address part enclosed in '()' parens
348 * instead of '[]'. 356 * instead of '[]'.
349 * Will automatically decide whether to treat @addr as v4 or v6 address. 357 * Will automatically decide whether to treat 'addr' as v4 or v6 address.
350 * 358 *
351 * @param addr a string, may not be 0-terminated. 359 * @param addr a string, may not be 0-terminated.
352 * @param addrlen number of bytes in addr (if addr is 0-terminated, 360 * @param addrlen number of bytes in addr (if addr is 0-terminated,
@@ -356,8 +364,10 @@ GNUNET_STRINGS_to_address_ipv4 (char *zt_addr, uint16_t addrlen,
356 * case the contents of r_buf are undefined. 364 * case the contents of r_buf are undefined.
357 */ 365 */
358int 366int
359GNUNET_STRINGS_to_address_ip (const char *addr, uint16_t addrlen, 367GNUNET_STRINGS_to_address_ip (const char *addr,
360 struct sockaddr_storage *r_buf); 368 uint16_t addrlen,
369 struct sockaddr_storage *r_buf);
370
361 371
362/* ifndef GNUNET_UTIL_STRING_H */ 372/* ifndef GNUNET_UTIL_STRING_H */
363#endif 373#endif
diff --git a/src/util/strings.c b/src/util/strings.c
index 0d58ec567..37500b45b 100644
--- a/src/util/strings.c
+++ b/src/util/strings.c
@@ -921,7 +921,7 @@ GNUNET_STRINGS_path_is_absolute (const char *filename, int can_be_uri,
921 */ 921 */
922int 922int
923GNUNET_STRINGS_check_filename (const char *filename, 923GNUNET_STRINGS_check_filename (const char *filename,
924 enum GNUNET_STRINGS_FilenameCheck checks) 924 enum GNUNET_STRINGS_FilenameCheck checks)
925{ 925{
926 struct stat st; 926 struct stat st;
927 if (filename == NULL || filename[0] == '\0') 927 if (filename == NULL || filename[0] == '\0')
@@ -954,8 +954,9 @@ GNUNET_STRINGS_check_filename (const char *filename,
954#define MAX_IPV4_ADDRLEN 21 954#define MAX_IPV4_ADDRLEN 21
955#define MAX_IP_ADDRLEN MAX_IPV6_ADDRLEN 955#define MAX_IP_ADDRLEN MAX_IPV6_ADDRLEN
956 956
957
957/** 958/**
958 * Tries to convert @zt_addr string to an IPv6 address. 959 * Tries to convert 'zt_addr' string to an IPv6 address.
959 * 960 *
960 * @param zt_addr 0-terminated string. May be mangled by the function. 961 * @param zt_addr 0-terminated string. May be mangled by the function.
961 * @param addrlen length of zt_addr (not counting 0-terminator). 962 * @param addrlen length of zt_addr (not counting 0-terminator).
@@ -965,8 +966,9 @@ GNUNET_STRINGS_check_filename (const char *filename,
965 * case the contents of r_buf are undefined. 966 * case the contents of r_buf are undefined.
966 */ 967 */
967int 968int
968GNUNET_STRINGS_to_address_ipv6 (char *zt_addr, uint16_t addrlen, 969GNUNET_STRINGS_to_address_ipv6 (const char *zt_addr,
969 struct sockaddr_in6 *r_buf) 970 uint16_t addrlen,
971 struct sockaddr_in6 *r_buf)
970{ 972{
971 int ret; 973 int ret;
972 char *port_colon; 974 char *port_colon;
@@ -982,7 +984,6 @@ GNUNET_STRINGS_to_address_ipv6 (char *zt_addr, uint16_t addrlen,
982 if (ret != 1 || port > 65535) 984 if (ret != 1 || port > 65535)
983 return GNUNET_SYSERR; 985 return GNUNET_SYSERR;
984 port_colon[0] = '\0'; 986 port_colon[0] = '\0';
985
986 memset (r_buf, 0, sizeof (struct sockaddr_in6)); 987 memset (r_buf, 0, sizeof (struct sockaddr_in6));
987 ret = inet_pton (AF_INET6, zt_addr, &r_buf->sin6_addr); 988 ret = inet_pton (AF_INET6, zt_addr, &r_buf->sin6_addr);
988 if (ret <= 0) 989 if (ret <= 0)
@@ -992,8 +993,9 @@ GNUNET_STRINGS_to_address_ipv6 (char *zt_addr, uint16_t addrlen,
992 return GNUNET_OK; 993 return GNUNET_OK;
993} 994}
994 995
996
995/** 997/**
996 * Tries to convert @zt_addr string to an IPv4 address. 998 * Tries to convert 'zt_addr' string to an IPv4 address.
997 * 999 *
998 * @param zt_addr 0-terminated string. May be mangled by the function. 1000 * @param zt_addr 0-terminated string. May be mangled by the function.
999 * @param addrlen length of zt_addr (not counting 0-terminator). 1001 * @param addrlen length of zt_addr (not counting 0-terminator).
@@ -1002,8 +1004,8 @@ GNUNET_STRINGS_to_address_ipv6 (char *zt_addr, uint16_t addrlen,
1002 * the contents of r_buf are undefined. 1004 * the contents of r_buf are undefined.
1003 */ 1005 */
1004int 1006int
1005GNUNET_STRINGS_to_address_ipv4 (char *zt_addr, uint16_t addrlen, 1007GNUNET_STRINGS_to_address_ipv4 (const char *zt_addr, uint16_t addrlen,
1006 struct sockaddr_in *r_buf) 1008 struct sockaddr_in *r_buf)
1007{ 1009{
1008 unsigned int temps[5]; 1010 unsigned int temps[5];
1009 unsigned int port; 1011 unsigned int port;
@@ -1030,10 +1032,10 @@ GNUNET_STRINGS_to_address_ipv4 (char *zt_addr, uint16_t addrlen,
1030} 1032}
1031 1033
1032/** 1034/**
1033 * Tries to convert @addr string to an IP (v4 or v6) address. 1035 * Tries to convert 'addr' string to an IP (v4 or v6) address.
1034 * IPv6 address must have its address part enclosed in '()' parens 1036 * IPv6 address must have its address part enclosed in '()' parens
1035 * instead of '[]'. 1037 * instead of '[]'.
1036 * Will automatically decide whether to treat @addr as v4 or v6 address. 1038 * Will automatically decide whether to treat 'addr' as v4 or v6 address.
1037 * 1039 *
1038 * @param addr a string, may not be 0-terminated. 1040 * @param addr a string, may not be 0-terminated.
1039 * @param addrlen number of bytes in addr (if addr is 0-terminated, 1041 * @param addrlen number of bytes in addr (if addr is 0-terminated,
@@ -1043,8 +1045,9 @@ GNUNET_STRINGS_to_address_ipv4 (char *zt_addr, uint16_t addrlen,
1043 * case the contents of r_buf are undefined. 1045 * case the contents of r_buf are undefined.
1044 */ 1046 */
1045int 1047int
1046GNUNET_STRINGS_to_address_ip (const char *addr, uint16_t addrlen, 1048GNUNET_STRINGS_to_address_ip (const char *addr,
1047 struct sockaddr_storage *r_buf) 1049 uint16_t addrlen,
1050 struct sockaddr_storage *r_buf)
1048{ 1051{
1049 uint16_t i; 1052 uint16_t i;
1050 char zt_addr[MAX_IP_ADDRLEN + 1]; 1053 char zt_addr[MAX_IP_ADDRLEN + 1];
@@ -1078,8 +1081,7 @@ GNUNET_STRINGS_to_address_ip (const char *addr, uint16_t addrlen,
1078 } 1081 }
1079 return GNUNET_STRINGS_to_address_ipv6 (zt_addr, zt_len, (struct sockaddr_in6 *) r_buf); 1082 return GNUNET_STRINGS_to_address_ipv6 (zt_addr, zt_len, (struct sockaddr_in6 *) r_buf);
1080 } 1083 }
1081 else 1084 return GNUNET_STRINGS_to_address_ipv4 (zt_addr, zt_len, (struct sockaddr_in *) r_buf);
1082 return GNUNET_STRINGS_to_address_ipv4 (zt_addr, zt_len, (struct sockaddr_in *) r_buf);
1083} 1085}
1084 1086
1085/* end of strings.c */ 1087/* end of strings.c */