In the final scene of the horror movie, just when you think the monster
[obnox/wireshark/wip.git] / wiretap / file.c
index bf4c4ee31d9d13c0c879929411826e290bf6f71e..c95eee5ceff5efcd70203dd0f2c9bd6bc8d6050a 100644 (file)
@@ -1,6 +1,6 @@
 /* file.c
  *
- * $Id: file.c,v 1.51 2000/05/18 09:09:25 guy Exp $
+ * $Id: file.c,v 1.56 2000/07/26 06:04:32 guy Exp $
  *
  * Wiretap Library
  * Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
@@ -35,7 +35,7 @@
 #include <io.h>        /* open/close on win32 */
 #endif
 
-#include "wtap.h"
+#include "wtap-int.h"
 #include "file_wrappers.h"
 #include "buffer.h"
 #include "lanalyzer.h"
@@ -97,7 +97,7 @@ static int (*open_routines[])(wtap *, int *) = {
 };
 
 int wtap_def_seek_read(wtap *wth, int seek_off,
-       union pseudo_header *pseudo_header, guint8 *pd, int len)
+       union wtap_pseudo_header *pseudo_header, guint8 *pd, int len)
 {
        file_seek(wth->random_fh, seek_off, SEEK_SET);
 
@@ -126,7 +126,10 @@ wtap* wtap_open_offline(const char *filename, int *err, gboolean do_random)
        }
 #ifndef WIN32
        if (! S_ISREG(statb.st_mode) && ! S_ISFIFO(statb.st_mode)) {
-               *err = WTAP_ERR_NOT_REGULAR_FILE;
+               if (S_ISDIR(statb.st_mode))
+                       *err = EISDIR;
+               else
+                       *err = WTAP_ERR_NOT_REGULAR_FILE;
                return NULL;
        }
 #endif
@@ -145,7 +148,8 @@ wtap* wtap_open_offline(const char *filename, int *err, gboolean do_random)
 
        /* Open the file */
        errno = WTAP_ERR_CANT_OPEN;
-       if (!(wth->fd = open(filename, O_RDONLY|O_BINARY))) {
+       wth->fd = open(filename, O_RDONLY|O_BINARY);
+       if (wth->fd < 0) {
                *err = errno;
                g_free(wth);
                return NULL;
@@ -169,6 +173,7 @@ wtap* wtap_open_offline(const char *filename, int *err, gboolean do_random)
        /* initialization */
        wth->file_encap = WTAP_ENCAP_UNKNOWN;
        wth->data_offset = 0;
+       wth->subtype_sequential_close = NULL;
        wth->subtype_close = NULL;
 
        /* Try all file types */
@@ -224,22 +229,30 @@ const static struct file_type_info {
        { "libpcap (tcpdump, Ethereal, etc.)", "libpcap",
          libpcap_dump_can_write_encap, libpcap_dump_open },
 
-       /* WTAP_FILE_PCAP_MODIFIED */
-       { "modified libpcap (tcpdump)", "modlibpcap",
+       /* WTAP_FILE_PCAP_SS990417 */
+       { "Red Hat Linux 6.1 libpcap (tcpdump)", "rh6_1libpcap",
          libpcap_dump_can_write_encap, libpcap_dump_open },
 
-       /* WTAP_FILE_PCAP_RH_6_1 */
-       { "Red Hat Linux 6.1 libpcap (tcpdump)", "rh6_1libpcap",
+       /* WTAP_FILE_PCAP_SS990915 */
+       { "SuSE Linux 6.3 libpcap (tcpdump)", "suse6_3libpcap",
+         libpcap_dump_can_write_encap, libpcap_dump_open },
+
+       /* WTAP_FILE_PCAP_SS991029 */
+       { "modified libpcap (tcpdump)", "modlibpcap",
          libpcap_dump_can_write_encap, libpcap_dump_open },
 
        /* WTAP_FILE_LANALYZER */
        { "Novell LANalyzer", NULL,
          NULL, NULL },
 
-       /* WTAP_FILE_NGSNIFFER */
+       /* WTAP_FILE_NGSNIFFER_UNCOMPRESSED */
        { "Network Associates Sniffer (DOS-based)", "ngsniffer",
          ngsniffer_dump_can_write_encap, ngsniffer_dump_open },
 
+       /* WTAP_FILE_NGSNIFFER_COMPRESSED */
+       { "Network Associates Sniffer (DOS-based), compressed", "ngsniffer_comp",
+         NULL, NULL },
+
        /* WTAP_FILE_SNOOP */
        { "Sun snoop", "snoop",
          snoop_dump_can_write_encap, snoop_dump_open },
@@ -268,8 +281,8 @@ const static struct file_type_info {
        { "Network Associates Sniffer (Windows-based) 1.1", "ngwsniffer_1_1",
          netxray_dump_can_write_encap, netxray_dump_open_1_1 },
 
-       /* WTAP_FILE_NETXRAY_2_001 */
-       { "Network Associates Sniffer (Windows-based) 2.001", NULL,
+       /* WTAP_FILE_NETXRAY_2_00x */
+       { "Network Associates Sniffer (Windows-based) 2.00x", NULL,
          NULL, NULL },
 
        /* WTAP_FILE_RADCOM */
@@ -444,7 +457,7 @@ FILE* wtap_dump_file(wtap_dumper *wdh)
 }
 
 gboolean wtap_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
-    const union pseudo_header *pseudo_header, const u_char *pd, int *err)
+    const union wtap_pseudo_header *pseudo_header, const u_char *pd, int *err)
 {
        return (wdh->subtype_write)(wdh, phdr, pseudo_header, pd, err);
 }