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