[793] | 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 |
|
---|
[907] | 15 | #include <string.h>
|
---|
| 16 |
|
---|
[2] | 17 | #define INCL_DOS
|
---|
| 18 | #define INCL_WIN
|
---|
[907] | 19 | #define INCL_LONGLONG // dircnrs.h
|
---|
[2] | 20 |
|
---|
[1179] | 21 | #include "fm3dll.h"
|
---|
[2] | 22 | #include "fm3dlg.h"
|
---|
| 23 | #include "fm3str.h"
|
---|
[907] | 24 | #include "errutil.h" // Dos_Error...
|
---|
| 25 | #include "strutil.h" // GetPString
|
---|
[1157] | 26 | #include "fm2cmd.h"
|
---|
| 27 | #include "mainwnd.h" // FindDirCnrByName
|
---|
[1179] | 28 | #include "valid.h" // MakeFullName
|
---|
| 29 | #include "misc.h" // PostMsg
|
---|
| 30 | #include "delims.h" // skip_delim
|
---|
[2] | 31 |
|
---|
| 32 | #pragma data_seg(DATA2)
|
---|
| 33 |
|
---|
[551] | 34 | static VOID fullname(CHAR * directory, CHAR * name)
|
---|
| 35 | {
|
---|
[2] | 36 |
|
---|
| 37 | CHAR temp[CCHMAXPATH];
|
---|
| 38 |
|
---|
[551] | 39 | if (!*name) {
|
---|
| 40 | strcpy(name, directory);
|
---|
[2] | 41 | return;
|
---|
| 42 | }
|
---|
[551] | 43 | if (!strchr(name, ':')) {
|
---|
| 44 | if (*name != '\\' && *name != '/') {
|
---|
| 45 | strcpy(temp, directory);
|
---|
| 46 | if (directory[strlen(directory) - 1] != '\\')
|
---|
| 47 | strcat(temp, "\\");
|
---|
[2] | 48 | }
|
---|
| 49 | else {
|
---|
| 50 | *temp = *directory;
|
---|
| 51 | temp[1] = ':';
|
---|
| 52 | temp[2] = 0;
|
---|
| 53 | }
|
---|
[551] | 54 | strcat(temp, name);
|
---|
| 55 | strcpy(name, temp);
|
---|
[2] | 56 | }
|
---|
| 57 | MakeFullName(name);
|
---|
| 58 | }
|
---|
| 59 |
|
---|
[551] | 60 | static VOID parse(CHAR * command, CHAR * key, CHAR * rest)
|
---|
| 61 | {
|
---|
[2] | 62 |
|
---|
| 63 | CHAR *p;
|
---|
| 64 |
|
---|
| 65 | *key = *rest = 0;
|
---|
[551] | 66 | strcpy(key, command);
|
---|
| 67 | p = strchr(key, ' ');
|
---|
| 68 | if (p) {
|
---|
[2] | 69 | *p = 0;
|
---|
| 70 | p++;
|
---|
[551] | 71 | p = skip_delim(p, " \t");
|
---|
| 72 | strcpy(rest, p);
|
---|
[2] | 73 | }
|
---|
| 74 | }
|
---|
| 75 |
|
---|
[551] | 76 | BOOL FM2Command(CHAR * directory, CHAR * command)
|
---|
| 77 | {
|
---|
[2] | 78 |
|
---|
| 79 | BOOL ret = FALSE;
|
---|
[551] | 80 | CHAR key[CCHMAXPATH], rest[CCHMAXPATH];
|
---|
[2] | 81 | HWND hwnd;
|
---|
| 82 |
|
---|
[551] | 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);
|
---|
[2] | 88 | ret = TRUE;
|
---|
| 89 | }
|
---|
[551] | 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);
|
---|
[2] | 95 | ret = TRUE;
|
---|
| 96 | }
|
---|
[551] | 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));
|
---|
[2] | 101 | ret = TRUE;
|
---|
| 102 | }
|
---|
[551] | 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;
|
---|
[2] | 108 | }
|
---|
| 109 | }
|
---|
[551] | 110 | else if (!stricmp(key, GetPString(IDS_KEEPCMDTEXT)) ||
|
---|
| 111 | !stricmp(key, GetPString(IDS_NOKEEPCMDTEXT))) {
|
---|
| 112 | if (!stricmp(key, GetPString(IDS_NOKEEPCMDTEXT)))
|
---|
| 113 | fKeepCmdLine = FALSE;
|
---|
[2] | 114 | else
|
---|
[551] | 115 | fKeepCmdLine = TRUE;
|
---|
| 116 | PrfWriteProfileData(fmprof, FM3Str, "KeepCmdLine", &fKeepCmdLine,
|
---|
| 117 | sizeof(BOOL));
|
---|
[2] | 118 | ret = TRUE;
|
---|
| 119 | }
|
---|
[551] | 120 | else if (!stricmp(key, GetPString(IDS_SAVECMDTEXT)) ||
|
---|
| 121 | !stricmp(key, GetPString(IDS_NOSAVECMDTEXT))) {
|
---|
| 122 | if (!stricmp(key, GetPString(IDS_NOSAVECMDTEXT)))
|
---|
| 123 | fSaveMiniCmds = FALSE;
|
---|
[2] | 124 | else
|
---|
[551] | 125 | fSaveMiniCmds = TRUE;
|
---|
| 126 | PrfWriteProfileData(fmprof, FM3Str, "SaveMiniCmds", &fSaveMiniCmds,
|
---|
| 127 | sizeof(BOOL));
|
---|
[2] | 128 | ret = TRUE;
|
---|
| 129 | }
|
---|
| 130 | }
|
---|
| 131 | return ret;
|
---|
| 132 | }
|
---|
[793] | 133 |
|
---|
| 134 | #pragma alloc_text(FM2CMD,FM2Command,fullname,parse)
|
---|