summaryrefslogtreecommitdiffstats
path: root/wiretap/mime_file.c
diff options
context:
space:
mode:
Diffstat (limited to 'wiretap/mime_file.c')
-rw-r--r--wiretap/mime_file.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/wiretap/mime_file.c b/wiretap/mime_file.c
index a3cce0d1..c9aca57a 100644
--- a/wiretap/mime_file.c
+++ b/wiretap/mime_file.c
@@ -17,6 +17,7 @@
*/
#include "config.h"
+#include "mime_file.h"
#include <sys/types.h>
@@ -31,11 +32,10 @@
#include "wtap-int.h"
#include "file_wrappers.h"
#include <wsutil/buffer.h>
-#include "mime_file.h"
typedef struct {
- const guint8 *magic;
- guint magic_len;
+ const uint8_t *magic;
+ unsigned magic_len;
} mime_files_t;
/*
@@ -51,31 +51,31 @@ typedef struct {
* https://www.itu.int/rec/T-REC-T.871-201105-I/en
* https://www.w3.org/Graphics/JPEG/jfif3.pdf
*/
-static const guint8 jpeg_jfif_magic[] = { 0xFF, 0xD8, /* SOF */
+static const uint8_t jpeg_jfif_magic[] = { 0xFF, 0xD8, /* SOF */
0xFF /* start of the next marker */
};
/* <?xml */
-static const guint8 xml_magic[] = { '<', '?', 'x', 'm', 'l' };
-static const guint8 png_magic[] = { 0x89, 'P', 'N', 'G', '\r', '\n', 0x1A, '\n' };
-static const guint8 gif87a_magic[] = { 'G', 'I', 'F', '8', '7', 'a'};
-static const guint8 gif89a_magic[] = { 'G', 'I', 'F', '8', '9', 'a'};
-static const guint8 elf_magic[] = { 0x7F, 'E', 'L', 'F'};
-static const guint8 tiff_le_magic[] = { 'I', 'I', 42, 0 };
-static const guint8 tiff_be_magic[] = { 'M', 'M', 0, 42 };
-static const guint8 btsnoop_magic[] = { 'b', 't', 's', 'n', 'o', 'o', 'p', 0};
-static const guint8 pcap_magic[] = { 0xA1, 0xB2, 0xC3, 0xD4 };
-static const guint8 pcap_swapped_magic[] = { 0xD4, 0xC3, 0xB2, 0xA1 };
-static const guint8 pcap_nsec_magic[] = { 0xA1, 0xB2, 0x3C, 0x4D };
-static const guint8 pcap_nsec_swapped_magic[] = { 0x4D, 0x3C, 0xB2, 0xA1 };
-static const guint8 pcapng_premagic[] = { 0x0A, 0x0D, 0x0D, 0x0A };
-static const guint8 blf_magic[] = { 'L', 'O', 'G', 'G' };
-static const guint8 autosar_dlt_magic[] = { 'D', 'L', 'T', 0x01 };
-static const guint8 rtpdump_magic[] = { '#', '!', 'r', 't', 'p', 'p', 'l', 'a', 'y', '1', '.', '0', ' ' };
+static const uint8_t xml_magic[] = { '<', '?', 'x', 'm', 'l' };
+static const uint8_t png_magic[] = { 0x89, 'P', 'N', 'G', '\r', '\n', 0x1A, '\n' };
+static const uint8_t gif87a_magic[] = { 'G', 'I', 'F', '8', '7', 'a'};
+static const uint8_t gif89a_magic[] = { 'G', 'I', 'F', '8', '9', 'a'};
+static const uint8_t elf_magic[] = { 0x7F, 'E', 'L', 'F'};
+static const uint8_t tiff_le_magic[] = { 'I', 'I', 42, 0 };
+static const uint8_t tiff_be_magic[] = { 'M', 'M', 0, 42 };
+static const uint8_t btsnoop_magic[] = { 'b', 't', 's', 'n', 'o', 'o', 'p', 0};
+static const uint8_t pcap_magic[] = { 0xA1, 0xB2, 0xC3, 0xD4 };
+static const uint8_t pcap_swapped_magic[] = { 0xD4, 0xC3, 0xB2, 0xA1 };
+static const uint8_t pcap_nsec_magic[] = { 0xA1, 0xB2, 0x3C, 0x4D };
+static const uint8_t pcap_nsec_swapped_magic[] = { 0x4D, 0x3C, 0xB2, 0xA1 };
+static const uint8_t pcapng_premagic[] = { 0x0A, 0x0D, 0x0D, 0x0A };
+static const uint8_t blf_magic[] = { 'L', 'O', 'G', 'G' };
+static const uint8_t autosar_dlt_magic[] = { 'D', 'L', 'T', 0x01 };
+static const uint8_t rtpdump_magic[] = { '#', '!', 'r', 't', 'p', 'p', 'l', 'a', 'y', '1', '.', '0', ' ' };
/* File does not start with it */
-static const guint8 pcapng_xmagic[] = { 0x1A, 0x2B, 0x3C, 0x4D };
-static const guint8 pcapng_swapped_xmagic[] = { 0x4D, 0x3C, 0x2B, 0x1A };
+static const uint8_t pcapng_xmagic[] = { 0x1A, 0x2B, 0x3C, 0x4D };
+static const uint8_t pcapng_swapped_xmagic[] = { 0x4D, 0x3C, 0x2B, 0x1A };
static const mime_files_t magic_files[] = {
{ jpeg_jfif_magic, sizeof(jpeg_jfif_magic) },
@@ -97,27 +97,27 @@ static const mime_files_t magic_files[] = {
{ rtpdump_magic, sizeof(rtpdump_magic) },
};
-#define N_MAGIC_TYPES (sizeof(magic_files) / sizeof(magic_files[0]))
+#define N_MAGIC_TYPES array_length(magic_files)
static int mime_file_type_subtype = -1;
void register_mime(void);
wtap_open_return_val
-mime_file_open(wtap *wth, int *err, gchar **err_info)
+mime_file_open(wtap *wth, int *err, char **err_info)
{
char magic_buf[128]; /* increase buffer size when needed */
int bytes_read;
- gboolean found_file;
- /* guint file_ok; */
- guint i;
+ bool found_file;
+ /* unsigned file_ok; */
+ unsigned i;
- guint read_bytes = 12;
+ unsigned read_bytes = 12;
for (i = 0; i < N_MAGIC_TYPES; i++)
read_bytes = MAX(read_bytes, magic_files[i].magic_len);
- read_bytes = (guint)MIN(read_bytes, sizeof(magic_buf));
+ read_bytes = (unsigned)MIN(read_bytes, sizeof(magic_buf));
bytes_read = file_read(magic_buf, read_bytes, wth->fh);
if (bytes_read < 0) {
@@ -127,16 +127,16 @@ mime_file_open(wtap *wth, int *err, gchar **err_info)
if (bytes_read == 0)
return WTAP_OPEN_NOT_MINE;
- found_file = FALSE;
+ found_file = false;
for (i = 0; i < N_MAGIC_TYPES; i++) {
- if ((guint) bytes_read >= magic_files[i].magic_len && !memcmp(magic_buf, magic_files[i].magic, MIN(magic_files[i].magic_len, (guint) bytes_read))) {
+ if ((unsigned) bytes_read >= magic_files[i].magic_len && !memcmp(magic_buf, magic_files[i].magic, MIN(magic_files[i].magic_len, (unsigned) bytes_read))) {
if (!found_file) {
if (magic_files[i].magic == pcapng_premagic) {
if (memcmp(magic_buf + 8, pcapng_xmagic, sizeof(pcapng_xmagic)) &&
memcmp(magic_buf + 8, pcapng_swapped_xmagic, sizeof(pcapng_swapped_xmagic)))
continue;
}
- found_file = TRUE;
+ found_file = true;
} else
return WTAP_OPEN_NOT_MINE; /* many files matched, bad file */
}
@@ -169,7 +169,7 @@ static const struct supported_block_type mime_blocks_supported[] = {
static const struct file_type_subtype_info mime_info = {
"MIME File Format", "mime", NULL, NULL,
- FALSE, BLOCKS_SUPPORTED(mime_blocks_supported),
+ false, BLOCKS_SUPPORTED(mime_blocks_supported),
NULL, NULL, NULL
};
@@ -189,7 +189,7 @@ static const struct supported_block_type jpeg_jfif_blocks_supported[] = {
static const struct file_type_subtype_info jpeg_jfif_info = {
"JPEG/JFIF", "jpeg", "jpg", "jpeg;jfif",
- FALSE, BLOCKS_SUPPORTED(jpeg_jfif_blocks_supported),
+ false, BLOCKS_SUPPORTED(jpeg_jfif_blocks_supported),
NULL, NULL, NULL
};