source: branches/branch-1-0/include/helpers/wphandle.h@ 256

Last change on this file since 256 was 180, checked in by umoeller, 23 years ago

Final sources for V0.9.19.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 9.2 KB
Line 
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 "helpers\wphandle.h"
17 */
18
19/* This file Copyright (C) 1997-2001 Ulrich M”ller.
20 * This file is part of the "XWorkplace helpers" source package.
21 * This is free software; you can redistribute it and/or modify
22 * it under the terms of the GNU General Public License as published by
23 * the Free Software Foundation, in version 2 as it comes in the COPYING
24 * file of the XWorkplace main distribution.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 */
30
31#if __cplusplus
32extern "C" {
33#endif
34
35#ifndef WPHANDLE_HEADER_INCLUDED
36 #define WPHANDLE_HEADER_INCLUDED
37
38 /* ******************************************************************
39 *
40 * Errors
41 *
42 ********************************************************************/
43
44 #define ERROR_WPH_FIRST 41000
45
46 // #define ERROR_WPH_CRASHED (ERROR_WPH_FIRST + 0)
47 // now using ERROR_PROTECTION_VIOLATION instead
48 // V0.9.19 (2002-07-01) [umoeller]
49 #define ERROR_WPH_NO_BASECLASS_DATA (ERROR_WPH_FIRST + 1)
50 #define ERROR_WPH_NO_ACTIVEHANDLES_DATA (ERROR_WPH_FIRST + 2)
51 #define ERROR_WPH_INCOMPLETE_BASECLASS_DATA (ERROR_WPH_FIRST + 3)
52 #define ERROR_WPH_NO_HANDLES_DATA (ERROR_WPH_FIRST + 4)
53 #define ERROR_WPH_CORRUPT_HANDLES_DATA (ERROR_WPH_FIRST + 5)
54 // cannot determine format (invalid keywords)
55 #define ERROR_WPH_INVALID_PARENT_HANDLE (ERROR_WPH_FIRST + 6)
56 #define ERROR_WPH_CANNOT_FIND_HANDLE (ERROR_WPH_FIRST + 7)
57 #define ERROR_WPH_DRIV_TREEINSERT_FAILED (ERROR_WPH_FIRST + 8)
58 #define ERROR_WPH_NODE_TREEINSERT_FAILED (ERROR_WPH_FIRST + 9)
59 #define ERROR_WPH_NODE_BEFORE_DRIV (ERROR_WPH_FIRST + 10)
60 #define ERROR_WPH_NO_MATCHING_DRIVE_BLOCK (ERROR_WPH_FIRST + 11)
61 #define ERROR_WPH_NO_MATCHING_ROOT_DIR (ERROR_WPH_FIRST + 12)
62 #define ERROR_WPH_NOT_FILESYSTEM_HANDLE (ERROR_WPH_FIRST + 13)
63 #define ERROR_WPH_PRFQUERYPROFILESIZE_BLOCK (ERROR_WPH_FIRST + 14)
64 // PrfQueryProfileSize failed on BLOCK (fatal)
65 // V0.9.19 (2002-07-01) [umoeller]
66 #define ERROR_WPH_PRFQUERYPROFILEDATA_BLOCK (ERROR_WPH_FIRST + 15)
67 // PrfQueryProfileData failed on BLOCK (fatal)
68 // V0.9.19 (2002-07-01) [umoeller]
69
70 #define ERROR_WPH_LAST (ERROR_WPH_FIRST + 15)
71
72 /* ******************************************************************
73 *
74 * Definitions
75 *
76 ********************************************************************/
77
78 #pragma pack(1)
79
80 /*
81 *@@ NODE:
82 * file or directory node in the BLOCKS
83 * in OS2SYS.INI. See wphandle.c.
84 *
85 *@@added V0.9.16 (2001-10-02) [umoeller]
86 */
87
88 typedef struct _NODE
89 {
90 CHAR achName[4]; // = 'NODE'
91 USHORT usUsage; // always == 1
92 USHORT usHandle; // object handle of this NODE
93 USHORT usParentHandle; // object handle of parent NODE
94 BYTE achFiller[20]; // filler
95 USHORT usNameSize; // size of non-qualified filename
96 CHAR szName[1]; // variable length: non-qualified filename
97 // (zero-terminated)
98 } NODE, *PNODE;
99
100 /*
101 *@@ DRIVE:
102 * drive node in the BLOCKS
103 * in OS2SYS.INI. See wphandle.c.
104 *
105 *@@added V0.9.16 (2001-10-02) [umoeller]
106 */
107
108 typedef struct _DRIVE
109 {
110 CHAR achName[4]; // = 'DRIV'
111 USHORT usUnknown1[4];
112 ULONG ulSerialNr;
113 USHORT usUnknown2[2];
114 CHAR szName[1];
115 } DRIVE, *PDRIVE;
116
117 #pragma pack()
118
119 /* ******************************************************************
120 *
121 * Private declarations
122 *
123 ********************************************************************/
124
125 #ifdef INCLUDE_WPHANDLE_PRIVATE
126
127 /*
128 *@@ DRIVETREENODE:
129 *
130 *@@added V0.9.16 (2001-10-19) [umoeller]
131 */
132
133 typedef struct _DRIVETREENODE
134 {
135 TREE Tree; // ulKey points to the DRIVE.szName
136 // (null terminated)
137 PDRIVE pDriv; // actual DRIVE node
138
139 TREE *ChildrenTree; // NODETREENODE's, if any
140 LONG cChildren;
141
142 } DRIVETREENODE, *PDRIVETREENODE;
143
144 /*
145 *@@ NODETREENODE:
146 *
147 *@@added V0.9.16 (2001-10-19) [umoeller]
148 */
149
150 typedef struct _NODETREENODE
151 {
152 TREE Tree; // ulKey points to the NODE.szName
153 // (null terminated)
154 PNODE pNode; // actual NODE node
155
156 TREE *ChildrenTree; // NODETREENODE's, if any
157 LONG cChildren;
158
159 } NODETREENODE, *PNODETREENODE;
160
161 /*
162 *@@ WPHANDLESBUF:
163 * structure created by wphLoadHandles.
164 *
165 * The composed BLOCKs in the handles buffer make up a tree of
166 * DRIVE and NODE structures (see wphandle.h). Each NODE stands
167 * for either a directory or a file. (We don't care about the
168 * DRIVE structures because the root directory gets a NODE also.)
169 * Each NODE contains the non-qualified file name, an fshandle,
170 * and the fshandle of its parent NODE.
171 *
172 *@@added V0.9.16 (2001-10-02) [umoeller]
173 */
174
175 typedef struct _WPHANDLESBUF
176 {
177 PBYTE pbData; // ptr to all handles (buffers from OS2SYS.INI)
178 ULONG cbData; // byte count of *p
179
180 USHORT usHiwordAbstract, // hiword for WPAbstract handles
181 usHiwordFileSystem; // hiword for WPFileSystem handles
182
183 BOOL fCacheValid; // TRUE after wphRebuildNodeHashTable()
184 PNODETREENODE NodeHashTable[65536]; // hash table with all nodes sorted by handle;
185 // if item is NULL, no handle is assigned
186 TREE *DrivesTree; // DRIVETREENODE structs really
187 LONG cDrives;
188
189 LINKLIST llDuplicateHandles; // linked list of NODETREENODE's that
190 // have an fshandle that was already
191 // occupied (i.e. same fshandle for two
192 // NODEs)
193 LINKLIST llDuplicateShortNames;
194
195 } HANDLESBUF, *PHANDLESBUF;
196
197 #endif
198
199 /* ******************************************************************
200 *
201 * Load handles functions
202 *
203 ********************************************************************/
204
205 typedef unsigned long HHANDLES;
206
207 APIRET wphQueryActiveHandles(HINI hiniSystem,
208 PSZ *ppszActiveHandles);
209
210 APIRET wphQueryBaseClassesHiwords(HINI hiniUser,
211 PUSHORT pusHiwordAbstract,
212 PUSHORT pusHiwordFileSystem);
213
214 APIRET wphRebuildNodeHashTable(HHANDLES hHandles,
215 BOOL fQuitOnErrors);
216
217 APIRET wphLoadHandles(HINI hiniUser,
218 HINI hiniSystem,
219 const char *pcszActiveHandles,
220 HHANDLES *phHandles);
221
222 APIRET wphFreeHandles(HHANDLES *phHandles);
223
224 APIRET wphQueryHandleFromPath(HINI hiniUser,
225 HINI hiniSystem,
226 const char *pcszName,
227 HOBJECT *phobj);
228
229 APIRET wphComposePath(HHANDLES hHandles,
230 USHORT usHandle,
231 PSZ pszFilename,
232 ULONG cbFilename,
233 PNODE *ppNode);
234
235 APIRET wphQueryPathFromHandle(HINI hiniUser,
236 HINI hiniSystem,
237 HOBJECT hObject,
238 PSZ pszFilename,
239 ULONG cbFilename);
240
241 PCSZ wphDescribeError(APIRET arc);
242
243#endif
244
245#if __cplusplus
246}
247#endif
248
Note: See TracBrowser for help on using the repository browser.