source: trunk/dll/fm2cmd.c@ 1208

Last change on this file since 1208 was 1208, checked in by John Small, 17 years ago

Ticket 187: Move data declarations/definitions out of fm3dll.h

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