Added length check when importing taglines

This commit is contained in:
Michiel Broek 2002-11-02 14:52:29 +00:00
parent 5667926eab
commit 5bdc0a6cf6
2 changed files with 156 additions and 153 deletions

View File

@ -47,6 +47,7 @@ v0.35.05 19-Oct-2002
Removed the default Virnet record from the fidonet setup.
In node setup the pack netmail switch is renamed and is now
for all mail.
Added length check when importing taglines.
mbfido:
With ticfile processing, the KeepDate setup setting now works.

View File

@ -404,10 +404,8 @@ void InitOneline(void)
void PurgeOneline(void)
{
FILE *pOneline, *fp;
int recno = 0;
int iCount = 0;
char sFileName[PATH_MAX];
char temp[81];
int recno = 0, iCount = 0;
char *sFileName, temp[81];
clr_index();
set_color(WHITE, BLACK);
@ -422,9 +420,11 @@ void PurgeOneline(void)
IsDoing("Purge Oneliners");
sFileName = calloc(PATH_MAX, sizeof(char));
sprintf(sFileName,"%s/etc/oneline.data", getenv("MBSE_ROOT"));
if ((pOneline = fopen(sFileName, "r")) == NULL) {
free(sFileName);
return;
}
@ -441,6 +441,7 @@ void PurgeOneline(void)
if (iCount == 0) {
mvprintw(9, 6, "Press any key");
readkey(9, 20, LIGHTGRAY, BLACK);
free(sFileName);
return;
}
@ -459,6 +460,7 @@ void PurgeOneline(void)
working(2, 0, 0);
unlink("tmp.1");
working(0, 0, 0);
free(sFileName);
}
}
@ -467,24 +469,27 @@ void PurgeOneline(void)
void ImportOneline(void)
{
FILE *Imp, *pOneline;
char temp[PATH_MAX];
int recno = 0;
int recno = 0, skipped = 0;
struct tm *l_date;
char buf[12];
char *temp, buf[12];
time_t Time;
clr_index();
set_color(WHITE, BLACK);
mvprintw(5, 6, "8.7.3 IMPORT ONELINERS");
set_color(CYAN, BLACK);
temp = calloc(PATH_MAX, sizeof(char));
memset(&temp, 0, sizeof(temp));
strcpy(temp, edit_str(21, 6,64, temp, (char *)"The ^full path and filename^ of the file to import"));
if (strlen(temp) == 0)
if (strlen(temp) == 0) {
free(temp);
return;
}
working(1, 0, 0);
if (config_read() == -1) {
working(2, 0, 0);
free(temp);
return;
}
@ -493,6 +498,7 @@ void ImportOneline(void)
working(0, 0, 0);
mvprintw(21, 6, temp);
readkey(22, 6, LIGHTGRAY, BLACK);
free(temp);
return;
}
@ -520,6 +526,7 @@ void ImportOneline(void)
fclose(Imp);
mvprintw(21, 6, temp);
readkey(22, 6, LIGHTGRAY, BLACK);
free(temp);
return;
}
@ -529,7 +536,7 @@ void ImportOneline(void)
while ((fgets(temp, 80, Imp)) != NULL) {
Striplf(temp);
if ((strlen(temp) > 0) && (strlen(temp) < 78)) {
if ((strlen(temp) > 0) && (strlen(temp) < 69)) {
memset(&ol, 0, sizeof(ol));
strcpy(ol.Oneline, temp);
strcpy(ol.UserName, CFG.sysop_name);
@ -537,6 +544,8 @@ void ImportOneline(void)
ol.Available = TRUE;
fwrite(&ol, sizeof(ol), 1, pOneline);
recno++;
} else {
skipped++;
}
}
@ -544,9 +553,10 @@ void ImportOneline(void)
fclose(pOneline);
working(0, 0, 0);
sprintf(temp, "Imported %d records", recno);
sprintf(temp, "Imported %d records, skipped %d long/empty lines", recno, skipped);
mvprintw(21, 6, temp);
readkey(21, 27, LIGHTGRAY, BLACK);
free(temp);
}
@ -563,21 +573,13 @@ void ol_menu(void)
mvprintw( 9, 6, "3. Import Oneliners");
switch(select_menu(3)) {
case 0:
return;
case 1:
EditOneline();
case 0: return;
case 1: EditOneline();
break;
case 2:
PurgeOneline();
case 2: PurgeOneline();
break;
case 3:
ImportOneline();
case 3: ImportOneline();
break;
}
}
}