[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r20766 - in gnunet/src: gns include util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r20766 - in gnunet/src: gns include util |
Date: |
Mon, 26 Mar 2012 14:32:40 +0200 |
Author: schanzen
Date: 2012-03-26 14:32:40 +0200 (Mon, 26 Mar 2012)
New Revision: 20766
Modified:
gnunet/src/gns/Makefile.am
gnunet/src/gns/gnunet-service-gns.c
gnunet/src/gns/gnunet-service-gns_resolver.c
gnunet/src/include/gnunet_strings_lib.h
gnunet/src/util/Makefile.am
gnunet/src/util/crypto_hash.c
gnunet/src/util/strings.c
Log:
-utf8 tolower/upper
Modified: gnunet/src/gns/Makefile.am
===================================================================
--- gnunet/src/gns/Makefile.am 2012-03-26 12:00:26 UTC (rev 20765)
+++ gnunet/src/gns/Makefile.am 2012-03-26 12:32:40 UTC (rev 20766)
@@ -207,7 +207,6 @@
$(top_builddir)/src/dns/libgnunetdnsparser.la \
$(top_builddir)/src/dht/libgnunetdht.la \
$(top_builddir)/src/namestore/libgnunetnamestore.la \
- -lunistring \
$(GN_LIBINTL)
gnunet_service_gns_DEPENDENCIES = \
$(top_builddir)/src/tun/libgnunettun.la \
Modified: gnunet/src/gns/gnunet-service-gns.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns.c 2012-03-26 12:00:26 UTC (rev 20765)
+++ gnunet/src/gns/gnunet-service-gns.c 2012-03-26 12:32:40 UTC (rev 20766)
@@ -31,7 +31,6 @@
#include "gnunet_dnsparser_lib.h"
#include "gnunet_dht_service.h"
#include "gnunet_namestore_service.h"
-#include <unicase.h>
#include "gnunet_gns_service.h"
#include "block_gns.h"
#include "gns.h"
@@ -160,7 +159,7 @@
*
* @param old the old name to normalize
* @param new the buffer to write the new name to
- */
+ *
static void
normalize_name(const char* old, char** new)
{
@@ -174,6 +173,9 @@
(*new)[n_len] = '\0';
free(tmp_name);
}
+*/
+
+
/**
* Continue shutdown
*/
@@ -496,7 +498,7 @@
csh->client = client;
csh->unique_id = sh_msg->id;
- normalize_name((char*)&sh_msg[1], &nameptr);
+ GNUNET_STRINGS_utf8_tolower((char*)&sh_msg[1], &nameptr);
if (strlen (name) < strlen(GNUNET_GNS_TLD)) {
csh->name = NULL;
@@ -608,7 +610,7 @@
return;
}
- normalize_name((char*)&sh_msg[1], &nameptr);
+ GNUNET_STRINGS_utf8_tolower((char*)&sh_msg[1], &nameptr);
cah = GNUNET_malloc(sizeof(struct ClientGetAuthHandle));
@@ -738,7 +740,7 @@
return;
}
- normalize_name((char*)&sh_msg[1], &nameptr);
+ GNUNET_STRINGS_utf8_tolower((char*)&sh_msg[1], &nameptr);
namelen = strlen(name)+1;
clh = GNUNET_malloc(sizeof(struct ClientLookupHandle));
clh->client = client;
Modified: gnunet/src/gns/gnunet-service-gns_resolver.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns_resolver.c 2012-03-26 12:00:26 UTC
(rev 20765)
+++ gnunet/src/gns/gnunet-service-gns_resolver.c 2012-03-26 12:32:40 UTC
(rev 20766)
@@ -26,7 +26,6 @@
* @author Martin Schanzenbach
*/
#include "platform.h"
-#include <unicase.h>
#include "gnunet_util_lib.h"
#include "gnunet_transport_service.h"
#include "gnunet_dns_service.h"
@@ -1988,9 +1987,8 @@
struct ResolverHandle *rh;
struct RecordLookupHandle* rlh;
char string_hash[MAX_DNS_LABEL_LENGTH];
- uint8_t* normalized_zkey;
char nzkey[MAX_DNS_LABEL_LENGTH];
- size_t normal_len;
+ char* nzkey_ptr = nzkey;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting resolution for %s (type=%d)!\n",
@@ -2059,15 +2057,8 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"ZKEY is %s!\n", string_hash);
- normalized_zkey = u8_toupper ((uint8_t*)string_hash,
- strlen ((char *) string_hash),
- NULL, UNINORM_NFD, NULL, &normal_len);
+ GNUNET_STRINGS_utf8_toupper(string_hash, &nzkey_ptr);
-
- memcpy(nzkey, normalized_zkey, normal_len);
- nzkey[normal_len] = '\0';
- free(normalized_zkey);
-
if (GNUNET_OK != GNUNET_CRYPTO_short_hash_from_string(nzkey,
&rh->authority))
{
@@ -2429,9 +2420,8 @@
struct NameShortenHandle *nsh;
char string_hash[MAX_DNS_LABEL_LENGTH];
struct GNUNET_CRYPTO_ShortHashCode zkey;
- uint8_t* normalized_zkey;
- size_t normal_len;
char nzkey[MAX_DNS_LABEL_LENGTH];
+ char* nzkey_ptr = nzkey;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2475,14 +2465,9 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"ZKEY is %s!\n", string_hash);
+
+ GNUNET_STRINGS_utf8_toupper(string_hash, &nzkey_ptr);
- normalized_zkey = u8_toupper ((uint8_t*)string_hash, strlen ((char *)
string_hash),
- NULL, UNINORM_NFD, NULL, &normal_len);
-
- memcpy(nzkey, normalized_zkey, normal_len);
- nzkey[normal_len] = '\0';
- free(normalized_zkey);
-
if (GNUNET_OK != GNUNET_CRYPTO_short_hash_from_string(nzkey,
&zkey))
{
Modified: gnunet/src/include/gnunet_strings_lib.h
===================================================================
--- gnunet/src/include/gnunet_strings_lib.h 2012-03-26 12:00:26 UTC (rev
20765)
+++ gnunet/src/include/gnunet_strings_lib.h 2012-03-26 12:32:40 UTC (rev
20766)
@@ -121,8 +121,29 @@
char *
GNUNET_STRINGS_from_utf8 (const char *input, size_t len, const char *charset);
+/**
+ * Convert the utf-8 input string to lowercase
+ * Output needs to be allocated appropriately
+ *
+ * @param input input string
+ * @param output output buffer
+ */
+void
+GNUNET_STRINGS_utf8_tolower(const char* input, char** output);
+
/**
+ * Convert the utf-8 input string to lowercase
+ * Output needs to be allocated appropriately
+ *
+ * @param input input string
+ * @param output output buffer
+ */
+void
+GNUNET_STRINGS_utf8_toupper(const char* input, char** output);
+
+
+/**
* Complete filename (a la shell) from abbrevition.
*
* @param fil the name of the file, may contain ~/ or
Modified: gnunet/src/util/Makefile.am
===================================================================
--- gnunet/src/util/Makefile.am 2012-03-26 12:00:26 UTC (rev 20765)
+++ gnunet/src/util/Makefile.am 2012-03-26 12:32:40 UTC (rev 20766)
@@ -106,7 +106,7 @@
$(GCLIBADD) $(WINLIB) \
$(LIBGCRYPT_LIBS) \
$(LTLIBICONV) \
- -lltdl -lz $(XLIB)
+ -lltdl -lz -lunistring $(XLIB)
libgnunetutil_la_LDFLAGS = \
$(GN_LIB_LDFLAGS) \
Modified: gnunet/src/util/crypto_hash.c
===================================================================
--- gnunet/src/util/crypto_hash.c 2012-03-26 12:00:26 UTC (rev 20765)
+++ gnunet/src/util/crypto_hash.c 2012-03-26 12:32:40 UTC (rev 20766)
@@ -298,7 +298,12 @@
GNUNET_CRYPTO_hash_from_string2 (const char *enc, size_t enclen,
GNUNET_HashCode * result)
{
- return GNUNET_STRINGS_string_to_data (enc, enclen,
+ char upper_enc[enclen];
+ char* up_ptr = upper_enc;
+
+ GNUNET_STRINGS_utf8_toupper(enc, &up_ptr);
+
+ return GNUNET_STRINGS_string_to_data (upper_enc, enclen,
(unsigned char*) result,
sizeof (struct GNUNET_HashCode));
}
@@ -642,7 +647,12 @@
GNUNET_CRYPTO_short_hash_from_string2 (const char *enc, size_t enclen,
struct GNUNET_CRYPTO_ShortHashCode *
result)
{
- return GNUNET_STRINGS_string_to_data (enc, enclen,
+
+ char upper_enc[enclen];
+ char* up_ptr = upper_enc;
+
+ GNUNET_STRINGS_utf8_toupper(enc, &up_ptr);
+ return GNUNET_STRINGS_string_to_data (upper_enc, enclen,
(unsigned char*) result,
sizeof (struct
GNUNET_CRYPTO_ShortHashCode));
}
Modified: gnunet/src/util/strings.c
===================================================================
--- gnunet/src/util/strings.c 2012-03-26 12:00:26 UTC (rev 20765)
+++ gnunet/src/util/strings.c 2012-03-26 12:32:40 UTC (rev 20766)
@@ -31,6 +31,7 @@
#endif
#include "gnunet_common.h"
#include "gnunet_strings_lib.h"
+#include <unicase.h>
#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
@@ -401,9 +402,48 @@
return GNUNET_STRINGS_conv (input, len, "UTF-8", charset);
}
+/**
+ * Convert the utf-8 input string to lowercase
+ * Output needs to be allocated appropriately
+ *
+ * @param input input string
+ * @param output output buffer
+ */
+void
+GNUNET_STRINGS_utf8_tolower(const char* input, char** output)
+{
+ uint8_t *tmp_in;
+ size_t len;
+ tmp_in = u8_tolower ((uint8_t*)input, strlen ((char *) input),
+ NULL, UNINORM_NFD, NULL, &len);
+ memcpy(*output, tmp_in, len);
+ (*output)[len] = '\0';
+ free(tmp_in);
+}
/**
+ * Convert the utf-8 input string to uppercase
+ * Output needs to be allocated appropriately
+ *
+ * @param input input string
+ * @param output output buffer
+ */
+void
+GNUNET_STRINGS_utf8_toupper(const char* input, char** output)
+{
+ uint8_t *tmp_in;
+ size_t len;
+
+ tmp_in = u8_toupper ((uint8_t*)input, strlen ((char *) input),
+ NULL, UNINORM_NFD, NULL, &len);
+ memcpy(*output, tmp_in, len);
+ (*output)[len] = '\0';
+ free(tmp_in);
+}
+
+
+/**
* Complete filename (a la shell) from abbrevition.
* @param fil the name of the file, may contain ~/ or
* be relative to the current directory
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r20766 - in gnunet/src: gns include util,
gnunet <=