]> git.ipfire.org Git - thirdparty/sarg.git/blobdiff - convlog.c
Indent the configure script for more readability.
[thirdparty/sarg.git] / convlog.c
index 4b5600f4436bafde7fa0d2d190b326f6b655f72c..d87efee88fc95d3189c001b7a4c7c0cd573477c8 100644 (file)
--- a/convlog.c
+++ b/convlog.c
@@ -1,6 +1,6 @@
 /*
  * SARG Squid Analysis Report Generator      http://sarg.sourceforge.net
- *                                                            1998, 2012
+ *                                                            1998, 2015
  *
  * SARG donations:
  *      please look at http://sarg.sourceforge.net/donations.php
@@ -29,7 +29,7 @@
 
 void convlog(const char *arq, char df, int dfrom, int duntil)
 {
-       FILE *fp_in;
+       FileObject *fp_in;
        char *buf;
        char data[30];
        char dia[11];
@@ -42,20 +42,20 @@ void convlog(const char *arq, char df, int dfrom, int duntil)
        if(arq[0] == '\0')
                arq="/var/log/squid/access.log";
 
-       if((fp_in=MY_FOPEN(arq,"r"))==NULL) {
-               debuga(_("(convlog) Cannot open log 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);
        }
 
        if ((line=longline_create())==NULL) {
-               debuga(_("Not enough memory to read the log file %s\n"),arq);
+               debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),arq);
                exit(EXIT_FAILURE);
        }
 
        while((buf=longline_read(fp_in,line))!=NULL) {
                getword_start(&gwarea,buf);
                if (getword(data,sizeof(data),&gwarea,' ')<0) {
-                       debuga(_("Maybe you have a broken record or garbage in file %s\n"),arq);
+                       debuga(__FILE__,__LINE__,_("Invalid record in file \"%s\"\n"),arq);
                        exit(EXIT_FAILURE);
                }
                tt=atoi(data);
@@ -78,8 +78,8 @@ void convlog(const char *arq, char df, int dfrom, int duntil)
        }
 
        longline_destroy(&line);
-       if (fclose(fp_in)==EOF) {
-               debuga(_("Failed to close file %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);
        }
 }