diff options
author | Guy Harris <guy@alum.mit.edu> | 2011-07-05 23:59:23 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2011-07-05 23:59:23 +0000 |
commit | 053c583fda564bb3fe7505ed6c3bbf852305c868 (patch) | |
tree | 9de5204646376e5738927cd869a3aa198785ae58 /epan/tvbuff.c | |
parent | 2ef2ecde9ad4c16fa265a98ff4ec34030f182bdc (diff) |
Add some additional routine variants that handle string encodings, and
make FT_STRING and FT_UINT_STRING handle string encodings.
Get rid of FT_EBCDIC in favor of FT_STRING with ENC_EBCDIC.
Add some URLs for DRDA.
Clean up some stuff in TN3270 and TN5250, including using ENC_ values
for proto_tree_add_item().
svn path=/trunk/; revision=37909
Diffstat (limited to 'epan/tvbuff.c')
-rw-r--r-- | epan/tvbuff.c | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c index 7bbcc7a2bc..a5d2df3330 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -2568,15 +2568,16 @@ tvb_get_seasonal_string(tvbuff_t *tvb, const gint offset, const gint length) } /* - * Given a tvbuff and an offset, with the offset assumed to refer to - * a null-terminated string, find the length of that string (and throw - * an exception if the tvbuff ends before we find the null), allocate - * a buffer big enough to hold the string, copy the string into it, - * and return a pointer to the string. Also return the length of the + * Given a tvbuff, an offset, and an encoding, with the offset assumed + * to refer to a null-terminated string, find the length of that string + * (and throw an exception if the tvbuff ends before we find the null), + * allocate a buffer big enough to hold the string, copy the string into + * it, and return a pointer to the string; if the encoding is EBCDIC, map + * the string from EBCDIC to ASCII. Also return the length of the * string (including the terminating null) through a pointer. */ guint8 * -tvb_get_stringz(tvbuff_t *tvb, const gint offset, gint *lengthp) +tvb_get_stringz_enc(tvbuff_t *tvb, const gint offset, gint *lengthp, gint encoding) { guint size; guint8 *strptr; @@ -2584,10 +2585,19 @@ tvb_get_stringz(tvbuff_t *tvb, const gint offset, gint *lengthp) size = tvb_strsize(tvb, offset); strptr = g_malloc(size); tvb_memcpy(tvb, strptr, offset, size); + if ((encoding & ENC_CHARENCODING_MASK) == ENC_EBCDIC) + EBCDIC_to_ASCII(strptr, size); if (lengthp) *lengthp = size; return strptr; } + +guint8 * +tvb_get_stringz(tvbuff_t *tvb, const gint offset, gint *lengthp) +{ + return tvb_get_stringz_enc(tvb, offset, lengthp, ENC_UTF_8|ENC_NA); +} + /* * Given a tvbuff and an offset, with the offset assumed to refer to * a null-terminated string, find the length of that string (and throw @@ -2613,6 +2623,7 @@ tvb_get_const_stringz(tvbuff_t *tvb, const gint offset, gint *lengthp) *lengthp = size; return strptr; } + /* * Given a tvbuff and an offset, with the offset assumed to refer to * a null-terminated string, find the length of that string (and throw @@ -2628,7 +2639,7 @@ tvb_get_const_stringz(tvbuff_t *tvb, const gint offset, gint *lengthp) * after the current packet has been dissected. */ guint8 * -tvb_get_ephemeral_stringz(tvbuff_t *tvb, const gint offset, gint *lengthp) +tvb_get_ephemeral_stringz_enc(tvbuff_t *tvb, const gint offset, gint *lengthp, gint encoding) { guint size; guint8 *strptr; @@ -2636,11 +2647,19 @@ tvb_get_ephemeral_stringz(tvbuff_t *tvb, const gint offset, gint *lengthp) size = tvb_strsize(tvb, offset); strptr = ep_alloc(size); tvb_memcpy(tvb, strptr, offset, size); + if ((encoding & ENC_CHARENCODING_MASK) == ENC_EBCDIC) + EBCDIC_to_ASCII(strptr, size); if (lengthp) *lengthp = size; return strptr; } +guint8 * +tvb_get_ephemeral_stringz(tvbuff_t *tvb, const gint offset, gint *lengthp) +{ + return tvb_get_ephemeral_stringz_enc(tvb, offset, lengthp, ENC_UTF_8|ENC_NA); +} + /* * Unicode (UTF-16) version of tvb_get_ephemeral_stringz() * |