1 |
|
---|
2 | /*
|
---|
3 | *@@sourcefile wphandle.h:
|
---|
4 | * header file for wphandle.c, which contains the logic for
|
---|
5 | * dealing with those annoying WPS object handles in OS2SYS.INI.
|
---|
6 | *
|
---|
7 | * This code is mostly written by Henk Kelder and published
|
---|
8 | * with his kind permission.
|
---|
9 | *
|
---|
10 | * Note: Version numbering in this file relates to XWorkplace version
|
---|
11 | * numbering.
|
---|
12 | *
|
---|
13 | *@@include #define INCL_WINSHELLDATA
|
---|
14 | *@@include #define INCL_WINWORKPLACE
|
---|
15 | *@@include #include <os2.h>
|
---|
16 | *@@include #include "wphandle.h"
|
---|
17 | */
|
---|
18 |
|
---|
19 | /* This file Copyright (C) 1997-2000 Ulrich Mller,
|
---|
20 | * Henk Kelder.
|
---|
21 | * This file is part of the "XWorkplace helpers" source package.
|
---|
22 | * This is free software; you can redistribute it and/or modify
|
---|
23 | * it under the terms of the GNU General Public License as published by
|
---|
24 | * the Free Software Foundation, in version 2 as it comes in the COPYING
|
---|
25 | * file of the XWorkplace main distribution.
|
---|
26 | * This program is distributed in the hope that it will be useful,
|
---|
27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
29 | * GNU General Public License for more details.
|
---|
30 | */
|
---|
31 |
|
---|
32 | #if __cplusplus
|
---|
33 | extern "C" {
|
---|
34 | #endif
|
---|
35 |
|
---|
36 | #ifndef WPHANDLE_HEADER_INCLUDED
|
---|
37 | #define WPHANDLE_HEADER_INCLUDED
|
---|
38 |
|
---|
39 | /* ******************************************************************
|
---|
40 | *
|
---|
41 | * Errors
|
---|
42 | *
|
---|
43 | ********************************************************************/
|
---|
44 |
|
---|
45 | #define ERROR_WPH_FIRST 41000
|
---|
46 | #define ERROR_WPH_CRASHED (ERROR_WPH_FIRST + 0)
|
---|
47 | #define ERROR_WPH_NO_BASECLASS_DATA (ERROR_WPH_FIRST + 1)
|
---|
48 | #define ERROR_WPH_NO_ACTIVEHANDLES_DATA (ERROR_WPH_FIRST + 2)
|
---|
49 | #define ERROR_WPH_INCOMPLETE_BASECLASS_DATA (ERROR_WPH_FIRST + 3)
|
---|
50 | #define ERROR_WPH_NO_HANDLES_DATA (ERROR_WPH_FIRST + 4)
|
---|
51 | #define ERROR_WPH_CORRUPT_HANDLES_DATA (ERROR_WPH_FIRST + 5)
|
---|
52 | #define ERROR_WPH_INVALID_PARENT_HANDLE (ERROR_WPH_FIRST + 6)
|
---|
53 |
|
---|
54 | /* ******************************************************************
|
---|
55 | *
|
---|
56 | * Strings
|
---|
57 | *
|
---|
58 | ********************************************************************/
|
---|
59 |
|
---|
60 | // DECLARE_WPH_STRING is a handy macro which saves us from
|
---|
61 | // keeping two string lists in both the .h and the .c file.
|
---|
62 | // If this include file is included from the .c file, the
|
---|
63 | // string is defined as a global variable. Otherwise
|
---|
64 | // it is only declared as "extern" so other files can
|
---|
65 | // see it.
|
---|
66 |
|
---|
67 | #ifdef INCLUDE_WPHANDLE_PRIVATE
|
---|
68 | #define DECLARE_WPH_STRING(str, def) const char *str = def
|
---|
69 | #else
|
---|
70 | #define DECLARE_WPH_STRING(str, def) extern const char *str;
|
---|
71 | #endif
|
---|
72 |
|
---|
73 | /*
|
---|
74 | * OS2.INI applications
|
---|
75 | *
|
---|
76 | */
|
---|
77 |
|
---|
78 | // abstract objects per folder handle
|
---|
79 | DECLARE_WPH_STRING(WPINIAPP_FDRCONTENT, "PM_Abstract:FldrContent");
|
---|
80 | // all defined abstract objects on the system
|
---|
81 | DECLARE_WPH_STRING(WPINIAPP_OBJECTS, "PM_Abstract:Objects");
|
---|
82 | // their icons, if set individually
|
---|
83 | DECLARE_WPH_STRING(WPINIAPP_ICONS, "PM_Abstract:Icons");
|
---|
84 |
|
---|
85 | // object ID's (<WP_DESKTOP> etc.)
|
---|
86 | DECLARE_WPH_STRING(WPINIAPP_LOCATION, "PM_Workplace:Location");
|
---|
87 |
|
---|
88 | // folder positions
|
---|
89 | DECLARE_WPH_STRING(WPINIAPP_FOLDERPOS, "PM_Workplace:FolderPos");
|
---|
90 |
|
---|
91 | // palette positions
|
---|
92 | DECLARE_WPH_STRING(WPINIAPP_PALETTEPOS, "PM_Workplace:PalettePos");
|
---|
93 | // ???
|
---|
94 | DECLARE_WPH_STRING(WPINIAPP_STATUSPOS, "PM_Workplace:StatusPos");
|
---|
95 | // startup folders
|
---|
96 | DECLARE_WPH_STRING(WPINIAPP_STARTUP, "PM_Workplace:Startup");
|
---|
97 | // all the defined templates on the system
|
---|
98 | DECLARE_WPH_STRING(WPINIAPP_TEMPLATES, "PM_Workplace:Templates");
|
---|
99 |
|
---|
100 | // all work area folders
|
---|
101 | DECLARE_WPH_STRING(WPINIAPP_WORKAREARUNNING, "FolderWorkareaRunningObjects");
|
---|
102 | // spooler windows ?!?
|
---|
103 | DECLARE_WPH_STRING(WPINIAPP_JOBCNRPOS, "PM_PrintObject:JobCnrPos");
|
---|
104 |
|
---|
105 | // associations by type ("Plain Text")
|
---|
106 | DECLARE_WPH_STRING(WPINIAPP_ASSOCTYPE, "PMWP_ASSOC_TYPE");
|
---|
107 | // associations by filter ("*.txt")
|
---|
108 | DECLARE_WPH_STRING(WPINIAPP_ASSOCFILTER, "PMWP_ASSOC_FILTER");
|
---|
109 | // checksums ?!?
|
---|
110 | DECLARE_WPH_STRING(WPINIAPP_ASSOC_CHECKSUM, "PMWP_ASSOC_CHECKSUM");
|
---|
111 |
|
---|
112 | /*
|
---|
113 | * OS2SYS.INI applications
|
---|
114 | *
|
---|
115 | */
|
---|
116 |
|
---|
117 | DECLARE_WPH_STRING(WPINIAPP_ACTIVEHANDLES, "PM_Workplace:ActiveHandles");
|
---|
118 | DECLARE_WPH_STRING(WPINIAPP_HANDLES, "PM_Workplace:Handles");
|
---|
119 | DECLARE_WPH_STRING(WPINIAPP_HANDLESAPP, "HandlesAppName");
|
---|
120 |
|
---|
121 | /*
|
---|
122 | * some default WPS INI keys:
|
---|
123 | *
|
---|
124 | */
|
---|
125 |
|
---|
126 | DECLARE_WPH_STRING(WPOBJID_DESKTOP, "<WP_DESKTOP>");
|
---|
127 |
|
---|
128 | DECLARE_WPH_STRING(WPOBJID_KEYB, "<WP_KEYB>");
|
---|
129 | DECLARE_WPH_STRING(WPOBJID_MOUSE, "<WP_MOUSE>");
|
---|
130 | DECLARE_WPH_STRING(WPOBJID_CNTRY, "<WP_CNTRY>");
|
---|
131 | DECLARE_WPH_STRING(WPOBJID_SOUND, "<WP_SOUND>");
|
---|
132 | DECLARE_WPH_STRING(WPOBJID_SYSTEM, "<WP_SYSTEM>"); // V0.9.9
|
---|
133 | DECLARE_WPH_STRING(WPOBJID_POWER, "<WP_POWER>");
|
---|
134 | DECLARE_WPH_STRING(WPOBJID_WINCFG, "<WP_WINCFG>");
|
---|
135 |
|
---|
136 | DECLARE_WPH_STRING(WPOBJID_HIRESCLRPAL, "<WP_HIRESCLRPAL>");
|
---|
137 | DECLARE_WPH_STRING(WPOBJID_LORESCLRPAL, "<WP_LORESCLRPAL>");
|
---|
138 | DECLARE_WPH_STRING(WPOBJID_FNTPAL, "<WP_FNTPAL>");
|
---|
139 | DECLARE_WPH_STRING(WPOBJID_SCHPAL96, "<WP_SCHPAL96>");
|
---|
140 |
|
---|
141 | DECLARE_WPH_STRING(WPOBJID_LAUNCHPAD, "<WP_LAUNCHPAD>");
|
---|
142 | DECLARE_WPH_STRING(WPOBJID_WARPCENTER, "<WP_WARPCENTER>");
|
---|
143 |
|
---|
144 | DECLARE_WPH_STRING(WPOBJID_SPOOL, "<WP_SPOOL>");
|
---|
145 | DECLARE_WPH_STRING(WPOBJID_VIEWER, "<WP_VIEWER>");
|
---|
146 | DECLARE_WPH_STRING(WPOBJID_SHRED, "<WP_SHRED>");
|
---|
147 | DECLARE_WPH_STRING(WPOBJID_CLOCK, "<WP_CLOCK>");
|
---|
148 |
|
---|
149 | DECLARE_WPH_STRING(WPOBJID_START, "<WP_START>");
|
---|
150 | DECLARE_WPH_STRING(WPOBJID_TEMPS, "<WP_TEMPS>");
|
---|
151 | DECLARE_WPH_STRING(WPOBJID_DRIVES, "<WP_DRIVES>");
|
---|
152 |
|
---|
153 | /* ******************************************************************
|
---|
154 | *
|
---|
155 | * Definitions
|
---|
156 | *
|
---|
157 | ********************************************************************/
|
---|
158 |
|
---|
159 | #pragma pack(1)
|
---|
160 |
|
---|
161 | /*
|
---|
162 | *@@ NODE:
|
---|
163 | * file or directory node in the BLOCKS
|
---|
164 | * in OS2SYS.INI. See wphandle.c.
|
---|
165 | *
|
---|
166 | *@@added V0.9.16 (2001-10-02) [umoeller]
|
---|
167 | */
|
---|
168 |
|
---|
169 | typedef struct _NODE
|
---|
170 | {
|
---|
171 | CHAR achName[4]; // = 'NODE'
|
---|
172 | USHORT usUsage; // always == 1
|
---|
173 | USHORT usHandle; // object handle of this NODE
|
---|
174 | USHORT usParentHandle; // object handle of parent NODE
|
---|
175 | BYTE achFiller[20]; // filler
|
---|
176 | USHORT usNameSize; // size of non-qualified filename
|
---|
177 | CHAR szName[1]; // variable length: non-qualified filename
|
---|
178 | // (zero-terminated)
|
---|
179 | } NODE, *PNODE;
|
---|
180 |
|
---|
181 | /*
|
---|
182 | *@@ DRIVE:
|
---|
183 | * drive node in the BLOCKS
|
---|
184 | * in OS2SYS.INI. See wphandle.c.
|
---|
185 | *
|
---|
186 | *@@added V0.9.16 (2001-10-02) [umoeller]
|
---|
187 | */
|
---|
188 |
|
---|
189 | typedef struct _DRIVE
|
---|
190 | {
|
---|
191 | CHAR achName[4]; // = 'DRIV'
|
---|
192 | USHORT usUnknown1[4];
|
---|
193 | ULONG ulSerialNr;
|
---|
194 | USHORT usUnknown2[2];
|
---|
195 | CHAR szName[1];
|
---|
196 | } DRIV, *PDRIV;
|
---|
197 |
|
---|
198 | #pragma pack()
|
---|
199 |
|
---|
200 | /*
|
---|
201 | *@@ WPHANDLESBUF:
|
---|
202 | * structure created by wphLoadHandles.
|
---|
203 | *
|
---|
204 | *@@added V0.9.16 (2001-10-02) [umoeller]
|
---|
205 | */
|
---|
206 |
|
---|
207 | typedef struct _WPHANDLESBUF
|
---|
208 | {
|
---|
209 | PBYTE pbData; // ptr to all handles (buffers from OS2SYS.INI)
|
---|
210 | ULONG cbData; // byte count of *p
|
---|
211 |
|
---|
212 | USHORT usHiwordAbstract, // hiword for WPAbstract handles
|
---|
213 | usHiwordFileSystem; // hiword for WPFileSystem handles
|
---|
214 |
|
---|
215 | PNODE NodeHashTable[65536];
|
---|
216 | BOOL fNodeHashTableValid; // TRUE after wphRebuildNodeHashTable
|
---|
217 |
|
---|
218 | } HANDLESBUF, *PHANDLESBUF;
|
---|
219 |
|
---|
220 | /* ******************************************************************
|
---|
221 | *
|
---|
222 | * Load handles functions
|
---|
223 | *
|
---|
224 | ********************************************************************/
|
---|
225 |
|
---|
226 | APIRET wphQueryActiveHandles(HINI hiniSystem,
|
---|
227 | PSZ *ppszActiveHandles);
|
---|
228 |
|
---|
229 | APIRET wphQueryBaseClassesHiwords(HINI hiniUser,
|
---|
230 | PUSHORT pusHiwordAbstract,
|
---|
231 | PUSHORT pusHiwordFileSystem);
|
---|
232 |
|
---|
233 | APIRET wphRebuildNodeHashTable(PHANDLESBUF pHandlesBuf);
|
---|
234 |
|
---|
235 | APIRET wphLoadHandles(HINI hiniUser,
|
---|
236 | HINI hiniSystem,
|
---|
237 | const char *pcszActiveHandles,
|
---|
238 | PHANDLESBUF *ppHandlesBuf);
|
---|
239 |
|
---|
240 | APIRET wphFreeHandles(PHANDLESBUF *ppHandlesBuf);
|
---|
241 |
|
---|
242 | APIRET wphQueryHandleFromPath(HINI hiniUser,
|
---|
243 | HINI hiniSystem,
|
---|
244 | const char *pcszName,
|
---|
245 | HOBJECT *phobj);
|
---|
246 |
|
---|
247 | APIRET wphComposePath(PHANDLESBUF pHandlesBuf,
|
---|
248 | USHORT usHandle,
|
---|
249 | PSZ pszFilename,
|
---|
250 | ULONG cbFilename,
|
---|
251 | PNODE *ppNode);
|
---|
252 |
|
---|
253 | APIRET wphQueryPathFromHandle(HINI hiniUser,
|
---|
254 | HINI hiniSystem,
|
---|
255 | HOBJECT hObject,
|
---|
256 | PSZ pszFilename,
|
---|
257 | ULONG cbFilename);
|
---|
258 |
|
---|
259 | #endif
|
---|
260 |
|
---|
261 | #if __cplusplus
|
---|
262 | }
|
---|
263 | #endif
|
---|
264 |
|
---|