]> git.ipfire.org Git - thirdparty/sarg.git/blame - grepday.c
Ignore comments in exclude_code file
[thirdparty/sarg.git] / grepday.c
CommitLineData
25697a35 1/*
94ff9470 2 * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
1164c474 3 * 1998, 2010
25697a35
GS
4 *
5 * SARG donations:
6 * please look at http://sarg.sourceforge.net/donations.php
1164c474
FM
7 * Support:
8 * http://sourceforge.net/projects/sarg/forums/forum/363374
25697a35
GS
9 * ---------------------------------------------------------------------
10 *
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.
15 *
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.
20 *
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.
24 *
25 */
26
27#include "include/conf.h"
5f3cfd1d 28#include "include/defs.h"
25697a35 29
a1de61fe 30#if defined(HAVE_GD)
17c89803 31
c274f011
FM
32static int blue;
33static int white;
34static int lavender;
35static int darkblue;
36static int dimgray;
37static int goldenrod;
38static int goldenrod2;
39static int gray;
40static int silver;
41static int black;
25697a35 42
a1de61fe 43#if defined(HAVE_ICONV_H) && defined(gdFTEX_Unicode)
25697a35
GS
44#include <iconv.h>
45#define SARGgdImageStringFT I18NgdImageStringFT
46
c274f011 47static char * I18NgdImageStringFT (gdImage * im, int *brect, int fg, char *fontlist,
d6e703cc 48 double ptsize, double angle, int x, int y, char *string)
25697a35 49{
1dd9dcec
FM
50 iconv_t localtoutf;
51 char *sstring, *str, *sstr, *retval;
52 size_t slen, sslen;
53
54 slen = strlen(string) + 1; // We must include string termination character
55 sslen = slen * 2; // We assume that UTF8 maximum 2 times large than local
56 sstring = (char *)malloc(sslen);
57 if (!sstring) {
9f70c14e 58 debuga(_("malloc error (%zu bytes required)\n"),sslen);
06b39c87 59 exit(EXIT_FAILURE);
1dd9dcec 60 }
25697a35 61
1dd9dcec
FM
62 str = (char *) string;
63 sstr = (char *) sstring;
25697a35 64
1dd9dcec 65 localtoutf = iconv_open ("UTF-8", CharSet);
07709548 66 if (localtoutf==(iconv_t)-1) {
9f70c14e 67 debuga(_("(grepday) iconv cannot convert from %s to UTF-8 - %s\n"),CharSet,strerror(errno));
07709548
FM
68 strcpy(sstring,string); //show something sensible on the graph
69 }
70 else {
71 if (iconv (localtoutf, (ICONV_CONST char **)&str, &slen, &sstr, &sslen)==-1) {
9f70c14e 72 debuga(_("(grepday) iconv failed to convert string \"%s\" from %s to UTF-8 - %s\n"),string,CharSet,strerror(errno));
07709548
FM
73 strcpy(sstring,string); //show something sensible on the graph
74 }
75 iconv_close (localtoutf);
76 }
25697a35 77
1dd9dcec
FM
78 retval = gdImageStringFTEx (im, brect, fg, fontlist, ptsize, angle, x, y, sstring, gdFTEX_Unicode);
79 free(sstring);
25697a35 80
1dd9dcec 81 return retval;
25697a35
GS
82}
83#else
84#define SARGgdImageStringFT gdImageStringFT
85#endif
86
c274f011 87static void bar(int x1,long long int n)
1dd9dcec 88{
25697a35
GS
89 gdPoint points[4];
90 int brect[8];
91 int val=0, x;
32e71fa4 92 long long int num;
25697a35
GS
93 char v[15];
94
32e71fa4
FM
95 static const long long int limits[400]={0,500,1000,2000,3000,4000,
96 5000,6000,7000,8000,9000,10000,
97 20000,30000,40000,50000,70000,90000,
98 110000,130000,150000,170000,190000,210000,
99 230000,250000,280000,310000,340000,370000,
100 400000,430000,450000,460000,490000,500000,
101 550000,600000,650000,700000,750000,800000,
102 850000,900000,950000,1000000,1100000,1200000,
103 1300000,1400000,1500000,1600000,1700000,1800000,
104 1900000,2000000,2100000,2200000,2300000,2400000,
105 2500000,2600000,2700000,2800000,2900000,3000000,
106 3100000,3200000,3300000,3400000,3500000,3600000,
107 3700000,3800000,3900000,4000000,4100000,4200000,
108 4300000,4400000,4500000,4600000,4700000,4800000,
109 4900000,5000000,5100000,5200000,5300000,5400000,
110 5500000,5600000,5700000,5800000,5900000,6000000,
111 6100000,6200000,6300000,6400000,6500000,6600000,
112 6700000,6800000,6900000,7000000,7100000,7200000,
113 7300000,7400000,7500000,7600000,7700000,7800000,
114 7900000,8000000,8100000,8200000,8300000,8400000,
115 8500000,8600000,8700000,8800000,8900000,9000000,
116 9100000,9200000,9300000,9400000,9500000,9600000,
117 9700000,9800000,9900000,10000000,10500000,11000000,
118 11500000,12000000,12500000,13000000,13500000,14000000,
119 14500000,15000000,15500000,16000000,16500000,17000000,
120 17500000,18000000,18500000,19000000,19500000,20000000,
121 21000000,22000000,23000000,24000000,25000000,26000000,
122 27000000,28000000,29000000,30000000,31000000,32000000,
123 33000000,34000000,35000000,36000000,37000000,38000000,
124 39000000,40000000,41000000,42000000,43000000,44000000,
125 45000000,46000000,47000000,48000000,49000000,50000000,
126 51000000,52000000,53000000,54000000,55000000,56000000,
127 57000000,58000000,59000000,60000000,61000000,62000000,
128 63000000,64000000,65000000,66000000,67000000,68000000,
129 69000000,70000000,71000000,72000000,73000000,74000000,
130 75000000,76000000,77000000,78000000,79000000,80000000,
131 81000000,82000000,83000000,84000000,85000000,86000000,
132 87000000,88000000,89000000,90000000,91000000,92000000,
133 93000000,94000000,95000000,96000000,97000000,98000000,
134 99000000,100000000,110000000,120000000,130000000,140000000,
135 150000000,160000000,170000000,180000000,190000000,200000000,
136 210000000,220000000,230000000,240000000,250000000,260000000,
137 270000000,280000000,290000000,300000000,310000000,320000000,
138 330000000,340000000,350000000,360000000,370000000,380000000,
139 390000000,400000000,410000000,420000000,430000000,440000000,
140 450000000,460000000,470000000,480000000,490000000,500000000,
141 510000000,520000000,530000000,540000000,550000000,560000000,
142 570000000,580000000,590000000,600000000,610000000,620000000,
143 630000000,640000000,650000000,660000000,670000000,680000000,
144 690000000,700000000,710000000,720000000,730000000,740000000,
145 750000000,760000000,770000000,780000000,790000000,800000000,
146 810000000,820000000,830000000,840000000,850000000,860000000,
147 870000000,880000000,890000000,900000000,910000000,920000000,
148 930000000,940000000,950000000,960000000,970000000,980000000,
149 990000000LL,1000000000LL,1100000000LL,1200000000LL,1300000000LL,1400000000LL,
150 1500000000LL,1600000000LL,1700000000LL,1800000000LL,1900000000LL,2000000000LL,
151 2100000000LL,2200000000LL,2300000000LL,2400000000LL,2500000000LL,2600000000LL,
152 2700000000LL,2800000000LL,2900000000LL,3000000000LL,3100000000LL,3200000000LL,
153 3300000000LL,3400000000LL,3500000000LL,3600000000LL,3700000000LL,3800000000LL,
154 3900000000LL,4000000000LL,4100000000LL,4200000000LL,4300000000LL,4400000000LL,
155 4500000000LL,4600000000LL,4700000000LL,4800000000LL,4900000000LL,5000000000LL};
25697a35 156
25697a35
GS
157 if(strcmp(GraphDaysBytesBarColor,"orange") == 0) {
158 color1 = gdImageColorAllocate(im, 255, 233, 142);
159 color2 = gdImageColorAllocate(im, 220, 163, 72);
160 color3 = gdImageColorAllocate(im, 255, 198, 107);
161 }
162 if(strcmp(GraphDaysBytesBarColor,"blue") == 0) {
163 color1 = gdImageColorAllocate(im, 62, 80, 167);
164 color2 = gdImageColorAllocate(im, 40, 51, 101);
165 color3 = gdImageColorAllocate(im, 57, 73, 150);
166 }
167 if(strcmp(GraphDaysBytesBarColor,"green") == 0) {
168 color1 = gdImageColorAllocate(im,120,166,129);
169 color2 = gdImageColorAllocate(im,84,113,82);
170 color3 = gdImageColorAllocate(im,158,223,167);
171 }
172 if(strcmp(GraphDaysBytesBarColor,"yellow") == 0) {
173 color1 = gdImageColorAllocate(im,185,185,10);
174 color2 = gdImageColorAllocate(im,111,111,10);
175 color3 = gdImageColorAllocate(im,166,166,10);
176 }
177 if(strcmp(GraphDaysBytesBarColor,"brown") == 0) {
178 color1 = gdImageColorAllocate(im,97,45,27);
179 color2 = gdImageColorAllocate(im,60,30,20);
180 color3 = gdImageColorAllocate(im,88,41,26);
181 }
182 if(strcmp(GraphDaysBytesBarColor,"red") == 0){
183 color1 = gdImageColorAllocate(im,185,10,10);
184 color2 = gdImageColorAllocate(im,111,10,10);
185 color3 = gdImageColorAllocate(im,166,10,10);
186 }
187
188 blue = gdImageColorAllocate(im, 0, 0, 255);
189 white = gdImageColorAllocate(im, 255, 255, 255);
1dd9dcec 190 dimgray = gdImageColorAllocate(im, 105, 105, 105);
25697a35
GS
191 goldenrod = gdImageColorAllocate(im, 234, 234, 174);
192 goldenrod2 = gdImageColorAllocate(im, 207, 181, 59);
193
194 num = n;
32e71fa4 195 val = 55;
25697a35 196 for(x=0; x<=366; x++) {
32e71fa4 197 if(limits[x] >= num) {
25697a35
GS
198 val = 425 - x;
199 break;
200 }
201 }
25697a35
GS
202
203 gdImageFilledRectangle(im, x1, val, x1+11, 425, color3);
204
205 points[0].x = x1+7;
206 points[0].y = val-5;
207 points[1].x = x1;
208 points[1].y = val;
209 points[2].x = x1+11;
210 points[2].y = val;
211 points[3].x = x1+17;
212 points[3].y = val-5;
213 gdImageFilledPolygon(im, points, 4, color1);
214
1dd9dcec 215 gdImageLine(im, x1+8, val-2, x1+8, val-10, dimgray);
25697a35
GS
216 gdImageFilledRectangle(im, x1-2, val-20, x1+18, val-10, goldenrod);
217 gdImageRectangle(im, x1-2, val-20, x1+18, val-10, goldenrod2);
218
219 snprintf(v,6,"%s",fixnum(num,0));
220
3becf85c 221 SARGgdImageStringFT(im,&brect[0],black,GraphFont,6,0.0,x1-1,val-12,v);
1dd9dcec 222
25697a35
GS
223 points[0].x = x1+17;
224 points[0].y = val-5;
225 points[1].x = x1+11;
226 points[1].y = val;
227 points[2].x = x1+11;
228 points[2].y = 426;
229 points[3].x = x1+17;
230 points[3].y = 420;
231 gdImageFilledPolygon(im, points, 4, color2);
232
25697a35
GS
233 return;
234}
a1de61fe 235#endif //HAVE_GD
25697a35 236
f2ec8c75 237void greport_day(const struct userinfostruct *uinfo)
25697a35 238{
17c89803 239#ifdef HAVE_GD
25697a35 240 FILE *fp_in, *pngout;
d6e703cc 241 int x, y;
c274f011 242 int x1;
25697a35
GS
243 int brect[8];
244 char wdirname[MAXLEN];
245 char graph[MAXLEN];
9c7c6346 246 char buf[MAXLEN];
25697a35
GS
247 char csort[255];
248 char data[20];
2240dcea
FM
249 char s[15];
250 char tmp5[MAXLEN];
25697a35 251 int count=0;
65740c50
FM
252 int oday=0;
253 int day=0;
254 long long int llday;
255 long long int bytes;
120d768c 256 char ftime[128];
32e71fa4 257 long long int tot=0;
25697a35
GS
258 time_t t;
259 struct tm *local;
456d78a5 260 int cstatus;
9c7c6346
FM
261 struct getwordstruct gwarea;
262 struct getwordstruct gwarea1;
c274f011 263
3becf85c 264 if(!Graphs || GraphFont[0]=='\0') {
25697a35
GS
265 unlink(wdirname);
266 return;
267 }
3becf85c 268 if(access(GraphFont, R_OK) != 0) {
9f70c14e 269 debuga(_("(grepday) Fontname %s not found\n"),GraphFont);
06b39c87 270 exit(EXIT_FAILURE);
3becf85c 271 }
25697a35
GS
272
273 im = gdImageCreate(720, 480);
274
1dd9dcec
FM
275 lavender = gdImageColorAllocate(im, 230, 230, 250);
276 white = gdImageColorAllocate(im, 255, 255, 255);
277 gray = gdImageColorAllocate(im, 192, 192, 192);
278 silver = gdImageColorAllocate(im, 211, 211, 211);
279 black = gdImageColorAllocate(im, 0, 0, 0);
280 blue = gdImageColorAllocate(im, 35, 35, 227);
281 dimgray = gdImageColorAllocate(im, 105, 105, 105);
25697a35
GS
282 darkblue = gdImageColorAllocate(im, 0, 0, 139);
283
284 gdImageRectangle(im, 0, 0, 719, 479, dimgray);
285 gdImageFilledRectangle(im, 60, 60, 700, 420, silver);
286
287 points[0].x = 50;
288 points[0].y = 65;
289 points[1].x = 50;
290 points[1].y = 425;
291 points[2].x = 60;
292 points[2].y = 420;
293 points[3].x = 60;
294 points[3].y = 60;
295 gdImageFilledPolygon(im, points, 4, gray);
296
297 points[0].x = 60;
298 points[0].y = 420;
299 points[1].x = 50;
300 points[1].y = 425;
301 points[2].x = 690;
302 points[2].y = 425;
303 points[3].x = 700;
304 points[3].y = 420;
305 gdImageFilledPolygon(im, points, 4, gray);
1dd9dcec
FM
306
307 gdImageLine(im, 50, 65, 50, 430, black);
308 gdImageLine(im, 45, 425, 690, 425, black);
309 gdImageLine(im, 50, 425, 60, 420, black);
310 gdImageLine(im, 60, 420, 60, 60, black);
311 gdImageLine(im, 700, 60, 700, 420, black);
312 gdImageLine(im, 690, 425, 700, 420, black);
25697a35
GS
313
314 for(x=415; x>=65; x=x-10) {
1dd9dcec
FM
315 gdImageLine(im, 50, x, 60, x-5, dimgray);
316 gdImageLine(im, 47, x, 50, x, dimgray);
25697a35
GS
317 }
318
319 for(x=60; x<=420; x=x+10)
1dd9dcec
FM
320 gdImageLine(im, 60, x, 700, x, dimgray);
321
322 gdImageLine(im, 60, 420, 700, 420, black);
25697a35
GS
323
324 for(x=70; x<=680; x=x+20)
1dd9dcec 325 gdImageLine(im, x, 425, x, 428, dimgray);
25697a35
GS
326
327 y=65;
328 for(x=1; x<=31; x++) {
329 sprintf(s,"%02d",x);
3becf85c 330 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,y,437,s);
25697a35
GS
331 y=y+20;
332 }
333
334 t = time(NULL);
335 local = localtime(&t);
336 if(strcmp(DateFormat,"u") == 0)
120d768c 337 strftime(ftime, sizeof(ftime), "%b/%d/%Y %H:%M", local);
25697a35 338 if(strcmp(DateFormat,"e") == 0)
120d768c 339 strftime(ftime, sizeof(ftime), "%d/%b/%Y-%H:%M", local);
25697a35 340
3becf85c
FM
341 SARGgdImageStringFT(im,&brect[0],darkblue,GraphFont,7,0.0,620,470,ftime);
342 if(ShowSargInfo) SARGgdImageStringFT(im,&brect[0],darkblue,GraphFont,10,0.0,257,15,"SARG, ");
343 SARGgdImageStringFT(im,&brect[0],darkblue,GraphFont,10,0.0,300,15,Title);
fa6552b0 344 sprintf(warea,_("Period: %s"),period.text);
3becf85c 345 SARGgdImageStringFT(im,&brect[0],darkblue,GraphFont,9,0.0,300,27,warea);
9f70c14e 346 sprintf(warea,_("User: %s"),uinfo->label);
3becf85c
FM
347 SARGgdImageStringFT(im,&brect[0],darkblue,GraphFont,9,0.0,300,38,warea);
348 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,418," 50K");
349 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,408,"250K");
350 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,398,"500K");
351 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,388," 1M");
352 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,378," 2M");
353 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,368," 3M");
354 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,358," 4M");
355 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,348," 5M");
356 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,338," 6M");
357 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,328," 7M");
358 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,318," 8M");
359 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,308," 9M");
360 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,298," 10M");
361 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,288," 15M");
362 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,278," 20M");
363 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,268," 30M");
364 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,258," 40M");
365 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,248," 50M");
366 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,238," 60M");
367 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,228," 70M");
368 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,218," 80M");
369 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,208," 90M");
370 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,198,"100M");
371 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,188,"200M");
372 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,178,"300M");
373 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,168,"400M");
374 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,158,"500M");
375 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,148,"600M");
376 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,138,"700M");
377 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,128,"800M");
378 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,118,"900M");
379 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,108," 1G");
380 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23, 98," 2G");
381 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23, 88," 3G");
382 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23, 78," 4G");
383 SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23, 68," 5G");
085af286 384 if(strcmp(datetimeby,"bytes") == 0)
c36c7384 385 SARGgdImageStringFT(im,&brect[0],black,GraphFont,10,3.14/2,20,248,_("BYTES"));
085af286 386 else
c36c7384
FM
387 SARGgdImageStringFT(im,&brect[0],black,GraphFont,10,3.14/2,20,248,_("ELAPSED TIME"));
388 SARGgdImageStringFT(im,&brect[0],black,GraphFont,10,0.0,330,460,_("DAYS"));
1dd9dcec 389
d5d021c5 390 if (snprintf(graph,sizeof(graph),"%s/%s/graph_day.png",outdirname,uinfo->filename)>=sizeof(graph)) {
9f70c14e 391 debuga(_("user name too long for %s/%s/graph_day.png\n"),outdirname,uinfo->filename);
06b39c87 392 exit(EXIT_FAILURE);
32e71fa4 393 }
f2ec8c75 394 if (snprintf(wdirname,sizeof(wdirname),"%s/%s.day",tmp,uinfo->filename)>=sizeof(wdirname)) {
9f70c14e 395 debuga(_("user name too long for %s/%s.day\n"),tmp,uinfo->filename);
06b39c87 396 exit(EXIT_FAILURE);
32e71fa4 397 }
f2ec8c75 398 if (snprintf(tmp5,sizeof(tmp5),"%s/%s.graph",tmp,uinfo->filename)>=sizeof(tmp5)) {
9f70c14e 399 debuga(_("user name too long for %s/%s.graph\n"),tmp,uinfo->filename);
06b39c87 400 exit(EXIT_FAILURE);
32e71fa4 401 }
25697a35 402
05b90947
FM
403 if(access(wdirname, R_OK) != 0) {
404 gdImageDestroy(im);
25697a35 405 return;
05b90947 406 }
25697a35 407
25697a35 408 if(strcmp(DateFormat,"e") == 0)
9a2efbd0 409 sprintf(csort,"sort -t\"/\" -k 1,1 -o \"%s\" \"%s\"",tmp5,wdirname);
120d768c
FM
410 else
411 sprintf(csort,"sort -t\"/\" -k 2,2 -o \"%s\" \"%s\"",tmp5,wdirname);
25697a35 412
456d78a5
FM
413 cstatus=system(csort);
414 if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
10210234
FM
415 debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
416 debuga(_("sort command: %s\n"),csort);
06b39c87 417 exit(EXIT_FAILURE);
456d78a5 418 }
25697a35
GS
419
420 if((fp_in=fopen(tmp5,"r"))==NULL) {
9f70c14e 421 debuga(_("(grepday) Cannot open log file %s\n"),tmp5);
06b39c87 422 exit(EXIT_FAILURE);
25697a35
GS
423 }
424
425 if((pngout=fopen(graph,"wb"))==NULL) {
9f70c14e 426 debuga(_("(grepday) Cannot open log file %s\n"),graph);
06b39c87 427 exit(EXIT_FAILURE);
25697a35
GS
428 }
429
25697a35 430 while(fgets(buf,sizeof(buf),fp_in)!=NULL) {
9c7c6346
FM
431 fixendofline(buf);
432 getword_start(&gwarea,buf);
433 if (getword(data,sizeof(data),&gwarea,'\t')<0) {
9f70c14e 434 debuga(_("Maybe you have a broken record or garbage in your %s file\n"),tmp5);
06b39c87 435 exit(EXIT_FAILURE);
9c7c6346
FM
436 }
437 getword_start(&gwarea1,data);
65740c50 438 if (getword_atoll(&llday,&gwarea1,'/')<0) {
9f70c14e 439 debuga(_("Maybe you have a broken record or garbage in your %s file\n"),tmp5);
06b39c87 440 exit(EXIT_FAILURE);
4bcb77cf
FM
441 }
442 if(strcmp(DateFormat,"u") == 0) {
65740c50 443 if (getword_atoll(&llday,&gwarea1,'/')<0) {
9f70c14e 444 debuga(_("Maybe you have a broken record or garbage in your %s file\n"),tmp5);
06b39c87 445 exit(EXIT_FAILURE);
4bcb77cf
FM
446 }
447 }
65740c50 448 day=(int)llday;
25697a35 449 if(!count) {
65740c50 450 oday=day;
25697a35
GS
451 count++;
452 }
65740c50 453 if (getword_skip(20,&gwarea,'\t')<0 || getword_atoll(&bytes,&gwarea,'\t')<0) {
9f70c14e 454 debuga(_("Maybe you have a broken record or garbage in your %s file\n"),tmp5);
06b39c87 455 exit(EXIT_FAILURE);
4bcb77cf 456 }
25697a35 457
65740c50
FM
458 if(oday!=day) {
459 x1 = 44 +(oday * 20);
c274f011 460 bar(x1,tot);
65740c50 461 oday=day;
25697a35 462 tot=0;
d6e703cc 463 }
65740c50 464 tot+=bytes;
25697a35
GS
465 }
466
467 if(tot) {
65740c50 468 x1 = 44 +(day * 20);
c274f011 469 bar(x1,tot);
25697a35
GS
470 }
471
472 gdImagePng(im, pngout);
473 fclose(pngout);
474 gdImageDestroy(im);
475
476 fclose(fp_in);
477 unlink(wdirname);
478 unlink(tmp5);
1dd9dcec 479
a1de61fe 480#endif //HAVE_GD
d6e703cc 481
25697a35
GS
482 return;
483}
c274f011
FM
484
485void greport_cleanup(void)
486{
487#ifdef HAVE_GD
488 gdFontCacheShutdown();
489#endif
490}