source: trunk/dll/fm2cmd.c@ 1157

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

Ticket 187: Draft 1: Functions only

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