summaryrefslogtreecommitdiffstats
path: root/util/expire.c
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-03-26 13:58:58 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-03-26 13:58:58 +0800
commit1b888ad8dc09568946c10de09d69e1fe8621ce70 (patch)
tree9fde09d7e1ef3ae4b77f58a3b8e30eb23efb9f47 /util/expire.c
parent450a015e89ee02a4bc9564da1e33592e350a0e91 (diff)
downloadpttbbs-1b888ad8dc09568946c10de09d69e1fe8621ce70.tar
pttbbs-1b888ad8dc09568946c10de09d69e1fe8621ce70.tar.gz
pttbbs-1b888ad8dc09568946c10de09d69e1fe8621ce70.tar.bz2
pttbbs-1b888ad8dc09568946c10de09d69e1fe8621ce70.tar.lz
pttbbs-1b888ad8dc09568946c10de09d69e1fe8621ce70.tar.xz
pttbbs-1b888ad8dc09568946c10de09d69e1fe8621ce70.tar.zst
pttbbs-1b888ad8dc09568946c10de09d69e1fe8621ce70.zip
support X* for cleaning boards which brdnames start with 'X'
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1609 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util/expire.c')
-rw-r--r--util/expire.c45
1 files changed, 28 insertions, 17 deletions
diff --git a/util/expire.c b/util/expire.c
index ed02d013..293cb459 100644
--- a/util/expire.c
+++ b/util/expire.c
@@ -151,12 +151,28 @@ void toexpire(char *brdname)
}
}
+void visitdir(char c)
+{
+ DIR *dirp;
+ struct dirent *de;
+
+ sprintf(bpath, BBSHOME "/boards/%c", c);
+ if (!(dirp = opendir(bpath))){
+ printf(":Err: unable to open %s\n", bpath);
+ return;
+ }
+
+ while( (de = readdir(dirp)) != NULL )
+ if( de->d_name[0] != '.' )
+ toexpire(de->d_name);
+
+ closedir(dirp);
+}
+
int main(int argc, char **argv)
{
FILE *fin;
int number, i, ch;
- struct dirent *de;
- DIR *dirp;
char *ptr, *bname, buf[256];
char dirs[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p',
@@ -245,23 +261,18 @@ int main(int argc, char **argv)
attach_SHM();
if( argc > 0 ){
- for( i = 0 ; i < argc ; ++i ){
- sprintf(bpath, BBSHOME "/boards/%c", argv[i][0]);
- toexpire(argv[i]);
- }
+ for( i = 0 ; i < argc ; ++i )
+ if( argv[i][1] == '*' )
+ visitdir(argv[i][0]);
+ else{
+ sprintf(bpath, BBSHOME "/boards/%c", argv[i][0]);
+ toexpire(argv[i]);
+ }
}
else{ // visit all boards
- for( i = 0 ; dirs[i] != NULL ; ++i ){
- sprintf(bpath, BBSHOME "/boards/%c", dirs[i]);
- if (!(dirp = opendir(bpath))){
- printf(":Err: unable to open %s\n", bpath);
- continue;
- }
- while( (de = readdir(dirp)) != NULL )
- toexpire(de->d_name);
-
- closedir(dirp);
- }
+ for( i = 0 ; dirs[i] != NULL ; ++i )
+ visitdir(dirs[i]);
}
+
return 0;
}