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