source: trunk/dll/fm2cmd.c@ 1880

Last change on this file since 1880 was 1880, checked in by Gregg Young, 10 years ago

Remove dead code and comments from remaining c files. #if 0 and #if NEVER were not addressed

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
Line 
1
2/***********************************************************************
3
4 $Id: fm2cmd.c 1880 2015-10-12 18:26:16Z gyoung $
5
6 Copyright (c) 1993-98 M. Kimes
7 Copyright (c) 2003, 2008 Steven H.Levine
8
9 Command processing
10
11 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
12 28 Jun 09 GKY Added AddBackslashToPath() to remove repeatative code.
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
18
19***********************************************************************/
20
21#include <string.h>
22
23#define INCL_DOS
24#define INCL_WIN
25#define INCL_LONGLONG // dircnrs.h
26
27#include "fm3dll.h"
28#include "fm3dll2.h" // #define's for UM_*, control id's, etc.
29#include "notebook.h" // Data declaration(s)
30#include "fm3dlg.h"
31#include "fm3str.h"
32#include "errutil.h" // Dos_Error...
33#include "strutil.h" // GetPString
34#include "fm2cmd.h"
35#include "mainwnd.h" // FindDirCnrByName
36#include "valid.h" // MakeFullName
37#include "misc.h" // PostMsg
38#include "delims.h" // skip_delim
39#include "pathutil.h" // AddBackslashToPath
40
41
42static VOID fullname(CHAR * directory, CHAR * name);
43static VOID parse(CHAR * command, CHAR * key, CHAR * rest);
44
45// Data definitions
46#pragma data_seg(GLOBAL1)
47BOOL fKeepCmdLine;
48BOOL fSaveMiniCmds;
49
50#pragma data_seg(DATA2)
51
52static VOID fullname(CHAR * directory, CHAR * name)
53{
54
55 CHAR temp[CCHMAXPATH];
56
57 if (!*name) {
58 strcpy(name, directory);
59 return;
60 }
61 if (!strchr(name, ':')) {
62 if (*name != '\\' && *name != '/') {
63 strcpy(temp, directory);
64 AddBackslashToPath(directory);
65 }
66 else {
67 *temp = *directory;
68 temp[1] = ':';
69 temp[2] = 0;
70 }
71 strcat(temp, name);
72 strcpy(name, temp);
73 }
74 MakeFullName(name);
75}
76
77static VOID parse(CHAR * command, CHAR * key, CHAR * rest)
78{
79
80 CHAR *p;
81
82 *key = *rest = 0;
83 strcpy(key, command);
84 p = strchr(key, ' ');
85 if (p) {
86 *p = 0;
87 p++;
88 p = skip_delim(p, " \t");
89 strcpy(rest, p);
90 }
91}
92
93BOOL FM2Command(CHAR * directory, CHAR * command)
94{
95
96 BOOL ret = FALSE;
97 CHAR key[CCHMAXPATH], rest[CCHMAXPATH];
98 HWND hwnd;
99
100 if (command && *command == '/') {
101 parse(command, key, rest);
102 if (!stricmp(key, GetPString(IDS_OPENCMDTEXT))) {
103 fullname(directory, rest);
104 WinSendMsg(hwndTree, UM_OPENWINDOWFORME, MPFROMP(rest), MPVOID);
105 ret = TRUE;
106 }
107 else if (!stricmp(key, GetPString(IDS_CLOSECMDTEXT))) {
108 fullname(directory, rest);
109 hwnd = FindDirCnrByName(rest, FALSE);
110 if (hwnd)
111 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
112 ret = TRUE;
113 }
114 else if (!stricmp(key, GetPString(IDS_HELPCMDTEXT))) {
115 saymsg(MB_ENTER, (hwndMain) ? hwndMain : HWND_DESKTOP,
116 GetPString(IDS_FM2CMDHELPHDRTEXT), GetPString(IDS_FM2CMDHELPTEXT));
117 ret = TRUE;
118 }
119 else if (!stricmp(key, GetPString(IDS_FILTERCMDTEXT))) {
120 hwnd = FindDirCnrByName(directory, FALSE);
121 if (hwnd) {
122 WinSendMsg(hwnd, UM_FILTER, MPFROMP(rest), MPVOID);
123 ret = TRUE;
124 }
125 }
126 else if (!stricmp(key, GetPString(IDS_KEEPCMDTEXT)) ||
127 !stricmp(key, GetPString(IDS_NOKEEPCMDTEXT))) {
128 if (!stricmp(key, GetPString(IDS_NOKEEPCMDTEXT)))
129 fKeepCmdLine = FALSE;
130 else
131 fKeepCmdLine = TRUE;
132 PrfWriteProfileData(fmprof, appname, "KeepCmdLine", &fKeepCmdLine,
133 sizeof(BOOL));
134 ret = TRUE;
135 }
136 else if (!stricmp(key, GetPString(IDS_SAVECMDTEXT)) ||
137 !stricmp(key, GetPString(IDS_NOSAVECMDTEXT))) {
138 if (!stricmp(key, GetPString(IDS_NOSAVECMDTEXT)))
139 fSaveMiniCmds = FALSE;
140 else
141 fSaveMiniCmds = TRUE;
142 PrfWriteProfileData(fmprof, appname, "SaveMiniCmds", &fSaveMiniCmds,
143 sizeof(BOOL));
144 ret = TRUE;
145 }
146 }
147 return ret;
148}
149
150#pragma alloc_text(FM2CMD,FM2Command,fullname,parse)
Note: See TracBrowser for help on using the repository browser.