]>
git.ipfire.org Git - thirdparty/sarg.git/blob - lastlog.c
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"
33 struct dirent
*direntp
;
42 if(strcmp(LastLog
,"0") == 0)
45 sprintf(temp
,"%slastlog1",outdir
);
46 if((fp_ou
=fopen(temp
,"w"))==NULL
) {
47 fprintf(stderr
, "SARG: (lastlog) %s: %s\n",text
[9],temp
);
51 dirp
= opendir(outdir
);
52 while ((direntp
= readdir( dirp
)) != NULL
){
53 if(strstr(direntp
->d_name
,"-") == 0)
56 sprintf(warea
,"%s%s",outdir
,direntp
->d_name
);
59 local
= localtime(&t
);
60 strftime(ftime
, 127, "%Y%m%d%H%M%S", local
);
61 sprintf(buf
,"%s %s\n",ftime
,direntp
->d_name
);
62 printf("BUF=%s\n",buf
);
68 (void)rewinddir( dirp
);
69 (void)closedir( dirp
);
72 sprintf(buf
,"sort -n -k 1,1 -o '%slastlog' '%s'",outdir
,temp
);
77 if(ftot
<=atoi(LastLog
)) {
78 sprintf(temp
,"%slastlog",outdir
);
79 if(access(temp
, R_OK
) == 0)
86 sprintf(temp
,"%slastlog",outdir
);
87 if((fp_in
=fopen(temp
,"r"))==NULL
) {
88 fprintf(stderr
, "SARG: (lastlog) %s: %s\n",text
[9],temp
);
92 while(fgets(buf
,sizeof(buf
),fp_in
)!=NULL
) {
93 getword(warea
,buf
,' ');
94 buf
[strlen(buf
)-1]='\0';
98 sprintf(msg
,"%s: %s",text
[81],buf
);
101 // sprintf(temp,"%s%s",outdir,buf);
102 sprintf(temp
,"rm -r %s%s",outdir
,buf
);
110 sprintf(temp
,"%slastlog",outdir
);