| 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 Mller.
|
|---|
| 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
|
|---|
| 32 | extern "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 | #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 | #define ERROR_WPH_CANNOT_FIND_HANDLE (ERROR_WPH_FIRST + 7)
|
|---|
| 54 | #define ERROR_WPH_DRIV_TREEINSERT_FAILED (ERROR_WPH_FIRST + 8)
|
|---|
| 55 | #define ERROR_WPH_NODE_TREEINSERT_FAILED (ERROR_WPH_FIRST + 9)
|
|---|
| 56 | #define ERROR_WPH_NODE_BEFORE_DRIV (ERROR_WPH_FIRST + 10)
|
|---|
| 57 | #define ERROR_WPH_NO_MATCHING_DRIVE_BLOCK (ERROR_WPH_FIRST + 11)
|
|---|
| 58 | #define ERROR_WPH_NO_MATCHING_ROOT_DIR (ERROR_WPH_FIRST + 12)
|
|---|
| 59 | #define ERROR_WPH_NOT_FILESYSTEM_HANDLE (ERROR_WPH_FIRST + 13)
|
|---|
| 60 |
|
|---|
| 61 | #define ERROR_WPH_LAST (ERROR_WPH_FIRST + 13)
|
|---|
| 62 |
|
|---|
| 63 | /* ******************************************************************
|
|---|
| 64 | *
|
|---|
| 65 | * Definitions
|
|---|
| 66 | *
|
|---|
| 67 | ********************************************************************/
|
|---|
| 68 |
|
|---|
| 69 | #pragma pack(1)
|
|---|
| 70 |
|
|---|
| 71 | /*
|
|---|
| 72 | *@@ NODE:
|
|---|
| 73 | * file or directory node in the BLOCKS
|
|---|
| 74 | * in OS2SYS.INI. See wphandle.c.
|
|---|
| 75 | *
|
|---|
| 76 | *@@added V0.9.16 (2001-10-02) [umoeller]
|
|---|
| 77 | */
|
|---|
| 78 |
|
|---|
| 79 | typedef struct _NODE
|
|---|
| 80 | {
|
|---|
| 81 | CHAR achName[4]; // = 'NODE'
|
|---|
| 82 | USHORT usUsage; // always == 1
|
|---|
| 83 | USHORT usHandle; // object handle of this NODE
|
|---|
| 84 | USHORT usParentHandle; // object handle of parent NODE
|
|---|
| 85 | BYTE achFiller[20]; // filler
|
|---|
| 86 | USHORT usNameSize; // size of non-qualified filename
|
|---|
| 87 | CHAR szName[1]; // variable length: non-qualified filename
|
|---|
| 88 | // (zero-terminated)
|
|---|
| 89 | } NODE, *PNODE;
|
|---|
| 90 |
|
|---|
| 91 | /*
|
|---|
| 92 | *@@ DRIVE:
|
|---|
| 93 | * drive node in the BLOCKS
|
|---|
| 94 | * in OS2SYS.INI. See wphandle.c.
|
|---|
| 95 | *
|
|---|
| 96 | *@@added V0.9.16 (2001-10-02) [umoeller]
|
|---|
| 97 | */
|
|---|
| 98 |
|
|---|
| 99 | typedef struct _DRIVE
|
|---|
| 100 | {
|
|---|
| 101 | CHAR achName[4]; // = 'DRIV'
|
|---|
| 102 | USHORT usUnknown1[4];
|
|---|
| 103 | ULONG ulSerialNr;
|
|---|
| 104 | USHORT usUnknown2[2];
|
|---|
| 105 | CHAR szName[1];
|
|---|
| 106 | } DRIVE, *PDRIVE;
|
|---|
| 107 |
|
|---|
| 108 | #pragma pack()
|
|---|
| 109 |
|
|---|
| 110 | /* ******************************************************************
|
|---|
| 111 | *
|
|---|
| 112 | * Private declarations
|
|---|
| 113 | *
|
|---|
| 114 | ********************************************************************/
|
|---|
| 115 |
|
|---|
| 116 | #ifdef INCLUDE_WPHANDLE_PRIVATE
|
|---|
| 117 |
|
|---|
| 118 | /*
|
|---|
| 119 | *@@ DRIVETREENODE:
|
|---|
| 120 | *
|
|---|
| 121 | *@@added V0.9.16 (2001-10-19) [umoeller]
|
|---|
| 122 | */
|
|---|
| 123 |
|
|---|
| 124 | typedef struct _DRIVETREENODE
|
|---|
| 125 | {
|
|---|
| 126 | TREE Tree; // ulKey points to the DRIVE.szName
|
|---|
| 127 | // (null terminated)
|
|---|
| 128 | PDRIVE pDriv; // actual DRIVE node
|
|---|
| 129 |
|
|---|
| 130 | TREE *ChildrenTree; // NODETREENODE's, if any
|
|---|
| 131 | LONG cChildren;
|
|---|
| 132 |
|
|---|
| 133 | } DRIVETREENODE, *PDRIVETREENODE;
|
|---|
| 134 |
|
|---|
| 135 | /*
|
|---|
| 136 | *@@ NODETREENODE:
|
|---|
| 137 | *
|
|---|
| 138 | *@@added V0.9.16 (2001-10-19) [umoeller]
|
|---|
| 139 | */
|
|---|
| 140 |
|
|---|
| 141 | typedef struct _NODETREENODE
|
|---|
| 142 | {
|
|---|
| 143 | TREE Tree; // ulKey points to the NODE.szName
|
|---|
| 144 | // (null terminated)
|
|---|
| 145 | PNODE pNode; // actual NODE node
|
|---|
| 146 |
|
|---|
| 147 | TREE *ChildrenTree; // NODETREENODE's, if any
|
|---|
| 148 | LONG cChildren;
|
|---|
| 149 |
|
|---|
| 150 | } NODETREENODE, *PNODETREENODE;
|
|---|
| 151 |
|
|---|
| 152 | /*
|
|---|
| 153 | *@@ WPHANDLESBUF:
|
|---|
| 154 | * structure created by wphLoadHandles.
|
|---|
| 155 | *
|
|---|
| 156 | * The composed BLOCKs in the handles buffer make up a tree of
|
|---|
| 157 | * DRIVE and NODE structures (see wphandle.h). Each NODE stands
|
|---|
| 158 | * for either a directory or a file. (We don't care about the
|
|---|
| 159 | * DRIVE structures because the root directory gets a NODE also.)
|
|---|
| 160 | * Each NODE contains the non-qualified file name, an fshandle,
|
|---|
| 161 | * and the fshandle of its parent NODE.
|
|---|
| 162 | *
|
|---|
| 163 | *@@added V0.9.16 (2001-10-02) [umoeller]
|
|---|
| 164 | */
|
|---|
| 165 |
|
|---|
| 166 | typedef struct _WPHANDLESBUF
|
|---|
| 167 | {
|
|---|
| 168 | PBYTE pbData; // ptr to all handles (buffers from OS2SYS.INI)
|
|---|
| 169 | ULONG cbData; // byte count of *p
|
|---|
| 170 |
|
|---|
| 171 | USHORT usHiwordAbstract, // hiword for WPAbstract handles
|
|---|
| 172 | usHiwordFileSystem; // hiword for WPFileSystem handles
|
|---|
| 173 |
|
|---|
| 174 | BOOL fCacheValid; // TRUE after wphRebuildNodeHashTable()
|
|---|
| 175 | PNODETREENODE NodeHashTable[65536]; // hash table with all nodes sorted by handle;
|
|---|
| 176 | // if item is NULL, no handle is assigned
|
|---|
| 177 | TREE *DrivesTree; // DRIVETREENODE structs really
|
|---|
| 178 | LONG cDrives;
|
|---|
| 179 |
|
|---|
| 180 | LINKLIST llDuplicateHandles; // linked list of NODETREENODE's that
|
|---|
| 181 | // have an fshandle that was already
|
|---|
| 182 | // occupied (i.e. same fshandle for two
|
|---|
| 183 | // NODEs)
|
|---|
| 184 | LINKLIST llDuplicateShortNames;
|
|---|
| 185 |
|
|---|
| 186 | } HANDLESBUF, *PHANDLESBUF;
|
|---|
| 187 |
|
|---|
| 188 | #endif
|
|---|
| 189 |
|
|---|
| 190 | /* ******************************************************************
|
|---|
| 191 | *
|
|---|
| 192 | * Load handles functions
|
|---|
| 193 | *
|
|---|
| 194 | ********************************************************************/
|
|---|
| 195 |
|
|---|
| 196 | typedef unsigned long HHANDLES;
|
|---|
| 197 |
|
|---|
| 198 | APIRET wphQueryActiveHandles(HINI hiniSystem,
|
|---|
| 199 | PSZ *ppszActiveHandles);
|
|---|
| 200 |
|
|---|
| 201 | APIRET wphQueryBaseClassesHiwords(HINI hiniUser,
|
|---|
| 202 | PUSHORT pusHiwordAbstract,
|
|---|
| 203 | PUSHORT pusHiwordFileSystem);
|
|---|
| 204 |
|
|---|
| 205 | APIRET wphRebuildNodeHashTable(HHANDLES hHandles,
|
|---|
| 206 | BOOL fQuitOnErrors);
|
|---|
| 207 |
|
|---|
| 208 | APIRET wphLoadHandles(HINI hiniUser,
|
|---|
| 209 | HINI hiniSystem,
|
|---|
| 210 | const char *pcszActiveHandles,
|
|---|
| 211 | HHANDLES *phHandles);
|
|---|
| 212 |
|
|---|
| 213 | APIRET wphFreeHandles(HHANDLES *phHandles);
|
|---|
| 214 |
|
|---|
| 215 | APIRET wphQueryHandleFromPath(HINI hiniUser,
|
|---|
| 216 | HINI hiniSystem,
|
|---|
| 217 | const char *pcszName,
|
|---|
| 218 | HOBJECT *phobj);
|
|---|
| 219 |
|
|---|
| 220 | APIRET wphComposePath(HHANDLES hHandles,
|
|---|
| 221 | USHORT usHandle,
|
|---|
| 222 | PSZ pszFilename,
|
|---|
| 223 | ULONG cbFilename,
|
|---|
| 224 | PNODE *ppNode);
|
|---|
| 225 |
|
|---|
| 226 | APIRET wphQueryPathFromHandle(HINI hiniUser,
|
|---|
| 227 | HINI hiniSystem,
|
|---|
| 228 | HOBJECT hObject,
|
|---|
| 229 | PSZ pszFilename,
|
|---|
| 230 | ULONG cbFilename);
|
|---|
| 231 |
|
|---|
| 232 | #endif
|
|---|
| 233 |
|
|---|
| 234 | #if __cplusplus
|
|---|
| 235 | }
|
|---|
| 236 | #endif
|
|---|
| 237 |
|
|---|