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