Added mbfile rearc
This commit is contained in:
parent
ea5a8aa2a9
commit
79c89010d0
@ -38,6 +38,11 @@ v0.51.2 06-Mar-2004
|
|||||||
Updated kill, index, check, pack, list, adopt, import, move,
|
Updated kill, index, check, pack, list, adopt, import, move,
|
||||||
delete and sort to the new files database structure.
|
delete and sort to the new files database structure.
|
||||||
The file delete function in kill didn't delete the thumbnail.
|
The file delete function in kill didn't delete the thumbnail.
|
||||||
|
The mbfile del and undel commands accept wildcards in the
|
||||||
|
filename.
|
||||||
|
Fixed an error in check when a mangled 8.3 filename was changed
|
||||||
|
and the symbolic link was not adjusted.
|
||||||
|
Added rearc command.
|
||||||
|
|
||||||
mbaff:
|
mbaff:
|
||||||
When scanning for uploads, files which were hatched now have
|
When scanning for uploads, files which were hatched now have
|
||||||
|
7
TODO
7
TODO
@ -139,10 +139,13 @@ mbfile:
|
|||||||
|
|
||||||
L: Update <filespec> <area> <-touch>
|
L: Update <filespec> <area> <-touch>
|
||||||
|
|
||||||
L: Rearc <area>
|
|
||||||
|
|
||||||
L: Possibility to skip file areas from checking and reindexing.
|
L: Possibility to skip file areas from checking and reindexing.
|
||||||
|
|
||||||
|
N: The import function does not create long filenames.
|
||||||
|
|
||||||
|
N: The import function doesn't strip the [0] from the files.bbs
|
||||||
|
when importing the description.
|
||||||
|
|
||||||
mbmsg:
|
mbmsg:
|
||||||
N: With the post command if a netmail area is used the netmail area
|
N: With the post command if a netmail area is used the netmail area
|
||||||
will cause trouble later, should be blocked to be used on netmail
|
will cause trouble later, should be blocked to be used on netmail
|
||||||
|
10
lib/Makefile
10
lib/Makefile
@ -5,15 +5,15 @@
|
|||||||
include ../Makefile.global
|
include ../Makefile.global
|
||||||
|
|
||||||
|
|
||||||
COMMON_SRCS = clcomm.c client.c crc.c semafore.c signame.c charset.c \
|
COMMON_SRCS = clcomm.c client.c crc.c semafore.c signame.c charset.c remask.c \
|
||||||
attach.c falists.c hdr.c parsedate.c rfcmsg.c unpacker.c \
|
attach.c falists.c hdr.c parsedate.c rfcmsg.c unpacker.c rearc.c \
|
||||||
batchrd.c ftn.c pktname.c mangle.c sectest.c proglock.c \
|
batchrd.c ftn.c pktname.c mangle.c sectest.c proglock.c \
|
||||||
dostran.c ftnmsg.c mbfile.c nodelock.c rawio.c strcasestr.c \
|
dostran.c ftnmsg.c mbfile.c nodelock.c rawio.c strcasestr.c \
|
||||||
execute.c expipe.c getheader.c noderecord.c rfcaddr.c strutil.c \
|
execute.c expipe.c getheader.c noderecord.c rfcaddr.c strutil.c \
|
||||||
faddr.c gmtoffset.c packet.c rfcdate.c term.c endian.c timers.c
|
faddr.c gmtoffset.c packet.c rfcdate.c term.c endian.c timers.c
|
||||||
COMMON_OBJS = clcomm.o client.o crc.o semafore.o signame.o charset.o \
|
COMMON_OBJS = clcomm.o client.o crc.o semafore.o signame.o charset.o remask.o \
|
||||||
ftscprod.o attach.o falists.o hdr.o parsedate.o rfcmsg.o unpacker.o \
|
ftscprod.o attach.o falists.o hdr.o parsedate.o rfcmsg.o unpacker.o \
|
||||||
batchrd.o ftn.o pktname.o mangle.o sectest.o proglock.o \
|
batchrd.o ftn.o pktname.o mangle.o sectest.o proglock.o rearc.o \
|
||||||
dostran.o ftnmsg.o mbfile.o nodelock.o rawio.o strcasestr.o \
|
dostran.o ftnmsg.o mbfile.o nodelock.o rawio.o strcasestr.o \
|
||||||
execute.o expipe.o getheader.o noderecord.o rfcaddr.o strutil.o \
|
execute.o expipe.o getheader.o noderecord.o rfcaddr.o strutil.o \
|
||||||
faddr.o gmtoffset.o packet.o rfcdate.o term.o endian.o timers.o
|
faddr.o gmtoffset.o packet.o rfcdate.o term.o endian.o timers.o
|
||||||
@ -132,12 +132,14 @@ crc.o: ../config.h mbselib.h
|
|||||||
semafore.o: ../config.h mbselib.h
|
semafore.o: ../config.h mbselib.h
|
||||||
signame.o: ../config.h mbselib.h
|
signame.o: ../config.h mbselib.h
|
||||||
charset.o: ../config.h mbselib.h
|
charset.o: ../config.h mbselib.h
|
||||||
|
remask.o: ../config.h mbselib.h
|
||||||
attach.o: ../config.h mbselib.h
|
attach.o: ../config.h mbselib.h
|
||||||
falists.o: ../config.h mbselib.h
|
falists.o: ../config.h mbselib.h
|
||||||
hdr.o: ../config.h mbselib.h
|
hdr.o: ../config.h mbselib.h
|
||||||
parsedate.o: ../config.h mbselib.h
|
parsedate.o: ../config.h mbselib.h
|
||||||
rfcmsg.o: ../config.h mbselib.h
|
rfcmsg.o: ../config.h mbselib.h
|
||||||
unpacker.o: ../config.h mbselib.h
|
unpacker.o: ../config.h mbselib.h
|
||||||
|
rearc.o: ../config.h mbselib.h
|
||||||
batchrd.o: ../config.h mbselib.h
|
batchrd.o: ../config.h mbselib.h
|
||||||
ftn.o: ../config.h mbselib.h users.h mbsedb.h
|
ftn.o: ../config.h mbselib.h users.h mbsedb.h
|
||||||
pktname.o: ../config.h mbselib.h
|
pktname.o: ../config.h mbselib.h
|
||||||
|
@ -2434,6 +2434,12 @@ int gpt_running(int); /* Is timer running */
|
|||||||
int msleep(int); /* Milliseconds timer */
|
int msleep(int); /* Milliseconds timer */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* remask.c
|
||||||
|
*/
|
||||||
|
char *re_mask(char *, int); /* Bluid file mask */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
*
|
*
|
||||||
@ -2475,8 +2481,14 @@ char *charset_alias_rfc(char *); /* Search RFC alias */
|
|||||||
int charset_set_in_out(char *, char *); /* Setup mapping */
|
int charset_set_in_out(char *, char *); /* Setup mapping */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* rearc.c
|
||||||
|
*/
|
||||||
|
int rearc(char *, char *, int); /* Rearc command */
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
*
|
*
|
||||||
* Records data
|
* Records data
|
||||||
*/
|
*/
|
||||||
@ -2551,8 +2563,6 @@ struct _magic magic;
|
|||||||
struct _nodeshdr nodeshdr; /* Fidonet nodes */
|
struct _nodeshdr nodeshdr; /* Fidonet nodes */
|
||||||
struct _nodes nodes;
|
struct _nodes nodes;
|
||||||
|
|
||||||
//struct _bill bill; /* Unsent bills */
|
|
||||||
|
|
||||||
struct _newfileshdr newfileshdr; /* New file reports */
|
struct _newfileshdr newfileshdr; /* New file reports */
|
||||||
struct _newfiles newfiles;
|
struct _newfiles newfiles;
|
||||||
|
|
||||||
|
210
lib/rearc.c
Normal file
210
lib/rearc.c
Normal file
@ -0,0 +1,210 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
* Purpose ...............: ReArc an archive.
|
||||||
|
*
|
||||||
|
*****************************************************************************
|
||||||
|
* Copyright (C) 1997-2004
|
||||||
|
*
|
||||||
|
* Michiel Broek FIDO: 2:280/2802
|
||||||
|
* Beekmansbos 10
|
||||||
|
* 1971 BV IJmuiden
|
||||||
|
* the Netherlands
|
||||||
|
*
|
||||||
|
* This file is part of MBSE BBS.
|
||||||
|
*
|
||||||
|
* This BBS 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, or (at your option) any
|
||||||
|
* later version.
|
||||||
|
*
|
||||||
|
* MBSE BBS 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 MBSE BBS; see the file COPYING. If not, write to the Free
|
||||||
|
* Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include "../config.h"
|
||||||
|
#include "mbselib.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Rearchive an archive, if successfull the filename is updated.
|
||||||
|
* If it fails, return -1.
|
||||||
|
*/
|
||||||
|
int rearc(char *filename, char *arctype, int do_quiet)
|
||||||
|
{
|
||||||
|
char *p, *uncmd = NULL, *arccmd = NULL, *unarc, *newname, *workpath, *oldpath, *temp;
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
|
Syslog('f', "rearc(%s, %s)", filename, arctype);
|
||||||
|
|
||||||
|
if (!do_quiet) {
|
||||||
|
colour(12, 0);
|
||||||
|
printf(" ReArc file %s", filename);
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strchr(filename, '/') == NULL) {
|
||||||
|
if (!do_quiet) {
|
||||||
|
colour(LIGHTRED, BLACK);
|
||||||
|
printf(" no path in filename\n");
|
||||||
|
}
|
||||||
|
Syslog('+', "rearc(%s, %s), no path in filename", filename, arctype);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((unarc = unpacker(filename)) == NULL) {
|
||||||
|
if (!do_quiet) {
|
||||||
|
colour(LIGHTRED, BLACK);
|
||||||
|
printf(" unknown archive type\n");
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!getarchiver(unarc)) {
|
||||||
|
if (!do_quiet) {
|
||||||
|
colour(LIGHTRED, BLACK);
|
||||||
|
printf(" no unarchiver available\n");
|
||||||
|
}
|
||||||
|
Syslog('+', "rearc(%s, %s), no unarchiver available", filename, arctype);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uncmd = xstrcpy(archiver.funarc);
|
||||||
|
if ((uncmd == NULL) || (uncmd == "")) {
|
||||||
|
if (!do_quiet) {
|
||||||
|
colour(LIGHTRED, BLACK);
|
||||||
|
printf(" no unarchive command available\n");
|
||||||
|
}
|
||||||
|
Syslog('+', "rearc(%s, %s), no unarchive command available", filename, arctype);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
newname = calloc(PATH_MAX, sizeof(char));
|
||||||
|
strcpy(newname, filename);
|
||||||
|
p = strrchr(newname, '.');
|
||||||
|
*p++;
|
||||||
|
*p = '\0';
|
||||||
|
|
||||||
|
if (!getarchiver(arctype)) {
|
||||||
|
if (!do_quiet) {
|
||||||
|
colour(LIGHTRED, BLACK);
|
||||||
|
printf(" no archiver available\n");
|
||||||
|
}
|
||||||
|
Syslog('+', "rearc(%s, %s), no archiver available", filename, arctype);
|
||||||
|
free(uncmd);
|
||||||
|
free(newname);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(unarc, archiver.name) == 0) {
|
||||||
|
if (!do_quiet) {
|
||||||
|
colour(LIGHTRED, BLACK);
|
||||||
|
printf(" already in %s format\n", arctype);
|
||||||
|
}
|
||||||
|
Syslog('+', "rearc(%s, %s), already in %s format", filename, arctype, arctype);
|
||||||
|
free(uncmd);
|
||||||
|
free(newname);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(p, "%s", archiver.name);
|
||||||
|
Syslog('f', "new filename %s", newname);
|
||||||
|
|
||||||
|
arccmd = xstrcpy(archiver.farc);
|
||||||
|
if ((arccmd == NULL) || (arccmd == "")) {
|
||||||
|
if (!do_quiet) {
|
||||||
|
colour(LIGHTRED, BLACK);
|
||||||
|
printf(" no archive command available\n");
|
||||||
|
}
|
||||||
|
Syslog('+', "rearc(%s, %s), no archive command available", filename, arctype);
|
||||||
|
free(uncmd);
|
||||||
|
free(newname);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* unarchive and archive commands are available, create a temp directory to work in.
|
||||||
|
*/
|
||||||
|
workpath = calloc(PATH_MAX, sizeof(char));
|
||||||
|
oldpath = calloc(PATH_MAX, sizeof(char));
|
||||||
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
|
getcwd(oldpath, PATH_MAX);
|
||||||
|
sprintf(workpath, "%s/tmp/rearc%d", getenv("MBSE_ROOT"), getpid());
|
||||||
|
sprintf(temp, "%s/%s", workpath, filename);
|
||||||
|
rc = mkdirs(temp, 0755) ? 0 : -1;
|
||||||
|
if (rc == 0) {
|
||||||
|
if ((rc = chdir(workpath)) == -1) {
|
||||||
|
WriteError("$Can't chdir to %s", workpath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!do_quiet) {
|
||||||
|
colour(11, 0);
|
||||||
|
printf("\rUnpacking file %s", filename);
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Unarchive
|
||||||
|
*/
|
||||||
|
if (rc == 0) {
|
||||||
|
if ((rc = execute_str(uncmd,filename,(char *)NULL,(char*)"/dev/null",(char*)"/dev/null",(char*)"/dev/null"))) {
|
||||||
|
sync();
|
||||||
|
sleep(1);
|
||||||
|
WriteError("Warning: unpack %s failed, trying again after sync()", filename);
|
||||||
|
if ((rc = execute_str(uncmd,filename,(char *)NULL,(char*)"/dev/null",(char*)"/dev/null",(char*)"/dev/null"))) {
|
||||||
|
WriteError("$Can't unpack %s", filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!do_quiet) {
|
||||||
|
colour(10, 0);
|
||||||
|
printf("\r Packing file %s", filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Archive
|
||||||
|
*/
|
||||||
|
if (rc == 0) {
|
||||||
|
if ((rc = execute_str(arccmd,newname,(char *)".",(char*)"/dev/null",(char*)"/dev/null",(char*)"/dev/null"))) {
|
||||||
|
sync();
|
||||||
|
sleep(1);
|
||||||
|
WriteError("Warning: pack %s failed, trying again after sync()", newname);
|
||||||
|
if ((rc = execute_str(arccmd,newname,(char *)".",(char*)"/dev/null",(char*)"/dev/null",(char*)"/dev/null"))) {
|
||||||
|
WriteError("$Can't pack %s", newname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rc == 0)
|
||||||
|
unlink(filename);
|
||||||
|
|
||||||
|
if ((rc = chdir(oldpath)) == -1) {
|
||||||
|
WriteError("$Can't chdir to %s", oldpath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Clean and remove workdir
|
||||||
|
*/
|
||||||
|
sprintf(temp, "-rf %s", workpath);
|
||||||
|
execute_pth((char *)"rm", temp, (char*)"/dev/null", (char*)"/dev/null", (char*)"/dev/null");
|
||||||
|
if (rc == 0)
|
||||||
|
sprintf(filename, "%s", newname);
|
||||||
|
|
||||||
|
free(workpath);
|
||||||
|
free(oldpath);
|
||||||
|
free(temp);
|
||||||
|
free(uncmd);
|
||||||
|
free(arccmd);
|
||||||
|
free(newname);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
85
lib/remask.c
Normal file
85
lib/remask.c
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
* Purpose ...............: Regular Expression Mask
|
||||||
|
*
|
||||||
|
*****************************************************************************
|
||||||
|
* Copyright (C) 1997-2004
|
||||||
|
*
|
||||||
|
* Michiel Broek FIDO: 2:280/2802
|
||||||
|
* Beekmansbos 10
|
||||||
|
* 1971 BV IJmuiden
|
||||||
|
* the Netherlands
|
||||||
|
*
|
||||||
|
* This file is part of MBSE BBS.
|
||||||
|
*
|
||||||
|
* This BBS 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, or (at your option) any
|
||||||
|
* later version.
|
||||||
|
*
|
||||||
|
* MBSE BBS 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 MBSE BBS; see the file COPYING. If not, write to the Free
|
||||||
|
* Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include "../config.h"
|
||||||
|
#include "mbselib.h"
|
||||||
|
|
||||||
|
|
||||||
|
char *re_mask(char *nm, int forceupper)
|
||||||
|
{
|
||||||
|
char *p, *q;
|
||||||
|
static char mask[256];
|
||||||
|
|
||||||
|
memset(&mask, 0, sizeof(mask));
|
||||||
|
if (forceupper)
|
||||||
|
p = tl(nm);
|
||||||
|
else
|
||||||
|
p = nm;
|
||||||
|
q = mask;
|
||||||
|
*q++ = '^';
|
||||||
|
while ((*p) && (q < (mask + sizeof(mask) - 4))) {
|
||||||
|
switch (*p) {
|
||||||
|
case '\\': *q++ = '\\';
|
||||||
|
*q++ = '\\';
|
||||||
|
break;
|
||||||
|
case '?': *q++ = '.';
|
||||||
|
break;
|
||||||
|
case '.': *q++ = '\\';
|
||||||
|
*q++ = '.';
|
||||||
|
break;
|
||||||
|
case '+': *q++ = '\\';
|
||||||
|
*q++ = '+';
|
||||||
|
break;
|
||||||
|
case '*': *q++ = '.';
|
||||||
|
*q++ = '*';
|
||||||
|
break;
|
||||||
|
case '@': sprintf(q, "[A-Za-z]");
|
||||||
|
while (*q)
|
||||||
|
q++;
|
||||||
|
break;
|
||||||
|
case '#': sprintf(q, "[0-9]");
|
||||||
|
while (*q)
|
||||||
|
q++;
|
||||||
|
break;
|
||||||
|
default: if (forceupper)
|
||||||
|
*q++ = toupper(*p);
|
||||||
|
else
|
||||||
|
*q++ = *p;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
*q++ = '$';
|
||||||
|
*q++ = '\0';
|
||||||
|
Syslog('f', "Search mask \"%s\" => \"%s\"", nm, mask);
|
||||||
|
return mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -153,7 +153,7 @@ file_list *respfreq(char *nm, char *pw, char *dt)
|
|||||||
{
|
{
|
||||||
file_list *fl = NULL;
|
file_list *fl = NULL;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
char mask[256], *p, *q, *tnm, *t;
|
char mask[256], *p, *tnm, *t;
|
||||||
time_t upd = 0L;
|
time_t upd = 0L;
|
||||||
int newer = 1, Send;
|
int newer = 1, Send;
|
||||||
FILE *fa, *fb, *fi;
|
FILE *fa, *fb, *fi;
|
||||||
@ -222,23 +222,7 @@ file_list *respfreq(char *nm, char *pw, char *dt)
|
|||||||
|
|
||||||
Syslog('+', "File request : %s (update (%s), password \"%s\")",MBSE_SS(nm),MBSE_SS(dt),MBSE_SS(pw));
|
Syslog('+', "File request : %s (update (%s), password \"%s\")",MBSE_SS(nm),MBSE_SS(dt),MBSE_SS(pw));
|
||||||
add_report((char *)"RQ: Regular file \"%s\"",nm);
|
add_report((char *)"RQ: Regular file \"%s\"",nm);
|
||||||
p = tl(nm);
|
strcpy(mask, re_mask(nm, TRUE));
|
||||||
q = mask;
|
|
||||||
*q++ = '^';
|
|
||||||
while ((*p) && (q < (mask + sizeof(mask) - 4))) {
|
|
||||||
switch (*p) {
|
|
||||||
case '\\': *q++ = '\\'; *q++ = '\\'; break;
|
|
||||||
case '?': *q++ = '.'; break;
|
|
||||||
case '.': *q++ = '\\'; *q++ = '.'; break;
|
|
||||||
case '+': *q++ = '\\'; *q++ = '+'; break;
|
|
||||||
case '*': *q++ = '.'; *q++ = '*'; break;
|
|
||||||
default: *q++ = toupper(*p); break;
|
|
||||||
}
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
*q++ = '$';
|
|
||||||
*q = '\0';
|
|
||||||
Syslog('f', "Search mask \"%s\"", mask);
|
|
||||||
re_comp(mask);
|
re_comp(mask);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -21,7 +21,7 @@ HDRS = addbbs.h backalias.h flock.h hatch.h mbdiff.h mgrutil.h qualify.h \
|
|||||||
aliasdb.h fsort.h magic.h mbfile.h mover.h ping.h rfc2ftn.h \
|
aliasdb.h fsort.h magic.h mbfile.h mover.h ping.h rfc2ftn.h \
|
||||||
storeecho.h unpack.h announce.h fflist.h ftn2rfc.h makestat.h mbindex.h \
|
storeecho.h unpack.h announce.h fflist.h ftn2rfc.h makestat.h mbindex.h \
|
||||||
msgutil.h post.h rnews.h storenet.h utic.h areamgr.h filefind.h \
|
msgutil.h post.h rnews.h storenet.h utic.h areamgr.h filefind.h \
|
||||||
grlist.h maketags.h mbmsg.h newspost.h postecho.h rollover.h tic.h \
|
grlist.h maketags.h mbmsg.h newspost.h postecho.h rollover.h tic.h mbfrearc.h \
|
||||||
atoul.h filemgr.h hash.h mbaff.h mbseq.h notify.h postemail.h scan.h toberep.h \
|
atoul.h filemgr.h hash.h mbaff.h mbseq.h notify.h postemail.h scan.h toberep.h \
|
||||||
mbfkill.h mbfutil.h mbfindex.h mbfcheck.h mbfpack.h mbflist.h mbfadopt.h \
|
mbfkill.h mbfutil.h mbfindex.h mbfcheck.h mbfpack.h mbflist.h mbfadopt.h \
|
||||||
mbfimport.h mbfsort.h virscan.h mbftoberep.h mbfmove.h mbfdel.h bounce.h \
|
mbfimport.h mbfsort.h virscan.h mbftoberep.h mbfmove.h mbfdel.h bounce.h \
|
||||||
@ -39,7 +39,7 @@ MBAFF_OBJS = announce.o fflist.o filefind.o grlist.o mbaff.o msgutil.o toberep.o
|
|||||||
MBINDEX_OBJS = mbindex.o
|
MBINDEX_OBJS = mbindex.o
|
||||||
MBDIFF_OBJS = mbdiff.o
|
MBDIFF_OBJS = mbdiff.o
|
||||||
MBFILE_OBJS = mbfile.o mbfkill.o mbfutil.o mbfindex.o mbfcheck.o mbfpack.o mbflist.o mbfadopt.o \
|
MBFILE_OBJS = mbfile.o mbfkill.o mbfutil.o mbfindex.o mbfcheck.o mbfpack.o mbflist.o mbfadopt.o \
|
||||||
mbfimport.o virscan.o mbftoberep.o mbfmove.o mbfdel.o mbfsort.o
|
mbfimport.o virscan.o mbftoberep.o mbfmove.o mbfdel.o mbfsort.o mbfrearc.o
|
||||||
MBMSG_OBJS = post.o mbmsg.o
|
MBMSG_OBJS = post.o mbmsg.o
|
||||||
MBFIDO_LIBS = ../lib/libmbse.a ../lib/libmsgbase.a ../lib/libdbase.a ../lib/libdiesel.a ../lib/libmbinet.a ../lib/libnodelist.a
|
MBFIDO_LIBS = ../lib/libmbse.a ../lib/libmsgbase.a ../lib/libdbase.a ../lib/libdiesel.a ../lib/libmbinet.a ../lib/libnodelist.a
|
||||||
MBSEQ_LIBS = ../lib/libmbse.a ../lib/libdbase.a
|
MBSEQ_LIBS = ../lib/libmbse.a ../lib/libdbase.a
|
||||||
@ -147,7 +147,7 @@ unpack.o: ../config.h ../lib/mbselib.h flock.h unpack.h
|
|||||||
aliasdb.o: ../config.h ../lib/mbselib.h aliasdb.h
|
aliasdb.o: ../config.h ../lib/mbselib.h aliasdb.h
|
||||||
fsort.o: ../config.h ../lib/mbselib.h fsort.h
|
fsort.o: ../config.h ../lib/mbselib.h fsort.h
|
||||||
magic.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h tic.h utic.h magic.h
|
magic.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h tic.h utic.h magic.h
|
||||||
mbfile.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h mbfkill.h mbfadopt.h mbfindex.h mbfcheck.h mbfpack.h mbflist.h mbfimport.h mbftoberep.h mbfmove.h mbfdel.h mbfutil.h mbfsort.h mbfile.h
|
mbfile.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h mbfkill.h mbfadopt.h mbfindex.h mbfcheck.h mbfpack.h mbflist.h mbfimport.h mbftoberep.h mbfmove.h mbfdel.h mbfutil.h mbfsort.h mbfile.h mbfrearc.h
|
||||||
mover.o: ../config.h ../lib/mbselib.h tic.h mover.h
|
mover.o: ../config.h ../lib/mbselib.h tic.h mover.h
|
||||||
post.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h ../lib/msg.h ../lib/msgtext.h post.h
|
post.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h ../lib/msg.h ../lib/msgtext.h post.h
|
||||||
rnews.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbinet.h ../lib/mbsedb.h ../lib/msg.h ../lib/msgtext.h rfc2ftn.h mbfido.h ../paths.h rnews.h
|
rnews.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbinet.h ../lib/mbsedb.h ../lib/msg.h ../lib/msgtext.h rfc2ftn.h mbfido.h ../paths.h rnews.h
|
||||||
|
@ -104,7 +104,7 @@ int CheckHatch(char *temp)
|
|||||||
struct dirent *de;
|
struct dirent *de;
|
||||||
char *fn, *tf, tmp[4], *temp2;
|
char *fn, *tf, tmp[4], *temp2;
|
||||||
int i, hatched = FALSE;
|
int i, hatched = FALSE;
|
||||||
char *p, *q, mask[256];
|
char mask[256];
|
||||||
FILE *Tf;
|
FILE *Tf;
|
||||||
|
|
||||||
fn = xstrcpy(strrchr(temp, '/') + 1);
|
fn = xstrcpy(strrchr(temp, '/') + 1);
|
||||||
@ -125,26 +125,7 @@ int CheckHatch(char *temp)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&mask, 0, sizeof(mask));
|
strcpy(mask, re_mask(fn, FALSE));
|
||||||
p = fn;
|
|
||||||
q = mask;
|
|
||||||
*q++ = '^';
|
|
||||||
while ((*p) && (q < (mask + sizeof(mask) - 4))) {
|
|
||||||
switch(*p) {
|
|
||||||
case '\\': *q++ = '\\'; *q++ = '\\'; break;
|
|
||||||
case '?': *q++ = '.'; break;
|
|
||||||
case '.': *q++ = '\\'; *q++ = '.'; break;
|
|
||||||
case '+': *q++ = '\\'; *q++ = '+'; break;
|
|
||||||
case '*': *q++ = '.'; *q++ = '*'; break;
|
|
||||||
case '@': sprintf(q, "[A-Za-z]"); while (*q) q++; break;
|
|
||||||
case '#': sprintf(q, "[0-9]"); while (*q) q++; break;
|
|
||||||
default: *q++ = *p; break;
|
|
||||||
}
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
*q++ = '$';
|
|
||||||
*q = '\0';
|
|
||||||
|
|
||||||
if ((re_comp(mask)) == NULL) {
|
if ((re_comp(mask)) == NULL) {
|
||||||
tf = calloc(PATH_MAX, sizeof(char));
|
tf = calloc(PATH_MAX, sizeof(char));
|
||||||
while ((de = readdir(dp))) {
|
while ((de = readdir(dp))) {
|
||||||
|
@ -83,7 +83,7 @@ char *Magic_Macro(int C)
|
|||||||
int GetMagicRec(int Typ, int First)
|
int GetMagicRec(int Typ, int First)
|
||||||
{
|
{
|
||||||
int Eof = FALSE;
|
int Eof = FALSE;
|
||||||
char *temp, *p, *q, mask[256];
|
char *temp, mask[256];
|
||||||
FILE *FeM;
|
FILE *FeM;
|
||||||
|
|
||||||
if (First)
|
if (First)
|
||||||
@ -114,25 +114,7 @@ int GetMagicRec(int Typ, int First)
|
|||||||
if ((magic.Active) && (magic.Attrib == Typ) && (strcasecmp(magic.From, TIC.TicIn.Area) == 0)) {
|
if ((magic.Active) && (magic.Attrib == Typ) && (strcasecmp(magic.From, TIC.TicIn.Area) == 0)) {
|
||||||
|
|
||||||
memset(&mask, 0, sizeof(mask));
|
memset(&mask, 0, sizeof(mask));
|
||||||
p = magic.Mask;
|
strcpy(mask, re_mask(magic.Mask, FALSE));
|
||||||
q = mask;
|
|
||||||
*q++ = '^';
|
|
||||||
while ((*p) && (q < (mask + sizeof(mask) - 4))) {
|
|
||||||
switch(*p) {
|
|
||||||
case '\\': *q++ = '\\'; *q++ = '\\'; break;
|
|
||||||
case '?': *q++ = '.'; break;
|
|
||||||
case '.': *q++ = '\\'; *q++ = '.'; break;
|
|
||||||
case '+': *q++ = '\\'; *q++ = '+'; break;
|
|
||||||
case '*': *q++ = '.'; *q++ = '*'; break;
|
|
||||||
case '@': sprintf(q, "[A-Za-z]"); while (*q) q++; break;
|
|
||||||
case '#': sprintf(q, "[0-9]"); while (*q) q++; break;
|
|
||||||
default: *q++ = *p; break;
|
|
||||||
}
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
*q++ = '$';
|
|
||||||
*q = '\0';
|
|
||||||
|
|
||||||
if ((re_comp(mask)) == NULL) {
|
if ((re_comp(mask)) == NULL) {
|
||||||
if (re_exec(TIC.NewFile)) {
|
if (re_exec(TIC.NewFile)) {
|
||||||
fclose(FeM);
|
fclose(FeM);
|
||||||
|
@ -227,6 +227,9 @@ void Check(void)
|
|||||||
tname = calloc(PATH_MAX, sizeof(char));
|
tname = calloc(PATH_MAX, sizeof(char));
|
||||||
sprintf(tname, "%s/%s", area.Path, fdb.Name);
|
sprintf(tname, "%s/%s", area.Path, fdb.Name);
|
||||||
rename(tname, mname);
|
rename(tname, mname);
|
||||||
|
sprintf(tname, "%s/%s", area.Path, fdb.LName);
|
||||||
|
unlink(tname);
|
||||||
|
symlink(mname, tname);
|
||||||
free(tname);
|
free(tname);
|
||||||
strncpy(fdb.Name, temp, 12);
|
strncpy(fdb.Name, temp, 12);
|
||||||
iErrors++;
|
iErrors++;
|
||||||
|
@ -46,7 +46,7 @@ extern int do_quiet; /* Suppress screen output */
|
|||||||
*/
|
*/
|
||||||
void Delete(int UnDel, int Area, char *File)
|
void Delete(int UnDel, int Area, char *File)
|
||||||
{
|
{
|
||||||
char *temp;
|
char *temp, mask[256];
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
int rc = FALSE;
|
int rc = FALSE;
|
||||||
|
|
||||||
@ -84,29 +84,32 @@ void Delete(int UnDel, int Area, char *File)
|
|||||||
if ((fp = fopen(temp, "r+")) == NULL)
|
if ((fp = fopen(temp, "r+")) == NULL)
|
||||||
die(MBERR_GENERAL);
|
die(MBERR_GENERAL);
|
||||||
|
|
||||||
|
fread(&fdbhdr, sizeof(fdbhdr), 1, fp);
|
||||||
colour(CYAN, BLACK);
|
colour(CYAN, BLACK);
|
||||||
|
strcpy(mask, re_mask(File, FALSE));
|
||||||
|
if (re_comp(mask))
|
||||||
|
die(MBERR_GENERAL);
|
||||||
|
|
||||||
while (fread(&fdb, sizeof(fdb), 1, fp) == 1) {
|
while (fread(&fdb, fdbhdr.recsize, 1, fp) == 1) {
|
||||||
if ((! strcmp(fdb.LName, File) || (! strcmp(fdb.Name, File)))) {
|
if (re_exec(fdb.LName) || re_exec(fdb.Name)) {
|
||||||
if (UnDel && fdb.Deleted) {
|
if (UnDel && fdb.Deleted) {
|
||||||
fdb.Deleted = FALSE;
|
fdb.Deleted = FALSE;
|
||||||
Syslog('+', "Marked file %s in area %d for undeletion", File, Area);
|
Syslog('+', "Marked file %s in area %d for undeletion", fdb.Name, Area);
|
||||||
if (!do_quiet)
|
if (!do_quiet)
|
||||||
printf("Marked file %s in area %d for undeletion\n", File, Area);
|
printf("Marked file %s in area %d for undeletion\n", fdb.Name, Area);
|
||||||
rc = TRUE;
|
rc = TRUE;
|
||||||
}
|
}
|
||||||
if (!UnDel && !fdb.Deleted) {
|
if (!UnDel && !fdb.Deleted) {
|
||||||
fdb.Deleted = TRUE;
|
fdb.Deleted = TRUE;
|
||||||
Syslog('+', "Marked file %s in area %d for deletion", File, Area);
|
Syslog('+', "Marked file %s in area %d for deletion", fdb.Name, Area);
|
||||||
if (!do_quiet)
|
if (!do_quiet)
|
||||||
printf("Marked file %s in area %d for deletion\n", File, Area);
|
printf("Marked file %s in area %d for deletion\n", fdb.Name, Area);
|
||||||
rc = TRUE;
|
rc = TRUE;
|
||||||
}
|
}
|
||||||
if (rc) {
|
if (rc) {
|
||||||
fseek(fp, - sizeof(fdb), SEEK_CUR);
|
fseek(fp, - fdbhdr.recsize, SEEK_CUR);
|
||||||
fwrite(&fdb, sizeof(fdb), 1, fp);
|
fwrite(&fdb, fdbhdr.recsize, 1, fp);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
#include "mbfutil.h"
|
#include "mbfutil.h"
|
||||||
#include "mbfsort.h"
|
#include "mbfsort.h"
|
||||||
#include "mbfile.h"
|
#include "mbfile.h"
|
||||||
|
#include "mbfrearc.h"
|
||||||
|
|
||||||
|
|
||||||
extern int do_quiet; /* Suppress screen output */
|
extern int do_quiet; /* Suppress screen output */
|
||||||
@ -62,6 +62,7 @@ int do_tobe = FALSE; /* List toberep database */
|
|||||||
int do_move = FALSE; /* Move a file */
|
int do_move = FALSE; /* Move a file */
|
||||||
int do_del = FALSE; /* Delete/undelete a file */
|
int do_del = FALSE; /* Delete/undelete a file */
|
||||||
int do_sort = FALSE; /* Sort a filebase */
|
int do_sort = FALSE; /* Sort a filebase */
|
||||||
|
int do_rearc = FALSE; /* ReArc a file */
|
||||||
extern int e_pid; /* Pid of external process */
|
extern int e_pid; /* Pid of external process */
|
||||||
extern int show_log; /* Show logging */
|
extern int show_log; /* Show logging */
|
||||||
time_t t_start; /* Start time */
|
time_t t_start; /* Start time */
|
||||||
@ -137,6 +138,20 @@ int main(int argc, char **argv)
|
|||||||
do_del = TRUE;
|
do_del = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (!strncasecmp(argv[i], "r", 1)) {
|
||||||
|
if (argc > (i + 1)) {
|
||||||
|
i++;
|
||||||
|
Area = atoi(argv[i]);
|
||||||
|
cmd = xstrcat(cmd, (char *)" ");
|
||||||
|
cmd = xstrcat(cmd, argv[i]);
|
||||||
|
if (argc > (i + 1)) {
|
||||||
|
i++;
|
||||||
|
FileName = xstrcpy(argv[i]);
|
||||||
|
cmd = xstrcat(cmd, (char *)" ");
|
||||||
|
cmd = xstrcat(cmd, argv[i]);
|
||||||
|
do_rearc = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (!strncasecmp(argv[i], "in", 2)) {
|
} else if (!strncasecmp(argv[i], "in", 2)) {
|
||||||
do_index = TRUE;
|
do_index = TRUE;
|
||||||
} else if (!strncasecmp(argv[i], "im", 2)) {
|
} else if (!strncasecmp(argv[i], "im", 2)) {
|
||||||
@ -201,7 +216,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!(do_pack || do_sort || do_check || do_kill || do_index || do_import ||
|
if (!(do_pack || do_sort || do_check || do_kill || do_index || do_import ||
|
||||||
do_list || do_adopt || do_del || do_move || do_tobe))
|
do_list || do_adopt || do_del || do_move || do_tobe || do_rearc))
|
||||||
Help();
|
Help();
|
||||||
|
|
||||||
ProgName();
|
ProgName();
|
||||||
@ -263,6 +278,11 @@ int main(int argc, char **argv)
|
|||||||
die(MBERR_OK);
|
die(MBERR_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (do_rearc) {
|
||||||
|
ReArc(Area, FileName);
|
||||||
|
die(MBERR_OK);
|
||||||
|
}
|
||||||
|
|
||||||
if (do_list) {
|
if (do_list) {
|
||||||
ListFileAreas(Area);
|
ListFileAreas(Area);
|
||||||
die(MBERR_OK);
|
die(MBERR_OK);
|
||||||
|
@ -43,8 +43,7 @@ extern int do_quiet; /* Suppress screen output */
|
|||||||
void ListFileAreas(int Area)
|
void ListFileAreas(int Area)
|
||||||
{
|
{
|
||||||
FILE *pAreas, *pFile, *pTic;
|
FILE *pAreas, *pFile, *pTic;
|
||||||
int i, iAreas, fcount, tcount = 0;
|
int i, iAreas, fcount, tcount = 0, iTotal = 0, columns = 80;
|
||||||
int iTotal = 0;
|
|
||||||
long fsize, tsize = 0;
|
long fsize, tsize = 0;
|
||||||
char *sAreas, *fAreas, *sTic, flags[6], *ticarea;
|
char *sAreas, *fAreas, *sTic, flags[6], *ticarea;
|
||||||
|
|
||||||
@ -54,6 +53,15 @@ void ListFileAreas(int Area)
|
|||||||
if (do_quiet)
|
if (do_quiet)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* See if we know the width of the users screen.
|
||||||
|
*/
|
||||||
|
if (getenv("COLUMNS")) {
|
||||||
|
i = atoi(getenv("COLUMNS"));
|
||||||
|
if (i >= 80)
|
||||||
|
columns = i;
|
||||||
|
}
|
||||||
|
|
||||||
colour(LIGHTRED, BLACK);
|
colour(LIGHTRED, BLACK);
|
||||||
sAreas = calloc(PATH_MAX, sizeof(char));
|
sAreas = calloc(PATH_MAX, sizeof(char));
|
||||||
fAreas = calloc(PATH_MAX, sizeof(char));
|
fAreas = calloc(PATH_MAX, sizeof(char));
|
||||||
@ -118,7 +126,7 @@ void ListFileAreas(int Area)
|
|||||||
printf("File listing of area %d, %s\n\n", Area, area.Name);
|
printf("File listing of area %d, %s\n\n", Area, area.Name);
|
||||||
printf("Short name Kb. File date Down Flg TIC Area Long name\n");
|
printf("Short name Kb. File date Down Flg TIC Area Long name\n");
|
||||||
printf("------------ ----- ---------- ---- --- -------------------- ");
|
printf("------------ ----- ---------- ---- --- -------------------- ");
|
||||||
for (i = 63; i < COLS; i++)
|
for (i = 60; i < columns; i++)
|
||||||
printf("-");
|
printf("-");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
@ -133,7 +141,7 @@ void ListFileAreas(int Area)
|
|||||||
if (fdb.Announced)
|
if (fdb.Announced)
|
||||||
flags[2] = 'A';
|
flags[2] = 'A';
|
||||||
|
|
||||||
fdb.LName[COLS - 63] = '\0';
|
fdb.LName[columns - 60] = '\0';
|
||||||
printf("%-12s %5ld %s %4ld %s %-20s %s\n", fdb.Name, (long)(fdb.Size / 1024), StrDateDMY(fdb.FileDate),
|
printf("%-12s %5ld %s %4ld %s %-20s %s\n", fdb.Name, (long)(fdb.Size / 1024), StrDateDMY(fdb.FileDate),
|
||||||
(long)(fdb.TimesDL), flags, fdb.TicArea, fdb.LName);
|
(long)(fdb.TimesDL), flags, fdb.TicArea, fdb.LName);
|
||||||
fcount++;
|
fcount++;
|
||||||
@ -142,8 +150,8 @@ void ListFileAreas(int Area)
|
|||||||
fsize = fsize / 1024;
|
fsize = fsize / 1024;
|
||||||
|
|
||||||
colour(CYAN, BLACK);
|
colour(CYAN, BLACK);
|
||||||
printf("--------------------------------------------------------------");
|
printf("------------------------------------------------------------");
|
||||||
for (i = 63; i < COLS; i++)
|
for (i = 60; i < columns; i++)
|
||||||
printf("-");
|
printf("-");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("%d file%s, %ld Kbytes\n", fcount, (fcount == 1) ? "":"s", fsize);
|
printf("%d file%s, %ld Kbytes\n", fcount, (fcount == 1) ? "":"s", fsize);
|
||||||
|
196
mbfido/mbfrearc.c
Normal file
196
mbfido/mbfrearc.c
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
* Purpose: File Database Maintenance - ReArc file(s)
|
||||||
|
*
|
||||||
|
*****************************************************************************
|
||||||
|
* Copyright (C) 1997-2004
|
||||||
|
*
|
||||||
|
* Michiel Broek FIDO: 2:280/2802
|
||||||
|
* Beekmansbos 10
|
||||||
|
* 1971 BV IJmuiden
|
||||||
|
* the Netherlands
|
||||||
|
*
|
||||||
|
* This file is part of MBSE BBS.
|
||||||
|
*
|
||||||
|
* This BBS 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, or (at your option) any
|
||||||
|
* later version.
|
||||||
|
*
|
||||||
|
* MBSE BBS 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 MBSE BBS; see the file COPYING. If not, write to the Free
|
||||||
|
* Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include "../config.h"
|
||||||
|
#include "../lib/mbselib.h"
|
||||||
|
#include "../lib/users.h"
|
||||||
|
#include "../lib/mbsedb.h"
|
||||||
|
#include "mbfutil.h"
|
||||||
|
#include "mbfmove.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
extern int do_quiet; /* Suppress screen output */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ReArc file(s)
|
||||||
|
*/
|
||||||
|
void ReArc(int Area, char *File)
|
||||||
|
{
|
||||||
|
char *p, *temp, *linkpath, mask[256];
|
||||||
|
FILE *fp;
|
||||||
|
int i, rc = -1;
|
||||||
|
struct utimbuf ut;
|
||||||
|
|
||||||
|
IsDoing("ReArc file(s)");
|
||||||
|
colour(LIGHTRED, BLACK);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check area
|
||||||
|
*/
|
||||||
|
if (LoadAreaRec(Area) == FALSE) {
|
||||||
|
WriteError("Can't load record %d", Area);
|
||||||
|
die(MBERR_INIT_ERROR);
|
||||||
|
}
|
||||||
|
if (!area.Available) {
|
||||||
|
WriteError("Area %d not available", Area);
|
||||||
|
if (!do_quiet)
|
||||||
|
printf("Area %d not available\n", Area);
|
||||||
|
die(MBERR_CONFIG_ERROR);
|
||||||
|
}
|
||||||
|
if (area.CDrom) {
|
||||||
|
WriteError("Can't rearc on CD-ROM");
|
||||||
|
if (!do_quiet)
|
||||||
|
printf("Can't rearc on CD-ROM\n");
|
||||||
|
die(MBERR_COMMANDLINE);
|
||||||
|
}
|
||||||
|
if (strlen(area.Archiver) == 0) {
|
||||||
|
WriteError("No default archiver for area %d", Area);
|
||||||
|
if (!do_quiet)
|
||||||
|
printf("No default archiver for area %d\n", Area);
|
||||||
|
die(MBERR_COMMANDLINE);
|
||||||
|
}
|
||||||
|
if (CheckFDB(Area, area.Path))
|
||||||
|
die(MBERR_GENERAL);
|
||||||
|
|
||||||
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
|
sprintf(temp, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), Area);
|
||||||
|
|
||||||
|
if ((fp = fopen(temp, "r+")) == NULL)
|
||||||
|
die(MBERR_GENERAL);
|
||||||
|
|
||||||
|
fread(&fdbhdr, sizeof(fdbhdr), 1, fp);
|
||||||
|
colour(CYAN, BLACK);
|
||||||
|
strcpy(mask, re_mask(File, FALSE));
|
||||||
|
if (re_comp(mask))
|
||||||
|
die(MBERR_GENERAL);
|
||||||
|
|
||||||
|
while (fread(&fdb, fdbhdr.recsize, 1, fp) == 1) {
|
||||||
|
if (re_exec(fdb.LName) || re_exec(fdb.Name)) {
|
||||||
|
Syslog('+', "Will rearc %s", fdb.LName);
|
||||||
|
sprintf(temp, "%s/%s", area.Path, fdb.Name);
|
||||||
|
|
||||||
|
rc = rearc(temp, area.Archiver, do_quiet);
|
||||||
|
if (rc == 0) {
|
||||||
|
/*
|
||||||
|
* Success, update the file entry
|
||||||
|
*/
|
||||||
|
if (!do_quiet) {
|
||||||
|
colour(9, 0);
|
||||||
|
printf("\r Update file %s", temp);
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
|
||||||
|
linkpath = calloc(PATH_MAX, sizeof(char));
|
||||||
|
sprintf(linkpath, "%s/%s", area.Path, fdb.LName);
|
||||||
|
unlink(linkpath);
|
||||||
|
|
||||||
|
Syslog('+', "New name %s", temp);
|
||||||
|
if ((p = strstr(fdb.Name, "ARC")))
|
||||||
|
*p = '\0';
|
||||||
|
else if ((p = strstr(fdb.Name, "LHA")))
|
||||||
|
*p = '\0';
|
||||||
|
else if ((p = strstr(fdb.Name, "RAR")))
|
||||||
|
*p = '\0';
|
||||||
|
else if ((p = strstr(fdb.Name, "TGZ")))
|
||||||
|
*p = '\0';
|
||||||
|
else if ((p = strstr(fdb.Name, "BZ2")))
|
||||||
|
*p = '\0';
|
||||||
|
else if ((p = strstr(fdb.Name, "TAR")))
|
||||||
|
*p = '\0';
|
||||||
|
else if ((p = strstr(fdb.Name, "ARJ")))
|
||||||
|
*p = '\0';
|
||||||
|
else if ((p = strstr(fdb.Name, "ZIP")))
|
||||||
|
*p = '\0';
|
||||||
|
else if ((p = strstr(fdb.Name, "ZOO")))
|
||||||
|
*p = '\0';
|
||||||
|
else if ((p = strstr(fdb.Name, "HA")))
|
||||||
|
*p = '\0';
|
||||||
|
sprintf(p, "%s", archiver.name);
|
||||||
|
if ((p = strstr(fdb.LName, "arc")))
|
||||||
|
*p = '\0';
|
||||||
|
else if ((p = strstr(fdb.LName, "lha")))
|
||||||
|
*p = '\0';
|
||||||
|
else if ((p = strstr(fdb.LName, "rar")))
|
||||||
|
*p = '\0';
|
||||||
|
else if ((p = strstr(fdb.LName, "tar.gz")))
|
||||||
|
*p = '\0';
|
||||||
|
else if ((p = strstr(fdb.LName, "tgz")))
|
||||||
|
*p = '\0';
|
||||||
|
else if ((p = strstr(fdb.LName, "tar.bz2")))
|
||||||
|
*p = '\0';
|
||||||
|
else if ((p = strstr(fdb.LName, "bz2")))
|
||||||
|
*p = '\0';
|
||||||
|
else if ((p = strstr(fdb.LName, "tar")))
|
||||||
|
*p = '\0';
|
||||||
|
else if ((p = strstr(fdb.LName, "arj")))
|
||||||
|
*p = '\0';
|
||||||
|
else if ((p = strstr(fdb.LName, "zip")))
|
||||||
|
*p = '\0';
|
||||||
|
else if ((p = strstr(fdb.LName, "zoo")))
|
||||||
|
*p = '\0';
|
||||||
|
else if ((p = strstr(fdb.LName, "ha")))
|
||||||
|
*p = '\0';
|
||||||
|
sprintf(p, "%s", tl(archiver.name));
|
||||||
|
Syslog('f', "%s %s", fdb.Name, fdb.LName);
|
||||||
|
fdb.Size = file_size(temp);
|
||||||
|
fdb.Crc32 = file_crc(temp, FALSE);
|
||||||
|
ut.actime = mktime(localtime(&fdb.FileDate));
|
||||||
|
ut.modtime = mktime(localtime(&fdb.FileDate));
|
||||||
|
utime(temp, &ut);
|
||||||
|
fseek(fp, - fdbhdr.recsize, SEEK_CUR);
|
||||||
|
fwrite(&fdb, fdbhdr.recsize, 1, fp);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Update symbolic link to long filename
|
||||||
|
*/
|
||||||
|
sprintf(linkpath, "%s/%s", area.Path, fdb.LName);
|
||||||
|
symlink(temp, linkpath);
|
||||||
|
free(linkpath);
|
||||||
|
} else {
|
||||||
|
break; // stop when something goes wrong
|
||||||
|
}
|
||||||
|
if (!do_quiet) {
|
||||||
|
colour(7, 0);
|
||||||
|
printf("\r");
|
||||||
|
for (i = 0; i < (strlen(temp) + 17); i++)
|
||||||
|
printf(" ");
|
||||||
|
printf("\r");
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(fp);
|
||||||
|
free(temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
8
mbfido/mbfrearc.h
Normal file
8
mbfido/mbfrearc.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#ifndef _MBFREARC_H
|
||||||
|
#define _MBFREARC_H
|
||||||
|
|
||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
void ReArc(int, char *);
|
||||||
|
|
||||||
|
#endif
|
@ -114,17 +114,17 @@ void Help(void)
|
|||||||
colour(CYAN, BLACK);
|
colour(CYAN, BLACK);
|
||||||
printf(" a adopt <area> <file> [desc] Adopt file to area\n");
|
printf(" a adopt <area> <file> [desc] Adopt file to area\n");
|
||||||
printf(" c check Check filebase\n");
|
printf(" c check Check filebase\n");
|
||||||
printf(" d delete <area> <file> Mark file in area for deletion\n");
|
printf(" d delete <area> <filemask> Mark file(s) in area for deletion\n");
|
||||||
printf(" im import <area> Import files in current dir to area\n");
|
printf(" im import <area> Import files in current dir to area\n");
|
||||||
printf(" in index Create filerequest index\n");
|
printf(" in index Create filerequest index\n");
|
||||||
printf(" k kill Kill/move old files\n");
|
printf(" k kill Kill/move old files\n");
|
||||||
printf(" l list [area] List file areas or one area\n");
|
printf(" l list [area] List file areas or one area\n");
|
||||||
printf(" m move <from> <to> <file> Move file from to area\n");
|
printf(" m move <from> <to> <file> Move file from to area\n");
|
||||||
printf(" p pack Pack filebase\n");
|
printf(" p pack Pack filebase\n");
|
||||||
// printf(" r rearc <area> [file] [arc] Rearc file(s) in area\n");
|
printf(" r rearc <area> <filemask> Rearc file(s) in area to area archive type\n");
|
||||||
printf(" s sort <area> Sort files in a file area\n");
|
printf(" s sort <area> Sort files in a file area\n");
|
||||||
printf(" t toberep Show toberep database\n");
|
printf(" t toberep Show toberep database\n");
|
||||||
printf(" u undelete <area> <file> Mark file in area for undeletion\n");
|
printf(" u undelete <area> <filemask> Mark file(s) in area for undeletion\n");
|
||||||
colour(LIGHTBLUE, BLACK);
|
colour(LIGHTBLUE, BLACK);
|
||||||
printf("\n Options are:\n\n");
|
printf("\n Options are:\n\n");
|
||||||
colour(CYAN, BLACK);
|
colour(CYAN, BLACK);
|
||||||
|
@ -697,7 +697,7 @@ int FilenameScan()
|
|||||||
{
|
{
|
||||||
FILE *pAreas, *pFile;
|
FILE *pAreas, *pFile;
|
||||||
int Found, Count = 0;
|
int Found, Count = 0;
|
||||||
char *p, *q, mask[256];
|
char mask[256];
|
||||||
char *Name;
|
char *Name;
|
||||||
_Tag T;
|
_Tag T;
|
||||||
unsigned long OldArea;
|
unsigned long OldArea;
|
||||||
@ -724,25 +724,7 @@ int FilenameScan()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
strcpy(mask, re_mask(Name, TRUE));
|
||||||
* Make a regexp string for the users search mask.
|
|
||||||
*/
|
|
||||||
p = tl(Name);
|
|
||||||
q = mask;
|
|
||||||
*q++ = '^';
|
|
||||||
while ((*p) && (q < (mask + sizeof(mask) - 4))) {
|
|
||||||
switch (*p) {
|
|
||||||
case '\\': *q++ = '\\'; *q++ = '\\'; break;
|
|
||||||
case '?': *q++ = ','; break;
|
|
||||||
case '.': *q++ = '\\'; *q++ = '.'; break;
|
|
||||||
case '+': *q++ = '\\'; *q++ = '+'; break;
|
|
||||||
case '*': *q++ = '.'; *q++ = '*'; break;
|
|
||||||
default: *q++ = toupper(*p); break;
|
|
||||||
}
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
*q++ = '$';
|
|
||||||
*q++ = '\0';
|
|
||||||
Syslog('+', "FilenameScan(): \"%s\" -> \"%s\"", Name, mask);
|
Syslog('+', "FilenameScan(): \"%s\" -> \"%s\"", Name, mask);
|
||||||
free(Name);
|
free(Name);
|
||||||
re_comp(mask);
|
re_comp(mask);
|
||||||
|
Reference in New Issue
Block a user