]> git.ipfire.org Git - thirdparty/sarg.git/blobdiff - splitlog.c
Use a library to read gzip access.log files
[thirdparty/sarg.git] / splitlog.c
index c8c9fa2924225091090d52bf569d5c3017116e57..0816e03fdf381ebf13eca0842b9ee6241c115f53 100644 (file)
@@ -46,7 +46,7 @@ the files are named after the day they contain prefixed with the string containe
 */
 void splitlog(const char *arq, char df, int dfrom, int duntil, int convert, const char *splitprefix)
 {
-       FILE *fp_in;
+       FileObject *fp_in;
        FILE *fp_ou=NULL;
        char *buf;
        char data[30];
@@ -79,8 +79,8 @@ void splitlog(const char *arq, char df, int dfrom, int duntil, int convert, cons
        if(arq[0] == '\0')
                arq="/var/log/squid/access.log";
 
-       if((fp_in=MY_FOPEN(arq,"r"))==NULL) {
-               debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),arq,strerror(errno));
+       if((fp_in=FileObject_Open(arq))==NULL) {
+               debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),arq,FileObject_GetLastOpenError());
                exit(EXIT_FAILURE);
        }
 
@@ -140,8 +140,8 @@ void splitlog(const char *arq, char df, int dfrom, int duntil, int convert, cons
        }
 
        longline_destroy(&line);
-       if (fclose(fp_in)==EOF) {
-               debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),arq,strerror(errno));
+       if (FileObject_Close(fp_in)) {
+               debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),arq,FileObject_GetLastCloseError());
                exit(EXIT_FAILURE);
        }
        if (autosplit && fp_ou) {