source: trunk/dll/fm2cmd.c@ 1347

Last change on this file since 1347 was 1347, checked in by Gregg Young, 17 years ago

More code cleanup

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