Changed to new modular upload function
This commit is contained in:
parent
0bc80c5eec
commit
d7242cd944
@ -25,9 +25,13 @@ v0.71.0 27-Oct-2004
|
|||||||
Removed support for non-batching protocols (xmodem) and for
|
Removed support for non-batching protocols (xmodem) and for
|
||||||
bidirectional protocols.
|
bidirectional protocols.
|
||||||
Removed Ctrl-F G, this is of no use anymore.
|
Removed Ctrl-F G, this is of no use anymore.
|
||||||
Switched to new modular download function.
|
Switched to new modular download and upload functions.
|
||||||
With download from file areas, the long filename is sent to
|
With download from file areas, the long filename is sent to
|
||||||
the users, we will only support protocols that allow this.
|
the users, we will only support protocols that allow this.
|
||||||
|
When an invalid OLR reply packet is received, it is removed
|
||||||
|
from the users upload directory.
|
||||||
|
We don't reward upload time anymore, only bytes. It's more
|
||||||
|
troubles to implement right then it's worth these days.
|
||||||
|
|
||||||
mbnewusr:
|
mbnewusr:
|
||||||
Rewrote terminal i/o.
|
Rewrote terminal i/o.
|
||||||
@ -41,7 +45,7 @@ v0.71.0 27-Oct-2004
|
|||||||
Changed width of prompt 261.
|
Changed width of prompt 261.
|
||||||
Added prompt 28.
|
Added prompt 28.
|
||||||
Removed leading spaces of prompt 151.
|
Removed leading spaces of prompt 151.
|
||||||
Removed prompt 276.
|
Removed prompts 259 and 276.
|
||||||
|
|
||||||
script:
|
script:
|
||||||
Modified rundoor.sh so that it uses two different dosemu
|
Modified rundoor.sh so that it uses two different dosemu
|
||||||
|
@ -257,7 +257,7 @@
|
|||||||
256 offline.c |Untag Offline Reader message areas
|
256 offline.c |Untag Offline Reader message areas
|
||||||
257 filesub.c |Found FILEID.DIZ in
|
257 filesub.c |Found FILEID.DIZ in
|
||||||
258 file.c |No files marked for download.
|
258 file.c |No files marked for download.
|
||||||
259 filesub.c |extra minutes.
|
259 .c |
|
||||||
260 offline.c |You have selected the following Conference(s):
|
260 offline.c |You have selected the following Conference(s):
|
||||||
261 file.c |Filename Size Date
|
261 file.c |Filename Size Date
|
||||||
262 change.c |Protocol: Can't open protocol file.
|
262 change.c |Protocol: Can't open protocol file.
|
||||||
|
@ -257,7 +257,7 @@ JN|Node onbekend, toch doorgaan [j/N]:
|
|||||||
|Verwijder selectie Offline Reader berichten gebieden
|
|Verwijder selectie Offline Reader berichten gebieden
|
||||||
|FILEID.DIZ gevonden in
|
|FILEID.DIZ gevonden in
|
||||||
|Geen bestanden gemarkeerd voor download.
|
|Geen bestanden gemarkeerd voor download.
|
||||||
|extra minuten.
|
|
|
||||||
|De volgende conferentie(s) zijn geselecteerd:
|
|De volgende conferentie(s) zijn geselecteerd:
|
||||||
|Bestand Grootte Datum
|
|Bestand Grootte Datum
|
||||||
|Protocol: Kan protocollen bestand niet openen.
|
|Protocol: Kan protocollen bestand niet openen.
|
||||||
|
@ -257,7 +257,7 @@ YN|Node not known, continue anyway [y/N]:
|
|||||||
|Untag Offline Reader message areas
|
|Untag Offline Reader message areas
|
||||||
|Found FILEID.DIZ in
|
|Found FILEID.DIZ in
|
||||||
|No files marked for download.
|
|No files marked for download.
|
||||||
|extra minutes.
|
|
|
||||||
|You have selected the following Conference(s):
|
|You have selected the following Conference(s):
|
||||||
|Filename Size Date
|
|Filename Size Date
|
||||||
|Protocol: Can't open protocol file.
|
|Protocol: Can't open protocol file.
|
||||||
|
@ -257,7 +257,7 @@ ON|Node inconnu, continue quand m
|
|||||||
|Untag Offline Reader message areas
|
|Untag Offline Reader message areas
|
||||||
|Found FILEID.DIZ in
|
|Found FILEID.DIZ in
|
||||||
|No files marked for download.
|
|No files marked for download.
|
||||||
|extra minutes.
|
|
|
||||||
|You have selected the following Conference(s):
|
|You have selected the following Conference(s):
|
||||||
|Filename Size Date
|
|Filename Size Date
|
||||||
|Protocol: Can't open protocol file.
|
|Protocol: Can't open protocol file.
|
||||||
|
@ -257,7 +257,7 @@ SN|Nodo desco
|
|||||||
|Desmarcar reas para lectura Off-Line
|
|Desmarcar reas para lectura Off-Line
|
||||||
|Atopado FILEID.DIZ en
|
|Atopado FILEID.DIZ en
|
||||||
|Non hai ficheiros marcados.
|
|Non hai ficheiros marcados.
|
||||||
|minutos extra.
|
|
|
||||||
|Escolleche-las seguintes reas:
|
|Escolleche-las seguintes reas:
|
||||||
|Ficheiro Tama¤o Fecha
|
|Ficheiro Tama¤o Fecha
|
||||||
|Protocolo: Non podo abrir ficheiro de protocolos.
|
|Protocolo: Non podo abrir ficheiro de protocolos.
|
||||||
|
@ -257,7 +257,7 @@ JN|Adresse unbekannt, dennoch fortfahren [j/N]:
|
|||||||
|Mitteilungsbereiche fuer den "Offline Reader" abwaehlen
|
|Mitteilungsbereiche fuer den "Offline Reader" abwaehlen
|
||||||
|FILEID.DIZ gefunden in
|
|FILEID.DIZ gefunden in
|
||||||
|Es sind keine Dateien zum Herunterladen markiert.
|
|Es sind keine Dateien zum Herunterladen markiert.
|
||||||
|extra Minuten.
|
|
|
||||||
|Sie haben folgende Bereiche fuer den "Offline Reader" markiert:
|
|Sie haben folgende Bereiche fuer den "Offline Reader" markiert:
|
||||||
|Dateiname Groesse Datum
|
|Dateiname Groesse Datum
|
||||||
|Protokoll: Protokolldatei kann nicht geoeffnet werden.
|
|Protokoll: Protokolldatei kann nicht geoeffnet werden.
|
||||||
|
@ -257,7 +257,7 @@ JN|Adresse unbekannt, dennoch fortfahren [<j>a/<N>ein]:
|
|||||||
|Mitteilungsbereiche fuer den "Offline Reader" abwaehlen
|
|Mitteilungsbereiche fuer den "Offline Reader" abwaehlen
|
||||||
|FILEID.DIZ gefunden in
|
|FILEID.DIZ gefunden in
|
||||||
|Es sind keine Dateien zum Herunterladen markiert.
|
|Es sind keine Dateien zum Herunterladen markiert.
|
||||||
|extra Minuten.
|
|
|
||||||
|Du hast folgende Bereiche fuer den "Offline Reader" markiert:
|
|Du hast folgende Bereiche fuer den "Offline Reader" markiert:
|
||||||
|Dateiname Groesse Datum
|
|Dateiname Groesse Datum
|
||||||
|Protokoll: Protokolldatei kann nicht geoeffnet werden.
|
|Protokoll: Protokolldatei kann nicht geoeffnet werden.
|
||||||
|
@ -257,7 +257,7 @@ SN|Nodo sconosciuto, continua lo stesso [s/N]:
|
|||||||
|Untag aree messaggi per l'Offline Reader
|
|Untag aree messaggi per l'Offline Reader
|
||||||
|Trovato FILEID.DIZ in
|
|Trovato FILEID.DIZ in
|
||||||
|Nessun file selezionato per il download.
|
|Nessun file selezionato per il download.
|
||||||
|minuti extra.
|
|
|
||||||
|Hai selezionato le seguenti Conferenze:
|
|Hai selezionato le seguenti Conferenze:
|
||||||
|Filename Dimensione Data
|
|Filename Dimensione Data
|
||||||
|Protocollo: Non posso aprire il file del protocollo.
|
|Protocollo: Non posso aprire il file del protocollo.
|
||||||
|
@ -257,7 +257,7 @@ SN|Nodo desconocido.
|
|||||||
|Desmarcar reas para lectura Off-Line
|
|Desmarcar reas para lectura Off-Line
|
||||||
|Encontrado FILEID.DIZ en
|
|Encontrado FILEID.DIZ en
|
||||||
|No hay ficheros marcados.
|
|No hay ficheros marcados.
|
||||||
|minutos extra.
|
|
|
||||||
|Has seleccionado las siguientes reas:
|
|Has seleccionado las siguientes reas:
|
||||||
|Fichero Tama¤o Fecha
|
|Fichero Tama¤o Fecha
|
||||||
|Protocolo: No puedo abrir fichero de protocolos.
|
|Protocolo: No puedo abrir fichero de protocolos.
|
||||||
|
309
mbsebbs/file.c
309
mbsebbs/file.c
@ -882,24 +882,12 @@ int NewfileScan(int AskStart)
|
|||||||
*/
|
*/
|
||||||
int Upload()
|
int Upload()
|
||||||
{
|
{
|
||||||
char temp[81];
|
int Area, rc;
|
||||||
int Area, err;
|
|
||||||
unsigned long OldArea;
|
unsigned long OldArea;
|
||||||
time_t ElapstimeStart, ElapstimeFin, iTime;
|
char *arc, *temp;
|
||||||
DIR *dirp;
|
up_list *up = NULL, *tmpf;
|
||||||
struct dirent *dp;
|
|
||||||
struct stat statfile;
|
|
||||||
char *arc;
|
|
||||||
|
|
||||||
|
|
||||||
WhosDoingWhat(UPLOAD, NULL);
|
WhosDoingWhat(UPLOAD, NULL);
|
||||||
|
|
||||||
/*
|
|
||||||
* Select default protocol if users hasn't any.
|
|
||||||
*/
|
|
||||||
if (!ForceProtocol())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
Enter(1);
|
Enter(1);
|
||||||
Area = OldArea = iAreaNumber;
|
Area = OldArea = iAreaNumber;
|
||||||
|
|
||||||
@ -910,8 +898,6 @@ int Upload()
|
|||||||
if (area.Upload)
|
if (area.Upload)
|
||||||
Area = area.Upload;
|
Area = area.Upload;
|
||||||
SetFileArea(Area);
|
SetFileArea(Area);
|
||||||
|
|
||||||
SetFileArea(Area);
|
|
||||||
Syslog('+', "Upload area is %d %s", Area, area.Name);
|
Syslog('+', "Upload area is %d %s", Area, area.Name);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -929,113 +915,66 @@ int Upload()
|
|||||||
|
|
||||||
clear();
|
clear();
|
||||||
Enter(2);
|
Enter(2);
|
||||||
colour(CFG.HiliteF, CFG.HiliteB);
|
|
||||||
/* Please start your upload now ...*/
|
|
||||||
pout(CFG.HiliteF, CFG.HiliteB, sProtAdvice);
|
|
||||||
PUTCHAR(' ');
|
|
||||||
PUTSTR((char *) Language(283));
|
|
||||||
Enter(2);
|
|
||||||
|
|
||||||
Syslog('+', "Upload using %s", sProtName);
|
rc = upload(&up);
|
||||||
|
|
||||||
sprintf(temp, "%s/%s/upl", CFG.bbs_usersdir, exitinfo.Name);
|
if (rc) {
|
||||||
if (chdir(temp)) {
|
Syslog('+', "Upload failed, rc=%d", rc);
|
||||||
WriteError("$Can't chdir to %s", temp);
|
|
||||||
SetFileArea(OldArea);
|
SetFileArea(OldArea);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Syslog('b', "upload done, start checks");
|
||||||
sleep(2);
|
|
||||||
ElapstimeStart = time(NULL);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get the file(s). Set the Client/Server time to 2 hours.
|
|
||||||
* This is not a nice solution, at least it works and prevents
|
|
||||||
* that the bbs will hang.
|
|
||||||
*/
|
|
||||||
Altime(7200);
|
|
||||||
alarm_set(7190);
|
|
||||||
err = execute_str(sProtUp, (char *)"", NULL, NULL, NULL, NULL);
|
|
||||||
rawport();
|
|
||||||
|
|
||||||
if (err) {
|
|
||||||
/*
|
|
||||||
* Log any errors
|
|
||||||
*/
|
|
||||||
WriteError("$Upload error %d, prot: %s", err, sProtUp);
|
|
||||||
}
|
|
||||||
Altime(0);
|
|
||||||
alarm_off();
|
|
||||||
alarm_on();
|
|
||||||
Enter(3);
|
|
||||||
ElapstimeFin = time(NULL);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get time from Before Upload and After Upload to get
|
|
||||||
* upload time, if the time is zero, it will be one.
|
|
||||||
*/
|
|
||||||
iTime = ElapstimeFin - ElapstimeStart;
|
|
||||||
if (!iTime)
|
|
||||||
iTime = 1;
|
|
||||||
|
|
||||||
Syslog('b', "Transfer time %ld", iTime);
|
|
||||||
|
|
||||||
if ((dirp = opendir(".")) == NULL) {
|
|
||||||
WriteError("$Upload: can't open ./upl");
|
|
||||||
Home();
|
|
||||||
SetFileArea(OldArea);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Enter(2);
|
Enter(2);
|
||||||
pout(CFG.UnderlineColourF, CFG.UnderlineColourB, (char *)"Checking your upload(s)");
|
pout(CFG.UnderlineColourF, CFG.UnderlineColourB, (char *)"Checking your upload(s)");
|
||||||
Enter(1);
|
Enter(1);
|
||||||
|
|
||||||
while ((dp = readdir(dirp)) != NULL) {
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
if (*(dp->d_name) != '.') {
|
for (tmpf = up; tmpf; tmpf = tmpf->next) {
|
||||||
stat(dp->d_name, &statfile);
|
sprintf(temp, "%s/%s/upl", CFG.bbs_usersdir, exitinfo.Name);
|
||||||
Syslog('+', "Uploaded \"%s\", %ld bytes", dp->d_name, statfile.st_size);
|
chdir(temp);
|
||||||
|
|
||||||
if ((arc = GetFileType(dp->d_name)) == NULL) {
|
Syslog('b', "Checking upload %s", tmpf->filename);
|
||||||
/*
|
if ((arc = GetFileType(tmpf->filename)) == NULL) {
|
||||||
* If the filetype is unknown, it is probably
|
/*
|
||||||
* a textfile or so. Import it direct.
|
* If the filetype is unknown, it is probably
|
||||||
*/
|
* a textfile or so. Import it direct.
|
||||||
Syslog('b', "Unknown file type");
|
*/
|
||||||
if (!ScanDirect(dp->d_name))
|
Syslog('b', "Unknown file type");
|
||||||
ImportFile(dp->d_name, Area, FALSE, iTime, statfile.st_size);
|
if (!ScanDirect(basename(tmpf->filename)))
|
||||||
|
ImportFile(tmpf->filename, Area, FALSE, tmpf->size);
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* We figured out the type of the uploaded file.
|
||||||
|
*/
|
||||||
|
Syslog('b', "File type is %s", arc);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* MS-DOS executables are handled direct.
|
||||||
|
*/
|
||||||
|
if ((strcmp("EXE", arc) == 0) || (strcmp("COM", arc) == 0)) {
|
||||||
|
if (!ScanDirect(basename(tmpf->filename)))
|
||||||
|
ImportFile(tmpf->filename, Area, FALSE, tmpf->size);
|
||||||
} else {
|
} else {
|
||||||
/*
|
switch (ScanArchive(basename(tmpf->filename), arc)) {
|
||||||
* We figured out the type of the uploaded file.
|
case 0: ImportFile(tmpf->filename, Area, TRUE, tmpf->size);
|
||||||
*/
|
break;
|
||||||
Syslog('b', "File type is %s", arc);
|
case 1: break;
|
||||||
|
case 2: break;
|
||||||
/*
|
case 3: /*
|
||||||
* MS-DOS executables are handled direct.
|
* No valid unarchiver found, just import after scanning,
|
||||||
*/
|
* may catch macro viri.
|
||||||
if ((strcmp("EXE", arc) == 0) || (strcmp("COM", arc) == 0)) {
|
*/
|
||||||
if (!ScanDirect(dp->d_name))
|
if (!ScanDirect(basename(tmpf->filename)))
|
||||||
ImportFile(dp->d_name, Area, FALSE, iTime, statfile.st_size);
|
ImportFile(tmpf->filename, Area, FALSE, tmpf->size);
|
||||||
} else {
|
break;
|
||||||
switch (ScanArchive(dp->d_name, arc)) {
|
|
||||||
case 0: ImportFile(dp->d_name, Area, TRUE, iTime, statfile.st_size);
|
|
||||||
break;
|
|
||||||
case 1: break;
|
|
||||||
case 2: break;
|
|
||||||
case 3: /*
|
|
||||||
* No valid unarchiver found, just import after scanning,
|
|
||||||
* may catch macro viri.
|
|
||||||
*/
|
|
||||||
if (!ScanDirect(dp->d_name))
|
|
||||||
ImportFile(dp->d_name, Area, FALSE, iTime, statfile.st_size);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir(dirp);
|
|
||||||
|
|
||||||
|
tidy_upload(&up);
|
||||||
|
free(temp);
|
||||||
Home();
|
Home();
|
||||||
SetFileArea(OldArea);
|
SetFileArea(OldArea);
|
||||||
Pause();
|
Pause();
|
||||||
@ -1168,7 +1107,7 @@ void List_Home()
|
|||||||
*/
|
*/
|
||||||
void Delete_Home()
|
void Delete_Home()
|
||||||
{
|
{
|
||||||
char *temp, *temp1;
|
char *temp, *temp1, msg[81];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
temp = calloc(PATH_MAX, sizeof(char));
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
@ -1198,8 +1137,8 @@ void Delete_Home()
|
|||||||
if ((access(temp, R_OK)) == 0) {
|
if ((access(temp, R_OK)) == 0) {
|
||||||
Enter(1);
|
Enter(1);
|
||||||
/* Delete file: */ /* Are you Sure? [Y/n]: */
|
/* Delete file: */ /* Are you Sure? [Y/n]: */
|
||||||
sprintf(temp1, "%s %s, %s", (char *) Language(368), temp1, (char *) Language(369));
|
sprintf(msg, "%s %s, %s", (char *) Language(368), temp1, (char *) Language(369));
|
||||||
pout(LIGHTGREEN, BLACK, temp1);
|
pout(LIGHTGREEN, BLACK, msg);
|
||||||
i = toupper(Readkey());
|
i = toupper(Readkey());
|
||||||
|
|
||||||
if (i == Keystroke(369, 0) || i == 13) {
|
if (i == Keystroke(369, 0) || i == 13) {
|
||||||
@ -1306,80 +1245,22 @@ int Download_Home()
|
|||||||
*/
|
*/
|
||||||
int Upload_Home()
|
int Upload_Home()
|
||||||
{
|
{
|
||||||
DIR *dirp;
|
char *temp, *arc;
|
||||||
struct dirent *dp;
|
int rc = 0, Count = 0;
|
||||||
char *File, *sFileName, *temp, *arc;
|
up_list *up = NULL, *tmpf;
|
||||||
time_t ElapstimeStart, ElapstimeFin, iTime;
|
|
||||||
int err;
|
|
||||||
struct stat statfile;
|
|
||||||
|
|
||||||
WhosDoingWhat(UPLOAD, NULL);
|
WhosDoingWhat(UPLOAD, NULL);
|
||||||
if (!ForceProtocol())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
File = calloc(PATH_MAX, sizeof(char));
|
|
||||||
sFileName = calloc(PATH_MAX, sizeof(char));
|
|
||||||
temp = calloc(PATH_MAX, sizeof(char));
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
Enter(2);
|
Enter(2);
|
||||||
/* Please start your upload now ...*/
|
|
||||||
sprintf(temp, "%s, %s", sProtAdvice, (char *) Language(283));
|
|
||||||
pout(CFG.HiliteF, CFG.HiliteB, temp);
|
|
||||||
Enter(2);
|
|
||||||
Syslog('+', "Upload using %s", sProtName);
|
|
||||||
|
|
||||||
sprintf(temp, "%s/%s/upl", CFG.bbs_usersdir, exitinfo.Name);
|
rc = upload(&up);
|
||||||
if (chdir(temp)) {
|
|
||||||
WriteError("$Can't chdir to %s", temp);
|
|
||||||
free(File);
|
|
||||||
free(sFileName);
|
|
||||||
free(temp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
sleep(2);
|
if (rc) {
|
||||||
ElapstimeStart = time(NULL);
|
Syslog('+', "Upload home failed, rc=%d", rc);
|
||||||
|
|
||||||
/*
|
|
||||||
* Get the file(s). Set the Client/Server time to 2 hours.
|
|
||||||
* This is not a nice solution, at least it works and prevents
|
|
||||||
* that the bbs will hang.
|
|
||||||
*/
|
|
||||||
Altime(7200);
|
|
||||||
alarm_set(7190);
|
|
||||||
err = execute_str(sProtUp, (char *)"", NULL, NULL, NULL, NULL);
|
|
||||||
rawport();
|
|
||||||
|
|
||||||
if (err) {
|
|
||||||
/*
|
|
||||||
* Log any errors
|
|
||||||
*/
|
|
||||||
WriteError("$Upload error %d, prot: %s", err, sProtUp);
|
|
||||||
}
|
|
||||||
|
|
||||||
Altime(0);
|
|
||||||
alarm_off();
|
|
||||||
alarm_on();
|
|
||||||
Enter(3);
|
|
||||||
ElapstimeFin = time(NULL);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get time from Before Upload and After Upload to get
|
|
||||||
* upload time, if the time is zero, it will be one.
|
|
||||||
*/
|
|
||||||
iTime = ElapstimeFin - ElapstimeStart;
|
|
||||||
if (!iTime)
|
|
||||||
iTime = 1;
|
|
||||||
|
|
||||||
Syslog('b', "Transfer time %ld", iTime);
|
|
||||||
|
|
||||||
if ((dirp = opendir(".")) == NULL) {
|
|
||||||
WriteError("$Upload: can't open ./upl");
|
|
||||||
Home();
|
Home();
|
||||||
free(File);
|
|
||||||
free(sFileName);
|
|
||||||
free(temp);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1388,60 +1269,60 @@ int Upload_Home()
|
|||||||
pout(CFG.UnderlineColourF, CFG.UnderlineColourB, (char *)"Checking your upload(s)");
|
pout(CFG.UnderlineColourF, CFG.UnderlineColourB, (char *)"Checking your upload(s)");
|
||||||
Enter(2);
|
Enter(2);
|
||||||
|
|
||||||
while ((dp = readdir(dirp)) != NULL) {
|
for (tmpf = up; tmpf; tmpf = tmpf->next) {
|
||||||
|
sprintf(temp, "%s/%s/upl", CFG.bbs_usersdir, exitinfo.Name);
|
||||||
|
chdir(temp);
|
||||||
|
|
||||||
if (*(dp->d_name) != '.') {
|
Syslog('b', "Checking upload %s", tmpf->filename);
|
||||||
stat(dp->d_name, &statfile);
|
if ((arc = GetFileType(tmpf->filename)) == NULL) {
|
||||||
Syslog('+', "Uploaded \"%s\", %ld bytes", dp->d_name, statfile.st_size);
|
/*
|
||||||
|
* If the filetype is unknown, it is probably
|
||||||
|
* a textfile or so. Import it direct.
|
||||||
|
*/
|
||||||
|
Syslog('b', "Unknown file type");
|
||||||
|
ImportHome(basename(tmpf->filename));
|
||||||
|
Count++;
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* We figured out the type of the uploaded file.
|
||||||
|
*/
|
||||||
|
Syslog('b', "File type is %s", arc);
|
||||||
|
|
||||||
if ((arc = GetFileType(dp->d_name)) == NULL) {
|
/*
|
||||||
/*
|
* MS-DOS executables are handled direct.
|
||||||
* If the filetype is unknown, it is probably
|
*/
|
||||||
* a textfile or so. Import it direct.
|
if ((strcmp("EXE", arc) == 0) || (strcmp("COM", arc) == 0)) {
|
||||||
*/
|
if (!ScanDirect(basename(tmpf->filename))) {
|
||||||
Syslog('b', "Unknown file type");
|
ImportHome(basename(tmpf->filename));
|
||||||
ImportHome(dp->d_name);
|
Count++;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/*
|
switch(ScanArchive(basename(tmpf->filename), arc)) {
|
||||||
* We figured out the type of the uploaded file.
|
case 0: ImportHome(basename(tmpf->filename));
|
||||||
*/
|
Count++;
|
||||||
Syslog('b', "File type is %s", arc);
|
break;
|
||||||
|
case 1: break;
|
||||||
/*
|
case 2: break;
|
||||||
* MS-DOS executables are handled direct.
|
case 3: /*
|
||||||
*/
|
* No valid unarchiver found, just import
|
||||||
if ((strcmp("EXE", arc) == 0) || (strcmp("COM", arc) == 0)) {
|
*/
|
||||||
if (!ScanDirect(dp->d_name))
|
ImportHome(basename(tmpf->filename));
|
||||||
ImportHome(dp->d_name);
|
Count++;
|
||||||
} else {
|
break;
|
||||||
switch(ScanArchive(dp->d_name, arc)) {
|
|
||||||
case 0: ImportHome(dp->d_name);
|
|
||||||
break;
|
|
||||||
case 1: break;
|
|
||||||
case 2: break;
|
|
||||||
case 3: /*
|
|
||||||
* No valid unarchiver found, just import
|
|
||||||
*/
|
|
||||||
ImportHome(dp->d_name);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir(dirp);
|
|
||||||
Home();
|
Home();
|
||||||
|
|
||||||
ReadExitinfo();
|
ReadExitinfo();
|
||||||
exitinfo.Uploads++;
|
exitinfo.Uploads += Count;
|
||||||
WriteExitinfo();
|
WriteExitinfo();
|
||||||
|
|
||||||
|
tidy_upload(&up);
|
||||||
Pause();
|
Pause();
|
||||||
free(File);
|
|
||||||
free(sFileName);
|
|
||||||
free(temp);
|
free(temp);
|
||||||
return 1;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -759,20 +759,20 @@ char *GetFileType(char *fn)
|
|||||||
/*
|
/*
|
||||||
* Import file in area. Returns TRUE if successfull.
|
* Import file in area. Returns TRUE if successfull.
|
||||||
*/
|
*/
|
||||||
int ImportFile(char *fn, int Area, int fileid, time_t iTime, off_t Size)
|
int ImportFile(char *fn, int Area, int fileid, off_t Size)
|
||||||
{
|
{
|
||||||
char *temp, *temp1, msg[81];
|
char *temp, *temp1, msg[81];
|
||||||
|
|
||||||
temp = calloc(PATH_MAX, sizeof(char));
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
temp1 = calloc(PATH_MAX, sizeof(char));
|
temp1 = calloc(PATH_MAX, sizeof(char));
|
||||||
sprintf(temp, "%s/%s", area.Path, fn);
|
sprintf(temp, "%s/%s", area.Path, basename(fn));
|
||||||
sprintf(temp1, "%s/%s/upl/%s", CFG.bbs_usersdir, exitinfo.Name, fn);
|
sprintf(temp1, "%s", fn);
|
||||||
|
|
||||||
if ((file_mv(temp1, temp))) {
|
if ((file_mv(temp1, temp))) {
|
||||||
WriteError("$Can't move %s to %s", fn, area.Path);
|
WriteError("$Can't move %s to %s", fn, area.Path);
|
||||||
} else {
|
} else {
|
||||||
chmod(temp, 0664);
|
chmod(temp, 0664);
|
||||||
if (Addfile(fn, Area, fileid)) {
|
if (Addfile(basename(fn), Area, fileid)) {
|
||||||
|
|
||||||
ReadExitinfo();
|
ReadExitinfo();
|
||||||
|
|
||||||
@ -794,13 +794,6 @@ int ImportFile(char *fn, int Area, int fileid, time_t iTime, off_t Size)
|
|||||||
Syslog('b', "DownloadKToday %d", exitinfo.DownloadKToday);
|
Syslog('b', "DownloadKToday %d", exitinfo.DownloadKToday);
|
||||||
}
|
}
|
||||||
|
|
||||||
iTime /= 60; /* Divide Seconds by 60 to give minutes */
|
|
||||||
/* You have */ /* extra minutes. */
|
|
||||||
sprintf(msg, "%s %ld %s", (char *) Language(249), iTime, (char *) Language(259));
|
|
||||||
PUTSTR(msg);
|
|
||||||
Enter(1);
|
|
||||||
exitinfo.iTimeLeft += iTime;
|
|
||||||
|
|
||||||
WriteExitinfo();
|
WriteExitinfo();
|
||||||
free(temp);
|
free(temp);
|
||||||
free(temp1);
|
free(temp1);
|
||||||
|
@ -20,7 +20,7 @@ char *GetFileType(char *);
|
|||||||
void Home(void);
|
void Home(void);
|
||||||
int ScanDirect(char *);
|
int ScanDirect(char *);
|
||||||
int ScanArchive(char *, char *);
|
int ScanArchive(char *, char *);
|
||||||
int ImportFile(char *, int, int, time_t, off_t);
|
int ImportFile(char *, int, int, off_t);
|
||||||
unsigned long Quota(void);
|
unsigned long Quota(void);
|
||||||
void ImportHome(char *);
|
void ImportHome(char *);
|
||||||
|
|
||||||
|
@ -1011,10 +1011,10 @@ USHORT TOffline::TooOld (ULONG Restrict, class TMsgBase *Msg)
|
|||||||
*/
|
*/
|
||||||
void OLR_Upload(void)
|
void OLR_Upload(void)
|
||||||
{
|
{
|
||||||
char *File, *temp, *Arc, Dirpath[PATH_MAX], Filename[81], msg[81];
|
char *File, *temp, *Arc, Dirpath[PATH_MAX], Filename[81];
|
||||||
time_t ElapstimeStart, ElapstimeFin, iTime;
|
int rc = 0, RetVal = FALSE;
|
||||||
int err, RetVal = FALSE;
|
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
up_list *up = NULL, *tmpf;
|
||||||
|
|
||||||
if (strlen(CFG.bbsid) == 0) {
|
if (strlen(CFG.bbsid) == 0) {
|
||||||
PUTSTR((char *)"System configuration error, inform sysop");
|
PUTSTR((char *)"System configuration error, inform sysop");
|
||||||
@ -1029,57 +1029,17 @@ void OLR_Upload(void)
|
|||||||
/* Offline Reader Upload */
|
/* Offline Reader Upload */
|
||||||
poutCR(LIGHTMAGENTA, BLACK, (char *)Language(439));
|
poutCR(LIGHTMAGENTA, BLACK, (char *)Language(439));
|
||||||
|
|
||||||
if (!ForceProtocol())
|
|
||||||
return;
|
|
||||||
|
|
||||||
File = calloc(PATH_MAX, sizeof(char));
|
File = calloc(PATH_MAX, sizeof(char));
|
||||||
temp = calloc(PATH_MAX, sizeof(char));
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
|
|
||||||
Enter(1);
|
Enter(1);
|
||||||
/* Please start your upload now */
|
|
||||||
sprintf(msg, "%s, %s", sProtAdvice, (char *) Language(283));
|
|
||||||
pout(CFG.HiliteF, CFG.HiliteB, msg);
|
|
||||||
Enter(2);
|
|
||||||
Syslog('+', "Upload using %s", sProtName);
|
|
||||||
|
|
||||||
sprintf(temp, "%s/%s/upl", CFG.bbs_usersdir, exitinfo.Name);
|
if ((rc = upload(&up))) {
|
||||||
|
Syslog('+', "Upload failed, rc=%d", rc);
|
||||||
if (chdir(temp)) {
|
|
||||||
WriteError("$Can't chdir to %s", temp);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep(2);
|
|
||||||
ElapstimeStart = time(NULL);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get the file
|
|
||||||
*/
|
|
||||||
Altime(7200);
|
|
||||||
alarm_set(7190);
|
|
||||||
err = execute_str(sProtUp, (char *)"", NULL, NULL, NULL, NULL);
|
|
||||||
if (rawport() != 0) {
|
|
||||||
WriteError("Unable to set raw mode");
|
|
||||||
}
|
|
||||||
if (err) {
|
|
||||||
WriteError("$Upload error %d, prot: %s", err, sProtUp);
|
|
||||||
}
|
|
||||||
Altime(0);
|
|
||||||
alarm_off();
|
|
||||||
alarm_on();
|
|
||||||
|
|
||||||
Enter(1);
|
|
||||||
ElapstimeFin = time(NULL);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get the upload time.
|
|
||||||
*/
|
|
||||||
iTime = ElapstimeFin - ElapstimeStart;
|
|
||||||
if (!iTime)
|
|
||||||
iTime = 1;
|
|
||||||
|
|
||||||
Syslog('m', "Transfer time %ld", iTime);
|
|
||||||
Home();
|
Home();
|
||||||
|
Enter(1);
|
||||||
|
|
||||||
sprintf(Dirpath, "%s/%s/upl", CFG.bbs_usersdir, exitinfo.Name);
|
sprintf(Dirpath, "%s/%s/upl", CFG.bbs_usersdir, exitinfo.Name);
|
||||||
sprintf(Filename, "%s.NEW", CFG.bbsid);
|
sprintf(Filename, "%s.NEW", CFG.bbsid);
|
||||||
@ -1097,12 +1057,18 @@ void OLR_Upload(void)
|
|||||||
|
|
||||||
if (RetVal == FALSE) {
|
if (RetVal == FALSE) {
|
||||||
WriteError("Invalid OLR packed received");
|
WriteError("Invalid OLR packed received");
|
||||||
|
for (tmpf = up; tmpf; tmpf = tmpf->next) {
|
||||||
|
Syslog('+', "Delete %s", tmpf->filename);
|
||||||
|
unlink(tmpf->filename);
|
||||||
|
}
|
||||||
|
tidy_upload(&up);
|
||||||
/* Invalid packet received */
|
/* Invalid packet received */
|
||||||
pout(LIGHTRED, BLACK, (char *)Language(440));
|
pout(LIGHTRED, BLACK, (char *)Language(440));
|
||||||
Enter(2);
|
Enter(2);
|
||||||
sleep(2);
|
sleep(3);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
tidy_upload(&up);
|
||||||
|
|
||||||
sprintf(File, "%s/%s", Dirpath, Filename);
|
sprintf(File, "%s/%s", Dirpath, Filename);
|
||||||
Syslog('+', "Received OLR packet %s", File);
|
Syslog('+', "Received OLR packet %s", File);
|
||||||
@ -1112,6 +1078,7 @@ void OLR_Upload(void)
|
|||||||
poutCR(LIGHTRED, BLACK, (char *)Language(441));
|
poutCR(LIGHTRED, BLACK, (char *)Language(441));
|
||||||
Syslog('+', "Unknown compression type");
|
Syslog('+', "Unknown compression type");
|
||||||
Pause();
|
Pause();
|
||||||
|
unlink(File);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1134,6 +1101,7 @@ void OLR_Upload(void)
|
|||||||
/* Archiver not available */
|
/* Archiver not available */
|
||||||
poutCR(LIGHTRED, BLACK, (char *)Language(442));
|
poutCR(LIGHTRED, BLACK, (char *)Language(442));
|
||||||
Pause();
|
Pause();
|
||||||
|
unlink(File);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1147,11 +1115,11 @@ void OLR_Upload(void)
|
|||||||
Syslog('m', "Unarc %s", temp);
|
Syslog('m', "Unarc %s", temp);
|
||||||
colour(CFG.HiliteF, CFG.HiliteB);
|
colour(CFG.HiliteF, CFG.HiliteB);
|
||||||
|
|
||||||
err = execute_str(archiver.funarc, File, NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
|
rc = execute_str(archiver.funarc, File, NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
|
||||||
if (rawport() != 0) {
|
if (rawport() != 0) {
|
||||||
WriteError("Unable to set raw mode");
|
WriteError("Unable to set raw mode");
|
||||||
}
|
}
|
||||||
if (err) {
|
if (rc) {
|
||||||
WriteError("$Failed %s", temp);
|
WriteError("$Failed %s", temp);
|
||||||
/* ERROR */
|
/* ERROR */
|
||||||
poutCR(LIGHTRED, BLACK, (char *) Language(217));
|
poutCR(LIGHTRED, BLACK, (char *) Language(217));
|
||||||
|
@ -349,14 +349,42 @@ int download(down_list *download_list)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void tidy_upload(up_list **fdp)
|
||||||
|
{
|
||||||
|
up_list *tmp, *old;
|
||||||
|
|
||||||
|
for (tmp = *fdp; tmp; tmp = old) {
|
||||||
|
old = tmp->next;
|
||||||
|
if (tmp->filename)
|
||||||
|
free(tmp->filename);
|
||||||
|
free(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
*fdp = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Upload files from the user.
|
* Upload files from the user.
|
||||||
* Returns:
|
* Returns:
|
||||||
* 0 - All seems well
|
* 0 - All seems well
|
||||||
* 1 - No transfer protocol selected.
|
* 1 - No transfer protocol selected.
|
||||||
|
* 2 - Transfer failed
|
||||||
*/
|
*/
|
||||||
int upload(up_list *upload_list)
|
int upload(up_list **upload_list)
|
||||||
{
|
{
|
||||||
|
char *temp;
|
||||||
|
struct dirent *dp;
|
||||||
|
DIR *dirp;
|
||||||
|
struct stat statfile;
|
||||||
|
struct timeval starttime, endtime;
|
||||||
|
struct timezone tz;
|
||||||
|
unsigned long Size = 0;
|
||||||
|
int err, Count = 0, rc = 0;
|
||||||
|
up_list *tmp, *ta;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If user has no default protocol, make sure he has one.
|
* If user has no default protocol, make sure he has one.
|
||||||
*/
|
*/
|
||||||
@ -364,7 +392,91 @@ int upload(up_list *upload_list)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
|
|
||||||
|
/* Please start your upload now */
|
||||||
|
sprintf(temp, "%s, %s", sProtAdvice, (char *) Language(283));
|
||||||
|
pout(CFG.HiliteF, CFG.HiliteB, temp);
|
||||||
|
Enter(2);
|
||||||
|
Syslog('+', "Upload using %s", sProtName);
|
||||||
|
|
||||||
|
sprintf(temp, "%s/%s/upl", CFG.bbs_usersdir, exitinfo.Name);
|
||||||
|
|
||||||
|
if (chdir(temp)) {
|
||||||
|
WriteError("$Can't chdir to %s", temp);
|
||||||
|
free(temp);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
sleep(2);
|
||||||
|
|
||||||
|
if (uProtInternal) {
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* External protocol
|
||||||
|
*/
|
||||||
|
gettimeofday(&starttime, &tz);
|
||||||
|
|
||||||
|
Altime(7200);
|
||||||
|
alarm_set(7190);
|
||||||
|
err = execute_str(sProtUp, (char *)"", NULL, NULL, NULL, NULL);
|
||||||
|
if (rawport() != 0) {
|
||||||
|
WriteError("Unable to set raw mode");
|
||||||
|
}
|
||||||
|
if (err) {
|
||||||
|
WriteError("$Upload error %d, prot: %s", err, sProtUp);
|
||||||
|
rc = 2;
|
||||||
|
}
|
||||||
|
Altime(0);
|
||||||
|
alarm_off();
|
||||||
|
alarm_on();
|
||||||
|
|
||||||
|
gettimeofday(&endtime, &tz);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* With external protocols we don't know anything about what we got.
|
||||||
|
* Just check the files in the users upload directory.
|
||||||
|
*/
|
||||||
|
if ((dirp = opendir(".")) == NULL) {
|
||||||
|
WriteError("$Upload: can't open ./upl");
|
||||||
|
Home();
|
||||||
|
rc = 1;
|
||||||
|
} else {
|
||||||
|
while ((dp = readdir(dirp)) != NULL) {
|
||||||
|
if (*(dp->d_name) != '.') {
|
||||||
|
stat(dp->d_name, &statfile);
|
||||||
|
Syslog('+', "Uploaded \"%s\", %ld bytes", dp->d_name, statfile.st_size);
|
||||||
|
Count++;
|
||||||
|
Size += statfile.st_size;
|
||||||
|
sprintf(temp, "%s/%s/upl/%s", CFG.bbs_usersdir, exitinfo.Name, dp->d_name);
|
||||||
|
chmod(temp, 0660);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add uploaded file to the list
|
||||||
|
*/
|
||||||
|
tmp = (up_list *)malloc(sizeof(up_list));
|
||||||
|
tmp->next = NULL;
|
||||||
|
tmp->filename = xstrcpy(temp);
|
||||||
|
tmp->size = Size;
|
||||||
|
|
||||||
|
if (*upload_list == NULL) {
|
||||||
|
*upload_list = tmp;
|
||||||
|
} else {
|
||||||
|
for (ta = *upload_list; ta; ta = ta->next) {
|
||||||
|
if (ta->next == NULL) {
|
||||||
|
ta->next = (up_list *)tmp;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir(dirp);
|
||||||
|
Syslog('+', "Upload %s in %d file(s)", transfertime(starttime, endtime, (unsigned long)Size, FALSE), Count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(temp);
|
||||||
|
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,18 +27,17 @@ typedef struct _down_list {
|
|||||||
*/
|
*/
|
||||||
typedef struct _up_list {
|
typedef struct _up_list {
|
||||||
struct _up_list *next;
|
struct _up_list *next;
|
||||||
char *remote; /* Remote filename */
|
char *filename; /* Filename */
|
||||||
char *local; /* Local filename */
|
unsigned long size; /* Filesize */
|
||||||
long cps; /* CPS after received */
|
|
||||||
unsigned success : 1; /* If received Ok. */
|
|
||||||
} up_list;
|
} up_list;
|
||||||
|
|
||||||
int ForceProtocol(void);
|
|
||||||
|
|
||||||
void add_download(down_list **, char *, char *, long, unsigned long, int);
|
int ForceProtocol(void);
|
||||||
void tidy_download(down_list **);
|
void add_download(down_list **, char *, char *, long, unsigned long, int);
|
||||||
int download(down_list *);
|
void tidy_download(down_list **);
|
||||||
int upload(up_list *);
|
int download(down_list *);
|
||||||
|
void tidy_upload(up_list **);
|
||||||
|
int upload(up_list **);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user