From Harald Welte:
[obnox/wireshark/wip.git] / epan / guid-utils.c
index 8427c93e6fa157e6e0033d9d2316fed150d4568b..3e44f46a98e58f2cab5b981287678cf60c170c03 100644 (file)
@@ -31,7 +31,7 @@
 
 #include <glib.h>
 #include <epan/epan.h>
-#include <epan/strutil.h>
+#include <wsutil/unicode-utils.h>
 #include <epan/emem.h>
 #include "guid-utils.h"
 
@@ -46,7 +46,7 @@ static emem_tree_t *guid_to_name_tree = NULL;
 #ifdef _WIN32
 /* try to resolve an DCE/RPC interface name to it's name using the Windows registry entries */
 /* XXX - might be better to fill all interfaces into our database at startup instead of searching each time */
-int 
+int
 ResolveWin32UUID(e_guid_t if_id, char *uuid_name, int uuid_name_max_len)
 {
        TCHAR *reg_uuid_name;
@@ -71,7 +71,7 @@ ResolveWin32UUID(e_guid_t if_id, char *uuid_name, int uuid_name_max_len)
                if (RegQueryValueEx(hKey, NULL, NULL, NULL, (LPBYTE)reg_uuid_name, &uuid_max_size) == ERROR_SUCCESS && uuid_max_size <= MAX_PATH) {
                        g_snprintf(uuid_name, uuid_name_max_len, "%s", utf_16to8(reg_uuid_name));
                        RegCloseKey(hKey);
-                       return strlen(uuid_name);
+                       return (int) strlen(uuid_name);
                }
                RegCloseKey(hKey);
        }
@@ -82,7 +82,7 @@ ResolveWin32UUID(e_guid_t if_id, char *uuid_name, int uuid_name_max_len)
 
 
 /* store a guid to name mapping */
-void 
+void
 guids_add_guid(e_guid_t *guid, const gchar *name)
 {
        emem_tree_key_t guidkey[2];
@@ -113,12 +113,12 @@ guids_add_guid(e_guid_t *guid, const gchar *name)
        guidkey[0].key=g;
        guidkey[0].length=4;
        guidkey[1].length=0;
-       
-       pe_tree_insert32_array(guid_to_name_tree, &guidkey[0], name);
+
+       pe_tree_insert32_array(guid_to_name_tree, &guidkey[0], (gchar *) name);
 }
 
 
-/* retreive the registered name for this GUID */
+/* retrieve the registered name for this GUID */
 const gchar *
 guids_get_guid_name(e_guid_t *guid)
 {
@@ -154,7 +154,7 @@ guids_get_guid_name(e_guid_t *guid)
        guidkey[0].key=g;
        guidkey[0].length=4;
        guidkey[1].length=0;
-       
+
        if((name = pe_tree_lookup32_array(guid_to_name_tree, &guidkey[0]))){
                return name;
        }
@@ -172,7 +172,7 @@ guids_get_guid_name(e_guid_t *guid)
 }
 
 
-void 
+void
 guids_init(void)
 {
        guid_to_name_tree=pe_tree_create(EMEM_TREE_TYPE_RED_BLACK, "guid_to_name");
@@ -188,22 +188,17 @@ const gchar *
 guids_resolve_guid_to_str(e_guid_t *guid)
 {
        const gchar *name;
-       gchar *namebuf;
 
        name=guids_get_guid_name(guid);
        if(name){
                return name;
        }
 
-
-       namebuf=ep_alloc(64);
-       g_snprintf(namebuf, 64, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+       return ep_strdup_printf("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
                       guid->data1, guid->data2, guid->data3,
                       guid->data4[0], guid->data4[1],
                       guid->data4[2], guid->data4[3],
                       guid->data4[4], guid->data4[5],
                       guid->data4[6], guid->data4[7]);
-       return namebuf;
 }
 
-