More warining fixes: char -> const char
[obnox/wireshark/wip.git] / epan / to_str.c
index 76bcd4eccd0db501f14e78df550b6d8ec4670aee..51892422609f71538f7112d0d6dae4010a75128f 100644 (file)
@@ -827,11 +827,8 @@ decode_numeric_bitfield(guint32 val, guint32 mask, int width,
 gchar* 
 address_to_str(const address *addr)
 {
-#ifndef INET6_ADDRSTRLEN
-#define INET6_ADDRSTRLEN 46
-#endif
   static int i=0;
-  static gchar *strp, str[16][INET6_ADDRSTRLEN];/* IPv6 is the largest one */
+  static gchar *strp, str[16][256];
 
   i++;
   if(i>=16){
@@ -883,11 +880,18 @@ address_to_str_buf(const address *addr, gchar *buf)
   case AT_SS7PC:
     mtp3_addr_to_str_buf(addr->data, buf);
     break;
+  case AT_STRINGZ:
+    strcpy(buf, addr->data);
+    break;
   case AT_EUI64:
     sprintf(buf, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
             addr->data[0], addr->data[1], addr->data[2], addr->data[3],
             addr->data[4], addr->data[5], addr->data[6], addr->data[7]);
     break;
+  case AT_URI:
+    memmove(buf, addr->data, addr->len);
+    buf[addr->len] = '\0';
+    break;
   default:
     g_assert_not_reached();
   }
@@ -911,22 +915,41 @@ gchar* oid_to_str_buf(const guint8 *oid, gint oid_len, gchar *buf) {
   bufp = buf; value=0;
   for (i=0; i<oid_len; i++){
     byte = oid[i];
-    if ((bufp - buf) > (MAX_OID_STR_LEN - 12)) {
+    if ((bufp - buf) > (MAX_OID_STR_LEN - 16)) {    /* "4294967295" + ".>>>" + '\0' + 1 */
       bufp += sprintf(bufp, ".>>>");
       break;
     }
     if (i == 0) {
-      bufp += sprintf(bufp, "%d.%d", byte/40, byte%40);
+      bufp += sprintf(bufp, "%u.%u", byte/40, byte%40);
       continue;
     }
     value = (value << 7) | (byte & 0x7F);
     if (byte & 0x80) {
       continue;
     }
-    bufp += sprintf(bufp, ".%d", value);
+    bufp += sprintf(bufp, ".%u", value);
     value = 0;
   }
   *bufp = '\0';
 
   return buf;
 }
+
+gchar* guid_to_str(const guint8 *guid) {
+  /* static buffer */
+  static int cnt = 0;
+  static gchar strbuf[8][GUID_STR_LEN];
+
+  cnt = (cnt + 1) % 8;
+  return guid_to_str_buf(guid, strbuf[cnt]);
+}
+
+gchar* guid_to_str_buf(const guint8 *guid, gchar *buf) {
+  sprintf(buf, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+          guid[0], guid[1], guid[2], guid[3],
+          guid[4], guid[5],
+          guid[6], guid[7],
+          guid[8], guid[9], 
+          guid[10], guid[11], guid[12], guid[13], guid[14], guid[15]);
+  return buf;
+}