source: trunk/dll/fm2cmd.c@ 1036

Last change on this file since 1036 was 907, checked in by Steven Levine, 18 years ago

Avoid out of memory traps in Compare Directories
Rework Compare Directories progress display for 2 second update rate
Start refactoring to reduce dependence on fm3dll.h
Add timer services (IsITimerExpired etc.)

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