sarg
2.4.0
About: SARG ia a Squid Analysis Report Generator. Fossies Dox: sarg-2.4.0.tar.gz ("unofficial" and yet experimental doxygen-generated source code documentation) 
|
Go to the documentation of this file.
30 static void saverecs(FILE *fp_ou,
const struct userinfostruct *uinfo,
long long int nacc,
const char *url,
long long int nbytes,
const char *ip,
const char *hora,
const char *dia,
long long int nelap,
long long int incache,
long long int oucache);
38 char accdia[11], acchora[9], accip[
MAXLEN], *accurl;
39 char oldaccdia[11], oldacchora[9], oldaccip[
MAXLEN];
41 char acccode[50], oldacccode[50];
50 long long int nbytes=0;
51 long long int nelap=0;
54 long long int incache=0;
55 long long int oucache=0;
56 long long int accbytes;
57 long long int accelap;
76 debuga(__FILE__,__LINE__,
_(
"Cannot enumerate the user list\n"));
91 if (snprintf(tmp3,
sizeof(tmp3),
"%s/%s.user_log",
tmp,uinfo->
filename)>=
sizeof(tmp3)) {
92 debuga(__FILE__,__LINE__,
_(
"Path too long: "));
103 debuga(__FILE__,__LINE__,
_(
"Not enough memory to read file \"%s\"\n"),tmp3);
111 if (
getword(accdia,
sizeof(accdia),&gwarea,
'\t')<0 ||
getword(acchora,
sizeof(acchora),&gwarea,
'\t')<0 ||
112 getword(accip,
sizeof(accip),&gwarea,
'\t')<0 ||
115 debuga(__FILE__,__LINE__,
_(
"Invalid record in file \"%s\"\n"),tmp3);
118 if (
getword_skip(20000,&gwarea,
'"')<0 ||
getword(accsmart,
sizeof(accsmart),&gwarea,
'"')<0) {
119 debuga(__FILE__,__LINE__,
_(
"Invalid smart info in file \"%s\"\n"),tmp3);
124 if (strcmp(accip,ipantes) != 0) {
125 strcpy(ipantes,accip);
127 strcpy(nameantes,accip);
129 else strcpy(accip,nameantes);
133 url_len=strlen(accurl);
134 if (!oldurl || url_len>=ourl_size) {
136 oldurl=realloc(oldurl,ourl_size);
138 debuga(__FILE__,__LINE__,
_(
"Not enough memory to store the url\n"));
142 strcpy(oldurl,accurl);
143 strcpy(oldacccode,acccode);
144 strcpy(oldaccip,accip);
145 strcpy(oldaccdia,accdia);
146 strcpy(oldacchora,acchora);
150 same_url=(strcmp(oldurl,accurl) == 0);
152 if (!same_url || new_user){
154 debuga(__FILE__,__LINE__,
_(
"Cannot open file \"%s\": %s\n"),
DataFile,strerror(errno));
157 saverecs(fp_ou,uinfo,nacc,oldurl,nbytes,oldaccip,oldacchora,oldaccdia,nelap,incache,oucache);
170 strcpy(crc2,acccode);
171 str=strchr(crc2,
'/');
174 if (strstr(crc2,
"MISS") != 0) oucache+=accbytes;
175 else incache+=accbytes;
178 url_len=strlen(accurl);
179 if (url_len>=ourl_size) {
181 oldurl=realloc(oldurl,ourl_size);
183 debuga(__FILE__,__LINE__,
_(
"Not enough memory to store the url\n"));
187 strcpy(oldurl,accurl);
190 strcpy(oldacccode,acccode);
191 strcpy(oldaccip,accip);
192 strcpy(oldaccdia,accdia);
193 strcpy(oldacchora,acchora);
203 if (oldurl) free(oldurl);
204 if (fp_ou && fclose(fp_ou)==EOF) {
205 debuga(__FILE__,__LINE__,
_(
"Write error in \"%s\": %s\n"),
DataFile,strerror(errno));
210 debuga(__FILE__,__LINE__,
_(
"Datafile \"%s\" written successfully\n"),
DataFile);
213 static void saverecs(FILE *fp_ou,
const struct userinfostruct *uinfo,
long long int nacc,
const char *url,
long long int nbytes,
const char *
ip,
const char *hora,
const char *dia,
long long int nelap,
long long int incache,
long long int oucache)
219 fputs(uinfo->
label,fp_ou);
247 my_lltoa(incache,val,
sizeof(val),0);
252 my_lltoa(oucache,val,
sizeof(val),0);
userscan userinfo_startscan(void)
void sort_users_log(const char *tmp, int debug, struct userinfostruct *uinfo)
void getword_start(struct getwordstruct *gwarea, const char *line)
void debuga(const char *File, int Line, const char *msg,...)
What is known about a user.
void name2ip(char *name, int name_size)
char * longline_read(FileObject *fp_in, longline line)
const char * FileObject_GetLastCloseError(void)
const char * FileObject_GetLastOpenError(void)
void data_file(char *tmp)
const char * id
The ID of the user as found in the input file.
void my_lltoa(unsigned long long int n, char *s, int ssize, int len)
void ip2name(char *ip, int ip_len)
int getword_skip(int limit, struct getwordstruct *gwarea, char stop)
Hold pointer to scan through the user list.
#define DATA_FIELD_ELAPSED
unsigned long int DataFileFields
bool id_is_ip
True if the ID is in fact the IP address from which the user connected.
void init_usertab(const char *UserTabFile)
const char * label
The name of the user to display in the report.
int getword_ptr(char *orig_line, char **word, struct getwordstruct *gwarea, char stop)
#define DATA_FIELD_OUT_CACHE
#define DATA_FIELD_CONNECT
int getword(char *word, int limit, struct getwordstruct *gwarea, char stop)
FileObject * FileObject_Open(const char *FileName)
Include headers and define global variables. */.
void userinfo_stopscan(userscan uscan)
#define ALIAS_PREFIX
The character prefixed in front of the host names that are aliased.
struct userinfostruct * userinfo_advancescan(userscan uscan)
longline longline_create(void)
const char * filename
The mangled name to use in file names of that user.
void longline_destroy(longline *line_ptr)
const char * ip
The user's IP address.
Declaration of the structures and functions.
void url_hostname(const char *url, char *hostname, int hostsize)
char DataFileDelimiter[3]
void user_find(char *mappedname, int namelen, const char *userlogin)
unsigned long int DataFileUrl
int getword_atoll(long long int *number, struct getwordstruct *gwarea, char stop)
void userinfo_label(struct userinfostruct *uinfo, const char *label)
static void saverecs(FILE *fp_ou, const struct userinfostruct *uinfo, long long int nacc, const char *url, long long int nbytes, const char *ip, const char *hora, const char *dia, long long int nelap, long long int incache, long long int oucache)
int FileObject_Close(FileObject *File)
void debuga_more(const char *msg,...)
#define DATA_FIELD_IN_CACHE