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