propset...
authorjmayer <jmayer@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 11 Mar 2006 01:45:42 +0000 (01:45 +0000)
committerjmayer <jmayer@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 11 Mar 2006 01:45:42 +0000 (01:45 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@17574 f5534014-38df-0310-8fa8-9805f1628bb7

epan/ftypes/ftype-guid.c
epan/guid-utils.h

index ded271e13138c1c180126f5aa9ab4a50a62995d8..6c78fe9cea3783ff42cb62aed00769e195096989 100644 (file)
-/*\r
- * $Id$\r
- *\r
- * Ethereal - Network traffic analyzer\r
- * By Gerald Combs <gerald@ethereal.com>\r
- * Copyright 2001 Gerald Combs\r
- *\r
- * This program is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU General Public License\r
- * as published by the Free Software Foundation; either version 2\r
- * of the License, or (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\r
- */\r
-\r
-#ifdef HAVE_CONFIG_H\r
-#include "config.h"\r
-#endif\r
-\r
-#include <string.h>\r
-#include <ctype.h>\r
-\r
-#include <ftypes-int.h>\r
-#include <epan/guid-utils.h>\r
-\r
-#define GUID_LEN       16\r
-\r
-static void\r
-guid_fvalue_set(fvalue_t *fv, gpointer value, gboolean already_copied)\r
-{\r
-       fv->value.guid = *(e_guid_t*)value;\r
-}\r
-\r
-static gpointer\r
-value_get(fvalue_t *fv)\r
-{\r
-       return &(fv->value.guid);\r
-}\r
-\r
-static gboolean\r
-get_guid(char *s, e_guid_t *guid)\r
-{\r
-       size_t i, n;\r
-       char *p, digits[9];\r
-       static const char fmt[] = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";\r
-\r
-       n = strlen(s);\r
-       if (n != strlen(fmt))\r
-               return FALSE;\r
-       for (i=0; i<n; i++) {\r
-               if (fmt[i] == 'X') {\r
-                       if (!isxdigit((guchar)s[i]))\r
-                               return FALSE;\r
-               } else {\r
-                       if (s[i] != fmt[i])\r
-                               return FALSE;\r
-               }\r
-       }\r
-       \r
-       p = s;\r
-       strncpy(digits, p, 8); \r
-    digits[8] = '\0';\r
-       guid->data1 = strtoul(digits, NULL, 16);\r
-    p += 9;\r
-       strncpy(digits, p, 4); \r
-    digits[4] = '\0';\r
-       guid->data2 = (guint16)strtoul(digits, NULL, 16);\r
-    p += 5;\r
-       strncpy(digits, p, 4); \r
-    digits[4] = '\0';\r
-       guid->data3 = (guint16)strtoul(digits, NULL, 16);\r
-    p += 5;\r
-       for (i=0; i < sizeof(guid->data4); i++) {\r
-               if (*p == '-') p++;\r
-               digits[0] = *(p++);\r
-               digits[1] = *(p++);\r
-               digits[2] = '\0';\r
-               guid->data4[i] = (guint8)strtoul(digits, NULL, 16);\r
-       }\r
-       return TRUE;\r
-}\r
-\r
-static gboolean\r
-guid_from_unparsed(fvalue_t *fv, char *s, gboolean allow_partial_value _U_, LogFunc logfunc)\r
-{\r
-        e_guid_t guid;\r
-\r
-       if (!get_guid(s, &guid)) {\r
-               logfunc("\"%s\" is not a valid GUID.", s);\r
-               return FALSE;\r
-       }\r
-\r
-       fv->value.guid = guid;\r
-       return TRUE;\r
-}\r
-\r
-static int\r
-guid_repr_len(fvalue_t *fv _U_, ftrepr_t rtype _U_)\r
-{\r
-       return GUID_STR_LEN;\r
-}\r
-\r
-static void\r
-guid_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, char *buf)\r
-{\r
-       guid_to_str_buf(&fv->value.guid, buf, GUID_STR_LEN);\r
-}\r
-\r
-static gboolean\r
-cmp_eq(fvalue_t *a, fvalue_t *b)\r
-{\r
-       return memcmp(&a->value.guid, &b->value.guid, sizeof(e_guid_t)) == 0;\r
-}\r
-\r
-static gboolean\r
-cmp_ne(fvalue_t *a, fvalue_t *b)\r
-{\r
-       return memcmp(&a->value.guid, &b->value.guid, sizeof(e_guid_t)) != 0;\r
-}\r
-\r
-void\r
-ftype_register_guid(void)\r
-{\r
-\r
-       static ftype_t guid_type = {\r
-               "GUID",                 /* name */\r
-               "Globally Unique Identifier",                   /* pretty_name */\r
-               GUID_LEN,                       /* wire_size */\r
-               NULL,                           /* new_value */\r
-               NULL,                           /* free_value */\r
-               guid_from_unparsed,     /* val_from_unparsed */\r
-               NULL,                           /* val_from_string */\r
-               guid_to_repr,           /* val_to_string_repr */\r
-               guid_repr_len,          /* len_string_repr */\r
-\r
-               guid_fvalue_set,        /* set_value */\r
-               NULL,                           /* set_value_integer */\r
-               NULL,                           /* set_value_integer64 */\r
-               NULL,                           /* set_value_floating */\r
-\r
-               value_get,                      /* get_value */\r
-               NULL,                           /* get_value_integer */\r
-               NULL,                           /* get_value_integer64 */\r
-               NULL,                           /* get_value_floating */\r
-\r
-               cmp_eq,\r
-               cmp_ne,\r
-               NULL,\r
-               NULL,\r
-               NULL,\r
-               NULL,\r
-               NULL,\r
-               NULL,\r
-               NULL,                           /* cmp_matches */\r
-\r
-               NULL,\r
-               NULL,\r
-       };\r
-\r
-       ftype_register(FT_GUID, &guid_type);\r
-}\r
+/*
+ * $Id$
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@ethereal.com>
+ * Copyright 2001 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include <ctype.h>
+
+#include <ftypes-int.h>
+#include <epan/guid-utils.h>
+
+#define GUID_LEN       16
+
+static void
+guid_fvalue_set(fvalue_t *fv, gpointer value, gboolean already_copied)
+{
+       fv->value.guid = *(e_guid_t*)value;
+}
+
+static gpointer
+value_get(fvalue_t *fv)
+{
+       return &(fv->value.guid);
+}
+
+static gboolean
+get_guid(char *s, e_guid_t *guid)
+{
+       size_t i, n;
+       char *p, digits[9];
+       static const char fmt[] = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
+
+       n = strlen(s);
+       if (n != strlen(fmt))
+               return FALSE;
+       for (i=0; i<n; i++) {
+               if (fmt[i] == 'X') {
+                       if (!isxdigit((guchar)s[i]))
+                               return FALSE;
+               } else {
+                       if (s[i] != fmt[i])
+                               return FALSE;
+               }
+       }
+       
+       p = s;
+       strncpy(digits, p, 8); 
+    digits[8] = '\0';
+       guid->data1 = strtoul(digits, NULL, 16);
+    p += 9;
+       strncpy(digits, p, 4); 
+    digits[4] = '\0';
+       guid->data2 = (guint16)strtoul(digits, NULL, 16);
+    p += 5;
+       strncpy(digits, p, 4); 
+    digits[4] = '\0';
+       guid->data3 = (guint16)strtoul(digits, NULL, 16);
+    p += 5;
+       for (i=0; i < sizeof(guid->data4); i++) {
+               if (*p == '-') p++;
+               digits[0] = *(p++);
+               digits[1] = *(p++);
+               digits[2] = '\0';
+               guid->data4[i] = (guint8)strtoul(digits, NULL, 16);
+       }
+       return TRUE;
+}
+
+static gboolean
+guid_from_unparsed(fvalue_t *fv, char *s, gboolean allow_partial_value _U_, LogFunc logfunc)
+{
+        e_guid_t guid;
+
+       if (!get_guid(s, &guid)) {
+               logfunc("\"%s\" is not a valid GUID.", s);
+               return FALSE;
+       }
+
+       fv->value.guid = guid;
+       return TRUE;
+}
+
+static int
+guid_repr_len(fvalue_t *fv _U_, ftrepr_t rtype _U_)
+{
+       return GUID_STR_LEN;
+}
+
+static void
+guid_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, char *buf)
+{
+       guid_to_str_buf(&fv->value.guid, buf, GUID_STR_LEN);
+}
+
+static gboolean
+cmp_eq(fvalue_t *a, fvalue_t *b)
+{
+       return memcmp(&a->value.guid, &b->value.guid, sizeof(e_guid_t)) == 0;
+}
+
+static gboolean
+cmp_ne(fvalue_t *a, fvalue_t *b)
+{
+       return memcmp(&a->value.guid, &b->value.guid, sizeof(e_guid_t)) != 0;
+}
+
+void
+ftype_register_guid(void)
+{
+
+       static ftype_t guid_type = {
+               "GUID",                 /* name */
+               "Globally Unique Identifier",                   /* pretty_name */
+               GUID_LEN,                       /* wire_size */
+               NULL,                           /* new_value */
+               NULL,                           /* free_value */
+               guid_from_unparsed,     /* val_from_unparsed */
+               NULL,                           /* val_from_string */
+               guid_to_repr,           /* val_to_string_repr */
+               guid_repr_len,          /* len_string_repr */
+
+               guid_fvalue_set,        /* set_value */
+               NULL,                           /* set_value_integer */
+               NULL,                           /* set_value_integer64 */
+               NULL,                           /* set_value_floating */
+
+               value_get,                      /* get_value */
+               NULL,                           /* get_value_integer */
+               NULL,                           /* get_value_integer64 */
+               NULL,                           /* get_value_floating */
+
+               cmp_eq,
+               cmp_ne,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,
+               NULL,                           /* cmp_matches */
+
+               NULL,
+               NULL,
+       };
+
+       ftype_register(FT_GUID, &guid_type);
+}
index 85269818a90691e04268cb6d6e693652fc06617c..d80e2a6458076517022f04f4eee120e3d0669e05 100644 (file)
@@ -1,38 +1,38 @@
-/* guid-utils.h\r
- * Definitions for GUID handling\r
- *\r
- * $Id$\r
- *\r
- * Ethereal - Network traffic analyzer\r
- * By Gerald Combs <gerald@ethereal.com>\r
- *\r
- * Copyright 1998 Gerald Combs\r
- *\r
- * MobileIPv6 support added by Tomislav Borosa <tomislav.borosa@siemens.hr>\r
- *\r
- * This program is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU General Public License\r
- * as published by the Free Software Foundation; either version 2\r
- * of the License, or (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\r
- */\r
-\r
-#ifndef __GUID_UTILS_H__\r
-#define __GUID_UTILS_H__\r
-\r
-typedef struct _e_guid_t {\r
-    guint32 data1;\r
-    guint16 data2;\r
-    guint16 data3;\r
-    guint8  data4[8];\r
-} e_guid_t;\r
-\r
-#endif /* __GUID_UTILS_H__ */\r
+/* guid-utils.h
+ * Definitions for GUID handling
+ *
+ * $Id$
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@ethereal.com>
+ *
+ * Copyright 1998 Gerald Combs
+ *
+ * MobileIPv6 support added by Tomislav Borosa <tomislav.borosa@siemens.hr>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#ifndef __GUID_UTILS_H__
+#define __GUID_UTILS_H__
+
+typedef struct _e_guid_t {
+    guint32 data1;
+    guint16 data2;
+    guint16 data3;
+    guint8  data4[8];
+} e_guid_t;
+
+#endif /* __GUID_UTILS_H__ */