| [793] | 1 | 
 | 
|---|
 | 2 | /***********************************************************************
 | 
|---|
 | 3 | 
 | 
|---|
 | 4 |   $Id: fm2cmd.c 1482 2009-12-13 19:59:47Z gyoung $
 | 
|---|
 | 5 | 
 | 
|---|
 | 6 |   Copyright (c) 1993-98 M. Kimes
 | 
|---|
| [1347] | 7 |   Copyright (c) 2003, 2008 Steven H.Levine
 | 
|---|
| [793] | 8 | 
 | 
|---|
 | 9 |   Command processing
 | 
|---|
 | 10 | 
 | 
|---|
 | 11 |   20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
 | 
|---|
| [1438] | 12 |   28 Jun 09 GKY Added AddBackslashToPath() to remove repeatative code.
 | 
|---|
| [1482] | 13 |   13 Dec 09 GKY Fixed separate paramenters. Please note that appname should be used in
 | 
|---|
 | 14 |                 profile calls for user settings that work and are setable in more than one
 | 
|---|
 | 15 |                 miniapp; FM3Str should be used for setting only relavent to FM/2 or that
 | 
|---|
 | 16 |                 aren't user settable; realappname should be used for setting applicable to
 | 
|---|
 | 17 |                 one or more miniapp but not to FM/2
 | 
|---|
| [793] | 18 | 
 | 
|---|
 | 19 | ***********************************************************************/
 | 
|---|
 | 20 | 
 | 
|---|
| [907] | 21 | #include <string.h>
 | 
|---|
 | 22 | 
 | 
|---|
| [2] | 23 | #define INCL_DOS
 | 
|---|
 | 24 | #define INCL_WIN
 | 
|---|
| [907] | 25 | #define INCL_LONGLONG                   // dircnrs.h
 | 
|---|
| [2] | 26 | 
 | 
|---|
| [1179] | 27 | #include "fm3dll.h"
 | 
|---|
| [1223] | 28 | #include "fm3dll2.h"                    // #define's for UM_*, control id's, etc.
 | 
|---|
| [1208] | 29 | #include "notebook.h"                   // Data declaration(s)
 | 
|---|
| [2] | 30 | #include "fm3dlg.h"
 | 
|---|
 | 31 | #include "fm3str.h"
 | 
|---|
| [907] | 32 | #include "errutil.h"                    // Dos_Error...
 | 
|---|
 | 33 | #include "strutil.h"                    // GetPString
 | 
|---|
| [1157] | 34 | #include "fm2cmd.h"
 | 
|---|
 | 35 | #include "mainwnd.h"                    // FindDirCnrByName
 | 
|---|
| [1179] | 36 | #include "valid.h"                      // MakeFullName
 | 
|---|
 | 37 | #include "misc.h"                       // PostMsg
 | 
|---|
 | 38 | #include "delims.h"                     // skip_delim
 | 
|---|
| [1438] | 39 | #include "pathutil.h"                   // AddBackslashToPath
 | 
|---|
| [2] | 40 | 
 | 
|---|
| [1229] | 41 | 
 | 
|---|
 | 42 | static VOID fullname(CHAR * directory, CHAR * name);
 | 
|---|
 | 43 | static VOID parse(CHAR * command, CHAR * key, CHAR * rest);
 | 
|---|
 | 44 | 
 | 
|---|
| [1208] | 45 | // Data definitions
 | 
|---|
 | 46 | #pragma data_seg(GLOBAL1)
 | 
|---|
 | 47 | BOOL fKeepCmdLine;
 | 
|---|
 | 48 | BOOL fSaveMiniCmds;
 | 
|---|
 | 49 | 
 | 
|---|
| [2] | 50 | #pragma data_seg(DATA2)
 | 
|---|
 | 51 | 
 | 
|---|
| [551] | 52 | static VOID fullname(CHAR * directory, CHAR * name)
 | 
|---|
 | 53 | {
 | 
|---|
| [2] | 54 | 
 | 
|---|
 | 55 |   CHAR temp[CCHMAXPATH];
 | 
|---|
 | 56 | 
 | 
|---|
| [551] | 57 |   if (!*name) {
 | 
|---|
 | 58 |     strcpy(name, directory);
 | 
|---|
| [2] | 59 |     return;
 | 
|---|
 | 60 |   }
 | 
|---|
| [551] | 61 |   if (!strchr(name, ':')) {
 | 
|---|
 | 62 |     if (*name != '\\' && *name != '/') {
 | 
|---|
 | 63 |       strcpy(temp, directory);
 | 
|---|
| [1438] | 64 |       AddBackslashToPath(directory);
 | 
|---|
 | 65 |       //if (directory[strlen(directory) - 1] != '\\')
 | 
|---|
 | 66 |       //  strcat(temp, "\\");
 | 
|---|
| [2] | 67 |     }
 | 
|---|
 | 68 |     else {
 | 
|---|
 | 69 |       *temp = *directory;
 | 
|---|
 | 70 |       temp[1] = ':';
 | 
|---|
 | 71 |       temp[2] = 0;
 | 
|---|
 | 72 |     }
 | 
|---|
| [551] | 73 |     strcat(temp, name);
 | 
|---|
 | 74 |     strcpy(name, temp);
 | 
|---|
| [2] | 75 |   }
 | 
|---|
 | 76 |   MakeFullName(name);
 | 
|---|
 | 77 | }
 | 
|---|
 | 78 | 
 | 
|---|
| [551] | 79 | static VOID parse(CHAR * command, CHAR * key, CHAR * rest)
 | 
|---|
 | 80 | {
 | 
|---|
| [2] | 81 | 
 | 
|---|
 | 82 |   CHAR *p;
 | 
|---|
 | 83 | 
 | 
|---|
 | 84 |   *key = *rest = 0;
 | 
|---|
| [551] | 85 |   strcpy(key, command);
 | 
|---|
 | 86 |   p = strchr(key, ' ');
 | 
|---|
 | 87 |   if (p) {
 | 
|---|
| [2] | 88 |     *p = 0;
 | 
|---|
 | 89 |     p++;
 | 
|---|
| [551] | 90 |     p = skip_delim(p, " \t");
 | 
|---|
 | 91 |     strcpy(rest, p);
 | 
|---|
| [2] | 92 |   }
 | 
|---|
 | 93 | }
 | 
|---|
 | 94 | 
 | 
|---|
| [551] | 95 | BOOL FM2Command(CHAR * directory, CHAR * command)
 | 
|---|
 | 96 | {
 | 
|---|
| [2] | 97 | 
 | 
|---|
 | 98 |   BOOL ret = FALSE;
 | 
|---|
| [551] | 99 |   CHAR key[CCHMAXPATH], rest[CCHMAXPATH];
 | 
|---|
| [2] | 100 |   HWND hwnd;
 | 
|---|
 | 101 | 
 | 
|---|
| [551] | 102 |   if (command && *command == '/') {
 | 
|---|
 | 103 |     parse(command, key, rest);
 | 
|---|
 | 104 |     if (!stricmp(key, GetPString(IDS_OPENCMDTEXT))) {
 | 
|---|
 | 105 |       fullname(directory, rest);
 | 
|---|
 | 106 |       WinSendMsg(hwndTree, UM_OPENWINDOWFORME, MPFROMP(rest), MPVOID);
 | 
|---|
| [2] | 107 |       ret = TRUE;
 | 
|---|
 | 108 |     }
 | 
|---|
| [551] | 109 |     else if (!stricmp(key, GetPString(IDS_CLOSECMDTEXT))) {
 | 
|---|
 | 110 |       fullname(directory, rest);
 | 
|---|
 | 111 |       hwnd = FindDirCnrByName(rest, FALSE);
 | 
|---|
 | 112 |       if (hwnd)
 | 
|---|
 | 113 |         PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
 | 
|---|
| [2] | 114 |       ret = TRUE;
 | 
|---|
 | 115 |     }
 | 
|---|
| [551] | 116 |     else if (!stricmp(key, GetPString(IDS_HELPCMDTEXT))) {
 | 
|---|
 | 117 |       saymsg(MB_ENTER, (hwndMain) ? hwndMain : HWND_DESKTOP,
 | 
|---|
| [1402] | 118 |              GetPString(IDS_FM2CMDHELPHDRTEXT), GetPString(IDS_FM2CMDHELPTEXT));
 | 
|---|
| [2] | 119 |       ret = TRUE;
 | 
|---|
 | 120 |     }
 | 
|---|
| [551] | 121 |     else if (!stricmp(key, GetPString(IDS_FILTERCMDTEXT))) {
 | 
|---|
 | 122 |       hwnd = FindDirCnrByName(directory, FALSE);
 | 
|---|
 | 123 |       if (hwnd) {
 | 
|---|
 | 124 |         WinSendMsg(hwnd, UM_FILTER, MPFROMP(rest), MPVOID);
 | 
|---|
 | 125 |         ret = TRUE;
 | 
|---|
| [2] | 126 |       }
 | 
|---|
 | 127 |     }
 | 
|---|
| [551] | 128 |     else if (!stricmp(key, GetPString(IDS_KEEPCMDTEXT)) ||
 | 
|---|
 | 129 |              !stricmp(key, GetPString(IDS_NOKEEPCMDTEXT))) {
 | 
|---|
 | 130 |       if (!stricmp(key, GetPString(IDS_NOKEEPCMDTEXT)))
 | 
|---|
 | 131 |         fKeepCmdLine = FALSE;
 | 
|---|
| [2] | 132 |       else
 | 
|---|
| [551] | 133 |         fKeepCmdLine = TRUE;
 | 
|---|
| [1482] | 134 |       PrfWriteProfileData(fmprof, appname, "KeepCmdLine", &fKeepCmdLine,
 | 
|---|
| [551] | 135 |                           sizeof(BOOL));
 | 
|---|
| [2] | 136 |       ret = TRUE;
 | 
|---|
 | 137 |     }
 | 
|---|
| [551] | 138 |     else if (!stricmp(key, GetPString(IDS_SAVECMDTEXT)) ||
 | 
|---|
 | 139 |              !stricmp(key, GetPString(IDS_NOSAVECMDTEXT))) {
 | 
|---|
 | 140 |       if (!stricmp(key, GetPString(IDS_NOSAVECMDTEXT)))
 | 
|---|
 | 141 |         fSaveMiniCmds = FALSE;
 | 
|---|
| [2] | 142 |       else
 | 
|---|
| [551] | 143 |         fSaveMiniCmds = TRUE;
 | 
|---|
| [1482] | 144 |       PrfWriteProfileData(fmprof, appname, "SaveMiniCmds", &fSaveMiniCmds,
 | 
|---|
| [551] | 145 |                           sizeof(BOOL));
 | 
|---|
| [2] | 146 |       ret = TRUE;
 | 
|---|
 | 147 |     }
 | 
|---|
 | 148 |   }
 | 
|---|
 | 149 |   return ret;
 | 
|---|
 | 150 | }
 | 
|---|
| [793] | 151 | 
 | 
|---|
 | 152 | #pragma alloc_text(FM2CMD,FM2Command,fullname,parse)
 | 
|---|