Avoid warnings.
[obnox/wireshark/wip.git] / wiretap / file_access.c
index b975cae0a8218bf56503ce15312975e6cefd3036..5ba7d685e514b27bceadc09cea106e794d991b97 100644 (file)
 #include "netscreen.h"
 #include "commview.h"
 #include "pcapng.h"
+#include "aethra.h"
 #include "btsnoop.h"
 #include "tnef.h"
 #include "dct3trace.h"
 #include "packetlogger.h"
 #include "daintree-sna.h"
 #include "netscaler.h"
-#include "jpeg_jfif.h"
+#include "mime_file.h"
 #include "ipfix.h"
 
 
@@ -126,6 +127,7 @@ static wtap_open_routine_t open_routines_base[] = {
        catapult_dct2000_open,
        ber_open,
        pcapng_open,
+       aethra_open,
        btsnoop_open,
        packetlogger_open, /* This type does not have a magic number, but its
                            * files are sometimes grabbed by mpeg_open. */
@@ -133,7 +135,7 @@ static wtap_open_routine_t open_routines_base[] = {
        tnef_open,
        dct3trace_open,
        daintree_sna_open,
-       jpeg_jfif_open,
+       mime_file_open,
        /* Files that don't have magic bytes at a fixed location,
         * but that instead require a heuristic of some sort to
         * identify them.  This includes the ASCII trace files that
@@ -222,6 +224,7 @@ void wtap_register_open_routine(wtap_open_routine_t open_routine, gboolean has_m
 wtap* wtap_open_offline(const char *filename, int *err, char **err_info,
                        gboolean do_random)
 {
+       int     fd;
        ws_statb64 statb;
        wtap    *wth;
        unsigned int    i;
@@ -293,37 +296,36 @@ wtap* wtap_open_offline(const char *filename, int *err, char **err_info,
        if (use_stdin) {
                /*
                 * We dup FD 0, so that we don't have to worry about
-                * an fclose or gzclose of wth->fh closing the standard
+                * a file_close of wth->fh closing the standard
                 * input of the process.
                 */
-               wth->fd = ws_dup(0);
-               if (wth->fd < 0) {
+               fd = ws_dup(0);
+               if (fd < 0) {
                        *err = errno;
                        g_free(wth);
                        return NULL;
                }
 #ifdef _WIN32
-               if (_setmode(wth->fd, O_BINARY) == -1) {
+               if (_setmode(fd, O_BINARY) == -1) {
                        /* "Shouldn't happen" */
                        *err = errno;
                        g_free(wth);
                        return NULL;
                }
 #endif
+               if (!(wth->fh = filed_open(fd))) {
+                       *err = errno;
+                       ws_close(fd);
+                       g_free(wth);
+                       return NULL;
+               }
        } else {
-               wth->fd = ws_open(filename, O_RDONLY|O_BINARY, 0000 /* no creation so don't matter */);
-               if (wth->fd < 0) {
+               if (!(wth->fh = file_open(filename))) {
                        *err = errno;
                        g_free(wth);
                        return NULL;
                }
        }
-       if (!(wth->fh = filed_open(wth->fd))) {
-               *err = errno;
-               ws_close(wth->fd);
-               g_free(wth);
-               return NULL;
-       }
 
        if (do_random) {
                if (!(wth->random_fh = file_open(filename))) {
@@ -412,6 +414,7 @@ static const struct file_type_info dump_open_table_base[] = {
          NULL, NULL },
 
        /* WTAP_FILE_PCAP */
+        /* Gianluca Varenni suggests that we add "deprecated" to the description. */
        { "Wireshark/tcpdump/... - libpcap", "libpcap", "*.pcap;*.cap", ".pcap", FALSE, FALSE,
          libpcap_dump_can_write_encap, libpcap_dump_open },
 
@@ -485,7 +488,7 @@ static const struct file_type_info dump_open_table_base[] = {
 
        /* WTAP_FILE_ERF */
        { "Endace ERF capture", "erf", "*.erf", ".erf", FALSE, FALSE,
-         NULL, NULL },
+         erf_dump_can_write_encap, erf_dump_open },
 
        /* WTAP_FILE_EYESDN */
        { "EyeSDN USB S0/E1 ISDN trace format", "eyesdn", "*.trc", ".trc", FALSE, FALSE,
@@ -535,8 +538,8 @@ static const struct file_type_info dump_open_table_base[] = {
        { "NA Sniffer (Windows) 2.00x", "ngwsniffer_2_0", "*.cap", ".cap", TRUE, FALSE,
          netxray_dump_can_write_encap_2_0, netxray_dump_open_2_0 },
 
-       /* WTAP_FILE_NETWORK_INSTRUMENTS_V9 */
-       { "Network Instruments Observer (V9)", "niobserverv9", "*.bfr", ".bfr", FALSE, FALSE,
+       /* WTAP_FILE_NETWORK_INSTRUMENTS */
+       { "Network Instruments Observer", "niobserver", "*.bfr", ".bfr", FALSE, FALSE,
          network_instruments_dump_can_write_encap, network_instruments_dump_open },
 
        /* WTAP_FILE_LANALYZER */
@@ -645,7 +648,15 @@ static const struct file_type_info dump_open_table_base[] = {
 
        /* WTAP_FILE_IPFIX */
        { "IPFIX File Format", "ipfix", "*.pfx;*.ipfix", NULL, FALSE, FALSE,
-         NULL, NULL }
+         NULL, NULL },
+
+       /* WTAP_ENCAP_MIME */
+       { "MIME File Format", "mime", NULL, NULL, FALSE, FALSE,
+          NULL, NULL },
+
+       /* WTAP_FILE_AETHRA */
+       { "Aethra .aps file", "aethra", "*.aps", NULL, FALSE, FALSE,
+         NULL, NULL },
 };
 
 gint wtap_num_file_types = sizeof(dump_open_table_base) / sizeof(struct file_type_info);
@@ -976,7 +987,7 @@ static gboolean wtap_dump_open_finish(wtap_dumper *wdh, int filetype, gboolean c
 }
 
 gboolean wtap_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
-                  const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err)
+                  const union wtap_pseudo_header *pseudo_header, const guint8 *pd, int *err)
 {
        return (wdh->subtype_write)(wdh, phdr, pseudo_header, pd, err);
 }