$OpenBSD: patch-tcpslice_c,v 1.1 2001/10/18 15:12:40 naddy Exp $
--- tcpslice.c.orig	Fri Oct 12 18:24:23 2001
+++ tcpslice.c	Fri Oct 12 18:28:45 2001
@@ -71,14 +71,14 @@ enum stamp_styles timestamp_style = TIME
 
 
 int is_timestamp( char *str );
-struct timeval parse_time(char *time_string, struct timeval base_time);
+struct bpf_timeval parse_time(char *time_string, struct bpf_timeval base_time);
 void fill_tm(char *time_string, int is_delta, struct tm *t, time_t *usecs_addr);
 void get_file_range( char filename[], pcap_t **p,
-			struct timeval *first_time, struct timeval *last_time );
-struct timeval first_packet_time(char filename[], pcap_t **p_addr);
+			struct bpf_timeval *first_time, struct bpf_timeval *last_time );
+struct bpf_timeval first_packet_time(char filename[], pcap_t **p_addr);
 void extract_slice(char filename[], char write_file_name[],
-			struct timeval *start_time, struct timeval *stop_time);
-char *timestamp_to_string(struct timeval *timestamp);
+			struct bpf_timeval *start_time, struct bpf_timeval *stop_time);
+char *timestamp_to_string(struct bpf_timeval *timestamp);
 void dump_times(pcap_t **p, char filename[]);
 __dead void usage(void)__attribute__((volatile));
 
@@ -98,7 +98,7 @@ main(int argc, char **argv)
 	char *start_time_string = 0;
 	char *stop_time_string = 0;
 	char *write_file_name = "-";	/* default is stdout */
-	struct timeval first_time, start_time, stop_time;
+	struct bpf_timeval first_time, start_time, stop_time;
 	pcap_t *pcap;
 	char ebuf[PCAP_ERRBUF_SIZE];
 
@@ -223,15 +223,19 @@ int is_timestamp( char *str )
  * containing the specified time.
  */
 
-struct timeval
-parse_time(char *time_string, struct timeval base_time)
+struct bpf_timeval
+parse_time(char *time_string, struct bpf_timeval base_time)
 {
-	struct tm *bt = localtime((time_t *) &base_time.tv_sec);
+	struct tm *bt;
 	struct tm t;
-	struct timeval result;
+	struct bpf_timeval result;
+	time_t secs;
 	time_t usecs = 0;
 	int is_delta = (time_string[0] == '+');
 
+	secs = base_time.tv_sec;
+	bt = localtime(&secs);
+
 	if ( is_delta )
 		++time_string;	/* skip over '+' sign */
 
@@ -412,7 +416,7 @@ fill_tm(char *time_string, int is_delta,
  */
 void
 get_file_range( char filename[], pcap_t **p,
-		struct timeval *first_time, struct timeval *last_time )
+		struct bpf_timeval *first_time, struct bpf_timeval *last_time )
 {
 	*first_time = first_packet_time( filename, p );
 
@@ -427,7 +431,7 @@ int snaplen;
  * reading.
  */
 
-struct timeval
+struct bpf_timeval
 first_packet_time(char filename[], pcap_t **p_addr)
 {
 	struct pcap_pkthdr hdr;
@@ -457,10 +461,10 @@ first_packet_time(char filename[], pcap_
 
 void
 extract_slice(char filename[], char write_file_name[],
-		struct timeval *start_time, struct timeval *stop_time)
+		struct bpf_timeval *start_time, struct bpf_timeval *stop_time)
 {
 	off_t start_pos, stop_pos;
-	struct timeval file_start_time, file_stop_time;
+	struct bpf_timeval file_start_time, file_stop_time;
 	struct pcap_pkthdr hdr;
 	pcap_t *p;
 	char errbuf[PCAP_ERRBUF_SIZE];
@@ -511,7 +515,7 @@ extract_slice(char filename[], char writ
 
 	for ( ; ; )
 		{
-		struct timeval *timestamp;
+		struct bpf_timeval *timestamp;
 		const u_char *pkt = pcap_next( p, &hdr );
 
 		if ( pkt == 0 )
@@ -554,7 +558,7 @@ extract_slice(char filename[], char writ
  */
 
 char *
-timestamp_to_string(struct timeval *timestamp)
+timestamp_to_string(struct bpf_timeval *timestamp)
 {
 	struct tm *t;
 #define NUM_BUFFERS 2
@@ -599,7 +603,7 @@ timestamp_to_string(struct timeval *time
 void
 dump_times(pcap_t **p, char filename[])
 {
-	struct timeval first_time, last_time;
+	struct bpf_timeval first_time, last_time;
 
 	get_file_range( filename, p, &first_time, &last_time );
 
