]> git.ipfire.org Git - thirdparty/sarg.git/blobdiff - exclude.c
Indent the configure script for more readability.
[thirdparty/sarg.git] / exclude.c
index cebe1911499dce5b2fb31ff0f2c1e51a1ab06b9c..29c1e296859e2c8642efbae44d07c811a43e2f65 100644 (file)
--- a/exclude.c
+++ b/exclude.c
@@ -1,6 +1,6 @@
 /*
  * SARG Squid Analysis Report Generator      http://sarg.sourceforge.net
- *                                                            1998, 2013
+ *                                                            1998, 2015
  *
  * SARG donations:
  *      please look at http://sarg.sourceforge.net/donations.php
@@ -79,7 +79,7 @@ static void store_exclude_ip4(unsigned char *addr,int nbits)
                ip4allocated+=5;
                temp=realloc(exclude_ip4,ip4allocated*sizeof(*temp));
                if (temp==NULL) {
-                       debuga(_("Not enough memory to store the exlcluded IP addresses\n"));
+                       debuga(__FILE__,__LINE__,_("Not enough memory to store the exlcluded IP addresses\n"));
                        exit(EXIT_FAILURE);
                }
                exclude_ip4=temp;
@@ -107,7 +107,7 @@ static void store_exclude_ip6(unsigned short *addr,int nbits)
                ip6allocated+=5;
                temp=realloc(exclude_ip6,ip6allocated*sizeof(*temp));
                if (temp==NULL) {
-                       debuga(_("Not enough memory to store the exlcluded IP addresses\n"));
+                       debuga(__FILE__,__LINE__,_("Not enough memory to store the exlcluded IP addresses\n"));
                        exit(EXIT_FAILURE);
                }
                exclude_ip6=temp;
@@ -158,7 +158,7 @@ static void store_exclude_url(const char *url,const char *next)
                nameallocated+=5;
                temp=realloc(exclude_name,nameallocated*sizeof(*temp));
                if (temp==NULL) {
-                       debuga(_("Not enough memory to store the excluded URLs\n"));
+                       debuga(__FILE__,__LINE__,_("Not enough memory to store the excluded URLs\n"));
                        exit(EXIT_FAILURE);
                }
                exclude_name=temp;
@@ -168,7 +168,7 @@ static void store_exclude_url(const char *url,const char *next)
        num_exclude_name++;
        item->url=malloc(length+1);
        if (!item->url) {
-               debuga(_("Not enough memory to store the excluded URLs\n"));
+               debuga(__FILE__,__LINE__,_("Not enough memory to store the excluded URLs\n"));
                exit(EXIT_FAILURE);
        }
        safe_strcpy(item->url,url,length+1);
@@ -193,14 +193,14 @@ void gethexclude(const char *hexfile, int debug)
        const char *next;
 
        if(access(hexfile, R_OK) != 0) {
-               debuga(_("Cannot open file \"%s\": %s\n"),hexfile,strerror(errno));
+               debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),hexfile,strerror(errno));
                exit(EXIT_FAILURE);
        }
        if(debug)
-               debuga(_("Loading exclude host file from: %s\n"),hexfile);
+               debuga(__FILE__,__LINE__,_("Loading exclude host file from \"%s\"\n"),hexfile);
 
        if ((fp_ex = fopen(hexfile, "r")) == NULL) {
-               debuga(_("Cannot open file \"%s\": %s\n"),hexfile,strerror(errno));
+               debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),hexfile,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -211,7 +211,7 @@ void gethexclude(const char *hexfile, int debug)
 
                type=extract_address_mask(buf,&name,ipv4,ipv6,&nbits,&next);
                if (type<0) {
-                       debuga(_("While reading \"%s\"\n"),hexfile);
+                       debuga(__FILE__,__LINE__,_("While reading \"%s\"\n"),hexfile);
                        exit(EXIT_FAILURE);
                }
 
@@ -224,7 +224,10 @@ void gethexclude(const char *hexfile, int debug)
                }
        }
 
-       fclose(fp_ex);
+       if (fclose(fp_ex)==EOF) {
+               debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),hexfile,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
        return;
 }
 
@@ -311,30 +314,30 @@ void getuexclude(const char *uexfile, int debug)
        long int nreg=0;
 
        if(debug)
-               debuga(_("Loading exclude file from: %s\n"),uexfile);
+               debuga(__FILE__,__LINE__,_("Loading exclude file from \"%s\"\n"),uexfile);
 
        if ((fp_ex = fopen(uexfile, "r")) == NULL) {
-               debuga(_("Cannot open file \"%s\": %s\n"),uexfile,strerror(errno));
+               debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),uexfile,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
        if (fseek(fp_ex, 0, SEEK_END)==-1) {
-               debuga(_("Failed to move till the end of the excluded users file %s: %s\n"),uexfile,strerror(errno));
+               debuga(__FILE__,__LINE__,_("Failed to move till the end of file \"%s\": %s\n"),uexfile,strerror(errno));
                exit(EXIT_FAILURE);
        }
        nreg = ftell(fp_ex);
        if (nreg<0) {
-               debuga(_("Cannot get the size of file %s\n"),uexfile);
+               debuga(__FILE__,__LINE__,_("Cannot get the size of file \"%s\"\n"),uexfile);
                exit(EXIT_FAILURE);
        }
        nreg += 11;
        if (fseek(fp_ex, 0, SEEK_SET)==-1) {
-               debuga(_("Failed to rewind the excluded users file %s: %s\n"),uexfile,strerror(errno));
+               debuga(__FILE__,__LINE__,_("Failed to rewind file \"%s\": %s\n"),uexfile,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
        if((excludeuser=(char *) malloc(nreg))==NULL){
-               debuga(_("malloc error (%ld bytes required)\n"),nreg);
+               debuga(__FILE__,__LINE__,_("malloc error (%ld bytes required)\n"),nreg);
                exit(EXIT_FAILURE);
        }
 
@@ -350,7 +353,10 @@ void getuexclude(const char *uexfile, int debug)
 
        strcat(excludeuser,"*END* ");
 
-       fclose(fp_ex);
+       if (fclose(fp_ex)==EOF) {
+               debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),uexfile,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
 
        return;
 }