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