aboutsummaryrefslogtreecommitdiff
path: root/src/gnunet_chat_util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gnunet_chat_util.c')
-rw-r--r--src/gnunet_chat_util.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/gnunet_chat_util.c b/src/gnunet_chat_util.c
index de17e0c..26d2985 100644
--- a/src/gnunet_chat_util.c
+++ b/src/gnunet_chat_util.c
@@ -287,6 +287,19 @@ util_get_filename (const char *directory,
287 return result; 287 return result;
288} 288}
289 289
290char*
291util_get_lower(const char *name)
292{
293 GNUNET_assert(name);
294
295 char *lower = GNUNET_malloc(strlen(name));
296 if (GNUNET_OK == GNUNET_STRINGS_utf8_tolower(name, lower))
297 return lower;
298
299 GNUNET_free(lower);
300 return GNUNET_strdup(name);
301}
302
290int 303int
291util_get_context_label (enum GNUNET_CHAT_ContextType type, 304util_get_context_label (enum GNUNET_CHAT_ContextType type,
292 const struct GNUNET_HashCode *hash, 305 const struct GNUNET_HashCode *hash,
@@ -306,21 +319,31 @@ util_get_context_label (enum GNUNET_CHAT_ContextType type,
306 break; 319 break;
307 } 320 }
308 321
309 return GNUNET_asprintf ( 322 char *low = util_get_lower(GNUNET_h2s(hash));
323
324 int result = GNUNET_asprintf (
310 label, 325 label,
311 "%s_%s", 326 "%s_%s",
312 type_string, 327 type_string,
313 GNUNET_h2s(hash) 328 low
314 ); 329 );
330
331 GNUNET_free(low);
332 return result;
315} 333}
316 334
317int 335int
318util_lobby_name (const struct GNUNET_HashCode *hash, 336util_lobby_name (const struct GNUNET_HashCode *hash,
319 char **name) 337 char **name)
320{ 338{
321 return GNUNET_asprintf ( 339 char *low = util_get_lower(GNUNET_h2s(hash));
340
341 int result = GNUNET_asprintf (
322 name, 342 name,
323 "chat_lobby_%s", 343 "chat_lobby_%s",
324 GNUNET_h2s(hash) 344 low
325 ); 345 );
346
347 GNUNET_free(low);
348 return result;
326} 349}