[793] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: fm2cmd.c 1402 2009-03-14 17:17:59Z gyoung $
|
---|
| 5 |
|
---|
| 6 | Copyright (c) 1993-98 M. Kimes
|
---|
[1347] | 7 | Copyright (c) 2003, 2008 Steven H.Levine
|
---|
[793] | 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 |
|
---|
[1229] | 34 |
|
---|
| 35 | static VOID fullname(CHAR * directory, CHAR * name);
|
---|
| 36 | static VOID parse(CHAR * command, CHAR * key, CHAR * rest);
|
---|
| 37 |
|
---|
[1208] | 38 | // Data definitions
|
---|
| 39 | #pragma data_seg(GLOBAL1)
|
---|
| 40 | BOOL fKeepCmdLine;
|
---|
| 41 | BOOL fSaveMiniCmds;
|
---|
| 42 |
|
---|
[2] | 43 | #pragma data_seg(DATA2)
|
---|
| 44 |
|
---|
[551] | 45 | static VOID fullname(CHAR * directory, CHAR * name)
|
---|
| 46 | {
|
---|
[2] | 47 |
|
---|
| 48 | CHAR temp[CCHMAXPATH];
|
---|
| 49 |
|
---|
[551] | 50 | if (!*name) {
|
---|
| 51 | strcpy(name, directory);
|
---|
[2] | 52 | return;
|
---|
| 53 | }
|
---|
[551] | 54 | if (!strchr(name, ':')) {
|
---|
| 55 | if (*name != '\\' && *name != '/') {
|
---|
| 56 | strcpy(temp, directory);
|
---|
| 57 | if (directory[strlen(directory) - 1] != '\\')
|
---|
| 58 | strcat(temp, "\\");
|
---|
[2] | 59 | }
|
---|
| 60 | else {
|
---|
| 61 | *temp = *directory;
|
---|
| 62 | temp[1] = ':';
|
---|
| 63 | temp[2] = 0;
|
---|
| 64 | }
|
---|
[551] | 65 | strcat(temp, name);
|
---|
| 66 | strcpy(name, temp);
|
---|
[2] | 67 | }
|
---|
| 68 | MakeFullName(name);
|
---|
| 69 | }
|
---|
| 70 |
|
---|
[551] | 71 | static VOID parse(CHAR * command, CHAR * key, CHAR * rest)
|
---|
| 72 | {
|
---|
[2] | 73 |
|
---|
| 74 | CHAR *p;
|
---|
| 75 |
|
---|
| 76 | *key = *rest = 0;
|
---|
[551] | 77 | strcpy(key, command);
|
---|
| 78 | p = strchr(key, ' ');
|
---|
| 79 | if (p) {
|
---|
[2] | 80 | *p = 0;
|
---|
| 81 | p++;
|
---|
[551] | 82 | p = skip_delim(p, " \t");
|
---|
| 83 | strcpy(rest, p);
|
---|
[2] | 84 | }
|
---|
| 85 | }
|
---|
| 86 |
|
---|
[551] | 87 | BOOL FM2Command(CHAR * directory, CHAR * command)
|
---|
| 88 | {
|
---|
[2] | 89 |
|
---|
| 90 | BOOL ret = FALSE;
|
---|
[551] | 91 | CHAR key[CCHMAXPATH], rest[CCHMAXPATH];
|
---|
[2] | 92 | HWND hwnd;
|
---|
| 93 |
|
---|
[551] | 94 | if (command && *command == '/') {
|
---|
| 95 | parse(command, key, rest);
|
---|
| 96 | if (!stricmp(key, GetPString(IDS_OPENCMDTEXT))) {
|
---|
| 97 | fullname(directory, rest);
|
---|
| 98 | WinSendMsg(hwndTree, UM_OPENWINDOWFORME, MPFROMP(rest), MPVOID);
|
---|
[2] | 99 | ret = TRUE;
|
---|
| 100 | }
|
---|
[551] | 101 | else if (!stricmp(key, GetPString(IDS_CLOSECMDTEXT))) {
|
---|
| 102 | fullname(directory, rest);
|
---|
| 103 | hwnd = FindDirCnrByName(rest, FALSE);
|
---|
| 104 | if (hwnd)
|
---|
| 105 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
[2] | 106 | ret = TRUE;
|
---|
| 107 | }
|
---|
[551] | 108 | else if (!stricmp(key, GetPString(IDS_HELPCMDTEXT))) {
|
---|
| 109 | saymsg(MB_ENTER, (hwndMain) ? hwndMain : HWND_DESKTOP,
|
---|
[1402] | 110 | GetPString(IDS_FM2CMDHELPHDRTEXT), GetPString(IDS_FM2CMDHELPTEXT));
|
---|
[2] | 111 | ret = TRUE;
|
---|
| 112 | }
|
---|
[551] | 113 | else if (!stricmp(key, GetPString(IDS_FILTERCMDTEXT))) {
|
---|
| 114 | hwnd = FindDirCnrByName(directory, FALSE);
|
---|
| 115 | if (hwnd) {
|
---|
| 116 | WinSendMsg(hwnd, UM_FILTER, MPFROMP(rest), MPVOID);
|
---|
| 117 | ret = TRUE;
|
---|
[2] | 118 | }
|
---|
| 119 | }
|
---|
[551] | 120 | else if (!stricmp(key, GetPString(IDS_KEEPCMDTEXT)) ||
|
---|
| 121 | !stricmp(key, GetPString(IDS_NOKEEPCMDTEXT))) {
|
---|
| 122 | if (!stricmp(key, GetPString(IDS_NOKEEPCMDTEXT)))
|
---|
| 123 | fKeepCmdLine = FALSE;
|
---|
[2] | 124 | else
|
---|
[551] | 125 | fKeepCmdLine = TRUE;
|
---|
| 126 | PrfWriteProfileData(fmprof, FM3Str, "KeepCmdLine", &fKeepCmdLine,
|
---|
| 127 | sizeof(BOOL));
|
---|
[2] | 128 | ret = TRUE;
|
---|
| 129 | }
|
---|
[551] | 130 | else if (!stricmp(key, GetPString(IDS_SAVECMDTEXT)) ||
|
---|
| 131 | !stricmp(key, GetPString(IDS_NOSAVECMDTEXT))) {
|
---|
| 132 | if (!stricmp(key, GetPString(IDS_NOSAVECMDTEXT)))
|
---|
| 133 | fSaveMiniCmds = FALSE;
|
---|
[2] | 134 | else
|
---|
[551] | 135 | fSaveMiniCmds = TRUE;
|
---|
| 136 | PrfWriteProfileData(fmprof, FM3Str, "SaveMiniCmds", &fSaveMiniCmds,
|
---|
| 137 | sizeof(BOOL));
|
---|
[2] | 138 | ret = TRUE;
|
---|
| 139 | }
|
---|
| 140 | }
|
---|
| 141 | return ret;
|
---|
| 142 | }
|
---|
[793] | 143 |
|
---|
| 144 | #pragma alloc_text(FM2CMD,FM2Command,fullname,parse)
|
---|