[2] | 1 |
|
---|
[862] | 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: undel.c 1341 2008-12-14 22:18:26Z stevenhl $
|
---|
| 5 |
|
---|
| 6 | File undelete applet
|
---|
| 7 |
|
---|
| 8 | Copyright (c) 1993-98 M. Kimes
|
---|
[1341] | 9 | Copyright (c) 2007, 2008 Steven H. Levine
|
---|
[862] | 10 |
|
---|
| 11 | 23 Sep 07 SHL Sync with standards
|
---|
| 12 | 23 Sep 07 SHL Get rid of statics
|
---|
[1341] | 13 | 14 Dec 08 SHL Add exception handler support
|
---|
[862] | 14 |
|
---|
| 15 | ***********************************************************************/
|
---|
| 16 |
|
---|
[2] | 17 | #include <string.h>
|
---|
[862] | 18 |
|
---|
| 19 | #define INCL_DOS
|
---|
[1341] | 20 | #define INCL_DOSEXCEPTIONS // XCTP_...
|
---|
| 21 | #define INCL_DOSERRORS // NO_ERROR
|
---|
[862] | 22 |
|
---|
[1189] | 23 | #include "dll\fm3dll.h"
|
---|
[1341] | 24 | #include "dll\mainwnd.h" // FM3ModHandle
|
---|
[907] | 25 | #include "dll\fm3dlg.h"
|
---|
[1189] | 26 | #include "dll\undel.h" // UndeleteDlgProc
|
---|
| 27 | #include "dll\init.h" // InitFM3DLL
|
---|
| 28 | #include "dll\valid.h" // MakeValidDir
|
---|
| 29 | #include "dll\dirs.h" // save_dir
|
---|
[1341] | 30 | #include "dll\errutil.h" // Error reporting
|
---|
| 31 | #include "dll\excputil.h" // Exception handlers
|
---|
[2] | 32 |
|
---|
[1341] | 33 | static PSZ pszSrcFile = __FILE__;
|
---|
| 34 |
|
---|
[551] | 35 | int main(int argc, char *argv[])
|
---|
| 36 | {
|
---|
| 37 | HAB hab;
|
---|
| 38 | HMQ hmq;
|
---|
[844] | 39 | FILESTATUS3 fs;
|
---|
[862] | 40 | CHAR fullname[CCHMAXPATH];
|
---|
[1341] | 41 | PSZ thisarg = NULL;
|
---|
| 42 | UINT x;
|
---|
| 43 | APIRET regRet;
|
---|
| 44 | EXCEPTIONREGISTRATIONRECORD regRec = { NULL, NULL };
|
---|
[2] | 45 |
|
---|
| 46 | DosError(FERR_DISABLEHARDERR);
|
---|
[1341] | 47 |
|
---|
| 48 | regRec.ExceptionHandler = HandleException;
|
---|
| 49 | regRet = DosSetExceptionHandler(®Rec);
|
---|
| 50 | if (regRet != NO_ERROR) {
|
---|
| 51 | DbgMsg(pszSrcFile, __LINE__,
|
---|
| 52 | "DosSetExceptionHandler failed with error %u", regRet);
|
---|
| 53 | }
|
---|
| 54 |
|
---|
[551] | 55 | for (x = 1; x < argc; x++) {
|
---|
| 56 | if (!strchr("/;,`\'", *argv[x]) && !thisarg) {
|
---|
[2] | 57 | thisarg = argv[x];
|
---|
| 58 | break;
|
---|
| 59 | }
|
---|
| 60 | }
|
---|
[551] | 61 | if (!thisarg) {
|
---|
[2] | 62 | thisarg = fullname;
|
---|
| 63 | save_dir(fullname);
|
---|
| 64 | }
|
---|
| 65 | DosError(FERR_DISABLEHARDERR);
|
---|
[844] | 66 | if (thisarg && !DosQueryPathInfo(thisarg, FIL_STANDARD, &fs, sizeof(fs))) {
|
---|
[551] | 67 | if (DosQueryPathInfo(thisarg,
|
---|
| 68 | FIL_QUERYFULLNAME, fullname, sizeof(fullname)))
|
---|
| 69 | strcpy(fullname, thisarg);
|
---|
[2] | 70 | hab = WinInitialize(0);
|
---|
[551] | 71 | if (hab) {
|
---|
| 72 | hmq = WinCreateMsgQueue(hab, 256);
|
---|
| 73 | if (hmq) {
|
---|
| 74 | if (InitFM3DLL(hab, argc, argv)) {
|
---|
| 75 | MakeValidDir(fullname);
|
---|
| 76 | WinDlgBox(HWND_DESKTOP,
|
---|
| 77 | HWND_DESKTOP,
|
---|
| 78 | UndeleteDlgProc,
|
---|
[862] | 79 | FM3ModHandle,
|
---|
| 80 | UNDEL_FRAME,
|
---|
| 81 | fullname);
|
---|
[551] | 82 | }
|
---|
[844] | 83 | DosSleep(250);
|
---|
[551] | 84 | WinDestroyMsgQueue(hmq);
|
---|
[2] | 85 | }
|
---|
| 86 | WinTerminate(hab);
|
---|
| 87 | }
|
---|
| 88 | }
|
---|
| 89 | else
|
---|
[551] | 90 | DosBeep(250, 100);
|
---|
[2] | 91 | return 0;
|
---|
| 92 | }
|
---|