Revert "Allow wtap_read() and wtap_seek_read() to return non-packet records."
authorGuy Harris <guy@alum.mit.edu>
Fri, 23 May 2014 10:50:02 +0000 (10:50 +0000)
committerGuy Harris <guy@alum.mit.edu>
Fri, 23 May 2014 10:50:10 +0000 (10:50 +0000)
This reverts commit c0c480d08c175eed4524ea9e73ec86298f468cf4.

A better way to do this is to have the record type be part of struct wtap_pkthdr; that keeps the metadata for the record together and requires fewer API changes.  That is in-progress.

Change-Id: Ic558f163a48e2c6d0df7f55e81a35a5e24b53bc6
Reviewed-on: https://code.wireshark.org/review/1741
Reviewed-by: Guy Harris <guy@alum.mit.edu>
78 files changed:
capinfos.c
capture.c
capture_info.c
capture_info.h
capture_sync.c
capture_sync.h
editcap.c
file.c
file.h
frame_tvbuff.c
proto_hier_stats.c
reordercap.c
tfshark.c
tshark.c
ui/gtk/capture_file_dlg.c
ui/gtk/iax2_analysis.c
ui/gtk/main.c
ui/gtk/packet_list_store.c
ui/gtk/packet_win.c
ui/gtk/rlc_lte_graph.c
ui/gtk/rtp_analysis.c
ui/gtk/sctp_assoc_analyse.c
ui/qt/capture_file_dialog.cpp
ui/qt/packet_list.cpp
ui/qt/packet_list_model.cpp
ui/tap-tcp-stream.c
ui/win32/file_dlg_win32.c
wiretap/5views.c
wiretap/aethra.c
wiretap/ascendtext.c
wiretap/ber.c
wiretap/btsnoop.c
wiretap/camins.c
wiretap/catapult_dct2000.c
wiretap/commview.c
wiretap/cosine.c
wiretap/csids.c
wiretap/daintree-sna.c
wiretap/dbs-etherwatch.c
wiretap/dct3trace.c
wiretap/erf.c
wiretap/eyesdn.c
wiretap/hcidump.c
wiretap/i4btrace.c
wiretap/ipfix.c
wiretap/iptrace.c
wiretap/iseries.c
wiretap/k12.c
wiretap/k12text.l
wiretap/lanalyzer.c
wiretap/libpcap.c
wiretap/logcat.c
wiretap/mime_file.c
wiretap/mp2t.c
wiretap/mpeg.c
wiretap/netmon.c
wiretap/netscaler.c
wiretap/netscreen.c
wiretap/nettl.c
wiretap/network_instruments.c
wiretap/netxray.c
wiretap/ngsniffer.c
wiretap/packetlogger.c
wiretap/pcapng.c
wiretap/peekclassic.c
wiretap/peektagged.c
wiretap/pppdump.c
wiretap/radcom.c
wiretap/snoop.c
wiretap/stanag4607.c
wiretap/tnef.c
wiretap/toshiba.c
wiretap/visual.c
wiretap/vms.c
wiretap/vwr.c
wiretap/wtap-int.h
wiretap/wtap.c
wiretap/wtap.h

index a24a6ae5a203910c5fc140a9a02fcd75cf83fad2..bad557e2ddad8cc001d9cf864e96ec933ef08bfa 100644 (file)
@@ -803,7 +803,6 @@ static int
 process_cap_file(wtap *wth, const char *filename)
 {
   int                   status = 0;
-  int                   rec_type;
   int                   err;
   gchar                *err_info;
   gint64                size;
@@ -829,53 +828,51 @@ process_cap_file(wtap *wth, const char *filename)
   cf_info.encap_counts = g_new0(int,WTAP_NUM_ENCAP_TYPES);
 
   /* Tally up data that we need to parse through the file to find */
-  while ((rec_type = wtap_read(wth, &err, &err_info, &data_offset)) != -1)  {
-    if (rec_type == REC_TYPE_PACKET) {
-      phdr = wtap_phdr(wth);
-      if (phdr->presence_flags & WTAP_HAS_TS) {
-        prev_time = cur_time;
-        cur_time = nstime_to_sec(&phdr->ts);
-        if (packet == 0) {
-          start_time = cur_time;
-          stop_time  = cur_time;
-          prev_time  = cur_time;
-        }
-        if (cur_time < prev_time) {
-          order = NOT_IN_ORDER;
-        }
-        if (cur_time < start_time) {
-          start_time = cur_time;
-        }
-        if (cur_time > stop_time) {
-          stop_time = cur_time;
-        }
-      } else {
-        have_times = FALSE; /* at least one packet has no time stamp */
-        if (order != NOT_IN_ORDER)
-          order = ORDER_UNKNOWN;
+  while (wtap_read(wth, &err, &err_info, &data_offset))  {
+    phdr = wtap_phdr(wth);
+    if (phdr->presence_flags & WTAP_HAS_TS) {
+      prev_time = cur_time;
+      cur_time = nstime_to_sec(&phdr->ts);
+      if (packet == 0) {
+        start_time = cur_time;
+        stop_time  = cur_time;
+        prev_time  = cur_time;
       }
-
-      bytes+=phdr->len;
-      packet++;
-
-      /* If caplen < len for a rcd, then presumably           */
-      /* 'Limit packet capture length' was done for this rcd. */
-      /* Keep track as to the min/max actual snapshot lengths */
-      /*  seen for this file.                                 */
-      if (phdr->caplen < phdr->len) {
-        if (phdr->caplen < snaplen_min_inferred)
-          snaplen_min_inferred = phdr->caplen;
-        if (phdr->caplen > snaplen_max_inferred)
-          snaplen_max_inferred = phdr->caplen;
+      if (cur_time < prev_time) {
+        order = NOT_IN_ORDER;
+      }
+      if (cur_time < start_time) {
+        start_time = cur_time;
       }
+      if (cur_time > stop_time) {
+        stop_time = cur_time;
+      }
+    } else {
+      have_times = FALSE; /* at least one packet has no time stamp */
+      if (order != NOT_IN_ORDER)
+        order = ORDER_UNKNOWN;
+    }
 
-      /* Per-packet encapsulation */
-      if (wtap_file_encap(wth) == WTAP_ENCAP_PER_PACKET) {
-        if ((phdr->pkt_encap > 0) && (phdr->pkt_encap < WTAP_NUM_ENCAP_TYPES)) {
-          cf_info.encap_counts[phdr->pkt_encap] += 1;
-        } else {
-          fprintf(stderr, "capinfos: Unknown per-packet encapsulation: %d [frame number: %d]\n", phdr->pkt_encap, packet);
-        }
+    bytes+=phdr->len;
+    packet++;
+
+    /* If caplen < len for a rcd, then presumably           */
+    /* 'Limit packet capture length' was done for this rcd. */
+    /* Keep track as to the min/max actual snapshot lengths */
+    /*  seen for this file.                                 */
+    if (phdr->caplen < phdr->len) {
+      if (phdr->caplen < snaplen_min_inferred)
+        snaplen_min_inferred = phdr->caplen;
+      if (phdr->caplen > snaplen_max_inferred)
+        snaplen_max_inferred = phdr->caplen;
+    }
+
+    /* Per-packet encapsulation */
+    if (wtap_file_encap(wth) == WTAP_ENCAP_PER_PACKET) {
+      if ((phdr->pkt_encap > 0) && (phdr->pkt_encap < WTAP_NUM_ENCAP_TYPES)) {
+        cf_info.encap_counts[phdr->pkt_encap] += 1;
+      } else {
+        fprintf(stderr, "capinfos: Unknown per-packet encapsulation: %d [frame number: %d]\n", phdr->pkt_encap, packet);
       }
     }
 
index c7f9ebf99505fb1d4a4285989b7ea293c23b3412..c308727096c309d9603e90e586be0586918263d8 100644 (file)
--- a/capture.c
+++ b/capture.c
@@ -390,9 +390,9 @@ capture_input_new_file(capture_session *cap_session, gchar *new_file)
 }
 
 
-/* capture child tells us we have new records to read */
+/* capture child tells us we have new packets to read */
 void
-capture_input_new_records(capture_session *cap_session, int to_read)
+capture_input_new_packets(capture_session *cap_session, int to_read)
 {
   capture_options *capture_opts = cap_session->capture_opts;
   int  err;
@@ -435,7 +435,7 @@ capture_input_new_records(capture_session *cap_session, int to_read)
 #endif
 
   if(capture_opts->show_info)
-    capture_info_new_records(to_read);
+    capture_info_new_packets(to_read);
 }
 
 
index c3c232816c27d9ccaed1f645c5bc14fda2417d67..3ef12df504da1434b085c0c260045a5996d48e40 100644 (file)
@@ -232,11 +232,9 @@ gboolean capture_info_new_file(const char *new_filename)
 }
 
 
-/* new records arrived */
-void capture_info_new_records(int to_read)
+/* new packets arrived */
+void capture_info_new_packets(int to_read)
 {
-    int rec_type;
-    int packets_read = 0;
     int err;
     gchar *err_info;
     gint64 data_offset;
@@ -246,27 +244,25 @@ void capture_info_new_records(int to_read)
     const guchar *buf;
 
 
+    info_data.ui.new_packets = to_read;
+
     /*g_warning("new packets: %u", to_read);*/
 
     while (to_read > 0) {
         wtap_cleareof(info_data.wtap);
-        if ((rec_type = wtap_read(info_data.wtap, &err, &err_info, &data_offset)) != -1) {
-            if (rec_type == REC_TYPE_PACKET) {
-                phdr = wtap_phdr(info_data.wtap);
-                pseudo_header = &phdr->pseudo_header;
-                wtap_linktype = phdr->pkt_encap;
-                buf = wtap_buf_ptr(info_data.wtap);
+        if (wtap_read(info_data.wtap, &err, &err_info, &data_offset)) {
+            phdr = wtap_phdr(info_data.wtap);
+            pseudo_header = &phdr->pseudo_header;
+            wtap_linktype = phdr->pkt_encap;
+            buf = wtap_buf_ptr(info_data.wtap);
 
-                capture_info_packet(&info_data.counts, wtap_linktype, buf, phdr->caplen, pseudo_header);
-                packets_read++;
+            capture_info_packet(&info_data.counts, wtap_linktype, buf, phdr->caplen, pseudo_header);
 
-                /*g_warning("new packet");*/
-            }
+            /*g_warning("new packet");*/
             to_read--;
         }
     }
 
-    info_data.ui.new_packets = packets_read;
     capture_info_ui_update(&info_data.ui);
 }
 
index 286dce12c09b36cbf996eff67b7445e467f87787..3e5845ac6cf9a6f54f9434799517f9847bd544d2 100644 (file)
@@ -43,8 +43,8 @@ extern void capture_info_open(capture_session *cap_session);
 /* new file arrived - (eventually close old wtap), open wtap */
 extern gboolean capture_info_new_file(const char *new_filename);
 
-/* new records arrived - read from wtap, count */
-extern void capture_info_new_records(int to_read);
+/* new packets arrived - read from wtap, count */
+extern void capture_info_new_packets(int to_read);
 
 /* close the info - close wtap, destroy dialog */
 extern void capture_info_close(void);
index 0b374e877c296633657fa647434dc2f88ca24472..2f9d2cc62ef37e706a69407b914e820946d99a03 100644 (file)
@@ -1776,7 +1776,7 @@ sync_pipe_input_cb(gint source, gpointer user_data)
     case SP_PACKET_COUNT:
         npackets = atoi(buffer);
         g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "sync_pipe_input_cb: new packets %u", npackets);
-        capture_input_new_records(cap_session, npackets);
+        capture_input_new_packets(cap_session, npackets);
         break;
     case SP_ERROR_MSG:
         /* convert primary message */
index 27326905730ab819dd9919bce5f1702021dd5643..2c4bb639af5bd1dfd5579b34bff42058de1a999b 100644 (file)
@@ -99,10 +99,10 @@ extern gboolean
 capture_input_new_file(capture_session *cap_session, gchar *new_file);
 
 /**
- * Capture child told us we have new records to read.
+ * Capture child told us we have new packets to read.
  */
 extern void
-capture_input_new_records(capture_session *cap_session, int to_read);
+capture_input_new_packets(capture_session *cap_session, int to_read);
 
 /**
  * Capture child told us how many dropped packets it counted.
index 415e2e481e453115a445e5e417f9a504cc3a5429..70dfd0859a73aaa4c7c5d6085c18c59416915b87 100644 (file)
--- a/editcap.c
+++ b/editcap.c
@@ -842,7 +842,7 @@ main(int argc, char *argv[])
     int           i, j, err;
     gchar        *err_info;
     int           opt;
-    int           rec_type;
+
     char         *p;
     guint32       snaplen            = 0; /* No limit               */
     chop_t        chop               = {0, 0, 0, 0, 0, 0}; /* No chop */
@@ -1192,30 +1192,60 @@ main(int argc, char *argv[])
             }
         }
 
-        while ((rec_type = wtap_read(wth, &err, &err_info, &data_offset)) != -1) {
-            if (rec_type == REC_TYPE_PACKET) {
-                read_count++;
+        while (wtap_read(wth, &err, &err_info, &data_offset)) {
+            read_count++;
 
-                phdr = wtap_phdr(wth);
-                buf = wtap_buf_ptr(wth);
+            phdr = wtap_phdr(wth);
+            buf = wtap_buf_ptr(wth);
 
-                if (nstime_is_unset(&block_start)) {  /* should only be the first packet */
-                    block_start.secs = phdr->ts.secs;
-                    block_start.nsecs = phdr->ts.nsecs;
+            if (nstime_is_unset(&block_start)) {  /* should only be the first packet */
+                block_start.secs = phdr->ts.secs;
+                block_start.nsecs = phdr->ts.nsecs;
 
-                    if (split_packet_count > 0 || secs_per_block > 0) {
-                        if (!fileset_extract_prefix_suffix(argv[optind+1], &fprefix, &fsuffix))
-                            exit(2);
+                if (split_packet_count > 0 || secs_per_block > 0) {
+                    if (!fileset_extract_prefix_suffix(argv[optind+1], &fprefix, &fsuffix))
+                        exit(2);
 
-                        filename = fileset_get_filename_by_pattern(block_cnt++, &phdr->ts, fprefix, fsuffix);
-                    } else {
-                        filename = g_strdup(argv[optind+1]);
-                    }
+                    filename = fileset_get_filename_by_pattern(block_cnt++, &phdr->ts, fprefix, fsuffix);
+                } else {
+                    filename = g_strdup(argv[optind+1]);
+                }
+
+                /* If we don't have an application name add Editcap */
+                if (shb_hdr->shb_user_appl == NULL) {
+                    shb_hdr->shb_user_appl = "Editcap " VERSION;
+                }
 
-                    /* If we don't have an application name add Editcap */
-                    if (shb_hdr->shb_user_appl == NULL) {
-                        shb_hdr->shb_user_appl = "Editcap " VERSION;
+                pdh = wtap_dump_open_ng(filename, out_file_type_subtype, out_frame_type,
+                                        snaplen ? MIN(snaplen, wtap_snapshot_length(wth)) : wtap_snapshot_length(wth),
+                                        FALSE /* compressed */, shb_hdr, idb_inf, &err);
+
+                if (pdh == NULL) {
+                    fprintf(stderr, "editcap: Can't open or create %s: %s\n",
+                            filename, wtap_strerror(err));
+                    exit(2);
+                }
+            }
+
+            g_assert(filename);
+
+            if (secs_per_block > 0) {
+                while ((phdr->ts.secs - block_start.secs >  secs_per_block)
+                       || (phdr->ts.secs - block_start.secs == secs_per_block
+                           && phdr->ts.nsecs >= block_start.nsecs )) { /* time for the next file */
+
+                    if (!wtap_dump_close(pdh, &err)) {
+                        fprintf(stderr, "editcap: Error writing to %s: %s\n",
+                                filename, wtap_strerror(err));
+                        exit(2);
                     }
+                    block_start.secs = block_start.secs +  secs_per_block; /* reset for next interval */
+                    g_free(filename);
+                    filename = fileset_get_filename_by_pattern(block_cnt++, &phdr->ts, fprefix, fsuffix);
+                    g_assert(filename);
+
+                    if (verbose)
+                        fprintf(stderr, "Continuing writing in file %s\n", filename);
 
                     pdh = wtap_dump_open_ng(filename, out_file_type_subtype, out_frame_type,
                                             snaplen ? MIN(snaplen, wtap_snapshot_length(wth)) : wtap_snapshot_length(wth),
@@ -1227,138 +1257,89 @@ main(int argc, char *argv[])
                         exit(2);
                     }
                 }
+            }
 
-                g_assert(filename);
-
-                if (secs_per_block > 0) {
-                    while ((phdr->ts.secs - block_start.secs >  secs_per_block)
-                           || (phdr->ts.secs - block_start.secs == secs_per_block
-                               && phdr->ts.nsecs >= block_start.nsecs )) { /* time for the next file */
-
-                        if (!wtap_dump_close(pdh, &err)) {
-                            fprintf(stderr, "editcap: Error writing to %s: %s\n",
-                                    filename, wtap_strerror(err));
-                            exit(2);
-                        }
-                        block_start.secs = block_start.secs +  secs_per_block; /* reset for next interval */
-                        g_free(filename);
-                        filename = fileset_get_filename_by_pattern(block_cnt++, &phdr->ts, fprefix, fsuffix);
-                        g_assert(filename);
-
-                        if (verbose)
-                            fprintf(stderr, "Continuing writing in file %s\n", filename);
-
-                        pdh = wtap_dump_open_ng(filename, out_file_type_subtype, out_frame_type,
-                                                snaplen ? MIN(snaplen, wtap_snapshot_length(wth)) : wtap_snapshot_length(wth),
-                                                FALSE /* compressed */, shb_hdr, idb_inf, &err);
-
-                        if (pdh == NULL) {
-                            fprintf(stderr, "editcap: Can't open or create %s: %s\n",
-                                    filename, wtap_strerror(err));
-                            exit(2);
-                        }
+            if (split_packet_count > 0) {
+                /* time for the next file? */
+                if (written_count > 0 && written_count % split_packet_count == 0) {
+                    if (!wtap_dump_close(pdh, &err)) {
+                        fprintf(stderr, "editcap: Error writing to %s: %s\n",
+                                filename, wtap_strerror(err));
+                        exit(2);
                     }
-                }
-
-                if (split_packet_count > 0) {
-                    /* time for the next file? */
-                    if (written_count > 0 && written_count % split_packet_count == 0) {
-                        if (!wtap_dump_close(pdh, &err)) {
-                            fprintf(stderr, "editcap: Error writing to %s: %s\n",
-                                    filename, wtap_strerror(err));
-                            exit(2);
-                        }
 
-                        g_free(filename);
-                        filename = fileset_get_filename_by_pattern(block_cnt++, &phdr->ts, fprefix, fsuffix);
-                        g_assert(filename);
+                    g_free(filename);
+                    filename = fileset_get_filename_by_pattern(block_cnt++, &phdr->ts, fprefix, fsuffix);
+                    g_assert(filename);
 
-                        if (verbose)
-                            fprintf(stderr, "Continuing writing in file %s\n", filename);
+                    if (verbose)
+                        fprintf(stderr, "Continuing writing in file %s\n", filename);
 
-                        pdh = wtap_dump_open_ng(filename, out_file_type_subtype, out_frame_type,
-                                                snaplen ? MIN(snaplen, wtap_snapshot_length(wth)) : wtap_snapshot_length(wth),
-                                                FALSE /* compressed */, shb_hdr, idb_inf, &err);
-                        if (pdh == NULL) {
-                            fprintf(stderr, "editcap: Can't open or create %s: %s\n",
-                                    filename, wtap_strerror(err));
-                            exit(2);
-                        }
+                    pdh = wtap_dump_open_ng(filename, out_file_type_subtype, out_frame_type,
+                                            snaplen ? MIN(snaplen, wtap_snapshot_length(wth)) : wtap_snapshot_length(wth),
+                                            FALSE /* compressed */, shb_hdr, idb_inf, &err);
+                    if (pdh == NULL) {
+                        fprintf(stderr, "editcap: Can't open or create %s: %s\n",
+                                filename, wtap_strerror(err));
+                        exit(2);
                     }
                 }
+            }
 
-                if (check_startstop)
-                    ts_okay = check_timestamp(wth);
+            if (check_startstop)
+                ts_okay = check_timestamp(wth);
 
-                if (ts_okay && ((!selected(count) && !keep_em)
-                                || (selected(count) && keep_em))) {
+            if (ts_okay && ((!selected(count) && !keep_em)
+                            || (selected(count) && keep_em))) {
 
-                    if (verbose && !dup_detect && !dup_detect_by_time)
-                        fprintf(stderr, "Packet: %u\n", count);
+                if (verbose && !dup_detect && !dup_detect_by_time)
+                    fprintf(stderr, "Packet: %u\n", count);
 
-                    /* We simply write it, perhaps after truncating it; we could
-                     * do other things, like modify it. */
+                /* We simply write it, perhaps after truncating it; we could
+                 * do other things, like modify it. */
 
-                    phdr = wtap_phdr(wth);
+                phdr = wtap_phdr(wth);
 
-                    if (snaplen != 0) {
-                        if (phdr->caplen > snaplen) {
-                            snap_phdr = *phdr;
-                            snap_phdr.caplen = snaplen;
-                            phdr = &snap_phdr;
-                        }
-                        if (adjlen && phdr->len > snaplen) {
-                            snap_phdr = *phdr;
-                            snap_phdr.len = snaplen;
-                            phdr = &snap_phdr;
-                        }
+                if (snaplen != 0) {
+                    if (phdr->caplen > snaplen) {
+                        snap_phdr = *phdr;
+                        snap_phdr.caplen = snaplen;
+                        phdr = &snap_phdr;
                     }
+                    if (adjlen && phdr->len > snaplen) {
+                        snap_phdr = *phdr;
+                        snap_phdr.len = snaplen;
+                        phdr = &snap_phdr;
+                    }
+                }
 
-                    /* CHOP */
-                    snap_phdr = *phdr;
-                    handle_chopping(chop, &snap_phdr, phdr, &buf, adjlen);
-                    phdr = &snap_phdr;
+                /* CHOP */
+                snap_phdr = *phdr;
+                handle_chopping(chop, &snap_phdr, phdr, &buf, adjlen);
+                phdr = &snap_phdr;
 
-                    /* Do we adjust timestamps to ensure strict chronological
-                     * order? */
-                    if (do_strict_time_adjustment) {
-                        if (previous_time.secs || previous_time.nsecs) {
-                            if (!strict_time_adj.is_negative) {
-                                nstime_t current;
-                                nstime_t delta;
-
-                                current.secs = phdr->ts.secs;
-                                current.nsecs = phdr->ts.nsecs;
-
-                                nstime_delta(&delta, &current, &previous_time);
-
-                                if (delta.secs < 0 || delta.nsecs < 0) {
-                                    /*
-                                     * A negative delta indicates that the current packet
-                                     * has an absolute timestamp less than the previous packet
-                                     * that it is being compared to.  This is NOT a normal
-                                     * situation since trace files usually have packets in
-                                     * chronological order (oldest to newest).
-                                     */
-                                    /* fprintf(stderr, "++out of order, need to adjust this packet!\n"); */
-                                    snap_phdr = *phdr;
-                                    snap_phdr.ts.secs = previous_time.secs + strict_time_adj.tv.tv_sec;
-                                    snap_phdr.ts.nsecs = previous_time.nsecs;
-                                    if (snap_phdr.ts.nsecs + strict_time_adj.tv.tv_usec * 1000 > ONE_MILLION * 1000) {
-                                        /* carry */
-                                        snap_phdr.ts.secs++;
-                                        snap_phdr.ts.nsecs += (strict_time_adj.tv.tv_usec - ONE_MILLION) * 1000;
-                                    } else {
-                                        snap_phdr.ts.nsecs += strict_time_adj.tv.tv_usec * 1000;
-                                    }
-                                    phdr = &snap_phdr;
-                                }
-                            } else {
+                /* Do we adjust timestamps to ensure strict chronological
+                 * order? */
+                if (do_strict_time_adjustment) {
+                    if (previous_time.secs || previous_time.nsecs) {
+                        if (!strict_time_adj.is_negative) {
+                            nstime_t current;
+                            nstime_t delta;
+
+                            current.secs = phdr->ts.secs;
+                            current.nsecs = phdr->ts.nsecs;
+
+                            nstime_delta(&delta, &current, &previous_time);
+
+                            if (delta.secs < 0 || delta.nsecs < 0) {
                                 /*
-                                 * A negative strict time adjustment is requested.
-                                 * Unconditionally set each timestamp to previous
-                                 * packet's timestamp plus delta.
+                                 * A negative delta indicates that the current packet
+                                 * has an absolute timestamp less than the previous packet
+                                 * that it is being compared to.  This is NOT a normal
+                                 * situation since trace files usually have packets in
+                                 * chronological order (oldest to newest).
                                  */
+                                /* fprintf(stderr, "++out of order, need to adjust this packet!\n"); */
                                 snap_phdr = *phdr;
                                 snap_phdr.ts.secs = previous_time.secs + strict_time_adj.tv.tv_sec;
                                 snap_phdr.ts.nsecs = previous_time.nsecs;
@@ -1371,190 +1352,207 @@ main(int argc, char *argv[])
                                 }
                                 phdr = &snap_phdr;
                             }
-                        }
-                        previous_time.secs = phdr->ts.secs;
-                        previous_time.nsecs = phdr->ts.nsecs;
-                    }
-
-                    /* assume that if the frame's tv_sec is 0, then
-                     * the timestamp isn't supported */
-                    if (phdr->ts.secs > 0 && time_adj.tv.tv_sec != 0) {
-                        snap_phdr = *phdr;
-                        if (time_adj.is_negative)
-                            snap_phdr.ts.secs -= time_adj.tv.tv_sec;
-                        else
-                            snap_phdr.ts.secs += time_adj.tv.tv_sec;
-                         phdr = &snap_phdr;
-                    }
-
-                    /* assume that if the frame's tv_sec is 0, then
-                     * the timestamp isn't supported */
-                    if (phdr->ts.secs > 0 && time_adj.tv.tv_usec != 0) {
-                        snap_phdr = *phdr;
-                        if (time_adj.is_negative) { /* subtract */
-                            if (snap_phdr.ts.nsecs/1000 < time_adj.tv.tv_usec) { /* borrow */
-                                snap_phdr.ts.secs--;
-                                snap_phdr.ts.nsecs += ONE_MILLION * 1000;
-                            }
-                            snap_phdr.ts.nsecs -= time_adj.tv.tv_usec * 1000;
-                        } else {                  /* add */
-                            if (snap_phdr.ts.nsecs + time_adj.tv.tv_usec * 1000 > ONE_MILLION * 1000) {
+                        } else {
+                            /*
+                             * A negative strict time adjustment is requested.
+                             * Unconditionally set each timestamp to previous
+                             * packet's timestamp plus delta.
+                             */
+                            snap_phdr = *phdr;
+                            snap_phdr.ts.secs = previous_time.secs + strict_time_adj.tv.tv_sec;
+                            snap_phdr.ts.nsecs = previous_time.nsecs;
+                            if (snap_phdr.ts.nsecs + strict_time_adj.tv.tv_usec * 1000 > ONE_MILLION * 1000) {
                                 /* carry */
                                 snap_phdr.ts.secs++;
-                                snap_phdr.ts.nsecs += (time_adj.tv.tv_usec - ONE_MILLION) * 1000;
+                                snap_phdr.ts.nsecs += (strict_time_adj.tv.tv_usec - ONE_MILLION) * 1000;
                             } else {
-                                snap_phdr.ts.nsecs += time_adj.tv.tv_usec * 1000;
+                                snap_phdr.ts.nsecs += strict_time_adj.tv.tv_usec * 1000;
                             }
+                            phdr = &snap_phdr;
                         }
-                        phdr = &snap_phdr;
                     }
+                    previous_time.secs = phdr->ts.secs;
+                    previous_time.nsecs = phdr->ts.nsecs;
+                }
 
-                    /* suppress duplicates by packet window */
-                    if (dup_detect) {
-                        if (is_duplicate(buf, phdr->caplen)) {
-                            if (verbose) {
-                                fprintf(stderr, "Skipped: %u, Len: %u, MD5 Hash: ",
-                                        count, phdr->caplen);
-                                for (i = 0; i < 16; i++)
-                                    fprintf(stderr, "%02x",
-                                            (unsigned char)fd_hash[cur_dup_entry].digest[i]);
-                                fprintf(stderr, "\n");
-                            }
-                            duplicate_count++;
-                            count++;
-                            continue;
+                /* assume that if the frame's tv_sec is 0, then
+                 * the timestamp isn't supported */
+                if (phdr->ts.secs > 0 && time_adj.tv.tv_sec != 0) {
+                    snap_phdr = *phdr;
+                    if (time_adj.is_negative)
+                        snap_phdr.ts.secs -= time_adj.tv.tv_sec;
+                    else
+                        snap_phdr.ts.secs += time_adj.tv.tv_sec;
+                    phdr = &snap_phdr;
+                }
+
+                /* assume that if the frame's tv_sec is 0, then
+                 * the timestamp isn't supported */
+                if (phdr->ts.secs > 0 && time_adj.tv.tv_usec != 0) {
+                    snap_phdr = *phdr;
+                    if (time_adj.is_negative) { /* subtract */
+                        if (snap_phdr.ts.nsecs/1000 < time_adj.tv.tv_usec) { /* borrow */
+                            snap_phdr.ts.secs--;
+                            snap_phdr.ts.nsecs += ONE_MILLION * 1000;
+                        }
+                        snap_phdr.ts.nsecs -= time_adj.tv.tv_usec * 1000;
+                    } else {                  /* add */
+                        if (snap_phdr.ts.nsecs + time_adj.tv.tv_usec * 1000 > ONE_MILLION * 1000) {
+                            /* carry */
+                            snap_phdr.ts.secs++;
+                            snap_phdr.ts.nsecs += (time_adj.tv.tv_usec - ONE_MILLION) * 1000;
                         } else {
-                            if (verbose) {
-                                fprintf(stderr, "Packet: %u, Len: %u, MD5 Hash: ",
-                                        count, phdr->caplen);
-                                for (i = 0; i < 16; i++)
-                                    fprintf(stderr, "%02x",
-                                            (unsigned char)fd_hash[cur_dup_entry].digest[i]);
-                                fprintf(stderr, "\n");
-                            }
+                            snap_phdr.ts.nsecs += time_adj.tv.tv_usec * 1000;
                         }
                     }
+                    phdr = &snap_phdr;
+                }
 
-                    /* suppress duplicates by time window */
-                    if (dup_detect_by_time) {
-                        nstime_t current;
-
-                        current.secs  = phdr->ts.secs;
-                        current.nsecs = phdr->ts.nsecs;
-
-                        if (is_duplicate_rel_time(buf, phdr->caplen, &current)) {
-                            if (verbose) {
-                                fprintf(stderr, "Skipped: %u, Len: %u, MD5 Hash: ",
-                                        count, phdr->caplen);
-                                for (i = 0; i < 16; i++)
-                                    fprintf(stderr, "%02x",
-                                            (unsigned char)fd_hash[cur_dup_entry].digest[i]);
-                                fprintf(stderr, "\n");
-                            }
-                            duplicate_count++;
-                            count++;
-                            continue;
-                        } else {
-                            if (verbose) {
-                                fprintf(stderr, "Packet: %u, Len: %u, MD5 Hash: ",
-                                        count, phdr->caplen);
-                                for (i = 0; i < 16; i++)
-                                    fprintf(stderr, "%02x",
-                                            (unsigned char)fd_hash[cur_dup_entry].digest[i]);
-                                fprintf(stderr, "\n");
-                            }
+                /* suppress duplicates by packet window */
+                if (dup_detect) {
+                    if (is_duplicate(buf, phdr->caplen)) {
+                        if (verbose) {
+                            fprintf(stderr, "Skipped: %u, Len: %u, MD5 Hash: ",
+                                    count, phdr->caplen);
+                            for (i = 0; i < 16; i++)
+                                fprintf(stderr, "%02x",
+                                        (unsigned char)fd_hash[cur_dup_entry].digest[i]);
+                            fprintf(stderr, "\n");
+                        }
+                        duplicate_count++;
+                        count++;
+                        continue;
+                    } else {
+                        if (verbose) {
+                            fprintf(stderr, "Packet: %u, Len: %u, MD5 Hash: ",
+                                    count, phdr->caplen);
+                            for (i = 0; i < 16; i++)
+                                fprintf(stderr, "%02x",
+                                        (unsigned char)fd_hash[cur_dup_entry].digest[i]);
+                            fprintf(stderr, "\n");
                         }
                     }
+                }
 
-                    /* Random error mutation */
-                    if (err_prob > 0.0) {
-                        int real_data_start = 0;
+                /* suppress duplicates by time window */
+                if (dup_detect_by_time) {
+                    nstime_t current;
+
+                    current.secs  = phdr->ts.secs;
+                    current.nsecs = phdr->ts.nsecs;
+
+                    if (is_duplicate_rel_time(buf, phdr->caplen, &current)) {
+                        if (verbose) {
+                            fprintf(stderr, "Skipped: %u, Len: %u, MD5 Hash: ",
+                                    count, phdr->caplen);
+                            for (i = 0; i < 16; i++)
+                                fprintf(stderr, "%02x",
+                                        (unsigned char)fd_hash[cur_dup_entry].digest[i]);
+                            fprintf(stderr, "\n");
+                        }
+                        duplicate_count++;
+                        count++;
+                        continue;
+                    } else {
+                        if (verbose) {
+                            fprintf(stderr, "Packet: %u, Len: %u, MD5 Hash: ",
+                                    count, phdr->caplen);
+                            for (i = 0; i < 16; i++)
+                                fprintf(stderr, "%02x",
+                                        (unsigned char)fd_hash[cur_dup_entry].digest[i]);
+                            fprintf(stderr, "\n");
+                        }
+                    }
+                }
 
-                        /* Protect non-protocol data */
-                        if (wtap_file_type_subtype(wth) == WTAP_FILE_TYPE_SUBTYPE_CATAPULT_DCT2000)
-                            real_data_start = find_dct2000_real_data(buf);
+                /* Random error mutation */
+                if (err_prob > 0.0) {
+                    int real_data_start = 0;
 
-                        for (i = real_data_start; i < (int) phdr->caplen; i++) {
-                            if (rand() <= err_prob * RAND_MAX) {
-                                err_type = rand() / (RAND_MAX / ERR_WT_TOTAL + 1);
+                    /* Protect non-protocol data */
+                    if (wtap_file_type_subtype(wth) == WTAP_FILE_TYPE_SUBTYPE_CATAPULT_DCT2000)
+                        real_data_start = find_dct2000_real_data(buf);
 
-                                if (err_type < ERR_WT_BIT) {
-                                    buf[i] ^= 1 << (rand() / (RAND_MAX / 8 + 1));
-                                    err_type = ERR_WT_TOTAL;
-                                } else {
-                                    err_type -= ERR_WT_BYTE;
-                                }
+                    for (i = real_data_start; i < (int) phdr->caplen; i++) {
+                        if (rand() <= err_prob * RAND_MAX) {
+                            err_type = rand() / (RAND_MAX / ERR_WT_TOTAL + 1);
 
-                                if (err_type < ERR_WT_BYTE) {
-                                    buf[i] = rand() / (RAND_MAX / 255 + 1);
-                                    err_type = ERR_WT_TOTAL;
-                                } else {
-                                    err_type -= ERR_WT_BYTE;
-                                }
+                            if (err_type < ERR_WT_BIT) {
+                                buf[i] ^= 1 << (rand() / (RAND_MAX / 8 + 1));
+                                err_type = ERR_WT_TOTAL;
+                            } else {
+                                err_type -= ERR_WT_BYTE;
+                            }
 
-                                if (err_type < ERR_WT_ALNUM) {
-                                    buf[i] = ALNUM_CHARS[rand() / (RAND_MAX / ALNUM_LEN + 1)];
-                                    err_type = ERR_WT_TOTAL;
-                                } else {
-                                    err_type -= ERR_WT_ALNUM;
-                                }
+                            if (err_type < ERR_WT_BYTE) {
+                                buf[i] = rand() / (RAND_MAX / 255 + 1);
+                                err_type = ERR_WT_TOTAL;
+                            } else {
+                                err_type -= ERR_WT_BYTE;
+                            }
 
-                                if (err_type < ERR_WT_FMT) {
-                                    if ((unsigned int)i < phdr->caplen - 2)
-                                        g_strlcpy((char*) &buf[i], "%s", 2);
-                                    err_type = ERR_WT_TOTAL;
-                                } else {
-                                    err_type -= ERR_WT_FMT;
-                                }
+                            if (err_type < ERR_WT_ALNUM) {
+                                buf[i] = ALNUM_CHARS[rand() / (RAND_MAX / ALNUM_LEN + 1)];
+                                err_type = ERR_WT_TOTAL;
+                            } else {
+                                err_type -= ERR_WT_ALNUM;
+                            }
 
-                                if (err_type < ERR_WT_AA) {
-                                    for (j = i; j < (int) phdr->caplen; j++)
-                                        buf[j] = 0xAA;
-                                    i = phdr->caplen;
-                                }
+                            if (err_type < ERR_WT_FMT) {
+                                if ((unsigned int)i < phdr->caplen - 2)
+                                    g_strlcpy((char*) &buf[i], "%s", 2);
+                                err_type = ERR_WT_TOTAL;
+                            } else {
+                                err_type -= ERR_WT_FMT;
+                            }
+
+                            if (err_type < ERR_WT_AA) {
+                                for (j = i; j < (int) phdr->caplen; j++)
+                                    buf[j] = 0xAA;
+                                i = phdr->caplen;
                             }
                         }
                     }
+                }
 
-                    if (!wtap_dump(pdh, phdr, buf, &err)) {
-                        switch (err) {
-                        case WTAP_ERR_UNSUPPORTED_ENCAP:
-                            /*
-                             * This is a problem with the particular frame we're
-                             * writing and the file type and subtype we're
-                             * writing; note that, and report the frame number
-                             * and file type/subtype.
-                             */
-                            fprintf(stderr,
-                                    "editcap: Frame %u of \"%s\" has a network type that can't be saved in a \"%s\" file\n.",
-                                    read_count, argv[optind],
-                                    wtap_file_type_subtype_string(out_file_type_subtype));
-                            break;
-
-                        case WTAP_ERR_PACKET_TOO_LARGE:
-                            /*
-                             * This is a problem with the particular frame we're
-                             * writing and the file type and subtype we're
-                             * writing; note that, and report the frame number
-                             * and file type/subtype.
-                             */
-                            fprintf(stderr,
-                                    "editcap: Frame %u of \"%s\" is too large for a \"%s\" file\n.",
-                                    read_count, argv[optind],
-                                    wtap_file_type_subtype_string(out_file_type_subtype));
-                            break;
-
-                        default:
-                            fprintf(stderr, "editcap: Error writing to %s: %s\n",
-                                    filename, wtap_strerror(err));
-                            break;
-                        }
-                        exit(2);
+                if (!wtap_dump(pdh, phdr, buf, &err)) {
+                    switch (err) {
+                    case WTAP_ERR_UNSUPPORTED_ENCAP:
+                        /*
+                         * This is a problem with the particular frame we're
+                         * writing and the file type and subtype we're
+                         * writing; note that, and report the frame number
+                         * and file type/subtype.
+                         */
+                        fprintf(stderr,
+                                "editcap: Frame %u of \"%s\" has a network type that can't be saved in a \"%s\" file\n.",
+                                read_count, argv[optind],
+                                wtap_file_type_subtype_string(out_file_type_subtype));
+                        break;
+
+                    case WTAP_ERR_PACKET_TOO_LARGE:
+                        /*
+                         * This is a problem with the particular frame we're
+                         * writing and the file type and subtype we're
+                         * writing; note that, and report the frame number
+                         * and file type/subtype.
+                         */
+                        fprintf(stderr,
+                                "editcap: Frame %u of \"%s\" is too large for a \"%s\" file\n.",
+                                read_count, argv[optind],
+                                wtap_file_type_subtype_string(out_file_type_subtype));
+                        break;
+
+                    default:
+                        fprintf(stderr, "editcap: Error writing to %s: %s\n",
+                                filename, wtap_strerror(err));
+                        break;
                     }
-                    written_count++;
+                    exit(2);
                 }
-                count++;
+                written_count++;
             }
+            count++;
         }
 
         g_free(fprefix);
diff --git a/file.c b/file.c
index c54188b550b55c57c70f6415ce7086b78d01cddb..e75a78d4f9791e0b5c708a0b7cf3b465291a70d1 100644 (file)
--- a/file.c
+++ b/file.c
@@ -575,7 +575,6 @@ cf_read(capture_file *cf, gboolean reloading)
 {
   int                  err;
   gchar               *err_info;
-  int                  rec_type;
   gchar               *name_ptr;
   progdlg_t           *progbar        = NULL;
   gboolean             stop_flag;
@@ -652,7 +651,7 @@ cf_read(capture_file *cf, gboolean reloading)
     }else
       progbar_quantum = 0;
 
-    while ((rec_type = wtap_read(cf->wth, &err, &err_info, &data_offset)) != -1) {
+    while ((wtap_read(cf->wth, &err, &err_info, &data_offset))) {
       if (size >= 0) {
         count++;
         file_pos = wtap_read_so_far(cf->wth);
@@ -702,9 +701,7 @@ cf_read(capture_file *cf, gboolean reloading)
            hours even on fast machines) just to see that it was the wrong file. */
         break;
       }
-
-      if (rec_type == REC_TYPE_PACKET)
-          read_packet(cf, dfcode, &edt, cinfo, data_offset);
+      read_packet(cf, dfcode, &edt, cinfo, data_offset);
     }
   }
   CATCH(OutOfMemoryError) {
@@ -840,7 +837,6 @@ cf_read(capture_file *cf, gboolean reloading)
 cf_read_status_t
 cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
 {
-  int               rec_type;
   gchar            *err_info;
   volatile int      newly_displayed_packets = 0;
   dfilter_t        *dfcode;
@@ -879,7 +875,7 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
 
     while (to_read != 0) {
       wtap_cleareof(cf->wth);
-      if ((rec_type = wtap_read(cf->wth, err, &err_info, &data_offset)) == -1) {
+      if (!wtap_read(cf->wth, err, &err_info, &data_offset)) {
         break;
       }
       if (cf->state == FILE_READ_ABORTED) {
@@ -888,10 +884,8 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
            aren't any packets left to read) exit. */
         break;
       }
-      if (rec_type == REC_TYPE_PACKET) {
-        if (read_packet(cf, dfcode, &edt, (column_info *) cinfo, data_offset) != -1) {
-          newly_displayed_packets++;
-        }
+      if (read_packet(cf, dfcode, &edt, (column_info *) cinfo, data_offset) != -1) {
+        newly_displayed_packets++;
       }
       to_read--;
     }
@@ -965,7 +959,6 @@ cf_fake_continue_tail(capture_file *cf) {
 cf_read_status_t
 cf_finish_tail(capture_file *cf, int *err)
 {
-  int        rec_type;
   gchar     *err_info;
   gint64     data_offset;
   dfilter_t *dfcode;
@@ -999,15 +992,14 @@ cf_finish_tail(capture_file *cf, int *err)
 
   epan_dissect_init(&edt, cf->epan, create_proto_tree, FALSE);
 
-  while ((rec_type = wtap_read(cf->wth, err, &err_info, &data_offset)) != -1) {
+  while ((wtap_read(cf->wth, err, &err_info, &data_offset))) {
     if (cf->state == FILE_READ_ABORTED) {
       /* Well, the user decided to abort the read.  Break out of the
          loop, and let the code below (which is called even if there
          aren't any packets left to read) exit. */
       break;
     }
-    if (rec_type == REC_TYPE_PACKET)
-      read_packet(cf, dfcode, &edt, cinfo, data_offset);
+    read_packet(cf, dfcode, &edt, cinfo, data_offset);
   }
 
   /* Cleanup and release all dfilter resources */
@@ -1761,11 +1753,10 @@ cf_redissect_packets(capture_file *cf)
   }
 }
 
-int
+gboolean
 cf_read_frame_r(capture_file *cf, const frame_data *fdata,
                 struct wtap_pkthdr *phdr, Buffer *buf)
 {
-  int    rec_type;
   int    err;
   gchar *err_info;
   gchar *display_basename;
@@ -1777,19 +1768,17 @@ cf_read_frame_r(capture_file *cf, const frame_data *fdata,
 
     if (!frame) {
       simple_error_message_box("fdata->file_off == -1, but can't find modified frame!");
-      return -1;
+      return FALSE;
     }
 
     *phdr = frame->phdr;
     buffer_assure_space(buf, frame->phdr.caplen);
     memcpy(buffer_start_ptr(buf), frame->pd, frame->phdr.caplen);
-    /* XXX - what if this isn't a packet? */
-    return REC_TYPE_PACKET;
+    return TRUE;
   }
 #endif
 
-  rec_type = wtap_seek_read(cf->wth, fdata->file_off, phdr, buf, &err, &err_info);
-  if (rec_type == -1) {
+  if (!wtap_seek_read(cf->wth, fdata->file_off, phdr, buf, &err, &err_info)) {
     display_basename = g_filename_display_basename(cf->filename);
     switch (err) {
 
@@ -1812,12 +1801,12 @@ cf_read_frame_r(capture_file *cf, const frame_data *fdata,
       break;
     }
     g_free(display_basename);
-    return -1;
+    return FALSE;
   }
-  return rec_type;
+  return TRUE;
 }
 
-int
+gboolean
 cf_read_frame(capture_file *cf, frame_data *fdata)
 {
   return cf_read_frame_r(cf, fdata, &cf->phdr, &cf->buf);
@@ -2016,7 +2005,7 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb
     /* Frame dependencies from the previous dissection/filtering are no longer valid. */
     fdata->flags.dependent_of_displayed = 0;
 
-    if (cf_read_frame(cf, fdata) == -1)
+    if (!cf_read_frame(cf, fdata))
       break; /* error reading the frame */
 
     /* If the previous frame is displayed, and we haven't yet seen the
@@ -2343,7 +2332,7 @@ process_specified_packets(capture_file *cf, packet_range_t *range,
     }
 
     /* Get the packet */
-    if (cf_read_frame_r(cf, fdata, &phdr, &buf) == -1) {
+    if (!cf_read_frame_r(cf, fdata, &phdr, &buf)) {
       /* Attempt to get the packet failed. */
       ret = PSP_FAILED;
       break;
@@ -3120,7 +3109,7 @@ match_protocol_tree(capture_file *cf, frame_data *fdata, void *criterion)
   epan_dissect_t  edt;
 
   /* Load the frame's data. */
-  if (cf_read_frame(cf, fdata) == -1) {
+  if (!cf_read_frame(cf, fdata)) {
     /* Attempt to get the packet failed. */
     return MR_ERROR;
   }
@@ -3224,7 +3213,7 @@ match_summary_line(capture_file *cf, frame_data *fdata, void *criterion)
   size_t          c_match    = 0;
 
   /* Load the frame's data. */
-  if (cf_read_frame(cf, fdata) == -1) {
+  if (!cf_read_frame(cf, fdata)) {
     /* Attempt to get the packet failed. */
     return MR_ERROR;
   }
@@ -3322,7 +3311,7 @@ match_narrow_and_wide(capture_file *cf, frame_data *fdata, void *criterion)
   size_t        c_match    = 0;
 
   /* Load the frame's data. */
-  if (cf_read_frame(cf, fdata) == -1) {
+  if (!cf_read_frame(cf, fdata)) {
     /* Attempt to get the packet failed. */
     return MR_ERROR;
   }
@@ -3370,7 +3359,7 @@ match_narrow(capture_file *cf, frame_data *fdata, void *criterion)
   size_t        c_match    = 0;
 
   /* Load the frame's data. */
-  if (cf_read_frame(cf, fdata) == -1) {
+  if (!cf_read_frame(cf, fdata)) {
     /* Attempt to get the packet failed. */
     return MR_ERROR;
   }
@@ -3417,7 +3406,7 @@ match_wide(capture_file *cf, frame_data *fdata, void *criterion)
   size_t        c_match    = 0;
 
   /* Load the frame's data. */
-  if (cf_read_frame(cf, fdata) == -1) {
+  if (!cf_read_frame(cf, fdata)) {
     /* Attempt to get the packet failed. */
     return MR_ERROR;
   }
@@ -3463,7 +3452,7 @@ match_binary(capture_file *cf, frame_data *fdata, void *criterion)
   size_t        c_match     = 0;
 
   /* Load the frame's data. */
-  if (cf_read_frame(cf, fdata) == -1) {
+  if (!cf_read_frame(cf, fdata)) {
     /* Attempt to get the packet failed. */
     return MR_ERROR;
   }
@@ -3533,7 +3522,7 @@ match_dfilter(capture_file *cf, frame_data *fdata, void *criterion)
   match_result    result;
 
   /* Load the frame's data. */
-  if (cf_read_frame(cf, fdata) == -1) {
+  if (!cf_read_frame(cf, fdata)) {
     /* Attempt to get the packet failed. */
     return MR_ERROR;
   }
@@ -3859,7 +3848,7 @@ cf_select_packet(capture_file *cf, int row)
   }
 
   /* Get the data in that frame. */
-  if (cf_read_frame (cf, fdata) == -1) {
+  if (!cf_read_frame (cf, fdata)) {
     return;
   }
 
@@ -4039,7 +4028,7 @@ cf_get_comment(capture_file *cf, const frame_data *fd)
     memset(&phdr, 0, sizeof(struct wtap_pkthdr));
 
     buffer_init(&buf, 1500);
-    if (cf_read_frame_r(cf, fd, &phdr, &buf) == -1)
+    if (!cf_read_frame_r(cf, fd, &phdr, &buf))
       { /* XXX, what we can do here? */ }
 
     buffer_free(&buf);
@@ -4333,7 +4322,6 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
 {
   const struct wtap_pkthdr *phdr;
   gchar               *err_info;
-  int                  rec_type;
   gchar               *name_ptr;
   gint64               data_offset;
   gint64               file_pos;
@@ -4420,7 +4408,10 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
 
   framenum = 0;
   phdr = wtap_phdr(cf->wth);
-  while ((rec_type = wtap_read(cf->wth, err, &err_info, &data_offset)) != -1) {
+  while ((wtap_read(cf->wth, err, &err_info, &data_offset))) {
+    framenum++;
+    fdata = frame_data_sequence_find(cf->frames, framenum);
+    fdata->file_off = data_offset;
     if (size >= 0) {
       count++;
       file_pos = wtap_read_so_far(cf->wth);
@@ -4464,19 +4455,13 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
       break;
     }
 
-    if (rec_type == REC_TYPE_PACKET) {
-      framenum++;
-      fdata = frame_data_sequence_find(cf->frames, framenum);
-      fdata->file_off = data_offset;
-
-      /* Add this packet's link-layer encapsulation type to cf->linktypes, if
-         it's not already there.
-         XXX - yes, this is O(N), so if every packet had a different
-         link-layer encapsulation type, it'd be O(N^2) to read the file, but
-         there are probably going to be a small number of encapsulation types
-         in a file. */
-      cf_add_encapsulation_type(cf, phdr->pkt_encap);
-    }
+    /* Add this packet's link-layer encapsulation type to cf->linktypes, if
+       it's not already there.
+       XXX - yes, this is O(N), so if every packet had a different
+       link-layer encapsulation type, it'd be O(N^2) to read the file, but
+       there are probably going to be a small number of encapsulation types
+       in a file. */
+    cf_add_encapsulation_type(cf, phdr->pkt_encap);
   }
 
   /* Free the display name */
diff --git a/file.h b/file.h
index ed12f57044fba1a20833cafd97006c27c2579bfe..79df1cfd68c33754e3390ff2993cd32ee3f31869 100644 (file)
--- a/file.h
+++ b/file.h
@@ -137,30 +137,29 @@ void cf_reload(capture_file *cf);
 cf_read_status_t cf_read(capture_file *cf, gboolean from_save);
 
 /**
- * Read a record from a capture file.  It will pop up an alert box
- * if there's an error.
+ * Read the pseudo-header and raw data for a packet.  It will pop
+ * up an alert box if there's an error.
  *
- * @param cf the capture file from which to read the record
- * @param fdata the frame_data structure for the record in question
+ * @param cf the capture file from which to read the packet
+ * @param fdata the frame_data structure for the packet in question
  * @param phdr pointer to a wtap_pkthdr structure to contain the
- * packet's pseudo-header and other metadata, if the record is a
- * packet
- * @param buf a Buffer into which to read the record's data
- * @return record type if the read succeeded, -1 if there was an error
+ * packet's pseudo-header and other metadata
+ * @param buf a Buffer into which to read the packet's raw data
+ * @return TRUE if the read succeeded, FALSE if there was an error
  */
-int cf_read_frame_r(capture_file *cf, const frame_data *fdata,
-                    struct wtap_pkthdr *phdr, Buffer *buf);
+gboolean cf_read_frame_r(capture_file *cf, const frame_data *fdata,
+                         struct wtap_pkthdr *phdr, Buffer *buf);
 
 /**
- * Read a record from a capture file into a capture_file structure's
- * pseudo_header and buf members.
+ * Read the pseudo-header and raw data for a packet into a
+ * capture_file structure's pseudo_header and buf members.
  * It will pop up an alert box if there's an error.
  *
- * @param cf the capture file from which to read the record
- * @param fdata the frame_data structure for the record in question
- * @return record type if the read succeeded, -1 if there was an error
+ * @param cf the capture file from which to read the packet
+ * @param fdata the frame_data structure for the packet in question
+ * @return TRUE if the read succeeded, FALSE if there was an error
  */
-int cf_read_frame(capture_file *cf, frame_data *fdata);
+gboolean cf_read_frame(capture_file *cf, frame_data *fdata);
 
 /**
  * Read packets from the "end" of a capture file.
index e9321926bbc658ba9da667a424e32a46cbfc7e6a..b47d206f07bbc4426421d13f02707d9f85acc857 100644 (file)
@@ -57,7 +57,7 @@ frame_read(struct tvb_frame *frame_tvb, struct wtap_pkthdr *phdr, Buffer *buf)
        /* XXX, what if phdr->caplen isn't equal to
         * frame_tvb->tvb.length + frame_tvb->offset?
         */
-       if (wtap_seek_read(frame_tvb->wth, frame_tvb->file_off, phdr, buf, &err, &err_info) == -1) {
+       if (!wtap_seek_read(frame_tvb->wth, frame_tvb->file_off, phdr, buf, &err, &err_info)) {
                switch (err) {
                        case WTAP_ERR_UNSUPPORTED_ENCAP:
                        case WTAP_ERR_BAD_FILE:
index ae0ee5035010d4bcfdaea861839c33676af1fa5d..68eaaa1eac83913bc5266688a90215b61ca627de 100644 (file)
@@ -147,7 +147,7 @@ process_frame(frame_data *frame, column_info *cinfo, ph_stats_t* ps)
 
        /* Load the frame from the capture file */
        buffer_init(&buf, 1500);
-       if (cf_read_frame_r(&cfile, frame, &phdr, &buf) == -1)
+       if (!cf_read_frame_r(&cfile, frame, &phdr, &buf))
                return FALSE;   /* failure */
 
        /* Dissect the frame   tree  not visible */
index df46d7c166f6ba0519566ce4409fad5591a168cc..4b363b84b149b7329d0c47c86e956514ba9a279e 100644 (file)
@@ -103,7 +103,7 @@ frame_write(FrameRecord_t *frame, wtap *wth, wtap_dumper *pdh, Buffer *buf,
 
 
     /* Re-read the first frame from the stored location */
-    if (wtap_seek_read(wth, frame->offset, &phdr, buf, &err, &err_info) == -1) {
+    if (!wtap_seek_read(wth, frame->offset, &phdr, buf, &err, &err_info)) {
         if (err != 0) {
             /* Print a message noting that the read failed somewhere along the line. */
             fprintf(stderr,
@@ -176,7 +176,6 @@ int main(int argc, char *argv[])
 {
     wtap *wth = NULL;
     wtap_dumper *pdh = NULL;
-    int rec_type;
     Buffer buf;
     int err;
     gchar *err_info;
@@ -262,24 +261,22 @@ int main(int argc, char *argv[])
     frames = g_ptr_array_new();
 
     /* Read each frame from infile */
-    while ((rec_type = wtap_read(wth, &err, &err_info, &data_offset)) != -1) {
-        if (rec_type == REC_TYPE_PACKET) {
-            FrameRecord_t *newFrameRecord;
+    while (wtap_read(wth, &err, &err_info, &data_offset)) {
+        FrameRecord_t *newFrameRecord;
 
-            phdr = wtap_phdr(wth);
+        phdr = wtap_phdr(wth);
 
-            newFrameRecord = g_slice_new(FrameRecord_t);
-            newFrameRecord->num = frames->len + 1;
-            newFrameRecord->offset = data_offset;
-            newFrameRecord->time = phdr->ts;
+        newFrameRecord = g_slice_new(FrameRecord_t);
+        newFrameRecord->num = frames->len + 1;
+        newFrameRecord->offset = data_offset;
+        newFrameRecord->time = phdr->ts;
 
-            if (prevFrame && frames_compare(&newFrameRecord, &prevFrame) < 0) {
-               wrong_order_count++;
-            }
-
-            g_ptr_array_add(frames, newFrameRecord);
-            prevFrame = newFrameRecord;
+        if (prevFrame && frames_compare(&newFrameRecord, &prevFrame) < 0) {
+           wrong_order_count++;
         }
+
+        g_ptr_array_add(frames, newFrameRecord);
+        prevFrame = newFrameRecord;
     }
     if (err != 0) {
       /* Print a message noting that the read failed somewhere along the line. */
index 6de68cd53c8da311f72ccc46c458cc4c184afb02..e62350400f8a59d592f60bca267811d919040f98 100644 (file)
--- a/tfshark.c
+++ b/tfshark.c
@@ -1857,7 +1857,7 @@ load_cap_file(capture_file *cf, int max_packet_count, gint64 max_byte_count)
     for (framenum = 1; err == 0 && framenum <= cf->count; framenum++) {
       fdata = frame_data_sequence_find(cf->frames, framenum);
 #if 0
-      if (local_wtap_seek_read(cf->wth, fdata->file_off,
+      if (wtap_seek_read(cf->wth, fdata->file_off,
           &buf, fdata->cap_len, &err, &err_info)) {
         process_packet_second_pass(cf, edt, fdata, &cf->phdr, &buf, tap_flags);
       }
index afbf6310ac600750843846ebbe99ede220b6fd7d..f52b00502f883f40e863bf09b6f033c31131b431 100644 (file)
--- a/tshark.c
+++ b/tshark.c
@@ -2651,11 +2651,11 @@ capture_input_new_file(capture_session *cap_session, gchar *new_file)
 }
 
 
-/* capture child tells us we have new records to read */
+/* capture child tells us we have new packets to read */
 void
-capture_input_new_records(capture_session *cap_session, int to_read)
+capture_input_new_packets(capture_session *cap_session, int to_read)
 {
-  int           rec_type;
+  gboolean      ret;
   int           err;
   gchar        *err_info;
   gint64        data_offset;
@@ -2696,21 +2696,20 @@ capture_input_new_records(capture_session *cap_session, int to_read)
 
     while (to_read-- && cf->wth) {
       wtap_cleareof(cf->wth);
-      rec_type = wtap_read(cf->wth, &err, &err_info, &data_offset);
-      if (rec_type == -1) {
+      ret = wtap_read(cf->wth, &err, &err_info, &data_offset);
+      if (ret == FALSE) {
         /* read from file failed, tell the capture child to stop */
         sync_pipe_stop(cap_session);
         wtap_close(cf->wth);
         cf->wth = NULL;
       } else {
-       if (rec_type == REC_TYPE_PACKET) {
-          if (process_packet(cf, edt, data_offset, wtap_phdr(cf->wth),
+        ret = process_packet(cf, edt, data_offset, wtap_phdr(cf->wth),
                              wtap_buf_ptr(cf->wth),
-                             tap_flags)) {
-            /* packet successfully read and gone through the "Read Filter" */
-            packet_count++;
-          }
-        }
+                             tap_flags);
+      }
+      if (ret != FALSE) {
+        /* packet successfully read and gone through the "Read Filter" */
+        packet_count++;
       }
     }
 
@@ -3063,11 +3062,9 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
   int          snapshot_length;
   wtap_dumper *pdh;
   guint32      framenum;
-  int          rec_type;
   int          err;
   gchar       *err_info = NULL;
   gint64       data_offset;
-  gboolean     packet_count_reached = FALSE;
   char        *save_file_string = NULL;
   gboolean     filtering_tap_listeners;
   guint        tap_flags;
@@ -3194,19 +3191,17 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
       edt = epan_dissect_new(cf->epan, create_proto_tree, FALSE);
     }
 
-    while ((rec_type = wtap_read(cf->wth, &err, &err_info, &data_offset)) != -1) {
-      if (rec_type == REC_TYPE_PACKET) {
-        if (process_packet_first_pass(cf, edt, data_offset, wtap_phdr(cf->wth),
-                                      wtap_buf_ptr(cf->wth))) {
-          /* Stop reading if we have the maximum number of packets;
-           * When the -c option has not been used, max_packet_count
-           * starts at 0, which practically means, never stop reading.
-           * (unless we roll over max_packet_count ?)
-           */
-          if ( (--max_packet_count == 0) || (max_byte_count != 0 && data_offset >= max_byte_count)) {
-            err = 0; /* This is not an error */
-            break;
-          }
+    while (wtap_read(cf->wth, &err, &err_info, &data_offset)) {
+      if (process_packet_first_pass(cf, edt, data_offset, wtap_phdr(cf->wth),
+                         wtap_buf_ptr(cf->wth))) {
+        /* Stop reading if we have the maximum number of packets;
+         * When the -c option has not been used, max_packet_count
+         * starts at 0, which practically means, never stop reading.
+         * (unless we roll over max_packet_count ?)
+         */
+        if ( (--max_packet_count == 0) || (max_byte_count != 0 && data_offset >= max_byte_count)) {
+          err = 0; /* This is not an error */
+          break;
         }
       }
     }
@@ -3245,101 +3240,15 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
 
     for (framenum = 1; err == 0 && framenum <= cf->count; framenum++) {
       fdata = frame_data_sequence_find(cf->frames, framenum);
-      if ((rec_type = wtap_seek_read(cf->wth, fdata->file_off, &phdr, &buf, &err,
-                                     &err_info)) == -1) {
-        if (rec_type == REC_TYPE_PACKET) {
-          if (process_packet_second_pass(cf, edt, fdata, &phdr, &buf,
-                                         tap_flags)) {
-            /* Either there's no read filtering or this packet passed the
-               filter, so, if we're writing to a capture file, write
-               this packet out. */
-            if (pdh != NULL) {
-              if (!wtap_dump(pdh, &phdr, buffer_start_ptr(&buf), &err)) {
-                /* Error writing to a capture file */
-                switch (err) {
-
-                case WTAP_ERR_UNSUPPORTED_ENCAP:
-                  /*
-                   * This is a problem with the particular frame we're writing
-                   * and the file type and subtype we're writing; note that,
-                   * and report the frame number and file type/subtype.
-                   *
-                   * XXX - framenum is not necessarily the frame number in
-                   * the input file if there was a read filter.
-                   */
-                  fprintf(stderr,
-                          "Frame %u of \"%s\" has a network type that can't be saved in a \"%s\" file.\n",
-                          framenum, cf->filename,
-                          wtap_file_type_subtype_short_string(out_file_type));
-                  break;
-
-                case WTAP_ERR_PACKET_TOO_LARGE:
-                  /*
-                   * This is a problem with the particular frame we're writing
-                   * and the file type and subtype we're writing; note that,
-                   * and report the frame number and file type/subtype.
-                   *
-                   * XXX - framenum is not necessarily the frame number in
-                   * the input file if there was a read filter.
-                   */
-                  fprintf(stderr,
-                          "Frame %u of \"%s\" is too large for a \"%s\" file.\n",
-                          framenum, cf->filename,
-                          wtap_file_type_subtype_short_string(out_file_type));
-                  break;
-
-                default:
-                  show_capture_file_io_error(save_file, err, FALSE);
-                  break;
-                }
-                wtap_dump_close(pdh, &err);
-                g_free(shb_hdr);
-                exit(2);
-              }
-            }
-          }
-        }
-      }
-    }
-
-    if (edt) {
-      epan_dissect_free(edt);
-      edt = NULL;
-    }
-
-    buffer_free(&buf);
-  }
-  else {
-    framenum = 0;
-
-    if (do_dissection) {
-      gboolean create_proto_tree;
-
-      if (cf->rfcode || cf->dfcode || print_details || filtering_tap_listeners ||
-          (tap_flags & TL_REQUIRES_PROTO_TREE) || have_custom_cols(&cf->cinfo))
-        create_proto_tree = TRUE;
-      else
-        create_proto_tree = FALSE;
-
-      /* The protocol tree will be "visible", i.e., printed, only if we're
-         printing packet details, which is true if we're printing stuff
-         ("print_packet_info" is true) and we're in verbose mode
-         ("packet_details" is true). */
-      edt = epan_dissect_new(cf->epan, create_proto_tree, print_packet_info && print_details);
-    }
-
-    while ((rec_type = wtap_read(cf->wth, &err, &err_info, &data_offset)) != -1) {
-      if (rec_type == REC_TYPE_PACKET) {
-        framenum++;
-
-        if (process_packet(cf, edt, data_offset, wtap_phdr(cf->wth),
-                           wtap_buf_ptr(cf->wth),
-                           tap_flags)) {
+      if (wtap_seek_read(cf->wth, fdata->file_off, &phdr, &buf, &err,
+                         &err_info)) {
+        if (process_packet_second_pass(cf, edt, fdata, &phdr, &buf,
+                                       tap_flags)) {
           /* Either there's no read filtering or this packet passed the
              filter, so, if we're writing to a capture file, write
              this packet out. */
           if (pdh != NULL) {
-            if (!wtap_dump(pdh, wtap_phdr(cf->wth), wtap_buf_ptr(cf->wth), &err)) {
+            if (!wtap_dump(pdh, &phdr, buffer_start_ptr(&buf), &err)) {
               /* Error writing to a capture file */
               switch (err) {
 
@@ -3348,6 +3257,9 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
                  * This is a problem with the particular frame we're writing
                  * and the file type and subtype we're writing; note that,
                  * and report the frame number and file type/subtype.
+                 *
+                 * XXX - framenum is not necessarily the frame number in
+                 * the input file if there was a read filter.
                  */
                 fprintf(stderr,
                         "Frame %u of \"%s\" has a network type that can't be saved in a \"%s\" file.\n",
@@ -3360,6 +3272,9 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
                  * This is a problem with the particular frame we're writing
                  * and the file type and subtype we're writing; note that,
                  * and report the frame number and file type/subtype.
+                 *
+                 * XXX - framenum is not necessarily the frame number in
+                 * the input file if there was a read filter.
                  */
                 fprintf(stderr,
                         "Frame %u of \"%s\" is too large for a \"%s\" file.\n",
@@ -3377,23 +3292,89 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
             }
           }
         }
+      }
+    }
 
-        /* If we're supposed to stop after max_packet_count packets,
-         * count this packet. 
-         * When the -c option has not been used, max_packet_count
-         * starts at 0.
-         */
-        if (max_packet_count != 0) {
-          max_packet_count--;
-          if (max_packet_count == 0)
-            packet_count_reached = TRUE;
+    if (edt) {
+      epan_dissect_free(edt);
+      edt = NULL;
+    }
+
+    buffer_free(&buf);
+  }
+  else {
+    framenum = 0;
+
+    if (do_dissection) {
+      gboolean create_proto_tree;
+
+      if (cf->rfcode || cf->dfcode || print_details || filtering_tap_listeners ||
+          (tap_flags & TL_REQUIRES_PROTO_TREE) || have_custom_cols(&cf->cinfo))
+        create_proto_tree = TRUE;
+      else
+        create_proto_tree = FALSE;
+
+      /* The protocol tree will be "visible", i.e., printed, only if we're
+         printing packet details, which is true if we're printing stuff
+         ("print_packet_info" is true) and we're in verbose mode
+         ("packet_details" is true). */
+      edt = epan_dissect_new(cf->epan, create_proto_tree, print_packet_info && print_details);
+    }
+
+    while (wtap_read(cf->wth, &err, &err_info, &data_offset)) {
+      framenum++;
+
+      if (process_packet(cf, edt, data_offset, wtap_phdr(cf->wth),
+                         wtap_buf_ptr(cf->wth),
+                         tap_flags)) {
+        /* Either there's no read filtering or this packet passed the
+           filter, so, if we're writing to a capture file, write
+           this packet out. */
+        if (pdh != NULL) {
+          if (!wtap_dump(pdh, wtap_phdr(cf->wth), wtap_buf_ptr(cf->wth), &err)) {
+            /* Error writing to a capture file */
+            switch (err) {
+
+            case WTAP_ERR_UNSUPPORTED_ENCAP:
+              /*
+               * This is a problem with the particular frame we're writing
+               * and the file type and subtype we're writing; note that,
+               * and report the frame number and file type/subtype.
+               */
+              fprintf(stderr,
+                      "Frame %u of \"%s\" has a network type that can't be saved in a \"%s\" file.\n",
+                      framenum, cf->filename,
+                      wtap_file_type_subtype_short_string(out_file_type));
+              break;
+
+            case WTAP_ERR_PACKET_TOO_LARGE:
+              /*
+               * This is a problem with the particular frame we're writing
+               * and the file type and subtype we're writing; note that,
+               * and report the frame number and file type/subtype.
+               */
+              fprintf(stderr,
+                      "Frame %u of \"%s\" is too large for a \"%s\" file.\n",
+                      framenum, cf->filename,
+                      wtap_file_type_subtype_short_string(out_file_type));
+              break;
+
+            default:
+              show_capture_file_io_error(save_file, err, FALSE);
+              break;
+            }
+            wtap_dump_close(pdh, &err);
+            g_free(shb_hdr);
+            exit(2);
+          }
         }
       }
-
-      /* Stop reading if we have the maximum number of packets or the
-       * maximum file size.
+      /* Stop reading if we have the maximum number of packets;
+       * When the -c option has not been used, max_packet_count
+       * starts at 0, which practically means, never stop reading.
+       * (unless we roll over max_packet_count ?)
        */
-      if ( packet_count_reached || (max_byte_count != 0 && data_offset >= max_byte_count)) {
+      if ( (--max_packet_count == 0) || (max_byte_count != 0 && data_offset >= max_byte_count)) {
         err = 0; /* This is not an error */
         break;
       }
index 74f35d6748155e875a6c46353984eacf28861947..baef2baed97aacf21bb91613229bc537187bf292 100644 (file)
@@ -173,7 +173,6 @@ preview_set_filename(GtkWidget *prev, const gchar *cf_name)
 static void
 preview_do(GtkWidget *prev, wtap *wth)
 {
-  int           rec_type;
   GtkWidget    *label;
   unsigned int  elapsed_time;
   time_t        time_preview;
@@ -184,7 +183,6 @@ preview_do(GtkWidget *prev, wtap *wth)
   double        start_time   = 0; /* seconds, with nsec resolution */
   double        stop_time    = 0; /* seconds, with nsec resolution */
   double        cur_time;
-  unsigned int  records    = 0;
   unsigned int  packets    = 0;
   gboolean      is_breaked = FALSE;
   gchar         string_buff[PREVIEW_STR_MAX];
@@ -194,25 +192,22 @@ preview_do(GtkWidget *prev, wtap *wth)
 
 
   time(&time_preview);
-  while ( (rec_type = wtap_read(wth, &err, &err_info, &data_offset)) != -1 ) {
-    if (rec_type == REC_TYPE_PACKET) {
-      phdr = wtap_phdr(wth);
-      cur_time = nstime_to_sec(&phdr->ts);
-      if (packets == 0) {
-        start_time = cur_time;
-        stop_time = cur_time;
-      }
-      if (cur_time < start_time) {
-        start_time = cur_time;
-      }
-      if (cur_time > stop_time) {
-        stop_time = cur_time;
-      }
-
-      packets++;
+  while ( (wtap_read(wth, &err, &err_info, &data_offset)) ) {
+    phdr = wtap_phdr(wth);
+    cur_time = nstime_to_sec(&phdr->ts);
+    if (packets == 0) {
+      start_time = cur_time;
+      stop_time = cur_time;
     }
-    records++;
-    if (records%1000 == 0) {
+    if (cur_time < start_time) {
+      start_time = cur_time;
+    }
+    if (cur_time > stop_time) {
+      stop_time = cur_time;
+    }
+
+    packets++;
+    if (packets%1000 == 0) {
       /* do we have a timeout? */
       time(&time_current);
       if (time_current-time_preview >= (time_t) prefs.gui_fileopen_preview) {
index d756b3a58b241fb8383ac82fb843eb056cb2c89b..6f7fe77c730777a21fd9433fddf7ea4ff2e87dd9 100644 (file)
@@ -3711,7 +3711,7 @@ void iax2_analysis_cb(GtkAction *action _U_, gpointer user_data _U_)
                return; /* if we exit here it's an error */
 
        /* dissect the current frame */
-       if (cf_read_frame(cf, fdata) == -1)
+       if (!cf_read_frame(cf, fdata))
                return; /* error reading the frame */
        epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
        epan_dissect_prime_dfilter(&edt, sfcode);
index a3140b18e12453595e2a1631ff2c742d1608ca5a..e49e0531a0131263a19f134588b49127a9230958 100644 (file)
@@ -543,7 +543,7 @@ get_ip_address_list_from_packet_list_row(gpointer data)
     if (fdata != NULL) {
         epan_dissect_t edt;
 
-        if (cf_read_frame (&cfile, fdata) == -1)
+        if (!cf_read_frame (&cfile, fdata))
             return NULL; /* error reading the frame */
 
         epan_dissect_init(&edt, cfile.epan, FALSE, FALSE);
@@ -584,7 +584,7 @@ get_filter_from_packet_list_row_and_column(gpointer data)
     if (fdata != NULL) {
         epan_dissect_t edt;
 
-        if (cf_read_frame(&cfile, fdata) == -1)
+        if (!cf_read_frame(&cfile, fdata))
             return NULL; /* error reading the frame */
         /* proto tree, visible. We need a proto tree if there's custom columns */
         epan_dissect_init(&edt, cfile.epan, have_custom_cols(&cfile.cinfo), FALSE);
index efb8e44ea15aa8294ef2c4c24ceed0183df55ffe..dd904b58be1be1216a425283798145a165aa69c2 100644 (file)
@@ -1117,7 +1117,7 @@ packet_list_dissect_and_cache_record(PacketList *packet_list, PacketListRecord *
                cinfo = NULL;
 
        buffer_init(&buf, 1500);
-       if (cf_read_frame_r(&cfile, fdata, &phdr, &buf) == -1) {
+       if (!cf_read_frame_r(&cfile, fdata, &phdr, &buf)) {
                /*
                 * Error reading the frame.
                 *
index 67fb5fddd2594ed4c32c9671e4daa07627b7ca60..c25d62b48aac29ae51cdb644bc0fd3a863c202d7 100644 (file)
@@ -961,7 +961,7 @@ void new_packet_window(GtkWidget *w _U_, gboolean reference, gboolean editable _
        }
 
        /* With the new packetlists "lazy columns" it's necessary to reread the frame */
-       if (cf_read_frame(&cfile, fd) == -1) {
+       if (!cf_read_frame(&cfile, fd)) {
                /* error reading the frame */
                return;
        }
index eb9e2635f105be7334289a1c5bce2a7ef6f77f09..aeb5b9996ba810e7f871c7986d0670f2f77ff3b5 100644 (file)
@@ -903,7 +903,7 @@ static rlc_lte_tap_info *select_rlc_lte_session(capture_file *cf, struct segment
     }
 
     /* dissect the current frame */
-    if (cf_read_frame(cf, fdata) == -1) {
+    if (!cf_read_frame(cf, fdata)) {
         return NULL;  /* error reading the frame */
     }
 
index 66c2406658d87406943a75b4ae821ee1f22192c3..0305b0a26afe09215ce159b0eaaa03a8d0975823 100644 (file)
@@ -3946,7 +3946,7 @@ rtp_analysis_cb(GtkAction *action _U_, gpointer user_data _U_)
                return; /* if we exit here it's an error */
 
        /* dissect the current frame */
-       if (cf_read_frame(cf, fdata) == -1)
+       if (!cf_read_frame(cf, fdata))
                return; /* error reading the frame */
        epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
        epan_dissect_prime_dfilter(&edt, sfcode);
index 927be97b0e0c4bb078845caf2cb65b540e17b125..2b751f7135d5f1d1b8fc53f75b15b78b02414a02 100644 (file)
@@ -975,7 +975,7 @@ sctp_analyse_cb(struct sctp_analyse *u_data, gboolean ext)
                return; /* if we exit here it's an error */
 
        /* dissect the current frame */
-       if (cf_read_frame(cf, fdata) == -1)
+       if (!cf_read_frame(cf, fdata))
                return; /* error reading the frame */
 
        epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
index 3e123dc34b9e9c96c54abdb45b44b72680a2f54a..03d48924114be569b82a4ede56f7089e605ba113 100644 (file)
@@ -736,13 +736,11 @@ void CaptureFileDialog::preview(const QString & path)
     wtap        *wth;
     int          err = 0;
     gchar       *err_info;
-    int          rec_type;
     gint64       data_offset;
     const struct wtap_pkthdr *phdr;
     double       start_time = 0; /* seconds, with nsec resolution */
     double       stop_time = 0;  /* seconds, with nsec resolution */
     double       cur_time;
-    unsigned int records = 0;
     unsigned int packets = 0;
     bool         timed_out = FALSE;
     time_t       time_preview;
@@ -794,25 +792,22 @@ void CaptureFileDialog::preview(const QString & path)
     preview_size_.setText(QString(tr("%1 bytes")).arg(wtap_file_size(wth, &err)));
 
     time(&time_preview);
-    while ( (rec_type = wtap_read(wth, &err, &err_info, &data_offset)) != -1 ) {
-        if (rec_type == REC_TYPE_PACKET) {
-            phdr = wtap_phdr(wth);
-            cur_time = nstime_to_sec(&phdr->ts);
-            if(packets == 0) {
-                start_time = cur_time;
-                stop_time = cur_time;
-            }
-            if (cur_time < start_time) {
-                start_time = cur_time;
-            }
-            if (cur_time > stop_time){
-                stop_time = cur_time;
-            }
-
-            packets++;
+    while ( (wtap_read(wth, &err, &err_info, &data_offset)) ) {
+        phdr = wtap_phdr(wth);
+        cur_time = nstime_to_sec(&phdr->ts);
+        if(packets == 0) {
+            start_time = cur_time;
+            stop_time = cur_time;
         }
-        records++;
-        if(records%1000 == 0) {
+        if (cur_time < start_time) {
+            start_time = cur_time;
+        }
+        if (cur_time > stop_time){
+            stop_time = cur_time;
+        }
+
+        packets++;
+        if(packets%1000 == 0) {
             /* do we have a timeout? */
             time(&time_current);
             if(time_current-time_preview >= (time_t) prefs.gui_fileopen_preview) {
index 2388c6b380f04524bf7e25afac92b2678bf38263..7e9ff9413220ab3c5c40c7ececa7d5bbc70af775 100644 (file)
@@ -655,7 +655,7 @@ QString &PacketList::getFilterFromRowAndColumn()
     if (fdata != NULL) {
         epan_dissect_t edt;
 
-        if (cf_read_frame(cap_file_, fdata) == -1)
+        if (!cf_read_frame(cap_file_, fdata))
             return filter; /* error reading the frame */
         /* proto tree, visible. We need a proto tree if there's custom columns */
         epan_dissect_init(&edt, cap_file_->epan, have_custom_cols(&cap_file_->cinfo), FALSE);
index 805da14c8f0c490eb9568f37b4881c610f69705c..a6b68f51bdec3a2aa3379332cc55784d9dbb5764 100644 (file)
@@ -221,7 +221,7 @@ QVariant PacketListModel::data(const QModelIndex &index, int role) const
     memset(&phdr, 0, sizeof(struct wtap_pkthdr));
 
     buffer_init(&buf, 1500);
-    if (!cap_file_ || cf_read_frame_r(cap_file_, fdata, &phdr, &buf) == -1) {
+    if (!cap_file_ || !cf_read_frame_r(cap_file_, fdata, &phdr, &buf)) {
         /*
          * Error reading the frame.
          *
index 8ba41c22cc16aa93c45827116df26646a2109b20..9dd1e46381712aae5677fd038fa8982a94c53852 100644 (file)
@@ -305,7 +305,7 @@ select_tcpip_session(capture_file *cf, struct segment *hdrs)
     }
 
     /* dissect the current frame */
-    if (cf_read_frame(cf, fdata) == -1)
+    if (!cf_read_frame(cf, fdata))
         return NULL;    /* error reading the frame */
 
 
index 47cf06cd4c0be6253383bbbd7bd1e08b4070a28f..a65aaf4d0fd5bc3264b2412ffecb69e198b42685 100644 (file)
@@ -1119,10 +1119,8 @@ preview_set_file_info(HWND of_hwnd, gchar *preview_file) {
     int         err = 0;
     gchar      *err_info;
     TCHAR       string_buff[PREVIEW_STR_MAX];
-    int         rec_type;
     gint64      data_offset;
-    guint       records = 0;
-    guint       packets = 0;
+    guint       packet = 0;
     gint64      filesize;
     time_t      ti_time;
     struct tm  *ti_tm;
@@ -1188,24 +1186,21 @@ preview_set_file_info(HWND of_hwnd, gchar *preview_file) {
     SetWindowText(cur_ctrl, string_buff);
 
     time(&time_preview);
-    while ( (rec_type = wtap_read(wth, &err, &err_info, &data_offset)) != -1 ) {
-        if (rec_type == REC_TYPE_PACKET) {
-            phdr = wtap_phdr(wth);
-            cur_time = nstime_to_sec( (const nstime_t *) &phdr->ts );
-            if(packets == 0) {
-                start_time  = cur_time;
-                stop_time = cur_time;
-            }
-            if (cur_time < start_time) {
-                start_time = cur_time;
-            }
-            if (cur_time > stop_time){
-                stop_time = cur_time;
-            }
-            packets++;
+    while ( (wtap_read(wth, &err, &err_info, &data_offset)) ) {
+        phdr = wtap_phdr(wth);
+        cur_time = nstime_to_sec( (const nstime_t *) &phdr->ts );
+        if(packet == 0) {
+            start_time  = cur_time;
+            stop_time = cur_time;
+        }
+        if (cur_time < start_time) {
+            start_time = cur_time;
+        }
+        if (cur_time > stop_time){
+            stop_time = cur_time;
         }
-        records++;
-        if(records%100 == 0) {
+        packet++;
+        if(packet%100 == 0) {
             time(&time_current);
             if(time_current-time_preview >= (time_t) prefs.gui_fileopen_preview) {
                 is_breaked = TRUE;
@@ -1215,7 +1210,7 @@ preview_set_file_info(HWND of_hwnd, gchar *preview_file) {
     }
 
     if(err != 0) {
-        StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("error after reading %u packets"), packets);
+        StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("error after reading %u packets"), packet);
         cur_ctrl = GetDlgItem(of_hwnd, EWFD_PTX_PACKETS);
         SetWindowText(cur_ctrl, string_buff);
         wtap_close(wth);
@@ -1224,9 +1219,9 @@ preview_set_file_info(HWND of_hwnd, gchar *preview_file) {
 
     /* Packets */
     if(is_breaked) {
-        StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("more than %u packets (preview timeout)"), packets);
+        StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("more than %u packets (preview timeout)"), packet);
     } else {
-        StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("%u"), packets);
+        StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("%u"), packet);
     }
     cur_ctrl = GetDlgItem(of_hwnd, EWFD_PTX_PACKETS);
     SetWindowText(cur_ctrl, string_buff);
index fed60d05ec5a5bcd8dd6a7c84c8d052613c08960..db377b15702a02de27dfd843573f6aeff2f39a21 100644 (file)
@@ -99,9 +99,9 @@ typedef struct
 #define CST_5VW_CAPTURES_RECORD                (CST_5VW_SECTION_CAPTURES << 28)        /* 0x80000000 */
 #define CST_5VW_SYSTEM_RECORD          0x00000000U
 
-static int _5views_read(wtap *wth, int *err, gchar **err_info,
+static gboolean _5views_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static int _5views_seek_read(wtap *wth, gint64 seek_off,
+static gboolean _5views_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static int _5views_read_header(wtap *wth, FILE_T fh, t_5VW_TimeStamped_Header *hdr,
     struct wtap_pkthdr *phdr, int *err, gchar **err_info);
@@ -191,7 +191,7 @@ int _5views_open(wtap *wth, int *err, gchar **err_info)
 }
 
 /* Read the next packet */
-static int
+static gboolean
 _5views_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
        t_5VW_TimeStamped_Header TimeStamped_Header;
@@ -207,7 +207,7 @@ _5views_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
                /* Read record header. */
                if (!_5views_read_header(wth, wth->fh, &TimeStamped_Header,
                    &wth->phdr, err, err_info))
-                       return -1;
+                       return FALSE;
 
                if (TimeStamped_Header.RecSubType == CST_5VW_FRAME_RECORD) {
                        /*
@@ -220,7 +220,7 @@ _5views_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
                 * Not a packet - skip to the next record.
                 */
                if (file_seek(wth->fh, TimeStamped_Header.RecSize, SEEK_CUR, err) == -1)
-                       return -1;
+                       return FALSE;
        } while (1);
 
        if (wth->phdr.caplen > WTAP_MAX_PACKET_SIZE) {
@@ -231,13 +231,11 @@ _5views_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("5views: File has %u-byte packet, bigger than maximum of %u",
                    wth->phdr.caplen, WTAP_MAX_PACKET_SIZE);
-               return -1;
+               return FALSE;
        }
 
-       if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer,
-           wth->phdr.caplen, err, err_info))
-               return -1;
-       return REC_TYPE_PACKET;
+       return wtap_read_packet_bytes(wth->fh, wth->frame_buffer,
+           wth->phdr.caplen, err, err_info);
 }
 
 static gboolean
@@ -247,7 +245,7 @@ _5views_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
        t_5VW_TimeStamped_Header TimeStamped_Header;
 
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return -1;
+               return FALSE;
 
        /*
         * Read the header.
@@ -256,16 +254,14 @@ _5views_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
            phdr, err, err_info)) {
                if (*err == 0)
                        *err = WTAP_ERR_SHORT_READ;
-               return -1;
+               return FALSE;
        }
 
        /*
         * Read the packet data.
         */
-       if (!wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen,
-           err, err_info))
-               return -1;
-       return REC_TYPE_PACKET;
+       return wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen,
+           err, err_info);
 }
 
 /* Read the header of the next packet.  Return TRUE on success, FALSE
index bab0091fb0fd0428e1451e59418937cdf2c254c1..a0b783b3495872e0788d62f22bfe5d4fc417d8f3 100644 (file)
@@ -112,9 +112,9 @@ typedef struct {
        time_t  start;
 } aethra_t;
 
-static int aethra_read(wtap *wth, int *err, gchar **err_info,
+static gboolean aethra_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static int aethra_seek_read(wtap *wth, gint64 seek_off,
+static gboolean aethra_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static gboolean aethra_read_rec_header(wtap *wth, FILE_T fh, struct aethrarec_hdr *hdr,
     struct wtap_pkthdr *phdr, int *err, gchar **err_info);
@@ -182,7 +182,7 @@ static guint packet = 0;
 #endif
 
 /* Read the next packet */
-static int aethra_read(wtap *wth, int *err, gchar **err_info,
+static gboolean aethra_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        struct aethrarec_hdr hdr;
@@ -196,7 +196,7 @@ static int aethra_read(wtap *wth, int *err, gchar **err_info,
 
                /* Read record header. */
                if (!aethra_read_rec_header(wth, wth->fh, &hdr, &wth->phdr, err, err_info))
-                       return -1;
+                       return FALSE;
 
                /*
                 * XXX - if this is big, we might waste memory by
@@ -205,7 +205,7 @@ static int aethra_read(wtap *wth, int *err, gchar **err_info,
                if (wth->phdr.caplen != 0) {
                        if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer,
                            wth->phdr.caplen, err, err_info))
-                               return -1;      /* Read error */
+                               return FALSE;   /* Read error */
                }
 #if 0
 packet++;
@@ -270,32 +270,32 @@ packet, hdr.rec_type, wth->phdr.caplen, hdr.flags);
        }
 
 found:
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
-static int
+static gboolean
 aethra_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
     Buffer *buf, int *err, gchar **err_info)
 {
        struct aethrarec_hdr hdr;
 
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return -1;
+               return FALSE;
 
        if (!aethra_read_rec_header(wth, wth->random_fh, &hdr, phdr, err,
            err_info)) {
                if (*err == 0)
                        *err = WTAP_ERR_SHORT_READ;
-               return -1;
+               return FALSE;
        }
 
        /*
         * Read the packet data.
         */
        if (!wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen, err, err_info))
-               return -1;      /* failed */
+               return FALSE;   /* failed */
 
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
 static gboolean
index 58ea2fbea6321d7d2e2c77d4da71d30febb723ac..32d4d494184c65c34d7a6903ddfdacfd5f9b230f 100644 (file)
@@ -74,9 +74,9 @@ static const ascend_magic_string ascend_magic[] = {
   { ASCEND_PFX_ETHER,  "ETHER" },
 };
 
-static int ascend_read(wtap *wth, int *err, gchar **err_info,
+static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
        gint64 *data_offset);
-static int ascend_seek_read(wtap *wth, gint64 seek_off,
+static gboolean ascend_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf,
        int *err, gchar **err_info);
 
@@ -237,36 +237,36 @@ static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
      packet's header because we might mistake part of it for a new header. */
   if (file_seek(wth->fh, ascend->next_packet_seek_start,
                 SEEK_SET, err) == -1)
-    return -1;
+    return FALSE;
 
   offset = ascend_seek(wth, err, err_info);
   if (offset == -1)
-    return -1;
+    return FALSE;
   if (parse_ascend(ascend, wth->fh, &wth->phdr, wth->frame_buffer,
                    wth->snapshot_length) != PARSED_RECORD) {
     *err = WTAP_ERR_BAD_FILE;
     *err_info = g_strdup((ascend_parse_error != NULL) ? ascend_parse_error : "parse error");
-    return -1;
+    return FALSE;
   }
 
   *data_offset = offset;
-  return REC_TYPE_PACKET;
+  return TRUE;
 }
 
-static int ascend_seek_read(wtap *wth, gint64 seek_off,
+static gboolean ascend_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf,
        int *err, gchar **err_info)
 {
   ascend_t *ascend = (ascend_t *)wth->priv;
 
   if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-    return -1;
+    return FALSE;
   if (parse_ascend(ascend, wth->random_fh, phdr, buf,
                    wth->snapshot_length) != PARSED_RECORD) {
     *err = WTAP_ERR_BAD_FILE;
     *err_info = g_strdup((ascend_parse_error != NULL) ? ascend_parse_error : "parse error");
-    return -1;
+    return FALSE;
   }
 
-  return REC_TYPE_PACKET;
+  return TRUE;
 }
index 1a3f4e6bf6065879e66d8d791490a2c19adf5454..59e7e28f3964a1d9f0ed82ce7d54ae5cbe445781 100644 (file)
 #define BER_UNI_TAG_SEQ        16      /* SEQUENCE, SEQUENCE OF */
 #define BER_UNI_TAG_SET        17      /* SET, SET OF */
 
-static int ber_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
-                         Buffer *buf, int *err, gchar **err_info)
+static gboolean ber_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
+                              Buffer *buf, int *err, gchar **err_info)
 {
   gint64 file_size;
   int packet_size;
 
   if ((file_size = wtap_file_size(wth, err)) == -1)
-    return -1;
+    return FALSE;
 
   if (file_size > WTAP_MAX_PACKET_SIZE) {
     /*
@@ -55,7 +55,7 @@ static int ber_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
     *err = WTAP_ERR_BAD_FILE;
     *err_info = g_strdup_printf("ber: File has %" G_GINT64_MODIFIER "d-byte packet, bigger than maximum of %u",
                                file_size, WTAP_MAX_PACKET_SIZE);
-    return -1;
+    return FALSE;
   }
   packet_size = (int)file_size;
 
@@ -67,12 +67,10 @@ static int ber_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
   phdr->ts.secs = 0;
   phdr->ts.nsecs = 0;
 
-  if (!wtap_read_packet_bytes(fh, buf, packet_size, err, err_info))
-    return -1;
-  return REC_TYPE_PACKET;
+  return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
 }
 
-static int ber_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+static gboolean ber_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
   gint64 offset;
 
@@ -82,24 +80,24 @@ static int ber_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 
   /* there is only ever one packet */
   if (offset != 0)
-    return -1;
+    return FALSE;
 
   *data_offset = offset;
 
   return ber_read_file(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info);
 }
 
-static int ber_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr _U_,
-                        Buffer *buf, int *err, gchar **err_info)
+static gboolean ber_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr _U_,
+                             Buffer *buf, int *err, gchar **err_info)
 {
   /* there is only one packet */
   if(seek_off > 0) {
     *err = 0;
-    return -1;
+    return FALSE;
   }
 
   if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-    return -1;
+    return FALSE;
 
   return ber_read_file(wth, wth->random_fh, phdr, buf, err, err_info);
 }
index c1e5a9881ee63c05bc66015db6c903d2ea5eace7..b7c0b4c5c55168d304d13f1a06be568b447485c9 100644 (file)
@@ -73,11 +73,11 @@ struct btsnooprec_hdr {
 
 static const gint64 KUnixTimeBase = G_GINT64_CONSTANT(0x00dcddb30f2f8000); /* offset from symbian - unix time */
 
-static int btsnoop_read(wtap *wth, int *err, gchar **err_info,
+static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static int btsnoop_seek_read(wtap *wth, gint64 seek_off,
+static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
-static int btsnoop_read_record(wtap *wth, FILE_T fh,
+static gboolean btsnoop_read_record(wtap *wth, FILE_T fh,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 
 int btsnoop_open(wtap *wth, int *err, gchar **err_info)
@@ -160,7 +160,7 @@ int btsnoop_open(wtap *wth, int *err, gchar **err_info)
        return 1;
 }
 
-static int btsnoop_read(wtap *wth, int *err, gchar **err_info,
+static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        *data_offset = file_tell(wth->fh);
@@ -169,16 +169,16 @@ static int btsnoop_read(wtap *wth, int *err, gchar **err_info,
            err, err_info);
 }
 
-static int btsnoop_seek_read(wtap *wth, gint64 seek_off,
+static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return -1;
+               return FALSE;
 
        return btsnoop_read_record(wth, wth->random_fh, phdr, buf, err, err_info);
 }
 
-static int btsnoop_read_record(wtap *wth, FILE_T fh,
+static gboolean btsnoop_read_record(wtap *wth, FILE_T fh,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
        int     bytes_read;
@@ -196,7 +196,7 @@ static int btsnoop_read_record(wtap *wth, FILE_T fh,
                *err = file_error(fh, err_info);
                if (*err == 0 && bytes_read != 0)
                        *err = WTAP_ERR_SHORT_READ;
-               return -1;
+               return FALSE;
        }
 
        packet_size = g_ntohl(hdr.incl_len);
@@ -210,7 +210,7 @@ static int btsnoop_read_record(wtap *wth, FILE_T fh,
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("btsnoop: File has %u-byte packet, bigger than maximum of %u",
                    packet_size, WTAP_MAX_PACKET_SIZE);
-               return -1;
+               return FALSE;
        }
 
        ts = GINT64_FROM_BE(hdr.ts_usec);
@@ -248,9 +248,7 @@ static int btsnoop_read_record(wtap *wth, FILE_T fh,
 
 
        /* Read packet data. */
-       if (!wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info))
-               return -1;
-       return REC_TYPE_PACKET;
+       return wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info);
 }
 
 /* Returns 0 if we could write the specified encapsulation type,
index d49cf96b805d079388c3843aea57b837100ca150..ccc618498aa1b55a14e6187a8223457f53fa7ce7 100644 (file)
@@ -256,7 +256,7 @@ create_pseudo_hdr(guint8 *buf, guint8 dat_trans_type, guint16 dat_len)
 }
 
 
-static int
+static gboolean
 camins_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
     int *err, gchar **err_info)
 {
@@ -266,7 +266,7 @@ camins_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
     gint        offset, bytes_read;
 
     if (!find_next_pkt_dat_type_len(fh, &dat_trans_type, &dat_len, err, err_info))
-        return -1;
+        return FALSE;
 
     buffer_assure_space(buf, DVB_CI_PSEUDO_HDR_LEN+dat_len);
     p = buffer_start_ptr(buf);
@@ -276,7 +276,7 @@ camins_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
         /* shouldn't happen, all invalid packets must be detected by
            find_next_pkt_dat_type_len() */
         *err = WTAP_ERR_INTERNAL;
-        return -1;
+        return FALSE;
     }
 
     bytes_read = read_packet_data(fh, dat_trans_type,
@@ -284,7 +284,7 @@ camins_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
     /* 0<=bytes_read<=dat_len is very likely a corrupted packet
        we let the dissector handle this */
     if (bytes_read < 0)
-        return -1;
+        return FALSE;
     offset += bytes_read;
 
     phdr->pkt_encap = WTAP_ENCAP_DVBCI;
@@ -292,11 +292,11 @@ camins_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
     phdr->caplen = offset;
     phdr->len = offset;
 
-    return REC_TYPE_PACKET;
+    return TRUE;
 }
 
 
-static int
+static gboolean
 camins_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
     *data_offset = file_tell(wth->fh);
@@ -306,12 +306,12 @@ camins_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 }
 
 
-static int
+static gboolean
 camins_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *pkthdr, Buffer *buf, int *err, gchar **err_info)
 {
     if (-1 == file_seek(wth->random_fh, seek_off, SEEK_SET, err))
-        return -1;
+        return FALSE;
 
     return camins_read_packet(wth->random_fh, pkthdr, buf, err, err_info);
 }
index aece8e75fd6ef95c01c708f064e9dc0ceb1b412a..8b29a23880a2bf049b967712660549621f1adbfc 100644 (file)
@@ -103,12 +103,12 @@ static const gchar catapult_dct2000_magic[] = "Session Transcript";
 
 /************************************************************/
 /* Functions called from wiretap core                       */
-static int catapult_dct2000_read(wtap *wth, int *err, gchar **err_info,
-                                 gint64 *data_offset);
-static int catapult_dct2000_seek_read(wtap *wth, gint64 seek_off,
-                                      struct wtap_pkthdr *phdr,
-                                      Buffer *buf, int *err,
-                                      gchar **err_info);
+static gboolean catapult_dct2000_read(wtap *wth, int *err, gchar **err_info,
+                                      gint64 *data_offset);
+static gboolean catapult_dct2000_seek_read(wtap *wth, gint64 seek_off,
+                                           struct wtap_pkthdr *phdr,
+                                           Buffer *buf, int *err,
+                                           gchar **err_info);
 static void catapult_dct2000_close(wtap *wth);
 
 static gboolean catapult_dct2000_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
@@ -331,9 +331,9 @@ static void write_timestamp_string(char *timestamp_string, int secs, int tenthou
 /**************************************************/
 /* Read packet function.                          */
 /* Look for and read the next usable packet       */
-/* - return REC_TYPE_PACKET and details if found  */
+/* - return TRUE and details if found             */
 /**************************************************/
-static int
+static gboolean
 catapult_dct2000_read(wtap *wth, int *err, gchar **err_info,
                       gint64 *data_offset)
 {
@@ -370,7 +370,7 @@ catapult_dct2000_read(wtap *wth, int *err, gchar **err_info,
         if (!read_new_line(wth->fh, &offset, &line_length, linebuff,
                            sizeof linebuff, err, err_info)) {
             if (*err != 0)
-                return -1;  /* error */
+                return FALSE;  /* error */
             /* No more lines can be read, so quit. */
             break;
         }
@@ -434,19 +434,19 @@ catapult_dct2000_read(wtap *wth, int *err, gchar **err_info,
             g_hash_table_insert(file_externals->packet_prefix_table, pkey, line_prefix_info);
 
             /* OK, we have packet details to return */
-            return REC_TYPE_PACKET;
+            return TRUE;
         }
     }
 
     /* No packet details to return... */
-    return -1;
+    return FALSE;
 }
 
 
 /**************************************************/
 /* Read & seek function.                          */
 /**************************************************/
-static int
+static gboolean
 catapult_dct2000_seek_read(wtap *wth, gint64 seek_off,
                            struct wtap_pkthdr *phdr, Buffer *buf,
                            int *err, gchar **err_info)
@@ -476,13 +476,13 @@ catapult_dct2000_seek_read(wtap *wth, gint64 seek_off,
 
     /* Seek to beginning of packet */
     if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) {
-        return -1;
+        return FALSE;
     }
 
     /* Re-read whole line (this really should succeed) */
     if (!read_new_line(wth->random_fh, &offset, &length, linebuff,
                       sizeof linebuff, err, err_info)) {
-        return -1;
+        return FALSE;
     }
 
     /* Try to parse this line again (should succeed as re-reading...) */
@@ -508,7 +508,7 @@ catapult_dct2000_seek_read(wtap *wth, gint64 seek_off,
                             is_comment, data_chars);
 
         *err = errno = 0;
-        return REC_TYPE_PACKET;
+        return TRUE;
     }
 
     /* If get here, must have failed */
@@ -516,7 +516,7 @@ catapult_dct2000_seek_read(wtap *wth, gint64 seek_off,
     *err_info = g_strdup_printf("catapult dct2000: seek_read failed to read/parse "
                                 "line at position %" G_GINT64_MODIFIER "d",
                                 seek_off);
-    return -1;
+    return FALSE;
 }
 
 
index fa7660bbff566f7ab7b010224d26625d8a184ab1..e2a868a6b27c0cb80122c2dcdfa08bcf29632095 100644 (file)
@@ -78,11 +78,11 @@ typedef struct commview_header {
 #define MEDIUM_WIFI            1
 #define MEDIUM_TOKEN_RING      2
 
-static int commview_read(wtap *wth, int *err, gchar **err_info,
-                        gint64 *data_offset);
-static int commview_seek_read(wtap *wth, gint64 seek_off,
-                             struct wtap_pkthdr *phdr,
-                             Buffer *buf, int *err, gchar **err_info);
+static gboolean commview_read(wtap *wth, int *err, gchar **err_info,
+                             gint64 *data_offset);
+static gboolean commview_seek_read(wtap *wth, gint64 seek_off,
+                                  struct wtap_pkthdr *phdr,
+                                  Buffer *buf, int *err, gchar **err_info);
 static gboolean commview_read_header(commview_header_t *cv_hdr, FILE_T fh,
                                     int *err, gchar **err_info);
 static gboolean commview_dump(wtap_dumper *wdh,        const struct wtap_pkthdr *phdr,
@@ -136,7 +136,7 @@ commview_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
        struct tm tm;
 
        if(!commview_read_header(&cv_hdr, fh, err, err_info))
-               return -1;
+               return FALSE;
 
        switch(cv_hdr.flags & FLAGS_MEDIUM) {
 
@@ -162,7 +162,7 @@ commview_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("commview: unsupported encap: %u",
                                            cv_hdr.flags & FLAGS_MEDIUM);
-               return -1;
+               return FALSE;
        }
 
        tm.tm_year = cv_hdr.year - 1900;
@@ -181,12 +181,10 @@ commview_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
        phdr->ts.secs = mktime(&tm);
        phdr->ts.nsecs = cv_hdr.usecs * 1000;
 
-       if (!wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info))
-               return -1;
-       return REC_TYPE_PACKET;
+       return wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info);
 }
 
-static int
+static gboolean
 commview_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
        *data_offset = file_tell(wth->fh);
@@ -195,12 +193,12 @@ commview_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
            err_info);
 }
 
-static int
+static gboolean
 commview_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
                   Buffer *buf, int *err, gchar **err_info)
 {
        if(file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return -1;
+               return FALSE;
 
        return commview_read_packet(wth->random_fh, phdr, buf, err, err_info);
 }
index 18b2065287e445075c0e374a257f76dd439ffea1..d9370187968385bf4e7988f26928f2b975223971 100644 (file)
@@ -166,13 +166,13 @@ static gboolean empty_line(const gchar *line);
 static gint64 cosine_seek_next_packet(wtap *wth, int *err, gchar **err_info,
        char *hdr);
 static gboolean cosine_check_file_type(wtap *wth, int *err, gchar **err_info);
-static int cosine_read(wtap *wth, int *err, gchar **err_info,
+static gboolean cosine_read(wtap *wth, int *err, gchar **err_info,
        gint64 *data_offset);
-static int cosine_seek_read(wtap *wth, gint64 seek_off,
+static gboolean cosine_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static int parse_cosine_rec_hdr(struct wtap_pkthdr *phdr, const char *line,
        int *err, gchar **err_info);
-static int parse_cosine_hex_dump(FILE_T fh, struct wtap_pkthdr *phdr,
+static gboolean parse_cosine_hex_dump(FILE_T fh, struct wtap_pkthdr *phdr,
        int pkt_len, Buffer* buf, int *err, gchar **err_info);
 static int parse_single_hex_dump_line(char* rec, guint8 *buf,
        guint byte_offset);
@@ -286,7 +286,7 @@ int cosine_open(wtap *wth, int *err, gchar **err_info)
 }
 
 /* Find the next packet and parse it; called from wtap_read(). */
-static int cosine_read(wtap *wth, int *err, gchar **err_info,
+static gboolean cosine_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        gint64  offset;
@@ -296,13 +296,13 @@ static int cosine_read(wtap *wth, int *err, gchar **err_info,
        /* Find the next packet */
        offset = cosine_seek_next_packet(wth, err, err_info, line);
        if (offset < 0)
-               return -1;
+               return FALSE;
        *data_offset = offset;
 
        /* Parse the header */
        pkt_len = parse_cosine_rec_hdr(&wth->phdr, line, err, err_info);
        if (pkt_len == -1)
-               return -1;
+               return FALSE;
 
        /* Convert the ASCII hex dump to binary data */
        return parse_cosine_hex_dump(wth->fh, &wth->phdr, pkt_len,
@@ -310,7 +310,7 @@ static int cosine_read(wtap *wth, int *err, gchar **err_info,
 }
 
 /* Used to read packets in random-access fashion */
-static int
+static gboolean
 cosine_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
        Buffer *buf, int *err, gchar **err_info)
 {
@@ -435,9 +435,9 @@ parse_cosine_rec_hdr(struct wtap_pkthdr *phdr, const char *line,
        return pkt_len;
 }
 
-/* Converts ASCII hex dump to binary data. Returns REC_TYPE_PACKET on success,
-   -1 if any error is encountered. */
-static int
+/* Converts ASCII hex dump to binary data. Returns TRUE on success,
+   FALSE if any error is encountered. */
+static gboolean
 parse_cosine_hex_dump(FILE_T fh, struct wtap_pkthdr *phdr, int pkt_len,
     Buffer* buf, int *err, gchar **err_info)
 {
@@ -459,7 +459,7 @@ parse_cosine_hex_dump(FILE_T fh, struct wtap_pkthdr *phdr, int pkt_len,
                        if (*err == 0) {
                                *err = WTAP_ERR_SHORT_READ;
                        }
-                       return -1;
+                       return FALSE;
                }
                if (empty_line(line)) {
                        break;
@@ -467,12 +467,12 @@ parse_cosine_hex_dump(FILE_T fh, struct wtap_pkthdr *phdr, int pkt_len,
                if ((n = parse_single_hex_dump_line(line, pd, i*16)) == -1) {
                        *err = WTAP_ERR_BAD_FILE;
                        *err_info = g_strdup("cosine: hex dump line doesn't have 16 numbers");
-                       return -1;
+                       return FALSE;
                }
                caplen += n;
        }
        phdr->caplen = caplen;
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
 
index 7145b62749df0b1cac3d8b9697ce597f7ff1f4a1..bc640f639d1e87d794d18b6b0e29c38e05d2ebc6 100644 (file)
@@ -44,9 +44,9 @@ typedef struct {
        gboolean byteswapped;
 } csids_t;
 
-static int csids_read(wtap *wth, int *err, gchar **err_info,
+static gboolean csids_read(wtap *wth, int *err, gchar **err_info,
        gint64 *data_offset);
-static int csids_seek_read(wtap *wth, gint64 seek_off,
+static gboolean csids_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static gboolean csids_read_packet(FILE_T fh, csids_t *csids,
        struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
@@ -144,21 +144,19 @@ int csids_open(wtap *wth, int *err, gchar **err_info)
 }
 
 /* Find the next packet and parse it; called from wtap_read(). */
-static int csids_read(wtap *wth, int *err, gchar **err_info,
+static gboolean csids_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
   csids_t *csids = (csids_t *)wth->priv;
 
   *data_offset = file_tell(wth->fh);
 
-  if (!csids_read_packet( wth->fh, csids, &wth->phdr, wth->frame_buffer,
-                          err, err_info ))
-    return -1;
-  return REC_TYPE_PACKET;
+  return csids_read_packet( wth->fh, csids, &wth->phdr, wth->frame_buffer,
+                            err, err_info );
 }
 
 /* Used to read packets in random-access fashion */
-static int
+static gboolean
 csids_seek_read(wtap *wth,
                 gint64 seek_off,
                 struct wtap_pkthdr *phdr,
@@ -169,14 +167,14 @@ csids_seek_read(wtap *wth,
   csids_t *csids = (csids_t *)wth->priv;
 
   if( file_seek( wth->random_fh, seek_off, SEEK_SET, err ) == -1 )
-    return -1;
+    return FALSE;
 
   if( !csids_read_packet( wth->random_fh, csids, phdr, buf, err, err_info ) ) {
     if( *err == 0 )
       *err = WTAP_ERR_SHORT_READ;
-    return -1;
+    return FALSE;
   }
-  return REC_TYPE_PACKET;
+  return TRUE;
 }
 
 static gboolean
index bb25611fd887fb6a923b8a24638d09ef71ba6ba9..23785548d27d27703c84fa997fc88f89cbc96b2b 100644 (file)
@@ -77,16 +77,16 @@ static const char daintree_magic_text[] =
 
 #define COMMENT_LINE daintree_magic_text[0]
 
-static int daintree_sna_read(wtap *wth, int *err, gchar **err_info,
+static gboolean daintree_sna_read(wtap *wth, int *err, gchar **err_info,
        gint64 *data_offset);
 
-static int daintree_sna_seek_read(wtap *wth, gint64 seek_off,
+static gboolean daintree_sna_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 
 static gboolean daintree_sna_scan_header(struct wtap_pkthdr *phdr,
        char *readLine, char *readData, int *err, gchar **err_info);
 
-static int daintree_sna_process_hex_data(struct wtap_pkthdr *phdr,
+static gboolean daintree_sna_process_hex_data(struct wtap_pkthdr *phdr,
        Buffer *buf, char *readData, int *err, gchar **err_info);
 
 /* Open a file and determine if it's a Daintree file */
@@ -134,7 +134,7 @@ int daintree_sna_open(wtap *wth, int *err, gchar **err_info)
 
 /* Read the capture file sequentially
  * Wireshark scans the file with sequential reads during preview and initial display. */
-static int
+static gboolean
 daintree_sna_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
        char readLine[DAINTREE_MAX_LINE_SIZE];
@@ -147,14 +147,14 @@ daintree_sna_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
        do {
                if (file_gets(readLine, DAINTREE_MAX_LINE_SIZE, wth->fh) == NULL) {
                        *err = file_error(wth->fh, err_info);
-                       return -1; /* all done */
+                       return FALSE; /* all done */
                }
        } while (readLine[0] == COMMENT_LINE);
 
        /* parse one line of capture data */
        if (!daintree_sna_scan_header(&wth->phdr, readLine, readData,
            err, err_info))
-               return -1;
+               return FALSE;
 
        /* process packet data */
        return daintree_sna_process_hex_data(&wth->phdr, wth->frame_buffer,
@@ -163,7 +163,7 @@ daintree_sna_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 
 /* Read the capture file randomly
  * Wireshark opens the capture file for random access when displaying user-selected packets */
-static int
+static gboolean
 daintree_sna_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
        Buffer *buf, int *err, gchar **err_info)
 {
@@ -171,20 +171,20 @@ daintree_sna_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
        char readData[READDATA_BUF_SIZE];
 
        if(file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return -1;
+               return FALSE;
 
        /* It appears only file header lines start with '#', but
         * if we find any others, we toss them */
        do {
                if (file_gets(readLine, DAINTREE_MAX_LINE_SIZE, wth->random_fh) == NULL) {
                        *err = file_error(wth->random_fh, err_info);
-                       return -1; /* all done */
+                       return FALSE; /* all done */
                }
        } while (readLine[0] == COMMENT_LINE);
 
        /* parse one line of capture data */
        if (!daintree_sna_scan_header(phdr, readLine, readData, err, err_info))
-               return -1;
+               return FALSE;
 
        /* process packet data */
        return daintree_sna_process_hex_data(phdr, buf, readData, err,
@@ -226,7 +226,7 @@ daintree_sna_scan_header(struct wtap_pkthdr *phdr, char *readLine,
 /* Convert packet data from ASCII hex string to binary in place,
  * sanity-check its length against what we assume is the packet length field,
  * and copy it into a Buffer */
-static int
+static gboolean
 daintree_sna_process_hex_data(struct wtap_pkthdr *phdr, Buffer *buf,
     char *readData, int *err, gchar **err_info)
 {
@@ -242,7 +242,7 @@ daintree_sna_process_hex_data(struct wtap_pkthdr *phdr, Buffer *buf,
                if (!isxdigit((guchar)*str)) {
                        *err = WTAP_ERR_BAD_FILE;
                        *err_info = g_strdup("daintree_sna: non-hex digit in hex data");
-                       return -1;
+                       return FALSE;
                }
                if(isdigit((guchar)*str)) {
                        *p = (*str - '0') << 4;
@@ -255,7 +255,7 @@ daintree_sna_process_hex_data(struct wtap_pkthdr *phdr, Buffer *buf,
                if (!isxdigit((guchar)*str)) {
                        *err = WTAP_ERR_BAD_FILE;
                        *err_info = g_strdup("daintree_sna: non-hex digit in hex data");
-                       return -1;
+                       return FALSE;
                }
                if(isdigit((guchar)*str)) {
                        *p += *str - '0';
@@ -274,19 +274,19 @@ daintree_sna_process_hex_data(struct wtap_pkthdr *phdr, Buffer *buf,
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("daintree_sna: Only %u bytes of packet data",
                    bytes);
-               return -1;
+               return FALSE;
        }
        bytes -= FCS_LENGTH;
        if (bytes > phdr->len) {
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("daintree_sna: capture length (%u) > packet length (%u)",
                    bytes, phdr->len);
-               return -1;
+               return FALSE;
        }
 
        phdr->caplen = bytes;
 
        buffer_assure_space(buf, bytes);
        memcpy(buffer_start_ptr(buf), readData, bytes);
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
index 31fa9af6306a76e8379e5482cc8ea93b08654865..0a3e9f57e12e110cdceb14b9e916c5d8e58cff82 100644 (file)
@@ -84,11 +84,11 @@ static const char dbs_etherwatch_rec_magic[]  =
  */
 #define DBS_ETHERWATCH_MAX_PACKET_LEN  16384
 
-static int dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
+static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
        gint64 *data_offset);
-static int dbs_etherwatch_seek_read(wtap *wth, gint64 seek_off,
+static gboolean dbs_etherwatch_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
-static int parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh,
+static gboolean parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh,
        Buffer* buf, int *err, gchar **err_info);
 static guint parse_single_hex_dump_line(char* rec, guint8 *buf,
        int byte_offset);
@@ -196,7 +196,7 @@ int dbs_etherwatch_open(wtap *wth, int *err, gchar **err_info)
 }
 
 /* Find the next packet and parse it; called from wtap_read(). */
-static int dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
+static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        gint64  offset;
@@ -204,7 +204,7 @@ static int dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
        /* Find the next packet */
        offset = dbs_etherwatch_seek_next_packet(wth, err, err_info);
        if (offset < 1)
-               return -1;
+               return FALSE;
        *data_offset = offset;
 
        /* Parse the packet */
@@ -213,12 +213,12 @@ static int dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
 }
 
 /* Used to read packets in random-access fashion */
-static int
+static gboolean
 dbs_etherwatch_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1)
-               return -1;
+               return FALSE;
 
        return parse_dbs_etherwatch_packet(phdr, wth->random_fh, buf, err,
            err_info);
@@ -268,7 +268,7 @@ unnumbered. Unnumbered has length 1, numbered 2.
 */
 #define CTL_UNNUMB_MASK                0x03
 #define CTL_UNNUMB_VALUE       0x03
-static int
+static gboolean
 parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
     int *err, gchar **err_info)
 {
@@ -298,7 +298,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
                if (*err == 0) {
                        *err = WTAP_ERR_SHORT_READ;
                }
-               return -1;
+               return FALSE;
        }
 
        /* Get the destination address */
@@ -306,14 +306,14 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
        if(!p) {
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup("dbs_etherwatch: destination address not found");
-               return -1;
+               return FALSE;
        }
        p += strlen(DEST_MAC_PREFIX);
        if(parse_hex_dump(p, &pd[eth_hdr_len], HEX_HDR_SPR, HEX_HDR_END)
                                != MAC_ADDR_LENGTH) {
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup("dbs_etherwatch: destination address not valid");
-               return -1;
+               return FALSE;
        }
        eth_hdr_len += MAC_ADDR_LENGTH;
 
@@ -331,7 +331,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
                HEX_HDR_END) != MAC_ADDR_LENGTH) {
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup("dbs_etherwatch: source address not valid");
-               return -1;
+               return FALSE;
        }
        eth_hdr_len += MAC_ADDR_LENGTH;
 
@@ -341,14 +341,14 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
                if (*err == 0) {
                        *err = WTAP_ERR_SHORT_READ;
                }
-               return -1;
+               return FALSE;
        }
 
        /* Check the lines is as least as long as the length position */
        if(strlen(line) < LENGTH_POS) {
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup("dbs_etherwatch: line too short");
-               return -1;
+               return FALSE;
        }
 
        num_items_scanned = sscanf(line + LENGTH_POS,
@@ -361,7 +361,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
        if (num_items_scanned != 8) {
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup("dbs_etherwatch: header line not valid");
-               return -1;
+               return FALSE;
        }
 
        /* Determine whether it is Ethernet II or IEEE 802 */
@@ -373,7 +373,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
                                        HEX_HDR_END) != PROTOCOL_LENGTH) {
                        *err = WTAP_ERR_BAD_FILE;
                        *err_info = g_strdup("dbs_etherwatch: Ethernet II protocol value not valid");
-                       return -1;
+                       return FALSE;
                }
                eth_hdr_len += PROTOCOL_LENGTH;
        } else {
@@ -389,7 +389,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
                                        HEX_HDR_END) != SAP_LENGTH) {
                        *err = WTAP_ERR_BAD_FILE;
                        *err_info = g_strdup("dbs_etherwatch: 802.2 DSAP+SSAP value not valid");
-                       return -1;
+                       return FALSE;
                }
                eth_hdr_len += SAP_LENGTH;
                /* Get the (first part of the) control field */
@@ -397,7 +397,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
                                        HEX_HDR_END) != CTL_UNNUMB_LENGTH) {
                        *err = WTAP_ERR_BAD_FILE;
                        *err_info = g_strdup("dbs_etherwatch: 802.2 control field first part not valid");
-                       return -1;
+                       return FALSE;
                }
                /* Determine whether the control is numbered, and thus longer */
                if((pd[eth_hdr_len] & CTL_UNNUMB_MASK) != CTL_UNNUMB_VALUE) {
@@ -407,7 +407,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
                                                HEX_HDR_SPR) != CTL_NUMB_LENGTH - CTL_UNNUMB_LENGTH) {
                                *err = WTAP_ERR_BAD_FILE;
                                *err_info = g_strdup("dbs_etherwatch: 802.2 control field second part value not valid");
-                               return -1;
+                               return FALSE;
                        }
                        eth_hdr_len += CTL_NUMB_LENGTH;
                } else {
@@ -421,7 +421,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
                                                HEX_PID_END) != PID_LENGTH) {
                                *err = WTAP_ERR_BAD_FILE;
                                *err_info = g_strdup("dbs_etherwatch: 802.2 PID value not valid");
-                               return -1;
+                               return FALSE;
                        }
                        eth_hdr_len += PID_LENGTH;
                }
@@ -457,22 +457,22 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
                        if (*err == 0) {
                                *err = WTAP_ERR_SHORT_READ;
                        }
-                       return -1;
+                       return FALSE;
                }
                if (!(line_count = parse_single_hex_dump_line(line,
                                &pd[eth_hdr_len + count], count))) {
                        *err = WTAP_ERR_BAD_FILE;
                        *err_info = g_strdup("dbs_etherwatch: packet data value not valid");
-                       return -1;
+                       return FALSE;
                }
                count += line_count;
                if (count > pkt_len) {
                        *err = WTAP_ERR_BAD_FILE;
                        *err_info = g_strdup("dbs_etherwatch: packet data value has too many bytes");
-                       return -1;
+                       return FALSE;
                }
        }
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
 /* Parse a hex dump line */
index 032df310a28442184e40d7486862f130623ff208..2a0eb9103ac4d3738ad09471fc2787ae6a04e506 100644 (file)
@@ -73,9 +73,9 @@ static const char dct3trace_magic_end[]  = "</dump>";
 
 #define MAX_PACKET_LEN 23
 
-static int dct3trace_read(wtap *wth, int *err, gchar **err_info,
+static gboolean dct3trace_read(wtap *wth, int *err, gchar **err_info,
        gint64 *data_offset);
-static int dct3trace_seek_read(wtap *wth, gint64 seek_off,
+static gboolean dct3trace_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 
 /*
@@ -187,7 +187,7 @@ int dct3trace_open(wtap *wth, int *err, gchar **err_info)
 }
 
 
-static int dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr,
+static gboolean dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr,
        Buffer *buf, int *err, gchar **err_info)
 {
        char line[1024];
@@ -202,7 +202,7 @@ static int dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr,
                {
                        /* Return on end of file </dump> */
                        *err = 0;
-                       return -1;
+                       return FALSE;
                }
                else if( memcmp(dct3trace_magic_record_end, line, strlen(dct3trace_magic_record_end)) == 0 )
                {
@@ -222,14 +222,14 @@ static int dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr,
                                buffer_assure_space(buf, phdr->caplen);
                                memcpy( buffer_start_ptr(buf), databuf, phdr->caplen );
 
-                               return REC_TYPE_PACKET;
+                               return TRUE;
                        }
                        else
                        {
                                /* If not got any data return error */
                                *err = WTAP_ERR_BAD_FILE;
                                *err_info = g_strdup_printf("dct3trace: record without data");
-                               return -1;
+                               return FALSE;
                        }
                }
                else if( memcmp(dct3trace_magic_record_start, line, strlen(dct3trace_magic_record_start)) == 0 )
@@ -282,7 +282,7 @@ static int dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr,
                                {
                                        *err = WTAP_ERR_BAD_FILE;
                                        *err_info = g_strdup_printf("dct3trace: record length %d too long", phdr->caplen);
-                                       return -1;
+                                       return FALSE;
                                }
                        }
                }
@@ -322,7 +322,7 @@ static int dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr,
                        {
                                *err = WTAP_ERR_BAD_FILE;
                                *err_info = g_strdup_printf("dct3trace: record length %d too long", phdr->caplen);
-                               return -1;
+                               return FALSE;
                        }
                        len += data_len;
 
@@ -336,17 +336,17 @@ static int dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr,
        {
                *err = WTAP_ERR_SHORT_READ;
        }
-       return -1;
+       return FALSE;
 
 baddata:
        *err = WTAP_ERR_BAD_FILE;
        *err_info = g_strdup_printf("dct3trace: record missing mandatory attributes");
-       return -1;
+       return FALSE;
 }
 
 
 /* Find the next packet and parse it; called from wtap_read(). */
-static int dct3trace_read(wtap *wth, int *err, gchar **err_info,
+static gboolean dct3trace_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        *data_offset = file_tell(wth->fh);
@@ -357,12 +357,12 @@ static int dct3trace_read(wtap *wth, int *err, gchar **err_info,
 
 
 /* Used to read packets in random-access fashion */
-static int dct3trace_seek_read(wtap *wth, gint64 seek_off,
+static gboolean dct3trace_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
        {
-               return -1;
+               return FALSE;
        }
 
        return dct3trace_get_packet(wth->random_fh, phdr, buf, err, err_info);
index 3513642121806835397aabaa8bf69fc6499779c2..67b7ccab1d522087056296e12bb16c1ca3a38e84 100644 (file)
@@ -64,11 +64,11 @@ static int erf_read_header(FILE_T fh,
                            gchar **err_info,
                            guint32 *bytes_read,
                            guint32 *packet_size);
-static int erf_read(wtap *wth, int *err, gchar **err_info,
-                    gint64 *data_offset);
-static int erf_seek_read(wtap *wth, gint64 seek_off,
-                         struct wtap_pkthdr *phdr, Buffer *buf,
-                         int *err, gchar **err_info);
+static gboolean erf_read(wtap *wth, int *err, gchar **err_info,
+                         gint64 *data_offset);
+static gboolean erf_seek_read(wtap *wth, gint64 seek_off,
+                              struct wtap_pkthdr *phdr, Buffer *buf,
+                              int *err, gchar **err_info);
 
 static const struct {
   int erf_encap_value;
@@ -280,7 +280,7 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info)
 }
 
 /* Read the next packet */
-static int erf_read(wtap *wth, int *err, gchar **err_info,
+static gboolean erf_read(wtap *wth, int *err, gchar **err_info,
                          gint64 *data_offset)
 {
   erf_header_t erf_header;
@@ -292,38 +292,36 @@ static int erf_read(wtap *wth, int *err, gchar **err_info,
     if (!erf_read_header(wth->fh,
                          &wth->phdr, &erf_header,
                          err, err_info, &bytes_read, &packet_size)) {
-      return -1;
+      return FALSE;
     }
 
     if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer, packet_size,
                                 err, err_info))
-      return -1;
+      return FALSE;
 
   } while ( erf_header.type == ERF_TYPE_PAD );
 
-  return REC_TYPE_PACKET;
+  return TRUE;
 }
 
-static int erf_seek_read(wtap *wth, gint64 seek_off,
-                         struct wtap_pkthdr *phdr, Buffer *buf,
-                         int *err, gchar **err_info)
+static gboolean erf_seek_read(wtap *wth, gint64 seek_off,
+                              struct wtap_pkthdr *phdr, Buffer *buf,
+                              int *err, gchar **err_info)
 {
   erf_header_t erf_header;
   guint32      packet_size;
 
   if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-    return -1;
+    return FALSE;
 
   do {
     if (!erf_read_header(wth->random_fh, phdr, &erf_header,
                          err, err_info, NULL, &packet_size))
-      return -1;
+      return FALSE;
   } while ( erf_header.type == ERF_TYPE_PAD );
 
-  if (!wtap_read_packet_bytes(wth->random_fh, buf, packet_size,
-                              err, err_info))
-    return -1;
-  return REC_TYPE_PACKET;
+  return wtap_read_packet_bytes(wth->random_fh, buf, packet_size,
+                                err, err_info);
 }
 
 static int erf_read_header(FILE_T fh,
index 4444b0d9f5df5b2cfc51471f717318ca7fd2aa26..8bd32c224970cb4607d404147965f4de12526539 100644 (file)
@@ -90,9 +90,9 @@ static const unsigned char eyesdn_hdr_magic[]  =
  */
 #define EYESDN_MAX_PACKET_LEN  16384
 
-static int eyesdn_read(wtap *wth, int *err, gchar **err_info,
+static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info,
        gint64 *data_offset);
-static int eyesdn_seek_read(wtap *wth, gint64 seek_off,
+static gboolean eyesdn_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static int read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer* buf,
        int *err, gchar **err_info);
@@ -149,7 +149,7 @@ int eyesdn_open(wtap *wth, int *err, gchar **err_info)
 }
 
 /* Find the next packet and parse it; called from wtap_read(). */
-static int eyesdn_read(wtap *wth, int *err, gchar **err_info,
+static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        gint64  offset;
@@ -157,7 +157,7 @@ static int eyesdn_read(wtap *wth, int *err, gchar **err_info,
        /* Find the next record */
        offset = eyesdn_seek_next_packet(wth, err, err_info);
        if (offset < 1)
-               return -1;
+               return FALSE;
        *data_offset = offset;
 
        /* Parse the record */
@@ -166,18 +166,18 @@ static int eyesdn_read(wtap *wth, int *err, gchar **err_info,
 }
 
 /* Used to read packets in random-access fashion */
-static int
+static gboolean
 eyesdn_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
        Buffer *buf, int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return -1;
+               return FALSE;
 
        return read_eyesdn_rec(wth->random_fh, phdr, buf, err, err_info);
 }
 
 /* Parses a record. */
-static int
+static gboolean
 read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err,
     gchar **err_info)
 {
@@ -198,7 +198,7 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err,
                *err = file_error(fh, err_info);
                if (*err == 0)
                        *err = WTAP_ERR_SHORT_READ;
-               return -1;
+               return FALSE;
        }
 
         /* extract information from header */
@@ -251,7 +251,7 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err,
                        *err_info = g_strdup_printf(
                            "eyesdn: ATM cell has a length != 53 (%u)",
                            pkt_len);
-                       return -1;
+                       return FALSE;
                }
 
                cur_off = file_tell(fh);
@@ -259,10 +259,10 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err,
                        *err = file_error(fh, err_info);
                        if (*err == 0)
                                *err = WTAP_ERR_SHORT_READ;
-                       return -1;
+                       return FALSE;
                }
                if (file_seek(fh, cur_off, SEEK_SET, err) == -1)
-                       return -1;
+                       return FALSE;
                phdr->pkt_encap = WTAP_ENCAP_ATM_PDUS_UNTRUNCATED;
                pseudo_header->atm.flags=ATM_RAW_CELL;
                pseudo_header->atm.aal=AAL_UNKNOWN;
@@ -310,7 +310,7 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err,
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("eyesdn: File has %u-byte packet, bigger than maximum of %u",
                    pkt_len, EYESDN_MAX_PACKET_LEN);
-               return -1;
+               return FALSE;
        }
 
        phdr->presence_flags = WTAP_HAS_TS;
@@ -335,9 +335,9 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err,
                        *err_info = g_strdup("eyesdn: No flag character seen in frame");
                } else
                        *err = WTAP_ERR_SHORT_READ;
-               return -1;
+               return FALSE;
        }
-       return REC_TYPE_PACKET;;
+       return TRUE;
 }
 
 
index 22483b7d6ad123f5a595a98d820dfd5157c67eb4..cc38a621544104ee802c7cb586b6eba8bb19d22f 100644 (file)
@@ -34,7 +34,7 @@ struct dump_hdr {
 
 #define DUMP_HDR_SIZE (sizeof(struct dump_hdr))
 
-static int hcidump_process_packet(FILE_T fh, struct wtap_pkthdr *phdr,
+static gboolean hcidump_process_packet(FILE_T fh, struct wtap_pkthdr *phdr,
     Buffer *buf, int *err, gchar **err_info)
 {
        struct dump_hdr dh;
@@ -45,7 +45,7 @@ static int hcidump_process_packet(FILE_T fh, struct wtap_pkthdr *phdr,
                *err = file_error(fh, err_info);
                if (*err == 0 && bytes_read != 0)
                        *err = WTAP_ERR_SHORT_READ;
-               return -1;
+               return FALSE;
        }
 
        packet_size = GUINT16_FROM_LE(dh.len);
@@ -57,7 +57,7 @@ static int hcidump_process_packet(FILE_T fh, struct wtap_pkthdr *phdr,
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("hcidump: File has %u-byte packet, bigger than maximum of %u",
                        packet_size, WTAP_MAX_PACKET_SIZE);
-               return -1;
+               return FALSE;
        }
 
        phdr->presence_flags = WTAP_HAS_TS;
@@ -68,12 +68,10 @@ static int hcidump_process_packet(FILE_T fh, struct wtap_pkthdr *phdr,
 
        phdr->pseudo_header.p2p.sent = (dh.in ? FALSE : TRUE);
 
-       if (!wtap_read_packet_bytes(fh, buf, packet_size, err, err_info))
-               return -1;
-       return REC_TYPE_PACKET;
+       return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
 }
 
-static int hcidump_read(wtap *wth, int *err, gchar **err_info,
+static gboolean hcidump_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        *data_offset = file_tell(wth->fh);
@@ -82,11 +80,11 @@ static int hcidump_read(wtap *wth, int *err, gchar **err_info,
            err, err_info);
 }
 
-static int hcidump_seek_read(wtap *wth, gint64 seek_off,
+static gboolean hcidump_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return -1;
+               return FALSE;
 
        return hcidump_process_packet(wth->random_fh, phdr, buf, err, err_info);
 }
index 00cf9e876c0fd7ea59ea220da115ee7f779ff4b2..d474ec2c8f9e8d66b808ddcc84ecce1d13bc362e 100644 (file)
@@ -33,11 +33,11 @@ typedef struct {
        gboolean byte_swapped;
 } i4btrace_t;
 
-static int i4btrace_read(wtap *wth, int *err, gchar **err_info,
+static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static int i4btrace_seek_read(wtap *wth, gint64 seek_off,
+static gboolean i4btrace_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
-static gboolean i4b_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
+static int i4b_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
     Buffer *buf, int *err, gchar **err_info);
 
 /*
@@ -110,23 +110,21 @@ int i4btrace_open(wtap *wth, int *err, gchar **err_info)
 }
 
 /* Read the next packet */
-static int i4btrace_read(wtap *wth, int *err, gchar **err_info,
+static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        *data_offset = file_tell(wth->fh);
 
-       if (!i4b_read_rec(wth, wth->fh, &wth->phdr, wth->frame_buffer,
-           err, err_info))
-               return -1;
-       return REC_TYPE_PACKET;
+       return i4b_read_rec(wth, wth->fh, &wth->phdr, wth->frame_buffer,
+           err, err_info);
 }
 
-static int
+static gboolean
 i4btrace_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
     Buffer *buf, int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return -1;
+               return FALSE;
 
        if (!i4b_read_rec(wth, wth->random_fh, phdr, buf, err, err_info)) {
                /* Read error or EOF */
@@ -134,12 +132,12 @@ i4btrace_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
                        /* EOF means "short read" in random-access mode */
                        *err = WTAP_ERR_SHORT_READ;
                }
-               return -1;
+               return FALSE;
        }
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
-static gboolean
+static int
 i4b_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
     int *err, gchar **err_info)
 {
index 87de43359991eef0a7c6a93befea81f97d863da8..061a53d79cd41b47a6ff512666c826606b3bc234 100644 (file)
 
 #define RECORDS_FOR_IPFIX_CHECK 20
 
-static int
+static gboolean
 ipfix_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static int
+static gboolean
 ipfix_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static void
@@ -280,7 +280,7 @@ ipfix_open(wtap *wth, int *err, gchar **err_info)
 
 
 /* classic wtap: read packet */
-static int
+static gboolean
 ipfix_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
     *data_offset = file_tell(wth->fh);
@@ -289,15 +289,15 @@ ipfix_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
     if (!ipfix_read_message(wth->fh, &wth->phdr, wth->frame_buffer, err, err_info)) {
         ipfix_debug2("ipfix_read: couldn't read message header with code: %d\n, and error '%s'",
                      *err, *err_info);
-        return -1;
+        return FALSE;
     }
 
-    return REC_TYPE_PACKET;
+    return TRUE;
 }
 
 
 /* classic wtap: seek to file position and read packet */
-static int
+static gboolean
 ipfix_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
     Buffer *buf, int *err, gchar **err_info)
 {
@@ -305,7 +305,7 @@ ipfix_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
     if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) {
         ipfix_debug2("ipfix_seek_read: couldn't read message header with code: %d\n, and error '%s'",
                      *err, *err_info);
-        return -1;   /* Seek error */
+        return FALSE;   /* Seek error */
     }
 
     ipfix_debug1("ipfix_seek_read: reading at offset %" G_GINT64_MODIFIER "u", seek_off);
@@ -314,9 +314,9 @@ ipfix_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
         ipfix_debug0("ipfix_seek_read: couldn't read message header");
         if (*err == 0)
             *err = WTAP_ERR_SHORT_READ;
-        return -1;
+        return FALSE;
     }
-    return REC_TYPE_PACKET;
+    return TRUE;
 }
 
 
index 3f128fe2050ed4ff21e346cee5cbe5bbdb6f3580..67e8e65806ad4551a94fd9f2a01604a8a72c6195 100644 (file)
@@ -214,7 +214,7 @@ iptrace_read_rec_1_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
 }
 
 /* Read the next packet */
-static int iptrace_read_1_0(wtap *wth, int *err, gchar **err_info,
+static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        *data_offset = file_tell(wth->fh);
@@ -223,7 +223,7 @@ static int iptrace_read_1_0(wtap *wth, int *err, gchar **err_info,
        if (!iptrace_read_rec_1_0(wth->fh, &wth->phdr, wth->frame_buffer,
            err, err_info)) {
                /* Read error or EOF */
-               return -1;
+               return FALSE;
        }
 
        /* If the per-file encapsulation isn't known, set it to this
@@ -239,22 +239,22 @@ static int iptrace_read_1_0(wtap *wth, int *err, gchar **err_info,
                        wth->file_encap = WTAP_ENCAP_PER_PACKET;
        }
 
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
-static int iptrace_seek_read_1_0(wtap *wth, gint64 seek_off,
+static gboolean iptrace_seek_read_1_0(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return -1;
+               return FALSE;
 
        /* Read the packet */
        if (!iptrace_read_rec_1_0(wth->random_fh, phdr, buf, err, err_info)) {
                if (*err == 0)
                        *err = WTAP_ERR_SHORT_READ;
-               return -1;
+               return FALSE;
        }
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
 /***********************************************************
@@ -409,7 +409,7 @@ iptrace_read_rec_2_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
 }
 
 /* Read the next packet */
-static int iptrace_read_2_0(wtap *wth, int *err, gchar **err_info,
+static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        *data_offset = file_tell(wth->fh);
@@ -418,7 +418,7 @@ static int iptrace_read_2_0(wtap *wth, int *err, gchar **err_info,
        if (!iptrace_read_rec_2_0(wth->fh, &wth->phdr, wth->frame_buffer,
            err, err_info)) {
                /* Read error or EOF */
-               return -1;
+               return FALSE;
        }
 
        /* If the per-file encapsulation isn't known, set it to this
@@ -434,22 +434,22 @@ static int iptrace_read_2_0(wtap *wth, int *err, gchar **err_info,
                        wth->file_encap = WTAP_ENCAP_PER_PACKET;
        }
 
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
-static int iptrace_seek_read_2_0(wtap *wth, gint64 seek_off,
+static gboolean iptrace_seek_read_2_0(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return -1;
+               return FALSE;
 
        /* Read the packet */
        if (!iptrace_read_rec_2_0(wth->random_fh, phdr, buf, err, err_info)) {
                if (*err == 0)
                        *err = WTAP_ERR_SHORT_READ;
-               return -1;
+               return FALSE;
        }
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
 static int
index 4c42fb45020abd25b7eb9a7cb4344b638f0734d4..0a171a63410cce8ca7cf18714534e23090370bb1 100644 (file)
@@ -187,9 +187,9 @@ static gboolean iseries_seek_read (wtap * wth, gint64 seek_off,
 static gboolean iseries_check_file_type (wtap * wth, int *err, gchar **err_info,
                                          int format);
 static gint64 iseries_seek_next_packet (wtap * wth, int *err, gchar **err_info);
-static int iseries_parse_packet (wtap * wth, FILE_T fh,
-                                 struct wtap_pkthdr *phdr,
-                                 Buffer * buf, int *err, gchar ** err_info);
+static gboolean iseries_parse_packet (wtap * wth, FILE_T fh,
+                                      struct wtap_pkthdr *phdr,
+                                      Buffer * buf, int *err, gchar ** err_info);
 static int iseries_UNICODE_to_ASCII (guint8 * buf, guint bytes);
 static gboolean iseries_parse_hex_string (const char * ascii, guint8 * buf,
                                           size_t len);
@@ -370,7 +370,7 @@ iseries_check_file_type (wtap * wth, int *err, gchar **err_info, int format)
 /*
  * Find the next packet and parse it; called from wtap_read().
  */
-static int
+static gboolean
 iseries_read (wtap * wth, int *err, gchar ** err_info, gint64 *data_offset)
 {
   gint64 offset;
@@ -457,14 +457,14 @@ iseries_seek_next_packet (wtap * wth, int *err, gchar **err_info)
 /*
  * Read packets in random-access fashion
  */
-static int
+static gboolean
 iseries_seek_read (wtap * wth, gint64 seek_off, struct wtap_pkthdr *phdr,
                    Buffer * buf, int *err, gchar ** err_info)
 {
 
   /* seek to packet location */
   if (file_seek (wth->random_fh, seek_off - 1, SEEK_SET, err) == -1)
-    return -1;
+    return FALSE;
 
   /*
    * Parse the packet and extract the various fields
@@ -554,7 +554,7 @@ done:
 }
 
 /* Parses a packet. */
-static int
+static gboolean
 iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr,
                       Buffer *buf, int *err, gchar **err_info)
 {
@@ -581,7 +581,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr,
       if (file_gets (data, ISERIES_LINE_LENGTH, fh) == NULL)
         {
           *err = file_error (fh, err_info);
-          return -1;
+          return FALSE;
         }
       /* Convert UNICODE data to ASCII */
       if (iseries->format == ISERIES_FORMAT_UNICODE)
@@ -615,7 +615,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr,
     {
       *err = WTAP_ERR_BAD_FILE;
       *err_info = g_strdup ("iseries: packet header isn't valid");
-      return -1;
+      return FALSE;
     }
 
   phdr->presence_flags = WTAP_HAS_CAP_LEN;
@@ -747,7 +747,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr,
               if (ascii_offset == -1)
                 {
                   /* Bad line. */
-                  return -1;
+                  return FALSE;
                 }
               continue;
             }
@@ -769,7 +769,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr,
               if (ascii_offset == -1)
                 {
                   /* Bad line. */
-                  return -1;
+                  return FALSE;
                 }
               continue;
             }
@@ -792,7 +792,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr,
           if (ascii_offset == -1)
             {
               /* Bad line. */
-              return -1;
+              return FALSE;
             }
           continue;
         }
@@ -842,11 +842,11 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr,
   /* free buffer allocs and return */
   *err = 0;
   g_free (ascii_buf);
-  return REC_TYPE_PACKET;
+  return TRUE;
 
 errxit:
   g_free (ascii_buf);
-  return -1;
+  return FALSE;
 }
 
 /*
index 013c19e6f672d2ee990d628087305b17d67e3506..cd1bbe61041dd9dee11e44a103893806f12b47dc 100644 (file)
@@ -623,7 +623,7 @@ process_packet_data(struct wtap_pkthdr *phdr, Buffer *target, guint8 *buffer,
     phdr->pseudo_header.k12.stuff = k12;
 }
 
-static int k12_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) {
+static gboolean k12_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) {
     k12_t *k12 = (k12_t *)wth->priv;
     k12_src_desc_t* src_desc;
     guint8* buffer;
@@ -644,16 +644,16 @@ static int k12_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 
         if (len < 0) {
             /* read error */
-            return -1;
+            return FALSE;
         } else if (len == 0) {
             /* EOF */
             *err = 0;
-            return -1;
+            return FALSE;
         } else if (len < K12_RECORD_SRC_ID + 4) {
             /* Record not large enough to contain a src ID */
             *err = WTAP_ERR_BAD_FILE;
             *err_info = g_strdup_printf("data record length %d too short", len);
-            return -1;
+            return FALSE;
         }
 
         buffer = k12->seq_read_buff;
@@ -681,11 +681,11 @@ static int k12_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 
     process_packet_data(&wth->phdr, wth->frame_buffer, buffer, len, k12);
 
-    return REC_TYPE_PACKET;
+    return TRUE;
 }
 
 
-static int k12_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) {
+static gboolean k12_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) {
     k12_t *k12 = (k12_t *)wth->priv;
     guint8* buffer;
     gint len;
@@ -694,18 +694,18 @@ static int k12_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, B
 
     if ( file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) {
         K12_DBG(5,("k12_seek_read: SEEK ERROR"));
-        return -1;
+        return FALSE;
     }
 
     len = get_record(k12, wth->random_fh, seek_off, TRUE, err, err_info);
     if (len < 0) {
         K12_DBG(5,("k12_seek_read: READ ERROR"));
-        return -1;
+        return FALSE;
     } else if (len < K12_RECORD_SRC_ID + 4) {
         /* Record not large enough to contain a src ID */
         K12_DBG(5,("k12_seek_read: SHORT READ"));
         *err = WTAP_ERR_SHORT_READ;
-        return -1;
+        return FALSE;
     }
 
     buffer = k12->rand_read_buff;
@@ -714,7 +714,7 @@ static int k12_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, B
 
     K12_DBG(5,("k12_seek_read: DONE OK"));
 
-    return REC_TYPE_PACKET;
+    return TRUE;
 }
 
 
index 8db5c673c8a69704fbef13a088c089660e387ac9..42de8e68756ec3ee4314e83e59277b2f28bd35f3 100644 (file)
@@ -244,7 +244,7 @@ k12text_reset(FILE_T fh)
        ii=0;
 }
 
-static int
+static gboolean
 k12text_read(wtap *wth, int *err, char ** err_info, gint64 *data_offset)
 {
        k12text_t *k12text = (k12text_t *)wth->priv;
@@ -259,7 +259,7 @@ k12text_read(wtap *wth, int *err, char ** err_info, gint64 *data_offset)
         */
 
        if ( file_seek(wth->fh, k12text->next_frame_offset, SEEK_SET, err) == -1) {
-               return -1;
+               return FALSE;
        }
        k12text_reset(wth->fh);         /* init lexer buffer and vars set by lexer */
 
@@ -274,7 +274,7 @@ k12text_read(wtap *wth, int *err, char ** err_info, gint64 *data_offset)
                        *err = WTAP_ERR_BAD_FILE;
                        *err_info = error_str;
                }
-               return -1;
+               return FALSE;
        }
 
        *data_offset = k12text->next_frame_offset;       /* file position for beginning of this frame   */
@@ -285,14 +285,14 @@ k12text_read(wtap *wth, int *err, char ** err_info, gint64 *data_offset)
        buffer_assure_space(wth->frame_buffer, wth->phdr.caplen);
        memcpy(buffer_start_ptr(wth->frame_buffer), bb, wth->phdr.caplen);
 
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
-static int
+static gboolean
 k12text_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, char **err_info)
 {
        if ( file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) {
-               return -1;
+               return FALSE;
        }
        k12text_reset(wth->random_fh);          /* init lexer buffer and vars set by lexer */
 
@@ -307,7 +307,7 @@ k12text_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *
                } else {
                        *err_info = error_str;
                }
-               return -1;
+               return FALSE;
        }
 
        k12text_set_headers(phdr);
@@ -315,7 +315,7 @@ k12text_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *
        buffer_assure_space(buf, phdr->caplen);
        memcpy(buffer_start_ptr(buf), bb, phdr->caplen);
 
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
 int
index 5c4942b10ec7c951067ff8fb3c0db0dfec09e32f..8c2ce348a1426bebd2977cf5266c0f87183ea7f8 100644 (file)
@@ -270,9 +270,9 @@ typedef struct {
        time_t  start;
 } lanalyzer_t;
 
-static int lanalyzer_read(wtap *wth, int *err, gchar **err_info,
+static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static int lanalyzer_seek_read(wtap *wth, gint64 seek_off,
+static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static gboolean lanalyzer_dump_close(wtap_dumper *wdh, int *err);
 
@@ -560,32 +560,30 @@ static gboolean lanalyzer_read_trace_record(wtap *wth, FILE_T fh,
 }
 
 /* Read the next packet */
-static int lanalyzer_read(wtap *wth, int *err, gchar **err_info,
+static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        *data_offset = file_tell(wth->fh);
 
        /* Read the record  */
-       if (!lanalyzer_read_trace_record(wth, wth->fh, &wth->phdr,
-           wth->frame_buffer, err, err_info))
-               return -1;
-       return REC_TYPE_PACKET;
+       return lanalyzer_read_trace_record(wth, wth->fh, &wth->phdr,
+           wth->frame_buffer, err, err_info);
 }
 
-static int lanalyzer_seek_read(wtap *wth, gint64 seek_off,
+static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return -1;
+               return FALSE;
 
        /* Read the record  */
        if (!lanalyzer_read_trace_record(wth, wth->random_fh, phdr, buf,
            err, err_info)) {
                if (*err == 0)
                        *err = WTAP_ERR_SHORT_READ;
-               return -1;
+               return FALSE;
        }
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
 /*---------------------------------------------------
index 7d467cb06c6108028feb47a15fa9fad7930a7b64..fe9c111261bb43f1732c3e1de59108a61ea6789c 100644 (file)
@@ -63,9 +63,9 @@ typedef enum {
 } libpcap_try_t;
 static libpcap_try_t libpcap_try(wtap *wth, int *err);
 
-static int libpcap_read(wtap *wth, int *err, gchar **err_info,
+static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static int libpcap_seek_read(wtap *wth, gint64 seek_off,
+static gboolean libpcap_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static int libpcap_read_header(wtap *wth, FILE_T fh, int *err, gchar **err_info,
     struct pcaprec_ss990915_hdr *hdr);
@@ -590,15 +590,13 @@ static libpcap_try_t libpcap_try(wtap *wth, int *err)
 }
 
 /* Read the next packet */
-static int libpcap_read(wtap *wth, int *err, gchar **err_info,
+static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        *data_offset = file_tell(wth->fh);
 
-       if (!libpcap_read_packet(wth, wth->fh, &wth->phdr,
-           wth->frame_buffer, err, err_info))
-               return -1;
-       return REC_TYPE_PACKET;
+       return libpcap_read_packet(wth, wth->fh, &wth->phdr,
+           wth->frame_buffer, err, err_info);
 }
 
 static gboolean
@@ -606,15 +604,15 @@ libpcap_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
     Buffer *buf, int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return -1;
+               return FALSE;
 
        if (!libpcap_read_packet(wth, wth->random_fh, phdr, buf, err,
            err_info)) {
                if (*err == 0)
                        *err = WTAP_ERR_SHORT_READ;
-               return -1;
+               return FALSE;
        }
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
 static gboolean
index 022b6a230841643dd302fb03dc2af866ebd3ae5b..a1a41c0689b0aea88010fc6a46e05838d60bb104 100644 (file)
@@ -214,31 +214,29 @@ static gboolean logcat_read_packet(struct logcat_phdr *logcat, FILE_T fh,
     return TRUE;
 }
 
-static int logcat_read(wtap *wth, int *err, gchar **err_info,
+static gboolean logcat_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
     *data_offset = file_tell(wth->fh);
 
-    if (!logcat_read_packet((struct logcat_phdr *) wth->priv, wth->fh,
-        &wth->phdr, wth->frame_buffer, err, err_info))
-        return -1;
-    return REC_TYPE_PACKET;
+    return logcat_read_packet((struct logcat_phdr *) wth->priv, wth->fh,
+        &wth->phdr, wth->frame_buffer, err, err_info);
 }
 
-static int logcat_seek_read(wtap *wth, gint64 seek_off,
+static gboolean logcat_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf,
     int *err, gchar **err_info)
 {
     if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-        return -1;
+        return FALSE;
 
     if (!logcat_read_packet((struct logcat_phdr *) wth->priv, wth->random_fh,
          phdr, buf, err, err_info)) {
         if (*err == 0)
             *err = WTAP_ERR_SHORT_READ;
-        return -1;
+        return FALSE;
     }
-    return REC_TYPE_PACKET;
+    return TRUE;
 }
 
 int logcat_open(wtap *wth, int *err, gchar **err_info _U_)
index 0f8934a28e61d4fefe41ce699d71f7d4344c7147..2a7d8be0e4eac46443a3e00ed9bc2a80981c2206 100644 (file)
@@ -94,7 +94,7 @@ static const mime_files_t magic_files[] = {
  */
 #define MAX_FILE_SIZE  (16*1024*1024)
 
-static int
+static gboolean
 mime_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
     Buffer *buf, int *err, gchar **err_info)
 {
@@ -102,7 +102,7 @@ mime_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
        int packet_size;
 
        if ((file_size = wtap_file_size(wth, err)) == -1)
-               return -1;
+               return FALSE;
 
        if (file_size > MAX_FILE_SIZE) {
                /*
@@ -112,7 +112,7 @@ mime_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("mime_file: File has %" G_GINT64_MODIFIER "d-byte packet, bigger than maximum of %u",
                                file_size, MAX_FILE_SIZE);
-               return -1;
+               return FALSE;
        }
        packet_size = (int)file_size;
 
@@ -124,12 +124,10 @@ mime_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
        phdr->ts.secs = 0;
        phdr->ts.nsecs = 0;
 
-       if (!wtap_read_packet_bytes(fh, buf, packet_size, err, err_info))
-               return -1;
-       return REC_TYPE_PACKET;
+       return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
 }
 
-static int
+static gboolean
 mime_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
        gint64 offset;
@@ -140,24 +138,24 @@ mime_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 
        /* there is only ever one packet */
        if (offset != 0)
-               return -1;
+               return FALSE;
 
        *data_offset = offset;
 
        return mime_read_file(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info);
 }
 
-static int
+static gboolean
 mime_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
        /* there is only one packet */
        if (seek_off > 0) {
                *err = 0;
-               return -1;
+               return FALSE;
        }
 
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return -1;
+               return FALSE;
 
        return mime_read_file(wth, wth->random_fh, phdr, buf, err, err_info);
 }
index 8b44a1bd4c7029de12cd4cb950c0930ef112e4b5..844fb40a1362108a9404e7d192961b8412b934a0 100644 (file)
@@ -102,7 +102,7 @@ mp2t_read_packet(mp2t_filetype_t *mp2t, FILE_T fh, gint64 offset,
     return TRUE;
 }
 
-static int
+static gboolean
 mp2t_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
     mp2t_filetype_t *mp2t;
@@ -113,27 +113,27 @@ mp2t_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 
     if (!mp2t_read_packet(mp2t, wth->fh, *data_offset, &wth->phdr,
                           wth->frame_buffer, err, err_info)) {
-        return -1;
+        return FALSE;
     }
 
     /* if there's a trailer, skip it and go to the start of the next packet */
     if (mp2t->trailer_len!=0) {
         if (-1 == file_seek(wth->fh, mp2t->trailer_len, SEEK_CUR, err)) {
-            return -1;
+            return FALSE;
         }
     }
 
-    return REC_TYPE_PACKET;
+    return TRUE;
 }
 
-static int
+static gboolean
 mp2t_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
         Buffer *buf, int *err, gchar **err_info)
 {
     mp2t_filetype_t *mp2t;
 
     if (-1 == file_seek(wth->random_fh, seek_off, SEEK_SET, err)) {
-        return -1;
+        return FALSE;
     }
 
     mp2t = (mp2t_filetype_t*) wth->priv;
@@ -142,9 +142,9 @@ mp2t_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
                           err, err_info)) {
         if (*err == 0)
             *err = WTAP_ERR_SHORT_READ;
-        return -1;
+        return FALSE;
     }
-    return REC_TYPE_PACKET;
+    return TRUE;
 }
 
 int
index 2f4998ebb3f408326b390bca32c9f99b5482f5d2..abe87a37fe19788aebc932e2b01d5fd165183ec8 100644 (file)
@@ -220,32 +220,30 @@ mpeg_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
        return TRUE;
 }
 
-static int
+static gboolean
 mpeg_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
        *data_offset = file_tell(wth->fh);
 
-       if (!mpeg_read_packet(wth, wth->fh, &wth->phdr, wth->frame_buffer,
-           FALSE, err, err_info))
-               return -1;
-       return REC_TYPE_PACKET;
+       return mpeg_read_packet(wth, wth->fh, &wth->phdr, wth->frame_buffer,
+           FALSE, err, err_info);
 }
 
-static int
+static gboolean
 mpeg_seek_read(wtap *wth, gint64 seek_off,
                struct wtap_pkthdr *phdr, Buffer *buf,
                int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return -1;
+               return FALSE;
 
        if (!mpeg_read_packet(wth, wth->random_fh, phdr, buf, TRUE, err,
            err_info)) {
                if (*err == 0)
                        *err = WTAP_ERR_SHORT_READ;
-               return -1;
+               return FALSE;
        }
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
 struct _mpeg_magic {
index 85f3234121b977919135711c1e7e31df0f340b59..f12bf43a87cd91471d5092665dd5fa6bb40ad432 100644 (file)
@@ -175,9 +175,9 @@ static const int netmon_encap[] = {
 #define NETMON_NET_DNS_CACHE           0xFFFE
 #define NETMON_NET_NETMON_FILTER       0xFFFF
 
-static int netmon_read(wtap *wth, int *err, gchar **err_info,
+static gboolean netmon_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static int netmon_seek_read(wtap *wth, gint64 seek_off,
+static gboolean netmon_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static gboolean netmon_read_atm_pseudoheader(FILE_T fh,
     union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info);
@@ -677,7 +677,7 @@ static process_trailer_retval netmon_process_rec_trailer(netmon_t *netmon,
 }
 
 /* Read the next packet */
-static int netmon_read(wtap *wth, int *err, gchar **err_info,
+static gboolean netmon_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        netmon_t *netmon = (netmon_t *)wth->priv;
@@ -691,7 +691,7 @@ again:
                g_free(netmon->frame_table);
                netmon->frame_table = NULL;
                *err = 0;       /* it's just an EOF, not an error */
-               return -1;
+               return FALSE;
        }
 
        /* Seek to the beginning of the current record, if we're
@@ -707,7 +707,7 @@ again:
        rec_offset = netmon->frame_table[netmon->current_frame];
        if (file_tell(wth->fh) != rec_offset) {
                if (file_seek(wth->fh, rec_offset, SEEK_SET, err) == -1)
-                       return -1;
+                       return FALSE;
        }
        netmon->current_frame++;
 
@@ -715,11 +715,11 @@ again:
 
        if (!netmon_process_rec_header(wth, wth->fh, &wth->phdr,
            err, err_info))
-               return -1;
+               return FALSE;
 
        if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer,
            wth->phdr.caplen, err, err_info))
-               return -1;      /* Read error */
+               return FALSE;   /* Read error */
 
        /*
         * For version 2.1 and later, there's additional information
@@ -735,33 +735,33 @@ again:
                break;
 
        case FAILURE:
-               return -1;
+               return FALSE;
        }
 
        netmon_set_pseudo_header_info(wth->phdr.pkt_encap, &wth->phdr,
            wth->frame_buffer);
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
-static int
+static gboolean
 netmon_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
        netmon_t *netmon = (netmon_t *)wth->priv;
 
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return -1;
+               return FALSE;
 
        if (!netmon_process_rec_header(wth, wth->random_fh, phdr,
            err, err_info))
-               return -1;
+               return FALSE;
 
        /*
         * Read the packet data.
         */
        if (!wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen, err,
            err_info))
-               return -1;
+               return FALSE;
 
        /*
         * For version 2.1 and later, there's additional information
@@ -776,18 +776,18 @@ netmon_seek_read(wtap *wth, gint64 seek_off,
                 */
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup("netmon: saw metadata in netmon_seek_read");
-               return -1;
+               return FALSE;
 
        case SUCCESS:
                break;
 
        case FAILURE:
-               return -1;
+               return FALSE;
        }
 
        netmon_set_pseudo_header_info(phdr->pkt_encap, phdr, buf);
 
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
 static gboolean
index 71e835a584b2dc0245f3192e675f140599f39edc..9772567ae7c724a6b1649e950a26960ed9f51099 100644 (file)
@@ -613,24 +613,24 @@ typedef struct {
 } nstrace_t;
 
 static guint32 nspm_signature_version(wtap*, gchar*, gint32);
-static int nstrace_read_v10(wtap *wth, int *err, gchar **err_info,
-                            gint64 *data_offset);
-static int nstrace_read_v20(wtap *wth, int *err, gchar **err_info,
-                            gint64 *data_offset);
-static int nstrace_read_v30(wtap *wth, int *err, gchar **err_info,
-                            gint64 *data_offset);
-static int nstrace_seek_read_v10(wtap *wth, gint64 seek_off,
-                                 struct wtap_pkthdr *phdr,
-                                 Buffer *buf,
-                                 int *err, gchar **err_info);
-static int nstrace_seek_read_v20(wtap *wth, gint64 seek_off,
-                                 struct wtap_pkthdr *phdr,
-                                 Buffer *buf,
-                                 int *err, gchar **err_info);
-static int nstrace_seek_read_v30(wtap *wth, gint64 seek_off,
-                                 struct wtap_pkthdr *phdr,
-                                 Buffer *buf,
-                                 int *err, gchar **err_info);
+static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info,
+                                 gint64 *data_offset);
+static gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info,
+                                 gint64 *data_offset);
+static gboolean nstrace_read_v30(wtap *wth, int *err, gchar **err_info,
+                                 gint64 *data_offset);
+static gboolean nstrace_seek_read_v10(wtap *wth, gint64 seek_off,
+                                      struct wtap_pkthdr *phdr,
+                                      Buffer *buf,
+                                      int *err, gchar **err_info);
+static gboolean nstrace_seek_read_v20(wtap *wth, gint64 seek_off,
+                                      struct wtap_pkthdr *phdr,
+                                      Buffer *buf,
+                                      int *err, gchar **err_info);
+static gboolean nstrace_seek_read_v30(wtap *wth, gint64 seek_off,
+                                      struct wtap_pkthdr *phdr,
+                                      Buffer *buf,
+                                      int *err, gchar **err_info);
 static void nstrace_close(wtap *wth);
 
 static gboolean nstrace_set_start_time_v10(wtap *wth);
@@ -925,7 +925,7 @@ static gboolean nstrace_set_start_time(wtap *wth)
 /*
 ** Netscaler trace format read routines.
 */
-static int nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
     nstrace_t *nstrace = (nstrace_t *)wth->priv;
     guint64 nsg_creltime = nstrace->nsg_creltime;
@@ -965,7 +965,7 @@ static int nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *data_
             nstrace->nstrace_buf_offset = nstrace_buf_offset + (phdr)->len;\
             nstrace->nstrace_buflen = nstrace_buflen;\
             nstrace->nsg_creltime = nsg_creltime;\
-            return REC_TYPE_PACKET;
+            return TRUE;
 
 #define GENERATE_CASE_PART(phdr,type,acttype) \
         case NSPR_PDPKTRACEPARTTX_V##type:\
@@ -988,7 +988,7 @@ static int nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *data_
             nstrace->nstrace_buf_offset = nstrace_buf_offset + (phdr)->caplen;\
             nstrace->nsg_creltime = nsg_creltime;\
             nstrace->nstrace_buflen = nstrace_buflen;\
-            return REC_TYPE_PACKET;\
+            return TRUE;\
 
             switch (pletoh16(&(( nspr_header_v10_t*)&nstrace_buf[nstrace_buf_offset])->ph_RecordType))
             {
@@ -1030,7 +1030,7 @@ static int nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *data_
         nstrace_buflen = GET_READ_PAGE_SIZE((nstrace->file_size - nstrace->xxx_offset));
     }while((nstrace_buflen > 0) && (bytes_read = file_read(nstrace_buf, nstrace_buflen, wth->fh)) && (bytes_read == nstrace_buflen));
 
-    return -1;
+    return FALSE;
 }
 
 #define TIMEDEFV20(fp,type) \
@@ -1112,10 +1112,10 @@ static int nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *data_
         nstrace->nstrace_buf_offset = nstrace_buf_offset + nspr_getv20recordsize((nspr_hd_v20_t *)fp);\
         nstrace->nstrace_buflen = nstrace_buflen;\
         nstrace->nsg_creltime = nsg_creltime;\
-        return REC_TYPE_PACKET;\
+        return TRUE;\
     }while(0)
 
-static int nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+static gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
     nstrace_t *nstrace = (nstrace_t *)wth->priv;
     guint64 nsg_creltime = nstrace->nsg_creltime;
@@ -1219,7 +1219,7 @@ static int nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *data_
         nstrace_buflen = GET_READ_PAGE_SIZE((nstrace->file_size - nstrace->xxx_offset));
     }while((nstrace_buflen > 0) && (bytes_read = file_read(nstrace_buf, nstrace_buflen, wth->fh)) && (bytes_read == nstrace_buflen));
 
-    return -1;
+    return FALSE;
 }
 
 #undef PACKET_DESCRIBE
@@ -1248,7 +1248,7 @@ static int nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *data_
         nstrace->xxx_offset += nstrace_buflen;\
         bytes_read = file_read(nstrace_buf, NSPR_PAGESIZE_TRACE, wth->fh);\
         if (bytes_read != NSPR_PAGESIZE_TRACE) {\
-            return -1;\
+            return FALSE;\
         } else {\
             nstrace_buf_offset = 0;\
         }\
@@ -1263,10 +1263,10 @@ static int nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *data_
     nstrace->nstrace_buf_offset = nstrace_buf_offset;\
     nstrace->nstrace_buflen = nstrace_buflen = ((gint32)NSPR_PAGESIZE_TRACE);\
     nstrace->nsg_creltime = nsg_creltime;\
-    return REC_TYPE_PACKET;\
+    return TRUE;\
 } while(0)
 
-static int nstrace_read_v30(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+static gboolean nstrace_read_v30(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
     nstrace_t *nstrace = (nstrace_t *)wth->priv;
     guint64 nsg_creltime = nstrace->nsg_creltime;
@@ -1324,12 +1324,12 @@ static int nstrace_read_v30(wtap *wth, int *err, gchar **err_info, gint64 *data_
         nstrace_buflen = NSPR_PAGESIZE_TRACE;
     } while((nstrace_buflen > 0) && (bytes_read = file_read(nstrace_buf, nstrace_buflen, wth->fh)) && (bytes_read == nstrace_buflen));
 
-    return -1;
+    return FALSE;
 }
 
 #undef PACKET_DESCRIBE
 
-static int nstrace_seek_read_v10(wtap *wth, gint64 seek_off,
+static gboolean nstrace_seek_read_v10(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
     nspr_hd_v10_t hdr;
@@ -1343,7 +1343,7 @@ static int nstrace_seek_read_v10(wtap *wth, gint64 seek_off,
     *err = 0;
 
     if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-        return -1;
+        return FALSE;
 
     /*
     ** Read the record header.
@@ -1353,7 +1353,7 @@ static int nstrace_seek_read_v10(wtap *wth, gint64 seek_off,
         *err = file_error(wth->random_fh, err_info);
         if (*err == 0)
             *err = WTAP_ERR_SHORT_READ;
-        return -1;
+        return FALSE;
     }
 
     /*
@@ -1374,7 +1374,7 @@ static int nstrace_seek_read_v10(wtap *wth, gint64 seek_off,
             *err = file_error(wth->random_fh, err_info);
             if (*err == 0)
                 *err = WTAP_ERR_SHORT_READ;
-            return -1;
+            return FALSE;
         }
     }
 
@@ -1408,7 +1408,7 @@ static int nstrace_seek_read_v10(wtap *wth, gint64 seek_off,
 #undef GENERATE_CASE_FULL
 #undef GENERATE_CASE_PART
 
-    return REC_TYPE_PACKET;
+    return TRUE;
 }
 
 #define PACKET_DESCRIBE(phdr,FPTIMEDEF,SIZEDEF,ver,enumprefix,type,structname,TYPE)\
@@ -1417,10 +1417,10 @@ static int nstrace_seek_read_v10(wtap *wth, gint64 seek_off,
         SIZEDEF##ver((phdr),fp,ver);\
         TRACE_V##ver##_REC_LEN_OFF((phdr),enumprefix,type,structname);\
         (phdr)->pseudo_header.nstr.rec_type = NSPR_HEADER_VERSION##TYPE;\
-        return REC_TYPE_PACKET;\
+        return TRUE;\
     }while(0)
 
-static int nstrace_seek_read_v20(wtap *wth, gint64 seek_off,
+static gboolean nstrace_seek_read_v20(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
     nspr_hd_v20_t hdr;
@@ -1433,7 +1433,7 @@ static int nstrace_seek_read_v20(wtap *wth, gint64 seek_off,
     *err = 0;
 
     if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-        return -1;
+        return FALSE;
 
     /*
     ** Read the first 2 bytes of the record header.
@@ -1443,7 +1443,7 @@ static int nstrace_seek_read_v20(wtap *wth, gint64 seek_off,
         *err = file_error(wth->random_fh, err_info);
         if (*err == 0)
             *err = WTAP_ERR_SHORT_READ;
-        return -1;
+        return FALSE;
     }
     hdrlen = 2;
 
@@ -1456,7 +1456,7 @@ static int nstrace_seek_read_v20(wtap *wth, gint64 seek_off,
             *err = file_error(wth->random_fh, err_info);
             if (*err == 0)
                 *err = WTAP_ERR_SHORT_READ;
-            return -1;
+            return FALSE;
         }
         hdrlen = 3;
     }
@@ -1479,7 +1479,7 @@ static int nstrace_seek_read_v20(wtap *wth, gint64 seek_off,
             *err = file_error(wth->random_fh, err_info);
             if (*err == 0)
                 *err = WTAP_ERR_SHORT_READ;
-            return -1;
+            return FALSE;
         }
     }
 
@@ -1532,11 +1532,11 @@ static int nstrace_seek_read_v20(wtap *wth, gint64 seek_off,
 #undef GENERATE_CASE_PART
 #undef GENERATE_CASE_PART_V25
 
-    return REC_TYPE_PACKET;
+    return TRUE;
 }
 
 
-static int nstrace_seek_read_v30(wtap *wth, gint64 seek_off,
+static gboolean nstrace_seek_read_v30(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
     nspr_hd_v20_t hdr;
@@ -1549,7 +1549,7 @@ static int nstrace_seek_read_v30(wtap *wth, gint64 seek_off,
     *err = 0;
 
     if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-        return -1;
+        return FALSE;
     /*
     ** Read the first 2 bytes of the record header.
     */
@@ -1558,7 +1558,7 @@ static int nstrace_seek_read_v30(wtap *wth, gint64 seek_off,
         *err = file_error(wth->random_fh, err_info);
         if (*err == 0)
             *err = WTAP_ERR_SHORT_READ;
-        return -1;
+        return FALSE;
     }
     hdrlen = 2;
 
@@ -1571,7 +1571,7 @@ static int nstrace_seek_read_v30(wtap *wth, gint64 seek_off,
             *err = file_error(wth->random_fh, err_info);
             if (*err == 0)
                 *err = WTAP_ERR_SHORT_READ;
-            return -1;
+            return FALSE;
         }
         hdrlen = 3;
     }
@@ -1594,7 +1594,7 @@ static int nstrace_seek_read_v30(wtap *wth, gint64 seek_off,
             *err = file_error(wth->random_fh, err_info);
             if (*err == 0)
                 *err = WTAP_ERR_SHORT_READ;
-            return -1;
+            return FALSE;
         }
     }
 
@@ -1612,7 +1612,7 @@ static int nstrace_seek_read_v30(wtap *wth, gint64 seek_off,
             GENERATE_CASE_V30(phdr,30, 300);
         }
 
-    return REC_TYPE_PACKET;
+    return TRUE;
 }
 
 
index 91c82c796d07b7ac1e9733962d1bc0739060bb34..bbb4a535e96f576cf0913cdeab0ea1df864c3537 100644 (file)
@@ -67,9 +67,9 @@ static gint64 netscreen_seek_next_packet(wtap *wth, int *err, gchar **err_info,
        char *hdr);
 static gboolean netscreen_check_file_type(wtap *wth, int *err,
        gchar **err_info);
-static int netscreen_read(wtap *wth, int *err, gchar **err_info,
+static gboolean netscreen_read(wtap *wth, int *err, gchar **err_info,
        gint64 *data_offset);
-static int netscreen_seek_read(wtap *wth, gint64 seek_off,
+static gboolean netscreen_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf,
        int *err, gchar **err_info);
 static int parse_netscreen_rec_hdr(struct wtap_pkthdr *phdr, const char *line,
@@ -190,7 +190,7 @@ int netscreen_open(wtap *wth, int *err, gchar **err_info)
 }
 
 /* Find the next packet and parse it; called from wtap_read(). */
-static int netscreen_read(wtap *wth, int *err, gchar **err_info,
+static gboolean netscreen_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        gint64          offset;
@@ -203,19 +203,19 @@ static int netscreen_read(wtap *wth, int *err, gchar **err_info,
        /* Find the next packet */
        offset = netscreen_seek_next_packet(wth, err, err_info, line);
        if (offset < 0)
-               return -1;
+               return FALSE;
 
        /* Parse the header */
        pkt_len = parse_netscreen_rec_hdr(&wth->phdr, line, cap_int, &cap_dir,
            cap_dst, err, err_info);
        if (pkt_len == -1)
-               return -1;
+               return FALSE;
 
        /* Convert the ASCII hex dump to binary data, and fill in some
           struct wtap_pkthdr fields */
        if (!parse_netscreen_hex_dump(wth->fh, pkt_len, cap_int,
            cap_dst, &wth->phdr, wth->frame_buffer, err, err_info))
-               return -1;
+               return FALSE;
 
        /*
         * If the per-file encapsulation isn't known, set it to this
@@ -233,11 +233,11 @@ static int netscreen_read(wtap *wth, int *err, gchar **err_info,
        }
 
        *data_offset = offset;
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
 /* Used to read packets in random-access fashion */
-static int
+static gboolean
 netscreen_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf,
        int *err, gchar **err_info)
@@ -249,7 +249,7 @@ netscreen_seek_read(wtap *wth, gint64 seek_off,
        char            cap_dst[13];
 
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) {
-               return -1;
+               return FALSE;
        }
 
        if (file_gets(line, NETSCREEN_LINE_LENGTH, wth->random_fh) == NULL) {
@@ -257,18 +257,18 @@ netscreen_seek_read(wtap *wth, gint64 seek_off,
                if (*err == 0) {
                        *err = WTAP_ERR_SHORT_READ;
                }
-               return -1;
+               return FALSE;
        }
 
        pkt_len = parse_netscreen_rec_hdr(phdr, line, cap_int, &cap_dir,
            cap_dst, err, err_info);
        if (pkt_len == -1)
-               return -1;
+               return FALSE;
 
        if (!parse_netscreen_hex_dump(wth->random_fh, pkt_len, cap_int,
            cap_dst, phdr, buf, err, err_info))
-               return -1;
-       return REC_TYPE_PACKET;
+               return FALSE;
+       return TRUE;
 }
 
 /* Parses a packet record header. There are a few possible formats:
index 0e3c9a9f97ec6aeaf38cce10862c9beedd8cba4a..0c6898bbdbce2984a604aa32fc29d44a41f88f44 100644 (file)
@@ -175,9 +175,9 @@ typedef struct {
        gboolean is_hpux_11;
 } nettl_t;
 
-static int nettl_read(wtap *wth, int *err, gchar **err_info,
+static gboolean nettl_read(wtap *wth, int *err, gchar **err_info,
                gint64 *data_offset);
-static int nettl_seek_read(wtap *wth, gint64 seek_off,
+static gboolean nettl_seek_read(wtap *wth, gint64 seek_off,
                struct wtap_pkthdr *phdr, Buffer *buf,
                int *err, gchar **err_info);
 static gboolean nettl_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
@@ -287,7 +287,7 @@ int nettl_open(wtap *wth, int *err, gchar **err_info)
 }
 
 /* Read the next packet */
-static int nettl_read(wtap *wth, int *err, gchar **err_info,
+static gboolean nettl_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
     /* Read record header. */
@@ -295,7 +295,7 @@ static int nettl_read(wtap *wth, int *err, gchar **err_info,
     if (!nettl_read_rec(wth, wth->fh, &wth->phdr, wth->frame_buffer,
         err, err_info)) {
        /* Read error or EOF */
-       return -1;
+       return FALSE;
     }
 
     /*
@@ -313,15 +313,15 @@ static int nettl_read(wtap *wth, int *err, gchar **err_info,
            wth->file_encap = WTAP_ENCAP_PER_PACKET;
     }
 
-    return REC_TYPE_PACKET;
+    return TRUE;
 }
 
-static int
+static gboolean
 nettl_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
                Buffer *buf, int *err, gchar **err_info)
 {
     if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-       return -1;
+       return FALSE;
 
     /* Read record header. */
     if (!nettl_read_rec(wth, wth->random_fh, phdr, buf, err, err_info)) {
@@ -330,9 +330,9 @@ nettl_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
            /* EOF means "short read" in random-access mode */
            *err = WTAP_ERR_SHORT_READ;
        }
-       return -1;
+       return FALSE;
     }
-    return REC_TYPE_PACKET;
+    return TRUE;
 }
 
 static gboolean
index 01ed983932711dcd6c8e752f6ec8225f487818a6..38abfab2cdaa2812ec3ef01cbabbfdb2ff709762 100644 (file)
@@ -94,9 +94,9 @@ static void init_gmt_to_localtime_offset(void)
     }
 }
 
-static int observer_read(wtap *wth, int *err, gchar **err_info,
+static gboolean observer_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static int observer_seek_read(wtap *wth, gint64 seek_off,
+static gboolean observer_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static int read_packet_header(FILE_T fh, union wtap_pseudo_header *pseudo_header,
     packet_entry_header *packet_header, int *err, gchar **err_info);
@@ -258,7 +258,7 @@ int network_instruments_open(wtap *wth, int *err, gchar **err_info)
 }
 
 /* Reads the next packet. */
-static int observer_read(wtap *wth, int *err, gchar **err_info,
+static gboolean observer_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
     int header_bytes_consumed;
@@ -273,7 +273,7 @@ static int observer_read(wtap *wth, int *err, gchar **err_info,
         header_bytes_consumed = read_packet_header(wth->fh, &wth->phdr.pseudo_header, &packet_header, err,
             err_info);
         if (header_bytes_consumed <= 0)
-            return -1;    /* EOF or error */
+            return FALSE;    /* EOF or error */
 
         if (packet_header.packet_type == PACKET_TYPE_DATA_PACKET)
             break;
@@ -281,32 +281,32 @@ static int observer_read(wtap *wth, int *err, gchar **err_info,
         /* skip to next packet */
         if (!skip_to_next_packet(wth, packet_header.offset_to_next_packet,
                 header_bytes_consumed, err, err_info)) {
-            return -1;    /* EOF or error */
+            return FALSE;    /* EOF or error */
         }
     }
 
     if (!process_packet_header(wth, &packet_header, &wth->phdr, err, err_info))
-        return -1;
+        return FALSE;
 
     /* read the frame data */
     data_bytes_consumed = read_packet_data(wth->fh, packet_header.offset_to_frame,
             header_bytes_consumed, wth->frame_buffer,
             wth->phdr.caplen, err, err_info);
     if (data_bytes_consumed < 0) {
-        return -1;
+        return FALSE;
     }
 
     /* skip over any extra bytes following the frame data */
     if (!skip_to_next_packet(wth, packet_header.offset_to_next_packet,
             header_bytes_consumed + data_bytes_consumed, err, err_info)) {
-        return -1;
+        return FALSE;
     }
 
-    return REC_TYPE_PACKET;
+    return TRUE;
 }
 
 /* Reads a packet at an offset. */
-static int observer_seek_read(wtap *wth, gint64 seek_off,
+static gboolean observer_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
     union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header;
@@ -315,25 +315,25 @@ static int observer_seek_read(wtap *wth, gint64 seek_off,
     int data_bytes_consumed;
 
     if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-        return -1;
+        return FALSE;
 
     /* process the packet header, including TLVs */
     offset = read_packet_header(wth->random_fh, pseudo_header, &packet_header, err,
         err_info);
     if (offset <= 0)
-        return -1;    /* EOF or error */
+        return FALSE;    /* EOF or error */
 
     if (!process_packet_header(wth, &packet_header, phdr, err, err_info))
-        return -1;
+        return FALSE;
 
     /* read the frame data */
     data_bytes_consumed = read_packet_data(wth->random_fh, packet_header.offset_to_frame,
         offset, buf, phdr->caplen, err, err_info);
     if (data_bytes_consumed < 0) {
-        return -1;
+        return FALSE;
     }
 
-    return REC_TYPE_PACKET;
+    return TRUE;
 }
 
 static int
index 782918c92149f652e3be0394584a03d0a4775217..e6dd704bb3c3d12f078b7d505ef170924efd5f9a 100644 (file)
@@ -402,9 +402,9 @@ typedef struct {
        guint           isdn_type;      /* 1 = E1 PRI, 2 = T1 PRI, 3 = BRI */
 } netxray_t;
 
-static int netxray_read(wtap *wth, int *err, gchar **err_info,
+static gboolean netxray_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static int netxray_seek_read(wtap *wth, gint64 seek_off,
+static gboolean netxray_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static int netxray_process_rec_header(wtap *wth, FILE_T fh,
     struct wtap_pkthdr *phdr, int *err, gchar **err_info);
@@ -989,7 +989,7 @@ netxray_open(wtap *wth, int *err, gchar **err_info)
 }
 
 /* Read the next packet */
-static int
+static gboolean
 netxray_read(wtap *wth, int *err, gchar **err_info,
             gint64 *data_offset)
 {
@@ -1007,7 +1007,7 @@ reread:
        if (*data_offset == netxray->end_offset) {
                /* Yes. */
                *err = 0;       /* it's just an EOF, not an error */
-               return -1;
+               return FALSE;
        }
 
        /* Read and process record header. */
@@ -1021,7 +1021,7 @@ reread:
                        /*
                         * Error of some sort; give up.
                         */
-                       return -1;
+                       return FALSE;
                }
 
                /* We're at EOF.  Wrap?
@@ -1046,7 +1046,7 @@ reread:
                 */
                if (netxray->start_offset < netxray->end_offset) {
                        *err = WTAP_ERR_SHORT_READ;
-                       return -1;
+                       return FALSE;
                }
 
                if (!netxray->wrapped) {
@@ -1054,12 +1054,12 @@ reread:
                        netxray->wrapped = TRUE;
                        if (file_seek(wth->fh, CAPTUREFILE_HEADER_SIZE,
                            SEEK_SET, err) == -1)
-                               return -1;
+                               return FALSE;
                        goto reread;
                }
 
                /* We've already wrapped - don't wrap again. */
-               return -1;
+               return FALSE;
        }
 
        /*
@@ -1067,13 +1067,13 @@ reread:
         */
        if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer,
            wth->phdr.caplen, err, err_info))
-               return -1;
+               return FALSE;
 
        /*
         * If there's extra stuff at the end of the record, skip it.
         */
        if (file_seek(wth->fh, padding, SEEK_CUR, err) == -1)
-               return -1;
+               return FALSE;
 
        /*
         * If it's an ATM packet, and we don't have enough information
@@ -1081,16 +1081,16 @@ reread:
         * attempt to guess them from the packet data.
         */
        netxray_guess_atm_type(wth, &wth->phdr, wth->frame_buffer);
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
-static int
+static gboolean
 netxray_seek_read(wtap *wth, gint64 seek_off,
                  struct wtap_pkthdr *phdr, Buffer *buf,
                  int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return -1;
+               return FALSE;
 
        if (netxray_process_rec_header(wth, wth->random_fh, phdr, err,
            err_info) == -1) {
@@ -1102,7 +1102,7 @@ netxray_seek_read(wtap *wth, gint64 seek_off,
                         */
                        *err = WTAP_ERR_SHORT_READ;
                }
-               return -1;
+               return FALSE;
        }
 
        /*
@@ -1110,7 +1110,7 @@ netxray_seek_read(wtap *wth, gint64 seek_off,
         */
        if (!wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen, err,
            err_info))
-               return -1;
+               return FALSE;
 
        /*
         * If it's an ATM packet, and we don't have enough information
@@ -1118,7 +1118,7 @@ netxray_seek_read(wtap *wth, gint64 seek_off,
         * attempt to guess them from the packet data.
         */
        netxray_guess_atm_type(wth, phdr, buf);
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
 static int
index 1eafa3f15094c31f01be10fe06c5b91f5a669155..8138a31f448a50c54aab657e93fa9477679b6f6c 100644 (file)
@@ -509,9 +509,9 @@ static int process_rec_header2_v2(wtap *wth, unsigned char *buffer,
     guint16 length, int *err, gchar **err_info);
 static int process_rec_header2_v145(wtap *wth, unsigned char *buffer,
     guint16 length, gint16 maj_vers, int *err, gchar **err_info);
-static int ngsniffer_read(wtap *wth, int *err, gchar **err_info,
+static gboolean ngsniffer_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static int ngsniffer_seek_read(wtap *wth, gint64 seek_off,
+static gboolean ngsniffer_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static int ngsniffer_process_record(wtap *wth, gboolean is_random,
     guint *padding, struct wtap_pkthdr *phdr, Buffer *buf, int *err,
@@ -1053,7 +1053,7 @@ process_rec_header2_v145(wtap *wth, unsigned char *buffer, guint16 length,
 }
 
 /* Read the next packet */
-static int
+static gboolean
 ngsniffer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
        ngsniffer_t *ngsniffer;
@@ -1075,7 +1075,7 @@ ngsniffer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
                    &wth->phdr, wth->frame_buffer, err, err_info);
                if (ret < 0) {
                        /* Read error or short read */
-                       return -1;
+                       return FALSE;
                }
 
                /*
@@ -1093,16 +1093,16 @@ ngsniffer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
                        if (padding != 0) {
                                if (!ng_file_skip_seq(wth, padding, err,
                                    err_info))
-                                       return -1;
+                                       return FALSE;
                        }
-                       return REC_TYPE_PACKET;
+                       return TRUE;
 
                case REC_EOF:
                        /*
                         * End of file.  Return an EOF indication.
                         */
                        *err = 0;       /* EOF, not error */
-                       return -1;
+                       return FALSE;
 
                default:
                        /*
@@ -1114,26 +1114,26 @@ ngsniffer_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
                        if (padding != 0) {
                                if (!ng_file_skip_seq(wth, padding, err,
                                    err_info))
-                                       return -1;
+                                       return FALSE;
                        }
                        break;
                }
        }
 }
 
-static int
+static gboolean
 ngsniffer_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
        int     ret;
 
        if (!ng_file_seek_rand(wth, seek_off, err, err_info))
-               return -1;
+               return FALSE;
 
        ret = ngsniffer_process_record(wth, TRUE, NULL, phdr, buf, err, err_info);
        if (ret < 0) {
                /* Read error or short read */
-               return -1;
+               return FALSE;
        }
 
        /*
@@ -1152,10 +1152,10 @@ ngsniffer_seek_read(wtap *wth, gint64 seek_off,
                 * "Can't happen".
                 */
                g_assert_not_reached();
-               return -1;
+               return FALSE;
        }
 
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
 /*
index 5970b00d2083d0684d2e7940d68b43fad38c0522..313cf3e5b8ca349963423505b7f9a0b4550d0dd0 100644 (file)
@@ -44,11 +44,11 @@ typedef struct packetlogger_header {
        guint64 ts;
 } packetlogger_header_t;
 
-static int packetlogger_read(wtap *wth, int *err, gchar **err_info,
-                            gint64 *data_offset);
-static int packetlogger_seek_read(wtap *wth, gint64 seek_off,
-                                 struct wtap_pkthdr *phdr,
-                                 Buffer *buf, int *err, gchar **err_info);
+static gboolean packetlogger_read(wtap *wth, int *err, gchar **err_info,
+                                 gint64 *data_offset);
+static gboolean packetlogger_seek_read(wtap *wth, gint64 seek_off,
+                                      struct wtap_pkthdr *phdr,
+                                      Buffer *buf, int *err, gchar **err_info);
 static gboolean packetlogger_read_header(packetlogger_header_t *pl_hdr,
                                         FILE_T fh, int *err, gchar **err_info);
 static gboolean packetlogger_read_packet(FILE_T fh, struct wtap_pkthdr *phdr,
@@ -93,31 +93,29 @@ int packetlogger_open(wtap *wth, int *err, gchar **err_info)
        return 1; /* Our kind of file */
 }
 
-static int
+static gboolean
 packetlogger_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
        *data_offset = file_tell(wth->fh);
 
-       if (!packetlogger_read_packet(wth->fh, &wth->phdr,
-           wth->frame_buffer, err, err_info))
-               return -1;
-       return REC_TYPE_PACKET;
+       return packetlogger_read_packet(wth->fh, &wth->phdr,
+           wth->frame_buffer, err, err_info);
 }
 
-static int
+static gboolean
 packetlogger_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
                       Buffer *buf, int *err, gchar **err_info)
 {
        if(file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return -1;
+               return FALSE;
 
        if(!packetlogger_read_packet(wth->random_fh, phdr, buf, err, err_info)) {
                if(*err == 0)
                        *err = WTAP_ERR_SHORT_READ;
 
-               return -1;
+               return FALSE;
        }
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
 static gboolean
index 2132858770020f32f0f7c4b17db01908c03ae980..a0be4a9eaac2660254bcf699ba5d73c8ac72ba2e 100644 (file)
@@ -2257,7 +2257,7 @@ pcapng_open(wtap *wth, int *err, gchar **err_info)
 
 
 /* classic wtap: read packet */
-static int
+static gboolean
 pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
         pcapng_t *pcapng = (pcapng_t *)wth->priv;
@@ -2282,7 +2282,7 @@ pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
                 if (bytes_read <= 0) {
                         pcapng_debug1("pcapng_read: data_offset is finally %" G_GINT64_MODIFIER "d", *data_offset);
                         pcapng_debug0("pcapng_read: couldn't read packet block");
-                        return -1;
+                        return FALSE;
                 }
 
                 switch (wblock.type) {
@@ -2292,7 +2292,7 @@ pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
                         wth->phdr.pkt_encap = WTAP_ENCAP_UNKNOWN;
                         *err = WTAP_ERR_UNSUPPORTED;
                         *err_info = g_strdup_printf("pcapng: multi-section files not currently supported");
-                        return -1;
+                        return FALSE;
 
                 case(BLOCK_TYPE_PB):
                 case(BLOCK_TYPE_SPB):
@@ -2361,12 +2361,12 @@ got_packet:
         /*pcapng_debug2("Read length: %u Packet length: %u", bytes_read, wth->phdr.caplen);*/
         pcapng_debug1("pcapng_read: data_offset is finally %" G_GINT64_MODIFIER "d", *data_offset + bytes_read);
 
-        return REC_TYPE_PACKET;
+        return TRUE;
 }
 
 
 /* classic wtap: seek to file position and read packet */
-static int
+static gboolean
 pcapng_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf,
     int *err, gchar **err_info)
@@ -2380,7 +2380,7 @@ pcapng_seek_read(wtap *wth, gint64 seek_off,
         /* seek to the right file position */
         bytes_read64 = file_seek(wth->random_fh, seek_off, SEEK_SET, err);
         if (bytes_read64 <= 0) {
-                return -1;   /* Seek error */
+                return FALSE;   /* Seek error */
         }
         pcapng_debug1("pcapng_seek_read: reading at offset %" G_GINT64_MODIFIER "u", seek_off);
 
@@ -2393,7 +2393,7 @@ pcapng_seek_read(wtap *wth, gint64 seek_off,
         if (bytes_read <= 0) {
                 pcapng_debug3("pcapng_seek_read: couldn't read packet block (err=%d, errno=%d, bytes_read=%d).",
                               *err, errno, bytes_read);
-                return -1;
+                return FALSE;
         }
 
         /* block must be a "Packet Block", an "Enhanced Packet Block",
@@ -2404,7 +2404,7 @@ pcapng_seek_read(wtap *wth, gint64 seek_off,
                 return FALSE;
         }
 
-        return REC_TYPE_PACKET;
+        return TRUE;
 }
 
 
index 3d9e8dc0862c15e0d6a60dfa00f960397372db27..a10ae66fd5aa07f31e52f11095bfd2944f0b84a4 100644 (file)
@@ -358,7 +358,7 @@ int peekclassic_open(wtap *wth, int *err, gchar **err_info)
        return 1;
 }
 
-static int peekclassic_read_v7(wtap *wth, int *err, gchar **err_info,
+static gboolean peekclassic_read_v7(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        int sliceLength;
@@ -369,38 +369,38 @@ static int peekclassic_read_v7(wtap *wth, int *err, gchar **err_info,
        sliceLength = peekclassic_read_packet_v7(wth, wth->fh, &wth->phdr,
            wth->frame_buffer, err, err_info);
        if (sliceLength < 0)
-               return -1;
+               return FALSE;
 
        /* Skip extra ignored data at the end of the packet. */
        if ((guint32)sliceLength > wth->phdr.caplen) {
                if (!file_skip(wth->fh, sliceLength - wth->phdr.caplen, err))
-                       return -1;
+                       return FALSE;
        }
 
        /* Records are padded to an even length, so if the slice length
           is odd, read the padding byte. */
        if (sliceLength & 0x01) {
                if (!file_skip(wth->fh, 1, err))
-                       return -1;
+                       return FALSE;
        }
 
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
-static int peekclassic_seek_read_v7(wtap *wth, gint64 seek_off,
+static gboolean peekclassic_seek_read_v7(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return -1;
+               return FALSE;
 
        /* Read the packet. */
        if (peekclassic_read_packet_v7(wth, wth->random_fh, phdr, buf,
            err, err_info) == -1) {
                if (*err == 0)
                        *err = WTAP_ERR_SHORT_READ;
-               return -1;
+               return FALSE;
        }
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
 static int peekclassic_read_packet_v7(wtap *wth, FILE_T fh,
@@ -493,7 +493,7 @@ static int peekclassic_read_packet_v7(wtap *wth, FILE_T fh,
        return sliceLength;
 }
 
-static int peekclassic_read_v56(wtap *wth, int *err, gchar **err_info,
+static gboolean peekclassic_read_v56(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        *data_offset = file_tell(wth->fh);
@@ -501,29 +501,29 @@ static int peekclassic_read_v56(wtap *wth, int *err, gchar **err_info,
        /* read the packet */
        if (!peekclassic_read_packet_v56(wth, wth->fh, &wth->phdr,
            wth->frame_buffer, err, err_info))
-               return -1;
+               return FALSE;
 
        /*
         * XXX - is the captured packet data padded to a multiple
         * of 2 bytes?
         */
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
 static gboolean peekclassic_seek_read_v56(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return -1;
+               return FALSE;
 
        /* read the packet */
        if (!peekclassic_read_packet_v56(wth, wth->random_fh, phdr, buf,
            err, err_info)) {
                if (*err == 0)
                        *err = WTAP_ERR_SHORT_READ;
-               return -1;
+               return FALSE;
        }
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
 static gboolean peekclassic_read_packet_v56(wtap *wth, FILE_T fh,
index 3007bdf99a63c4e0c633a2d312951de2983e8698..05dc8beaefde4e237e1a0a47bda1ddcd12413516 100644 (file)
@@ -123,9 +123,9 @@ typedef struct {
        gboolean        has_fcs;
 } peektagged_t;
 
-static int peektagged_read(wtap *wth, int *err, gchar **err_info,
+static gboolean peektagged_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static int peektagged_seek_read(wtap *wth, gint64 seek_off,
+static gboolean peektagged_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 
 static int wtap_file_read_pattern (wtap *wth, const char *pattern, int *err,
@@ -633,7 +633,7 @@ peektagged_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
     return skip_len;
 }
 
-static int peektagged_read(wtap *wth, int *err, gchar **err_info,
+static gboolean peektagged_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
     int skip_len;
@@ -644,29 +644,29 @@ static int peektagged_read(wtap *wth, int *err, gchar **err_info,
     skip_len = peektagged_read_packet(wth, wth->fh, &wth->phdr,
                                       wth->frame_buffer, err, err_info);
     if (skip_len == -1)
-       return -1;
+       return FALSE;
 
     if (skip_len != 0) {
        /* Skip extra junk at the end of the packet data. */
         if (!file_skip(wth->fh, skip_len, err))
-           return -1;
+           return FALSE;
     }
 
-    return REC_TYPE_PACKET;
+    return TRUE;
 }
 
-static int
+static gboolean
 peektagged_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
     if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-       return -1;
+       return FALSE;
 
     /* Read the packet. */
     if (peektagged_read_packet(wth, wth->random_fh, phdr, buf, err, err_info) == -1) {
         if (*err == 0)
             *err = WTAP_ERR_SHORT_READ;
-       return -1;
+       return FALSE;
     }
-    return REC_TYPE_PACKET;
+    return TRUE;
 }
index 319ada0feb968118a0c0c47a71c688a5a811e9e0..6ba142485bbdc009e3fd35bc0adb5c75ddba999f 100644 (file)
@@ -95,9 +95,9 @@ typedef enum {
        DIRECTION_RECV
 } direction_enum;
 
-static int pppdump_read(wtap *wth, int *err, gchar **err_info,
+static gboolean pppdump_read(wtap *wth, int *err, gchar **err_info,
        gint64 *data_offset);
-static int pppdump_seek_read(wtap *wth, gint64 seek_off,
+static gboolean pppdump_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 
 /*
@@ -327,7 +327,7 @@ pppdump_set_phdr(struct wtap_pkthdr *phdr, int num_bytes,
 }
 
 /* Find the next packet and parse it; called from wtap_read(). */
-static int
+static gboolean
 pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
        int             num_bytes;
@@ -344,7 +344,7 @@ pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
                pid = g_new(pkt_id, 1);
                if (!pid) {
                        *err = errno;   /* assume a malloc failed and set "errno" */
-                       return -1;
+                       return FALSE;
                }
                pid->offset = 0;
        } else
@@ -357,7 +357,7 @@ pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
            pid, 0)) {
                if (pid != NULL)
                        g_free(pid);
-               return -1;
+               return FALSE;
        }
 
        if (pid != NULL)
@@ -374,7 +374,7 @@ pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
        wth->phdr.ts.nsecs      = state->tenths * 100000000;
        pppdump_set_phdr(&wth->phdr, num_bytes, direction);
 
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
 /* Returns number of bytes copied for record, -1 if failure.
@@ -715,7 +715,7 @@ done:
 
 
 /* Used to read packets in random-access fashion */
-static int
+static gboolean
 pppdump_seek_read(wtap *wth,
                 gint64 seek_off,
                 struct wtap_pkthdr *phdr,
@@ -736,11 +736,11 @@ pppdump_seek_read(wtap *wth,
        if (!pid) {
                *err = WTAP_ERR_BAD_FILE;       /* XXX - better error? */
                *err_info = g_strdup("pppdump: PID not found for record");
-               return -1;
+               return FALSE;
        }
 
        if (file_seek(wth->random_fh, pid->offset, SEEK_SET, err) == -1)
-               return -1;
+               return FALSE;
 
        init_state(state->seek_state);
        state->seek_state->offset = pid->offset;
@@ -763,13 +763,13 @@ pppdump_seek_read(wtap *wth,
        do {
                if (!collate(state->seek_state, wth->random_fh, err, err_info,
                    pd, &num_bytes, &direction, NULL, num_bytes_to_skip))
-                       return -1;
+                       return FALSE;
                num_bytes_to_skip = 0;
        } while (direction != pid->dir);
 
        pppdump_set_phdr(phdr, num_bytes, pid->dir);
 
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
 static void
index 16df1397e7d22f86ca99c08ad224c8cc431bccd5..e056cdd69171f0b27eba1806009383b1b92d2a9c 100644 (file)
@@ -84,9 +84,9 @@ struct radcomrec_hdr {
        char    xxw[9];         /* unknown */
 };
 
-static int radcom_read(wtap *wth, int *err, gchar **err_info,
+static gboolean radcom_read(wtap *wth, int *err, gchar **err_info,
        gint64 *data_offset);
-static int radcom_seek_read(wtap *wth, gint64 seek_off,
+static gboolean radcom_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static gboolean radcom_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
        Buffer *buf, int *err, gchar **err_info);
@@ -252,8 +252,8 @@ read_error:
 }
 
 /* Read the next packet */
-static int radcom_read(wtap *wth, int *err, gchar **err_info,
-                      gint64 *data_offset)
+static gboolean radcom_read(wtap *wth, int *err, gchar **err_info,
+                           gint64 *data_offset)
 {
        int     bytes_read;
        char    fcs[2];
@@ -264,7 +264,7 @@ static int radcom_read(wtap *wth, int *err, gchar **err_info,
        if (!radcom_read_rec(wth, wth->fh, &wth->phdr, wth->frame_buffer,
            err, err_info)) {
                /* Read error or EOF */
-               return -1;
+               return FALSE;
        }
 
        if (wth->file_encap == WTAP_ENCAP_LAPB) {
@@ -278,20 +278,20 @@ static int radcom_read(wtap *wth, int *err, gchar **err_info,
                        *err = file_error(wth->fh, err_info);
                        if (*err == 0)
                                *err = WTAP_ERR_SHORT_READ;
-                       return -1;
+                       return FALSE;
                }
        }
 
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
-static int
+static gboolean
 radcom_seek_read(wtap *wth, gint64 seek_off,
                 struct wtap_pkthdr *phdr, Buffer *buf,
                 int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return -1;
+               return FALSE;
 
        /* Read record. */
        if (!radcom_read_rec(wth, wth->random_fh, phdr, buf, err,
@@ -301,9 +301,9 @@ radcom_seek_read(wtap *wth, gint64 seek_off,
                        /* EOF means "short read" in random-access mode */
                        *err = WTAP_ERR_SHORT_READ;
                }
-               return -1;
+               return FALSE;
        }
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
 static gboolean
index 8001ddf58c6167ac83cae9e3b830621f7e8fa5a3..265d23f4a29dbf802d887f38543641737e76e908 100644 (file)
@@ -84,9 +84,9 @@ struct shomiti_trailer {
 #define RX_STATUS_FIFO_ERROR           0x0080  /* receive FIFO error */
 #define RX_STATUS_TRIGGERED            0x0001  /* frame did trigger */
 
-static int snoop_read(wtap *wth, int *err, gchar **err_info,
+static gboolean snoop_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static int snoop_seek_read(wtap *wth, gint64 seek_off,
+static gboolean snoop_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static int snoop_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
     Buffer *buf, int *err, gchar **err_info);
@@ -447,7 +447,7 @@ typedef struct {
 
 
 /* Read the next packet */
-static int snoop_read(wtap *wth, int *err, gchar **err_info,
+static gboolean snoop_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        int     padbytes;
@@ -460,7 +460,7 @@ static int snoop_read(wtap *wth, int *err, gchar **err_info,
        padbytes = snoop_read_packet(wth, wth->fh, &wth->phdr,
            wth->frame_buffer, err, err_info);
        if (padbytes == -1)
-               return -1;
+               return FALSE;
 
        /*
         * Skip over the padding (don't "fseek()", as the standard
@@ -482,27 +482,27 @@ static int snoop_read(wtap *wth, int *err, gchar **err_info,
                        *err = file_error(wth->fh, err_info);
                        if (*err == 0)
                                *err = WTAP_ERR_SHORT_READ;
-                       return -1;
+                       return FALSE;
                }
                padbytes -= bytes_read;
        }
 
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
-static int
+static gboolean
 snoop_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-               return -1;
+               return FALSE;
 
        if (snoop_read_packet(wth, wth->random_fh, phdr, buf, err, err_info) == -1) {
                if (*err == 0)
                        *err = WTAP_ERR_SHORT_READ;
-               return -1;
+               return FALSE;
        }
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
 static int
index 8c0625c74fea61536f97a9ab28e18e357ee25af7..12bc05885c96d07cd2462613845bf578b2c2b625 100644 (file)
@@ -48,8 +48,8 @@ static gboolean is_valid_id(guint16 version_id)
   return TRUE;
 }
 
-static int stanag4607_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
-                                Buffer *buf, int *err, gchar **err_info)
+static gboolean stanag4607_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
+                               Buffer *buf, int *err, gchar **err_info)
 {
   stanag4607_t *stanag4607 = (stanag4607_t *)wth->priv;
   guint32 millisecs, secs, nsecs;
@@ -69,7 +69,7 @@ static int stanag4607_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
   if (!is_valid_id(pntoh16(&stanag_pkt_hdr[0]))) {
     *err = WTAP_ERR_BAD_FILE;
     *err_info = g_strdup("Bad version number");
-    return -1;
+    return FALSE;
   }
 
   /* The next 4 bytes are the packet length */
@@ -133,19 +133,16 @@ static int stanag4607_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
 
   /* wind back to the start of the packet ... */
   if (file_seek(fh, - offset, SEEK_CUR, err) == -1)
-    return -1;
-
-  if (!wtap_read_packet_bytes(fh, buf, packet_size, err, err_info))
-    return -1;
+    goto fail;
 
-  return REC_TYPE_PACKET;
+  return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
 
 fail:
   *err = file_error(wth->fh, err_info);
-  return -1;
+  return FALSE;
 }
 
-static int stanag4607_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+static gboolean stanag4607_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
   gint64 offset;
 
@@ -158,12 +155,12 @@ static int stanag4607_read(wtap *wth, int *err, gchar **err_info, gint64 *data_o
   return stanag4607_read_file(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info);
 }
 
-static int stanag4607_seek_read(wtap *wth, gint64 seek_off,
-                                struct wtap_pkthdr *phdr,
-                                Buffer *buf, int *err, gchar **err_info)
+static gboolean stanag4607_seek_read(wtap *wth, gint64 seek_off,
+                               struct wtap_pkthdr *phdr,
+                               Buffer *buf, int *err, gchar **err_info)
 {
   if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-    return -1;
+    return FALSE;
 
   return stanag4607_read_file(wth, wth->random_fh, phdr, buf, err, err_info);
 }
index a08d42fb2cf6b70159a45b2e566b42654d35542f..5bd2fa1463fd57811249b2324bb640c9421f3028 100644 (file)
 #include "buffer.h"
 #include "tnef.h"
 
-static int tnef_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
-                          Buffer *buf, int *err, gchar **err_info)
+static gboolean tnef_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
+                               Buffer *buf, int *err, gchar **err_info)
 {
   gint64 file_size;
   int packet_size;
 
   if ((file_size = wtap_file_size(wth, err)) == -1)
-    return -1;
+    return FALSE;
 
   if (file_size > WTAP_MAX_PACKET_SIZE) {
     /*
@@ -47,7 +47,7 @@ static int tnef_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
     *err = WTAP_ERR_BAD_FILE;
     *err_info = g_strdup_printf("tnef: File has %" G_GINT64_MODIFIER "d-byte packet, bigger than maximum of %u",
                                file_size, WTAP_MAX_PACKET_SIZE);
-    return -1;
+    return FALSE;
   }
   packet_size = (int)file_size;
 
@@ -59,12 +59,10 @@ static int tnef_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
   phdr->ts.secs = 0;
   phdr->ts.nsecs = 0;
 
-  if (!wtap_read_packet_bytes(fh, buf, packet_size, err, err_info))
-    return -1;
-  return REC_TYPE_PACKET;
+  return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
 }
 
-static int tnef_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+static gboolean tnef_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
   gint64 offset;
 
@@ -74,25 +72,25 @@ static int tnef_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 
   /* there is only ever one packet */
   if (offset)
-    return -1;
+    return FALSE;
 
   *data_offset = offset;
 
   return tnef_read_file(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info);
 }
 
-static int tnef_seek_read(wtap *wth, gint64 seek_off,
-                          struct wtap_pkthdr *phdr,
-                          Buffer *buf, int *err, gchar **err_info)
+static gboolean tnef_seek_read(wtap *wth, gint64 seek_off,
+                               struct wtap_pkthdr *phdr,
+                               Buffer *buf, int *err, gchar **err_info)
 {
   /* there is only one packet */
   if(seek_off > 0) {
     *err = 0;
-    return -1;
+    return FALSE;
   }
 
   if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-    return -1;
+    return FALSE;
 
   return tnef_read_file(wth, wth->random_fh, phdr, buf, err, err_info);
 }
index 6e8ab1a1781a4b1a870c2902cd0dac7ba867e076..6fcf40270bd2c33cfd9f18f99325f6a9cc45d6a6 100644 (file)
@@ -105,9 +105,9 @@ static const char toshiba_rec_magic[]  = { '[', 'N', 'o', '.' };
  */
 #define TOSHIBA_MAX_PACKET_LEN 16384
 
-static int toshiba_read(wtap *wth, int *err, gchar **err_info,
+static gboolean toshiba_read(wtap *wth, int *err, gchar **err_info,
        gint64 *data_offset);
-static int toshiba_seek_read(wtap *wth, gint64 seek_off,
+static gboolean toshiba_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static gboolean parse_single_hex_dump_line(char* rec, guint8 *buf,
        guint byte_offset);
@@ -214,7 +214,7 @@ int toshiba_open(wtap *wth, int *err, gchar **err_info)
 }
 
 /* Find the next packet and parse it; called from wtap_read(). */
-static int toshiba_read(wtap *wth, int *err, gchar **err_info,
+static gboolean toshiba_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
        gint64  offset;
@@ -222,31 +222,29 @@ static int toshiba_read(wtap *wth, int *err, gchar **err_info,
        /* Find the next packet */
        offset = toshiba_seek_next_packet(wth, err, err_info);
        if (offset < 1)
-               return -1;
+               return FALSE;
        *data_offset = offset;
 
        /* Parse the packet */
-       if (!parse_toshiba_packet(wth->fh, &wth->phdr, wth->frame_buffer,
-           err, err_info))
-               return -1;
-       return REC_TYPE_PACKET;
+       return parse_toshiba_packet(wth->fh, &wth->phdr, wth->frame_buffer,
+           err, err_info);
 }
 
 /* Used to read packets in random-access fashion */
-static int
+static gboolean
 toshiba_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf,
        int *err, gchar **err_info)
 {
        if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1)
-               return -1;
+               return FALSE;
 
        if (!parse_toshiba_packet(wth->random_fh, phdr, buf, err, err_info)) {
                if (*err == 0)
                        *err = WTAP_ERR_SHORT_READ;
-               return -1;
+               return FALSE;
        }
-       return REC_TYPE_PACKET;
+       return TRUE;
 }
 
 /* Parses a packet. */
index 67a7d481f9e609ddbfd708d96c32347161ff5333..cfa03bceacc9571a7951c0b1bb37674ba5c07ac4 100644 (file)
@@ -158,9 +158,9 @@ struct visual_write_info
 
 
 /* Local functions to handle file reads and writes */
-static int visual_read(wtap *wth, int *err, gchar **err_info,
+static gboolean visual_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static int visual_seek_read(wtap *wth, gint64 seek_off,
+static gboolean visual_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static gboolean visual_read_packet(wtap *wth, FILE_T fh,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
@@ -281,7 +281,7 @@ int visual_open(wtap *wth, int *err, gchar **err_info)
    in a loop to sequentially read the entire file one time.  After
    the file has been read once, any Future access to the packets is
    done through seek_read. */
-static int visual_read(wtap *wth, int *err, gchar **err_info,
+static gboolean visual_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
     struct visual_read_info *visual = (struct visual_read_info *)wth->priv;
@@ -292,33 +292,31 @@ static int visual_read(wtap *wth, int *err, gchar **err_info,
     if (visual->current_pkt > visual->num_pkts)
     {
         *err = 0;   /* it's just an EOF, not an error */
-        return -1;
+        return FALSE;
     }
     visual->current_pkt++;
 
     *data_offset = file_tell(wth->fh);
 
-    if (!visual_read_packet(wth, wth->fh, &wth->phdr, wth->frame_buffer,
-            err, err_info))
-        return -1;
-    return REC_TYPE_PACKET;
+    return visual_read_packet(wth, wth->fh, &wth->phdr, wth->frame_buffer,
+            err, err_info);
 }
 
 /* Read packet header and data for random access. */
-static int visual_seek_read(wtap *wth, gint64 seek_off,
+static gboolean visual_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
     /* Seek to the packet header */
     if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-        return -1;
+        return FALSE;
 
     /* Read the packet. */
     if (!visual_read_packet(wth, wth->random_fh, phdr, buf, err, err_info)) {
         if (*err == 0)
             *err = WTAP_ERR_SHORT_READ;
-        return -1;
+        return FALSE;
     }
-    return REC_TYPE_PACKET;
+    return TRUE;
 }
 
 static gboolean
index 90d5e24acc6ca3cad6a766bdee3c5616afc2b38d..3684c3bbbe41c7a5319c576dd86d19a5c10d0d89 100644 (file)
@@ -139,9 +139,9 @@ to handle them.
 #define VMS_HEADER_LINES_TO_CHECK    200
 #define VMS_LINE_LENGTH              240
 
-static int vms_read(wtap *wth, int *err, gchar **err_info,
+static gboolean vms_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset);
-static int vms_seek_read(wtap *wth, gint64 seek_off,
+static gboolean vms_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
 static gboolean parse_single_hex_dump_line(char* rec, guint8 *buf,
     long byte_offset, int in_off, int remaining_bytes);
@@ -255,7 +255,7 @@ int vms_open(wtap *wth, int *err, gchar **err_info)
 }
 
 /* Find the next packet and parse it; called from wtap_read(). */
-static int vms_read(wtap *wth, int *err, gchar **err_info,
+static gboolean vms_read(wtap *wth, int *err, gchar **err_info,
     gint64 *data_offset)
 {
     gint64   offset = 0;
@@ -268,14 +268,12 @@ static int vms_read(wtap *wth, int *err, gchar **err_info,
 #endif
     if (offset < 1) {
         *err = file_error(wth->fh, err_info);
-        return -1;
+        return FALSE;
     }
     *data_offset = offset;
 
     /* Parse the packet */
-    if (!parse_vms_packet(wth->fh, &wth->phdr, wth->frame_buffer, err, err_info))
-        return -1;
-    return REC_TYPE_PACKET;
+    return parse_vms_packet(wth->fh, &wth->phdr, wth->frame_buffer, err, err_info);
 }
 
 /* Used to read packets in random-access fashion */
@@ -284,14 +282,14 @@ vms_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
     Buffer *buf, int *err, gchar **err_info)
 {
     if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1)
-        return -1;
+        return FALSE;
 
     if (!parse_vms_packet(wth->random_fh, phdr, buf, err, err_info)) {
         if (*err == 0)
             *err = WTAP_ERR_SHORT_READ;
-        return -1;
+        return FALSE;
     }
-    return REC_TYPE_PACKET;
+    return TRUE;
 }
 
 /* isdumpline assumes that dump lines start with some non-alphanumerics
index 518ebaf46cbbc3576855d754e9d821459eb29851..7d0b291c625b8d44057428956a8787fc01ee45cd 100644 (file)
@@ -496,8 +496,8 @@ static guint8       get_ofdm_rate(const guint8 *);
 static guint8       get_cck_rate(const guint8 *plcp);
 static void         setup_defaults(vwr_t *, guint16);
 
-static int          vwr_read(wtap *, int *, gchar **, gint64 *);
-static int          vwr_seek_read(wtap *, gint64, struct wtap_pkthdr *phdr,
+static gboolean     vwr_read(wtap *, int *, gchar **, gint64 *);
+static gboolean     vwr_seek_read(wtap *, gint64, struct wtap_pkthdr *phdr,
                                   Buffer *, int *, gchar **);
 
 static gboolean     vwr_read_rec_header(vwr_t *, FILE_T, int *, int *, int *, gchar **);
@@ -571,14 +571,14 @@ int vwr_open(wtap *wth, int *err, gchar **err_info)
 /*  frame, and a 64-byte statistics block trailer.                                         */
 /* The PLCP frame consists of a 4-byte or 6-byte PLCP header, followed by the MAC frame    */
 
-static int vwr_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+static gboolean vwr_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
     vwr_t *vwr      = (vwr_t *)wth->priv;
     int    rec_size = 0, IS_TX;
 
     /* read the next frame record header in the capture file; if no more frames, return */
     if (!vwr_read_rec_header(vwr, wth->fh, &rec_size, &IS_TX, err, err_info))
-        return -1;                                   /* Read error or EOF */
+        return FALSE;                                   /* Read error or EOF */
 
     /*
      * We're past the header; return the offset of the header, not of
@@ -589,7 +589,7 @@ static int vwr_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
     /* got a frame record; read and process it */
     if (!vwr_process_rec_data(wth->fh, rec_size, &wth->phdr,
                               wth->frame_buffer, vwr, IS_TX, err, err_info))
-       return -1;
+       return FALSE;
 
     /* If the per-file encapsulation isn't known, set it to this packet's encapsulation. */
     /* If it *is* known, and it isn't this packet's encapsulation, set it to             */
@@ -602,12 +602,12 @@ static int vwr_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
             wth->file_encap = WTAP_ENCAP_PER_PACKET;
     }
 
-    return REC_TYPE_PACKET;
+    return TRUE;
 }
 
 /* read a random record in the middle of a file; the start of the record is @ seek_off */
 
-static int vwr_seek_read(wtap *wth, gint64 seek_off,
+static gboolean vwr_seek_read(wtap *wth, gint64 seek_off,
     struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
     vwr_t *vwr = (vwr_t *)wth->priv;
@@ -615,17 +615,14 @@ static int vwr_seek_read(wtap *wth, gint64 seek_off,
 
     /* first seek to the indicated record header */
     if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
-        return -1;
+        return FALSE;
 
     /* read in the record header */
     if (!vwr_read_rec_header(vwr, wth->random_fh, &rec_size, &IS_TX, err, err_info))
-        return -1;                                  /* Read error or EOF */
-
-    if (!vwr_process_rec_data(wth->random_fh, rec_size, phdr, buf,
-                              vwr, IS_TX, err, err_info))
-        return -1;
+        return FALSE;                                  /* Read error or EOF */
 
-    return REC_TYPE_PACKET;
+    return vwr_process_rec_data(wth->random_fh, rec_size, phdr, buf,
+                                vwr, IS_TX, err, err_info);
 }
 
 /* Scan down in the input capture file to find the next frame header.       */
index 8291609b733166f0520935627d3a5208b07a6e46..dfa3441835e58a54f0df77899f2fb774c2192afb 100644 (file)
 WS_DLL_PUBLIC
 int wtap_fstat(wtap *wth, ws_statb64 *statb, int *err);
 
-typedef int (*subtype_read_func)(struct wtap*, int*, char**, gint64*);
-typedef int (*subtype_seek_read_func)(struct wtap*, gint64,
-                                      struct wtap_pkthdr *, Buffer *,
-                                      int *, char **);
+typedef gboolean (*subtype_read_func)(struct wtap*, int*, char**, gint64*);
+typedef gboolean (*subtype_seek_read_func)(struct wtap*, gint64,
+                                           struct wtap_pkthdr *, Buffer *buf,
+                                           int *, char **);
 /**
  * Struct holding data of the currently read file.
  */
index f03900cfbf09bed1f3e3ccae0e83546ab4fe7111..c32524be8055ca99f235e41b4fdcd7218c02a381 100644 (file)
@@ -975,11 +975,9 @@ void wtap_set_cb_new_ipv6(wtap *wth, wtap_new_ipv6_callback_t add_new_ipv6) {
                wth->add_new_ipv6 = add_new_ipv6;
 }
 
-int
+gboolean
 wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
 {
-       int rectype;
-
        /*
         * Set the packet encapsulation to the file's encapsulation
         * value; if that's not WTAP_ENCAP_PER_PACKET, it's the
@@ -990,8 +988,7 @@ wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
         */
        wth->phdr.pkt_encap = wth->file_encap;
 
-       rectype = wth->subtype_read(wth, err, err_info, data_offset);
-       if (rectype == -1) {
+       if (!wth->subtype_read(wth, err, err_info, data_offset)) {
                /*
                 * If we didn't get an error indication, we read
                 * the last packet.  See if there's any deferred
@@ -1003,7 +1000,7 @@ wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
                 */
                if (*err == 0)
                        *err = file_error(wth->fh, err_info);
-               return rectype; /* failure */
+               return FALSE;   /* failure */
        }
 
        /*
@@ -1021,7 +1018,7 @@ wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
         */
        g_assert(wth->phdr.pkt_encap != WTAP_ENCAP_PER_PACKET);
 
-       return rectype;
+       return TRUE;    /* success */
 }
 
 /*
@@ -1074,15 +1071,12 @@ wtap_buf_ptr(wtap *wth)
        return buffer_start_ptr(wth->frame_buffer);
 }
 
-int
+gboolean
 wtap_seek_read(wtap *wth, gint64 seek_off,
        struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
 {
-       int rectype;
-
-       rectype = wth->subtype_seek_read(wth, seek_off, phdr, buf, err, err_info);
-       if (rectype == -1)
-               return rectype;
+       if (!wth->subtype_seek_read(wth, seek_off, phdr, buf, err, err_info))
+               return FALSE;
 
        /*