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