source: trunk/dll/fm2cmd.c@ 1402

Last change on this file since 1402 was 1402, checked in by Gregg Young, 16 years ago

Remove variable aurgs from docopy & unlinkf (not used); Move more strings to PCSZs and string table; Move PCSZs to compile time initialization; Fix hang on startup caused by a drive scan and a dircnr scan trying to update a drive in the tree at the same time (related to the "treeswitch options); Code cleanup mainly removal of old printfs, SayMsgs, DbgMsg and unneeded %s.

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