/*
- * $Id$
- *
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 2001 Gerald Combs
*
* 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.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif
#include <string.h>
-#include <ctype.h>
+#include <stdlib.h>
#include <ftypes-int.h>
#include <epan/guid-utils.h>
+#include <epan/to_str.h>
static void
-guid_fvalue_set(fvalue_t *fv, gpointer value, gboolean already_copied)
+guid_fvalue_set_guid(fvalue_t *fv, const e_guid_t *value)
{
- g_assert(!already_copied);
- fv->value.guid = *(e_guid_t*)value;
+ fv->value.guid = *value;
}
static gpointer
}
static gboolean
-get_guid(char *s, e_guid_t *guid)
+get_guid(const char *s, e_guid_t *guid)
{
size_t i, n;
- char *p, digits[9];
+ const char *p;
+ char digits[9];
static const char fmt[] = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
n = strlen(s);
return FALSE;
for (i=0; i<n; i++) {
if (fmt[i] == 'X') {
- if (!isxdigit((guchar)s[i]))
+ if (!g_ascii_isxdigit(s[i]))
return FALSE;
} else {
if (s[i] != fmt[i])
return FALSE;
}
}
-
+
p = s;
- strncpy(digits, p, 8);
+ strncpy(digits, p, 8);
digits[8] = '\0';
guid->data1 = (guint32)strtoul(digits, NULL, 16);
p += 9;
- strncpy(digits, p, 4);
+ strncpy(digits, p, 4);
digits[4] = '\0';
guid->data2 = (guint16)strtoul(digits, NULL, 16);
p += 5;
- strncpy(digits, p, 4);
+ strncpy(digits, p, 4);
digits[4] = '\0';
guid->data3 = (guint16)strtoul(digits, NULL, 16);
p += 5;
}
static gboolean
-guid_from_unparsed(fvalue_t *fv, char *s, gboolean allow_partial_value _U_, LogFunc logfunc)
+guid_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_, gchar **err_msg)
{
e_guid_t guid;
if (!get_guid(s, &guid)) {
- logfunc("\"%s\" is not a valid GUID.", s);
+ if (err_msg != NULL)
+ *err_msg = g_strdup_printf("\"%s\" is not a valid GUID.", s);
return FALSE;
}
}
static int
-guid_repr_len(fvalue_t *fv _U_, ftrepr_t rtype _U_)
+guid_repr_len(fvalue_t *fv _U_, ftrepr_t rtype _U_, int field_display _U_)
{
return GUID_STR_LEN;
}
static void
-guid_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, char *buf)
+guid_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, int field_display _U_, char *buf)
{
guid_to_str_buf(&fv->value.guid, buf, GUID_STR_LEN);
}
static gboolean
-cmp_eq(fvalue_t *a, fvalue_t *b)
+cmp_eq(const fvalue_t *a, const 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)
+cmp_ne(const fvalue_t *a, const fvalue_t *b)
{
return memcmp(&a->value.guid, &b->value.guid, sizeof(e_guid_t)) != 0;
}
guid_to_repr, /* val_to_string_repr */
guid_repr_len, /* len_string_repr */
- guid_fvalue_set, /* set_value */
+ NULL, /* set_value_byte_array */
+ NULL, /* set_value_bytes */
+ guid_fvalue_set_guid, /* set_value_guid */
+ NULL, /* set_value_time */
+ NULL, /* set_value_string */
+ NULL, /* set_value_tvbuff */
NULL, /* set_value_uinteger */
NULL, /* set_value_sinteger */
- NULL, /* set_value_integer64 */
+ NULL, /* set_value_uinteger64 */
+ NULL, /* set_value_sinteger64 */
NULL, /* set_value_floating */
value_get, /* get_value */
NULL, /* get_value_uinteger */
NULL, /* get_value_sinteger */
- NULL, /* get_value_integer64 */
+ NULL, /* get_value_uinteger64 */
+ NULL, /* get_value_sinteger64 */
NULL, /* get_value_floating */
cmp_eq,
ftype_register(FT_GUID, &guid_type);
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */