aboutsummaryrefslogtreecommitdiff
path: root/src/util/strings.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-02-22 14:53:11 +0100
committerChristian Grothoff <christian@grothoff.org>2017-02-22 14:53:11 +0100
commit0244c0d86cd86e4cc90e0c112c6edeafdfb558c2 (patch)
treeb534b32562883064a09d856f700995a2f1b5cc42 /src/util/strings.c
parent7184623654f81c1ba557f8fa95a3086342b4af6b (diff)
downloadgnunet-0244c0d86cd86e4cc90e0c112c6edeafdfb558c2.tar.gz
gnunet-0244c0d86cd86e4cc90e0c112c6edeafdfb558c2.zip
strcmp instead of memcmp
Diffstat (limited to 'src/util/strings.c')
-rw-r--r--src/util/strings.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/util/strings.c b/src/util/strings.c
index 2b51d3e52..291255344 100644
--- a/src/util/strings.c
+++ b/src/util/strings.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2005-2013 GNUnet e.V. 3 Copyright (C) 2005-2017 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -17,7 +17,6 @@
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA. 18 Boston, MA 02110-1301, USA.
19*/ 19*/
20
21/** 20/**
22 * @file util/strings.c 21 * @file util/strings.c
23 * @brief string functions 22 * @brief string functions
@@ -90,6 +89,37 @@ GNUNET_STRINGS_buffer_fill (char *buffer, size_t size, unsigned int count, ...)
90 89
91 90
92/** 91/**
92 * Convert a peer path to a human-readable string.
93 *
94 * @param pids array of PIDs to convert to a string
95 * @param num_pids length of the @a pids array
96 * @return string representing the array of @a pids
97 */
98char *
99GNUNET_STRINGS_pp2s (const struct GNUNET_PeerIdentity *pids,
100 unsigned int num_pids)
101{
102 char *buf;
103 size_t off;
104 size_t plen = num_pids * 5 + 1;
105
106 off = 0;
107 buf = GNUNET_malloc (plen);
108 for (unsigned int i = 0;
109 i < num_pids;
110 i++)
111 {
112 off += GNUNET_snprintf (&buf[off],
113 plen - off,
114 "%s%s",
115 GNUNET_i2s (&pids[i]),
116 (i == num_pids -1) ? "" : "-");
117 }
118 return buf;
119}
120
121
122/**
93 * Given a buffer of a given size, find "count" 123 * Given a buffer of a given size, find "count"
94 * 0-terminated strings in the buffer and assign 124 * 0-terminated strings in the buffer and assign
95 * the count (varargs) of type "const char**" to the 125 * the count (varargs) of type "const char**" to the