"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "url.c" between
sarg-2.3.11.tar.gz and sarg-2.4.0.tar.gz

About: SARG ia a Squid Analysis Report Generator.

url.c  (sarg-2.3.11):url.c  (sarg-2.4.0)
/* /*
* SARG Squid Analysis Report Generator http://sarg.sourceforge.net * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
* 1998, 2013 * 1998, 2015
* *
* SARG donations: * SARG donations:
* please look at http://sarg.sourceforge.net/donations.php * please look at http://sarg.sourceforge.net/donations.php
* Support: * Support:
* http://sourceforge.net/projects/sarg/forums/forum/363374 * http://sourceforge.net/projects/sarg/forums/forum/363374
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
skipping to change at line 150 skipping to change at line 150
// get host name and split at the wildcard // get host name and split at the wildcard
NameBegin=name; NameBegin=name;
for (str=NameBegin ; str<next && (unsigned char)*str>' ' && *str!='*' ; s tr++); for (str=NameBegin ; str<next && (unsigned char)*str>' ' && *str!='*' ; s tr++);
NameBeginE=str; NameBeginE=str;
if (NameBegin==NameBeginE) NameBegin=NULL; if (NameBegin==NameBeginE) NameBegin=NULL;
if (str<next && *str=='*') { if (str<next && *str=='*') {
NameEnd=++str; NameEnd=++str;
while (str<next && (unsigned char)*str>' ') { while (str<next && (unsigned char)*str>' ') {
if (*str=='*') { if (*str=='*') {
debuga(_("Host name alias \"%s*%s\" contains too many wildcards (*)\n"),NameBegin,NameEnd); debuga(__FILE__,__LINE__,_("Host name alias \"%s* %s\" contains too many wildcards (*)\n"),NameBegin,NameEnd);
return(-1); return(-1);
} }
str++; str++;
} }
NameEndE=str; NameEndE=str;
if (NameEnd==NameEndE) { if (NameEnd==NameEndE) {
debuga(_("Host name alias \"%*s\" must not end with a wil dcard\n"),(int)(next-name),name); debuga(__FILE__,__LINE__,_("Host name alias \"%*s\" must not end with a wildcard\n"),(int)(next-name),name);
return(-1); return(-1);
} }
} else { } else {
NameEnd=NULL; NameEnd=NULL;
} }
while (str<next && (unsigned char)*str<=' ') str++; while (str<next && (unsigned char)*str<=' ') str++;
if (!NameBegin && !NameEnd) return(0); if (!NameBegin && !NameEnd) return(0);
// get the alias // get the alias
sep=*next; sep=*next;
skipping to change at line 184 skipping to change at line 184
for (str=Replace ; *str && (unsigned char)*str>=' ' ; str ++); for (str=Replace ; *str && (unsigned char)*str>=' ' ; str ++);
ReplaceE=str; ReplaceE=str;
} }
} else } else
Replace=NULL; Replace=NULL;
if (NameBegin) { if (NameBegin) {
len=(int)(NameBeginE-NameBegin); len=(int)(NameBeginE-NameBegin);
tmp=malloc(len+1); tmp=malloc(len+1);
if (!tmp) { if (!tmp) {
debuga(_("Not enough memory to store the host name aliasi ng directives\n")); debuga(__FILE__,__LINE__,_("Not enough memory to store th e host name aliasing directives\n"));
return(-1); return(-1);
} }
memcpy(tmp,NameBegin,len); memcpy(tmp,NameBegin,len);
tmp[len]='\0'; tmp[len]='\0';
NameBegin=tmp; NameBegin=tmp;
} }
if (NameEnd) { if (NameEnd) {
len=(int)(NameEndE-NameEnd); len=(int)(NameEndE-NameEnd);
tmp=malloc(len+1); tmp=malloc(len+1);
if (!tmp) { if (!tmp) {
if (NameBegin) free((void*)NameBegin); if (NameBegin) free((void*)NameBegin);
debuga(_("Not enough memory to store the host name aliasi ng directives\n")); debuga(__FILE__,__LINE__,_("Not enough memory to store th e host name aliasing directives\n"));
return(-1); return(-1);
} }
memcpy(tmp,NameEnd,len); memcpy(tmp,NameEnd,len);
tmp[len]='\0'; tmp[len]='\0';
NameEnd=tmp; NameEnd=tmp;
} }
// ignore duplicates // ignore duplicates
prev_alias=NULL; prev_alias=NULL;
for (alias=FirstAliasName ; alias ; alias=alias->Next) { for (alias=FirstAliasName ; alias ; alias=alias->Next) {
skipping to change at line 220 skipping to change at line 220
return(0); return(0);
} }
prev_alias=alias; prev_alias=alias;
} }
// insert into the list // insert into the list
new_alias=malloc(sizeof(*new_alias)); new_alias=malloc(sizeof(*new_alias));
if (!new_alias) { if (!new_alias) {
if (NameBegin) free((void*)NameBegin); if (NameBegin) free((void*)NameBegin);
if (NameEnd) free((void*)NameEnd); if (NameEnd) free((void*)NameEnd);
debuga(_("Not enough memory to store the host name aliasing direc tives\n")); debuga(__FILE__,__LINE__,_("Not enough memory to store the host n ame aliasing directives\n"));
return(-1); return(-1);
} }
new_alias->MinLen=0; new_alias->MinLen=0;
if (NameBegin) { if (NameBegin) {
new_alias->HostName_Prefix=NameBegin; new_alias->HostName_Prefix=NameBegin;
new_alias->MinLen+=strlen(NameBegin); new_alias->MinLen+=strlen(NameBegin);
new_alias->PrefixLen=strlen(NameBegin); new_alias->PrefixLen=strlen(NameBegin);
} else { } else {
new_alias->HostName_Prefix=NULL; new_alias->HostName_Prefix=NULL;
new_alias->PrefixLen=0; new_alias->PrefixLen=0;
skipping to change at line 244 skipping to change at line 244
new_alias->MinLen+=strlen(NameEnd)+1; new_alias->MinLen+=strlen(NameEnd)+1;
new_alias->SuffixLen=strlen(NameEnd); new_alias->SuffixLen=strlen(NameEnd);
} else { } else {
new_alias->HostName_Suffix=NULL; new_alias->HostName_Suffix=NULL;
new_alias->SuffixLen=0; new_alias->SuffixLen=0;
} }
if (Replace) { if (Replace) {
len=(int)(ReplaceE-Replace); len=(int)(ReplaceE-Replace);
tmp=malloc(len+2); tmp=malloc(len+2);
if (!tmp) { if (!tmp) {
debuga(_("Not enough memory to store the host name aliasi ng directives\n")); debuga(__FILE__,__LINE__,_("Not enough memory to store th e host name aliasing directives\n"));
return(-1); return(-1);
} }
tmp[0]=ALIAS_PREFIX; tmp[0]=ALIAS_PREFIX;
memcpy(tmp+1,Replace,len); memcpy(tmp+1,Replace,len);
tmp[len+1]='\0'; tmp[len+1]='\0';
new_alias->Alias=tmp; new_alias->Alias=tmp;
} else { } else {
tmp=malloc(new_alias->MinLen+2); tmp=malloc(new_alias->MinLen+2);
if (!tmp) { if (!tmp) {
debuga(_("Not enough memory to store the host name aliasi ng directives\n")); debuga(__FILE__,__LINE__,_("Not enough memory to store th e host name aliasing directives\n"));
return(-1); return(-1);
} }
tmp[0]=ALIAS_PREFIX; tmp[0]=ALIAS_PREFIX;
if (new_alias->HostName_Prefix) strcpy(tmp+1,new_alias->HostName_ Prefix); if (new_alias->HostName_Prefix) strcpy(tmp+1,new_alias->HostName_ Prefix);
if (new_alias->HostName_Suffix) { if (new_alias->HostName_Suffix) {
tmp[new_alias->PrefixLen+1]='*'; tmp[new_alias->PrefixLen+1]='*';
strcpy(tmp+new_alias->PrefixLen+2,new_alias->HostName_Suf fix); strcpy(tmp+new_alias->PrefixLen+2,new_alias->HostName_Suf fix);
} }
new_alias->Alias=tmp; new_alias->Alias=tmp;
} }
skipping to change at line 320 skipping to change at line 320
i=(nbits<alias->NBits) ? nbits : alias->NBits; i=(nbits<alias->NBits) ? nbits : alias->NBits;
if ((i<8 || memcmp(ipv4,alias->Ip,i/8)==0) && ((i%8)==0 || (ipv4[ i/8] ^ alias->Ip[i/8]) & (0xFFU<<(8-i%8)))==0) { if ((i<8 || memcmp(ipv4,alias->Ip,i/8)==0) && ((i%8)==0 || (ipv4[ i/8] ^ alias->Ip[i/8]) & (0xFFU<<(8-i%8)))==0) {
break; break;
} }
prev_alias=alias; prev_alias=alias;
} }
// insert into the list // insert into the list
new_alias=malloc(sizeof(*new_alias)); new_alias=malloc(sizeof(*new_alias));
if (!new_alias) { if (!new_alias) {
debuga(_("Not enough memory to store the host name aliasing direc tives\n")); debuga(__FILE__,__LINE__,_("Not enough memory to store the host n ame aliasing directives\n"));
return(-1); return(-1);
} }
memcpy(new_alias->Ip,ipv4,4); memcpy(new_alias->Ip,ipv4,4);
new_alias->NBits=nbits; new_alias->NBits=nbits;
if (Replace) { if (Replace) {
len=(int)(ReplaceE-Replace); len=(int)(ReplaceE-Replace);
tmp=malloc(len+2); tmp=malloc(len+2);
if (!tmp) { if (!tmp) {
debuga(_("Not enough memory to store the host name aliasi ng directives\n")); debuga(__FILE__,__LINE__,_("Not enough memory to store th e host name aliasing directives\n"));
return(-1); return(-1);
} }
tmp[0]=ALIAS_PREFIX; tmp[0]=ALIAS_PREFIX;
memcpy(tmp+1,Replace,len); memcpy(tmp+1,Replace,len);
tmp[len+1]='\0'; tmp[len+1]='\0';
new_alias->Alias=tmp; new_alias->Alias=tmp;
} else { } else {
tmp=malloc(5*4+1); tmp=malloc(5*4+1);
if (!tmp) { if (!tmp) {
debuga(_("Not enough memory to store the host name aliasi ng directives\n")); debuga(__FILE__,__LINE__,_("Not enough memory to store th e host name aliasing directives\n"));
return(-1); return(-1);
} }
sprintf(tmp,"%c%d.%d.%d.%d/%d",ALIAS_PREFIX,ipv4[0],ipv4[1],ipv4[ 2],ipv4[3],nbits); sprintf(tmp,"%c%d.%d.%d.%d/%d",ALIAS_PREFIX,ipv4[0],ipv4[1],ipv4[ 2],ipv4[3],nbits);
new_alias->Alias=tmp; new_alias->Alias=tmp;
} }
if (prev_alias) { if (prev_alias) {
new_alias->Next=prev_alias->Next; new_alias->Next=prev_alias->Next;
prev_alias->Next=new_alias; prev_alias->Next=new_alias;
} else { } else {
skipping to change at line 402 skipping to change at line 402
i=(nbits<alias->NBits) ? nbits : alias->NBits; i=(nbits<alias->NBits) ? nbits : alias->NBits;
if ((i<16 || memcmp(ipv6,alias->Ip,i/16*2)==0) && ((i%16)==0 || ( ipv6[i/16] ^ alias->Ip[i/16]) & (0xFFFFU<<(16-i%16)))==0) { if ((i<16 || memcmp(ipv6,alias->Ip,i/16*2)==0) && ((i%16)==0 || ( ipv6[i/16] ^ alias->Ip[i/16]) & (0xFFFFU<<(16-i%16)))==0) {
break; break;
} }
prev_alias=alias; prev_alias=alias;
} }
// insert into the list // insert into the list
new_alias=malloc(sizeof(*new_alias)); new_alias=malloc(sizeof(*new_alias));
if (!new_alias) { if (!new_alias) {
debuga(_("Not enough memory to store the host name aliasing direc tives\n")); debuga(__FILE__,__LINE__,_("Not enough memory to store the host n ame aliasing directives\n"));
return(-1); return(-1);
} }
memcpy(new_alias->Ip,ipv6,8*sizeof(unsigned short int)); memcpy(new_alias->Ip,ipv6,8*sizeof(unsigned short int));
new_alias->NBits=nbits; new_alias->NBits=nbits;
if (Replace) { if (Replace) {
len=ReplaceE-Replace; len=ReplaceE-Replace;
tmp=malloc(len+2); tmp=malloc(len+2);
if (!tmp) { if (!tmp) {
debuga(_("Not enough memory to store the host name aliasi ng directives\n")); debuga(__FILE__,__LINE__,_("Not enough memory to store th e host name aliasing directives\n"));
return(-1); return(-1);
} }
tmp[0]=ALIAS_PREFIX; tmp[0]=ALIAS_PREFIX;
memcpy(tmp+1,Replace,len); memcpy(tmp+1,Replace,len);
tmp[len+1]='\0'; tmp[len+1]='\0';
new_alias->Alias=tmp; new_alias->Alias=tmp;
} else { } else {
tmp=malloc(5*8+5); tmp=malloc(5*8+5);
if (!tmp) { if (!tmp) {
debuga(_("Not enough memory to store the host name aliasi ng directives\n")); debuga(__FILE__,__LINE__,_("Not enough memory to store th e host name aliasing directives\n"));
return(-1); return(-1);
} }
sprintf(tmp,"%c%x:%x:%x:%x:%x:%x:%x:%x/%d",ALIAS_PREFIX,ipv6[0],i pv6[1],ipv6[2],ipv6[3],ipv6[4],ipv6[5],ipv6[6],ipv6[7],nbits); sprintf(tmp,"%c%x:%x:%x:%x:%x:%x:%x:%x/%d",ALIAS_PREFIX,ipv6[0],i pv6[1],ipv6[2],ipv6[3],ipv6[4],ipv6[5],ipv6[6],ipv6[7],nbits);
new_alias->Alias=tmp; new_alias->Alias=tmp;
} }
if (prev_alias) { if (prev_alias) {
new_alias->Next=prev_alias->Next; new_alias->Next=prev_alias->Next;
prev_alias->Next=new_alias; prev_alias->Next=new_alias;
} else { } else {
skipping to change at line 465 skipping to change at line 465
char *Replace; char *Replace;
int len; int len;
char *tmp; char *tmp;
int i; int i;
// find the pattern // find the pattern
Delimiter=*buf++; Delimiter=*buf++;
for (End=buf ; *End && *End!=Delimiter ; End++) { for (End=buf ; *End && *End!=Delimiter ; End++) {
if (*End=='\\') { if (*End=='\\') {
if (End[1]=='\0') { 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); return(-1);
} }
End++; //ignore the escaped character End++; //ignore the escaped character
} }
} }
if (*End!=Delimiter) { if (*End!=Delimiter) {
debuga(_("Unterminated regular expression\n")); debuga(__FILE__,__LINE__,_("Unterminated regular expression\n"));
return(-1); return(-1);
} }
*End++='\0'; *End++='\0';
// find the alias // find the alias
for (Replace=End ; *Replace==' ' || *Replace=='\t' ; Replace++); for (Replace=End ; *Replace==' ' || *Replace=='\t' ; Replace++);
for (End=Replace ; *End && (unsigned char)*End>' ' ; End++); for (End=Replace ; *End && (unsigned char)*End>' ' ; End++);
*End='\0'; *End='\0';
// store it // store it
new_alias=malloc(sizeof(*new_alias)); new_alias=malloc(sizeof(*new_alias));
if (!new_alias) { if (!new_alias) {
debuga(_("Not enough memory to store the host name aliasing direc tives\n")); debuga(__FILE__,__LINE__,_("Not enough memory to store the host n ame aliasing directives\n"));
return(-1); return(-1);
} }
new_alias->Next=NULL; new_alias->Next=NULL;
new_alias->Re=pcre_compile(buf,0,&PcreError,&ErrorOffset,NULL); new_alias->Re=pcre_compile(buf,0,&PcreError,&ErrorOffset,NULL);
if (new_alias->Re==NULL) { if (new_alias->Re==NULL) {
debuga(_("Failed to compile the regular expression \"%s\": %s\n") ,buf,PcreError); debuga(__FILE__,__LINE__,_("Failed to compile the regular express ion \"%s\": %s\n"),buf,PcreError);
free(new_alias); free(new_alias);
return(-1); return(-1);
} }
len=strlen(Replace); len=strlen(Replace);
tmp=malloc(len+2); tmp=malloc(len+2);
if (!tmp) { if (!tmp) {
debuga(_("Not enough memory to store the host name aliasing direc tives\n")); debuga(__FILE__,__LINE__,_("Not enough memory to store the host n ame aliasing directives\n"));
pcre_free(new_alias->Re); pcre_free(new_alias->Re);
return(-1); return(-1);
} }
tmp[0]=ALIAS_PREFIX; tmp[0]=ALIAS_PREFIX;
memcpy(tmp+1,Replace,len); memcpy(tmp+1,Replace,len);
tmp[len+1]='\0'; tmp[len+1]='\0';
new_alias->Alias=tmp; new_alias->Alias=tmp;
new_alias->SubPartern=false; new_alias->SubPartern=false;
for (i=1 ; tmp[i] ; i++) for (i=1 ; tmp[i] ; i++)
skipping to change at line 532 skipping to change at line 532
} }
#endif #endif
/*! /*!
Store an alias in the corresponding list. Store an alias in the corresponding list.
\param buf The string to parse and store. \param buf The string to parse and store.
\retval 0 No error. \retval 0 No error.
\retval -1 Error in file. \retval -1 Error in file.
\retval -2 Unknown string type to store.
*/ */
static int Alias_Store(char *buf) static int Alias_Store(char *buf)
{ {
int type; int type;
const char *name; const char *name;
unsigned char ipv4[4]; unsigned char ipv4[4];
unsigned short int ipv6[8]; unsigned short int ipv6[8];
int nbits; int nbits;
const char *next; const char *next;
int Error=-10;//compiler pacifier: uninitialized variable int Error=-2;
if (strncasecmp(buf,"re:",3)==0) { if (strncasecmp(buf,"re:",3)==0) {
#ifdef USE_PCRE #ifdef USE_PCRE
if (Alias_StoreRegexp(buf+3)<0) if (Alias_StoreRegexp(buf+3)<0)
return(-1); return(-1);
return(0); return(0);
#else #else
debuga(_("PCRE not compiled in therefore the regular expressions are not available in the host alias file\n")); debuga(__FILE__,__LINE__,_("PCRE not compiled in therefore the re gular expressions are not available in the host alias file\n"));
return(-1); return(-1);
#endif #endif
} }
type=extract_address_mask(buf,&name,ipv4,ipv6,&nbits,&next); type=extract_address_mask(buf,&name,ipv4,ipv6,&nbits,&next);
if (type<0) { if (type<0) {
return(-1); return(-1);
} }
if (type==1) { if (type==1) {
Error=Alias_StoreName(name,next); Error=Alias_StoreName(name,next);
skipping to change at line 576 skipping to change at line 577
return(0); return(0);
} }
/*! /*!
Read the file containing the host names to alias in the report. Read the file containing the host names to alias in the report.
\param Filename The name of the file. \param Filename The name of the file.
*/ */
void read_hostalias(const char *Filename) void read_hostalias(const char *Filename)
{ {
FILE *fi; FileObject *fi;
longline line; longline line;
char *buf; char *buf;
if (debug) debuga(_("Reading host alias file \"%s\"\n"),Filename); if (debug) debuga(__FILE__,__LINE__,_("Reading host alias file \"%s\"\n")
fi=fopen(Filename,"rt"); ,Filename);
fi=FileObject_Open(Filename);
if (!fi) { if (!fi) {
debuga(_("Cannot read host name alias file \"%s\": %s\n"),Filenam e,strerror(errno)); debuga(__FILE__,__LINE__,_("Cannot read host name alias file \"%s \": %s\n"),Filename,FileObject_GetLastOpenError());
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if ((line=longline_create())==NULL) { if ((line=longline_create())==NULL) {
debuga(_("Not enough memory to read file \"%s\"\n"),Filename); debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\" \n"),Filename);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
while ((buf=longline_read(fi,line)) != NULL) { while ((buf=longline_read(fi,line)) != NULL) {
if (Alias_Store(buf)<0) { if (Alias_Store(buf)<0) {
debuga(_("While reading \"%s\"\n"),Filename); debuga(__FILE__,__LINE__,_("While reading \"%s\"\n"),File name);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
longline_destroy(&line); longline_destroy(&line);
fclose(fi); if (FileObject_Close(fi)) {
debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),Filename
,FileObject_GetLastCloseError());
exit(EXIT_FAILURE);
}
if (debug) { if (debug) {
struct hostalias_name *alias1; struct hostalias_name *alias1;
struct hostalias_ipv4 *alias4; struct hostalias_ipv4 *alias4;
struct hostalias_ipv6 *alias6; struct hostalias_ipv6 *alias6;
debuga(_("List of host names to alias:\n")); debuga(__FILE__,__LINE__,_("List of host names to alias:\n"));
for (alias1=FirstAliasName ; alias1 ; alias1=alias1->Next) { for (alias1=FirstAliasName ; alias1 ; alias1=alias1->Next) {
if (alias1->HostName_Prefix && alias1->HostName_Suffix) if (alias1->HostName_Prefix && alias1->HostName_Suffix)
debuga(_(" %s*%s => %s\n"),alias1->HostName_Pref ix,alias1->HostName_Suffix,alias1->Alias); debuga(__FILE__,__LINE__,_(" %s*%s => %s\n"),ali as1->HostName_Prefix,alias1->HostName_Suffix,alias1->Alias);
else if (alias1->HostName_Prefix) else if (alias1->HostName_Prefix)
debuga(_(" %s => %s\n"),alias1->HostName_Prefix, alias1->Alias); debuga(__FILE__,__LINE__,_(" %s => %s\n"),alias1 ->HostName_Prefix,alias1->Alias);
else else
debuga(_(" *%s => %s\n"),alias1->HostName_Suffix ,alias1->Alias); debuga(__FILE__,__LINE__,_(" *%s => %s\n"),alias 1->HostName_Suffix,alias1->Alias);
} }
for (alias4=FirstAliasIpv4 ; alias4 ; alias4=alias4->Next) { for (alias4=FirstAliasIpv4 ; alias4 ; alias4=alias4->Next) {
debuga(_(" %d.%d.%d.%d/%d => %s\n"),alias4->Ip[0],alias4 ->Ip[1],alias4->Ip[2],alias4->Ip[3],alias4->NBits,alias4->Alias); debuga(__FILE__,__LINE__,_(" %d.%d.%d.%d/%d => %s\n"),al ias4->Ip[0],alias4->Ip[1],alias4->Ip[2],alias4->Ip[3],alias4->NBits,alias4->Alia s);
} }
for (alias6=FirstAliasIpv6 ; alias6 ; alias6=alias6->Next) { for (alias6=FirstAliasIpv6 ; alias6 ; alias6=alias6->Next) {
debuga(_(" %x:%x:%x:%x:%x:%x:%x:%x/%d => %s\n"),alias6-> Ip[0],alias6->Ip[1],alias6->Ip[2],alias6->Ip[3], debuga(__FILE__,__LINE__,_(" %x:%x:%x:%x:%x:%x:%x:%x/%d => %s\n"),alias6->Ip[0],alias6->Ip[1],alias6->Ip[2],alias6->Ip[3],
alias6->Ip[4],alias6->Ip[5],alias6->Ip[6],alias6- >Ip[7],alias6->NBits,alias6->Alias); alias6->Ip[4],alias6->Ip[5],alias6->Ip[6],alias6- >Ip[7],alias6->NBits,alias6->Alias);
} }
} }
} }
/*! /*!
Free the memory allocated by read_hostalias(). Free the memory allocated by read_hostalias().
*/ */
void free_hostalias(void) void free_hostalias(void)
{ {
skipping to change at line 858 skipping to change at line 862
return(url); return(url);
} }
/*! /*!
Get the part of the URL necessary to generate the report. Get the part of the URL necessary to generate the report.
\param url The URL as extracted from the report. \param url The URL as extracted from the report.
\param full_url \c True to keep the whole URL. If \c false, \param full_url \c True to keep the whole URL. If \c false,
the URL is truncated to only keep the host name and port number. the URL is truncated to only keep the host name and port number.
*/ */
const char *process_url(char *url,bool full_url) const char *process_url(const char *url,bool full_url)
{ {
char *str; static char short_url[1024];
int i;
const char *start; const char *start;
int type; int type;
unsigned char ipv4[4]; unsigned char ipv4[4];
unsigned short int ipv6[8]; unsigned short int ipv6[8];
const char *next; const char *next;
start=skip_scheme(url); start=skip_scheme(url);
if (!full_url) { if (!full_url) {
for (str=(char *)start ; *str && *str!='/' && *str!='?' ; str++); for (i=0 ; i<sizeof(short_url)-1 && start[i] && start[i]!='/' &&
*str='\0'; start[i]!='?' ; i++)
short_url[i]=start[i];
short_url[i]='\0';
start=short_url;
#ifdef USE_PCRE #ifdef USE_PCRE
if (FirstAliasRe) { if (FirstAliasRe) {
if (alias_url_regex(&start)) return(start); if (alias_url_regex(&start)) return(start);
} }
#endif #endif
type=extract_address_mask(start,NULL,ipv4,ipv6,NULL,&next); type=extract_address_mask(start,NULL,ipv4,ipv6,NULL,&next);
if (type==1) { if (type==1) {
if (FirstAliasName) if (FirstAliasName)
start=alias_url_name(start,next); start=alias_url_name(start,next);
} else if (type==2) { } else if (type==2) {
 End of changes. 37 change blocks. 
38 lines changed or deleted 48 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)