$(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 \
#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"
*
* @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)
{
(*new)[n_len] = '\0';
free(tmp_name);
}
+*/
+
+
/**
* Continue shutdown
*/
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;
return;
}
- normalize_name((char*)&sh_msg[1], &nameptr);
+ GNUNET_STRINGS_utf8_tolower((char*)&sh_msg[1], &nameptr);
cah = GNUNET_malloc(sizeof(struct ClientGetAuthHandle));
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;
* @author Martin Schanzenbach
*/
#include "platform.h"
-#include <unicase.h>
#include "gnunet_util_lib.h"
#include "gnunet_transport_service.h"
#include "gnunet_dns_service.h"
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",
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))
{
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,
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);
-
- memcpy(nzkey, normalized_zkey, normal_len);
- nzkey[normal_len] = '\0';
- free(normalized_zkey);
+
+ GNUNET_STRINGS_utf8_toupper(string_hash, &nzkey_ptr);
if (GNUNET_OK != GNUNET_CRYPTO_short_hash_from_string(nzkey,
&zkey))
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.
$(GCLIBADD) $(WINLIB) \
$(LIBGCRYPT_LIBS) \
$(LTLIBICONV) \
- -lltdl -lz $(XLIB)
+ -lltdl -lz -lunistring $(XLIB)
libgnunetutil_la_LDFLAGS = \
$(GN_LIB_LDFLAGS) \
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));
}
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));
}
#endif
#include "gnunet_common.h"
#include "gnunet_strings_lib.h"
+#include <unicase.h>
#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
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);
+}
/**