Fixes for malformatted file description lines with tic processing
This commit is contained in:
parent
eb93569b53
commit
7e56a3b95a
@ -4743,6 +4743,9 @@ v0.33.20 10-Feb-2002
|
|||||||
removed if they are empty. Good for bulk areas create.
|
removed if they are empty. Good for bulk areas create.
|
||||||
When missing areas are created, uplink requests are sent to
|
When missing areas are created, uplink requests are sent to
|
||||||
connect the areas.
|
connect the areas.
|
||||||
|
Added more checks to processing of file_id.diz files. Also
|
||||||
|
when it is illegal formatted the already processed lines are
|
||||||
|
cleared to prevent later malformatted descriptions.
|
||||||
|
|
||||||
mbmsg:
|
mbmsg:
|
||||||
When creating non-existend message bases, the path is created
|
When creating non-existend message bases, the path is created
|
||||||
@ -4755,6 +4758,8 @@ v0.33.20 10-Feb-2002
|
|||||||
The check function now checks download directory permissions
|
The check function now checks download directory permissions
|
||||||
and tries to correct errors.
|
and tries to correct errors.
|
||||||
Missing download directories are created mode 0775.
|
Missing download directories are created mode 0775.
|
||||||
|
Moved check for empty areas to mbfile check function.
|
||||||
|
The mbfile move command now also moves the thumbnails.
|
||||||
|
|
||||||
mball:
|
mball:
|
||||||
Will not crash anymore when it needs more then 10 minutes to
|
Will not crash anymore when it needs more then 10 minutes to
|
||||||
|
4
TODO
4
TODO
@ -71,10 +71,6 @@ mbfile:
|
|||||||
|
|
||||||
N: Rearc <area>
|
N: Rearc <area>
|
||||||
|
|
||||||
L: When files are moved from one area to another, the thumbnails
|
|
||||||
are not moved. They are recreated later but this can be very
|
|
||||||
time consuming.
|
|
||||||
|
|
||||||
mbaff:
|
mbaff:
|
||||||
L: Add setup parameters for minimum length of keywords.
|
L: Add setup parameters for minimum length of keywords.
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ extern int do_pack; /* Pack filebase */
|
|||||||
void Check(void)
|
void Check(void)
|
||||||
{
|
{
|
||||||
FILE *pAreas, *pFile;
|
FILE *pAreas, *pFile;
|
||||||
int i, iAreas, iAreasNew = 0, Fix;
|
int i, iAreas, iAreasNew = 0, Fix, inArea;
|
||||||
int iTotal = 0, iErrors = 0;
|
int iTotal = 0, iErrors = 0;
|
||||||
char *sAreas, *fAreas, *newdir, *temp;
|
char *sAreas, *fAreas, *newdir, *temp;
|
||||||
DIR *dp;
|
DIR *dp;
|
||||||
@ -193,9 +193,11 @@ void Check(void)
|
|||||||
* Now start checking the files in the filedatabase
|
* Now start checking the files in the filedatabase
|
||||||
* against the contents of the directory.
|
* against the contents of the directory.
|
||||||
*/
|
*/
|
||||||
|
inArea = 0;
|
||||||
while (fread(&file, sizeof(file), 1, pFile) == 1) {
|
while (fread(&file, sizeof(file), 1, pFile) == 1) {
|
||||||
|
|
||||||
iTotal++;
|
iTotal++;
|
||||||
|
inArea++;
|
||||||
sprintf(newdir, "%s/%s", area.Path, file.LName);
|
sprintf(newdir, "%s/%s", area.Path, file.LName);
|
||||||
|
|
||||||
if (file_exist(newdir, R_OK)) {
|
if (file_exist(newdir, R_OK)) {
|
||||||
@ -248,6 +250,8 @@ void Check(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (inArea == 0)
|
||||||
|
Syslog('+', "Warning: area %d (%s) is empty", i, area.Name);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check files in the directory against the database.
|
* Check files in the directory against the database.
|
||||||
|
@ -225,9 +225,6 @@ void Kill(void)
|
|||||||
unlink(sTemp);
|
unlink(sTemp);
|
||||||
chmod(fAreas, 006600);
|
chmod(fAreas, 006600);
|
||||||
}
|
}
|
||||||
if (!FilesLeft) {
|
|
||||||
Syslog('+', "Warning: area %d (%s) is empty", i, area.Name);
|
|
||||||
}
|
|
||||||
} else
|
} else
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
|
|
||||||
|
@ -132,8 +132,26 @@ void Move(int From, int To, char *File)
|
|||||||
while (fread(&fdb, sizeof(fdb), 1, fp1) == 1) {
|
while (fread(&fdb, sizeof(fdb), 1, fp1) == 1) {
|
||||||
if (strcmp(fdb.LName, File))
|
if (strcmp(fdb.LName, File))
|
||||||
fwrite(&fdb, sizeof(fdb), 1, fp2);
|
fwrite(&fdb, sizeof(fdb), 1, fp2);
|
||||||
else
|
else {
|
||||||
rc = AddFile(fdb, To, topath, frompath);
|
rc = AddFile(fdb, To, topath, frompath);
|
||||||
|
if (rc) {
|
||||||
|
/*
|
||||||
|
* Try to move thumbnail if it exists
|
||||||
|
*/
|
||||||
|
unlink(frompath);
|
||||||
|
free(frompath);
|
||||||
|
free(topath);
|
||||||
|
frompath = xstrcpy(area.Path);
|
||||||
|
frompath = xstrcat(frompath, (char *)"/.");
|
||||||
|
frompath = xstrcat(frompath, File);
|
||||||
|
topath = xstrcpy(area.Path);
|
||||||
|
topath = xstrcat(topath, (char *)"/.");
|
||||||
|
topath = xstrcat(topath, File);
|
||||||
|
if (file_exist(frompath, R_OK) == 0) {
|
||||||
|
file_mv(frompath, topath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fclose(fp1);
|
fclose(fp1);
|
||||||
fclose(fp2);
|
fclose(fp2);
|
||||||
@ -149,7 +167,6 @@ void Move(int From, int To, char *File)
|
|||||||
WriteError("$Can't unlink %s", temp1);
|
WriteError("$Can't unlink %s", temp1);
|
||||||
unlink(temp2);
|
unlink(temp2);
|
||||||
}
|
}
|
||||||
unlink(frompath);
|
|
||||||
colour(CYAN, BLACK);
|
colour(CYAN, BLACK);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
|
@ -579,9 +579,7 @@ int ProcessTic(fa_list *sbl)
|
|||||||
if (!Get_File_Id()) {
|
if (!Get_File_Id()) {
|
||||||
if (TIC.TicIn.TotLDesc > 2) {
|
if (TIC.TicIn.TotLDesc > 2) {
|
||||||
for (i = 0; i < TIC.TicIn.TotLDesc; i++) {
|
for (i = 0; i < TIC.TicIn.TotLDesc; i++) {
|
||||||
strcpy(temp1, TIC.TicIn.LDesc[i]);
|
strncpy(TIC.File_Id[i], TIC.TicIn.LDesc[i], 48);
|
||||||
temp1[48] = '\0';
|
|
||||||
strcpy(TIC.File_Id[i], temp1);
|
|
||||||
}
|
}
|
||||||
TIC.File_Id_Ct = TIC.TicIn.TotLDesc;
|
TIC.File_Id_Ct = TIC.TicIn.TotLDesc;
|
||||||
} else {
|
} else {
|
||||||
@ -599,14 +597,18 @@ int ProcessTic(fa_list *sbl)
|
|||||||
j = 48;
|
j = 48;
|
||||||
while (TDesc[j] != ' ')
|
while (TDesc[j] != ' ')
|
||||||
j--;
|
j--;
|
||||||
strncat(TIC.File_Id[TIC.File_Id_Ct], TDesc, j);
|
strncpy(TIC.File_Id[TIC.File_Id_Ct], TDesc, j);
|
||||||
|
Syslog('f', "%2d/%2d: \"%s\"", TIC.File_Id_Ct, j, TIC.File_Id[TIC.File_Id_Ct]);
|
||||||
TIC.File_Id_Ct++;
|
TIC.File_Id_Ct++;
|
||||||
k = strlen(TDesc);
|
k = strlen(TDesc);
|
||||||
j++; /* Correct space */
|
j++; /* Correct space */
|
||||||
for (i = 0; i <= k; i++, j++)
|
for (i = 0; i <= k; i++, j++)
|
||||||
TDesc[i] = TDesc[j];
|
TDesc[i] = TDesc[j];
|
||||||
|
if (TIC.File_Id_Ct == 23)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
strcpy(TIC.File_Id[TIC.File_Id_Ct], TDesc);
|
strncpy(TIC.File_Id[TIC.File_Id_Ct], TDesc, 48);
|
||||||
|
Syslog('f', "%2d/%2d: \"%s\"", TIC.File_Id_Ct, strlen(TIC.File_Id[TIC.File_Id_Ct]), TIC.File_Id[TIC.File_Id_Ct]);
|
||||||
TIC.File_Id_Ct++;
|
TIC.File_Id_Ct++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
23
mbfido/tic.c
23
mbfido/tic.c
@ -165,7 +165,7 @@ int LoadTic(char *inb, char *tfn)
|
|||||||
{
|
{
|
||||||
FILE *tfp;
|
FILE *tfp;
|
||||||
char *Temp, *Temp2, *Buf, *Log = NULL;
|
char *Temp, *Temp2, *Buf, *Log = NULL;
|
||||||
int i, j, rc;
|
int i, j, rc, bufsize;
|
||||||
fa_list *sbl = NULL;
|
fa_list *sbl = NULL;
|
||||||
int DescCnt = FALSE;
|
int DescCnt = FALSE;
|
||||||
|
|
||||||
@ -184,10 +184,15 @@ int LoadTic(char *inb, char *tfn)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Temp = calloc(PATH_MAX, sizeof(char));
|
if (PATH_MAX > 1024)
|
||||||
Buf = calloc(PATH_MAX, sizeof(char));
|
bufsize = PATH_MAX;
|
||||||
|
else
|
||||||
|
bufsize = 1024;
|
||||||
|
Temp = calloc(bufsize+1, sizeof(char));
|
||||||
|
Buf = calloc(bufsize+1, sizeof(char));
|
||||||
|
Syslog('f', "Tic buffersize %d", bufsize);
|
||||||
|
|
||||||
while ((fgets(Buf, PATH_MAX -1, tfp)) != NULL) {
|
while ((fgets(Buf, bufsize, tfp)) != NULL) {
|
||||||
/*
|
/*
|
||||||
* Remove all garbage from the .TIC file.
|
* Remove all garbage from the .TIC file.
|
||||||
*/
|
*/
|
||||||
@ -200,10 +205,10 @@ int LoadTic(char *inb, char *tfn)
|
|||||||
}
|
}
|
||||||
Temp[j] = '\0';
|
Temp[j] = '\0';
|
||||||
|
|
||||||
if (strlen(Temp) > 255) {
|
// if (strlen(Temp) > 255) {
|
||||||
Syslog('+', "Truncating TIC line of %d characters", strlen(Temp));
|
// Syslog('+', "Truncating TIC line of %d characters", strlen(Temp));
|
||||||
Temp[255] = '\0';
|
// Temp[255] = '\0';
|
||||||
}
|
// }
|
||||||
|
|
||||||
Syslog('f', "TIC: %s", Temp);
|
Syslog('f', "TIC: %s", Temp);
|
||||||
if (strncasecmp(Temp, "hatch", 5) == 0) {
|
if (strncasecmp(Temp, "hatch", 5) == 0) {
|
||||||
@ -251,7 +256,7 @@ int LoadTic(char *inb, char *tfn)
|
|||||||
|
|
||||||
} else if (strncasecmp(Temp, "desc ", 5) == 0) {
|
} else if (strncasecmp(Temp, "desc ", 5) == 0) {
|
||||||
if (!DescCnt) {
|
if (!DescCnt) {
|
||||||
strncpy(TIC.TicIn.Desc, Temp+5, 255);
|
strncpy(TIC.TicIn.Desc, Temp+5, 1023);
|
||||||
strncpy(T_File.Desc, TIC.TicIn.Desc, 255);
|
strncpy(T_File.Desc, TIC.TicIn.Desc, 255);
|
||||||
DescCnt = TRUE;
|
DescCnt = TRUE;
|
||||||
} else {
|
} else {
|
||||||
|
@ -17,7 +17,7 @@ typedef struct _tic_in {
|
|||||||
char Created[81]; /* Created text */
|
char Created[81]; /* Created text */
|
||||||
char Path[25][81]; /* Travelled path */
|
char Path[25][81]; /* Travelled path */
|
||||||
int TotPath; /* Nr of pathlines */
|
int TotPath; /* Nr of pathlines */
|
||||||
char Desc[256]; /* Short description */
|
char Desc[1024]; /* Short description */
|
||||||
char Magic[21]; /* Magic alias */
|
char Magic[21]; /* Magic alias */
|
||||||
char Crc[9]; /* CRC of file */
|
char Crc[9]; /* CRC of file */
|
||||||
char Pw[21]; /* Password */
|
char Pw[21]; /* Password */
|
||||||
|
130
mbfido/utic.c
130
mbfido/utic.c
@ -172,74 +172,80 @@ void ReCalcCrc(char *fn)
|
|||||||
|
|
||||||
int Get_File_Id()
|
int Get_File_Id()
|
||||||
{
|
{
|
||||||
char *temp;
|
char *temp;
|
||||||
char Desc[256];
|
char Desc[1024];
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
int i, j, lines = 0;
|
int i, j, lines = 0;
|
||||||
|
|
||||||
temp = calloc(PATH_MAX, sizeof(char));
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
sprintf(temp, "%s/tmp/FILE_ID.DIZ", getenv("MBSE_ROOT"));
|
sprintf(temp, "%s/tmp/FILE_ID.DIZ", getenv("MBSE_ROOT"));
|
||||||
|
if ((fp = fopen(temp, "r")) == NULL) {
|
||||||
|
sprintf(temp, "%s/tmp/file_id.diz", getenv("MBSE_ROOT"));
|
||||||
if ((fp = fopen(temp, "r")) == NULL) {
|
if ((fp = fopen(temp, "r")) == NULL) {
|
||||||
sprintf(temp, "%s/tmp/file_id.diz", getenv("MBSE_ROOT"));
|
free(temp);
|
||||||
if ((fp = fopen(temp, "r")) == NULL) {
|
return FALSE;
|
||||||
free(temp);
|
}
|
||||||
return FALSE;
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Read no more then 25 lines.
|
||||||
|
*/
|
||||||
|
while (((fgets(Desc, 1023, fp)) != NULL) && (TIC.File_Id_Ct < 25)) {
|
||||||
|
lines++;
|
||||||
|
/*
|
||||||
|
* Check if the FILE_ID.DIZ is in a normal layout.
|
||||||
|
* The layout should be max. 10 lines of max. 48 characters.
|
||||||
|
* We check at 51 characters and if the lines are longer,
|
||||||
|
* we trash the FILE_ID.DIZ file.
|
||||||
|
*/
|
||||||
|
if (strlen(Desc) > 51) {
|
||||||
|
fclose(fp);
|
||||||
|
unlink(temp);
|
||||||
|
for (i = 0; i < 25; i++)
|
||||||
|
TIC.File_Id[i][0] = '\0';
|
||||||
|
TIC.File_Id_Ct = 0;
|
||||||
|
Syslog('f', "FILE_ID.DIZ line %d is %d chars", lines, strlen(Desc));
|
||||||
|
Syslog('!', "Trashing illegal formatted FILE_ID.DIZ");
|
||||||
|
free(temp);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen(Desc) > 0) {
|
||||||
|
j = 0;
|
||||||
|
for (i = 0; i < strlen(Desc); i++) {
|
||||||
|
if (isprint(Desc[i])) {
|
||||||
|
TIC.File_Id[TIC.File_Id_Ct][j] = Desc[i];
|
||||||
|
j++;
|
||||||
|
if (j > 47)
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Remove trailing spaces
|
||||||
|
*/
|
||||||
|
while (j && isspace(TIC.File_Id[TIC.File_Id_Ct][j-1]))
|
||||||
|
j--;
|
||||||
|
TIC.File_Id[TIC.File_Id_Ct][j] = '\0';
|
||||||
|
Syslog('f', "%2d/%2d: \"%s\"", TIC.File_Id_Ct, j, TIC.File_Id[TIC.File_Id_Ct]);
|
||||||
|
TIC.File_Id_Ct++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
fclose(fp);
|
||||||
|
unlink(temp);
|
||||||
|
free(temp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read no more then 25 lines.
|
* Strip empty lines at end of FILE_ID.DIZ
|
||||||
*/
|
*/
|
||||||
while (((fgets(Desc, 255, fp)) != NULL) && (TIC.File_Id_Ct < 25)) {
|
while ((strlen(TIC.File_Id[TIC.File_Id_Ct-1]) == 0) && (TIC.File_Id_Ct))
|
||||||
lines++;
|
TIC.File_Id_Ct--;
|
||||||
/*
|
|
||||||
* Check if the FILE_ID.DIZ is in a normal layout.
|
|
||||||
* The layout should be max. 10 lines of max. 48 characters.
|
|
||||||
* We check at 51 characters and if the lines are longer,
|
|
||||||
* we trash the FILE_ID.DIZ file.
|
|
||||||
*/
|
|
||||||
if (strlen(Desc) > 51) {
|
|
||||||
fclose(fp);
|
|
||||||
unlink(temp);
|
|
||||||
TIC.File_Id_Ct = 0;
|
|
||||||
Syslog('f', "FILE_ID.DIZ line %d is %d chars", lines, strlen(Desc));
|
|
||||||
Syslog('!', "Trashing illegal formatted FILE_ID.DIZ");
|
|
||||||
free(temp);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strlen(Desc) > 0) {
|
Syslog('f', "Got %d FILE_ID.DIZ lines", TIC.File_Id_Ct);
|
||||||
j = 0;
|
if (TIC.File_Id_Ct)
|
||||||
for (i = 0; i < strlen(Desc); i++) {
|
return TRUE;
|
||||||
if ((Desc[i] >= ' ') || (Desc[i] < 0)) {
|
else
|
||||||
TIC.File_Id[TIC.File_Id_Ct][j] = Desc[i];
|
return FALSE;
|
||||||
j++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (j >= 48)
|
|
||||||
TIC.File_Id[TIC.File_Id_Ct][48] = '\0';
|
|
||||||
else
|
|
||||||
TIC.File_Id[TIC.File_Id_Ct][j] = '\0';
|
|
||||||
|
|
||||||
TIC.File_Id_Ct++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(fp);
|
|
||||||
unlink(temp);
|
|
||||||
free(temp);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Strip empty lines at end of FILE_ID.DIZ
|
|
||||||
*/
|
|
||||||
while ((strlen(TIC.File_Id[TIC.File_Id_Ct-1]) == 0) && (TIC.File_Id_Ct))
|
|
||||||
TIC.File_Id_Ct--;
|
|
||||||
|
|
||||||
Syslog('f', "Got %d FILE_ID.DIZ lines", TIC.File_Id_Ct);
|
|
||||||
if (TIC.File_Id_Ct)
|
|
||||||
return TRUE;
|
|
||||||
else
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user