diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-04-12 15:26:34 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-04-12 22:27:22 +0000 |
commit | cb16dff992c3844936bf5829f19e5a5247458503 (patch) | |
tree | 901b7be3379f5b94f150de71d1c0f3e2fa2d12e4 /epan/ftypes/ftype-string.c | |
parent | ef8a0a2ce172810d48371eb65c73b1bd4a6303ca (diff) |
Get rid of more tvb_get_nstringz* calls.
Add an FT_STRINGZPAD type, for null-padded strings (typically
fixed-length fields, where the string can be up to the length of the
field, and is null-padded if it's shorter than that), and use it. Use
IS_FT_STRING() in more cases, so that less code needs to know what types
are string types.
Add a tvb_get_stringzpad() routine, which gets null-padded strings.
Currently, it does the same thing that tvb_get_string_enc() does, but
that might change if we don't store string values as null-terminated
strings.
Change-Id: I46f56e130de8f419a19b56ded914e24cc7518a66
Reviewed-on: https://code.wireshark.org/review/1082
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan/ftypes/ftype-string.c')
-rw-r--r-- | epan/ftypes/ftype-string.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/epan/ftypes/ftype-string.c b/epan/ftypes/ftype-string.c index b2e0c63ef0..3893823b28 100644 --- a/epan/ftypes/ftype-string.c +++ b/epan/ftypes/ftype-string.c @@ -356,8 +356,51 @@ ftype_register_string(void) len, slice, }; + static ftype_t stringzpad_type = { + FT_STRINGZPAD, /* ftype */ + "FT_STRINGZPAD", /* name */ + "Character string", /* pretty name */ + 0, /* wire_size */ + string_fvalue_new, /* new_value */ + string_fvalue_free, /* free_value */ + val_from_unparsed, /* val_from_unparsed */ + val_from_string, /* val_from_string */ + string_to_repr, /* val_to_string_repr */ + string_repr_len, /* len_string_repr */ + + NULL, /* set_value_byte_array */ + NULL, /* set_value_bytes */ + NULL, /* set_value_guid */ + NULL, /* set_value_time */ + string_fvalue_set_string, /* set_value_string */ + NULL, /* set_value_tvbuff */ + NULL, /* set_value_uinteger */ + NULL, /* set_value_sinteger */ + NULL, /* set_value_integer64 */ + NULL, /* set_value_floating */ + + value_get, /* get_value */ + NULL, /* get_value_uinteger */ + NULL, /* get_value_sinteger */ + NULL, /* get_value_integer64 */ + NULL, /* get_value_floating */ + + cmp_eq, + cmp_ne, + cmp_gt, + cmp_ge, + cmp_lt, + cmp_le, + NULL, /* cmp_bitwise_and */ + cmp_contains, /* cmp_contains */ + CMP_MATCHES, + + len, + slice, + }; ftype_register(FT_STRING, &string_type); ftype_register(FT_STRINGZ, &stringz_type); ftype_register(FT_UINT_STRING, &uint_string_type); + ftype_register(FT_STRINGZPAD, &stringzpad_type); } |