From: ulfl Date: Sun, 5 Nov 2006 22:46:44 +0000 (+0000) Subject: change all file offsets from long to gint64 so we can - theoretically - handle files... X-Git-Url: http://git.samba.org/samba.git/?p=obnox%2Fwireshark%2Fwip.git;a=commitdiff_plain;h=d494883dde3d40cce3f04e8dd1f0d73037e63378 change all file offsets from long to gint64 so we can - theoretically - handle files > 2GB correct. Please distclean Win32 builds! git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@19814 f5534014-38df-0310-8fa8-9805f1628bb7 --- diff --git a/capinfos.c b/capinfos.c index d811a6210f..4e6b7ca530 100644 --- a/capinfos.c +++ b/capinfos.c @@ -118,7 +118,7 @@ process_cap_file(wtap *wth, const char *filename) int err; gchar *err_info; gint64 size; - long data_offset; + gint64 data_offset; guint32 packet = 0; gint64 bytes = 0; diff --git a/capture_info.c b/capture_info.c index e9bc1d9316..a5e9431d5f 100644 --- a/capture_info.c +++ b/capture_info.c @@ -224,7 +224,7 @@ void capture_info_new_packets(int to_read) { int err; gchar *err_info; - long data_offset; + gint64 data_offset; const struct wtap_pkthdr *phdr; union wtap_pseudo_header *pseudo_header; int wtap_linktype; diff --git a/cfile.h b/cfile.h index d70dd7d69c..bc726ea202 100644 --- a/cfile.h +++ b/cfile.h @@ -46,7 +46,7 @@ typedef struct _capture_file { gchar *filename; /* Name of capture file */ gboolean is_tempfile; /* Is capture file a temporary file? */ gboolean user_saved;/* If capture file is temporary, has it been saved by user yet? */ - long f_datalen; /* Size of capture file data (uncompressed) */ + gint64 f_datalen; /* Size of capture file data (uncompressed) */ guint16 cd_t; /* File type of capture file */ int lnk_t; /* Link-layer type with which to save capture */ guint32 vers; /* Version. For tcpdump minor is appended to major */ diff --git a/config.nmake b/config.nmake index 39007c29d2..3e6bf59c8b 100644 --- a/config.nmake +++ b/config.nmake @@ -19,6 +19,7 @@ VERSION_EXTRA= # The version of the wiretap library (recommended: leave unchanged) WTAP_VERSION_MAJOR=0 WTAP_VERSION_MINOR=3 +WTAP_VERSION_MICRO=1 @@ -394,8 +395,8 @@ LINK_PLUGINS_WITH_LIBWIRESHARK=USE VERSION=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_MICRO)$(VERSION_EXTRA) RC_VERSION=$(VERSION_MAJOR),$(VERSION_MINOR),$(VERSION_MICRO) -WTAP_VERSION=$(WTAP_VERSION_MAJOR).$(WTAP_VERSION_MINOR) -RC_WTAP_VERSION=$(WTAP_VERSION_MAJOR),$(WTAP_VERSION_MINOR) +WTAP_VERSION=$(WTAP_VERSION_MAJOR).$(WTAP_VERSION_MINOR).$(WTAP_VERSION_MICRO) +RC_WTAP_VERSION=$(WTAP_VERSION_MAJOR),$(WTAP_VERSION_MINOR),$(WTAP_VERSION_MICRO) GLIB_CFLAGS=/I$(GLIB_DIR)\include\glib-$(GLIB_VERSION) \ diff --git a/editcap.c b/editcap.c index 923642f39b..f9e39ba532 100644 --- a/editcap.c +++ b/editcap.c @@ -355,7 +355,7 @@ int main(int argc, char *argv[]) unsigned int choplen = 0; /* No chop */ wtap_dumper *pdh; int count = 1; - long data_offset; + gint64 data_offset; struct wtap_pkthdr snap_phdr; const struct wtap_pkthdr *phdr; int err_type; diff --git a/epan/dissectors/packet-frame.c b/epan/dissectors/packet-frame.c index 1d8b4ef965..65d50b3249 100644 --- a/epan/dissectors/packet-frame.c +++ b/epan/dissectors/packet-frame.c @@ -252,9 +252,9 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) } if (show_file_off) { - proto_tree_add_int_format(fh_tree, hf_frame_file_off, tvb, + proto_tree_add_int64_format(fh_tree, hf_frame_file_off, tvb, 0, 0, pinfo->fd->file_off, - "File Offset: %ld (0x%lx)", + "File Offset: %lld (0x%llx)", pinfo->fd->file_off, pinfo->fd->file_off); } @@ -477,7 +477,7 @@ proto_register_frame(void) "", HFILL }}, { &hf_frame_file_off, - { "File Offset", "frame.file_off", FT_INT32, BASE_DEC, NULL, 0x0, + { "File Offset", "frame.file_off", FT_INT64, BASE_DEC, NULL, 0x0, "", HFILL }}, { &hf_frame_marked, diff --git a/epan/frame_data.h b/epan/frame_data.h index 15e6057191..e6baff2ea5 100644 --- a/epan/frame_data.h +++ b/epan/frame_data.h @@ -47,7 +47,7 @@ typedef struct _frame_data { nstime_t abs_ts; /* Absolute timestamp */ nstime_t rel_ts; /* Relative timestamp (yes, it can be negative) */ nstime_t del_ts; /* Delta timestamp (yes, it can be negative) */ - long file_off; /* File offset */ + gint64 file_off; /* File offset */ int lnk_t; /* Per-packet encapsulation/data-link type */ struct { unsigned int passed_dfilter : 1; /* 1 = display, 0 = no display */ diff --git a/file.c b/file.c index 2d9a281135..e8c790c70d 100644 --- a/file.c +++ b/file.c @@ -87,7 +87,7 @@ static guint32 cum_bytes = 0; static void cf_reset_state(capture_file *cf); -static int read_packet(capture_file *cf, long offset); +static int read_packet(capture_file *cf, gint64 offset); static void rescan_packets(capture_file *cf, const char *action, const char *action_item, gboolean refilter, gboolean redissect); @@ -366,7 +366,7 @@ cf_read(capture_file *cf) const char *errmsg; char errmsg_errno[1024+1]; gchar err_str[2048+1]; - long data_offset; + gint64 data_offset; progdlg_t *progbar = NULL; gboolean stop_flag; gint64 size, file_pos; @@ -560,7 +560,7 @@ cf_start_tail(capture_file *cf, const char *fname, gboolean is_tempfile, int *er cf_read_status_t cf_continue_tail(capture_file *cf, int to_read, int *err) { - long data_offset = 0; + gint64 data_offset = 0; gchar *err_info; int newly_displayed_packets = 0; @@ -620,7 +620,7 @@ cf_read_status_t cf_finish_tail(capture_file *cf, int *err) { gchar *err_info; - long data_offset; + gint64 data_offset; if(cf->wth == NULL) { cf_close(cf); @@ -910,7 +910,7 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf, /* read in a new packet */ /* returns the row of the new packet in the packet list or -1 if not displayed */ static int -read_packet(capture_file *cf, long offset) +read_packet(capture_file *cf, gint64 offset) { const struct wtap_pkthdr *phdr = wtap_phdr(cf->wth); union wtap_pseudo_header *pseudo_header = wtap_pseudoheader(cf->wth); @@ -994,7 +994,7 @@ cf_merge_files(char **out_filenamep, int in_file_count, gchar err_str[2048+1]; const char *errmsg; gboolean got_read_error = FALSE, got_write_error = FALSE; - long data_offset; + gint64 data_offset; progdlg_t *progbar = NULL; gboolean stop_flag; gint64 f_len, file_pos; diff --git a/gtk/capture_file_dlg.c b/gtk/capture_file_dlg.c index 282a9bf186..dc0a7fbc1d 100644 --- a/gtk/capture_file_dlg.c +++ b/gtk/capture_file_dlg.c @@ -200,7 +200,7 @@ preview_do(GtkWidget *prev, wtap *wth) time_t time_current; int err = 0; gchar *err_info; - long data_offset; + gint64 data_offset; const struct wtap_pkthdr *phdr; double start_time = 0; /* seconds, with nsec resolution */ double stop_time = 0; /* seconds, with nsec resolution */ diff --git a/gtk/gsm_map_summary.c b/gtk/gsm_map_summary.c index 7515bf808e..1ee3acc046 100644 --- a/gtk/gsm_map_summary.c +++ b/gtk/gsm_map_summary.c @@ -110,7 +110,7 @@ gsm_map_stat_gtk_sum_cb(GtkWidget *w _U_, gpointer d _U_) add_string_to_box(string_buff, file_box); /* length */ - g_snprintf(string_buff, SUM_STR_MAX, "Length: %lu", summary.file_length); + g_snprintf(string_buff, SUM_STR_MAX, "Length: %lld", summary.file_length); add_string_to_box(string_buff, file_box); /* format */ diff --git a/gtk/main.c b/gtk/main.c index 6d7f0bc477..4b6bb91790 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -1401,11 +1401,11 @@ set_display_filename(capture_file *cf) /* convert file size */ if (cf->f_datalen/1024/1024 > 10) { - size_str = g_strdup_printf("%ld MB", cf->f_datalen/1024/1024); + size_str = g_strdup_printf("%lld MB", cf->f_datalen/1024/1024); } else if (cf->f_datalen/1024 > 10) { - size_str = g_strdup_printf("%ld KB", cf->f_datalen/1024); + size_str = g_strdup_printf("%lld KB", cf->f_datalen/1024); } else { - size_str = g_strdup_printf("%ld Bytes", cf->f_datalen); + size_str = g_strdup_printf("%lld Bytes", cf->f_datalen); } /* statusbar */ @@ -1657,19 +1657,19 @@ main_cf_cb_live_capture_update_continue(capture_file *cf) #if 0 /* XXX - don't show the highest expert level unless the TCP checksum offloading is "solved" */ if (cf->f_datalen/1024/1024 > 10) { - capture_msg = g_strdup_printf(" %s: File: %s %ld MB [Expert: %s]", + capture_msg = g_strdup_printf(" %s: File: %s %lld MB [Expert: %s]", get_interface_descriptive_name(capture_opts->iface), capture_opts->save_file, cf->f_datalen/1024/1024, val_to_str(expert_get_highest_severity(), expert_severity_vals, "Unknown (%u)")); } else if (cf->f_datalen/1024 > 10) { - capture_msg = g_strdup_printf(" %s: File: %s %ld KB [Expert: %s]", + capture_msg = g_strdup_printf(" %s: File: %s %lld KB [Expert: %s]", get_interface_descriptive_name(capture_opts->iface), capture_opts->save_file, cf->f_datalen/1024, val_to_str(expert_get_highest_severity(), expert_severity_vals, "Unknown (%u)")); } else { - capture_msg = g_strdup_printf(" %s: File: %s %ld Bytes [Expert: %s]", + capture_msg = g_strdup_printf(" %s: File: %s %lld Bytes [Expert: %s]", get_interface_descriptive_name(capture_opts->iface), capture_opts->save_file, cf->f_datalen, @@ -1677,17 +1677,17 @@ main_cf_cb_live_capture_update_continue(capture_file *cf) } #endif if (cf->f_datalen/1024/1024 > 10) { - capture_msg = g_strdup_printf(" %s: File: %s %ld MB", + capture_msg = g_strdup_printf(" %s: File: %s %lld MB", get_interface_descriptive_name(capture_opts->iface), capture_opts->save_file, cf->f_datalen/1024/1024); } else if (cf->f_datalen/1024 > 10) { - capture_msg = g_strdup_printf(" %s: File: %s %ld KB", + capture_msg = g_strdup_printf(" %s: File: %s %lld KB", get_interface_descriptive_name(capture_opts->iface), capture_opts->save_file, cf->f_datalen/1024); } else { - capture_msg = g_strdup_printf(" %s: File: %s %ld Bytes", + capture_msg = g_strdup_printf(" %s: File: %s %lld Bytes", get_interface_descriptive_name(capture_opts->iface), capture_opts->save_file, cf->f_datalen); diff --git a/gtk/mtp3_summary.c b/gtk/mtp3_summary.c index a3872260ad..f57ae06cd9 100644 --- a/gtk/mtp3_summary.c +++ b/gtk/mtp3_summary.c @@ -276,7 +276,7 @@ mtp3_sum_gtk_sum_cb(GtkWidget *w _U_, gpointer d _U_) add_string_to_box(string_buff, file_box); /* length */ - g_snprintf(string_buff, SUM_STR_MAX, "Length: %lu", summary.file_length); + g_snprintf(string_buff, SUM_STR_MAX, "Length: %lld", summary.file_length); add_string_to_box(string_buff, file_box); /* format */ diff --git a/gtk/summary_dlg.c b/gtk/summary_dlg.c index ae6af94a7f..d286f2740e 100644 --- a/gtk/summary_dlg.c +++ b/gtk/summary_dlg.c @@ -144,7 +144,7 @@ summary_open_cb(GtkWidget *w _U_, gpointer d _U_) add_string_to_table(table, &row, "Name:", string_buff); /* length */ - g_snprintf(string_buff, SUM_STR_MAX, "%lu bytes", summary.file_length); + g_snprintf(string_buff, SUM_STR_MAX, "%lld bytes", summary.file_length); add_string_to_table(table, &row, "Length:", string_buff); /* format */ diff --git a/gtk/win32-file-dlg.c b/gtk/win32-file-dlg.c index fb24c61ac9..bbaf930172 100644 --- a/gtk/win32-file-dlg.c +++ b/gtk/win32-file-dlg.c @@ -770,7 +770,7 @@ preview_set_filename(HWND of_hwnd, gchar *preview_file) { int err = 0; gchar *err_info; TCHAR string_buff[PREVIEW_STR_MAX]; - long data_offset; + gint64 data_offset; guint packet = 0; guint64 filesize; time_t ti_time; diff --git a/merge.h b/merge.h index ae2faeffb1..2a0a1bbd9a 100644 --- a/merge.h +++ b/merge.h @@ -42,7 +42,7 @@ typedef enum { typedef struct merge_in_file_s { const char *filename; wtap *wth; - long data_offset; + gint64 data_offset; in_file_state_e state; gint64 size; /* file size */ } merge_in_file_t; diff --git a/summary.h b/summary.h index b18bde4ec1..dc28edced8 100644 --- a/summary.h +++ b/summary.h @@ -43,7 +43,7 @@ typedef struct _summary_tally { double filtered_start; /* time in seconds, with msec resolution */ double filtered_stop; /* time in seconds, with msec resolution */ const char *filename; - long file_length; /* file length in bytes */ + gint64 file_length; /* file length in bytes */ int encap_type; /* wiretap encapsulation type */ gboolean has_snap; /* TRUE if maximum capture packet length is known */ int snap; /* Maximum captured packet length */ diff --git a/tshark.c b/tshark.c index 79188bd7d6..9b59f86ea2 100644 --- a/tshark.c +++ b/tshark.c @@ -178,7 +178,7 @@ static void report_counts_siginfo(int); #endif /* HAVE_LIBPCAP */ static int load_cap_file(capture_file *, char *, int); -static gboolean process_packet(capture_file *cf, long offset, +static gboolean process_packet(capture_file *cf, gint64 offset, const struct wtap_pkthdr *whdr, union wtap_pseudo_header *pseudo_header, const guchar *pd); static void show_capture_file_io_error(const char *, int, gboolean); @@ -2048,7 +2048,7 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type) wtap_dumper *pdh; int err; gchar *err_info; - long data_offset; + gint64 data_offset; char *save_file_string = NULL; linktype = wtap_file_encap(cf->wth); @@ -2185,7 +2185,7 @@ out: static void fill_in_fdata(frame_data *fdata, capture_file *cf, - const struct wtap_pkthdr *phdr, long offset) + const struct wtap_pkthdr *phdr, gint64 offset) { fdata->next = NULL; fdata->prev = NULL; @@ -2246,7 +2246,7 @@ clear_fdata(frame_data *fdata) } static gboolean -process_packet(capture_file *cf, long offset, const struct wtap_pkthdr *whdr, +process_packet(capture_file *cf, gint64 offset, const struct wtap_pkthdr *whdr, union wtap_pseudo_header *pseudo_header, const guchar *pd) { frame_data fdata; diff --git a/wiretap/5views.c b/wiretap/5views.c index e44969fe4f..edfb7b5c13 100644 --- a/wiretap/5views.c +++ b/wiretap/5views.c @@ -104,12 +104,12 @@ typedef struct #define CST_5VW_SYSTEM_RECORD 0x00000000 static gboolean _5views_read(wtap *wth, int *err, gchar **err_info, - long *data_offset); + gint64 *data_offset); static gboolean _5views_read_rec_data(FILE_T fh, guchar *pd, int length, int *err); static int _5views_read_header(wtap *wth, FILE_T fh, t_5VW_TimeStamped_Header *hdr, int *err); -static gboolean _5views_seek_read(wtap *wth, long seek_off, +static gboolean _5views_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info); @@ -204,7 +204,7 @@ int _5views_open(wtap *wth, int *err, gchar **err_info) /* Read the next packet */ static gboolean -_5views_read(wtap *wth, int *err, gchar **err_info _U_, long *data_offset) +_5views_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data_offset) { t_5VW_TimeStamped_Header TimeStamped_Header; int bytes_read; @@ -314,7 +314,7 @@ _5views_read_header(wtap *wth _U_, FILE_T fh, t_5VW_TimeStamped_Header *hdr, } static gboolean -_5views_seek_read(wtap *wth, long seek_off, +_5views_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info _U_) { diff --git a/wiretap/airopeek9.c b/wiretap/airopeek9.c index b716021e54..9fa878f382 100644 --- a/wiretap/airopeek9.c +++ b/wiretap/airopeek9.c @@ -78,8 +78,8 @@ typedef struct airopeek_utime { } airopeek_utime; static gboolean airopeekv9_read(wtap *wth, int *err, gchar **err_info, - long *data_offset); -static gboolean airopeekv9_seek_read(wtap *wth, long seek_off, + gint64 *data_offset); +static gboolean airopeekv9_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info); static void airopeekv9_close(wtap *wth); @@ -475,7 +475,7 @@ airopeekv9_process_header(FILE_T fh, hdr_info_t *hdr_info, int *err, #define TIME_FIXUP_CONSTANT (369.0*365.25*24*60*60-(3.0*24*60*60+6.0*60*60)) static gboolean airopeekv9_read(wtap *wth, int *err, gchar **err_info, - long *data_offset) + gint64 *data_offset) { hdr_info_t hdr_info; int hdrlen; @@ -551,7 +551,7 @@ static gboolean airopeekv9_read(wtap *wth, int *err, gchar **err_info, static gboolean -airopeekv9_seek_read(wtap *wth, long seek_off, +airopeekv9_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info) { diff --git a/wiretap/ascend-grammar.y b/wiretap/ascend-grammar.y index 398d8c5852..27c5c5c4dd 100644 --- a/wiretap/ascend-grammar.y +++ b/wiretap/ascend-grammar.y @@ -154,7 +154,7 @@ static guint32 start_time, secs, usecs, caplen, wirelen; static ascend_pkthdr *header; struct ascend_phdr *pseudo_header; static guint8 *pkt_data; -static long first_hexbyte; +static gint64 first_hexbyte; static FILE_T *fh_ptr; %} @@ -446,7 +446,7 @@ init_parse_ascend() if there is none. */ int parse_ascend(FILE_T fh, guint8 *pd, struct ascend_phdr *phdr, - ascend_pkthdr *hdr, long *start_of_data) + ascend_pkthdr *hdr, gint64 *start_of_data) { /* yydebug = 1; */ int retval; diff --git a/wiretap/ascend-int.h b/wiretap/ascend-int.h index 2360b169e7..ac4de11cb7 100644 --- a/wiretap/ascend-int.h +++ b/wiretap/ascend-int.h @@ -49,6 +49,6 @@ int ascendlex(void); void init_parse_ascend(void); void ascend_init_lexer(FILE_T fh); int parse_ascend(FILE_T fh, guint8 *pd, struct ascend_phdr *phdr, - ascend_pkthdr *hdr, long *start_of_data); + ascend_pkthdr *hdr, gint64 *start_of_data); #endif /* ! __ASCEND_INT_H__ */ diff --git a/wiretap/ascend.c b/wiretap/ascend.c index 5ead8142cd..d2a94fd157 100644 --- a/wiretap/ascend.c +++ b/wiretap/ascend.c @@ -79,8 +79,8 @@ static const ascend_magic_string ascend_magic[] = { }; static gboolean ascend_read(wtap *wth, int *err, gchar **err_info, - long *data_offset); -static gboolean ascend_seek_read(wtap *wth, long seek_off, + gint64 *data_offset); +static gboolean ascend_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_head, guint8 *pd, int len, int *err, gchar **err_info); static void ascend_close(wtap *wth); @@ -88,10 +88,10 @@ static void ascend_close(wtap *wth); /* Seeks to the beginning of the next packet, and returns the byte offset at which the header for that packet begins. Returns -1 on failure. */ -static long ascend_seek(wtap *wth, int *err) +static gint64 ascend_seek(wtap *wth, int *err) { int byte; - long date_off = -1, cur_off, packet_off; + gint64 date_off = -1, cur_off, packet_off; guint string_level[ASCEND_MAGIC_STRINGS]; guint string_i = 0, type = 0; @@ -163,7 +163,7 @@ found: int ascend_open(wtap *wth, int *err, gchar **err_info _U_) { - long offset; + gint64 offset; struct stat statbuf; /* We haven't yet allocated a data structure for our private stuff; @@ -247,9 +247,9 @@ static void config_pseudo_header(union wtap_pseudo_header *pseudo_head) /* Read the next packet; called from wtap_read(). */ static gboolean ascend_read(wtap *wth, int *err, gchar **err_info, - long *data_offset) + gint64 *data_offset) { - long offset; + gint64 offset; guint8 *buf = buffer_start_ptr(wth->frame_buffer); ascend_pkthdr header; @@ -303,7 +303,7 @@ static gboolean ascend_read(wtap *wth, int *err, gchar **err_info, return TRUE; } -static gboolean ascend_seek_read(wtap *wth, long seek_off, +static gboolean ascend_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_head, guint8 *pd, int len, int *err, gchar **err_info) { diff --git a/wiretap/ber.c b/wiretap/ber.c index 27fb232da7..6e37a6fe9e 100644 --- a/wiretap/ber.c +++ b/wiretap/ber.c @@ -42,7 +42,7 @@ #define BER_UNI_TAG_SEQ 16 /* SEQUENCE, SEQUENCE OF */ #define BER_UNI_TAG_SET 17 /* SET, SET OF */ -static gboolean ber_read(wtap *wth, int *err, gchar **err_info, long *data_offset) +static gboolean ber_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { guint8 *buf; gint64 file_size; @@ -93,7 +93,7 @@ static gboolean ber_read(wtap *wth, int *err, gchar **err_info, long *data_offse return TRUE; } -static gboolean ber_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header _U_, +static gboolean ber_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header _U_, guint8 *pd, int length, int *err, gchar **err_info _U_) { int packet_size = length; diff --git a/wiretap/catapult_dct2000.c b/wiretap/catapult_dct2000.c index 05301d09f6..348f7c9668 100644 --- a/wiretap/catapult_dct2000.c +++ b/wiretap/catapult_dct2000.c @@ -112,8 +112,8 @@ static gchar outhdr_name[MAX_OUTHDR_NAME+1]; /************************************************************/ /* Functions called from wiretap */ static gboolean catapult_dct2000_read(wtap *wth, int *err, gchar **err_info, - long *data_offset); -static gboolean catapult_dct2000_seek_read(wtap *wth, long seek_off, + gint64 *data_offset); +static gboolean catapult_dct2000_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info); @@ -127,7 +127,7 @@ static gboolean catapult_dct2000_dump_close(wtap_dumper *wdh, int *err); /************************************************************/ /* Private helper functions */ -static gboolean read_new_line(FILE_T fh, long *offset, gint *length); +static gboolean read_new_line(FILE_T fh, gint64 *offset, gint *length); static gboolean parse_line(gint line_length, gint *seconds, gint *useconds, long *before_time_offset, long *after_time_offset, long *data_offset, @@ -141,7 +141,7 @@ static gchar char_from_hex(guchar hex); static void set_pseudo_header_info(wtap *wth, int pkt_encap, - long file_offset, + gint64 file_offset, union wtap_pseudo_header *pseudo_header, packet_direction_t direction); static void set_aal_info(union wtap_pseudo_header *pseudo_header, @@ -164,7 +164,7 @@ static gboolean free_line_prefix_info(gpointer key, gpointer value, gpointer use /********************************************/ int catapult_dct2000_open(wtap *wth, int *err, gchar **err_info _U_) { - long offset = 0; + gint64 offset = 0; time_t timestamp; guint32 usecs; gint firstline_length; @@ -269,9 +269,9 @@ int catapult_dct2000_open(wtap *wth, int *err, gchar **err_info _U_) /* - return TRUE and details if found */ /**************************************************/ gboolean catapult_dct2000_read(wtap *wth, int *err, gchar **err_info _U_, - long *data_offset) + gint64 *data_offset) { - long offset = wth->data_offset; + gint64 offset = wth->data_offset; long dollar_offset, before_time_offset, after_time_offset; packet_direction_t direction; int encap; @@ -290,7 +290,7 @@ gboolean catapult_dct2000_read(wtap *wth, int *err, gchar **err_info _U_, while (1) { int line_length, seconds, useconds, data_chars; - long this_offset = offset; + gint64 this_offset = offset; /* Are looking for first packet after 2nd line */ if (wth->data_offset == 0) @@ -412,11 +412,11 @@ gboolean catapult_dct2000_read(wtap *wth, int *err, gchar **err_info _U_, /* Read & seek function. */ /**************************************************/ static gboolean -catapult_dct2000_seek_read(wtap *wth, long seek_off, +catapult_dct2000_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info) { - long offset = wth->data_offset; + gint64 offset = wth->data_offset; long dollar_offset, before_time_offset, after_time_offset; packet_direction_t direction; int encap; @@ -476,7 +476,7 @@ catapult_dct2000_seek_read(wtap *wth, long seek_off, /* If get here, must have failed */ *err = errno; *err_info = g_strdup_printf("catapult dct2000: seek_read failed to read/parse " - "line at position %ld", seek_off); + "line at position %lld", seek_off); return FALSE; } @@ -700,7 +700,7 @@ static gboolean catapult_dct2000_dump_close(wtap_dumper *wdh _U_, int *err _U_) /* - on return 'offset' will point to the next position to read from */ /* - return TRUE if this read is successful */ /**********************************************************************/ -gboolean read_new_line(FILE_T fh, long *offset, gint *length) +gboolean read_new_line(FILE_T fh, gint64 *offset, gint *length) { char *result; @@ -1176,7 +1176,7 @@ int write_stub_header(guchar *frame_buffer, char *timestamp_string, /**************************************************************/ void set_pseudo_header_info(wtap *wth, int pkt_encap, - long file_offset, + gint64 file_offset, union wtap_pseudo_header *pseudo_header, packet_direction_t direction) { diff --git a/wiretap/cosine.c b/wiretap/cosine.c index 841d80bac9..e43dc007d3 100644 --- a/wiretap/cosine.c +++ b/wiretap/cosine.c @@ -167,11 +167,11 @@ #define COSINE_MAX_PACKET_LEN 65536 static gboolean empty_line(const gchar *line); -static long cosine_seek_next_packet(wtap *wth, int *err, char *hdr); +static gint64 cosine_seek_next_packet(wtap *wth, int *err, char *hdr); static gboolean cosine_check_file_type(wtap *wth, int *err); static gboolean cosine_read(wtap *wth, int *err, gchar **err_info, - long *data_offset); -static gboolean cosine_seek_read(wtap *wth, long seek_off, + gint64 *data_offset); +static gboolean cosine_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err, gchar **err_info); static int parse_cosine_rec_hdr(wtap *wth, const char *line, @@ -202,9 +202,9 @@ static gboolean empty_line(const gchar *line) /* Seeks to the beginning of the next packet, and returns the byte offset. Copy the header line to hdr. Returns -1 on failure, and sets "*err" to the error and set hdr as NULL. */ -static long cosine_seek_next_packet(wtap *wth, int *err, char *hdr) +static gint64 cosine_seek_next_packet(wtap *wth, int *err, char *hdr) { - long cur_off; + gint64 cur_off; char buf[COSINE_LINE_LENGTH]; while (1) { @@ -306,9 +306,9 @@ int cosine_open(wtap *wth, int *err, gchar **err_info _U_) /* Find the next packet and parse it; called from wtap_read(). */ static gboolean cosine_read(wtap *wth, int *err, gchar **err_info, - long *data_offset) + gint64 *data_offset) { - long offset; + gint64 offset; guint8 *buf; int pkt_len, caplen; char line[COSINE_LINE_LENGTH]; @@ -341,7 +341,7 @@ static gboolean cosine_read(wtap *wth, int *err, gchar **err_info, /* Used to read packets in random-access fashion */ static gboolean -cosine_seek_read (wtap *wth, long seek_off, +cosine_seek_read (wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err, gchar **err_info) { diff --git a/wiretap/csids.c b/wiretap/csids.c index 86c0843a50..fc078c2129 100644 --- a/wiretap/csids.c +++ b/wiretap/csids.c @@ -45,8 +45,8 @@ */ static gboolean csids_read(wtap *wth, int *err, gchar **err_info, - long *data_offset); -static gboolean csids_seek_read(wtap *wth, long seek_off, + gint64 *data_offset); +static gboolean csids_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err, gchar **err_info); static void csids_close(wtap *wth); @@ -145,7 +145,7 @@ int csids_open(wtap *wth, int *err, gchar **err_info _U_) /* Find the next packet and parse it; called from wtap_read(). */ static gboolean csids_read(wtap *wth, int *err, gchar **err_info _U_, - long *data_offset) + gint64 *data_offset) { guint8 *buf; int bytesRead = 0; @@ -200,7 +200,7 @@ static gboolean csids_read(wtap *wth, int *err, gchar **err_info _U_, /* Used to read packets in random-access fashion */ static gboolean csids_seek_read (wtap *wth, - long seek_off, + gint64 seek_off, union wtap_pseudo_header *pseudo_header _U_, guint8 *pd, int len, diff --git a/wiretap/dbs-etherwatch.c b/wiretap/dbs-etherwatch.c index 984a5b28ed..4230aebe07 100644 --- a/wiretap/dbs-etherwatch.c +++ b/wiretap/dbs-etherwatch.c @@ -85,8 +85,8 @@ static const char dbs_etherwatch_rec_magic[] = #define DBS_ETHERWATCH_MAX_PACKET_LEN 16384 static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info, - long *data_offset); -static gboolean dbs_etherwatch_seek_read(wtap *wth, long seek_off, + gint64 *data_offset); +static gboolean dbs_etherwatch_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err, gchar **err_info); static int parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, @@ -97,11 +97,11 @@ static guint parse_hex_dump(char* dump, guint8 *buf, char seperator, char end); /* Seeks to the beginning of the next packet, and returns the byte offset. Returns -1 on failure, and sets "*err" to the error. */ -static long dbs_etherwatch_seek_next_packet(wtap *wth, int *err) +static gint64 dbs_etherwatch_seek_next_packet(wtap *wth, int *err) { int byte; unsigned int level = 0; - long cur_off; + gint64 cur_off; while ((byte = file_getc(wth->fh)) != EOF) { if (byte == dbs_etherwatch_rec_magic[level]) { @@ -206,9 +206,9 @@ int dbs_etherwatch_open(wtap *wth, int *err, gchar **err_info _U_) /* Find the next packet and parse it; called from wtap_read(). */ static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info, - long *data_offset) + gint64 *data_offset) { - long offset; + gint64 offset; guint8 *buf; int pkt_len; @@ -238,7 +238,7 @@ static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info, /* Used to read packets in random-access fashion */ static gboolean -dbs_etherwatch_seek_read (wtap *wth, long seek_off, +dbs_etherwatch_seek_read (wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header _U_, guint8 *pd, int len, int *err, gchar **err_info) { diff --git a/wiretap/erf.c b/wiretap/erf.c index ae5fcc237c..4961398b8d 100644 --- a/wiretap/erf.c +++ b/wiretap/erf.c @@ -69,8 +69,8 @@ static int erf_read_header( guint32 *bytes_read, guint32 *packet_size); static gboolean erf_read(wtap *wth, int *err, gchar **err_info, - long *data_offset); -static gboolean erf_seek_read(wtap *wth, long seek_off, + gint64 *data_offset); +static gboolean erf_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info); static void erf_close(wtap *wth); @@ -209,7 +209,7 @@ int erf_open(wtap *wth, int *err, gchar **err_info _U_) /* Read the next packet */ static gboolean erf_read(wtap *wth, int *err, gchar **err_info, - long *data_offset) + gint64 *data_offset) { erf_header_t erf_header; guint32 packet_size, bytes_read; @@ -249,7 +249,7 @@ static gboolean erf_read(wtap *wth, int *err, gchar **err_info, return TRUE; } -static gboolean erf_seek_read(wtap *wth, long seek_off, +static gboolean erf_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info) { diff --git a/wiretap/etherpeek.c b/wiretap/etherpeek.c index 6fc9ef1518..e7202f58a2 100644 --- a/wiretap/etherpeek.c +++ b/wiretap/etherpeek.c @@ -143,15 +143,15 @@ static const etherpeek_encap_lookup_t etherpeek_encap[] = { (sizeof (etherpeek_encap) / sizeof (etherpeek_encap[0])) static gboolean etherpeek_read_v7(wtap *wth, int *err, gchar **err_info, - long *data_offset); -static gboolean etherpeek_seek_read_v7(wtap *wth, long seek_off, + gint64 *data_offset); +static gboolean etherpeek_seek_read_v7(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info); static void etherpeek_fill_pseudo_header_v7( union wtap_pseudo_header *pseudo_header, airopeek_radio_hdr_t *radio_hdr); static gboolean etherpeek_read_v56(wtap *wth, int *err, gchar **err_info, - long *data_offset); -static gboolean etherpeek_seek_read_v56(wtap *wth, long seek_off, + gint64 *data_offset); +static gboolean etherpeek_seek_read_v56(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info); static void etherpeek_close(wtap *wth); @@ -363,7 +363,7 @@ static void etherpeek_close(wtap *wth) } static gboolean etherpeek_read_v7(wtap *wth, int *err, gchar **err_info, - long *data_offset) + gint64 *data_offset) { guchar ep_pkt[ETHERPEEK_V7_PKT_SIZE]; guint16 protoNum; @@ -468,7 +468,7 @@ static gboolean etherpeek_read_v7(wtap *wth, int *err, gchar **err_info, } static gboolean -etherpeek_seek_read_v7(wtap *wth, long seek_off, +etherpeek_seek_read_v7(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info) { @@ -533,7 +533,7 @@ etherpeek_fill_pseudo_header_v7(union wtap_pseudo_header *pseudo_header, } static gboolean etherpeek_read_v56(wtap *wth, int *err, gchar **err_info _U_, - long *data_offset) + gint64 *data_offset) { guchar ep_pkt[ETHERPEEK_V56_PKT_SIZE]; guint16 length; @@ -616,7 +616,7 @@ static gboolean etherpeek_read_v56(wtap *wth, int *err, gchar **err_info _U_, } static gboolean -etherpeek_seek_read_v56(wtap *wth, long seek_off, +etherpeek_seek_read_v56(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info _U_) { diff --git a/wiretap/eyesdn.c b/wiretap/eyesdn.c index ba674d48f7..a8f768b824 100644 --- a/wiretap/eyesdn.c +++ b/wiretap/eyesdn.c @@ -95,8 +95,8 @@ static const unsigned char eyesdn_hdr_magic[] = #define EYESDN_MAX_PACKET_LEN 16384 static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info, - long *data_offset); -static gboolean eyesdn_seek_read(wtap *wth, long seek_off, + gint64 *data_offset); +static gboolean eyesdn_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err, gchar **err_info); static gboolean parse_eyesdn_packet_data(FILE_T fh, int pkt_len, guint8* buf, @@ -106,10 +106,10 @@ static int parse_eyesdn_rec_hdr(wtap *wth, FILE_T fh, /* Seeks to the beginning of the next packet, and returns the byte offset. Returns -1 on failure, and sets "*err" to the error. */ -static long eyesdn_seek_next_packet(wtap *wth, int *err) +static gint64 eyesdn_seek_next_packet(wtap *wth, int *err) { int byte; - long cur_off; + gint64 cur_off; while ((byte = file_getc(wth->fh)) != EOF) { if (byte == 0xff) { @@ -163,9 +163,9 @@ int eyesdn_open(wtap *wth, int *err, gchar **err_info _U_) /* Find the next packet and parse it; called from wtap_read(). */ static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info, - long *data_offset) + gint64 *data_offset) { - long offset; + gint64 offset; guint8 *buf; int pkt_len; @@ -195,7 +195,7 @@ static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info, /* Used to read packets in random-access fashion */ static gboolean -eyesdn_seek_read (wtap *wth, long seek_off, +eyesdn_seek_read (wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err, gchar **err_info) { diff --git a/wiretap/file_access.c b/wiretap/file_access.c index 50f025b167..cf8792c74a 100644 --- a/wiretap/file_access.c +++ b/wiretap/file_access.c @@ -859,12 +859,12 @@ gboolean wtap_dump_close(wtap_dumper *wdh, int *err) return ret; } -long wtap_get_bytes_dumped(wtap_dumper *wdh) +gint64 wtap_get_bytes_dumped(wtap_dumper *wdh) { return wdh->bytes_dumped; } -void wtap_set_bytes_dumped(wtap_dumper *wdh, long bytes_dumped) +void wtap_set_bytes_dumped(wtap_dumper *wdh, gint64 bytes_dumped) { wdh->bytes_dumped = bytes_dumped; } diff --git a/wiretap/file_wrappers.c b/wiretap/file_wrappers.c index 487aa397d8..0e331eab69 100644 --- a/wiretap/file_wrappers.c +++ b/wiretap/file_wrappers.c @@ -115,7 +115,9 @@ #include "file_wrappers.h" #include "file_util.h" + #ifdef HAVE_LIBZ + FILE_T file_open(const char *path, const char *mode) { @@ -160,12 +162,13 @@ file_open(const char *path, const char *mode) return ft; } -long -file_seek(void *stream, long offset, int whence, int *err) +int +file_seek(void *stream, gint64 offset, int whence, int *err) { - long ret; + gint64 ret; - ret = gzseek(stream, (z_off_t)offset, whence); + /* XXX - z_off_t is usually long, won't work >= 2GB! */ + ret = (gint64) gzseek(stream, (z_off_t)offset, whence); if (ret == -1) { /* * XXX - "gzseek()", as of zlib 1.1.4, doesn't set @@ -183,30 +186,18 @@ file_seek(void *stream, long offset, int whence, int *err) return ret; } -long +gint64 file_tell(void *stream) { - return (long)gztell(stream); + /* XXX - z_off_t is usually long, won't work >= 2GB! */ + return (gint64)gztell(stream); } -#else /* HAVE_LIBZ */ -long -file_seek(void *stream, long offset, int whence, int *err) -{ - long ret; - - ret = fseek(stream, offset, whence); - if (ret == -1) - *err = file_error(stream); - return ret; -} -#endif /* HAVE_LIBZ */ /* * Routine to return a Wiretap error code (0 for no error, an errno * for a file error, or a WTAP_ERR_ code for other errors) for an * I/O stream. */ -#ifdef HAVE_LIBZ int file_error(void *fh) { @@ -228,13 +219,80 @@ file_error(void *fh) return WTAP_ERR_ZLIB + errnum; } } + #else /* HAVE_LIBZ */ + +gint64 +file_seek(void *stream, gint64 offset, int whence, int *err) +{ + gint64 ret; +#ifdef _WIN32 + gint64 pos; +#endif + +#ifdef _WIN32 + /* Win32 version using fsetpos/fgetpos */ + /* XXX - using fsetpos/fgetpos this way is UNDOCUMENTED, but I don't see a any better way :-( */ + /* _lseeki64(_fileno(stream)) doesn't work as this will mangle the internal FILE handling data */ + switch(whence) { + case(SEEK_SET): + /* do nothing */ + break; + case(SEEK_CUR): + /* adjust offset */ + /* XXX - CURRENTLY UNTESTED!!! */ + ret = fgetpos(stream, &pos); + if(ret != 0) { + *err = errno; + return ret; + } + offset += pos; + break; + case(SEEK_END): + default: + g_assert_not_reached(); + } + ret = fsetpos(stream, &offset); + if(ret != 0) { + *err = errno; + } + /* XXX - won't work >= 2GB! */ + /*ret = (gint64) fseek(stream, (long) offset, whence); + if(ret == -1) { + *err = errno; + }*/ +#else + /* "basic" version using fseek */ + /* XXX - won't work >= 2GB! */ + ret = (gint64) fseek(stream, (long) offset, whence); + if (ret == -1) + *err = file_error(stream); +#endif + /*g_warning("Seek %lld whence %u ret %lld size %u", offset, whence, ret, sizeof(fpos_t));*/ + return ret; +} + +gint64 +file_tell(void *stream) +{ +#ifdef _WIN32 + /* Win32 version using _telli64 */ + /* XXX - CURRENTLY UNTESTED!!! */ + return _telli64(_fileno((FILE *)stream)); +#else + /* "basic" version using ftell */ + /* XXX - ftell returns a long - won't work >= 2GB! */ + return (gint64) ftell(stream); +#endif +} + int -file_error(FILE *fh) +file_error(void *fh) { - if (ferror(fh)) + if (ferror((FILE *) fh)) return errno; else return 0; } + #endif /* HAVE_LIBZ */ diff --git a/wiretap/file_wrappers.h b/wiretap/file_wrappers.h index c5ace29953..9dcf643ff6 100644 --- a/wiretap/file_wrappers.h +++ b/wiretap/file_wrappers.h @@ -24,29 +24,28 @@ #ifndef __FILE_H__ #define __FILE_H__ +extern gint64 file_seek(void *stream, gint64 offset, int whence, int *err); +extern gint64 file_tell(void *stream); +extern int file_error(void *fh); + #ifdef HAVE_LIBZ extern FILE_T file_open(const char *path, const char *mode); #define filed_open gzdopen -extern long file_seek(void *stream, long offset, int whence, int *err); #define file_read(buf, bsize, count, file) gzread((file),(buf),((count)*(bsize))) #define file_write(buf, bsize, count, file) gzwrite((file),(buf),((count)*(bsize))) #define file_close gzclose -extern long file_tell(void *stream); #define file_getc gzgetc #define file_gets(buf, len, file) gzgets((file), (buf), (len)) -extern int file_error(void *fh); #define file_eof gzeof #else /* No zLib */ +/* XXX - mixing eth_xxx and fxxx calls might not be a good idea with MSVC 2005! */ #define file_open(path, mode) eth_fopen(path, mode) #define filed_open fdopen -extern long file_seek(void *stream, long offset, int whence, int *err); #define file_read fread #define file_write fwrite #define file_close fclose -extern int file_error(FILE *fh); -#define file_tell ftell #define file_getc fgetc #define file_gets fgets #define file_eof feof diff --git a/wiretap/hcidump.c b/wiretap/hcidump.c index be699200a1..c67b206efd 100644 --- a/wiretap/hcidump.c +++ b/wiretap/hcidump.c @@ -39,7 +39,7 @@ struct dump_hdr { #define DUMP_HDR_SIZE (sizeof(struct dump_hdr)) static gboolean hcidump_read(wtap *wth, int *err, gchar **err_info, - long *data_offset) + gint64 *data_offset) { struct dump_hdr dh; guint8 *buf; @@ -90,7 +90,7 @@ static gboolean hcidump_read(wtap *wth, int *err, gchar **err_info, return TRUE; } -static gboolean hcidump_seek_read(wtap *wth, long seek_off, +static gboolean hcidump_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int length, int *err, gchar **err_info _U_) { diff --git a/wiretap/i4btrace.c b/wiretap/i4btrace.c index 9b9d2d6a7c..97515ddf94 100644 --- a/wiretap/i4btrace.c +++ b/wiretap/i4btrace.c @@ -34,8 +34,8 @@ #include "i4btrace.h" static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info, - long *data_offset); -static gboolean i4btrace_seek_read(wtap *wth, long seek_off, + gint64 *data_offset); +static gboolean i4btrace_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info); static int i4b_read_rec_header(FILE_T fh, i4b_trace_hdr_t *hdr, int *err); @@ -116,7 +116,7 @@ int i4btrace_open(wtap *wth, int *err, gchar **err_info _U_) /* Read the next packet */ static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info, - long *data_offset) + gint64 *data_offset) { int ret; i4b_trace_hdr_t hdr; @@ -182,7 +182,7 @@ static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info, } static gboolean -i4btrace_seek_read(wtap *wth, long seek_off, +i4btrace_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info _U_) { diff --git a/wiretap/iptrace.c b/wiretap/iptrace.c index 409f509bdc..2a50dad172 100644 --- a/wiretap/iptrace.c +++ b/wiretap/iptrace.c @@ -33,14 +33,14 @@ #include "iptrace.h" static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info, - long *data_offset); -static gboolean iptrace_seek_read_1_0(wtap *wth, long seek_off, + gint64 *data_offset); +static gboolean iptrace_seek_read_1_0(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size, int *err, gchar **err_info); static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info, - long *data_offset); -static gboolean iptrace_seek_read_2_0(wtap *wth, long seek_off, + gint64 *data_offset); +static gboolean iptrace_seek_read_2_0(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size, int *err, gchar **err_info); @@ -124,7 +124,7 @@ typedef struct { /* Read the next packet */ static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info _U_, - long *data_offset) + gint64 *data_offset) { int ret; guint32 packet_size; @@ -211,7 +211,7 @@ static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info _U_, return TRUE; } -static gboolean iptrace_seek_read_1_0(wtap *wth, long seek_off, +static gboolean iptrace_seek_read_1_0(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size, int *err, gchar **err_info _U_) { @@ -303,7 +303,7 @@ typedef struct { /* Read the next packet */ static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info _U_, - long *data_offset) + gint64 *data_offset) { int ret; guint32 packet_size; @@ -390,7 +390,7 @@ static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info _U_, return TRUE; } -static gboolean iptrace_seek_read_2_0(wtap *wth, long seek_off, +static gboolean iptrace_seek_read_2_0(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size, int *err, gchar **err_info _U_) { diff --git a/wiretap/iseries.c b/wiretap/iseries.c index ba278c6437..1b93bcb9b7 100644 --- a/wiretap/iseries.c +++ b/wiretap/iseries.c @@ -137,13 +137,13 @@ #define ISERIES_FORMAT_UNICODE 2 static gboolean iseries_read (wtap * wth, int *err, gchar ** err_info, - long *data_offset); -static gboolean iseries_seek_read (wtap * wth, long seek_off, + gint64 *data_offset); +static gboolean iseries_seek_read (wtap * wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guint8 * pd, int len, int *err, gchar ** err_info); static gboolean iseries_check_file_type (wtap * wth, int *err, int format); -static long iseries_seek_next_packet (wtap * wth, int *err); +static gint64 iseries_seek_next_packet (wtap * wth, int *err); static int iseries_parse_packet (wtap * wth, FILE_T fh, union wtap_pseudo_header *pseudo_header, guint8 * pd, int *err, gchar ** err_info); @@ -332,9 +332,9 @@ iseries_check_file_type (wtap * wth, int *err, int format) * Find the next packet and parse it; called from wtap_read(). */ static gboolean -iseries_read (wtap * wth, int *err, gchar ** err_info, long *data_offset) +iseries_read (wtap * wth, int *err, gchar ** err_info, gint64 *data_offset) { - long offset; + gint64 offset; int pkt_len; /* @@ -362,12 +362,13 @@ iseries_read (wtap * wth, int *err, gchar ** err_info, long *data_offset) * Seeks to the beginning of the next packet, and returns the * byte offset. Returns -1 on failure, and sets "*err" to the error. */ -static long +static gint64 iseries_seek_next_packet (wtap * wth, int *err) { char buf[ISERIES_LINE_LENGTH]; int line; - long cur_off, buflen; + gint64 cur_off; + long buflen; /* * Seeks to the beginning of the next packet, and returns the @@ -432,7 +433,7 @@ iseries_seek_next_packet (wtap * wth, int *err) * Read packets in random-access fashion */ static gboolean -iseries_seek_read (wtap * wth, long seek_off, +iseries_seek_read (wtap * wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guint8 * pd, int len, int *err, gchar ** err_info) { @@ -469,7 +470,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh, union wtap_pseudo_header *pseudo_header, guint8 * pd, int *err, gchar ** err_info) { - long cur_off; + gint64 cur_off; gboolean isValid, isCurrentPacket, IPread, TCPread, isDATA; int num_items_scanned, line, pktline, buflen; int pkt_len, cap_len, pktnum, month, day, year, hr, min, sec, csec; diff --git a/wiretap/k12.c b/wiretap/k12.c index 4c9a67e525..5b4bf4446d 100644 --- a/wiretap/k12.c +++ b/wiretap/k12.c @@ -174,14 +174,14 @@ typedef struct _k12_src_desc_t { * * XXX: works at most with 0x1FFF bytes per record */ -static gint get_record(guint8* buffer, FILE* fh, guint file_offset) { +static gint get_record(guint8* buffer, FILE* fh, gint64 file_offset) { long read; long len; - int i; - long junky_offset = 0x2000 - ( (file_offset - 0x200) % 0x2000 ); + gint64 i; + gint64 junky_offset = 0x2000 - ( (file_offset - 0x200) % 0x2000 ); #ifdef DEBUG_K12 - k12_dbg(5,"k12:get_record: ENTER offset=%u",file_offset); + k12_dbg(5,"k12:get_record: ENTER offset=%lld",file_offset); #endif if ( junky_offset != 0x2000 ) { @@ -289,10 +289,10 @@ static gint get_record(guint8* buffer, FILE* fh, guint file_offset) { } } -static gboolean k12_read(wtap *wth, int *err, gchar **err_info _U_, long *data_offset) { +static gboolean k12_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data_offset) { k12_src_desc_t* src_desc; guint8 buffer[0x2000]; - long offset; + gint64 offset; long len; guint32 type; guint64 ts; @@ -390,7 +390,7 @@ static gboolean k12_read(wtap *wth, int *err, gchar **err_info _U_, long *data_o } -static gboolean k12_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err _U_, gchar **err_info _U_) { +static gboolean k12_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err _U_, gchar **err_info _U_) { k12_src_desc_t* src_desc; guint8 buffer[0x2000]; guint32 input; diff --git a/wiretap/lanalyzer.c b/wiretap/lanalyzer.c index 49266d811c..c0a16ab980 100644 --- a/wiretap/lanalyzer.c +++ b/wiretap/lanalyzer.c @@ -118,8 +118,8 @@ static const guint8 LA_CyclicInformationFake[] = { }; static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info, - long *data_offset); -static gboolean lanalyzer_seek_read(wtap *wth, long seek_off, + gint64 *data_offset); +static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info); static void lanalyzer_close(wtap *wth); @@ -274,7 +274,7 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info) /* Read the next packet */ static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info, - long *data_offset) + gint64 *data_offset) { int packet_size = 0; int bytes_read; @@ -396,7 +396,7 @@ static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info, return TRUE; } -static gboolean lanalyzer_seek_read(wtap *wth, long seek_off, +static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info _U_) { diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c index 0d782d3b50..997b63f896 100644 --- a/wiretap/libpcap.c +++ b/wiretap/libpcap.c @@ -113,8 +113,8 @@ typedef enum { static libpcap_try_t libpcap_try(wtap *wth, int *err); static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info, - long *data_offset); -static gboolean libpcap_seek_read(wtap *wth, long seek_off, + gint64 *data_offset); +static gboolean libpcap_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info); static int libpcap_read_header(wtap *wth, int *err, gchar **err_info, @@ -1154,7 +1154,7 @@ static libpcap_try_t libpcap_try(wtap *wth, int *err) /* Read the next packet */ static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info, - long *data_offset) + gint64 *data_offset) { struct pcaprec_ss990915_hdr hdr; guint packet_size; @@ -1392,7 +1392,7 @@ static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info, } static gboolean -libpcap_seek_read(wtap *wth, long seek_off, +libpcap_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info) { diff --git a/wiretap/netmon.c b/wiretap/netmon.c index 19eb125bcd..7f21ac2d01 100644 --- a/wiretap/netmon.c +++ b/wiretap/netmon.c @@ -105,8 +105,8 @@ struct netmon_atm_hdr { }; static gboolean netmon_read(wtap *wth, int *err, gchar **err_info, - long *data_offset); -static gboolean netmon_seek_read(wtap *wth, long seek_off, + gint64 *data_offset); +static gboolean netmon_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info); static gboolean netmon_read_atm_pseudoheader(FILE_T fh, @@ -306,7 +306,7 @@ int netmon_open(wtap *wth, int *err, gchar **err_info) /* Read the next packet */ static gboolean netmon_read(wtap *wth, int *err, gchar **err_info, - long *data_offset) + gint64 *data_offset) { netmon_t *netmon = wth->capture.netmon; guint32 packet_size = 0; @@ -471,7 +471,7 @@ static gboolean netmon_read(wtap *wth, int *err, gchar **err_info, } static gboolean -netmon_seek_read(wtap *wth, long seek_off, +netmon_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info _U_) { diff --git a/wiretap/nettl.c b/wiretap/nettl.c index 0911388cec..6aaf73219b 100644 --- a/wiretap/nettl.c +++ b/wiretap/nettl.c @@ -175,8 +175,8 @@ struct nettlrec_ns_ls_drv_eth_hdr { /* header is followed by data and once again the total length (2 bytes) ! */ static gboolean nettl_read(wtap *wth, int *err, gchar **err_info, - long *data_offset); -static gboolean nettl_seek_read(wtap *wth, long seek_off, + gint64 *data_offset); +static gboolean nettl_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info); static int nettl_read_rec_header(wtap *wth, FILE_T fh, @@ -285,7 +285,7 @@ int nettl_open(wtap *wth, int *err, gchar **err_info _U_) /* Read the next packet */ static gboolean nettl_read(wtap *wth, int *err, gchar **err_info, - long *data_offset) + gint64 *data_offset) { int ret; gboolean fddihack=FALSE; @@ -327,7 +327,7 @@ static gboolean nettl_read(wtap *wth, int *err, gchar **err_info, } static gboolean -nettl_seek_read(wtap *wth, long seek_off, +nettl_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info) { diff --git a/wiretap/network_instruments.c b/wiretap/network_instruments.c index 6a7952fcf6..c36611ec3a 100644 --- a/wiretap/network_instruments.c +++ b/wiretap/network_instruments.c @@ -89,8 +89,8 @@ static void init_time_offset(void) } static gboolean observer_read(wtap *wth, int *err, gchar **err_info, - long *data_offset); -static gboolean observer_seek_read(wtap *wth, long seek_off, + gint64 *data_offset); +static gboolean observer_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info); static int read_packet_header(FILE_T fh, packet_entry_header *packet_header, @@ -230,7 +230,7 @@ int network_instruments_open(wtap *wth, int *err, gchar **err_info) /* reads the next packet */ static gboolean observer_read(wtap *wth, int *err, gchar **err_info, - long *data_offset) + gint64 *data_offset) { int offset; packet_entry_header packet_header; @@ -280,7 +280,7 @@ static gboolean observer_read(wtap *wth, int *err, gchar **err_info, GUINT64_FROM_LE(packet_header.nano_seconds_since_2000); wth->phdr.ts.secs = (time_t) (packet_header.nano_seconds_since_2000/1000000000 + seconds1970to2000); - wth->phdr.ts.nsecs = packet_header.nano_seconds_since_2000%1000000000; + wth->phdr.ts.nsecs = (int) (packet_header.nano_seconds_since_2000%1000000000); /* set-up the packet buffer */ buffer_assure_space(wth->frame_buffer, packet_header.captured_size); @@ -306,7 +306,7 @@ static gboolean observer_read(wtap *wth, int *err, gchar **err_info, } /* reads a packet at an offset */ -static gboolean observer_seek_read(wtap *wth, long seek_off, +static gboolean observer_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info) { diff --git a/wiretap/netxray.c b/wiretap/netxray.c index c7d3b05f41..aadf4fb05e 100644 --- a/wiretap/netxray.c +++ b/wiretap/netxray.c @@ -274,8 +274,8 @@ union netxrayrec_hdr { }; static gboolean netxray_read(wtap *wth, int *err, gchar **err_info, - long *data_offset); -static gboolean netxray_seek_read(wtap *wth, long seek_off, + gint64 *data_offset); +static gboolean netxray_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info); static int netxray_read_rec_header(wtap *wth, FILE_T fh, @@ -833,7 +833,7 @@ int netxray_open(wtap *wth, int *err, gchar **err_info) /* Read the next packet */ static gboolean netxray_read(wtap *wth, int *err, gchar **err_info _U_, - long *data_offset) + gint64 *data_offset) { guint32 packet_size; union netxrayrec_hdr hdr; @@ -961,7 +961,7 @@ reread: } static gboolean -netxray_seek_read(wtap *wth, long seek_off, +netxray_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info _U_) { diff --git a/wiretap/ngsniffer.c b/wiretap/ngsniffer.c index 4ec972408c..3d6ea5cf81 100644 --- a/wiretap/ngsniffer.c +++ b/wiretap/ngsniffer.c @@ -430,8 +430,8 @@ static int process_rec_header2_v2(wtap *wth, unsigned char *buffer, static int process_rec_header2_v145(wtap *wth, unsigned char *buffer, guint16 length, gint16 maj_vers, int *err, gchar **err_info); static gboolean ngsniffer_read(wtap *wth, int *err, gchar **err_info, - long *data_offset); -static gboolean ngsniffer_seek_read(wtap *wth, long seek_off, + gint64 *data_offset); +static gboolean ngsniffer_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size, int *err, gchar **err_info); static int ngsniffer_read_rec_header(wtap *wth, gboolean is_random, @@ -464,8 +464,8 @@ static int ng_file_read(void *buffer, size_t elementsize, size_t numelements, wtap *wth, gboolean is_random, int *err); static int read_blob(FILE_T infile, ngsniffer_comp_stream_t *comp_stream, int *err); -static long ng_file_seek_seq(wtap *wth, long offset, int whence, int *err); -static long ng_file_seek_rand(wtap *wth, long offset, int whence, int *err); +static gint64 ng_file_seek_seq(wtap *wth, gint64 offset, int whence, int *err); +static gint64 ng_file_seek_rand(wtap *wth, gint64 offset, int whence, int *err); int ngsniffer_open(wtap *wth, int *err, gchar **err_info) { @@ -967,7 +967,7 @@ process_rec_header2_v145(wtap *wth, unsigned char *buffer, guint16 length, /* Read the next packet */ static gboolean ngsniffer_read(wtap *wth, int *err, gchar **err_info, - long *data_offset) + gint64 *data_offset) { int ret; guint16 type, length; @@ -1156,7 +1156,7 @@ found: return TRUE; } -static gboolean ngsniffer_seek_read(wtap *wth, long seek_off, +static gboolean ngsniffer_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size, int *err, gchar **err_info _U_) { @@ -2335,8 +2335,8 @@ SnifferDecompress( unsigned char * inbuf, size_t inlen, underlying compressed file, and the offset in the uncompressed data stream, of the blob. */ typedef struct { - long blob_comp_offset; - long blob_uncomp_offset; + gint64 blob_comp_offset; + gint64 blob_uncomp_offset; } blob_info_t; static int @@ -2504,10 +2504,10 @@ read_blob(FILE_T infile, ngsniffer_comp_stream_t *comp_stream, int *err) /* Seek in the sequential data stream; we can only seek forward, and we do it on compressed files by skipping forward. */ -static long -ng_file_seek_seq(wtap *wth, long offset, int whence, int *err) +static gint64 +ng_file_seek_seq(wtap *wth, gint64 offset, int whence, int *err) { - long delta; + gint64 delta; char buf[65536]; long amount_to_read; @@ -2533,7 +2533,7 @@ ng_file_seek_seq(wtap *wth, long offset, int whence, int *err) /* Ok, now read and discard "delta" bytes. */ while (delta != 0) { - amount_to_read = delta; + amount_to_read = (long) delta; if ((unsigned long)amount_to_read > sizeof buf) amount_to_read = sizeof buf; if (ng_file_read(buf, 1, amount_to_read, wth, FALSE, err) < 0) @@ -2551,11 +2551,11 @@ ng_file_seek_seq(wtap *wth, long offset, int whence, int *err) we're seeking, and read that blob in. We can then move to the appropriate position within the blob we have in memory (whether it's the blob we already had in memory or, if necessary, the one we read in). */ -static long -ng_file_seek_rand(wtap *wth, long offset, int whence, int *err) +static gint64 +ng_file_seek_rand(wtap *wth, gint64 offset, int whence, int *err) { ngsniffer_t *ngsniffer; - long delta; + gint64 delta; GList *new, *next; blob_info_t *next_blob, *new_blob; @@ -2662,7 +2662,7 @@ ng_file_seek_rand(wtap *wth, long offset, int whence, int *err) "ngsniffer->rand.nextout" to point to the place to which we're seeking, and adjust "ngsniffer->rand.uncomp_offset" to be the destination offset. */ - ngsniffer->rand.nextout += delta; + ngsniffer->rand.nextout += (int) delta; ngsniffer->rand.uncomp_offset += delta; return offset; diff --git a/wiretap/pppdump.c b/wiretap/pppdump.c index 9513d6ab8f..3e19a59529 100644 --- a/wiretap/pppdump.c +++ b/wiretap/pppdump.c @@ -100,8 +100,8 @@ typedef enum { } direction_enum; static gboolean pppdump_read(wtap *wth, int *err, gchar **err_info, - long *data_offset); -static gboolean pppdump_seek_read(wtap *wth, long seek_off, + gint64 *data_offset); +static gboolean pppdump_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err, gchar **err_info); @@ -313,7 +313,7 @@ pppdump_open(wtap *wth, int *err, gchar **err_info _U_) /* Find the next packet and parse it; called from wtap_read(). */ static gboolean -pppdump_read(wtap *wth, int *err, gchar **err_info, long *data_offset) +pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { int num_bytes; direction_enum direction; @@ -702,7 +702,7 @@ done: /* Used to read packets in random-access fashion */ static gboolean pppdump_seek_read(wtap *wth, - long seek_off, + gint64 seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, diff --git a/wiretap/radcom.c b/wiretap/radcom.c index c32bfbaa3b..16ccd6bb40 100644 --- a/wiretap/radcom.c +++ b/wiretap/radcom.c @@ -90,8 +90,8 @@ struct radcomrec_hdr { }; static gboolean radcom_read(wtap *wth, int *err, gchar **err_info, - long *data_offset); -static gboolean radcom_seek_read(wtap *wth, long seek_off, + gint64 *data_offset); +static gboolean radcom_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info); static int radcom_read_rec_header(FILE_T fh, struct radcomrec_hdr *hdr, @@ -267,7 +267,7 @@ read_error: /* Read the next packet */ static gboolean radcom_read(wtap *wth, int *err, gchar **err_info _U_, - long *data_offset) + gint64 *data_offset) { int ret; struct radcomrec_hdr hdr; @@ -373,7 +373,7 @@ static gboolean radcom_read(wtap *wth, int *err, gchar **err_info _U_, } static gboolean -radcom_seek_read(wtap *wth, long seek_off, +radcom_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info _U_) { diff --git a/wiretap/snoop.c b/wiretap/snoop.c index 1c0125c159..cc6d62afdc 100644 --- a/wiretap/snoop.c +++ b/wiretap/snoop.c @@ -89,8 +89,8 @@ struct shomiti_trailer { #define RX_STATUS_TRIGGERED 0x0001 /* frame did trigger */ static gboolean snoop_read(wtap *wth, int *err, gchar **err_info, - long *data_offset); -static gboolean snoop_seek_read(wtap *wth, long seek_off, + gint64 *data_offset); +static gboolean snoop_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info); static gboolean snoop_read_atm_pseudoheader(FILE_T fh, @@ -404,7 +404,7 @@ int snoop_open(wtap *wth, int *err, gchar **err_info) /* Read the next packet */ static gboolean snoop_read(wtap *wth, int *err, gchar **err_info, - long *data_offset) + gint64 *data_offset) { guint32 rec_size; guint32 packet_size; @@ -554,7 +554,7 @@ static gboolean snoop_read(wtap *wth, int *err, gchar **err_info, } static gboolean -snoop_seek_read(wtap *wth, long seek_off, +snoop_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err, gchar **err_info _U_) { diff --git a/wiretap/toshiba.c b/wiretap/toshiba.c index 824b0a1591..a6d67900fe 100644 --- a/wiretap/toshiba.c +++ b/wiretap/toshiba.c @@ -110,8 +110,8 @@ static const char toshiba_rec_magic[] = { '[', 'N', 'o', '.' }; #define TOSHIBA_MAX_PACKET_LEN 16384 static gboolean toshiba_read(wtap *wth, int *err, gchar **err_info, - long *data_offset); -static gboolean toshiba_seek_read(wtap *wth, long seek_off, + gint64 *data_offset); +static gboolean toshiba_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err, gchar **err_info); static gboolean parse_single_hex_dump_line(char* rec, guint8 *buf, @@ -123,11 +123,11 @@ static int parse_toshiba_rec_hdr(wtap *wth, FILE_T fh, /* Seeks to the beginning of the next packet, and returns the byte offset. Returns -1 on failure, and sets "*err" to the error. */ -static long toshiba_seek_next_packet(wtap *wth, int *err) +static gint64 toshiba_seek_next_packet(wtap *wth, int *err) { int byte; guint level = 0; - long cur_off; + gint64 cur_off; while ((byte = file_getc(wth->fh)) != EOF) { if (byte == toshiba_rec_magic[level]) { @@ -233,9 +233,9 @@ int toshiba_open(wtap *wth, int *err, gchar **err_info _U_) /* Find the next packet and parse it; called from wtap_read(). */ static gboolean toshiba_read(wtap *wth, int *err, gchar **err_info, - long *data_offset) + gint64 *data_offset) { - long offset; + gint64 offset; guint8 *buf; int pkt_len; @@ -265,7 +265,7 @@ static gboolean toshiba_read(wtap *wth, int *err, gchar **err_info, /* Used to read packets in random-access fashion */ static gboolean -toshiba_seek_read (wtap *wth, long seek_off, +toshiba_seek_read (wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err, gchar **err_info) { diff --git a/wiretap/visual.c b/wiretap/visual.c index 2f4b23678b..332f985f26 100644 --- a/wiretap/visual.c +++ b/wiretap/visual.c @@ -113,9 +113,9 @@ struct visual_write_info /* Local functions to handle file reads and writes */ static gboolean visual_read(wtap *wth, int *err, gchar **err_info, - long *data_offset); + gint64 *data_offset); static void visual_close(wtap *wth); -static gboolean visual_seek_read(wtap *wth, long seek_off, +static gboolean visual_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size, int *err, gchar **err_info); static void visual_set_pseudo_header(int encap, struct visual_pkt_hdr *vpkt_hdr, @@ -233,7 +233,7 @@ int visual_open(wtap *wth, int *err, gchar **err_info) the file has been read once, any Future access to the packets is done through seek_read. */ static gboolean visual_read(wtap *wth, int *err, gchar **err_info, - long *data_offset) + gint64 *data_offset) { struct visual_read_info *visual = wth->capture.generic; guint32 packet_size = 0; @@ -330,7 +330,7 @@ static void visual_close(wtap *wth) /* Read packet data for random access. This gets the packet data and rebuilds the pseudo header so that the direction flag works. */ -static gboolean visual_seek_read (wtap *wth, long seek_off, +static gboolean visual_seek_read (wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err, gchar **err_info _U_) { diff --git a/wiretap/vms.c b/wiretap/vms.c index 81b00986dc..38fbb9e124 100644 --- a/wiretap/vms.c +++ b/wiretap/vms.c @@ -144,8 +144,8 @@ to handle them. #define VMS_LINE_LENGTH 240 static gboolean vms_read(wtap *wth, int *err, gchar **err_info, - long *data_offset); -static gboolean vms_seek_read(wtap *wth, long seek_off, + gint64 *data_offset); +static gboolean vms_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err, gchar **err_info); static gboolean parse_single_hex_dump_line(char* rec, guint8 *buf, @@ -210,7 +210,7 @@ static gboolean vms_check_file_type(wtap *wth, int *err) { char buf[VMS_LINE_LENGTH]; guint reclen, line; - long mpos; + gint64 mpos; buf[VMS_LINE_LENGTH-1] = '\0'; @@ -278,9 +278,9 @@ int vms_open(wtap *wth, int *err, gchar **err_info _U_) /* Find the next packet and parse it; called from wtap_read(). */ static gboolean vms_read(wtap *wth, int *err, gchar **err_info, - long *data_offset) + gint64 *data_offset) { - long offset = 0; + gint64 offset = 0; guint8 *buf; int pkt_len; @@ -313,7 +313,7 @@ static gboolean vms_read(wtap *wth, int *err, gchar **err_info, /* Used to read packets in random-access fashion */ static gboolean -vms_seek_read (wtap *wth, long seek_off, +vms_seek_read (wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header _U_, guint8 *pd, int len, int *err, gchar **err_info) { diff --git a/wiretap/wtap-int.h b/wiretap/wtap-int.h index 847ed8d2df..dabd8905c8 100644 --- a/wiretap/wtap-int.h +++ b/wiretap/wtap-int.h @@ -48,8 +48,8 @@ typedef struct { unsigned char *buf; /* buffer into which we uncompress data */ size_t nbytes; /* number of bytes of data in that buffer */ int nextout; /* offset in that buffer of stream's current position */ - long comp_offset; /* current offset in compressed data stream */ - long uncomp_offset; /* current offset in uncompressed data stream */ + gint64 comp_offset; /* current offset in compressed data stream */ + gint64 uncomp_offset; /* current offset in uncompressed data stream */ } ngsniffer_comp_stream_t; typedef struct { @@ -111,8 +111,8 @@ typedef struct { double start_timestamp; gboolean wrapped; guint32 nframes; - long start_offset; - long end_offset; + gint64 start_offset; + gint64 end_offset; int version_major; gboolean fcs_valid; /* if packets have valid FCS at the end */ guint isdn_type; /* 1 = E1 PRI, 2 = T1 PRI, 3 = BRI */ @@ -121,7 +121,7 @@ typedef struct { typedef struct { time_t inittime; int adjusted; - long next_packet_seek_start; + gint64 next_packet_seek_start; } ascend_t; typedef struct { @@ -149,8 +149,8 @@ typedef struct { guint32 start_usecs; } catapult_dct2000_t; -typedef gboolean (*subtype_read_func)(struct wtap*, int*, char**, long*); -typedef gboolean (*subtype_seek_read_func)(struct wtap*, long, union wtap_pseudo_header*, +typedef gboolean (*subtype_read_func)(struct wtap*, int*, char**, gint64*); +typedef gboolean (*subtype_seek_read_func)(struct wtap*, gint64, union wtap_pseudo_header*, guint8*, int, int *, char **); struct wtap { FILE_T fh; @@ -162,7 +162,7 @@ struct wtap { struct wtap_pkthdr phdr; union wtap_pseudo_header pseudo_header; - long data_offset; + gint64 data_offset; union { libpcap_t *pcap; @@ -248,7 +248,7 @@ struct wtap_dumper { int snaplen; int encap; gboolean compressed; - long bytes_dumped; + gint64 bytes_dumped; union { void *opaque; diff --git a/wiretap/wtap.c b/wiretap/wtap.c index 05246628b8..2648e1dfc1 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -492,7 +492,7 @@ wtap_close(wtap *wth) } gboolean -wtap_read(wtap *wth, int *err, gchar **err_info, long *data_offset) +wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { /* * Set the packet encapsulation to the file's encapsulation @@ -562,7 +562,7 @@ wtap_buf_ptr(wtap *wth) } gboolean -wtap_seek_read(wtap *wth, long seek_off, +wtap_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err, gchar **err_info) { diff --git a/wiretap/wtap.h b/wiretap/wtap.h index ebae43f763..eadee8d6df 100644 --- a/wiretap/wtap.h +++ b/wiretap/wtap.h @@ -513,7 +513,7 @@ struct catapult_dct2000_phdr struct atm_phdr atm; struct p2p_phdr p2p; } inner_pseudo_header; - long seek_off; + gint64 seek_off; struct wtap *wth; }; @@ -574,11 +574,11 @@ struct wtap* wtap_open_offline(const char *filename, int *err, * set the the offset in the file where the data for the read packet is * located. */ gboolean wtap_read(wtap *wth, int *err, gchar **err_info, - long *data_offset); + gint64 *data_offset); /* * Return an approximation of the amount of data we've read sequentially - * from the file so far. (gint64, in case that's 64 bits.) + * from the file so far. */ gint64 wtap_read_so_far(wtap *wth, int *err); @@ -606,7 +606,7 @@ int wtap_short_string_to_encap(const char *short_name); const char *wtap_strerror(int err); void wtap_sequential_close(wtap *wth); void wtap_close(wtap *wth); -gboolean wtap_seek_read (wtap *wth, long seek_off, +gboolean wtap_seek_read (wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err, gchar **err_info); @@ -621,8 +621,8 @@ gboolean wtap_dump(wtap_dumper *, const struct wtap_pkthdr *, const union wtap_pseudo_header *pseudo_header, const guchar *, int *err); void wtap_dump_flush(wtap_dumper *); gboolean wtap_dump_close(wtap_dumper *, int *); -long wtap_get_bytes_dumped(wtap_dumper *); -void wtap_set_bytes_dumped(wtap_dumper *wdh, long bytes_dumped); +gint64 wtap_get_bytes_dumped(wtap_dumper *); +void wtap_set_bytes_dumped(wtap_dumper *wdh, gint64 bytes_dumped); /* * Wiretap error codes.