Fixed mbfile import problem with one description lines

This commit is contained in:
uid41954 2002-01-31 21:08:29 +00:00
parent e2f0391f80
commit aa2cd9c5e5
2 changed files with 70 additions and 60 deletions

View File

@ -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,26 +158,30 @@ 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
*/ */
@ -229,6 +234,8 @@ void ImportFiles(int Area)
fdb.Desc[j][k] = token[x]; fdb.Desc[j][k] = token[x];
k++; k++;
} }
if (j == 25)
break;
} }
} }
@ -239,7 +246,8 @@ void ImportFiles(int Area)
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);

View File

@ -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.
*/ */