aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-10-30 18:15:48 +0000
committerChristian Grothoff <christian@grothoff.org>2013-10-30 18:15:48 +0000
commitafa714da4ed5de15331a694b25a228e4e4426c18 (patch)
tree35669eea3b84448122138b019f4268b0959f665e /src
parentdf64ed90529f6370a15bdb548f16b1948420c828 (diff)
downloadgnunet-afa714da4ed5de15331a694b25a228e4e4426c18.tar.gz
gnunet-afa714da4ed5de15331a694b25a228e4e4426c18.zip
-simplify utf8_tolower/upper APIs
Diffstat (limited to 'src')
-rw-r--r--src/gns/gnunet-service-gns.c2
-rw-r--r--src/gnsrecord/gnsrecord_misc.c8
-rw-r--r--src/include/gnunet_strings_lib.h16
-rw-r--r--src/util/crypto_hash.c6
-rw-r--r--src/util/strings.c24
5 files changed, 29 insertions, 27 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c
index 530318808..d2e5cda85 100644
--- a/src/gns/gnunet-service-gns.c
+++ b/src/gns/gnunet-service-gns.c
@@ -758,7 +758,7 @@ handle_lookup (void *cls,
758 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 758 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
759 return; 759 return;
760 } 760 }
761 GNUNET_STRINGS_utf8_tolower (utf_in, &nameptr); 761 GNUNET_STRINGS_utf8_tolower (utf_in, nameptr);
762 GNUNET_SERVER_receive_done (client, GNUNET_OK); 762 GNUNET_SERVER_receive_done (client, GNUNET_OK);
763 763
764 clh = GNUNET_new (struct ClientLookupHandle); 764 clh = GNUNET_new (struct ClientLookupHandle);
diff --git a/src/gnsrecord/gnsrecord_misc.c b/src/gnsrecord/gnsrecord_misc.c
index aee1f9fd2..91cbcf017 100644
--- a/src/gnsrecord/gnsrecord_misc.c
+++ b/src/gnsrecord/gnsrecord_misc.c
@@ -45,10 +45,10 @@
45char * 45char *
46GNUNET_GNSRECORD_string_to_lowercase (const char *src) 46GNUNET_GNSRECORD_string_to_lowercase (const char *src)
47{ 47{
48 GNUNET_assert (NULL != src); 48 char *res;
49 char *res = strdup (src); 49
50 /* normalize */ 50 res = GNUNET_strdup (src);
51 GNUNET_STRINGS_utf8_tolower(src, &res); 51 GNUNET_STRINGS_utf8_tolower (src, res);
52 return res; 52 return res;
53} 53}
54 54
diff --git a/src/include/gnunet_strings_lib.h b/src/include/gnunet_strings_lib.h
index 8bb8cfb06..686be93ad 100644
--- a/src/include/gnunet_strings_lib.h
+++ b/src/include/gnunet_strings_lib.h
@@ -153,27 +153,27 @@ GNUNET_STRINGS_from_utf8 (const char *input,
153 153
154 154
155/** 155/**
156 * Convert the utf-8 input string to lowercase 156 * Convert the utf-8 input string to lower case.
157 * Output needs to be allocated appropriately 157 * Output needs to be allocated appropriately.
158 * 158 *
159 * @param input input string 159 * @param input input string
160 * @param output output buffer 160 * @param output output buffer
161 */ 161 */
162void 162void
163GNUNET_STRINGS_utf8_tolower (const char* input, 163GNUNET_STRINGS_utf8_tolower (const char *input,
164 char** output); 164 char *output);
165 165
166 166
167/** 167/**
168 * Convert the utf-8 input string to lowercase 168 * Convert the utf-8 input string to upper case.
169 * Output needs to be allocated appropriately 169 * Output needs to be allocated appropriately.
170 * 170 *
171 * @param input input string 171 * @param input input string
172 * @param output output buffer 172 * @param output output buffer
173 */ 173 */
174void 174void
175GNUNET_STRINGS_utf8_toupper (const char* input, 175GNUNET_STRINGS_utf8_toupper (const char *input,
176 char** output); 176 char *output);
177 177
178 178
179/** 179/**
diff --git a/src/util/crypto_hash.c b/src/util/crypto_hash.c
index cd2ea75bf..e14e7c898 100644
--- a/src/util/crypto_hash.c
+++ b/src/util/crypto_hash.c
@@ -274,12 +274,12 @@ GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode *block,
274int 274int
275GNUNET_CRYPTO_hash_from_string2 (const char *enc, 275GNUNET_CRYPTO_hash_from_string2 (const char *enc,
276 size_t enclen, 276 size_t enclen,
277 struct GNUNET_HashCode *result) 277 struct GNUNET_HashCode *result)
278{ 278{
279 char upper_enc[enclen]; 279 char upper_enc[enclen];
280 char* up_ptr = upper_enc; 280 char *up_ptr = upper_enc;
281 281
282 GNUNET_STRINGS_utf8_toupper(enc, &up_ptr); 282 GNUNET_STRINGS_utf8_toupper (enc, up_ptr);
283 283
284 return GNUNET_STRINGS_string_to_data (upper_enc, enclen, 284 return GNUNET_STRINGS_string_to_data (upper_enc, enclen,
285 (unsigned char*) result, 285 (unsigned char*) result,
diff --git a/src/util/strings.c b/src/util/strings.c
index 00c0cf0e1..d5c752fe1 100644
--- a/src/util/strings.c
+++ b/src/util/strings.c
@@ -492,44 +492,46 @@ GNUNET_STRINGS_from_utf8 (const char *input,
492 492
493 493
494/** 494/**
495 * Convert the utf-8 input string to lowercase 495 * Convert the utf-8 input string to lowercase.
496 * Output needs to be allocated appropriately 496 * Output needs to be allocated appropriately.
497 * 497 *
498 * @param input input string 498 * @param input input string
499 * @param output output buffer 499 * @param output output buffer
500 */ 500 */
501void 501void
502GNUNET_STRINGS_utf8_tolower(const char* input, char** output) 502GNUNET_STRINGS_utf8_tolower (const char *input,
503 char *output)
503{ 504{
504 uint8_t *tmp_in; 505 uint8_t *tmp_in;
505 size_t len; 506 size_t len;
506 507
507 tmp_in = u8_tolower ((uint8_t*)input, strlen ((char *) input), 508 tmp_in = u8_tolower ((uint8_t*)input, strlen ((char *) input),
508 NULL, UNINORM_NFD, NULL, &len); 509 NULL, UNINORM_NFD, NULL, &len);
509 memcpy(*output, tmp_in, len); 510 memcpy(output, tmp_in, len);
510 (*output)[len] = '\0'; 511 output[len] = '\0';
511 free(tmp_in); 512 free(tmp_in);
512} 513}
513 514
514 515
515/** 516/**
516 * Convert the utf-8 input string to uppercase 517 * Convert the utf-8 input string to uppercase.
517 * Output needs to be allocated appropriately 518 * Output needs to be allocated appropriately.
518 * 519 *
519 * @param input input string 520 * @param input input string
520 * @param output output buffer 521 * @param output output buffer
521 */ 522 */
522void 523void
523GNUNET_STRINGS_utf8_toupper(const char* input, char** output) 524GNUNET_STRINGS_utf8_toupper(const char *input,
525 char *output)
524{ 526{
525 uint8_t *tmp_in; 527 uint8_t *tmp_in;
526 size_t len; 528 size_t len;
527 529
528 tmp_in = u8_toupper ((uint8_t*)input, strlen ((char *) input), 530 tmp_in = u8_toupper ((uint8_t*)input, strlen ((char *) input),
529 NULL, UNINORM_NFD, NULL, &len); 531 NULL, UNINORM_NFD, NULL, &len);
530 memcpy(*output, tmp_in, len); 532 memcpy (output, tmp_in, len);
531 (*output)[len] = '\0'; 533 output[len] = '\0';
532 free(tmp_in); 534 free (tmp_in);
533} 535}
534 536
535 537