main() { int fi, fo, total, bytes, i; char string[4096]; char szInFile[256], szOutFile[256]; while (getfile("Input file directory", "*.*", szInFile) == CR) { if ((fi = open(szInFile, "rb")) == EOF) return(Message("Couldn't open "+szInFile, TRUE)); if ((fo = open(szOutFile = Path(szInFile)+netuser()+"-"+str(rand())+"-Temp.tmp", "w+b")) == EOF) { close(fi); return(Message("Couldn't create "+szOutFile, TRUE)); } total = 0; while((bytes = read(fi, string, sizeof(string))) > 0) { /* Replace any binary characters with spaces. */ for(i = 0; i < bytes; i = i + 1) { if (string[i] < ' ') { if ((string[i] <> TAB) and (string[i] <> LF) and (string[i] <> CR)) string[i] = ' '; } } write(fo, string, bytes); Message("Bytes: "+str(total = total + bytes), FALSE); } close(fi); close(fo); erase(szInFile); rename(szOutFile, szInFile); szInFile[0] = 0; } } /* main() */ RGB(char red, grn, blu) { return(((blu & 255) * 65536) | ((grn & 255) * 256) | (red & 255)); } /**************************************************************** * Name: Message * * Synopsis: Displays error message and waits for key. * ****************************************************************/ Message(text message; int wait) { text screen; int key, rc; int fg, bk, tr, tc; if (wait) { eval('rc = messageBox(message, "Concordance", wait);', key); return(rc); } tr = 8; tc = 13; fg = RGB(0,0,0); cursoroff(); if (wait) screen = save(tr, tc, tr + 3, tc + 56); box(tr , tc , tr + 2, tc + 54,"3U", RGB(160,160,160), bk = RGB(200,200,200)); puts(tr + 1,tc + 1,pad(message,'C',53), fg, bk); if (wait) { while(keypress()) getkey(); key = getkey(); restore(tr,tc,screen); } return(asc(upper(chr(key)))); } /* Message() */ /**************************************************************** * Name: Path * * Synopsis: Returns the path up to the last \ and without * * the file's name. * ****************************************************************/ Path(text dosPath) { int i, j; if ((i = match(dosPath,":",1)) == 0) i = match(dosPath,"\",1); while(j = match(dosPath,"\",i+1)) i = j; return(substr(dosPath,1,i)); } /* Path() */ /**************************************************************** * Name: FileName * * Synopsis: Trims the path from the file name. * ****************************************************************/ FileName(text name) { int i; while(i = match(name,"\",1)) name = substr(name,i+1); return(name); } /* FileName() */ /**************************************************************** * Global Variable Declarations and Initialization * ****************************************************************/ /* findfirst() file attributes. */ int A_NORMAL = 00; /* Normal file - No read/write restrictions */ int A_RDONLY = 01; /* Read only file */ int A_HIDDEN = 02; /* Hidden file */ int A_SYSTEM = 04; /* System file */ int A_VOLID = 08; /* Volume ID file */ int A_SUBDIR = 16; /* Subdirectory */ int A_ARCH = 32; /* Archive file */ /* edit() mode attributes. A // Alpha only mode. U // Upper case conversion. N // Numeric only mode. Y // Y mode for dates. M // M mode for dates. D // D mode for dates. C // Cut and paste mode. S // Scroll field left and right, no wordwrapping. E // Return on [Enter], no CR in data. T // Always edit from the top. B // Always edit from the bottom. @ // Display only this field. ! // Return when this field is entered, don't edit. N:99.99 */ int CTRLPGUP = 33792, F11 = 34048, F12 = 34304, EOF = -1; short LEFT = 19200, RIGHT = 19712, UP = 18432, DOWN = 20480, HOME = 18176, END = 20224, PGUP = 18688, PGDN = 20736, CTRLPGDN = 30208, F1 = 15104, F2 = 15360, F3 = 15616, F4 = 15872, F5 = 16128, F6 = 16384, F7 = 16640, F8 = 16896, F9 = 17152, F10 = 17408; char ESC = 27, CTRLP = 16, FALSE = 0, TRUE = 1, TAB = 9, CR = 13, LF = 10, FF = 12; /* Standard dialog button return values. */ int IDOK = 1; int IDCANCEL = 2; int IDABORT = 3; int IDRETRY = 4; int IDIGNORE = 5; int IDYES = 6; int IDNO = 7; /* MessageBox() display options. */ int MB_OK = 0; int MB_OKCANCEL = 1; int MB_ABORTRETRYIGNORE = 2; int MB_YESNOCANCEL = 3; int MB_YESNO = 4; int MB_RETRYCANCEL = 5; int MB_ICONHAND = 16; int MB_ICONQUESTION = 32; int MB_ICONEXCLAMATION = 48; int MB_ICONASTERISK = 64; int MB_ICONINFORMATION = MB_ICONASTERISK; int MB_ICONSTOP = MB_ICONHAND; int MB_DEFBUTTON1 = 0; int MB_DEFBUTTON2 = 256; int MB_DEFBUTTON3 = 512; int MB_APPLMODAL = 0; int MB_SYSTEMMODAL = 4096; int MB_TASKMODAL = 8192; int MB_NOFOCUS = 32768; /**********************************************************/ /* The first byte of every entry in the database.TRK file */ /* indicates the type of log entry and the type of event. */ /**********************************************************/ int LOGDELETION = 'D'; int LOGDELETION_OLD = 1 ; int LOGFIELDEDITED = 2 ; int LOGTAGADDED = 4 ; int LOGTAGDELETED = 8 ; int LOGEVENTSDELETED = 'P'; int LOGREINDEX = 'R'; int LOGSECURITYDELETION = 'S'; /********************************************************/ /* Definitions for the shellExecute() command. */ /********************************************************/ int SW_HIDE = 0; int SW_MINIMIZE = 6; int SW_RESTORE = 9; int SW_SHOW = 5; int SW_SHOWMAXIMIZED = 3; int SW_SHOWMINIMIZED = 2; int SW_SHOWMINNOACTIVE = 7; int SW_SHOWNA = 8; int SW_SHOWNOACTIVATE = 4; int SW_SHOWNORMAL = 1; /********************************************************/ /* Definitions for the search() command's flag param V7.*/ /********************************************************/ int SEARCHDATABASE = 4; int SEARCHNOTES = 8; int SEARCHALL = (4|8);