aboutsummaryrefslogtreecommitdiffstats
path: root/epan/tvbuff.h
diff options
context:
space:
mode:
Diffstat (limited to 'epan/tvbuff.h')
-rw-r--r--epan/tvbuff.h42
1 files changed, 25 insertions, 17 deletions
diff --git a/epan/tvbuff.h b/epan/tvbuff.h
index be7db043f3..9e15612105 100644
--- a/epan/tvbuff.h
+++ b/epan/tvbuff.h
@@ -221,18 +221,29 @@ WS_DLL_PUBLIC tvbuff_t *tvb_new_composite(void);
WS_DLL_PUBLIC void tvb_composite_finalize(tvbuff_t *tvb);
-/* Get total length of buffer */
-WS_DLL_PUBLIC guint tvb_length(const tvbuff_t *tvb);
+/* Get amount of captured data in the buffer (which is *NOT* necessarily the
+ * length of the packet). You probably want tvb_reported_length instead. */
+WS_DLL_PUBLIC guint tvb_captured_length(const tvbuff_t *tvb);
+
+/* DEPRECATED, do not use in new code, call tvb_captured_length directly! */
+#define tvb_length tvb_captured_length
/** Computes bytes to end of buffer, from offset (which can be negative,
* to indicate bytes from end of buffer). Function returns 0 if offset is
- * either at the end of the buffer or out of bounds. No exception is thrown. */
-WS_DLL_PUBLIC gint tvb_length_remaining(const tvbuff_t *tvb, const gint offset);
+ * either at the end of the buffer or out of bounds. No exception is thrown.
+ * You probably want tvb_reported_length_remaining instead. */
+WS_DLL_PUBLIC gint tvb_captured_length_remaining(const tvbuff_t *tvb, const gint offset);
+
+/* DEPRECATED, do not use in new code, call tvb_captured_length_remaining directly! */
+#define tvb_length_remaining tvb_captured_length_remaining
/** Same as above, but throws an exception if the offset is out of bounds. */
-WS_DLL_PUBLIC guint tvb_ensure_length_remaining(const tvbuff_t *tvb,
+WS_DLL_PUBLIC guint tvb_ensure_captured_length_remaining(const tvbuff_t *tvb,
const gint offset);
+/* DEPRECATED, do not use in new code, call tvb_ensure_captured_length_remaining directly! */
+#define tvb_ensure_length_remaining tvb_ensure_captured_length_remaining
+
/* Checks (w/o throwing exception) that the bytes referred to by
* 'offset'/'length' actually exist in the buffer */
WS_DLL_PUBLIC gboolean tvb_bytes_exist(const tvbuff_t *tvb, const gint offset,
@@ -472,23 +483,20 @@ extern gchar *tvb_format_stringzpad_wsp(tvbuff_t *tvb, const gint offset,
*
* Throws an exception if the tvbuff ends before the string does.
*
- * tvb_get_string() handles 7-bit ASCII strings, with characters
- * with the 8th bit set are converted to the
- * Unicode REPLACEMENT CHARACTER.
+ * Takes a string encoding as well, and converts to UTF-8 from the encoding,
+ * possibly mapping some characters to the Unicode REPLACEMENT CHARACTER.
*
- * tvb_get_string_enc() takes a string encoding as well, and converts to UTF-8
- * from the encoding, possibly mapping some characters
- * to the REPLACEMENT CHARACTER.
- *
- * If scope is set to NULL it is the user's responsibility to g_free()
- * the memory allocated by tvb_memdup(). Otherwise memory is
- * automatically freed when the scope lifetime is reached.
+ * If scope is set to NULL it is the user's responsibility to wmem_free()
+ * the memory allocated. Otherwise memory is automatically freed when the scope
+ * lifetime is reached.
*/
-WS_DLL_PUBLIC guint8 *tvb_get_string(wmem_allocator_t *scope, tvbuff_t *tvb,
- const gint offset, const gint length);
WS_DLL_PUBLIC guint8 *tvb_get_string_enc(wmem_allocator_t *scope,
tvbuff_t *tvb, const gint offset, const gint length, const guint encoding);
+/* DEPRECATED, do not use in new code, call tvb_get_string_enc directly! */
+#define tvb_get_string(SCOPE, TVB, OFFSET, LENGTH) \
+ tvb_get_string_enc(SCOPE, TVB, OFFSET, LENGTH, ENC_ASCII)
+
/**
* Given a tvbuff, a bit offset, and a number of characters, allocate
* a buffer big enough to hold a non-null-terminated string of no_of_chars