Clean up indentation.

"time_t" is not guaranteed to be an "unsigned long"; when printing it
with %lu, cast it to "unsigned long".

The "secs" field of a wtap_nstime, however, *is* defined to be a time_t;
there's no need to cast it to time_t.

svn path=/trunk/; revision=23036
This commit is contained in:
Guy Harris 2007-09-30 22:13:38 +00:00
parent 4245058b58
commit 58585ac5c5
1 changed files with 52 additions and 46 deletions

View File

@ -185,11 +185,18 @@ selected(int recno)
} }
/* is the packet in the selected timeframe */ /* is the packet in the selected timeframe */
static gboolean check_timestamp(wtap *wth) { static gboolean
static int i = 0; check_timestamp(wtap *wth)
struct wtap_pkthdr* pkthdr = wtap_phdr(wth); {
if (!((i++)%250)) printf("== %d starttime=%lu stoptime=%lu ts=%lu",i,starttime,stoptime,pkthdr->ts.secs); static int i = 0;
return ( (time_t) pkthdr->ts.secs >= starttime ) && ( (time_t) pkthdr->ts.secs <= stoptime ); struct wtap_pkthdr* pkthdr = wtap_phdr(wth);
if (!((i++)%250))
printf("== %d starttime=%lu stoptime=%lu ts=%lu",i,
(unsigned long)starttime,
(unsigned long)stoptime,
(unsigned long)pkthdr->ts.secs);
return ( pkthdr->ts.secs >= starttime ) && ( pkthdr->ts.secs <= stoptime );
} }
static void static void
@ -505,42 +512,41 @@ int main(int argc, char *argv[])
verbose = !verbose; /* Just invert */ verbose = !verbose; /* Just invert */
break; break;
case 'A': case 'A':
{ {
struct tm starttm; struct tm starttm;
memset(&starttm,0,sizeof(struct tm)); memset(&starttm,0,sizeof(struct tm));
if(!strptime(optarg,"%F %T",&starttm)) { if(!strptime(optarg,"%F %T",&starttm)) {
fprintf(stderr, "editcap: \"%s\" isn't a valid time format\n\n", fprintf(stderr, "editcap: \"%s\" isn't a valid time format\n\n", optarg);
optarg); exit(1);
exit(1); }
}
check_startstop = TRUE; check_startstop = TRUE;
starttm.tm_isdst = -1; starttm.tm_isdst = -1;
starttime = mktime(&starttm); starttime = mktime(&starttm);
printf("=START=> given='%s' stoptime=%lu\n",optarg,starttime); printf("=START=> given='%s' stoptime=%lu\n",optarg,(unsigned long)starttime);
break; break;
} }
case 'B':
{
struct tm stoptm;
memset(&stoptm,0,sizeof(struct tm)); case 'B':
{
struct tm stoptm;
if(!strptime(optarg,"%F %T",&stoptm)) { memset(&stoptm,0,sizeof(struct tm));
fprintf(stderr, "editcap: \"%s\" isn't a valid time format\n\n",
optarg); if(!strptime(optarg,"%F %T",&stoptm)) {
exit(1); fprintf(stderr, "editcap: \"%s\" isn't a valid time format\n\n", optarg);
} exit(1);
check_startstop = TRUE; }
stoptm.tm_isdst = -1; check_startstop = TRUE;
stoptime = mktime(&stoptm); stoptm.tm_isdst = -1;
printf("=STOP=> given='%s' stoptime=%lu\n",optarg,stoptime); stoptime = mktime(&stoptm);
break; printf("=STOP=> given='%s' stoptime=%lu\n",optarg,(unsigned long)stoptime);
} break;
}
} }
} }
@ -557,22 +563,22 @@ int main(int argc, char *argv[])
} }
if (check_startstop && !stoptime) { if (check_startstop && !stoptime) {
struct tm stoptm; struct tm stoptm;
/* XXX: will work until 2035 */ /* XXX: will work until 2035 */
memset(&stoptm,0,sizeof(struct tm)); memset(&stoptm,0,sizeof(struct tm));
stoptm.tm_year = 135; stoptm.tm_year = 135;
stoptm.tm_mday = 31; stoptm.tm_mday = 31;
stoptm.tm_mon = 11; stoptm.tm_mon = 11;
stoptime = mktime(&stoptm); stoptime = mktime(&stoptm);
printf("=STOP=NEVER=> stoptime=%lu\n",stoptime); printf("=STOP=NEVER=> stoptime=%lu\n",(unsigned long)stoptime);
} }
if (starttime > stoptime) { if (starttime > stoptime) {
fprintf(stderr, "editcap: start time is after the stop time\n"); fprintf(stderr, "editcap: start time is after the stop time\n");
exit(1); exit(1);
} }
printf("==> stoptime=%lu stoptime=%lu\n",starttime,stoptime); printf("==> stoptime=%lu stoptime=%lu\n",(unsigned long)starttime,(unsigned long)stoptime);
wth = wtap_open_offline(argv[optind], &err, &err_info, FALSE); wth = wtap_open_offline(argv[optind], &err, &err_info, FALSE);