]>
git.ipfire.org Git - thirdparty/sarg.git/blob - totday.c
4d0133802bc45aa4c56be5da3768702cb7ee2317
2 * AUTHOR: Pedro Lineu Orso orso@penguintech.com.br
4 * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
7 * please look at http://sarg.sourceforge.net/donations.php
8 * ---------------------------------------------------------------------
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
26 #include "include/conf.h"
28 void totaliza_day(const char *tmp
, char *user
, int indexonly
)
43 char wdirname
[MAXLEN
];
47 long long int telap
=0;
48 long long int tused
=0;
51 if(strstr(ReportType
,"users_sites") == 0) return;
53 sprintf(wdirname
,"%s/%s.htmp",tmp
,user
);
54 sprintf(arqout
,"%s/%s.day",tmp
,user
);
55 sprintf(sortout
,"%s/%s.sort",tmp
,user
);
57 sprintf(csort
,"sort -k 1,1 -k 2,2 -o '%s' '%s'",sortout
,wdirname
);
62 if((fp_in
=fopen(sortout
,"r"))==NULL
) {
63 fprintf(stderr
, "SARG: (totday) %s: %s\n",text
[8],sortout
);
67 if((fp_ou
=fopen(arqout
,"w"))==NULL
) {
68 fprintf(stderr
, "SARG: (totday) %s: %s\n",text
[8],arqout
);
72 while(fgets(buf
,sizeof(buf
),fp_in
)!=NULL
) {
73 if(strstr(buf
,"\n") != 0)
74 buf
[strlen(buf
)-1]='\0';
76 getword(data
,buf
,' ');
77 getword(hora
,buf
,':');
79 getword(elap
,buf
,' ');
81 sprintf(hm
,"%s%s",hora
,min
);
91 if(strcmp(hora
,ohora
) != 0) {
95 my_lltoa(telap
,val1
,15);
96 sprintf(buf
,"%s %s %s\n",odata
,ohora
,val1
);
105 if(strcmp(ohm
,hm
) != 0) {
110 telap
+=my_atoll(elap
);
117 my_lltoa(telap
,val1
,15);
118 sprintf(buf
,"%s %s %s\n",data
,hora
,val1
);