]>
git.ipfire.org Git - thirdparty/sarg.git/blob - totday.c
a29638b41bbcc440032d76350f29053c51dc3321
2 * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
6 * please look at http://sarg.sourceforge.net/donations.php
8 * http://sourceforge.net/projects/sarg/forums/forum/363374
9 * ---------------------------------------------------------------------
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
27 #include "include/conf.h"
28 #include "include/defs.h"
30 void day_totalize(const char *tmp
, const struct userinfostruct
*uinfo
, int indexonly
)
43 char wdirname
[MAXLEN
];
47 long long int telap
=0;
49 struct getwordstruct gwarea
;
52 if((ReportType
& REPORT_TYPE_USERS_SITES
) == 0) return;
54 sprintf(wdirname
,"%s/%s.htmp",tmp
,uinfo
->filename
);
55 sprintf(arqout
,"%s/%s.day",tmp
,uinfo
->filename
);
56 sprintf(sortout
,"%s/%s.sort",tmp
,uinfo
->filename
);
58 sprintf(csort
,"sort -k 1,1 -k 2,2 -o \"%s\" \"%s\"",sortout
,wdirname
);
59 cstatus
=system(csort
);
60 if (!WIFEXITED(cstatus
) || WEXITSTATUS(cstatus
)) {
61 debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus
));
62 debuga(_("sort command: %s\n"),csort
);
65 if((fp_in
=fopen(sortout
,"r"))==NULL
) {
66 debuga(_("SARG: (totday) Cannot open log file: %s\n"),sortout
);
67 debuga(_("sort command: %s\n"),csort
);
73 if((fp_ou
=fopen(arqout
,"w"))==NULL
) {
74 debuga(_("(totday) Cannot open log file: %s\n"),arqout
);
78 while(fgets(buf
,sizeof(buf
),fp_in
)!=NULL
) {
80 getword_start(&gwarea
,buf
);
81 if (getword(data
,sizeof(data
),&gwarea
,'\t')<0 || getword(hora
,sizeof(hora
),&gwarea
,':')<0 ||
82 getword(min
,sizeof(min
),&gwarea
,':')<0 || getword_skip(20,&gwarea
,'\t')<0 ||
83 getword(elap
,sizeof(elap
),&gwarea
,0)<0) {
84 debuga(_("There is a broken record or garbage in file %s\n"),sortout
);
95 if(strcmp(hora
,ohora
) != 0 || strcmp(data
,odata
) != 0) {
96 fprintf(fp_ou
,"%s\t%s\t%015lld\n",odata
,ohora
,telap
);
102 telap
+=my_atoll(elap
);
105 fprintf(fp_ou
,"%s\t%s\t%015lld\n",data
,hora
,telap
);