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