]> git.ipfire.org Git - thirdparty/sarg.git/blobdiff - ip2name_exec.c
Add support to decompress xz files
[thirdparty/sarg.git] / ip2name_exec.c
index 30b237a6f497fb3d8778549272c8981a260ab771..11962d4936ffa55bfd63ae4318a7b328cb424195 100644 (file)
@@ -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
@@ -55,10 +55,10 @@ file.
 static void ip2name_execconfig(const char *name,const char *param)
 {
        int len;
-       
+
        len=strlen(param);
        if (len>=sizeof(ExecCmd)) {
-               debuga(_("Command to execute to resolve the IP addresses is too long (maximum is %d bytes)\n"),(int)sizeof(ExecCmd));
+               debuga(__FILE__,__LINE__,_("Command to execute to resolve the IP addresses is too long (maximum is %d bytes)\n"),(int)sizeof(ExecCmd));
                exit(EXIT_FAILURE);
        }
        strcpy(ExecCmd,param);
@@ -81,18 +81,18 @@ static enum ip2name_retcode ip2name_exec(char *ip,int ip_len)
        FILE *cmd_in;
        char buffer[512];
        size_t nread;
-       
+
        if (ExecCmd[0]=='\0') {
-               debuga(_("No command to run to resolve an IP address. Please configure it in sarg.conf\n"));
+               debuga(__FILE__,__LINE__,_("No command to run to resolve an IP address. Please configure it in sarg.conf\n"));
                exit(EXIT_FAILURE);
        }
-       
+
        j=0;
        len=strlen(ip);
        for (i=0 ; i<sizeof(ExecCmd) && ExecCmd[i] ; i++) {
                if (ExecCmd[i]=='%' && strncmp(ExecCmd+i+1,"IP",2)==0) {
                        if (j+len>=sizeof(cmd)) {
-                               debuga(_("IP address \"%s\" too long for the command to run\n"),ip);
+                               debuga(__FILE__,__LINE__,_("IP address \"%s\" too long for the command to run\n"),ip);
                                return(INRC_Error);
                        }
                        strcpy(cmd+j,ip);
@@ -100,29 +100,29 @@ static enum ip2name_retcode ip2name_exec(char *ip,int ip_len)
                        i+=2;
                } else {
                        if (j>=sizeof(cmd)) {
-                               debuga(_("IP address \"%.*s\" too long for the command to run\n"),ip_len,ip);
+                               debuga(__FILE__,__LINE__,_("IP address \"%s\" too long for the command to run\n"),ip);
                                return(INRC_Error);
                        }
                        cmd[j++]=ExecCmd[i];
                }
        }
        cmd[j]='\0';
-       
+
        cmd_in=popen(cmd,"r");
        if (!cmd_in) {
-               debuga(_("Cannot run command %s\n"),cmd);
+               debuga(__FILE__,__LINE__,_("Cannot run command %s\n"),cmd);
                exit(EXIT_FAILURE);
        }
-       
+
        nread=fread(buffer,1,sizeof(buffer),cmd_in);
-       
+
        if (pclose(cmd_in)==-1) {
-               debuga(_("Command failed: %s\n"),cmd);
+               debuga(__FILE__,__LINE__,_("Command failed: %s\n"),cmd);
                exit(EXIT_FAILURE);
        }
 
        if (nread==0) return(INRC_NotFound);
-       
+
        safe_strcpy(ip,buffer,ip_len);
        return(INRC_Found);
 }