]> git.ipfire.org Git - thirdparty/sarg.git/blobdiff - alias.c
Generate redirector log even if -d is not given
[thirdparty/sarg.git] / alias.c
diff --git a/alias.c b/alias.c
index c4b94f967db6b8c98f69c39413adb6c2251844d4..a7293b242fbef12b665de8fdde7221a89ae0c6ac 100644 (file)
--- a/alias.c
+++ b/alias.c
@@ -247,7 +247,7 @@ static int Alias_StoreName(struct AliasStruct *AliasData,const char *name,const
        prev_alias=NULL;
        for (alias=AliasData->First ; alias ; alias=alias->Next) {
                if (alias->Type==ALIASTYPE_Name && !strcmp(Name,alias->Name.Mask)) {
-                       debuga(_("Duplicate aliasing directive for name %s\n"),Name);
+                       debuga(__FILE__,__LINE__,_("Duplicate aliasing directive for name %s\n"),Name);
                        return(0);
                }
                prev_alias=alias;
@@ -256,7 +256,7 @@ static int Alias_StoreName(struct AliasStruct *AliasData,const char *name,const
        // insert into the list
        new_alias=malloc(sizeof(*new_alias));
        if (!new_alias) {
-               debuga(_("Not enough memory to store the user name aliasing directives\n"));
+               debuga(__FILE__,__LINE__,_("Not enough memory to store the user name aliasing directives\n"));
                return(-1);
        }
        new_alias->Type=ALIASTYPE_Name;
@@ -264,7 +264,7 @@ static int Alias_StoreName(struct AliasStruct *AliasData,const char *name,const
        new_alias->Name.Wildcards=wildcards;
        new_alias->Name.Mask=StringBuffer_Store(AliasData->StringBuffer,Name);
        if (!new_alias->Name.Mask) {
-               debuga(_("Not enough memory to store the user name aliasing directives\n"));
+               debuga(__FILE__,__LINE__,_("Not enough memory to store the user name aliasing directives\n"));
                free(new_alias);
                return(-1);
        }
@@ -272,7 +272,7 @@ static int Alias_StoreName(struct AliasStruct *AliasData,const char *name,const
        len=(int)(ReplaceE-Replace);
        new_alias->Alias=StringBuffer_StoreLength(AliasData->StringBuffer,Replace,len);
        if (!new_alias->Alias) {
-               debuga(_("Not enough memory to store the user name aliasing directives\n"));
+               debuga(__FILE__,__LINE__,_("Not enough memory to store the user name aliasing directives\n"));
                free(new_alias);
                return(-1);
        }
@@ -324,10 +324,10 @@ static int Alias_StoreIpv4(struct AliasStruct *AliasData,unsigned char *ipv4,int
                        int bit=alias->Ipv4.NBits%8;
                        if ((byte<1 || memcmp(ipv4,alias->Ipv4.Ip,byte)==0) && (bit==0 || (ipv4[byte] ^ alias->Ipv4.Ip[byte]) & (0xFFU<<(8-bit)))==0) {
                                if (nbits==alias->Ipv4.NBits)
-                                       debuga(_("Duplicate aliasing directive for IPv4 address %d.%d.%d.%d/%d\n"),
+                                       debuga(__FILE__,__LINE__,_("Duplicate aliasing directive for IPv4 address %d.%d.%d.%d/%d\n"),
                                                   ipv4[0],ipv4[1],ipv4[2],ipv4[3],nbits);
                                else
-                                       debuga(_("IPv4 aliasing directive ignored for IPv4 address %d.%d.%d.%d/%d as it is"
+                                       debuga(__FILE__,__LINE__,_("IPv4 aliasing directive ignored for IPv4 address %d.%d.%d.%d/%d as it is"
                                                         " narrower than a previous one (%d.%d.%d.%d/%d\n"),
                                                   ipv4[0],ipv4[1],ipv4[2],ipv4[3],nbits,
                                                        alias->Ipv4.Ip[0],alias->Ipv4.Ip[1],alias->Ipv4.Ip[2],alias->Ipv4.Ip[3],
@@ -341,7 +341,7 @@ static int Alias_StoreIpv4(struct AliasStruct *AliasData,unsigned char *ipv4,int
        // insert into the list
        new_alias=malloc(sizeof(*new_alias));
        if (!new_alias) {
-               debuga(_("Not enough memory to store the host name aliasing directives\n"));
+               debuga(__FILE__,__LINE__,_("Not enough memory to store the host name aliasing directives\n"));
                return(-1);
        }
        new_alias->Type=ALIASTYPE_Ipv4;
@@ -353,7 +353,7 @@ static int Alias_StoreIpv4(struct AliasStruct *AliasData,unsigned char *ipv4,int
                len=(int)(ReplaceE-Replace);
                tmp=malloc(len+2);
                if (!tmp) {
-                       debuga(_("Not enough memory to store the host name aliasing directives\n"));
+                       debuga(__FILE__,__LINE__,_("Not enough memory to store the host name aliasing directives\n"));
                        free(new_alias);
                        return(-1);
                }
@@ -368,7 +368,7 @@ static int Alias_StoreIpv4(struct AliasStruct *AliasData,unsigned char *ipv4,int
                new_alias->Alias=StringBuffer_Store(AliasData->StringBuffer,tmp);
        }
        if (!new_alias->Alias) {
-               debuga(_("Not enough memory to store the IPv4 aliasing directives\n"));
+               debuga(__FILE__,__LINE__,_("Not enough memory to store the IPv4 aliasing directives\n"));
                free(new_alias);
                return(-1);
        }
@@ -420,10 +420,10 @@ static int Alias_StoreIpv6(struct AliasStruct *AliasData,unsigned short *ipv6,in
                        int bit=alias->Ipv6.NBits%16;
                        if ((word<1 || memcmp(ipv6,alias->Ipv6.Ip,word*2)==0) && (bit==0 || (ipv6[word] ^ alias->Ipv6.Ip[word]) & (0xFFFFU<<(16-bit)))==0) {
                                if (nbits==alias->Ipv6.NBits)
-                                       debuga(_("Duplicate aliasing directive for IPv6 address %x:%x:%x:%x:%x:%x:%x:%x/%d\n"),
+                                       debuga(__FILE__,__LINE__,_("Duplicate aliasing directive for IPv6 address %x:%x:%x:%x:%x:%x:%x:%x/%d\n"),
                                                   ipv6[0],ipv6[1],ipv6[2],ipv6[3],ipv6[4],ipv6[5],ipv6[6],ipv6[7],nbits);
                                else
-                                       debuga(_("IPv6 aliasing directive ignored for IPv6 address %x:%x:%x:%x:%x:%x:%x:%x/%d as it is"
+                                       debuga(__FILE__,__LINE__,_("IPv6 aliasing directive ignored for IPv6 address %x:%x:%x:%x:%x:%x:%x:%x/%d as it is"
                                                         " narrower than a previous one (%x:%x:%x:%x:%x:%x:%x:%x/%d\n"),
                                                   ipv6[0],ipv6[1],ipv6[2],ipv6[3],ipv6[4],ipv6[5],ipv6[6],ipv6[7],nbits,
                                                        alias->Ipv6.Ip[0],alias->Ipv6.Ip[1],alias->Ipv6.Ip[2],alias->Ipv6.Ip[3],alias->Ipv6.Ip[4],
@@ -437,7 +437,7 @@ static int Alias_StoreIpv6(struct AliasStruct *AliasData,unsigned short *ipv6,in
        // insert into the list
        new_alias=malloc(sizeof(*new_alias));
        if (!new_alias) {
-               debuga(_("Not enough memory to store the host name aliasing directives\n"));
+               debuga(__FILE__,__LINE__,_("Not enough memory to store the host name aliasing directives\n"));
                return(-1);
        }
        new_alias->Type=ALIASTYPE_Ipv6;
@@ -448,7 +448,7 @@ static int Alias_StoreIpv6(struct AliasStruct *AliasData,unsigned short *ipv6,in
                len=ReplaceE-Replace;
                tmp=malloc(len+2);
                if (!tmp) {
-                       debuga(_("Not enough memory to store the host name aliasing directives\n"));
+                       debuga(__FILE__,__LINE__,_("Not enough memory to store the host name aliasing directives\n"));
                        free(new_alias);
                        return(-1);
                }
@@ -463,7 +463,7 @@ static int Alias_StoreIpv6(struct AliasStruct *AliasData,unsigned short *ipv6,in
                new_alias->Alias=StringBuffer_Store(AliasData->StringBuffer,tmp);
        }
        if (!new_alias->Alias) {
-               debuga(_("Not enough memory to store the IPv6 aliasing directives\n"));
+               debuga(__FILE__,__LINE__,_("Not enough memory to store the IPv6 aliasing directives\n"));
                free(new_alias);
                return(-1);
        }
@@ -503,14 +503,14 @@ static int Alias_StoreRegexp(struct AliasStruct *AliasData,char *buf)
        for (End=buf ; *End && *End!=Delimiter ; End++) {
                if (*End=='\\') {
                        if (End[1]=='\0') {
-                               debuga(_("Invalid NUL character found in regular expression\n"));
+                               debuga(__FILE__,__LINE__,_("Invalid NUL character found in regular expression\n"));
                                return(-1);
                        }
                        End++; //ignore the escaped character
                }
        }
        if (*End!=Delimiter) {
-               debuga(_("Unterminated regular expression\n"));
+               debuga(__FILE__,__LINE__,_("Unterminated regular expression\n"));
                return(-1);
        }
        *End++='\0';
@@ -523,21 +523,21 @@ static int Alias_StoreRegexp(struct AliasStruct *AliasData,char *buf)
        // store it
        new_alias=malloc(sizeof(*new_alias));
        if (!new_alias) {
-               debuga(_("Not enough memory to store the host name aliasing directives\n"));
+               debuga(__FILE__,__LINE__,_("Not enough memory to store the host name aliasing directives\n"));
                return(-1);
        }
        new_alias->Type=ALIASTYPE_Pcre;
        new_alias->Next=NULL;
        new_alias->Regex.Re=pcre_compile(buf,0,&PcreError,&ErrorOffset,NULL);
        if (new_alias->Regex.Re==NULL) {
-               debuga(_("Failed to compile the regular expression \"%s\": %s\n"),buf,PcreError);
+               debuga(__FILE__,__LINE__,_("Failed to compile the regular expression \"%s\": %s\n"),buf,PcreError);
                free(new_alias);
                return(-1);
        }
        len=strlen(Replace);
        tmp=malloc(len+2);
        if (!tmp) {
-               debuga(_("Not enough memory to store the host name aliasing directives\n"));
+               debuga(__FILE__,__LINE__,_("Not enough memory to store the host name aliasing directives\n"));
                pcre_free(new_alias->Regex.Re);
                return(-1);
        }
@@ -547,7 +547,7 @@ static int Alias_StoreRegexp(struct AliasStruct *AliasData,char *buf)
        new_alias->Alias=StringBuffer_Store(AliasData->StringBuffer,tmp);
        free(tmp);
        if (!new_alias->Alias) {
-               debuga(_("Not enough memory to store the regex aliasing directives\n"));
+               debuga(__FILE__,__LINE__,_("Not enough memory to store the regex aliasing directives\n"));
                free(new_alias);
                return(-1);
        }
@@ -596,7 +596,7 @@ int Alias_Store(struct AliasStruct *AliasData,char *String)
                if (Alias_StoreRegexp(AliasData,String+3)<0)
                        return(-1);
 #else
-               debuga(_("PCRE not compiled in therefore the regular expressions are not available to alias items\n"));
+               debuga(__FILE__,__LINE__,_("PCRE not compiled in therefore the regular expressions are not available to alias items\n"));
                return(-1);
 #endif
        }
@@ -631,19 +631,19 @@ void Alias_PrintList(struct AliasStruct *AliasData)
                switch (alias->Type)
                {
                        case ALIASTYPE_Name:
-                               debuga(_("  %s => %s\n"),alias->Name.Mask,alias->Alias);
+                               debuga(__FILE__,__LINE__,_("  %s => %s\n"),alias->Name.Mask,alias->Alias);
                                break;
                        case ALIASTYPE_Ipv4:
-                               debuga(_("  %d.%d.%d.%d/%d => %s\n"),alias->Ipv4.Ip[0],alias->Ipv4.Ip[1],alias->Ipv4.Ip[2],
+                               debuga(__FILE__,__LINE__,_("  %d.%d.%d.%d/%d => %s\n"),alias->Ipv4.Ip[0],alias->Ipv4.Ip[1],alias->Ipv4.Ip[2],
                                                alias->Ipv4.Ip[3],alias->Ipv4.NBits,alias->Alias);
                                break;
                        case ALIASTYPE_Ipv6:
-                               debuga(_("  %x:%x:%x:%x:%x:%x:%x:%x/%d => %s\n"),alias->Ipv6.Ip[0],alias->Ipv6.Ip[1],alias->Ipv6.Ip[2],
+                               debuga(__FILE__,__LINE__,_("  %x:%x:%x:%x:%x:%x:%x:%x/%d => %s\n"),alias->Ipv6.Ip[0],alias->Ipv6.Ip[1],alias->Ipv6.Ip[2],
                                                alias->Ipv6.Ip[3],alias->Ipv6.Ip[4],alias->Ipv6.Ip[5],alias->Ipv6.Ip[6],alias->Ipv6.Ip[7],
                                                alias->Ipv6.NBits,alias->Alias);
                                break;
                        case ALIASTYPE_Pcre:
-                               debuga(_("  Re => %s\n"),alias->Alias);
+                               debuga(__FILE__,__LINE__,_("  Re => %s\n"),alias->Alias);
                                break;
                }
        }