Fixed mbfile import problem with one description lines
This commit is contained in:
parent
e2f0391f80
commit
aa2cd9c5e5
@ -50,7 +50,7 @@ void ImportFiles(int Area)
|
|||||||
char *pwd, *temp, *temp2, *String, *token, *dest, *unarc;
|
char *pwd, *temp, *temp2, *String, *token, *dest, *unarc;
|
||||||
FILE *fbbs;
|
FILE *fbbs;
|
||||||
int Append = FALSE, Files = 0, i, j = 0, k = 0, x, Doit;
|
int Append = FALSE, Files = 0, i, j = 0, k = 0, x, Doit;
|
||||||
int Imported = 0, Errors = 0;
|
int Imported = 0, Errors = 0, Present = FALSE;
|
||||||
struct FILERecord fdb;
|
struct FILERecord fdb;
|
||||||
struct stat statfile;
|
struct stat statfile;
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ void ImportFiles(int Area)
|
|||||||
temp = calloc(PATH_MAX, sizeof(char));
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
temp2 = calloc(PATH_MAX, sizeof(char));
|
temp2 = calloc(PATH_MAX, sizeof(char));
|
||||||
pwd = calloc(PATH_MAX, sizeof(char));
|
pwd = calloc(PATH_MAX, sizeof(char));
|
||||||
String = calloc(256, sizeof(char));
|
String = calloc(4096, sizeof(char));
|
||||||
dest = calloc(PATH_MAX, sizeof(char));
|
dest = calloc(PATH_MAX, sizeof(char));
|
||||||
|
|
||||||
getcwd(pwd, PATH_MAX);
|
getcwd(pwd, PATH_MAX);
|
||||||
@ -92,13 +92,13 @@ void ImportFiles(int Area)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (fgets(String, 255, fbbs) != NULL) {
|
while (fgets(String, 4095, fbbs) != NULL) {
|
||||||
|
|
||||||
if ((String[0] != ' ') && (String[0] != 't')) {
|
if ((String[0] != ' ') && (String[0] != 't')) {
|
||||||
/*
|
/*
|
||||||
* New file entry, check if there has been a file that is not yet saved.
|
* New file entry, check if there has been a file that is not yet saved.
|
||||||
*/
|
*/
|
||||||
if (Append) {
|
if (Append && Present) {
|
||||||
Doit = TRUE;
|
Doit = TRUE;
|
||||||
if ((unarc = unpacker(temp)) == NULL) {
|
if ((unarc = unpacker(temp)) == NULL) {
|
||||||
Syslog('+', "Unknown archive format %s", temp);
|
Syslog('+', "Unknown archive format %s", temp);
|
||||||
@ -147,6 +147,7 @@ void ImportFiles(int Area)
|
|||||||
Errors++;
|
Errors++;
|
||||||
}
|
}
|
||||||
Append = FALSE;
|
Append = FALSE;
|
||||||
|
Present = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -157,89 +158,96 @@ void ImportFiles(int Area)
|
|||||||
|
|
||||||
Files++;
|
Files++;
|
||||||
memset(&fdb, 0, sizeof(fdb));
|
memset(&fdb, 0, sizeof(fdb));
|
||||||
|
Present = TRUE;
|
||||||
|
|
||||||
token = strtok(String, " \t");
|
token = strtok(String, " \t");
|
||||||
strcpy(fdb.LName, token);
|
strncpy(fdb.LName, token, 80);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Test filename against name on disk, first normal case,
|
* Test filename against name on disk, first normal case,
|
||||||
* then lowercase and finally uppercase.
|
* then lowercase and finally uppercase.
|
||||||
*/
|
*/
|
||||||
sprintf(temp,"%s/%s", pwd, fdb.LName);
|
sprintf(temp,"%s/%s", pwd, fdb.LName);
|
||||||
if (stat(temp,&statfile) != 0) {
|
if (stat(temp,&statfile) != 0) {
|
||||||
strcpy(fdb.LName, tl(token));
|
strncpy(fdb.LName, tl(token), 80);
|
||||||
sprintf(temp,"%s/%s", pwd, fdb.LName);
|
sprintf(temp,"%s/%s", pwd, fdb.LName);
|
||||||
if (stat(temp,&statfile) != 0) {
|
if (stat(temp,&statfile) != 0) {
|
||||||
strcpy(fdb.LName, tu(token));
|
strcpy(fdb.LName, tu(token));
|
||||||
if (stat(temp,&statfile) != 0) {
|
if (stat(temp,&statfile) != 0) {
|
||||||
WriteError("Cannot locate file on disk! Skipping... -> %s\n",temp);
|
WriteError("Can't find file on disk, skipping: %s\n",temp);
|
||||||
Append = FALSE;
|
Append = FALSE;
|
||||||
|
Present = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
if (Present) {
|
||||||
* Create DOS 8.3 filename
|
/*
|
||||||
*/
|
* Create DOS 8.3 filename
|
||||||
strcpy(temp2, fdb.LName);
|
*/
|
||||||
name_mangle(temp2);
|
strcpy(temp2, fdb.LName);
|
||||||
strcpy(fdb.Name, temp2);
|
name_mangle(temp2);
|
||||||
|
strcpy(fdb.Name, temp2);
|
||||||
|
|
||||||
if (do_annon)
|
if (do_annon)
|
||||||
fdb.Announced = TRUE;
|
fdb.Announced = TRUE;
|
||||||
Syslog('f', "File: %s (%s)", fdb.Name, fdb.LName);
|
Syslog('f', "File: %s (%s)", fdb.Name, fdb.LName);
|
||||||
|
|
||||||
if (!do_quiet) {
|
if (!do_quiet) {
|
||||||
printf("\rImport file: %s ", fdb.Name);
|
printf("\rImport file: %s ", fdb.Name);
|
||||||
printf("Checking \b\b\b\b\b\b\b\b\b\b");
|
printf("Checking \b\b\b\b\b\b\b\b\b\b");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
|
||||||
|
|
||||||
IsDoing("Import %s", fdb.Name);
|
|
||||||
|
|
||||||
token = strtok(NULL, "\0");
|
|
||||||
i = strlen(token);
|
|
||||||
j = k = 0;
|
|
||||||
for (x = 0; x < i; x++) {
|
|
||||||
if ((token[x] == '\n') || (token[x] == '\r'))
|
|
||||||
token[x] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
Doit = FALSE;
|
|
||||||
for (x = 0; x < i; x++) {
|
|
||||||
if (!Doit) {
|
|
||||||
if (isalnum(token[x]))
|
|
||||||
Doit = TRUE;
|
|
||||||
}
|
}
|
||||||
if (Doit) {
|
|
||||||
if (k > 42) {
|
IsDoing("Import %s", fdb.Name);
|
||||||
if (token[x] == ' ') {
|
|
||||||
fdb.Desc[j][k] = '\0';
|
token = strtok(NULL, "\0");
|
||||||
j++;
|
i = strlen(token);
|
||||||
k = 0;
|
j = k = 0;
|
||||||
} else {
|
for (x = 0; x < i; x++) {
|
||||||
if (k == 49) {
|
if ((token[x] == '\n') || (token[x] == '\r'))
|
||||||
|
token[x] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
Doit = FALSE;
|
||||||
|
for (x = 0; x < i; x++) {
|
||||||
|
if (!Doit) {
|
||||||
|
if (isalnum(token[x]))
|
||||||
|
Doit = TRUE;
|
||||||
|
}
|
||||||
|
if (Doit) {
|
||||||
|
if (k > 42) {
|
||||||
|
if (token[x] == ' ') {
|
||||||
fdb.Desc[j][k] = '\0';
|
fdb.Desc[j][k] = '\0';
|
||||||
k = 0;
|
|
||||||
j++;
|
j++;
|
||||||
|
k = 0;
|
||||||
|
} else {
|
||||||
|
if (k == 49) {
|
||||||
|
fdb.Desc[j][k] = '\0';
|
||||||
|
k = 0;
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
fdb.Desc[j][k] = token[x];
|
||||||
|
k++;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
fdb.Desc[j][k] = token[x];
|
fdb.Desc[j][k] = token[x];
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
} else {
|
if (j == 25)
|
||||||
fdb.Desc[j][k] = token[x];
|
break;
|
||||||
k++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
sprintf(dest, "%s/%s", area.Path, fdb.LName);
|
sprintf(dest, "%s/%s", area.Path, fdb.LName);
|
||||||
Append = TRUE;
|
Append = TRUE;
|
||||||
fdb.Size = statfile.st_size;
|
fdb.Size = statfile.st_size;
|
||||||
fdb.FileDate = statfile.st_mtime;
|
fdb.FileDate = statfile.st_mtime;
|
||||||
fdb.Crc32 = file_crc(temp, FALSE);
|
fdb.Crc32 = file_crc(temp, FALSE);
|
||||||
strcpy(fdb.Uploader, CFG.sysop_name);
|
strcpy(fdb.Uploader, CFG.sysop_name);
|
||||||
fdb.UploadDate = time(NULL);
|
fdb.UploadDate = time(NULL);
|
||||||
} else {
|
}
|
||||||
|
} else if (Present) {
|
||||||
/*
|
/*
|
||||||
* Add multiple description lines
|
* Add multiple description lines
|
||||||
*/
|
*/
|
||||||
@ -272,6 +280,8 @@ void ImportFiles(int Area)
|
|||||||
fdb.Desc[j][k] = token[x];
|
fdb.Desc[j][k] = token[x];
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
|
if (j == 25)
|
||||||
|
break;
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Skip until + or | is found
|
* Skip until + or | is found
|
||||||
@ -280,7 +290,7 @@ void ImportFiles(int Area)
|
|||||||
Doit = TRUE;
|
Doit = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} /* End if new file entry found */
|
||||||
} /* End of files.bbs */
|
} /* End of files.bbs */
|
||||||
fclose(fbbs);
|
fclose(fbbs);
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ int LoadTic(char *inb, char *tfn)
|
|||||||
Temp = calloc(PATH_MAX, sizeof(char));
|
Temp = calloc(PATH_MAX, sizeof(char));
|
||||||
Buf = calloc(257, sizeof(char));
|
Buf = calloc(257, sizeof(char));
|
||||||
|
|
||||||
while ((fgets(Buf, 256, tfp)) != NULL) {
|
while ((fgets(Buf, 255, tfp)) != NULL) {
|
||||||
/*
|
/*
|
||||||
* Remove all garbage from the .TIC file.
|
* Remove all garbage from the .TIC file.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user