[793] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: fm2cmd.c 1223 2008-09-13 23:11:11Z jbs $
|
---|
| 5 |
|
---|
| 6 | Copyright (c) 1993-98 M. Kimes
|
---|
| 7 | Copyright (c) 2003, 2007 Steven H.Levine
|
---|
| 8 |
|
---|
| 9 | Command processing
|
---|
| 10 |
|
---|
| 11 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
| 12 |
|
---|
| 13 | ***********************************************************************/
|
---|
| 14 |
|
---|
[907] | 15 | #include <string.h>
|
---|
| 16 |
|
---|
[2] | 17 | #define INCL_DOS
|
---|
| 18 | #define INCL_WIN
|
---|
[907] | 19 | #define INCL_LONGLONG // dircnrs.h
|
---|
[2] | 20 |
|
---|
[1179] | 21 | #include "fm3dll.h"
|
---|
[1223] | 22 | #include "fm3dll2.h" // #define's for UM_*, control id's, etc.
|
---|
[1208] | 23 | #include "notebook.h" // Data declaration(s)
|
---|
[2] | 24 | #include "fm3dlg.h"
|
---|
| 25 | #include "fm3str.h"
|
---|
[907] | 26 | #include "errutil.h" // Dos_Error...
|
---|
| 27 | #include "strutil.h" // GetPString
|
---|
[1157] | 28 | #include "fm2cmd.h"
|
---|
| 29 | #include "mainwnd.h" // FindDirCnrByName
|
---|
[1179] | 30 | #include "valid.h" // MakeFullName
|
---|
| 31 | #include "misc.h" // PostMsg
|
---|
| 32 | #include "delims.h" // skip_delim
|
---|
[2] | 33 |
|
---|
[1208] | 34 | // Data definitions
|
---|
| 35 | #pragma data_seg(GLOBAL1)
|
---|
| 36 | BOOL fKeepCmdLine;
|
---|
| 37 | BOOL fSaveMiniCmds;
|
---|
| 38 |
|
---|
[2] | 39 | #pragma data_seg(DATA2)
|
---|
| 40 |
|
---|
[551] | 41 | static VOID fullname(CHAR * directory, CHAR * name)
|
---|
| 42 | {
|
---|
[2] | 43 |
|
---|
| 44 | CHAR temp[CCHMAXPATH];
|
---|
| 45 |
|
---|
[551] | 46 | if (!*name) {
|
---|
| 47 | strcpy(name, directory);
|
---|
[2] | 48 | return;
|
---|
| 49 | }
|
---|
[551] | 50 | if (!strchr(name, ':')) {
|
---|
| 51 | if (*name != '\\' && *name != '/') {
|
---|
| 52 | strcpy(temp, directory);
|
---|
| 53 | if (directory[strlen(directory) - 1] != '\\')
|
---|
| 54 | strcat(temp, "\\");
|
---|
[2] | 55 | }
|
---|
| 56 | else {
|
---|
| 57 | *temp = *directory;
|
---|
| 58 | temp[1] = ':';
|
---|
| 59 | temp[2] = 0;
|
---|
| 60 | }
|
---|
[551] | 61 | strcat(temp, name);
|
---|
| 62 | strcpy(name, temp);
|
---|
[2] | 63 | }
|
---|
| 64 | MakeFullName(name);
|
---|
| 65 | }
|
---|
| 66 |
|
---|
[551] | 67 | static VOID parse(CHAR * command, CHAR * key, CHAR * rest)
|
---|
| 68 | {
|
---|
[2] | 69 |
|
---|
| 70 | CHAR *p;
|
---|
| 71 |
|
---|
| 72 | *key = *rest = 0;
|
---|
[551] | 73 | strcpy(key, command);
|
---|
| 74 | p = strchr(key, ' ');
|
---|
| 75 | if (p) {
|
---|
[2] | 76 | *p = 0;
|
---|
| 77 | p++;
|
---|
[551] | 78 | p = skip_delim(p, " \t");
|
---|
| 79 | strcpy(rest, p);
|
---|
[2] | 80 | }
|
---|
| 81 | }
|
---|
| 82 |
|
---|
[551] | 83 | BOOL FM2Command(CHAR * directory, CHAR * command)
|
---|
| 84 | {
|
---|
[2] | 85 |
|
---|
| 86 | BOOL ret = FALSE;
|
---|
[551] | 87 | CHAR key[CCHMAXPATH], rest[CCHMAXPATH];
|
---|
[2] | 88 | HWND hwnd;
|
---|
| 89 |
|
---|
[551] | 90 | if (command && *command == '/') {
|
---|
| 91 | parse(command, key, rest);
|
---|
| 92 | if (!stricmp(key, GetPString(IDS_OPENCMDTEXT))) {
|
---|
| 93 | fullname(directory, rest);
|
---|
| 94 | WinSendMsg(hwndTree, UM_OPENWINDOWFORME, MPFROMP(rest), MPVOID);
|
---|
[2] | 95 | ret = TRUE;
|
---|
| 96 | }
|
---|
[551] | 97 | else if (!stricmp(key, GetPString(IDS_CLOSECMDTEXT))) {
|
---|
| 98 | fullname(directory, rest);
|
---|
| 99 | hwnd = FindDirCnrByName(rest, FALSE);
|
---|
| 100 | if (hwnd)
|
---|
| 101 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
[2] | 102 | ret = TRUE;
|
---|
| 103 | }
|
---|
[551] | 104 | else if (!stricmp(key, GetPString(IDS_HELPCMDTEXT))) {
|
---|
| 105 | saymsg(MB_ENTER, (hwndMain) ? hwndMain : HWND_DESKTOP,
|
---|
| 106 | GetPString(IDS_FM2CMDHELPHDRTEXT), "%s",
|
---|
| 107 | GetPString(IDS_FM2CMDHELPTEXT));
|
---|
[2] | 108 | ret = TRUE;
|
---|
| 109 | }
|
---|
[551] | 110 | else if (!stricmp(key, GetPString(IDS_FILTERCMDTEXT))) {
|
---|
| 111 | hwnd = FindDirCnrByName(directory, FALSE);
|
---|
| 112 | if (hwnd) {
|
---|
| 113 | WinSendMsg(hwnd, UM_FILTER, MPFROMP(rest), MPVOID);
|
---|
| 114 | ret = TRUE;
|
---|
[2] | 115 | }
|
---|
| 116 | }
|
---|
[551] | 117 | else if (!stricmp(key, GetPString(IDS_KEEPCMDTEXT)) ||
|
---|
| 118 | !stricmp(key, GetPString(IDS_NOKEEPCMDTEXT))) {
|
---|
| 119 | if (!stricmp(key, GetPString(IDS_NOKEEPCMDTEXT)))
|
---|
| 120 | fKeepCmdLine = FALSE;
|
---|
[2] | 121 | else
|
---|
[551] | 122 | fKeepCmdLine = TRUE;
|
---|
| 123 | PrfWriteProfileData(fmprof, FM3Str, "KeepCmdLine", &fKeepCmdLine,
|
---|
| 124 | sizeof(BOOL));
|
---|
[2] | 125 | ret = TRUE;
|
---|
| 126 | }
|
---|
[551] | 127 | else if (!stricmp(key, GetPString(IDS_SAVECMDTEXT)) ||
|
---|
| 128 | !stricmp(key, GetPString(IDS_NOSAVECMDTEXT))) {
|
---|
| 129 | if (!stricmp(key, GetPString(IDS_NOSAVECMDTEXT)))
|
---|
| 130 | fSaveMiniCmds = FALSE;
|
---|
[2] | 131 | else
|
---|
[551] | 132 | fSaveMiniCmds = TRUE;
|
---|
| 133 | PrfWriteProfileData(fmprof, FM3Str, "SaveMiniCmds", &fSaveMiniCmds,
|
---|
| 134 | sizeof(BOOL));
|
---|
[2] | 135 | ret = TRUE;
|
---|
| 136 | }
|
---|
| 137 | }
|
---|
| 138 | return ret;
|
---|
| 139 | }
|
---|
[793] | 140 |
|
---|
| 141 | #pragma alloc_text(FM2CMD,FM2Command,fullname,parse)
|
---|