DECLARE SUB DefineErrors () DECLARE FUNCTION AttachmentType$ (in$) DECLARE FUNCTION ChangeChar$ (in$, ChangeFrom$, ChangeTo$) DECLARE SUB ShowProgInfo () DECLARE SUB WriteToLog (operation$, info$) DEFINT A-Z DECLARE SUB PrintAt (x%, y%, in$) DECLARE FUNCTION CurrentDrive$ () DECLARE FUNCTION CurrentPath$ () DECLARE FUNCTION DriveSpace& (drive$) DECLARE FUNCTION FindFile& (Name$) DECLARE FUNCTION StripToZero$ (in$) DECLARE FUNCTION DateCorrect$ (datein$, option$) DECLARE FUNCTION DateStr$ (datein&, option$) DECLARE FUNCTION DateVal& (datein$) DECLARE FUNCTION DateValid% (datein$, option$) DECLARE FUNCTION BackSlash$ (in$) DECLARE FUNCTION FileFromPath$ (FileX$) DECLARE FUNCTION GetAddress$ (in$) DECLARE FUNCTION StripCR$ (aline$) DECLARE SUB ScanDirectory (Dir$) DECLARE SUB Colour (fg%, bg%) DECLARE SUB Delay (tenths%) DECLARE FUNCTION Exists& (File$) DECLARE SUB ReadIniFile () DECLARE SUB ParseCommand (line$) TYPE RegType ax AS INTEGER bx AS INTEGER cx AS INTEGER dx AS INTEGER bp AS INTEGER si AS INTEGER di AS INTEGER flags AS INTEGER ds AS INTEGER es AS INTEGER END TYPE ' Used as DTA for DOS FileFind call. TYPE FileBuffer Reserved AS STRING * 21 Attribute AS STRING * 1 PackedTime AS STRING * 2 PackedDate AS STRING * 2 Size AS LONG ' Size of file in bytes filename AS STRING * 13 reserved2 AS STRING * 20 Date AS STRING * 10 ' Unpacked date "DD/MM/YY" time AS STRING * 8 ' Unpacked time "HH:MM:SS" DOSErr AS INTEGER ' Error returned by interrupt Exists AS INTEGER ' 1 if file exists END TYPE DECLARE SUB Interrupt (intnum AS INTEGER, inreg AS RegType, outreg AS RegType) DECLARE SUB INTERRUPTX (intnum AS INTEGER, inreg AS RegType, outreg AS RegType) '$INCLUDE: 'c:\utils\qb45\errors.dat' ' Setup Global variables and their defaults ' DIM SHARED HelpFile$: HelpFile$ = "helpfile.txt" DIM SHARED InfoFile$: InfoFile$ = "info.txt" DIM SHARED FileList$: FileList$ = "filelist.txt" DIM SHARED LogFile$: LogFile$ = "sendfile.log" DIM SHARED Sig$: Sig$ = "" DIM SHARED CopySelf$: CopySelf$ = "0" DIM SHARED ReadRcpt$: ReadRcpt$ = "0" DIM SHARED Delivery$: Delivery$ = "0" DIM SHARED encode$: encode$ = "0" DIM SHARED Log$: Log$ = "Y" DIM SHARED RootPath$: RootPath$ = "C:\FILES" DIM SHARED NewMail$: NewMail$ = "C:\PMAIL\MAIL" DIM SHARED MaxRequest: MaxRequest = 10 DIM SHARED inreg AS RegType, outreg AS RegType DIM SHARED FileInfo AS FileBuffer DIM SHARED Nul AS STRING * 1 DIM SHARED errline$(50) DIM SHARED ErrNum$(100) DIM SHARED Finished AS INTEGER ' Used to flag an "END" or "EXIT" in message. DIM SHARED openfile$ DefineErrors SLEEP 3 CONST TotalMax = 50 CONST MaxErrors = 30 RANDOMIZE TIMER * 100 DIM SHARED FilesToSend$(TotalMax), NumFiles DIM SHARED Error$(MaxErrors), errors DIM SHARED Request$(TotalMax), Requests DIM SHARED filename$ DIM SHARED FromLine$, LogFromLine$ DIM SHARED ver$ Nul = CHR$(0) ON ERROR GOTO ErrorSub ver$ = "1.0.11" File = 0: errors = 0: Requests = 0 filename$ = LTRIM$(RTRIM$(COMMAND$)) IF filename$ = "" THEN ShowProgInfo END END IF PRINT "SENDFILE Version " + ver$ + ", 6-May-2005" PRINT ReadIniFile 2 ' ** FindLogFile ** IF Log$ = "Y" THEN times = 1 IF Exists(LogFile$) THEN openfile$ = LogFile$ OPEN openfile$ FOR APPEND AS #9 ELSE openfile$ = LogFile$ OPEN openfile$ FOR OUTPUT AS #9 END IF END IF 4 ' ** Opening Message File ** openfile$ = filename$ OPEN openfile$ FOR INPUT SHARED AS #1 ' Skip past headers to get to body. DO LINE INPUT #1, line1$ IF LCASE$(LEFT$(line1$, 5)) = "from:" THEN FromLine$ = LTRIM$(RTRIM$(MID$(line1$, 6))) LogFromLine$ = ChangeChar$(FromLine$, CHR$(34), "'") END IF LOOP UNTIL RTRIM$(line1$) = "" OR EOF(1) IF NOT EOF(1) THEN DO LINE INPUT #1, line1$ ParseCommand line1$ LOOP UNTIL EOF(1) OR errors >= MaxErrors OR Finished = 1 END IF CLOSE #1 KILL filename$ DO Newfile$ = NewMail$ + "\SK" + HEX$(RND * 10000) + ".pmw" LOOP UNTIL Exists(Newfile$) <= 0 5 ' ** Outputting new file ** openfile$ = Newfile$ OPEN openfile$ FOR OUTPUT AS #1 PRINT #1, LEFT$(LEFT$(FromLine$, 20) + ", Outgoing File Request" + SPACE$(35), 52); REM Needs CR CR LF here. PRINT #1, CHR$(13) PRINT #1, "SY:0" PRINT #1, "TO:" + FromLine$ PRINT #1, "SU:" + "Results of your sendfile request." PRINT #1, "CC:" PRINT #1, "EN:0" PRINT #1, "CS:" + CopySelf$ PRINT #1, "RC:" + ReadRcpt$ PRINT #1, "DC:" + Delivery$ PRINT #1, "UR:0" IF Sig$ = "" THEN ' Suppress Signature PRINT #1, "SS:1" PRINT #1, "SG:0" ELSE PRINT #1, "SS:0" PRINT #1, "SG:" + Sig$ END IF PRINT #1, "MI:1" PRINT #1, "EX:0" IF NumFiles > 0 THEN FOR FileNum = 1 TO NumFiles 7 ' ** Attaching files ** FileType$ = AttachmentType$(FilesToSend$(FileNum)) PRINT #1, "AT:" + RootPath$ + "\" + FilesToSend$(FileNum) + "," + FileType$ + "," + encode$ WriteToLog "SEND", RootPath$ + "\" + FilesToSend$(FileNum) NEXT END IF ' Deal with requests to be added as attachments IF Requests > 0 THEN FOR Request = 1 TO Requests SELECT CASE LEFT$(Request$(Request), 4) CASE "TREE" ' CASE "HELP" PRINT #1, "AT:" + HelpFile$ + ",Text,0" WriteToLog "HELP", "" CASE "LIST" PRINT #1, "AT:" + FileList$ + ",Text,0" WriteToLog "LIST", "" CASE "INFO" PRINT #1, "AT:" + InfoFile$ + ",Text,0" WriteToLog "INFO", "" CASE "DIR " ' END SELECT NEXT END IF PRINT #1, "FL:0" PRINT #1, "" ' Body Text. Start by including Info.txt 10 ' ** ReadInfoFile ** openfile$ = InfoFile$ OPEN openfile$ FOR INPUT SHARED AS #2 DO UNTIL EOF(2) LINE INPUT #2, line1$ PRINT #1, line1$ LOOP CLOSE #2 PRINT #1, STRING$(70, "-") IF encode$ >= "3" AND encode$ <= "5" THEN PRINT #1, "Encoding type set to "; SELECT CASE encode$ CASE "3": PRINT #1, "UUENCODE" CASE "4": PRINT #1, "BINHEX" CASE "5": PRINT #1, "BASE64 MIME" END SELECT PRINT #1, STRING$(70, "-") END IF ' Then list of files sent. IF NumFiles > 0 OR Requests > 0 THEN PRINT #1, "Accepted File & Information Requests :" PRINT #1, "" FOR FileNum = 1 TO NumFiles PRINT #1, "GET " + FilesToSend$(FileNum) NEXT PRINT #1, "" FOR Request = 1 TO Requests PRINT #1, Request$(Request) NEXT PRINT #1, STRING$(70, "-") END IF ' List of errors. IF errors > 0 THEN PRINT #1, "Commands causing Errors :" PRINT #1, "" FOR ErrNum = 1 TO errors PRINT #1, Error$(ErrNum) WriteToLog "ERROR", Error$(ErrNum) NEXT PRINT #1, STRING$(70, "-") END IF IF Requests > 0 THEN FOR Request = 1 TO Requests SELECT CASE LEFT$(Request$(Request), 4) CASE "DIR " 11 ' ** DoingDir's ** ScanDirectory MID$(Request$(Request), 6) WriteToLog "DIR", MID$(Request$(Request), 6) 12 ' ** tree ** CASE "TREE" PRINT #1, "" PRINT #1, "Directory TREE" PRINT #1, "" IF Exists("TREE.TXT") = 0 THEN SHELL "TREE /a " + RootPath$ + " > TREE.TXT" END IF IF Exists("TREE.TXT") = 0 THEN PRINT #1, "not available currently on this system" PRINT #1, "" WriteToLog "ERROR", "Unable to create TREE.TXT file" ELSE openfile$ = "tree.txt" OPEN openfile$ FOR INPUT SHARED AS #2 DO UNTIL EOF(2) LINE INPUT #2, line1$ PRINT #1, line1$ LOOP CLOSE #2 WriteToLog "TREE", "" END IF END SELECT NEXT END IF PRINT #1, STRING$(70, "-") CLOSE #1, #2 IF Log$ = "Y" THEN CLOSE #9 END ErrorSub: errnumb = ERR: errlin = ERL IF errlin = 2 THEN ' In Log File wait situation PRINT "Waiting for Log file. " + STR$(times) + " secs - ERR : "; ErrNum$(errnumb) times = times + 1 SLEEP 1 ON ERROR GOTO ErrorSub IF times > 150 THEN PRINT PRINT "Error "; ERR; ". couldn't access Log File after 150 seconds : "; LogFile$ PRINT PRINT "PRESS ANY KEY TO CONTINUE" PRINT "" SLEEP END ELSE RESUME 0 END IF END IF CLS PRINT PRINT "AN Error has occured in SendFile.exe version "; ver$; " :" PRINT PRINT "Error "; errnumb; " in line number "; errlin PRINT PRINT "Line "; errlin; " is to do with : "; errline$(errlin) PRINT "Error "; errnumb; " is "; ErrNum$(errnumb) PRINT "Filename : "; openfile$ PRINT "Default drive (INI file location) : "; CurrentDrive PRINT "Default path (INI file location) : "; CurrentPath PRINT PRINT "PRESS A KEY TO CONTINUE" SLEEP 0 END FUNCTION AttachmentType$ (in$) dotpos = INSTR(in$, ".") IF dotpos > 0 THEN SELECT CASE UCASE$(MID$(in$, dotpos + 1)) CASE "ZIP": AttachmentType$ = "ZIP-archive" CASE "EXE": AttachmentType$ = "PCEXE" CASE "TXT": AttachmentType$ = "Text" CASE "INI": AttachmentType$ = "Text" CASE "BAT": AttachmentType$ = "Text" CASE "WAV": AttachmentType$ = "WAV-sound-file" CASE "DOC": AttachmentType$ = "MS-Word-6" CASE "XLS": AttachmentType$ = "Excel-Sheet" CASE "HTM", "HTML": AttachmentType$ = "HTML-illustrator" CASE "JPG", "JPEG": AttachmentType$ = "JPEG-image" CASE "PDF": AttachmentType$ = "Acrobat" CASE ELSE: AttachmentType$ = "Unknown" END SELECT ELSE AttachmentType$ = "Unknown" END IF END FUNCTION FUNCTION BackSlash$ (in$) ' Scan through a string and change all /'s for \'s in2$ = in$ nextpos = INSTR(in2$, "/") DO WHILE nextpos > 0 MID$(in2$, nextpos, 1) = "\" nextpos = INSTR(in2$, "/") LOOP BackSlash$ = in2$ END FUNCTION FUNCTION ChangeChar$ (in$, ChangeFrom$, ChangeTo$) ' Scan through a string and change all /'s for \'s in2$ = in$ nextpos = INSTR(in2$, ChangeFrom$) DO WHILE nextpos > 0 MID$(in2$, nextpos, 1) = ChangeTo$ nextpos = INSTR(in2$, ChangeFrom$) LOOP ChangeChar$ = in2$ END FUNCTION SUB Colour (fg, bg) STATIC Oldfg, Oldbg IF fg = -1 THEN fg = Oldfg IF bg = -1 THEN bg = Oldbg COLOR fg, bg Oldfg = fg: Oldbg = bg END SUB DEFSNG A-Z FUNCTION CurrentDrive$ inreg.ax = &H1900 INTERRUPTX &H21, inreg, outreg CurrentDrive$ = CHR$((outreg.ax AND &HFF) + 65) + ":" END FUNCTION FUNCTION CurrentPath$ DIM PathName AS STRING * 64 inreg.ax = &H4700 inreg.dx = 0 inreg.ds = VARSEG(PathName) inreg.si = VARPTR(PathName) INTERRUPTX &H21, inreg, outreg Path$ = "" IF (outreg.flags AND &H1) = 0 THEN Path$ = "\" + StripToZero$(PathName) IF Path$ <> "\" THEN Path$ = Path$ + "\" END IF CurrentPath$ = Path$ END FUNCTION DEFINT A-Z FUNCTION DateCorrect$ (datein$, option$) dd% = 0: mm% = 0: yy% = 0: longdate% = 0 A = INSTR(datein$, "/") IF A <> 0 THEN dd% = VAL(LEFT$(datein$, A - 1)) b = INSTR(A + 1, datein$, "/") IF b <> 0 THEN mm% = VAL(MID$(datein$, A + 1, b - A - 1)) yy% = VAL(MID$(datein$, b + 1)) END IF END IF IF INSTR(option$, "LONG") > 0 THEN longdate% = 2 IF yy% > 1900 AND longdate% = 0 THEN yy% = yy% - 1900 IF longdate% = 2 AND yy% < 200 THEN yy% = yy% + 1900 IF dd% = 0 OR mm% = 0 OR yy% = 0 THEN DateCorrect$ = "" ELSE DateCorrect$ = RIGHT$(STR$(dd%), 2) + "/" + RIGHT$(STR$(mm%), 2) + "/" + RIGHT$(STR$(yy%), 2 + longdate%) END IF END FUNCTION FUNCTION DateStr$ (datein&, option$) yy% = INT(datein& / 365.25) dd% = datein& - INT(yy% * 365.25) mm% = INT(dd% / 30.6) dd% = dd% - (mm% * 30.6) IF dd% = 0 THEN IF mm% = 0 THEN dd% = 29 ELSE dd% = 31 END IF mm% = mm% - 1 END IF mm% = mm% + 3 IF mm% > 12 THEN mm% = mm% - 12 yy% = yy% + 1 END IF IF INSTR(option$, "LONG") > 0 THEN yy% = yy% + 1900 DateStr$ = DateCorrect$(STR$(dd%) + "/" + STR$(mm%) + "/" + STR$(yy%), option$) END FUNCTION FUNCTION DateVal& (datein$) dd% = VAL(LEFT$(datein$, 2)) mm% = VAL(MID$(datein$, 4, 2)) - 3 yy% = VAL(MID$(datein$, 7)) IF yy% > 1900 THEN yy% = yy% - 1900 IF mm% < 0 THEN mm% = 12 + mm% yy% = yy% - 1 END IF IF dd% = 0 OR mm% < 0 OR yy% = 0 THEN DateVal& = 0 ELSE DateVal& = INT(yy% * 365.25) + mm% * 30.6 + dd% END IF END FUNCTION FUNCTION DateValid% (datein$, option$) DateValid% = (DateStr$(DateVal(datein$), option$) = datein$) END FUNCTION SUB DefineErrors RESTORE ErrorLines DO READ errlin IF errlin >= 0 THEN READ errline$(errlin) LOOP UNTIL errlin < 0 RESTORE ErrorNumbers DO READ ErrNum IF ErrNum >= 0 THEN READ ErrNum$(ErrNum) LOOP UNTIL ErrNum < 0 END SUB SUB Delay (tenths) FOR I = 1 TO tenths PLAY "T240P8" NEXT END SUB FUNCTION DriveSpace& (drive$) inreg.dx = ASC(UCASE$(LEFT$(drive$, 1) + "@")) - 64 inreg.ax = &H3600 Interrupt &H21, inreg, outreg sec = outreg.ax clfree = outreg.bx bytesec = outreg.cx IF sec <> &HFFFF THEN DriveSpace& = bytesec * sec / 1024 * clfree ELSE DriveSpace& = 0 END IF END FUNCTION FUNCTION Exists& (File$) Length& = FindFile(File$) IF Length& <= 0 THEN Length& = 0 END IF Exists& = Length& END FUNCTION FUNCTION FileFromPath$ (FileX$) FileN$ = LTRIM$(RTRIM$(LCASE$(FileX$))) IF FileN$ = "" THEN FileFromPath$ = "": EXIT FUNCTION ' Skip through and get last filename off line. DO BackSlashPos = INSTR(FileN$, "\") IF BackSlashPos > 0 THEN FileN$ = MID$(FileN$, BackSlashPos + 1) LOOP UNTIL BackSlashPos = 0 OR FileN$ = "" FileFromPath$ = FileN$ END FUNCTION FUNCTION FindFile& (Name$) STATIC PathName AS STRING * 120 IF Name$ = "" THEN FindNext = 1 ELSE PathName$ = Name$ + Nul END IF FileInfo.Size = -1 IF FindNext = 0 THEN inreg.ax = &H1A00 inreg.ds = VARSEG(FileInfo) inreg.dx = VARPTR(FileInfo) INTERRUPTX &H21, inreg, outreg inreg.ax = &H4E00 inreg.cx = &H10 inreg.ds = VARSEG(PathName) inreg.dx = VARPTR(PathName) ELSE inreg.ax = &H4F00 IF FileInfo.DOSErr <> 0 OR FileInfo.Exists = 0 THEN FindFile& = -1 EXIT FUNCTION END IF END IF INTERRUPTX &H21, inreg, outreg ' ti = (CVI(FileInfo.PackedTime) + 65536) AND 65535 da = (CVI(FileInfo.PackedDate) + 65536) AND 65535 hour = (ti AND &HF800) \ &H800 min = (ti AND &H7E0) \ 32 sec = (ti AND &H1F) * 2 day = (da AND &H1F) month = (da AND &H1E0) \ 32 year = (da AND &HFE00) \ 512 + 1980 FileInfo.Exists = 1 - (outreg.flags AND &H1) FileInfo.DOSErr = outreg.ax IF FileInfo.Exists = 1 AND FileInfo.DOSErr = 0 THEN FileInfo.time = RIGHT$(STR$(hour), 2) + ":" + RIGHT$(STR$(100 + min), 2) + ":" + RIGHT$(STR$(100 + sec), 2) FileInfo.Date = DateCorrect$(STR$(day) + "/" + STR$(month) + "/" + STR$(year), "LONG") FileInfo.filename = StripToZero$(FileInfo.filename) FindFile& = FileInfo.Size ELSE FileInfo.time = "" FileInfo.Date = "" FileInfo.filename = "" FindFile& = -1 END IF DEF SEG END FUNCTION DEFSNG A-Z FUNCTION GetAddress$ (in$) leftbracket = INSTR(in$, "<") IF leftbracket > 0 THEN rightbracket = INSTR(leftbracket + 1, in$, ">") IF rightbracket > 0 THEN GetAddress$ = MID$(in$, leftbracket + 1, rightbracket - leftbracket - 1) ELSE GetAddress$ = MID$(in$, leftbracket + 1) END IF ELSE GetAddress$ = in$ END IF END FUNCTION DEFINT A-Z SUB Locks DIM rec AS STRING * 1 timeout = 0 OPEN "lock" FOR RANDOM SHARED AS #3 LEN = 1 DO GET #3, 1, rec SLEEP 1 timeout = timeout + 1 LOOP UNTIL rec = " " OR rec = "" OR timeout = 90 CLOSE #3 rec = "X" OPEN "lock" FOR RANDOM SHARED AS #3 LEN = 1 PUT #3, 1, rec CLOSE #3 rec = " " OPEN "lock" FOR RANDOM SHARED AS #3 LEN = 1 PUT #3, 1, rec CLOSE #3 END SUB SUB ParseCommand (line$) IF errors >= MaxErrors THEN EXIT SUB spacepos = INSTR(line$ + " ", " ") IF spacepos > 0 THEN File$ = BackSlash(LTRIM$(RTRIM$(MID$(line$, spacepos + 1)))) IF LEFT$(File$, 1) = "\" THEN File$ = MID$(File$, 2) IF LEFT$(File$, 1) = "\" THEN File$ = MID$(File$, 2) ' To deal with "\\" situations ^^^ SELECT CASE LCASE$(LEFT$(line$, spacepos - 1)) CASE "to" From$ = File$ CASE "get", "retr", "send" IF Exists(RootPath$ + "\" + File$) THEN IF NumFiles < MaxRequest THEN IF INSTR(File$, "..") > 0 OR INSTR(File$, "\\") OR INSTR(File$, ":") > 0 THEN errors = errors + 1 Error$(errors) = "Rejected (illegal filename) - " + line$ ELSE NumFiles = NumFiles + 1 FilesToSend$(NumFiles) = File$ END IF ELSE errors = errors + 1 Error$(errors) = "Rejected (too many requests) - " + line$ END IF ELSE errors = errors + 1 Error$(errors) = "Rejected (file doesn't exist) - " + line$ END IF CASE "dir", "ls", "files" IF Requests < MaxRequest THEN IF INSTR(File$, "..") > 0 OR INSTR(File$, "\\") OR INSTR(File$, ":") > 0 THEN errors = errors + 1 Error$(errors) = "Rejected (illegal filename) - " + line$ ELSE Requests = Requests + 1 Request$(Requests) = "DIR " + File$ END IF ELSE errors = errors + 1 Error$(errors) = "Rejected (too many requests) - " + line$ END IF CASE "help" IF Requests < MaxRequest THEN Requests = Requests + 1 Request$(Requests) = "HELP" ELSE errors = errors + 1 Error$(errors) = "Rejected (too many requests) - " + line$ END IF CASE "info" IF Requests < MaxRequest THEN Requests = Requests + 1 Request$(Requests) = "INFO" ELSE errors = errors + 1 Error$(errors) = "Rejected (too many requests) - " + line$ END IF CASE "filelist", "list" IF Requests < MaxRequest THEN Requests = Requests + 1 Request$(Requests) = "LIST" ELSE errors = errors + 1 Error$(errors) = "Rejected (too many requests) - " + line$ END IF CASE "tree" IF Requests < MaxRequest THEN Requests = Requests + 1 Request$(Requests) = "TREE" ELSE errors = errors + 1 Error$(errors) = "Rejected (too many requests) - " + line$ END IF CASE "uuencode" encode$ = "3" CASE "binhex" encode$ = "4" CASE "mime" encode$ = "5" ' Include blank lines to end scan CASE "exit", "end", "done", "quit", "", ";" Finished = 1 CASE ELSE errors = errors + 1 Error$(errors) = "Rejected (unknown command) - " + line$ END SELECT END IF END SUB SUB PrintAt (x%, y%, in$) oldx% = POS(0): oldy% = CSRLIN IF x% > 0 AND y% > 0 THEN LOCATE y%, x% PRINT in$; LOCATE oldy%, oldx% END SUB SUB ReadIniFile 1 ' ** ReadInIFile ** openfile$ = "sendfile.ini" OPEN openfile$ FOR INPUT SHARED AS #1 DO LINE INPUT #1, iniline$ equalspos = INSTR(iniline$, "=") IF equalspos > 0 THEN set$ = LCASE$(LTRIM$(RTRIM$(LEFT$(iniline$, equalspos - 1)))) value$ = LTRIM$(RTRIM$(MID$(iniline$, equalspos + 1))) IF LEFT$(set$, 1) <> ";" THEN SELECT CASE set$ CASE "helpfile": HelpFile$ = value$ CASE "infofile": InfoFile$ = value$ CASE "filelist": FileList$ = value$ CASE "logfile": LogFile$ = value$ CASE "signature": Sig$ = value$ CASE "copyself": CopySelf$ = value$ CASE "receipt": ReadRcpt$ = value$ CASE "delivery": Delivery$ = value$ CASE "encode": encode$ = value$ CASE "log": Log$ = value$ CASE "root": RootPath$ = value$ IF RIGHT$(RootPath$, 1) = "\" THEN RootPath$ = LEFT$(RootPath$, LEN(RootPath$) - 1) CASE "newmail": NewMail$ = value$ IF RIGHT$(NewMail$, 1) = "\" THEN NewMail$ = LEFT$(NewMail$, LEN(NewMail$) - 1) CASE "requests": MaxRequest = VAL(value$) IF MaxRequest > TotalMax THEN MaxRequest = TotalMax IF MaxRequest <= 0 THEN MaxRequest = 10 END SELECT ' PRINT set$, value$ END IF ELSE ' Ignore blank and other lines. END IF LOOP UNTIL EOF(1) CLOSE #1 END SUB SUB ScanDirectory (Dir$) Length& = FindFile(Dir$) ShowDir$ = Dir$ Dir$ = RootPath$ + "\" + Dir$ IF (ASC(FileInfo.Attribute + Nul) AND 16) AND RIGHT$(Dir$, 1) <> "\" AND RIGHT$(Dir$, 1) <> "*" THEN ShowDir$ = ShowDir$ + "\*.*" Dir$ = Dir$ + "\*.*" END IF IF RIGHT$(Dir$, 1) = ":" OR RIGHT$(Dir$, 1) = "\" THEN Dir$ = Dir$ + "*.*" ShowDir$ = ShowDir$ + "*.*" END IF Number% = 1 Length& = FindFile(Dir$) PRINT #1, "" PRINT #1, "Directory of " + ShowDir$ PRINT #1, "=====================================" PRINT #1, "Filename Size Date " PRINT #1, "=====================================" DO WHILE Length& >= 0 IF LEFT$(FileInfo.filename, 1) <> "." THEN IF ASC(FileInfo.Attribute + Nul) AND 16 THEN Size$ = "[DIR]" ELSE Size$ = RIGHT$(" " + LTRIM$(STR$(FileInfo.Size \ 1024)) + " Kb", 9) END IF PRINT #1, USING "\ \ \ \ \ \"; FileInfo.filename; Size$; FileInfo.Date Number% = Number% + 1 END IF Length& = FindFile("") LOOP END SUB ' SUB SetDrive (drive$) drivenum = ASC(drive$) - 65 IF drivenum >= 0 AND drivenum <= 25 THEN inreg.ax = &HE00 inreg.dx = drivenum INTERRUPTX &H21, inreg, outreg END IF END SUB SUB ShowProgInfo CLS PRINT "SENDFILE Version " + ver$ + ", 6-May-2005" PRINT PRINT "Written by Stephen Knight http://www.dragon-it.co.uk/" PRINT PRINT "You have not specified a mail filename!" PRINT PRINT "You need to call this program with an argument :" PRINT PRINT "eg SENDFILE c:\temp\32424232.pm$" PRINT PRINT "The paramater is the filename of a message file containing the commands" PRINT "to be parsed for requests and is added automatically when called by a Pegasus" PRINT "Run A Program filter item. " PRINT PRINT "Press any key to exit" PRINT SLEEP END END SUB SUB StartUp PRINT "Filename : "; filename$ IF filename$ = "" THEN PRINT "Usage : SENDFILE " PRINT PRINT "This program will scan a mail message for commands to send files, directory" PRINT "listings etc. See the file SENDFILE.TXT for more information." PRINT PRINT "If used with pegasus filter the filename will be supplied" PRINT "automatically using a Run A Program filter." PRINT PRINT "Press any key" SLEEP END END IF 'split off filename PRINT "Scanning message "; filename$ PRINT PRINT "Program by Stephen Knight ( http://www.dragon-it.co.uk/ )" PRINT END SUB FUNCTION StripCR$ (aline$) IF RIGHT$(aline$, 1) = CHR$(13) OR RIGHT$(aline$, 1) = CHR$(10) THEN stripped$ = LEFT$(aline$, LEN(aline$) - 1) ELSE stripped$ = aline$ END IF IF LEFT$(stripped$, 1) = CHR$(10) THEN stripped$ = MID$(stripped$, 1) PRINT "strip chr(10)" END IF StripCR$ = stripped$ END FUNCTION FUNCTION StripToZero$ (in$) position = INSTR(in$, Nul) IF position > 0 THEN StripToZero$ = LEFT$(in$, position - 1) ELSE StripToZero$ = in$ END IF END FUNCTION SUB Worm Tail$ = CHR$(234): Head$ = CHR$(1) max = 10: dx = -1: dy = -1 REDIM x(max), y(max), C$(max) FOR A = 1 TO max x(A) = 40: y(A) = 18: C$(A) = " " NEXT COLOR 10, 0 DO C$(max) = CHR$(SCREEN(y(max) + dy, x(max) + dx)) IF C$(max) <> " " OR (dx = 0 AND dy = 0) OR n = 6 THEN stuck = 0 DO stuck = stuck + 1 dx = INT(RND * 2 + .5) - 1: dy = INT(RND * 2 + .5) - 1 IF stuck >= 40 THEN x(max) = INT(RND * 77) + 2: y(max) = INT(RND * 21) + 2 C$(max) = CHR$(SCREEN(y(max) + dy, x(max) + dx)) LOOP UNTIL C$(max) = " " AND (dx <> 0 OR dy <> 0) n = 0 END IF n = n + 1 y(max) = y(max) + dy: x(max) = x(max) + dx IF x(max) < 2 THEN x(max) = 2: dx = 1 ELSE IF x(max) > 79 THEN x(max) = 79: dx = -1 IF y(max) < 2 THEN y(max) = 2: dy = 1 ELSE IF y(max) > 23 THEN y(max) = 23: dy = -1 PrintAt x(max), y(max), Head$ PrintAt x(max - 1), y(max - 1), Tail$ Delay 1 PrintAt x(1), y(1), C$(1) FOR A = 2 TO max x(A - 1) = x(A) y(A - 1) = y(A) C$(A - 1) = C$(A) NEXT LOOP UNTIL INKEY$ <> "" FOR A = 1 TO max PrintAt x(A), y(A), C$(A) NEXT Colour -1, -1 END SUB SUB WriteToLog (operation$, info$) 19 ' ** Writing to Log file ** IF Log$ = "Y" THEN WRITE #9, DATE$, TIME$, LogFromLine$, operation$, ChangeChar$(info$, CHR$(34), "'") END IF END SUB