aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/wtap-int.h
diff options
context:
space:
mode:
Diffstat (limited to 'wiretap/wtap-int.h')
-rw-r--r--wiretap/wtap-int.h64
1 files changed, 37 insertions, 27 deletions
diff --git a/wiretap/wtap-int.h b/wiretap/wtap-int.h
index fa95119dfe..c550502b81 100644
--- a/wiretap/wtap-int.h
+++ b/wiretap/wtap-int.h
@@ -245,33 +245,6 @@ extern gint wtap_num_file_types;
}
#endif
-#define wtap_file_read_unknown_bytes(target, num_bytes, fh, err, err_info) \
- G_STMT_START \
- { \
- int _bytes_read; \
- _bytes_read = file_read((target), (num_bytes), (fh)); \
- if (_bytes_read != (int) (num_bytes)) { \
- *(err) = file_error((fh), (err_info)); \
- return FALSE; \
- } \
- } \
- G_STMT_END
-
-#define wtap_file_read_expected_bytes(target, num_bytes, fh, err, err_info) \
- G_STMT_START \
- { \
- int _bytes_read; \
- _bytes_read = file_read((target), (num_bytes), (fh)); \
- if (_bytes_read != (int) (num_bytes)) { \
- *(err) = file_error((fh), (err_info)); \
- if (*(err) == 0 && _bytes_read > 0) { \
- *(err) = WTAP_ERR_SHORT_READ; \
- } \
- return FALSE; \
- } \
- } \
- G_STMT_END
-
/* glib doesn't have g_ptr_array_len of all things!*/
#ifndef g_ptr_array_len
#define g_ptr_array_len(a) ((a)->len)
@@ -281,6 +254,43 @@ extern gint wtap_num_file_types;
GSList *wtap_get_compressed_file_extensions(void);
/*
+ * Read a given number of bytes from a file.
+ *
+ * If we succeed, return TRUE.
+ *
+ * If we get an EOF, return FALSE with *err set to 0, reporting this
+ * as an EOF.
+ *
+ * If we get fewer bytes than the specified number, return FALSE with
+ * *err set to WTAP_ERR_SHORT_READ, reporting this as a short read
+ * error.
+ *
+ * If we get a read error, return FALSE with *err and *err_info set
+ * appropriately.
+ */
+WS_DLL_PUBLIC
+gboolean
+wtap_read_bytes_or_eof(FILE_T fh, void *buf, unsigned int count, int *err,
+ gchar **err_info);
+
+/*
+ * Read a given number of bytes from a file.
+ *
+ * If we succeed, return TRUE.
+ *
+ * If we get fewer bytes than the specified number, including getting
+ * an EOF, return FALSE with *err set to WTAP_ERR_SHORT_READ, reporting
+ * this as a short read error.
+ *
+ * If we get a read error, return FALSE with *err and *err_info set
+ * appropriately.
+ */
+WS_DLL_PUBLIC
+gboolean
+wtap_read_bytes(FILE_T fh, void *buf, unsigned int count, int *err,
+ gchar **err_info);
+
+/*
* Read packet data into a Buffer, growing the buffer as necessary.
*
* This returns an error on a short read, even if the short read hit