source: trunk/dll/fm2cmd.c@ 1223

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

Ticket 187: Moved typedef's and some #define's from fm3dll.h

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