From: Frédéric Marchal Date: Wed, 8 Jul 2009 11:02:16 +0000 (+0000) Subject: Fixed Debian bug #444845. X-Git-Tag: v2_2_6~67 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d6dfc139bd38beaa68d35ba12e7cf11cb1aa682a;p=thirdparty%2Fsarg.git Fixed Debian bug #444845. --- diff --git a/log.c b/log.c index cea7892..94aa823 100644 --- a/log.c +++ b/log.c @@ -694,8 +694,9 @@ int main(argc,argv) fprintf(stderr, "%s: (log) %s: %s - %s\n",argv[0],text[45],UserTabFile,strerror(errno)); exit(1); } - nreg = lseek(fileno(fp_usr), 0, SEEK_END); - lseek(fileno(fp_usr), 0, 0); + fseek(fp_usr, 0, SEEK_END); + nreg = ftell(fp_usr); + fseek(fp_usr, 0, SEEK_SET); if((userfile=(char *) malloc(nreg+100))==NULL){ fprintf(stderr, "%s ERROR: %s",argv[0],text[87]); exit(1); @@ -758,7 +759,7 @@ int main(argc,argv) } sprintf(period,"%s-%s",val2,val3); sarglog=1; - } else lseek(fileno(fp_in), 0, 0); + } else fseek(fp_in, 0, SEEK_SET); if(strcmp(ParsedOutputLog, "no") != 0 && !sarglog) { if(access(ParsedOutputLog,R_OK) != 0) { @@ -1659,9 +1660,10 @@ void getusers(char *pwdfile, int debug) exit(1); } - nreg = lseek(fileno(fp_usr), (off_t)0, SEEK_END); + fseek(fp_usr, (off_t)0, SEEK_END); + nreg = ftell(fp_usr); nreg = nreg+5000; - lseek(fileno(fp_usr), (off_t)0, 0); + fseek(fp_usr, (off_t)0, SEEK_SET); if((userfile=(char *) malloc(nreg))==NULL){ fprintf(stderr, "SARG: %s (%ld):\n",text[59],nreg); @@ -1704,8 +1706,9 @@ void gethexclude(char *hexfile, int debug) exit(1); } - nreg = lseek(fileno(fp_ex), (off_t)0, SEEK_END); - lseek(fileno(fp_ex), (off_t)0, 0); + fseek(fp_ex, (off_t)0, SEEK_END); + nreg = ftell(fp_ex); + fseek(fp_ex, (off_t)0, SEEK_SET); if((excludefile=(char *) malloc(nreg+11))==NULL){ fprintf(stderr, "SARG: %s (%ld):\n",text[59],nreg); @@ -1748,8 +1751,9 @@ void getuexclude(char *uexfile, int debug) exit(1); } - nreg = lseek(fileno(fp_ex), (off_t)0, SEEK_END); - lseek(fileno(fp_ex), (off_t)0, 0); + fseek(fp_ex, (off_t)0, SEEK_END); + nreg = ftell(fp_ex); + fseek(fp_ex, (off_t)0, SEEK_SET); if((excludeuser=(char *) malloc(nreg+11))==NULL){ fprintf(stderr, "SARG: %s (%ld):\n",text[59],nreg); diff --git a/realtime.c b/realtime.c index ba72653..6f729ec 100755 --- a/realtime.c +++ b/realtime.c @@ -63,8 +63,9 @@ static void getlog(void) fprintf(stderr, "SARG: (realtime) %s: %s - %s\n",text[45],UserTabFile,strerror(errno)); exit(1); } - nreg = lseek(fileno(fp_usr), 0, SEEK_END); - lseek(fileno(fp_usr), 0, 0); + fseek(fp_usr, 0, SEEK_END); + nreg = ftell(fp_usr); + fseek(fp_usr, 0, SEEK_SET); if((userfile=(char *) malloc(nreg+100))==NULL){ fprintf(stderr, "SARG ERROR: %s",text[87]); exit(1);