Added long filename support to filerequests

This commit is contained in:
Michiel Broek 2001-12-02 14:01:49 +00:00
parent cd7bf461e6
commit 8f1f76998c
6 changed files with 95 additions and 61 deletions

View File

@ -4304,6 +4304,12 @@ v0.33.19 26-Oct-2001
mbcico: mbcico:
Removed IEMSI support since mbsebbs doesn't support it Removed IEMSI support since mbsebbs doesn't support it
anymore. anymore.
Filerequest responses are now created with long filenames.
When sending files, if the remote has the FNC link flag, the
filename is mangled to DOS 8.3 format when transmitted.
File request response messages now displayy the long and
short filename in the reply.
Filerequest resonse messages now have a random quote added.
mbtask: mbtask:
Changed to handle the External Doors flag in the lastcaller Changed to handle the External Doors flag in the lastcaller

View File

@ -122,6 +122,7 @@ charset.o: libs.h structs.h common.h clcomm.h
ftn.o: libs.h structs.h records.h clcomm.h dbftn.h common.h ftn.o: libs.h structs.h records.h clcomm.h dbftn.h common.h
nodelist.o: libs.h structs.h records.h clcomm.h common.h nodelist.o: libs.h structs.h records.h clcomm.h common.h
pktname.o: libs.h structs.h records.h clcomm.h common.h pktname.o: libs.h structs.h records.h clcomm.h common.h
mangle.o: libs.h structs.h clcomm.h common.h
charconv.o: libs.h structs.h records.h common.h clcomm.h charconv.o: libs.h structs.h records.h common.h clcomm.h
dostran.o: libs.h structs.h records.h common.h dostran.o: libs.h structs.h records.h common.h
ftnmsg.o: libs.h structs.h common.h clcomm.h ftnmsg.o: libs.h structs.h common.h clcomm.h

View File

@ -1,8 +1,7 @@
/***************************************************************************** /*****************************************************************************
* *
* File ..................: mbcico/filelist.c * $Id$
* Purpose ...............: fidonet mailer * Purpose ...............: fidonet mailer
* Last modification date : 07-Aug-2001
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2001 * Copyright (C) 1997-2001
@ -61,58 +60,26 @@ static char *tmpkname(void)
char *xtodos(char *orig) char *xtodos(char *orig)
{ {
int i; char buf[13], *copy, *p;
char buf[8+1+3+1],*copy,*p,*q,*r;
if (orig == NULL) if (orig == NULL)
return NULL; return NULL;
if ((remote_flags & SESSION_FNC) == 0) { if ((remote_flags & SESSION_FNC) == 0) {
Syslog('o', "No filename conversion for \"%s\"",MBSE_SS(orig)); Syslog('o', "No filename conversion for \"%s\"", MBSE_SS(orig));
return xstrcpy(orig); return xstrcpy(orig);
} }
copy=xstrcpy(orig); copy = xstrcpy(orig);
if ((p=strrchr(copy,'/'))) if ((p = strrchr(copy,'/')))
p++; p++;
else else
p=copy; p = copy;
if (strcmp(q=copy+strlen(copy)-strlen(".tar.gz"),".tar.gz") == 0) {
*q='\0';
q=(char *)"tgz";
} else if (strcmp(q=copy+strlen(copy)-strlen(".tar.z"),".tar.z") == 0) {
*q='\0';
q=(char *)"tgz";
} else if (strcmp(q=copy+strlen(copy)-strlen(".tar.Z"),".tar.Z") == 0) {
*q='\0';
q=(char *)"taz";
} else if ((q=strrchr(p,'.')))
*q++='\0';
else
q=NULL;
r=buf;
for (i=0;(i<8) && (*p);i++,p++,r++)
switch (*p) {
case '.':
case '\\': *r='_'; break;
default: *r=toupper(*p);
}
if (q) {
*r++='.';
for (i=0;(i<3) && (*q);i++,q++,r++)
switch (*q) {
case '.':
case '\\': *r='_'; break;
default: *r=toupper(*q);
}
}
*r++='\0';
Syslog('o', "name \"%s\" converted to \"%s\"",MBSE_SS(orig),MBSE_SS(buf));
name_mangle(p);
memset(&buf, 0, sizeof(buf));
strncpy(buf, p, 12);
Syslog('o', "name \"%s\" converted to \"%s\"", MBSE_SS(orig), MBSE_SS(buf));
free(copy); free(copy);
return xstrcpy(buf); return xstrcpy(buf);
} }

View File

@ -155,6 +155,9 @@ int main(int argc, char *argv[])
char *answermode = NULL, *p = NULL, *cmd = NULL; char *answermode = NULL, *p = NULL, *cmd = NULL;
struct passwd *pw; struct passwd *pw;
FILE *fp; FILE *fp;
#ifdef IEMSI
char temp[81];
#endif
#ifdef MEMWATCH #ifdef MEMWATCH
mwInit(); mwInit();
@ -286,7 +289,32 @@ int main(int argc, char *argv[])
tmpl = &callist; tmpl = &callist;
while (argv[optind]) { while (argv[optind]) {
for (p = argv[optind]; (*p) && (*p == '*'); p++); for (p = argv[optind]; (*p) && (*p == '*'); p++);
#ifdef IEMSI
if (strncasecmp(p, "EMSI_NAKEEC3", 12) == 0) {
Syslog('+', "Detected IEMSI client, starting BBS");
sprintf(temp, "%s/bin/mbsebbs", getenv("MBSE_ROOT"));
socket_shutdown(mypid);
if (execl(temp, "mbsebbs", (char *)NULL) == -1)
perror("FATAL: Error loading BBS!");
/*
* If this happens, nothing is logged!
*/
printf("\n\nFATAL: Loading of the BBS failed!\n\n");
sleep(3);
free_mem();
if (envptr)
free(envptr);
#ifdef MEMWATCH
mwTerm();
#endif
exit(100);
}
#endif
if ((strcasecmp(argv[optind],"tsync") == 0) || if ((strcasecmp(argv[optind],"tsync") == 0) ||
(strcasecmp(argv[optind],"yoohoo") == 0) || (strcasecmp(argv[optind],"yoohoo") == 0) ||
(strcasecmp(argv[optind],"ibn") == 0) || (strcasecmp(argv[optind],"ibn") == 0) ||

View File

@ -1,8 +1,7 @@
/***************************************************************************** /*****************************************************************************
* *
* File ..................: mbcico/respfreq.c * $Id$
* Purpose ...............: Fidonet mailer * Purpose ...............: Fidonet mailer - respond to filerequests
* Last modification date : 04-Oct-2001
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2001 * Copyright (C) 1997-2001
@ -296,14 +295,12 @@ file_list *respfreq(char *nm, char *pw, char *dt)
WriteError("$Can't read filerecord %d", idx.Record); WriteError("$Can't read filerecord %d", idx.Record);
} else { } else {
Send = FALSE; Send = FALSE;
Syslog('f', "Found \"%s\" in %s", file.Name, area.Name); Syslog('f', "Found \"%s\" in %s", file.LName, area.Name);
tnm = xstrcpy(area.Path); tnm = xstrcpy(area.Path);
tnm = xstrcat(tnm, (char *)"/"); tnm = xstrcat(tnm, (char *)"/");
tnm = xstrcat(tnm, file.Name); tnm = xstrcat(tnm, file.LName);
if ((stat(tnm, &st) == 0) && if ((stat(tnm, &st) == 0) && (S_ISREG(st.st_mode)) &&
(S_ISREG(st.st_mode)) && (access(tnm, R_OK) == 0) && ((upd == 0L) ||
(access(tnm, R_OK) == 0) &&
((upd == 0L) ||
((newer) && (st.st_mtime <= upd)))) { ((newer) && (st.st_mtime <= upd)))) {
Send = TRUE; Send = TRUE;
} }
@ -320,7 +317,8 @@ file_list *respfreq(char *nm, char *pw, char *dt)
if (strcasecmp(area.Password, pw)) { if (strcasecmp(area.Password, pw)) {
Send = FALSE; Send = FALSE;
Syslog('+', "Bad password for area %s", area.Name); Syslog('+', "Bad password for area %s", area.Name);
add_report((char *)"ER: bad password for area %s", area.Name); add_report((char *)"ER: bad password for area %s",
area.Name);
} }
} else { } else {
Send = FALSE; Send = FALSE;
@ -332,7 +330,8 @@ file_list *respfreq(char *nm, char *pw, char *dt)
if (strcasecmp(file.Password, pw)) { if (strcasecmp(file.Password, pw)) {
Send = FALSE; Send = FALSE;
Syslog('+', "Bad password for file %s", file.Name); Syslog('+', "Bad password for file %s", file.Name);
add_report((char *)"ER: bad password for file %s", file.Name); add_report((char *)"ER: bad password for file %s",
file.LName);
} }
} else { } else {
Send = FALSE; Send = FALSE;
@ -351,7 +350,8 @@ file_list *respfreq(char *nm, char *pw, char *dt)
if (Send && CFG.Req_MBytes) { if (Send && CFG.Req_MBytes) {
if ((st.st_size + report_total) > (CFG.Req_MBytes * 1048576)) { if ((st.st_size + report_total) > (CFG.Req_MBytes * 1048576)) {
Send = FALSE; Send = FALSE;
add_report((char *)"ER: file %s will exceed the request limit", file.Name); add_report((char *)"ER: file %s will exceed the request limit",
file.Name);
Syslog('+', "Exceeding request size limit"); Syslog('+', "Exceeding request size limit");
no_more = TRUE; no_more = TRUE;
} }
@ -361,8 +361,14 @@ file_list *respfreq(char *nm, char *pw, char *dt)
Syslog('f', "Will send %s", file.LName); Syslog('f', "Will send %s", file.LName);
report_total += st.st_size; report_total += st.st_size;
report_count++; report_count++;
add_report((char *)"OK: Sending \"%s\" (%lu bytes)", file.Name, file.Size); if (strcasecmp(file.Name, file.LName))
add_list(&fl, tnm, file.Name, 0, 0L, NULL, 1); add_report((char *)"OK: Sending \"%s\" as \"%s\" (%lu bytes)",
file.LName, file.Name, file.Size);
else
add_report((char *)"OK: Sending \"%s\" (%lu bytes)",
file.LName, file.Size);
add_list(&fl, tnm, file.LName, 0, 0L, NULL, 1);
/* /*
* Update file information * Update file information
*/ */
@ -568,12 +574,14 @@ file_list *respmagic(char *cmd) /* must free(cmd) before exit */
static void attach_report(file_list **fl) static void attach_report(file_list **fl)
{ {
FILE *fp; FILE *fp;
char tmpfn[PATH_MAX]; char *tmpfn;
char remname[14]; char remname[14];
long zeroes = 0L; long zeroes = 0L, recno, records;
ftnmsg fmsg; ftnmsg fmsg;
char *svname; char *svname;
tmpfn = calloc(PATH_MAX, sizeof(char));
if (report_text == NULL) { if (report_text == NULL) {
WriteError("Empty FREQ report"); WriteError("Empty FREQ report");
add_report((char *)"ER: empty request report, contact sysop"); add_report((char *)"ER: empty request report, contact sysop");
@ -590,6 +598,29 @@ static void attach_report(file_list **fl)
else else
add_report((char *)"Maximum size : %d MBytes", CFG.Req_MBytes); add_report((char *)"Maximum size : %d MBytes", CFG.Req_MBytes);
/*
* Add random quote
*/
sprintf(tmpfn, "%s/etc/oneline.data", getenv("MBSE_ROOT"));
if ((fp = fopen(tmpfn, "r+")) != NULL) {
fread(&olhdr, sizeof(olhdr), 1, fp);
fseek(fp, 0, SEEK_END);
records = (ftell(fp) - olhdr.hdrsize) / olhdr.recsize;
srand(getpid());
recno = 1+(int) (1.0 * records * rand() / (RAND_MAX + 1.0));
Syslog('f', "Selected quote %d out of %d records", recno, records);
if (fseek(fp, olhdr.hdrsize + (recno * olhdr.recsize), SEEK_SET) == 0) {
if (fread(&ol, olhdr.recsize, 1, fp) == 1) {
add_report((char *)"\r... %s", ol.Oneline);
} else {
WriteError("Can't read %s", tmpfn);
}
} else {
WriteError("$Can't seek record %d in %s", recno, tmpfn);
}
fclose(fp);
}
add_report((char *)"\r--- mbcico v%s\r", VERSION); add_report((char *)"\r--- mbcico v%s\r", VERSION);
sprintf(tmpfn, "%s/tmp/%08lX.rpl", getenv((char *)"MBSE_ROOT"), (unsigned long)sequencer()); sprintf(tmpfn, "%s/tmp/%08lX.rpl", getenv((char *)"MBSE_ROOT"), (unsigned long)sequencer());
@ -628,6 +659,7 @@ static void attach_report(file_list **fl)
report_total = 0L; report_total = 0L;
free(report_text); free(report_text);
free(tmpfn);
report_text = NULL; report_text = NULL;
} }

View File

@ -124,8 +124,8 @@ void ListFileAreas(int Area)
if (strlen(file.Desc[0]) > 36) if (strlen(file.Desc[0]) > 36)
file.Desc[0][36] = '\0'; file.Desc[0][36] = '\0';
printf("%-12s %6ld %s %5ld %s %s\n", printf("%-12s %6ld %s %5ld %s %s\n",
file.Name, file.Size / 1024, StrDateDMY(file.FileDate), file.Name, (long)(file.Size / 1024), StrDateDMY(file.FileDate),
file.TimesDL + file.TimesFTP + file.TimesReq, flags, file.Desc[0]); (long)(file.TimesDL + file.TimesFTP + file.TimesReq), flags, file.Desc[0]);
fcount++; fcount++;
fsize = fsize + file.Size; fsize = fsize + file.Size;
} }