2001-11-25 12:25:59 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
* Purpose: File Database Maintenance - Import files with files.bbs
|
|
|
|
*
|
|
|
|
*****************************************************************************
|
2005-08-28 14:52:14 +00:00
|
|
|
* Copyright (C) 1997-2005
|
2001-11-25 12:25:59 +00:00
|
|
|
*
|
|
|
|
* 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
|
2003-08-15 20:05:34 +00:00
|
|
|
* Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
2001-11-25 12:25:59 +00:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2002-06-30 12:48:44 +00:00
|
|
|
#include "../config.h"
|
2004-02-21 17:22:00 +00:00
|
|
|
#include "../lib/mbselib.h"
|
2002-01-07 19:16:03 +00:00
|
|
|
#include "../lib/users.h"
|
2004-02-21 17:22:00 +00:00
|
|
|
#include "../lib/mbsedb.h"
|
2001-11-25 12:25:59 +00:00
|
|
|
#include "virscan.h"
|
|
|
|
#include "mbfutil.h"
|
|
|
|
#include "mbfimport.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-06-19 20:31:35 +00:00
|
|
|
extern int do_quiet; /* Suppress screen output */
|
|
|
|
extern int do_annon; /* Suppress announce files */
|
|
|
|
extern int do_novir; /* Suppress virus scanning */
|
2001-11-25 12:25:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
void ImportFiles(int Area)
|
|
|
|
{
|
2005-01-02 15:11:07 +00:00
|
|
|
char *pwd, *temp, *fod, *temp2, *tmpdir, *String, *token, *dest, *unarc, *lname;
|
2001-12-02 20:49:36 +00:00
|
|
|
FILE *fbbs;
|
2003-01-19 14:43:23 +00:00
|
|
|
DIR *dp;
|
2004-12-22 15:52:25 +00:00
|
|
|
int Append = FALSE, Files = 0, rc, i, line = 0, pos, x, y, Doit;
|
2002-01-31 21:08:29 +00:00
|
|
|
int Imported = 0, Errors = 0, Present = FALSE;
|
2004-03-06 21:48:41 +00:00
|
|
|
struct FILE_record f_db;
|
2001-11-25 12:25:59 +00:00
|
|
|
struct stat statfile;
|
2003-01-19 14:43:23 +00:00
|
|
|
struct dirent *de;
|
2001-11-25 12:25:59 +00:00
|
|
|
|
|
|
|
if (!do_quiet)
|
2004-10-27 11:08:09 +00:00
|
|
|
mbse_colour(CYAN, BLACK);
|
2001-11-25 12:25:59 +00:00
|
|
|
|
2004-12-22 15:52:25 +00:00
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
2005-08-28 14:52:14 +00:00
|
|
|
snprintf(temp, PATH_MAX, "xxxxx%d", getpid());
|
2004-12-22 15:52:25 +00:00
|
|
|
if ((fbbs = fopen(temp, "a+")) == NULL) {
|
|
|
|
WriteError("$Can't write to directory");
|
|
|
|
if (!do_quiet)
|
|
|
|
printf("\nCan't write to this directory, cannot import\n");
|
|
|
|
free(temp);
|
|
|
|
die(MBERR_INIT_ERROR);
|
|
|
|
}
|
|
|
|
fclose(fbbs);
|
|
|
|
unlink(temp);
|
|
|
|
free(temp);
|
|
|
|
|
2001-12-02 20:49:36 +00:00
|
|
|
if (LoadAreaRec(Area) == FALSE)
|
2002-10-20 20:58:55 +00:00
|
|
|
die(MBERR_INIT_ERROR);
|
2001-11-25 12:25:59 +00:00
|
|
|
|
2005-08-11 21:05:15 +00:00
|
|
|
if (area.Available) {
|
2001-11-25 12:25:59 +00:00
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
|
|
|
temp2 = calloc(PATH_MAX, sizeof(char));
|
|
|
|
pwd = calloc(PATH_MAX, sizeof(char));
|
2002-06-01 12:27:11 +00:00
|
|
|
tmpdir = calloc(PATH_MAX, sizeof(char));
|
2002-01-31 21:08:29 +00:00
|
|
|
String = calloc(4096, sizeof(char));
|
2001-11-25 12:25:59 +00:00
|
|
|
dest = calloc(PATH_MAX, sizeof(char));
|
2002-11-23 16:48:54 +00:00
|
|
|
lname = calloc(PATH_MAX, sizeof(char));
|
2005-01-02 15:11:07 +00:00
|
|
|
fod = calloc(PATH_MAX, sizeof(char));
|
2001-11-25 12:25:59 +00:00
|
|
|
|
|
|
|
getcwd(pwd, PATH_MAX);
|
|
|
|
if (CheckFDB(Area, area.Path))
|
2002-10-20 20:58:55 +00:00
|
|
|
die(MBERR_GENERAL);
|
2001-11-25 12:25:59 +00:00
|
|
|
|
2005-12-03 14:52:34 +00:00
|
|
|
snprintf(tmpdir, PATH_MAX, "%s/tmp/arc%d", getenv("MBSE_ROOT"), (int)getpid());
|
|
|
|
if (create_tmpwork()) {
|
|
|
|
WriteError("Can't create %s", tmpdir);
|
|
|
|
if (!do_quiet)
|
|
|
|
printf("\nCan't create %s\n", tmpdir);
|
|
|
|
die(MBERR_GENERAL);
|
|
|
|
}
|
2001-11-25 12:25:59 +00:00
|
|
|
IsDoing("Import files");
|
|
|
|
|
|
|
|
/*
|
2004-12-22 15:52:25 +00:00
|
|
|
* Find and open files.bbs
|
2001-11-25 12:25:59 +00:00
|
|
|
*/
|
2005-08-28 14:52:14 +00:00
|
|
|
snprintf(temp, PATH_MAX, "FILES.BBS");
|
2005-12-16 20:00:40 +00:00
|
|
|
if (getfilecase(pwd, temp) == FALSE) {
|
2004-12-22 15:52:25 +00:00
|
|
|
WriteError("Can't find files.bbs anywhere");
|
|
|
|
if (!do_quiet)
|
|
|
|
printf("Can't find files.bbs anywhere\n");
|
|
|
|
die(MBERR_INIT_ERROR);
|
|
|
|
}
|
2001-11-25 12:25:59 +00:00
|
|
|
if ((fbbs = fopen(temp, "r")) == NULL) {
|
2004-12-22 15:52:25 +00:00
|
|
|
WriteError("Can't open files.bbs");
|
|
|
|
if (!do_quiet)
|
|
|
|
printf("Can't open files.bbs\n");
|
|
|
|
die(MBERR_INIT_ERROR);
|
2001-11-25 12:25:59 +00:00
|
|
|
}
|
|
|
|
|
2002-01-31 21:08:29 +00:00
|
|
|
while (fgets(String, 4095, fbbs) != NULL) {
|
2001-11-25 12:25:59 +00:00
|
|
|
|
2002-05-24 17:37:32 +00:00
|
|
|
if ((String[0] != ' ') && (String[0] != '\t')) {
|
2001-11-25 12:25:59 +00:00
|
|
|
/*
|
|
|
|
* New file entry, check if there has been a file that is not yet saved.
|
|
|
|
*/
|
2002-01-31 21:08:29 +00:00
|
|
|
if (Append && Present) {
|
2001-11-25 12:25:59 +00:00
|
|
|
Doit = TRUE;
|
|
|
|
if ((unarc = unpacker(temp)) == NULL) {
|
|
|
|
Syslog('+', "Unknown archive format %s", temp);
|
2005-12-03 14:52:34 +00:00
|
|
|
snprintf(temp2, PATH_MAX, "%s/tmp/arc%d/%s", getenv("MBSE_ROOT"), (int)getpid(), f_db.Name);
|
2002-05-10 18:14:27 +00:00
|
|
|
if ((rc = file_cp(temp, temp2))) {
|
2005-12-16 19:52:20 +00:00
|
|
|
WriteError("1 Can't copy file to %s, %s", temp2, strerror(rc));
|
2002-05-10 18:14:27 +00:00
|
|
|
if (!do_quiet)
|
|
|
|
printf("Can't copy file to %s, %s\n", temp2, strerror(rc));
|
2001-11-25 12:25:59 +00:00
|
|
|
Doit = FALSE;
|
|
|
|
} else {
|
2002-06-15 14:00:49 +00:00
|
|
|
if (do_novir == FALSE) {
|
|
|
|
if (!do_quiet) {
|
|
|
|
printf("Virscan \b\b\b\b\b\b\b\b\b\b");
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
if (VirScan(tmpdir)) {
|
|
|
|
Doit = FALSE;
|
|
|
|
}
|
2001-11-25 12:25:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!do_quiet) {
|
|
|
|
printf("Unpacking \b\b\b\b\b\b\b\b\b\b");
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
if (UnpackFile(temp)) {
|
2002-06-15 14:00:49 +00:00
|
|
|
if (do_novir == FALSE) {
|
|
|
|
if (!do_quiet) {
|
|
|
|
printf("Virscan \b\b\b\b\b\b\b\b\b\b");
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
if (VirScan(tmpdir)) {
|
|
|
|
Doit = FALSE;
|
|
|
|
}
|
2001-11-25 12:25:59 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Doit = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Doit) {
|
|
|
|
if (!do_quiet) {
|
|
|
|
printf("Adding \b\b\b\b\b\b\b\b\b\b");
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
2004-03-06 21:48:41 +00:00
|
|
|
if (strcmp(f_db.Name, f_db.LName)) {
|
|
|
|
if (AddFile(f_db, Area, dest, temp, lname)) {
|
2002-11-23 16:48:54 +00:00
|
|
|
Imported++;
|
|
|
|
} else {
|
|
|
|
Errors++;
|
|
|
|
}
|
|
|
|
} else {
|
2004-03-06 21:48:41 +00:00
|
|
|
if (AddFile(f_db, Area, dest, temp, NULL)) {
|
2002-11-23 16:48:54 +00:00
|
|
|
Imported++;
|
|
|
|
} else {
|
|
|
|
Errors++;
|
|
|
|
}
|
|
|
|
}
|
2001-11-25 12:25:59 +00:00
|
|
|
} else {
|
|
|
|
Errors++;
|
|
|
|
}
|
|
|
|
Append = FALSE;
|
2002-01-31 21:08:29 +00:00
|
|
|
Present = FALSE;
|
2003-01-19 14:43:23 +00:00
|
|
|
line = 0;
|
|
|
|
pos = 0;
|
2001-11-25 12:25:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check diskspace
|
|
|
|
*/
|
2004-03-21 12:55:45 +00:00
|
|
|
if (enoughspace(CFG.freespace) == 0)
|
2002-10-20 20:58:55 +00:00
|
|
|
die(MBERR_DISK_FULL);
|
2001-11-25 12:25:59 +00:00
|
|
|
|
2005-12-16 19:52:20 +00:00
|
|
|
/*
|
|
|
|
* Refresh tmpwork
|
|
|
|
*/
|
|
|
|
clean_tmpwork();
|
|
|
|
create_tmpwork();
|
|
|
|
|
2001-11-25 12:25:59 +00:00
|
|
|
Files++;
|
2004-03-06 21:48:41 +00:00
|
|
|
memset(&f_db, 0, sizeof(f_db));
|
2002-01-31 21:08:29 +00:00
|
|
|
Present = TRUE;
|
2001-11-25 12:25:59 +00:00
|
|
|
|
2004-12-22 15:52:25 +00:00
|
|
|
token = strtok(String, " \t\r\n\0");
|
2002-01-31 21:08:29 +00:00
|
|
|
|
2001-11-27 22:55:00 +00:00
|
|
|
/*
|
|
|
|
* Test filename against name on disk, first normal case,
|
|
|
|
* then lowercase and finally uppercase.
|
|
|
|
*/
|
2003-01-19 14:43:23 +00:00
|
|
|
if ((dp = opendir(pwd)) == NULL) {
|
|
|
|
WriteError("$Can't open directory %s", pwd);
|
2004-12-22 15:52:25 +00:00
|
|
|
if (!do_quiet)
|
|
|
|
printf("\nCan't open directory %s: %s\n", pwd, strerror(errno));
|
2003-01-19 14:43:23 +00:00
|
|
|
die(MBERR_INIT_ERROR);
|
|
|
|
}
|
|
|
|
while ((de = readdir(dp))) {
|
|
|
|
if (strcasecmp(de->d_name, token) == 0) {
|
|
|
|
/*
|
|
|
|
* Found the right file.
|
|
|
|
*/
|
2004-12-22 15:52:25 +00:00
|
|
|
strncpy(temp2, de->d_name, 80);
|
2003-01-19 14:43:23 +00:00
|
|
|
break;
|
2001-11-27 22:55:00 +00:00
|
|
|
}
|
|
|
|
}
|
2003-01-19 14:43:23 +00:00
|
|
|
closedir(dp);
|
2001-11-27 22:55:00 +00:00
|
|
|
|
2004-12-22 15:52:25 +00:00
|
|
|
if (strlen(temp2) == 0) {
|
2005-01-02 15:11:07 +00:00
|
|
|
WriteError("Can't find file on disk, skipping: %s", token);
|
2004-12-22 15:52:25 +00:00
|
|
|
if (!do_quiet)
|
2005-01-02 15:11:07 +00:00
|
|
|
printf("\nCan't find file on disk, skipping: %s\n", token);
|
2003-01-19 14:43:23 +00:00
|
|
|
Append = FALSE;
|
|
|
|
Present = FALSE;
|
|
|
|
} else {
|
2002-01-31 21:08:29 +00:00
|
|
|
/*
|
2004-12-22 15:52:25 +00:00
|
|
|
* Check type of filename and set the right values.
|
2002-01-31 21:08:29 +00:00
|
|
|
*/
|
2005-01-02 15:11:07 +00:00
|
|
|
strcpy(fod, temp2);
|
2004-12-22 15:52:25 +00:00
|
|
|
if (is_real_8_3(temp2)) {
|
|
|
|
Syslog('f', "%s is 8.3", temp2);
|
|
|
|
strcpy(f_db.Name, temp2);
|
|
|
|
tl(temp2);
|
|
|
|
strcpy(f_db.LName, temp2);
|
|
|
|
} else {
|
|
|
|
Syslog('f', "%s is LFN", temp2);
|
|
|
|
strcpy(f_db.LName, temp2);
|
|
|
|
name_mangle(temp2);
|
|
|
|
strcpy(f_db.Name, temp2);
|
2003-01-19 14:43:23 +00:00
|
|
|
}
|
|
|
|
|
2005-08-28 14:52:14 +00:00
|
|
|
snprintf(temp, PATH_MAX, "%s/%s", pwd, fod);
|
2003-01-19 14:43:23 +00:00
|
|
|
stat(temp, &statfile);
|
|
|
|
|
2002-01-31 21:08:29 +00:00
|
|
|
if (do_annon)
|
2004-03-06 21:48:41 +00:00
|
|
|
f_db.Announced = TRUE;
|
|
|
|
Syslog('f', "File: %s (%s)", f_db.Name, f_db.LName);
|
2001-11-25 12:25:59 +00:00
|
|
|
|
2002-01-31 21:08:29 +00:00
|
|
|
if (!do_quiet) {
|
2004-03-06 21:48:41 +00:00
|
|
|
printf("\rImport file: %s ", f_db.Name);
|
2002-01-31 21:08:29 +00:00
|
|
|
printf("Checking \b\b\b\b\b\b\b\b\b\b");
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
2001-11-25 12:25:59 +00:00
|
|
|
|
2004-03-06 21:48:41 +00:00
|
|
|
IsDoing("Import %s", f_db.Name);
|
2001-11-25 12:25:59 +00:00
|
|
|
|
2002-01-31 21:08:29 +00:00
|
|
|
token = strtok(NULL, "\0");
|
2004-12-22 15:52:25 +00:00
|
|
|
if (token) {
|
|
|
|
i = strlen(token);
|
|
|
|
line = pos = 0;
|
|
|
|
for (x = 0; x < i; x++) {
|
|
|
|
if ((token[x] == '\n') || (token[x] == '\r'))
|
|
|
|
token[x] = '\0';
|
|
|
|
}
|
|
|
|
i = strlen(token);
|
|
|
|
y = 0;
|
2002-01-31 21:08:29 +00:00
|
|
|
|
2004-12-22 15:52:25 +00:00
|
|
|
if (token[0] == '[') {
|
|
|
|
/*
|
|
|
|
* Skip over download counter
|
|
|
|
*/
|
|
|
|
while (token[y] != ']')
|
|
|
|
y++;
|
|
|
|
y += 2;
|
2002-01-31 21:08:29 +00:00
|
|
|
}
|
2004-12-22 15:52:25 +00:00
|
|
|
|
|
|
|
Doit = FALSE;
|
|
|
|
for (x = y; x < i; x++) {
|
|
|
|
if (!Doit) {
|
|
|
|
if (!iscntrl(token[x]) && !isblank(token[x]))
|
|
|
|
Doit = TRUE;
|
|
|
|
}
|
|
|
|
if (Doit) {
|
|
|
|
if (pos > 42) {
|
|
|
|
if (token[x] == ' ') {
|
2004-03-06 21:48:41 +00:00
|
|
|
f_db.Desc[line][pos] = '\0';
|
2003-01-19 14:43:23 +00:00
|
|
|
line++;
|
2004-12-22 15:52:25 +00:00
|
|
|
pos = 0;
|
|
|
|
} else {
|
|
|
|
if (pos == 49) {
|
|
|
|
f_db.Desc[line][pos] = '\0';
|
|
|
|
pos = 0;
|
|
|
|
line++;
|
|
|
|
}
|
|
|
|
f_db.Desc[line][pos] = token[x];
|
|
|
|
pos++;
|
2002-01-31 21:08:29 +00:00
|
|
|
}
|
2004-12-22 15:52:25 +00:00
|
|
|
} else {
|
2004-03-06 21:48:41 +00:00
|
|
|
f_db.Desc[line][pos] = token[x];
|
2003-01-19 14:43:23 +00:00
|
|
|
pos++;
|
2001-11-25 12:25:59 +00:00
|
|
|
}
|
2004-12-22 15:52:25 +00:00
|
|
|
if (line == 25)
|
|
|
|
break;
|
2001-11-25 12:25:59 +00:00
|
|
|
}
|
|
|
|
}
|
2004-12-22 15:52:25 +00:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* No file description
|
|
|
|
*/
|
|
|
|
Syslog('+', "No file description in files.bbs for %s", f_db.LName);
|
|
|
|
strcpy(f_db.Desc[0], "No description");
|
2001-11-25 12:25:59 +00:00
|
|
|
}
|
|
|
|
|
2005-08-28 14:52:14 +00:00
|
|
|
snprintf(dest, PATH_MAX, "%s/%s", area.Path, f_db.Name);
|
|
|
|
snprintf(lname, PATH_MAX, "%s/%s", area.Path, f_db.LName);
|
2002-01-31 21:08:29 +00:00
|
|
|
Append = TRUE;
|
2004-03-06 21:48:41 +00:00
|
|
|
f_db.Size = statfile.st_size;
|
|
|
|
f_db.FileDate = statfile.st_mtime;
|
|
|
|
f_db.Crc32 = file_crc(temp, FALSE);
|
|
|
|
strcpy(f_db.Uploader, CFG.sysop_name);
|
|
|
|
f_db.UploadDate = time(NULL);
|
2002-01-31 21:08:29 +00:00
|
|
|
}
|
|
|
|
} else if (Present) {
|
2001-11-25 12:25:59 +00:00
|
|
|
/*
|
|
|
|
* Add multiple description lines
|
|
|
|
*/
|
2003-01-19 14:43:23 +00:00
|
|
|
if (line < 25) {
|
|
|
|
token = strtok(String, "\0");
|
|
|
|
i = strlen(token);
|
|
|
|
line++;
|
|
|
|
pos = 0;
|
|
|
|
Doit = FALSE;
|
|
|
|
for (x = 0; x < i; x++) {
|
|
|
|
if ((token[x] == '\n') || (token[x] == '\r'))
|
|
|
|
token[x] = '\0';
|
|
|
|
}
|
|
|
|
for (x = 0; x < i; x++) {
|
|
|
|
if (Doit) {
|
|
|
|
if (pos > 42) {
|
|
|
|
if (token[x] == ' ') {
|
2004-03-06 21:48:41 +00:00
|
|
|
f_db.Desc[line][pos] = '\0';
|
2003-01-19 14:43:23 +00:00
|
|
|
line++;
|
|
|
|
pos = 0;
|
|
|
|
} else {
|
|
|
|
if (pos == 49) {
|
2004-03-06 21:48:41 +00:00
|
|
|
f_db.Desc[line][pos] = '\0';
|
2003-01-19 14:43:23 +00:00
|
|
|
pos = 0;
|
|
|
|
line++;
|
|
|
|
}
|
2004-03-06 21:48:41 +00:00
|
|
|
f_db.Desc[line][pos] = token[x];
|
2003-01-19 14:43:23 +00:00
|
|
|
pos++;
|
2001-11-25 12:25:59 +00:00
|
|
|
}
|
2003-01-19 14:43:23 +00:00
|
|
|
} else {
|
2004-03-06 21:48:41 +00:00
|
|
|
f_db.Desc[line][pos] = token[x];
|
2003-01-19 14:43:23 +00:00
|
|
|
pos++;
|
2001-11-25 12:25:59 +00:00
|
|
|
}
|
2003-01-19 14:43:23 +00:00
|
|
|
if (line == 25)
|
|
|
|
break;
|
2001-11-25 12:25:59 +00:00
|
|
|
} else {
|
2003-01-19 14:43:23 +00:00
|
|
|
/*
|
|
|
|
* Skip until + or | is found
|
|
|
|
*/
|
|
|
|
if ((token[x] == '+') || (token[x] == '|'))
|
|
|
|
Doit = TRUE;
|
2001-11-25 12:25:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-01-31 21:08:29 +00:00
|
|
|
} /* End if new file entry found */
|
2001-11-25 12:25:59 +00:00
|
|
|
} /* End of files.bbs */
|
|
|
|
fclose(fbbs);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Flush the last file to the database
|
|
|
|
*/
|
|
|
|
if (Append) {
|
|
|
|
Doit = TRUE;
|
|
|
|
if ((unarc = unpacker(temp)) == NULL) {
|
|
|
|
Syslog('+', "Unknown archive format %s", temp);
|
2005-12-03 14:52:34 +00:00
|
|
|
snprintf(temp2, PATH_MAX, "%s/tmp/arc%d/%s", getenv("MBSE_ROOT"), (int)getpid(), f_db.LName);
|
2002-05-18 12:57:00 +00:00
|
|
|
if ((rc = file_cp(temp, temp2))) {
|
|
|
|
WriteError("Can't copy file to %s, %s", temp2, strerror(rc));
|
2001-11-25 12:25:59 +00:00
|
|
|
Doit = FALSE;
|
|
|
|
} else {
|
2002-06-15 14:00:49 +00:00
|
|
|
if (do_novir == FALSE) {
|
|
|
|
if (!do_quiet) {
|
|
|
|
printf("Virscan \b\b\b\b\b\b\b\b\b\b");
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
if (VirScan(tmpdir)) {
|
|
|
|
Doit = FALSE;
|
|
|
|
}
|
2001-11-25 12:25:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!do_quiet) {
|
|
|
|
printf("Unpacking \b\b\b\b\b\b\b\b\b\b");
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
if (UnpackFile(temp)) {
|
2002-06-15 14:00:49 +00:00
|
|
|
if (do_novir == FALSE) {
|
|
|
|
if (!do_quiet) {
|
|
|
|
printf("Virscan \b\b\b\b\b\b\b\b\b\b");
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
if (VirScan(tmpdir)) {
|
|
|
|
Doit = FALSE;
|
|
|
|
}
|
2001-11-25 12:25:59 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Doit = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Doit) {
|
|
|
|
if (!do_quiet) {
|
|
|
|
printf("Adding \b\b\b\b\b\b\b\b\b\b");
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
2004-03-06 21:48:41 +00:00
|
|
|
if (strcmp(f_db.Name, f_db.LName)) {
|
|
|
|
if (AddFile(f_db, Area, dest, temp, lname))
|
2002-11-23 16:48:54 +00:00
|
|
|
Imported++;
|
|
|
|
else
|
|
|
|
Errors++;
|
|
|
|
} else {
|
2004-03-06 21:48:41 +00:00
|
|
|
if (AddFile(f_db, Area, dest, temp, NULL))
|
2002-11-23 16:48:54 +00:00
|
|
|
Imported++;
|
|
|
|
else
|
|
|
|
Errors++;
|
|
|
|
}
|
2001-11-25 12:25:59 +00:00
|
|
|
} else {
|
|
|
|
Errors++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-12-16 19:52:20 +00:00
|
|
|
clean_tmpwork();
|
2005-01-02 15:11:07 +00:00
|
|
|
free(fod);
|
2002-11-23 16:48:54 +00:00
|
|
|
free(lname);
|
2001-11-25 12:25:59 +00:00
|
|
|
free(dest);
|
|
|
|
free(String);
|
|
|
|
free(pwd);
|
|
|
|
free(temp2);
|
|
|
|
free(temp);
|
2002-06-01 12:27:11 +00:00
|
|
|
free(tmpdir);
|
2001-11-25 12:25:59 +00:00
|
|
|
} else {
|
|
|
|
if (!area.Available) {
|
|
|
|
WriteError("Area not available");
|
|
|
|
if (!do_quiet)
|
|
|
|
printf("Area not available\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!do_quiet) {
|
|
|
|
printf("\r \r");
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
Syslog('+', "Import Files [%5d] Imported [%5d] Errors [%5d]", Files, Imported, Errors);
|
|
|
|
}
|
|
|
|
|