2 * $Id: ftype-string.c,v 1.7 2002/08/28 20:41:00 jmayer Exp $
4 * Ethereal - Network traffic analyzer
5 * By Gerald Combs <gerald@ethereal.com>
6 * Copyright 2001 Gerald Combs
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 #include <ftypes-int.h>
31 string_fvalue_new(fvalue_t *fv)
33 fv->value.string = NULL;
37 string_fvalue_free(fvalue_t *fv)
39 if (fv->value.string) {
40 g_free(fv->value.string);
45 string_fvalue_set(fvalue_t *fv, gpointer value, gboolean already_copied)
47 g_assert(value != NULL);
49 fv->value.string = value;
52 fv->value.string = g_strdup(value);
57 value_get(fvalue_t *fv)
59 return fv->value.string;
63 val_from_string(fvalue_t *fv, char *s, LogFunc logfunc _U_)
65 fv->value.string = g_strdup(s);
72 return strlen(fv->value.string);
76 slice(fvalue_t *fv, GByteArray *bytes, guint offset, guint length)
80 data = fv->value.string + offset;
82 g_byte_array_append(bytes, data, length);
87 cmp_eq(fvalue_t *a, fvalue_t *b)
89 return (strcmp(a->value.string, b->value.string) == 0);
93 cmp_ne(fvalue_t *a, fvalue_t *b)
95 return (strcmp(a->value.string, b->value.string) != 0);
99 cmp_gt(fvalue_t *a, fvalue_t *b)
101 return (strcmp(a->value.string, b->value.string) > 0);
105 cmp_ge(fvalue_t *a, fvalue_t *b)
107 return (strcmp(a->value.string, b->value.string) >= 0);
111 cmp_lt(fvalue_t *a, fvalue_t *b)
113 return (strcmp(a->value.string, b->value.string) < 0);
117 cmp_le(fvalue_t *a, fvalue_t *b)
119 return (strcmp(a->value.string, b->value.string) <= 0);
123 ftype_register_string(void)
126 static ftype_t string_type = {
152 static ftype_t stringz_type = {
178 static ftype_t uint_string_type = {
205 ftype_register(FT_STRING, &string_type);
206 ftype_register(FT_STRINGZ, &stringz_type);
207 ftype_register(FT_UINT_STRING, &uint_string_type);