Corrections for file upload descriptions
This commit is contained in:
parent
ca5faeea0d
commit
040c0a37e5
@ -77,6 +77,12 @@ v0.35.03 06-Jul-2002
|
|||||||
Added test for HA archiver.
|
Added test for HA archiver.
|
||||||
When changing a Handle, Unix names are checked as forbidden
|
When changing a Handle, Unix names are checked as forbidden
|
||||||
names as well.
|
names as well.
|
||||||
|
Improved import of FILE_ID.DIZ with file uploads. Only if
|
||||||
|
FILE_ID.DIZ is processed successfull the user will see that
|
||||||
|
this file has been used.
|
||||||
|
Corrected length for manual file description to prevent string
|
||||||
|
overflow.
|
||||||
|
Added missing space in message to user about file unpack.
|
||||||
|
|
||||||
mbtask:
|
mbtask:
|
||||||
Changed logging of multiple logmessages that are equal.
|
Changed logging of multiple logmessages that are equal.
|
||||||
|
@ -608,7 +608,7 @@ int ScanArchive(char *fn, char *ftype)
|
|||||||
|
|
||||||
colour(CFG.TextColourF, CFG.TextColourB);
|
colour(CFG.TextColourF, CFG.TextColourB);
|
||||||
/* Unpacking archive */
|
/* Unpacking archive */
|
||||||
printf("%s %s", (char *) Language(201), fn);
|
printf("%s %s ", (char *) Language(201), fn);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
if (!strlen(archiver.funarc)) {
|
if (!strlen(archiver.funarc)) {
|
||||||
@ -846,11 +846,9 @@ int ImportFile(char *fn, int Area, int fileid, time_t iTime, off_t Size)
|
|||||||
int Addfile(char *File, int AreaNum, int fileid)
|
int Addfile(char *File, int AreaNum, int fileid)
|
||||||
{
|
{
|
||||||
FILE *id, *pFileDB, *pPrivate;
|
FILE *id, *pFileDB, *pPrivate;
|
||||||
int err = 1, iDesc = 1, iPrivate = FALSE, GotId = FALSE;
|
int err = 1, iDesc = 1, iPrivate = FALSE, GotId = FALSE, lines, i, j;
|
||||||
char *Filename, *temp1, *idname = NULL;
|
char *Filename, *temp1, *idname = NULL, *Desc[26];
|
||||||
char *Desc[26];
|
|
||||||
struct stat statfile;
|
struct stat statfile;
|
||||||
int i;
|
|
||||||
char temp[81];
|
char temp[81];
|
||||||
|
|
||||||
Filename = calloc(PATH_MAX, sizeof(char));
|
Filename = calloc(PATH_MAX, sizeof(char));
|
||||||
@ -927,31 +925,75 @@ int Addfile(char *File, int AreaNum, int fileid)
|
|||||||
if (!err) {
|
if (!err) {
|
||||||
Syslog('+', "Found %s", idname);
|
Syslog('+', "Found %s", idname);
|
||||||
GotId = TRUE;
|
GotId = TRUE;
|
||||||
colour(CFG.TextColourF, CFG.TextColourB);
|
|
||||||
/* Found FILE_ID.DIZ in */
|
|
||||||
printf("%s %s\n", (char *) Language(257), File);
|
|
||||||
fflush(stdout);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GotId) {
|
if (GotId) {
|
||||||
|
lines = 0;
|
||||||
if ((id = fopen(idname, "r")) != NULL) {
|
if ((id = fopen(idname, "r")) != NULL) {
|
||||||
/*
|
/*
|
||||||
* Import FILE_ID.DIZ, format to max. 25
|
* Import FILE_ID.DIZ, format to max. 25
|
||||||
* lines, 48 chars width.
|
* lines, 48 chars width.
|
||||||
*/
|
*/
|
||||||
while ((fgets(temp1, 256, id)) != NULL) {
|
while (((fgets(temp1, PATH_MAX -1, id)) != NULL) && (lines < 25)) {
|
||||||
if (iDesc < 26) {
|
|
||||||
Striplf(temp1);
|
Striplf(temp1);
|
||||||
temp1[48] = '\0';
|
if (strlen(temp1) > 51) {
|
||||||
strcpy(file.Desc[iDesc - 1], temp1);
|
/*
|
||||||
|
* Malformed FILE_ID.DIZ
|
||||||
|
*/
|
||||||
|
GotId = FALSE;
|
||||||
|
for (i = 0; i < 25; i++)
|
||||||
|
file.Desc[i][0] = '\0';
|
||||||
|
lines = 0;
|
||||||
|
Syslog('!', "Trashing illegal formatted FILE_ID.DIZ");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (strlen(temp1) > 0) {
|
||||||
|
j = 0;
|
||||||
|
for (i = 0; i < strlen(temp1); i++) {
|
||||||
|
if (isprint(temp1[i])) {
|
||||||
|
file.Desc[lines][j] = temp1[i];
|
||||||
|
j++;
|
||||||
|
if (j > 47)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Remove trailing spaces
|
||||||
|
*/
|
||||||
|
while (j && isspace(file.Desc[lines][j-1]))
|
||||||
|
j--;
|
||||||
|
file.Desc[lines][j] = '\0';
|
||||||
|
lines++;
|
||||||
}
|
}
|
||||||
iDesc++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(id);
|
fclose(id);
|
||||||
unlink(idname);
|
unlink(idname);
|
||||||
|
|
||||||
|
if (GotId) {
|
||||||
|
/*
|
||||||
|
* Strip empty FILE_ID.DIZ lines at the end
|
||||||
|
*/
|
||||||
|
while ((strlen(file.Desc[lines-1]) == 0) && (lines)) {
|
||||||
|
file.Desc[lines-1][0] = '\0';
|
||||||
|
lines--;
|
||||||
|
}
|
||||||
|
if (lines) {
|
||||||
|
Syslog('+', "Using %d FILE_ID.DIZ lines for description", lines);
|
||||||
|
colour(CFG.TextColourF, CFG.TextColourB);
|
||||||
|
/* Found FILE_ID.DIZ in */
|
||||||
|
printf("%s %s\n", (char *) Language(257), File);
|
||||||
|
fflush(stdout);
|
||||||
} else {
|
} else {
|
||||||
|
Syslog('!', "No FILE_ID.DIZ lines left to use");
|
||||||
|
GotId = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!GotId) {
|
||||||
/*
|
/*
|
||||||
* Ask the user for a description.
|
* Ask the user for a description.
|
||||||
*/
|
*/
|
||||||
@ -967,18 +1009,18 @@ int Addfile(char *File, int AreaNum, int fileid)
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
colour(CFG.InputColourF, CFG.InputColourB);
|
colour(CFG.InputColourF, CFG.InputColourB);
|
||||||
|
|
||||||
GetstrC(*(Desc + iDesc), 48);
|
GetstrC(*(Desc + iDesc), 47);
|
||||||
|
|
||||||
if((strcmp(*(Desc + iDesc), "")) == 0)
|
if ((strcmp(*(Desc + iDesc), "")) == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
iDesc++;
|
iDesc++;
|
||||||
|
|
||||||
if(iDesc >= 26)
|
if (iDesc >= 26)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 1; i < iDesc; i++)
|
for (i = 1; i < iDesc; i++)
|
||||||
strcpy(file.Desc[i - 1], Desc[i]);
|
strcpy(file.Desc[i - 1], Desc[i]);
|
||||||
|
|
||||||
for (i = 0; i < 26; i++)
|
for (i = 0; i < 26; i++)
|
||||||
@ -1000,7 +1042,7 @@ int Addfile(char *File, int AreaNum, int fileid)
|
|||||||
fprintf(pPrivate, "\nSize : %lu", (long)(file.Size));
|
fprintf(pPrivate, "\nSize : %lu", (long)(file.Size));
|
||||||
fprintf(pPrivate, "\nUpload Date : %s\n\n", StrDateDMY(file.UploadDate));
|
fprintf(pPrivate, "\nUpload Date : %s\n\n", StrDateDMY(file.UploadDate));
|
||||||
|
|
||||||
for(i = 0; i < iDesc - 1; i++)
|
for (i = 0; i < iDesc - 1; i++)
|
||||||
fprintf(pPrivate, "%2d: %s\n", i, file.Desc[i]);
|
fprintf(pPrivate, "%2d: %s\n", i, file.Desc[i]);
|
||||||
|
|
||||||
fclose(pPrivate);
|
fclose(pPrivate);
|
||||||
|
Reference in New Issue
Block a user