26
26
#include "include/conf.h"
27
#include "include/defs.h"
28
29
int totalger(const char *dirname, int debug, const char *outdir)
33
31
FILE *fp_in, *fp_ou;
34
32
long long int tnacc=0;
35
33
long long int tnbytes=0;
36
34
long long int telap=0;
37
35
long long int tincache=0, toucache=0;
38
char wger[MAXLEN], user[MAXLEN], nacc[16], nbytes[16], url[1024];
39
char ip[MAXLEN], hora[9], data[11], elap[16];
40
char incac[16], oucac[16];
36
char wger[MAXLEN], user[MAXLEN], nacc[16], nbytes[16], url[MAXLEN];
37
char ip[MAXLEN], hora[9], data[15], elap[16];
38
char incac[30], oucac[30];
42
41
strcpy(wger,dirname);
43
42
strcat(wger,"/sarg-general");
50
fscanf(fp_in,"%s%s%s%s%s%s%s%s%s%s",user,nacc,nbytes,url,ip,hora,data,elap,incac,oucac);
49
while(fgets(warea,sizeof(warea),fp_in))
51
//printf("%s\n",warea);
52
if (getword(user,sizeof(user),warea,' ')<0) {
53
printf("SARG: Maybe you have a broken user in your %s file.\n",wger);
56
if (getword(nacc,sizeof(nacc),warea,' ')<0) {
57
printf("SARG: Maybe you have a broken number of access in your %s file.\n",wger);
60
if (getword(nbytes,sizeof(nbytes),warea,' ')<0) {
61
printf("SARG: Maybe you have a broken number of bytes in your %s file.\n",wger);
64
if (getword(url,sizeof(url),warea,' ')<0) {
65
printf("SARG: Maybe you have a broken url in your %s file.\n",wger);
68
if (getword(ip,sizeof(ip),warea,' ')<0) {
69
printf("SARG: Maybe you have a broken source IP address in your %s file.\n",wger);
72
if (getword(hora,sizeof(hora),warea,' ')<0) {
73
printf("SARG: Maybe you have a broken time in your %s file.\n",wger);
76
if (getword(data,sizeof(data),warea,' ')<0) {
77
printf("SARG: Maybe you have a broken date in your %s file.\n",wger);
80
if (getword(elap,sizeof(elap),warea,' ')<0) {
81
printf("SARG: Maybe you have a broken elapsed time in your %s file.\n",wger);
84
if (getword(incac,sizeof(incac),warea,' ')<0) {
85
printf("SARG: Maybe you have a broken in cache column in your %s file.\n",wger);
88
if (getword(oucac,sizeof(oucac),warea,0)<0) {
89
printf("SARG: Maybe you have a broken not in cache column in your %s file.\n",wger);
54
92
tnacc+=my_atoll(nacc);
55
93
tnbytes+=my_atoll(nbytes);
56
94
telap+=my_atoll(elap);
57
95
tincache+=my_atoll(incac);
58
96
toucache+=my_atoll(oucac);
60
fscanf(fp_in,"%s%s%s%s%s%s%s%s%s%s",user,nacc,nbytes,url,ip,hora,data,elap,incac,oucac);
77
113
my_lltoa(telap,val3,15);
78
114
my_lltoa(tincache,val4,15);
79
115
my_lltoa(toucache,val5,15);
80
sprintf(url,"TOTAL %s %s %s %s %s\n",val1,val2,val3,val4,val5);
116
fprintf(fp_ou,"TOTAL %s %s %s %s %s\n",val1,val2,val3,val4,val5);