DEFLNG a-z DECLARE FUNCTION GetModuleFileName LIB "KERNEL32.DLL" ALIAS "GetModuleFileNameA" (BYVAL hModule AS LONG, lpFileName AS ASCIIZ, BYVAL nSize AS LONG) AS LONG DECLARE FUNCTION GetModuleHandle LIB "KERNEL32.DLL" ALIAS "GetModuleHandleA" (lpModuleName AS ASCIIZ) AS WORD FUNCTION PBMAIN() STDOUT "Eudora Deleted File Handler - Eudelf" STDOUT "By Shannon Larratt http://glider.bmezine.com/" STDOUT 'Preload options? DIM szPath AS ASCIIZ * 255 hres = GetModuleHandle("") res = GetModuleFileName(hres, szPath, 255) IF INSTR(-1, szPath, "\") > 0 THEN AppPath$ = LEFT$(szPath, INSTR(-1, szPath, "\")) END IF IF DIR$(AppPath$ & "eudelf.ini") <> "" THEN OPEN AppPath$ & "eudelf.ini" FOR INPUT AS #1 LINE INPUT #1, mblist$ LINE INPUT #1, atdir$ LINE INPUT #1, emdir$ LINE INPUT #1, cmd1$ LINE INPUT #1, cmd2$ CLOSE #1 END IF 'Get eudora mailbox list IF mblist$ <> "" THEN 'show current temp$ = mblist$ REPLACE "," WITH $CRLF IN temp$ STDOUT "Current Eudora mailboxes being scanned:" STDOUT temp$ STDOUT "USE THESE? (y/n) DO x$ = LCASE$(WAITKEY$) LOOP UNTIL x$ = "y" OR x$ = "n" IF x$ = "n" THEN mblist$ = "" STDOUT END IF IF mblist$ = "" THEN 'need input STDOUT "Please enter all the Eudora .MBX files to scan, and a blank line when done." DO LINE INPUT temp$ IF temp$ = "" THEN EXIT DO IF DIR$(temp$) = "" THEN STDOUT "ERROR: File not found (skipping)" ELSE mblist$ = mblist$ & TRIM$(temp$) & "," END IF LOOP END IF IF mblist$ = "" THEN STDOUT "FATAL ERROR: You did not enter any mailboxes" STDOUT "Exiting now." STDOUT EXIT FUNCTION END IF mblist$ = LEFT$(mblist$, LEN(mblist$)-1) 'remove trailing comma 'Get eudora attachment dir IF atdir$ <> "" THEN 'show current STDOUT "Current Eudora mailboxes attachment directory:" STDOUT atdir$ STDOUT "USE THIS? (y/n) DO x$ = LCASE$(WAITKEY$) LOOP UNTIL x$ = "y" OR x$ = "n" IF x$ = "n" THEN atdir$ = "" STDOUT END IF IF atdir$ = "" THEN 'need input STDOUT "Please enter the Eudora attachment directory:" DO LINE INPUT atdir$ IF atdir$ = "" THEN EXIT DO IF DIR$(atdir$, 16) = "" THEN STDOUT "ERROR: Directory not found" ELSE EXIT DO END IF LOOP END IF IF atdir$ = "" THEN STDOUT "FATAL ERROR: You did not enter an attachment directory" STDOUT "Exiting now." STDOUT EXIT FUNCTION END IF 'Get eudora embedded dir IF emdir$ <> "" THEN 'show current STDOUT "Current Eudora mailboxes embedded directory:" STDOUT emdir$ STDOUT "USE THIS? (y/n) DO x$ = LCASE$(WAITKEY$) LOOP UNTIL x$ = "y" OR x$ = "n" IF x$ = "n" THEN emdir$ = "" END IF IF emdir$ = "" THEN 'need input STDOUT "Please enter the Eudora embedded directory:" DO LINE INPUT emdir$ IF emdir$ = "" THEN EXIT DO IF DIR$(emdir$, 16) = "" THEN STDOUT "ERROR: Directory not found" ELSE EXIT DO END IF LOOP END IF STDOUT IF emdir$ = "" THEN STDOUT "FATAL ERROR: You did not enter an embedded directory" STDOUT "Exiting now." STDOUT EXIT FUNCTION END IF 'Load mailbox data (this could be a lot!) mbdata$ = "" nummb = PARSECOUNT(mblist$) FOR r = 1 TO nummb OPEN PARSE$(mblist$, r) FOR BINARY LOCK SHARED AS #1 GET$ #1, LOF(1), Buffer$ CLOSE #1 mbdata$ = mbdata$ & Buffer$ NEXT STDOUT "Loaded " & FORMAT$(LEN(mbdata$), ",") & " bytes of MBX data." NumAttachments = TALLY(mbdata$, "Attachment Converted:") + TALLY(mbdata$, "Embedded Content:") STDOUT "Extracting " & FORMAT$(NumAttachments, ",") & " files." DIM AtList$(NumAttachments) 'filenames 'Process Eudora mailbox list for all attachments atat = 0 curloc = 1 firstat = INSTR(mbdata$, "Attachment Converted:") IF firstat > 0 THEN DO firstat = INSTR(curloc, mbdata$, "Attachment Converted:") IF firstat = 0 THEN EXIT DO curloc = firstat + 21 firstq = INSTR(curloc, mbdata$, CHR$(34)) + 1 IF firstq = 0 THEN EXIT DO 'corrupted? curloc = firstq INCR atat AtList$(atat) = lcase$(MID$(mbdata$, curloc, INSTR(curloc, mbdata$, CHR$(34)) - curloc)) LOOP STDOUT FORMAT$(atat, ",") & " attachment(s) confirmed." END IF 'Process Eudora mailbox list for all embeddeds curloc = 1 tatat = atat firstat = INSTR(mbdata$, "Embedded Content:") IF firstat > 0 THEN DO firstat = INSTR(curloc, mbdata$, "Embedded Content:") IF firstat = 0 THEN EXIT DO curloc = firstat + 18 firstq = INSTR(curloc, mbdata$, ":") + 1 IF firstq = 0 THEN EXIT DO 'corrupted? INCR atat AtList$(atat) = LCASE$(emdir$ & "\" & MID$(mbdata$, curloc, (firstq - curloc) - 1)) curloc = firstq LOOP STDOUT FORMAT$(atat - tatat, ",") & " embedded(s) confirmed." END IF 'Display? ARRAY SORT AtList$() FOR atat IF cmd1$ <> "" THEN 'output file for FOUND list STDOUT STDOUT "Current output file for FOUND files:" STDOUT cmd1$ STDOUT "USE THIS? (y/n) DO x$ = LCASE$(WAITKEY$) LOOP UNTIL x$ = "y" OR x$ = "n" IF x$ = "n" THEN cmd1$ = "" END IF STDOUT IF cmd1$ = "" THEN 'need input STDOUT "Please enter a filename to write the FOUND list to (or none to skip):" LINE INPUT cmd1$ END IF cmd1$ = TRIM$(cmd1$) IF cmd1$ = "" THEN STDOUT "(Skipping)" ELSE 'Output list OPEN cmd1$ FOR OUTPUT AS #1 FOR r = 1 TO atat thisfile$ = AtList$(r) IF INSTR(thisfile$, " ") > 0 THEN thisfile$ = """" & thisfile$ & """" PRINT #1, "*CMD* " & thisfile$ & " *OPT*" NEXT CLOSE #1 STDOUT "Wrote " & FORMAT$(atat, ",") & " protocommands to " & cmd1$ END IF 'Display? IF cmd2$ <> "" THEN 'output file for FOUND list STDOUT STDOUT "Current output file for LOST files:" STDOUT cmd2$ STDOUT "USE THIS? (y/n) DO x$ = LCASE$(WAITKEY$) LOOP UNTIL x$ = "y" OR x$ = "n" IF x$ = "n" THEN cmd2$ = "" END IF STDOUT IF cmd2$ = "" THEN 'need input STDOUT "Please enter a filename to write the LOST list to (or none to skip):" LINE INPUT cmd2$ END IF cmd2$ = TRIM$(cmd2$) 'Write command so it can be repeated IF AppPath$ <> "" THEN OPEN AppPath$ & "eudelf.ini" FOR OUTPUT AS #1 PRINT #1, mblist$ PRINT #1, atdir$ PRINT #1, emdir$ PRINT #1, cmd1$ PRINT #1, cmd2$ CLOSE #1 END IF IF cmd2$ = "" THEN STDOUT "(Skipping)" STDOUT STDOUT "ALL DONE!" STDOUT EXIT FUNCTION END IF 'Load list of all files currently in attachments directory tempsize = 0 STDOUT "Scanning directories..."; x$ = DIR$(atdir$ & "\*.*") ctr = 0 DO UNTIL x$ = "" INCR ctr IF ctr > 1999 THEN ctr = 0 STDOUT "."; END IF INCR tempsize x$ = DIR$ LOOP x$ = DIR$(emdir$ & "\*.*") DO UNTIL x$ = "" INCR ctr IF ctr > 1999 THEN ctr = 0 STDOUT "."; END IF INCR tempsize x$ = DIR$ LOOP DIM DirFiles$(tempsize) atrf = 0 x$ = DIR$(atdir$ & "\*.*") DO UNTIL x$ = "" INCR ctr IF ctr > 1999 THEN ctr = 0 STDOUT "."; END IF INCR atrf DirFiles$(atrf) = LCASE$(atdir$ & "\" & x$) x$ = DIR$ LOOP x$ = DIR$(emdir$ & "\*.*") DO UNTIL x$ = "" INCR ctr IF ctr > 1999 THEN ctr = 0 STDOUT "."; END IF INCR atrf DirFiles$(atrf) = LCASE$(emdir$ & "\" & x$) x$ = DIR$ LOOP STDOUT FORMAT$(tempsize, ",") & " files" 'Subtract mailbox list from attachments (leaving unreferenced files) 'Note: this could be radically sped up. It's sloppy at best. mcount = 0 'match counter STDOUT "Please wait... subtracting... "; FOR r = 1 TO atat 'scan through all FOUND files, and remove them if match discovered FOR t = 1 TO atrf IF AtList$(r) = DirFiles$(t) THEN INCR mcount DirFiles$(t) = "" EXIT FOR END IF NEXT NEXT STDOUT "Done" STDOUT STDOUT "Verified " & FORMAT$(mcount, ",") & " file(s) (leaving " & FORMAT$(atrf - mcount, ",") & ")" STDOUT OPEN cmd2$ FOR OUTPUT AS #1 FOR r = 1 TO atrf thisfile$ = DirFiles$(r) IF thisfile$ <> "" THEN IF INSTR(thisfile$, " ") > 0 THEN thisfile$ = """" & thisfile$ & """" PRINT #1, "*CMD* " & thisfile$ & " *OPT*" END IF NEXT CLOSE #1 STDOUT "Wrote " & FORMAT$(atat, ",") & " protocommands to " & cmd2$ STDOUT STDOUT "ALL DONE!" STDOUT END FUNCTION