]>
Commit | Line | Data |
---|---|---|
25697a35 | 1 | /* |
94ff9470 | 2 | * AUTHOR: Pedro Lineu Orso orso@penguintech.com.br |
25697a35 | 3 | * 1998, 2005 |
94ff9470 | 4 | * SARG Squid Analysis Report Generator http://sarg.sourceforge.net |
25697a35 GS |
5 | * |
6 | * SARG donations: | |
7 | * please look at http://sarg.sourceforge.net/donations.php | |
8 | * --------------------------------------------------------------------- | |
9 | * | |
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. | |
14 | * | |
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. | |
19 | * | |
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. | |
23 | * | |
24 | */ | |
25 | ||
26 | #include "include/conf.h" | |
27 | ||
28 | void convlog(char *arq, char *df, int dfrom, int duntil) | |
29 | { | |
30 | ||
31 | FILE *fp_in; | |
32 | char buf[MAXLEN]; | |
33 | char data[30]; | |
34 | char dia[11]; | |
35 | char hora[9]; | |
36 | char wdata[20]; | |
37 | time_t tt; | |
38 | int idata=0; | |
39 | struct tm *t; | |
40 | ||
41 | if(arq[0] == '\0') | |
42 | strcpy(arq,"/usr/local/squid/logs/access.log"); | |
43 | ||
44 | if((fp_in=fopen(arq,"r"))==NULL) { | |
45 | fprintf(stderr, "SARG: (convlog) %s: %s\n",text[8],arq); | |
46 | exit(1); | |
47 | } | |
48 | ||
49 | while(fgets(buf,sizeof(buf),fp_in)!=NULL) { | |
50 | getword(data,buf,' '); | |
51 | tt=atoi(data); | |
52 | t=localtime(&tt); | |
53 | ||
54 | if(dfrom) { | |
55 | strftime(wdata, 127, "%Y%m%d", t); | |
56 | idata=atoi(wdata); | |
57 | if(idata < dfrom || idata > duntil) | |
58 | continue; | |
59 | } | |
60 | ||
61 | if(strncmp(df,"e",1) == 0) | |
62 | strftime(dia, 127, "%d/%m/%Y", t); | |
63 | else | |
64 | strftime(dia, 127, "%m/%d/%Y", t); | |
65 | sprintf(hora,"%02d:%02d:%02d",t->tm_hour,t->tm_min,t->tm_sec); | |
66 | ||
67 | printf("%s %s %s",dia,hora,buf); | |
68 | } | |
69 | ||
70 | fclose(fp_in); | |
71 | } |