long long int tnbytes=0;
long long int telap=0;
long long int tincache=0, toucache=0;
- long long int nacc, nbytes;
- long long int elap;
- long long int incac, oucac;
- char wger[MAXLEN], user[MAXLEN], url[MAXLEN];
- char ip[MAXLEN], hora[9], data[15];
- char warea[MAXLEN];
- struct getwordstruct gwarea;
+ char wger[MAXLEN];
+ char *warea;
+ struct longlinestruct line;
+ struct generalitemstruct item;
strcpy(wger,dirname);
strcat(wger,"/sarg-general");
if((fp_in=fopen(wger,"r"))==NULL) {
- fprintf(stderr, "SARG: (totger) %s: %s\n",text[45],wger);
+ fprintf(stderr, "SARG: (totger) %s: %s\n",_("Cannot open file"),wger);
exit(1);
}
- while(fgets(warea,sizeof(warea),fp_in))
+ if (longline_prepare(&line)<0) {
+ debuga(_("Not enough memory to read the temporary file %s"),wger);
+ exit(1);
+ }
+
+ while((warea=longline_read(fp_in,&line))!=NULL)
{
- //printf("%s\n",warea);
- getword_start(&gwarea,warea);
- if (getword(user,sizeof(user),&gwarea,'\t')<0) {
- printf("SARG: Maybe you have a broken user in your %s file.\n",wger);
- exit(1);
- }
- if (getword_atoll(&nacc,&gwarea,'\t')<0) {
- printf("SARG: Maybe you have a broken number of access in your %s file.\n",wger);
- exit(1);
- }
- if (getword_atoll(&nbytes,&gwarea,'\t')<0) {
- printf("SARG: Maybe you have a broken number of bytes in your %s file.\n",wger);
- exit(1);
- }
- if (getword(url,sizeof(url),&gwarea,'\t')<0) {
- printf("SARG: Maybe you have a broken url in your %s file.\n",wger);
- exit(1);
- }
- if (getword(ip,sizeof(ip),&gwarea,'\t')<0) {
- printf("SARG: Maybe you have a broken source IP address in your %s file.\n",wger);
- exit(1);
- }
- if (getword(hora,sizeof(hora),&gwarea,'\t')<0) {
- printf("SARG: Maybe you have a broken time in your %s file.\n",wger);
- exit(1);
- }
- if (getword(data,sizeof(data),&gwarea,'\t')<0) {
- printf("SARG: Maybe you have a broken date in your %s file.\n",wger);
- exit(1);
- }
- if (getword_atoll(&elap,&gwarea,'\t')<0) {
- printf("SARG: Maybe you have a broken elapsed time in your %s file.\n",wger);
- exit(1);
- }
- if (getword_atoll(&incac,&gwarea,'\t')<0) {
- printf("SARG: Maybe you have a broken in cache column in your %s file.\n",wger);
- exit(1);
- }
- if (getword_atoll(&oucac,&gwarea,'\n')<0) {
- printf("SARG: Maybe you have a broken not in cache column in your %s file.\n",wger);
- exit(1);
- }
- tnacc+=nacc;
- tnbytes+=nbytes;
- telap+=elap;
- tincache+=incac;
- toucache+=oucac;
+ ger_read(warea,&item,wger);
+ tnacc+=item.nacc;
+ tnbytes+=item.nbytes;
+ telap+=item.nelap;
+ tincache+=item.incache;
+ toucache+=item.oucache;
}
fclose(fp_in);
-
- strcpy(wger,dirname);
- strcat(wger,"/sarg-general");
+ longline_free(&line);
if((fp_ou=fopen(wger,"a"))==NULL) {
- fprintf(stderr, "SARG: (totger) %s: %s\n",text[45],wger);
- exit(1);
+ fprintf(stderr, "SARG: (totger) %s: %s\n",_("Cannot open file"),wger);
+ exit(1);
}
- url[0]='\0';
-
- my_lltoa(tnacc,val1,15);
- my_lltoa(tnbytes,val2,15);
- my_lltoa(telap,val3,15);
- my_lltoa(tincache,val4,15);
- my_lltoa(toucache,val5,15);
- fprintf(fp_ou,"TOTAL\t%s\t%s\t%s\t%s\t%s\n",val1,val2,val3,val4,val5);
+ fprintf(fp_ou,"TOTAL\t%lld\t%lld\t%lld\t%lld\t%lld\n",tnacc,tnbytes,telap,tincache,toucache);
fclose(fp_ou);
return (0);