[go: up one dir, main page]

Menu

[08f0a0]: / indexonly.c  Maximize  Restore  History

Download this file

58 lines (50 with data), 2.0 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* SARG Squid Analysis Report Generator http://sarg.sourceforge.net
* 1998, 2010
*
* SARG donations:
* please look at http://sarg.sourceforge.net/donations.php
* Support:
* http://sourceforge.net/projects/sarg/forums/forum/363374
* ---------------------------------------------------------------------
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
*
*/
#include "include/conf.h"
#include "include/defs.h"
void index_only(const char *dirname,int debug)
{
DIR *dirp;
struct dirent *direntp;
char remove[MAXLEN];
if ((dirp = opendir(dirname)) == NULL) {
debuga(_("Failed to open directory %s - %s\n"),dirname,strerror(errno));
exit(EXIT_FAILURE);
}
while ( (direntp = readdir( dirp )) != NULL ){
if(strcmp(direntp->d_name,".") == 0 || strcmp(direntp->d_name,"..") == 0 || strcmp(direntp->d_name, "index.html") == 0)
continue;
if (snprintf(remove,sizeof(remove),"%s/%s",dirname,direntp->d_name)>=sizeof(remove)) {
debuga(_("Name of the file to remove is too long: %s/%s\n"),dirname,direntp->d_name);
continue;
}
if (unlink(remove) == -1) {
debuga(_("Failed to remove the file %s\n"),remove);
}
}
(void)closedir( dirp );
return;
}