Changeset 106
- Timestamp:
- Oct 2, 2001, 8:28:47 PM (24 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/helpers/cnrh.h
r48 r106 618 618 USHORT usSupportedOps); 619 619 620 MRESULT cnrhOwnerDrawRecord(MPARAM mp2); 620 #define CODFL_DISABLEDTEXT 0x0001 621 #define CODFL_MINIICON 0x0002 622 623 MRESULT cnrhOwnerDrawRecord(MPARAM mp2, 624 ULONG flFlags); 621 625 622 626 BOOL cnrhDateTimeDos2Win(DATETIME* pdt, -
trunk/include/helpers/dialog.h
r104 r106 180 180 ********************************************************************/ 181 181 182 #define COMMON_SPACING 3 183 182 184 #define CONTROLDEF_GROUP(pcsz, id) { WC_STATIC, pcsz, \ 183 185 WS_VISIBLE | SS_GROUPBOX | DT_MNEMONIC, \ … … 186 188 #define CONTROLDEF_TEXT(pcsz, id, cx, cy) { WC_STATIC, pcsz, \ 187 189 WS_VISIBLE | SS_TEXT | DT_LEFT | DT_VCENTER | DT_MNEMONIC, \ 188 id, CTL_COMMON_FONT, 0, {cx, cy}, 5}190 id, CTL_COMMON_FONT, 0, {cx, cy}, COMMON_SPACING } 189 191 190 192 #define CONTROLDEF_DEFPUSHBUTTON(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \ 191 193 WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON | BS_DEFAULT, \ 192 id, CTL_COMMON_FONT, 0, {cx, cy}, 5}194 id, CTL_COMMON_FONT, 0, {cx, cy}, COMMON_SPACING } 193 195 194 196 #define CONTROLDEF_PUSHBUTTON(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \ 195 197 WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON, \ 196 id, CTL_COMMON_FONT, 0, {cx, cy}, 5 } 198 id, CTL_COMMON_FONT, 0, {cx, cy}, COMMON_SPACING } 199 200 #define CONTROLDEF_HELPPUSHBUTTON(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \ 201 WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON | BS_HELP, \ 202 id, CTL_COMMON_FONT, 0, {cx, cy}, COMMON_SPACING } 197 203 198 204 #define CONTROLDEF_AUTOCHECKBOX(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \ 199 205 WS_VISIBLE | WS_TABSTOP | BS_AUTOCHECKBOX, \ 200 id, CTL_COMMON_FONT, 0, { cx, cy }, 5}206 id, CTL_COMMON_FONT, 0, { cx, cy }, COMMON_SPACING } 201 207 202 208 #define CONTROLDEF_FIRST_AUTORADIO(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \ 203 209 WS_VISIBLE | WS_TABSTOP | BS_AUTORADIOBUTTON | WS_GROUP, \ 204 id, CTL_COMMON_FONT, 0, { cx, cy }, 5}210 id, CTL_COMMON_FONT, 0, { cx, cy }, COMMON_SPACING } 205 211 206 212 #define CONTROLDEF_NEXT_AUTORADIO(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \ 207 213 WS_VISIBLE | WS_TABSTOP | BS_AUTORADIOBUTTON, \ 208 id, CTL_COMMON_FONT, 0, { cx, cy }, 5}214 id, CTL_COMMON_FONT, 0, { cx, cy }, COMMON_SPACING } 209 215 210 216 #define CONTROLDEF_ENTRYFIELD(pcsz, id, cx, cy) { WC_ENTRYFIELD, pcsz, \ 211 217 WS_VISIBLE | WS_TABSTOP | ES_MARGIN, \ 212 id, CTL_COMMON_FONT, 0, { cx, cy }, 5}218 id, CTL_COMMON_FONT, 0, { cx, cy }, COMMON_SPACING } 213 219 214 220 #define CONTROLDEF_SPINBUTTON(id, cx, cy) { WC_SPINBUTTON, NULL, \ 215 221 WS_VISIBLE | WS_TABSTOP | SPBS_MASTER | SPBS_NUMERICONLY | SPBS_JUSTCENTER | SPBS_FASTSPIN, \ 216 id, CTL_COMMON_FONT, 0, {cx, cy}, 5}222 id, CTL_COMMON_FONT, 0, {cx, cy}, COMMON_SPACING } 217 223 218 224 /* ****************************************************************** … … 242 248 typedef DLGHCREATEDLG *PDLGHCREATEDLG; 243 249 250 APIRET dlghFormatDlg(HWND hwndDlg, 251 PDLGHITEM paDlgItems, 252 ULONG cDlgItems, 253 const char *pcszControlsFont, 254 ULONG flFlags); 255 256 #define DFFL_RESIZEFRAME 0x0001 257 #define DFFL_CREATECONTROLS 0x0002 258 244 259 /* 245 260 *@@ MSGBOXSTRINGS: -
trunk/include/helpers/tree.h
r84 r106 74 74 int TREEENTRY treeCompareKeys(unsigned long ul1, unsigned long ul2); 75 75 76 int TREEENTRY treeCompareStrings(unsigned long ul1, unsigned long ul2); 77 76 78 int treeInsert(TREE **root, 77 79 TREE *x, -
trunk/include/helpers/winh.h
r91 r106 848 848 /* ****************************************************************** 849 849 * 850 * Extended frame 851 * 852 ********************************************************************/ 853 854 #define XFCF_STATUSBAR 0x0001 855 856 #define FID_STATUSBAR 0x8100 857 858 /* 859 *@@ EXTFRAMECDATA: 860 * 861 *@@added V0.9.16 (2001-09-29) [umoeller] 862 */ 863 864 typedef struct _EXTFRAMECDATA 865 { 866 PSWP pswpFrame; // in: frame wnd pos 867 ULONG flFrameCreateFlags; // in: FCF_* flags 868 ULONG flExtFlags; // in: XFCF_* flags 869 ULONG ulFrameStyle; // in: WS_* flags (e.g. WS_VISIBLE, WS_ANIMATE) 870 const char *pcszFrameTitle; // in: frame title (title bar) 871 ULONG ulResourcesID; // in: according to FCF_* flags 872 const char *pcszClassClient; // in: client class name 873 ULONG flStyleClient; // in: client style 874 ULONG ulID; // in: frame window ID 875 PVOID pClientCtlData; // in: pCtlData structure pointer for client 876 } EXTFRAMECDATA, *PEXTFRAMECDATA; 877 878 /* 879 *@@ EXTFRAMEDATA: 880 * 881 *@@added V0.9.16 (2001-09-29) [umoeller] 882 */ 883 884 typedef struct _EXTFRAMEDATA 885 { 886 EXTFRAMECDATA CData; 887 888 PFNWP pfnwpOrig; // original frame wnd proc from subclassing 889 890 PVOID pvUser; // more data for user (e.g. for additional subclassing) 891 892 } EXTFRAMEDATA, *PEXTFRAMEDATA; 893 894 HWND winhCreateStatusBar(HWND hwndFrame, 895 HWND hwndOwner, 896 const char *pcszText, 897 const char *pcszFont, 898 LONG lColor); 899 900 HWND winhCreateExtStdWindow(PEXTFRAMECDATA pData, 901 PHWND phwndClient); 902 903 /* ****************************************************************** 904 * 850 905 * WPS Class List helpers 851 906 * -
trunk/include/helpers/wphandle.h
r41 r106 37 37 #define WPHANDLE_HEADER_INCLUDED 38 38 39 /* 40 *@@ IsObjectAbstract: 41 * this macro returns TRUE if the passed hObject points 42 * to an abstract object; the WPS sets the HIWORD of 43 * an abstract hObject to 2 or 3 for these, to 1 for 44 * file system objects 45 */ 46 47 #define IsObjectAbstract(h) (BOOL)((HIUSHORT(h)) != 3) 48 49 /* 50 * Two structures needed for finding 51 * a filename based on a object handle 52 * (OS2SYS.INI). These are only needed 53 * to parse the BLOCK data manually. 54 */ 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 ********************************************************************/ 55 158 56 159 #pragma pack(1) 57 160 58 typedef struct _NodeDev 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 59 170 { 60 BYTE chName[4];// = 'NODE'61 USHORT usLevel;// always == 162 USHORT usHandle;// object handle of this NODE63 USHORT usParentHandle;// object handle of parent NODE64 BYTE ch[20];65 USHORT usNameSize;// size of non-qualified filename66 BYTE szName[1];// variable length: non-qualified filename67 // (zero-terminated)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) 68 179 } NODE, *PNODE; 69 180 70 typedef struct _DrivDev 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 71 190 { 72 BYTEchName[4]; // = 'DRIV'191 CHAR achName[4]; // = 'DRIV' 73 192 USHORT usUnknown1[4]; 74 // or BYTE ch1[8], if you prefer75 193 ULONG ulSerialNr; 76 194 USHORT usUnknown2[2]; 77 // or BYTE ch2[4], if you prefer 78 BYTE szName[1]; 195 CHAR szName[1]; 79 196 } DRIV, *PDRIV; 80 197 81 /* 82 * prototypes 83 * 84 */ 85 86 BOOL wphQueryActiveHandles(HINI hIniSystem, 87 PSZ pszHandlesAppName, 88 USHORT usMax); 89 90 BOOL wphReadAllBlocks(HINI hiniSystem, 91 PSZ pszActiveHandles, 92 PBYTE* ppBlock, 93 PULONG pulSize); 94 95 HOBJECT wphQueryHandleFromPath(HINI hIniUser, 96 HINI hIniSystem, 97 PSZ pszName); 98 99 PNODE wphFindPartName(PBYTE pHandlesBuffer, 100 ULONG ulBufSize, 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, 101 248 USHORT usHandle, 102 PSZ pszFname, 103 USHORT usMax); 104 105 BOOL wphQueryPathFromHandle(HINI hIniSystem, 106 HOBJECT hObject, 107 PSZ pszFname, 108 USHORT usMax); 109 /* 110 * OS2.INI applications 111 * 112 */ 113 114 // abstract objects per folder handle 115 #define FOLDERCONTENT "PM_Abstract:FldrContent" 116 // all defined abstract objects on the system 117 #define OBJECTS "PM_Abstract:Objects" 118 // their icons, if set individually 119 #define ICONS "PM_Abstract:Icons" 120 121 // folder positions 122 #define FOLDERPOS "PM_Workplace:FolderPos" 123 124 // object ID's (<WP_DESKTOP> etc.) 125 #define LOCATION "PM_Workplace:Location" 126 // palette positions 127 #define PALETTEPOS "PM_Workplace:PalettePos" 128 // ??? 129 #define STATUSPOS "PM_Workplace:StatusPos" 130 // startup folders 131 #define STARTUP "PM_Workplace:Startup" 132 // all the defined templates on the system 133 #define TEMPLATES "PM_Workplace:Templates" 134 // associations by filter ("*.txt") 135 #define ASSOC_FILTER "PMWP_ASSOC_FILTER" 136 // associations by type ("Plain Text") 137 #define ASSOC_TYPE "PMWP_ASSOC_TYPE" 138 // checksums ?!? 139 #define ASSOC_CHECKSUM "PMWP_ASSOC_CHECKSUM" 140 // all work area folders 141 #define WORKAREARUNNING "FolderWorkareaRunningObjects" 142 // spooler windows ?!? 143 #define JOBCNRPOS "PM_PrintObject:JobCnrPos" 144 145 /* 146 * OS2SYS.INI applications 147 * 148 */ 149 150 #define HANDLEBLOCK "BLOCK1" 151 #define ACTIVEHANDLES "PM_Workplace:ActiveHandles" 152 #define HANDLES "PM_Workplace:Handles" 153 #define HANDLESAPP "HandlesAppName" 154 155 /* 156 * Extended Attrribute types 157 * 158 */ 159 160 #ifdef FORGET_IT 161 #define EAT_BINARY 0xFFFE // length preceeded binary 162 #define EAT_ASCII 0xFFFD // length preceeded ASCII 163 #define EAT_BITMAP 0xFFFB // length preceeded bitmap 164 #define EAT_METAFILE 0xFFFA // length preceeded metafile 165 #define EAT_ICON 0xFFF9 // length preceeded icon 166 #define EAT_EA 0xFFEE // length preceeded ASCII 167 // name of associated data (#include) 168 #define EAT_MVMT 0xFFDF // multi-valued, multi-typed field 169 #define EAT_MVST 0xFFDE // multi-valued, single-typed field 170 #define EAT_ASN1 0xFFDD // ASN.1 field 171 #endif 172 173 /* 174 * Several defines to read EA's 175 * 176 */ 177 178 #define EA_LPBINARY EAT_BINARY // Length preceeded binary 179 #define EA_LPASCII EAT_ASCII // Length preceeded ascii 180 #define EA_ASCIIZ 0xFFFC // Asciiz 181 #define EA_LPBITMAP EAT_BITMAP // Length preceeded bitmap 182 #define EA_LPMETAFILE EAT_METAFILE // metafile 183 #define EA_LPICON EAT_ICON // Length preceeded icon 184 #define EA_ASCIIZFN 0xFFEF // Asciiz file name of associated dat 185 #define EA_ASCIIZEA EAT_EA // Name of associated data, LP Ascii 186 #define EA_MVMT EAT_MVMT // Multi value, multi type 187 #define EA_MVST EAT_MVST // Multi value, single type 188 #define EA_ASN1 EAT_ASN1 // ASN.1 Field 189 190 /* 191 * The high word of a HOBJECT determines its type: 192 * 193 */ 194 195 // Abstract objects _always_ have an object handle, 196 // because they cannot be referenced by file name. 197 // The high word is either 1 or 2. 198 #define OBJECT_ABSTRACT 0x0001 // before Warp 3, I guess (UM) 199 #define OBJECT_ABSTRACT2 0x0002 200 // File-system objects do not necessarily have an 201 // object handle. If they do, these handles are stored 202 // in those ugly PM_Workplace:Handles BLOCK's in 203 // OS2SYS.INI. 204 // The high word is always 3. 205 #define OBJECT_FSYS 0x0003 206 207 /* 208 * Several datatags: 209 * all the following are used by the wpRestoreData/ 210 * wpSaveData methods to specify the type of data to 211 * be worked on (ulKey parameter). This is specific 212 * to each class. 213 * 214 * Object instance data is stored in OS2.INI for 215 * abstract, in file EA's for file-system objects 216 * (.CLASSDATA). 217 * 218 * Many of these are also declared in the WPS header 219 * files (IDKEY_* parameters; see wpfolder.h for 220 * examples). 221 */ 222 223 // WPObject 224 #define WPOBJECT_HELPPANEL 2 225 #define WPOBJECT_SZID 6 226 #define WPOBJECT_STYLE 7 227 #define WPOBJECT_MINWIN 8 228 #define WPOBJECT_CONCURRENT 9 229 #define WPOBJECT_VIEWBUTTON 10 230 #define WPOBJECT_DATA 11 231 #define WPOBJECT_STRINGS 12 232 #define WPOBJ_STR_OBJID 1 233 234 // WPAbstract 235 #define WPABSTRACT_TITLE 1 236 #define WPABSTRACT_STYLE 2 // appears to contain the same as WPOBJECT 7 237 238 // WPShadow 239 #define WPSHADOW_LINK 104 // target object 240 241 // WPProgram 242 #define WPPROGRAM_PROGTYPE 1 243 #define WPPROGRAM_EXEHANDLE 2 // object handle of executable 244 #define WPPROGRAM_PARAMS 3 245 #define WPPROGRAM_DIRHANDLE 4 // object handle of startup dir 246 #define WPPROGRAM_DOSSET 6 247 #define WPPROGRAM_STYLE 7 248 #define WPPROGRAM_EXENAME 9 249 #define WPPROGRAM_DATA 11 250 #define WPPROGRAM_STRINGS 10 251 #define WPPGM_STR_EXENAME 0 252 #define WPPGM_STR_ARGS 1 253 254 // WPFileSystem 255 #define WPFSYS_MENUCOUNT 4 256 #define WPFSYS_MENUARRAY 3 257 258 // WPFolder (also see the additional def's in wpfolder.h) 259 #define WPFOLDER_FOLDERFLAG 13 260 #define WPFOLDER_ICONVIEW 2900 /* IDKEY_FDRCONTENTATTR */ 261 #define WPFOLDER_DATA 2931 /* IDKEY_FDRLONGARRAY */ 262 #define WPFOLDER_FONTS 2932 /* IDKEY_FDRSTRARRAY */ 263 264 // WPProgramFile 265 #define WPPROGFILE_PROGTYPE 1 266 #define WPPROGFILE_DOSSET 5 267 #define WPPROGFILE_STYLE 6 268 #define WPPROGFILE_DATA 10 269 #define WPPROGFILE_STRINGS 11 270 #define WPPRGFIL_STR_ARGS 0 271 272 // printer queues?!? 273 #define IDKEY_PRNQUEUENAME 3 274 #define IDKEY_PRNCOMPUTER 5 275 #define IDKEY_PRNJOBDIALOG 9 276 #define IDKEY_PRNREMQUEUE 13 277 278 #define IDKEY_RPRNNETID 1 279 280 // WPDisk?!? 281 #define IDKEY_DRIVENUM 1 282 283 /* 284 * Two structures needed for reading 285 * WPAbstract's object information. 286 * 287 * These are only needed if the instance 288 * data in OS2.INI is to be parsed manually. 289 */ 290 291 typedef struct _ObjectInfo 292 { 293 USHORT cbName; // Size of szName 294 USHORT cbData; // Size of variable length data, starting after szName 295 BYTE szName[1]; // The name of the datagroup 296 } OINFO, *POINFO; 297 298 typedef struct _TagInfo 299 { 300 USHORT usTagFormat; // Format of data 301 USHORT usTag; // The data-identifier 302 USHORT cbTag; // The size of the data 303 } TAG, *PTAG; 304 305 typedef struct _WPProgramRefData 306 { 307 HOBJECT hExeHandle; 308 HOBJECT hCurDirHandle; 309 ULONG ulFiller1; 310 ULONG ulProgType; 311 BYTE bFiller[12]; 312 } WPPGMDATA; 313 314 typedef struct _WPProgramFileData 315 { 316 HOBJECT hCurDirHandle; 317 ULONG ulProgType; 318 ULONG ulFiller1; 319 ULONG ulFiller2; 320 ULONG ulFiller3; 321 } WPPGMFILEDATA; 322 323 typedef struct _WPObjectData 324 { 325 LONG lDefaultView; 326 ULONG ulHelpPanel; 327 ULONG ulUnknown3; 328 ULONG ulObjectStyle; 329 ULONG ulMinWin; 330 ULONG ulConcurrent; 331 ULONG ulViewButton; 332 ULONG ulMenuFlag; 333 } WPOBJDATA; 334 335 typedef struct _WPFolderData 336 { 337 ULONG ulIconView; 338 ULONG ulTreeView; 339 ULONG ulDetailsView; 340 ULONG ulFolderFlag; 341 ULONG ulTreeStyle; 342 ULONG ulDetailsStyle; 343 BYTE rgbIconTextBkgnd[4]; 344 BYTE Filler1[4]; 345 BYTE rgbIconTextColor[4]; 346 BYTE Filler2[8]; 347 BYTE rgbTreeTextColor[4]; 348 BYTE rgbDetailsTextColor[4]; 349 BYTE Filler3[4]; 350 USHORT fIconTextVisible; 351 USHORT fIconViewFlags; 352 USHORT fTreeTextVisible; 353 USHORT fTreeViewFlags; 354 BYTE Filler4[4]; 355 ULONG ulMenuFlag; 356 BYTE rgbIconShadowColor[4]; 357 BYTE rgbTreeShadowColor[4]; 358 BYTE rgbDetailsShadowColor[4]; 359 } WPFOLDATA; 360 361 typedef struct _FsysMenu 362 { 363 USHORT usIDMenu ; 364 USHORT usIDParent ; 365 USHORT usMenuType; // 1 = Cascade, 2 = condcascade, 3 = choice 366 HOBJECT hObject; 367 BYTE szTitle[32]; 368 } FSYSMENU, *PFSYSMENU; 369 370 typedef struct _FolderSort 371 { 372 LONG lDefaultSortIndex; 373 BOOL fAlwaysSort; 374 LONG lCurrentSort; 375 BYTE bFiller[12]; 376 } FOLDERSORT, *PFOLDERSORT; 377 378 typedef struct _FldBkgnd 379 { 380 ULONG ulUnknown; 381 BYTE bBlue; 382 BYTE bGreen; 383 BYTE bRed; 384 BYTE bExtra; 385 //RGB rgb; 386 //BYTE bFiller; 387 BYTE bColorOnly; // 0x28 Image, 0x27 Color only 388 BYTE bFiller2; 389 BYTE bImageType; // 2=Normal, 3=tiled, 4=scaled 390 BYTE bFiller3; 391 BYTE bScaleFactor; 392 BYTE bFiller4; 393 } FLDBKGND, *PFLDBKGND; 394 395 #pragma pack() // added V0.9.0 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); 396 258 397 259 #endif -
trunk/src/helpers/cnrh.c
r90 r106 1962 1962 * cores. 1963 1963 * 1964 * Presently, this function supports drawing record 1965 * cores in gray color if the record has the CRA_DISABLED 1966 * style (which, AFAIK, PM ignores per default). 1964 * What this draws depends on flFlags: 1965 * 1966 * -- If CODFL_DISABLEDTEXT is set, this function supports 1967 * drawing record cores in gray color if the record has 1968 * the CRA_DISABLED style (which, AFAIK, PM ignores per 1969 * default). 1970 * 1971 * -- If CODFL_MINIICON is set, this function paints the 1972 * record's mini-icon properly. So far I have failed 1973 * to find out how to get a container to paint the 1974 * correct mini-icon if the CV_MINI style is set... 1975 * the container normally _does_ paint a small icon, 1976 * but it won't use the "real" mini icon data if that 1977 * is present. 1978 * 1979 * For painting the mini-icon, WinDrawPointer is used 1980 * with DP_MINI set properly and the RECORDCORE's 1981 * hptrMiniIcon field. 1967 1982 * 1968 1983 * This returns either TRUE or FALSE as an MPARAM, depending 1969 1984 * on whether we have drawn the item. This return value should 1970 1985 * also be the return value of your window procedure. 1971 */ 1972 1973 MRESULT cnrhOwnerDrawRecord(MPARAM mp2) // in: mp2 of WM_DRAWITEM (POWNERITEM) 1974 { 1975 MRESULT mrc = 0; 1986 * 1987 *@@changed V0.9.16 (2001-09-29) [umoeller]: added flFlags, icon draw support 1988 */ 1989 1990 MRESULT cnrhOwnerDrawRecord(MPARAM mp2, // in: mp2 of WM_DRAWITEM (POWNERITEM) 1991 ULONG flFlags) // in: CODFL_* flags 1992 { 1993 MRESULT mrc = (MPARAM)FALSE; // tell cnr to draw the item 1976 1994 1977 1995 // get generic DRAWITEM structure 1978 POWNERITEM poi = (POWNERITEM)mp2; 1979 1980 // check if we're to draw the text 1981 // (and not the icon) 1982 if (poi->idItem == CMA_TEXT) 1996 POWNERITEM poi; 1997 1998 if (poi = (POWNERITEM)mp2) 1983 1999 { 1984 2000 // get container-specific draw-item struct 1985 2001 PCNRDRAWITEMINFO pcdii = (PCNRDRAWITEMINFO)poi->hItem; 1986 2002 1987 if (((pcdii->pRecord->flRecordAttr) & CRA_DISABLED) == 0) 2003 // check if we're to draw the text 2004 // (and not the icon) 2005 if ( (poi->idItem == CMA_TEXT) 2006 && (flFlags & CODFL_DISABLEDTEXT) 2007 ) 1988 2008 { 1989 /* 1990 // not disabled == valid WPS class 1991 if ((pcdii->pRecord->flRecordAttr) & CRA_SELECTED) 2009 if (((pcdii->pRecord->flRecordAttr) & CRA_DISABLED) == 0) 1992 2010 { 1993 // not disabled, but selected: 1994 lBackground = winhQueryPresColor(hwndDlg, PP_HILITEBACKGROUNDCOLOR, SYSCLR_HILITEBACKGROUND); 1995 lForeground = winhQueryPresColor(hwndDlg, PP_HILITEFOREGROUNDCOLOR, SYSCLR_HILITEFOREGROUND); 2011 /* 2012 // not disabled == valid WPS class 2013 if ((pcdii->pRecord->flRecordAttr) & CRA_SELECTED) 2014 { 2015 // not disabled, but selected: 2016 lBackground = winhQueryPresColor(hwndDlg, PP_HILITEBACKGROUNDCOLOR, SYSCLR_HILITEBACKGROUND); 2017 lForeground = winhQueryPresColor(hwndDlg, PP_HILITEFOREGROUNDCOLOR, SYSCLR_HILITEFOREGROUND); 2018 } 2019 else 2020 { 2021 // not disabled, not selected: 2022 lBackground = winhQueryPresColor(hwndDlg, PP_BACKGROUNDCOLOR, SYSCLR_BACKGROUND); 2023 lForeground = winhQueryPresColor(hwndDlg, PP_FOREGROUNDCOLOR, SYSCLR_WINDOWTEXT); 2024 } */ 2025 mrc = FALSE; 2026 // let cnr draw the thing 1996 2027 } 1997 2028 else 1998 2029 { 1999 // not disabled, not selected: 2000 lBackground = winhQueryPresColor(hwndDlg, PP_BACKGROUNDCOLOR, SYSCLR_BACKGROUND); 2001 lForeground = winhQueryPresColor(hwndDlg, PP_FOREGROUNDCOLOR, SYSCLR_WINDOWTEXT); 2002 } */ 2003 mrc = FALSE; 2004 // let cnr draw the thing 2030 // CRA_DISABLED: 2031 2032 ULONG flCmd = DT_LEFT | DT_TOP | DT_ERASERECT; 2033 RECTL rcl2; 2034 2035 // set draw colors 2036 LONG lBackground, 2037 lForeground; 2038 2039 // switch to RGB 2040 GpiCreateLogColorTable(poi->hps, 0, LCOLF_RGB, 0, 0, NULL); 2041 2042 if ((pcdii->pRecord->flRecordAttr) & CRA_SELECTED) 2043 { 2044 // disabled and selected: 2045 lBackground = WinQuerySysColor(HWND_DESKTOP, 2046 SYSCLR_SHADOWTEXT, 0); 2047 lForeground = winhQueryPresColor(poi->hwnd, 2048 PP_BACKGROUNDCOLOR, 2049 FALSE, // no inherit 2050 SYSCLR_WINDOW); 2051 } 2052 else 2053 { 2054 // disabled and not selected: 2055 lBackground = winhQueryPresColor(poi->hwnd, 2056 PP_BACKGROUNDCOLOR, 2057 FALSE, 2058 SYSCLR_WINDOW); 2059 lForeground = WinQuerySysColor(HWND_DESKTOP, 2060 SYSCLR_SHADOWTEXT, 0); 2061 } 2062 2063 memcpy(&rcl2, &(poi->rclItem), sizeof(rcl2)); 2064 /* WinDrawText(poi->hps, 2065 strlen(pcdii->pRecord->pszText), 2066 pcdii->pRecord->pszText, 2067 &rcl2, 2068 lForeground, // foreground 2069 lBackground, 2070 flCmd); */ 2071 2072 GpiSetBackColor(poi->hps, lBackground); 2073 GpiSetColor(poi->hps, lForeground); 2074 2075 winhDrawFormattedText(poi->hps, 2076 &rcl2, 2077 pcdii->pRecord->pszText, 2078 flCmd); 2079 2080 mrc = (MPARAM)TRUE; // tell cnr that we've drawn the item 2081 } 2005 2082 } 2006 else 2083 else if ( (poi->idItem == CMA_ICON) 2084 && (flFlags & CODFL_MINIICON) 2085 ) 2007 2086 { 2008 // CRA_DISABLED: 2009 2010 ULONG flCmd = DT_LEFT | DT_TOP | DT_ERASERECT; 2011 RECTL rcl2; 2012 2013 // set draw colors 2014 LONG lBackground, 2015 lForeground; 2016 2017 // switch to RGB 2018 GpiCreateLogColorTable(poi->hps, 0, LCOLF_RGB, 0, 0, NULL); 2019 2020 if ((pcdii->pRecord->flRecordAttr) & CRA_SELECTED) 2021 { 2022 // disabled and selected: 2023 lBackground = WinQuerySysColor(HWND_DESKTOP, 2024 SYSCLR_SHADOWTEXT, 0); 2025 lForeground = winhQueryPresColor(poi->hwnd, 2026 PP_BACKGROUNDCOLOR, 2027 FALSE, // no inherit 2028 SYSCLR_WINDOW); 2029 } 2030 else 2031 { 2032 // disabled and not selected: 2033 lBackground = winhQueryPresColor(poi->hwnd, 2034 PP_BACKGROUNDCOLOR, 2035 FALSE, 2036 SYSCLR_WINDOW); 2037 lForeground = WinQuerySysColor(HWND_DESKTOP, 2038 SYSCLR_SHADOWTEXT, 0); 2039 } 2040 2041 memcpy(&rcl2, &(poi->rclItem), sizeof(rcl2)); 2042 /* WinDrawText(poi->hps, 2043 strlen(pcdii->pRecord->pszText), 2044 pcdii->pRecord->pszText, 2045 &rcl2, 2046 lForeground, // foreground 2047 lBackground, 2048 flCmd); */ 2049 2050 GpiSetBackColor(poi->hps, lBackground); 2051 GpiSetColor(poi->hps, lForeground); 2052 2053 winhDrawFormattedText(poi->hps, 2054 &rcl2, 2055 pcdii->pRecord->pszText, 2056 flCmd); 2057 2058 mrc = (MPARAM)TRUE; // tell cnr that we've drawn the item 2087 WinDrawPointer(poi->hps, 2088 // center the icon in the rectangle 2089 ( poi->rclItem.xLeft 2090 + (poi->rclItem.xRight - poi->rclItem.xLeft 2091 - WinQuerySysValue(HWND_DESKTOP, SV_CXICON) / 2 2092 ) / 2 2093 ), 2094 ( poi->rclItem.yBottom 2095 + (poi->rclItem.yTop - poi->rclItem.yBottom 2096 - WinQuerySysValue(HWND_DESKTOP, SV_CYICON) / 2 2097 ) / 2 2098 ), 2099 pcdii->pRecord->hptrMiniIcon, 2100 DP_MINI); 2101 2102 mrc = (MPARAM)TRUE; // tell cnr that we've drawn the item 2059 2103 } 2060 } else 2061 mrc = (MPARAM)FALSE; // tell cnr to draw the item 2104 } 2062 2105 2063 2106 return (mrc); -
trunk/src/helpers/dialog.c
r105 r106 1778 1778 { 1779 1779 CHAR szErr[300]; 1780 sprintf(szErr, "Error %d occured in dlghCreateDlg.", arc);1780 sprintf(szErr, "Error %d occured in " __FUNCTION__ ".", arc); 1781 1781 winhDebugBox(hwndOwner, 1782 "Error in Dialog Manager", 1783 szErr); 1784 } 1785 1786 return (arc); 1787 } 1788 1789 /* 1790 *@@ dlghFormatDlg: 1791 * similar to dlghCreateDlg in that this can 1792 * dynamically format dialog items. 1793 * 1794 * The differences however are the following: 1795 * 1796 * -- This assumes that hwndDlg already points 1797 * to a valid dialog frame and that this 1798 * dialog should be modified according to 1799 * flFlags. 1800 * 1801 * flFlags can be any combination of the following: 1802 * 1803 * -- DFFL_CREATECONTROLS: paDlgItems points to 1804 * an array of cDlgItems DLGHITEM structures 1805 * (see dlghCreateDlg) which is used for creating 1806 * subwindows in hwndDlg. By using this flag, the 1807 * function will essentially work like dlghCreateDlg, 1808 * except that the frame is already created. 1809 * 1810 * -- DFFL_RESIZEFRAME: hwndDlg should be resized so 1811 * that it will properly surround the controls. 1812 * 1813 * This can only be used in conjunction with 1814 * DFFL_RESIZEFRAME. 1815 * 1816 *@@added V0.9.16 (2001-09-29) [umoeller] 1817 */ 1818 1819 APIRET dlghFormatDlg(HWND hwndDlg, // in: dialog frame to work on 1820 PDLGHITEM paDlgItems, // in: definition array 1821 ULONG cDlgItems, // in: array item count (NOT array size) 1822 const char *pcszControlsFont, // in: font for ctls with CTL_COMMON_FONT 1823 ULONG flFlags) // in: DFFL_* flags 1824 { 1825 APIRET arc = NO_ERROR; 1826 1827 ULONG ul; 1828 1829 PDLGPRIVATE pDlgData = NULL; 1830 1831 /* 1832 * 1) parse the table and create structures from it 1833 * 1834 */ 1835 1836 if (!(arc = Dlg0_Init(&pDlgData, 1837 pcszControlsFont))) 1838 { 1839 if (!(arc = Dlg1_ParseTables(pDlgData, 1840 paDlgItems, 1841 cDlgItems))) 1842 { 1843 /* 1844 * 2) create empty dialog frame 1845 * 1846 */ 1847 1848 HWND hwndFocusItem = NULLHANDLE; 1849 SIZEL szlClient = {0}; 1850 RECTL rclClient; 1851 1852 pDlgData->hwndDlg = hwndDlg; 1853 1854 /* 1855 * 3) compute size of all controls 1856 * 1857 */ 1858 1859 Dlg2_CalcSizes(pDlgData, 1860 &szlClient); 1861 1862 // WinSubclassWindow(hwndDlg, pfnwpDialogProc); 1863 1864 /* 1865 * 4) compute size of dialog client from total 1866 * size of all controls 1867 */ 1868 1869 if (flFlags & DFFL_RESIZEFRAME) 1870 { 1871 // calculate the frame size from the client size 1872 rclClient.xLeft = 10; 1873 rclClient.yBottom = 10; 1874 rclClient.xRight = szlClient.cx + 2 * SPACING; 1875 rclClient.yTop = szlClient.cy + 2 * SPACING; 1876 WinCalcFrameRect(hwndDlg, 1877 &rclClient, 1878 FALSE); // frame from client 1879 1880 WinSetWindowPos(hwndDlg, 1881 0, 1882 10, 1883 10, 1884 rclClient.xRight, 1885 rclClient.yTop, 1886 SWP_MOVE | SWP_SIZE | SWP_NOADJUST); 1887 } 1888 1889 if (flFlags & DFFL_CREATECONTROLS) 1890 { 1891 if (!(arc = Dlg3_PositionAndCreate(pDlgData, 1892 &szlClient, 1893 &hwndFocusItem))) 1894 WinSetFocus(HWND_DESKTOP, hwndFocusItem); 1895 } 1896 } 1897 1898 Dlg9_Cleanup(&pDlgData); 1899 } 1900 1901 if (arc) 1902 { 1903 CHAR szErr[300]; 1904 sprintf(szErr, "Error %d occured in " __FUNCTION__ ".", arc); 1905 winhDebugBox(NULLHANDLE, 1782 1906 "Error in Dialog Manager", 1783 1907 szErr); -
trunk/src/helpers/tree.c
r86 r106 304 304 if (ul1 > ul2) 305 305 return +1; 306 return (0); 307 } 308 309 /* 310 *@@ treeCompareStrings: 311 * standard comparison func if the TREE.ulKey 312 * field really is a string pointer (PCSZ). 313 * 314 * This runs strcmp internally, but can handle 315 * NULL pointers without crashing. 316 * 317 *@@added V0.9.16 (2001-09-29) [umoeller] 318 */ 319 320 int TREEENTRY treeCompareStrings(unsigned long ul1, unsigned long ul2) 321 { 322 #define p1 (const char*)(ul1) 323 #define p2 (const char*)(ul2) 324 325 if (p1 && p2) 326 { 327 int i = strcmp(p1, p2); 328 if (i < 0) return (-1); 329 if (i > 0) return (+1); 330 } 331 else if (p1) 332 // but p2 is NULL: p1 greater than p2 then 333 return (+1); 334 else if (p2) 335 // but p1 is NULL: p1 less than p2 then 336 return (-1); 337 338 // return 0 if strcmp returned 0 above or both strings are NULL 306 339 return (0); 307 340 } -
trunk/src/helpers/winh.c
r101 r106 58 58 #define INCL_WINSWITCHLIST 59 59 #define INCL_WINBUTTONS 60 #define INCL_WINSTATICS 60 61 #define INCL_WINMENUS 61 62 #define INCL_WINSCROLLBARS … … 84 85 #include "helpers\prfh.h" 85 86 #include "helpers\gpih.h" 87 #include "helpers\standards.h" 86 88 #include "helpers\stringh.h" 87 89 #include "helpers\undoc.h" … … 4275 4277 4276 4278 /* 4279 *@@category: Helpers\PM helpers\Extended frame windows 4280 */ 4281 4282 /* ****************************************************************** 4283 * 4284 * Extended frame 4285 * 4286 ********************************************************************/ 4287 4288 /* 4289 *@@ fnwpSubclExtFrame: 4290 * subclassed frame window proc. 4291 * 4292 *@@added V0.9.16 (2001-09-29) [umoeller] 4293 */ 4294 4295 MRESULT EXPENTRY fnwpSubclExtFrame(HWND hwndFrame, ULONG msg, MPARAM mp1, MPARAM mp2) 4296 { 4297 MRESULT mrc = 0; 4298 4299 PEXTFRAMEDATA pData = (PEXTFRAMEDATA)WinQueryWindowPtr(hwndFrame, QWL_USER); 4300 4301 switch (msg) 4302 { 4303 case WM_QUERYFRAMECTLCOUNT: 4304 { 4305 // query the standard frame controls count 4306 ULONG ulrc = (ULONG)pData->pfnwpOrig(hwndFrame, msg, mp1, mp2); 4307 4308 // if we have a status bar, increment the count 4309 ulrc++; 4310 4311 mrc = (MPARAM)ulrc; 4312 } 4313 break; 4314 4315 case WM_FORMATFRAME: 4316 { 4317 // query the number of standard frame controls 4318 ULONG ulCount = (ULONG)pData->pfnwpOrig(hwndFrame, msg, mp1, mp2); 4319 4320 // we have a status bar: 4321 // format the frame 4322 ULONG ul; 4323 PSWP swpArr = (PSWP)mp1; 4324 4325 for (ul = 0; ul < ulCount; ul++) 4326 { 4327 if (WinQueryWindowUShort( swpArr[ul].hwnd, QWS_ID ) == 0x8008 ) 4328 // FID_CLIENT 4329 { 4330 POINTL ptlBorderSizes; 4331 ULONG ulStatusBarHeight = 20; 4332 WinSendMsg(hwndFrame, 4333 WM_QUERYBORDERSIZE, 4334 (MPARAM)&ptlBorderSizes, 4335 0); 4336 4337 // first initialize the _new_ SWP for the status bar. 4338 // Since the SWP array for the std frame controls is 4339 // zero-based, and the standard frame controls occupy 4340 // indices 0 thru ulCount-1 (where ulCount is the total 4341 // count), we use ulCount for our static text control. 4342 swpArr[ulCount].fl = SWP_MOVE | SWP_SIZE | SWP_NOADJUST | SWP_ZORDER; 4343 swpArr[ulCount].x = ptlBorderSizes.x; 4344 swpArr[ulCount].y = ptlBorderSizes.y; 4345 swpArr[ulCount].cx = swpArr[ul].cx; // same as cnr's width 4346 swpArr[ulCount].cy = ulStatusBarHeight; 4347 swpArr[ulCount].hwndInsertBehind = HWND_BOTTOM; // HWND_TOP; 4348 swpArr[ulCount].hwnd = WinWindowFromID(hwndFrame, FID_STATUSBAR); 4349 4350 // adjust the origin and height of the container to 4351 // accomodate our static text control 4352 swpArr[ul].y += swpArr[ulCount].cy; 4353 swpArr[ul].cy -= swpArr[ulCount].cy; 4354 } 4355 } 4356 4357 // increment the number of frame controls 4358 // to include our status bar 4359 mrc = (MRESULT)(ulCount + 1); 4360 } 4361 break; 4362 4363 case WM_CALCFRAMERECT: 4364 { 4365 mrc = pData->pfnwpOrig(hwndFrame, msg, mp1, mp2); 4366 4367 // we have a status bar: calculate its rectangle 4368 // CalcFrameRect(mp1, mp2); 4369 } 4370 break; 4371 4372 case WM_DESTROY: 4373 WinSubclassWindow(hwndFrame, pData->pfnwpOrig); 4374 free(pData); 4375 WinSetWindowPtr(hwndFrame, QWL_USER, NULL); 4376 break; 4377 4378 default: 4379 mrc = pData->pfnwpOrig(hwndFrame, msg, mp1, mp2); 4380 } 4381 4382 return (mrc); 4383 } 4384 4385 /* 4386 *@@ winhCreateStatusBar: 4387 * creates a status bar for a frame window. 4388 * 4389 * Normally there's no need to call this manually, 4390 * this gets called by winhCreateExtStdWindow 4391 * automatically. 4392 * 4393 *@@added V0.9.16 (2001-09-29) [umoeller] 4394 */ 4395 4396 HWND winhCreateStatusBar(HWND hwndFrame, 4397 HWND hwndOwner, 4398 const char *pcszText, // in: initial status bar text 4399 const char *pcszFont, // in: font to use for status bar 4400 LONG lColor) // in: foreground color for status bar 4401 { 4402 // create status bar 4403 HWND hwndReturn = NULLHANDLE; 4404 PPRESPARAMS ppp = NULL; 4405 winhStorePresParam(&ppp, PP_FONTNAMESIZE, strlen(pcszFont)+1, (PVOID)pcszFont); 4406 lColor = WinQuerySysColor(HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0); 4407 winhStorePresParam(&ppp, PP_BACKGROUNDCOLOR, sizeof(lColor), &lColor); 4408 lColor = CLR_BLACK; 4409 winhStorePresParam(&ppp, PP_FOREGROUNDCOLOR, sizeof(lColor), &lColor); 4410 hwndReturn = WinCreateWindow(hwndFrame, 4411 WC_STATIC, 4412 (PSZ)pcszText, 4413 SS_TEXT | DT_VCENTER | WS_VISIBLE, 4414 0, 0, 0, 0, 4415 hwndOwner, 4416 HWND_TOP, 4417 FID_STATUSBAR, 4418 NULL, 4419 ppp); 4420 free(ppp); 4421 return (hwndReturn); 4422 } 4423 4424 /* 4425 *@@ winhCreateExtStdWindow: 4426 * creates an extended frame window. 4427 * 4428 * pData must point to an EXTFRAMECDATA structure 4429 * which contains a copy of the parameters to be 4430 * passed to winhCreateStdWindow. In addition, 4431 * this contains the flExtFlags field, which allows 4432 * you to automatically create a status bar for 4433 * the window. 4434 * 4435 * Note that we subclass the frame here and require 4436 * QWL_USER for that. The frame's QWL_USER points 4437 * to an EXTFRAMEDATA structure whose pUser parameter 4438 * you may use for additional data, if you want to 4439 * do further subclassing. 4440 * 4441 *@@added V0.9.16 (2001-09-29) [umoeller] 4442 */ 4443 4444 HWND winhCreateExtStdWindow(PEXTFRAMECDATA pData, // in: extended frame data 4445 PHWND phwndClient) // out: created client wnd 4446 { 4447 HWND hwndFrame; 4448 4449 if (hwndFrame = winhCreateStdWindow(HWND_DESKTOP, 4450 pData->pswpFrame, 4451 pData->flFrameCreateFlags, 4452 pData->ulFrameStyle, 4453 pData->pcszFrameTitle, 4454 pData->ulResourcesID, 4455 pData->pcszClassClient, 4456 pData->flStyleClient, 4457 pData->ulID, 4458 pData->pClientCtlData, 4459 phwndClient)) 4460 { 4461 if (pData->flExtFlags & XFCF_STATUSBAR) 4462 { 4463 // create status bar as child of the frame 4464 HWND hwndStatusBar = winhCreateStatusBar(hwndFrame, 4465 hwndFrame, 4466 NULL, 4467 "9.WarpSans", 4468 CLR_BLACK); 4469 4470 // subclass frame for supporting status bar and msgs 4471 PEXTFRAMEDATA pFrameData; 4472 if (pFrameData = NEW(EXTFRAMEDATA)) 4473 { 4474 ZERO(pFrameData), 4475 memcpy(&pFrameData->CData, pData, sizeof(pFrameData->CData)); 4476 if (pFrameData->pfnwpOrig = WinSubclassWindow(hwndFrame, 4477 fnwpSubclExtFrame)) 4478 { 4479 WinSetWindowPtr(hwndFrame, QWL_USER, pFrameData); 4480 } 4481 else 4482 free(pFrameData); 4483 } 4484 } 4485 } 4486 4487 return (hwndFrame); 4488 } 4489 4490 /* 4277 4491 *@@category: Helpers\PM helpers\Workplace Shell\WPS class list 4278 4492 */ -
trunk/src/helpers/wphandle.c
r21 r106 12 12 * -- wph* WPS object helper functions 13 13 * 14 * This code is mostly written by Henk Kelder and published 15 * with his kind permission. 14 * Thanks go out to Henk Kelder for telling me the 15 * format of the WPS INI data. With V0.9.16, this 16 * file was completely rewritten and no longer uses 17 * his code though. 16 18 * 17 19 * Note: Version numbering in this file relates to XWorkplace version … … 22 24 23 25 /* 24 * This file Copyright (C) 1997-2000 Ulrich Mller, 25 * Henk Kelder. 26 * This file Copyright (C) 1997-2001 Ulrich Mller, 26 27 * This file is part of the "XWorkplace helpers" source package. 27 28 * This is free software; you can redistribute it and/or modify … … 40 41 // as unsigned char 41 42 43 #define INCL_DOSEXCEPTIONS 44 #define INCL_DOSPROCESS 45 #define INCL_DOSERRORS 46 42 47 #define INCL_WINSHELLDATA 43 48 #include <os2.h> 44 45 #define OPTIONS_SIZE 3276746 49 47 50 #include <stdio.h> … … 49 52 #include <stdlib.h> 50 53 #include <io.h> 54 #include <setjmp.h> 51 55 52 56 #include "setup.h" // code generation and debugging options 53 57 58 #include "helpers\except.h" 59 #include "helpers\prfh.h" 60 #include "helpers\standards.h" 61 #include "helpers\stringh.h" 62 #define INCLUDE_WPHANDLE_PRIVATE 54 63 #include "helpers\wphandle.h" 55 56 /**************************************************** 57 * * 58 * helper functions * 59 * * 60 ****************************************************/ 61 62 static USHORT wphSearchBufferForHandle(PBYTE pHandlesBuffer, ULONG ulBufSize, USHORT usParent, PSZ pszFname); 63 PNODE wphFindPartName(PBYTE pHandlesBuffer, ULONG ulBufSize, USHORT usID, PSZ pszFname, USHORT usMax); 64 65 #define MakeDiskHandle(usObjID) (usObjID | 0x30000) 66 67 #define IsObjectDisk(hObject) ((hObject & 0x30000) == 0x30000) 64 #include "helpers\xstring.h" 68 65 69 66 /* … … 74 71 /* ****************************************************************** 75 72 * 76 * Helperfunctions73 * Load handles functions 77 74 * 78 75 ********************************************************************/ 79 76 80 77 /* 81 *@@ wphQueryProfileData:82 * like PrfQueryProfileData, but allocates sufficient83 * memory and returns a pointer to that buffer.84 * pulSize must point to a ULONG which will then85 * contain the no. of copied bytes.86 */87 88 PBYTE wphQueryProfileData(HINI hIniSystem, // in: can be HINI_USER or HINI_SYSTEM89 PSZ pApp, PSZ pKey, // in: load what?90 PULONG pulSize) // out: bytes loaded91 {92 PBYTE pData = NULL;93 if (PrfQueryProfileSize(hIniSystem, pApp, pKey, pulSize))94 {95 pData = (PBYTE)malloc(*pulSize);96 PrfQueryProfileData(hIniSystem, pApp, pKey, pData, pulSize);97 }98 // _Pmpf((" wphQueryProfileData(%lX, %s, %s, %d)", hIniSystem, pApp, pKey, *pulSize));99 return (pData);100 }101 102 /*103 *@@ wphEnumProfileKeys:104 * allocates memory for a buffer and copies the keys105 * for pApp into it.106 * Returns the pointer to the buffer.107 * pulKeysSize must point to a ULONG which will then108 * contain the size of the returned buffer.109 */110 111 PBYTE wphEnumProfileKeys(HINI hIniSystem, // in: can be HINI_USER or HINI_SYSTEM112 PSZ pApp, // in: app to query113 PULONG pulKeysSize) // out: sizeof(return buffer)114 {115 PBYTE pszKeys = NULL;116 if (PrfQueryProfileSize(hIniSystem, pApp, NULL, pulKeysSize))117 {118 pszKeys = (PBYTE)malloc(*pulKeysSize);119 if (pszKeys)120 PrfQueryProfileData(hIniSystem, pApp, NULL, pszKeys, pulKeysSize);121 }122 return (pszKeys);123 }124 125 /*126 * wphResetBlockBuffer:127 * Reset the block buffer, make sure the buffer is re-read.128 */129 130 /* VOID wphResetBlockBuffer(VOID)131 {132 if (pHandlesBuffer)133 {134 free(pHandlesBuffer);135 pHandlesBuffer = NULL;136 }137 } */138 139 /*140 78 *@@ wphQueryActiveHandles: 141 * this copies the contents of PM_Workplace:ActiveHandles 142 * in OS2SYS.INI into a given buffer. There are always two 143 * buffers in OS2SYS.INI for object handles, called 144 * "PM_Workplace:HandlesX" with "X" either being "0" or "1". 79 * returns the value of PM_Workplace:ActiveHandles 80 * in OS2SYS.INI as a new buffer. 81 * 82 * There are always two buffers in OS2SYS.INI for object 83 * handles, called "PM_Workplace:HandlesX" with "X" either 84 * being "0" or "1". 85 * 145 86 * It seems that every time the WPS does something in the 146 87 * handles section, it writes the data to the inactive … … 149 90 * by creating a shadow on your Desktop. 150 91 * 151 * This function copies the key only, but not the actual152 * handles blocks (use wphReadAllBlocks for that).92 * This returns a new PSZ which the caller must free() 93 * after use. 153 94 * 154 95 * This gets called by the one-shot function 155 96 * wphQueryHandleFromPath. 156 */ 157 158 BOOL wphQueryActiveHandles(HINI hIniSystem, // in: can be HINI_USER or HINI_SYSTEM 159 PSZ pszHandlesAppName, // out: active handles buffer. 160 USHORT usMax) // in: sizeof(pszHandlesAppName) 161 { 162 PBYTE pszHandles; 163 ULONG ulProfileSize; 164 165 pszHandles = wphQueryProfileData(hIniSystem, 166 ACTIVEHANDLES, HANDLESAPP, 167 &ulProfileSize); 168 if (!pszHandles) 169 { 170 strncpy(pszHandlesAppName, HANDLES, usMax-1); 171 return TRUE; 172 } 173 // fNewFormat = TRUE; 174 strncpy(pszHandlesAppName, pszHandles, usMax-1); 175 free(pszHandles); 176 return TRUE; 97 * 98 *@@changed V0.9.16 (2001-10-02) [umoeller]: rewritten 99 */ 100 101 APIRET wphQueryActiveHandles(HINI hiniSystem, 102 PSZ *ppszActiveHandles) 103 { 104 PSZ pszActiveHandles; 105 if (pszActiveHandles = prfhQueryProfileData(hiniSystem, 106 WPINIAPP_ACTIVEHANDLES, 107 WPINIAPP_HANDLESAPP, 108 NULL)) 109 { 110 *ppszActiveHandles = pszActiveHandles; 111 return (NO_ERROR); 112 } 113 114 return (ERROR_WPH_NO_ACTIVEHANDLES_DATA); 115 } 116 117 /* 118 *@@ wphQueryBaseClassesHiwords: 119 * returns the hiwords for the WPS base 120 * classes. Unless the user's system is 121 * really badly configured, this should 122 * set 123 * 124 * -- pusHiwordAbstract to 2; 125 * -- pusHiwordFileSystem to 3. 126 * 127 * Returns: 128 * 129 * -- NO_ERROR 130 * 131 * -- ERROR_WPH_NO_BASECLASS_DATA 132 * 133 * -- ERROR_WPH_INCOMPLETE_BASECLASS_DATA 134 * 135 * This gets called automatically from wphLoadHandles. 136 * 137 *@@added V0.9.16 (2001-10-02) [umoeller] 138 */ 139 140 APIRET wphQueryBaseClassesHiwords(HINI hiniUser, 141 PUSHORT pusHiwordAbstract, 142 PUSHORT pusHiwordFileSystem) 143 { 144 APIRET arc = NO_ERROR; 145 146 // get the index of WPFileSystem from the base classes list... 147 // we need this to determine the hiword for file-system handles 148 // properly. Normally, this should be 3. 149 ULONG cbBaseClasses = 0; 150 PSZ pszBaseClasses; 151 if (pszBaseClasses = prfhQueryProfileData(hiniUser, 152 "PM_Workplace:BaseClass", 153 "ClassList", 154 &cbBaseClasses)) 155 { 156 // parse that buffer... these has the base class names, 157 // separated by 0. List is terminated by two zeroes. 158 PSZ pszClassThis = pszBaseClasses; 159 ULONG ulHiwordThis = 1; 160 while ( (*pszClassThis) 161 && (pszClassThis - pszBaseClasses < cbBaseClasses) 162 ) 163 { 164 if (!strcmp(pszClassThis, "WPFileSystem")) 165 *pusHiwordFileSystem = ulHiwordThis; 166 else if (!strcmp(pszClassThis, "WPAbstract")) 167 *pusHiwordAbstract = ulHiwordThis; 168 169 ulHiwordThis++; 170 pszClassThis += strlen(pszClassThis) + 1; 171 } 172 173 // now check if we found both 174 if ( (!(*pusHiwordFileSystem)) 175 || (!(*pusHiwordAbstract)) 176 ) 177 arc = ERROR_WPH_INCOMPLETE_BASECLASS_DATA; 178 179 free(pszBaseClasses); 180 } 181 else 182 arc = ERROR_WPH_NO_BASECLASS_DATA; 183 184 return (arc); 185 } 186 187 /* 188 *@@ wphRebuildNodeHashTable: 189 * 190 * Returns: 191 * 192 * -- NO_ERROR 193 * 194 * -- ERROR_INVALID_PARAMETER 195 * 196 * -- ERROR_WPH_CORRUPT_HANDLES_DATA 197 * 198 *@@added V0.9.16 (2001-10-02) [umoeller] 199 */ 200 201 APIRET wphRebuildNodeHashTable(PHANDLESBUF pHandlesBuf) 202 { 203 APIRET arc = NO_ERROR; 204 205 if ( (!pHandlesBuf) 206 || (!pHandlesBuf->pbData) 207 || (!pHandlesBuf->cbData) 208 ) 209 arc = ERROR_INVALID_PARAMETER; 210 else 211 { 212 // start at beginning of buffer 213 PBYTE pCur = pHandlesBuf->pbData + 4; 214 PBYTE pEnd = pHandlesBuf->pbData + pHandlesBuf->cbData; 215 216 memset(pHandlesBuf->NodeHashTable, 0, sizeof(pHandlesBuf->NodeHashTable)); 217 218 // now set up hash table 219 while (pCur < pEnd) 220 { 221 if (!memicmp(pCur, "DRIV", 4)) 222 { 223 // pCur points to a DRIVE node: 224 // these never have handles, so skip this 225 PDRIV pDriv = (PDRIV)pCur; 226 pCur += sizeof(DRIV) + strlen(pDriv->szName); 227 } 228 else if (!memicmp(pCur, "NODE", 4)) 229 { 230 // pCur points to a regular NODE: offset pointer first 231 PNODE pNode = (PNODE)pCur; 232 // store PNODE in hash table 233 pHandlesBuf->NodeHashTable[pNode->usHandle] = pNode; 234 pCur += sizeof (NODE) + pNode->usNameSize; 235 } 236 else 237 { 238 arc = ERROR_WPH_CORRUPT_HANDLES_DATA; 239 break; 240 } 241 } 242 } 243 244 if (!arc) 245 pHandlesBuf->fNodeHashTableValid = TRUE; 246 247 return (arc); 248 } 249 250 /* 251 *@@ wphLoadHandles: 252 * returns a HANDLESBUF structure which will hold 253 * all the handles from OS2SYS.INI. In addition, 254 * this calls wphQueryBaseClassesHiwords and puts 255 * the hiwords for WPAbstract and WPFileSystem into 256 * the HANDLESBUF as well. 257 * 258 * Prerequisite before using any of the other wph* 259 * functions. 260 * 261 * Call wphFreeHandles to free all data allocated 262 * by this function. 263 * 264 * Returns: 265 * 266 * -- NO_ERROR 267 * 268 * -- ERROR_NOT_ENOUGH_MEMORY 269 * 270 * -- ERROR_INVALID_PARAMETER 271 * 272 * -- ERROR_WPH_NO_HANDLES_DATA: cannot read handle blocks. 273 * 274 * -- ERROR_WPH_CORRUPT_HANDLES_DATA: cannot read handle blocks. 275 * 276 *@@added V0.9.16 (2001-10-02) [umoeller] 277 */ 278 279 APIRET wphLoadHandles(HINI hiniUser, // in: HINI_USER or other INI handle 280 HINI hiniSystem, // in: HINI_SYSTEM or other INI handle 281 const char *pcszActiveHandles, 282 PHANDLESBUF *ppHandlesBuf) 283 { 284 APIRET arc = NO_ERROR; 285 286 if (!ppHandlesBuf) 287 arc = ERROR_INVALID_PARAMETER; 288 else 289 { 290 PSZ pszKeysList; 291 if (!(arc = prfhQueryKeysForApp(hiniSystem, 292 pcszActiveHandles, 293 &pszKeysList))) 294 { 295 PHANDLESBUF pReturn = NULL; 296 297 ULONG ulHighestBlock = 0, 298 ul, 299 cbTotal; 300 PBYTE pbData; 301 302 const char *pKey2 = pszKeysList; 303 while (*pKey2) 304 { 305 if (!memicmp((PVOID)pKey2, "BLOCK", 5)) 306 { 307 ULONG ulBlockThis = atoi(pKey2 + 5); 308 if (ulBlockThis > ulHighestBlock) 309 ulHighestBlock = ulBlockThis; 310 } 311 312 pKey2 += strlen(pKey2)+1; // next key 313 } 314 315 free(pszKeysList); 316 317 if (!ulHighestBlock) 318 arc = ERROR_WPH_NO_HANDLES_DATA; 319 else 320 { 321 // now go read the data 322 // (BLOCK1, BLOCK2, ..., BLOCKn) 323 cbTotal = 0; 324 pbData = NULL; 325 for (ul = 1; 326 ul <= ulHighestBlock; 327 ul++) 328 { 329 ULONG cbBlockThis; 330 CHAR szBlockThis[10]; 331 sprintf(szBlockThis, "BLOCK%d", ul); 332 if (!PrfQueryProfileSize(hiniSystem, 333 (PSZ)pcszActiveHandles, 334 szBlockThis, 335 &cbBlockThis)) 336 { 337 arc = ERROR_WPH_CORRUPT_HANDLES_DATA; 338 break; 339 } 340 else 341 { 342 ULONG cbTotalOld = cbTotal; 343 cbTotal += cbBlockThis; 344 if (!(pbData = realloc(pbData, cbTotal))) 345 // on first call, pbData is NULL and this 346 // behaves like malloc() 347 { 348 arc = ERROR_NOT_ENOUGH_MEMORY; 349 break; 350 } 351 352 if (!PrfQueryProfileData(hiniSystem, 353 (PSZ)pcszActiveHandles, 354 szBlockThis, 355 pbData + cbTotalOld, 356 &cbBlockThis)) 357 { 358 arc = ERROR_WPH_CORRUPT_HANDLES_DATA; 359 break; 360 } 361 } 362 } 363 } 364 365 if (!arc) 366 { 367 // all went OK: 368 if (pReturn = NEW(HANDLESBUF)) 369 { 370 ZERO(pReturn); 371 372 pReturn->pbData = pbData; 373 pReturn->cbData = cbTotal; 374 375 // and load the hiwords too 376 if (!(arc = wphQueryBaseClassesHiwords(hiniUser, 377 &pReturn->usHiwordAbstract, 378 &pReturn->usHiwordFileSystem))) 379 *ppHandlesBuf = pReturn; 380 } 381 else 382 arc = ERROR_NOT_ENOUGH_MEMORY; 383 } 384 385 if (arc) 386 // error: 387 wphFreeHandles(&pReturn); 388 } 389 } 390 391 return (arc); 392 } 393 394 /* 395 *@@ wphFreeHandles: 396 * frees all data allocated by wphLoadHandles 397 * and sets *ppHandlesBuf to NULL, for safety. 398 * 399 *@@added V0.9.16 (2001-10-02) [umoeller] 400 */ 401 402 APIRET wphFreeHandles(PHANDLESBUF *ppHandlesBuf) 403 { 404 APIRET arc = NO_ERROR; 405 406 if (ppHandlesBuf && *ppHandlesBuf) 407 { 408 PBYTE pbData; 409 if (pbData = (*ppHandlesBuf)->pbData) 410 free(pbData); 411 412 free(*ppHandlesBuf); 413 *ppHandlesBuf = NULL; 414 } 415 else 416 arc = ERROR_INVALID_PARAMETER; 417 418 return (arc); 177 419 } 178 420 … … 195 437 */ 196 438 197 BOOL wphReadAllBlocks(HINI hiniSystem, // in: can be HINI_USER or HINI_SYSTEM439 /* BOOL wphReadAllBlocks(HINI hiniSystem, // in: can be HINI_USER or HINI_SYSTEM 198 440 PSZ pszActiveHandles, // in: active handles section 199 441 PBYTE* ppBlock, // in/out: pointer to buffer, which … … 246 488 if (!(*ppBlock)) 247 489 { 248 /* MessageBox("wphReadAllBlocks", "Not enough memory for profile data!"); */249 490 free(pbAllBlocks); 250 491 return FALSE; … … 278 519 free(pbAllBlocks); 279 520 return TRUE; 280 } 521 } */ 281 522 282 523 /* ****************************************************************** … … 289 530 *@@ wphSearchBufferForHandle: 290 531 * returns the four-digit object handle which corresponds 291 * to pszF name, searching pHandlesBuffer. Note that you532 * to pszFilename, searching pHandlesBuffer. Note that you 292 533 * must OR the return value with 0x30000 to make this 293 534 * a valid WPS file-system handle. … … 304 545 USHORT usParent, // in: parent NODE ID; 305 546 // must be 0 initially 306 PSZ pszF name) // in: fully qlf'd filename to search for547 PSZ pszFilename) // in: fully qlf'd filename to search for 307 548 { 308 549 PDRIV pDriv; … … 313 554 USHORT usPartSize; 314 555 315 // _Pmpf(("Entering wphSearchBufferForHandle for %s", pszF name));556 // _Pmpf(("Entering wphSearchBufferForHandle for %s", pszFilename)); 316 557 317 558 // The composed BLOCKs in the handles buffer make up a tree of … … 334 575 // So first find the length of the first filename part (which 335 576 // should be 2 for the drive letter, "C:") 336 p = strchr(pszF name, '\\');577 p = strchr(pszFilename, '\\'); 337 578 if (p) 338 579 // backslash found: 339 usPartSize = p - pszF name; // extract first part580 usPartSize = p - pszFilename; // extract first part 340 581 else 341 usPartSize = strlen(pszF name);582 usPartSize = strlen(pszFilename); 342 583 343 584 // now set the pointer for the end of the BLOCKs buffer … … 348 589 pCur = pHandlesBuffer + 4; 349 590 350 // _Pmpf((" Searching for: %s, usPartSize: %d", pszF name, usPartSize));591 // _Pmpf((" Searching for: %s, usPartSize: %d", pszFilename, usPartSize)); 351 592 352 593 // go! … … 386 627 387 628 // do the partnames match too? 388 if (memicmp(pszF name, pNode->szName, usPartSize) == 0)629 if (memicmp(pszFilename, pNode->szName, usPartSize) == 0) 389 630 { 390 631 // OK!! proper NODE found! … … 393 634 // now check if this was the last NODE 394 635 // we were looking for 395 if (strlen(pszF name) == usPartSize)636 if (strlen(pszFilename) == usPartSize) 396 637 // yes: return ID 397 638 return (pNode->usHandle); … … 399 640 // else: update our status; 400 641 // get next partname 401 pszF name += usPartSize + 1;642 pszFilename += usPartSize + 1; 402 643 // calc next partname length 403 p = strchr(pszF name, '\\');644 p = strchr(pszFilename, '\\'); 404 645 if (p) 405 usPartSize = p - pszFname;646 usPartSize = p - pszFilename; 406 647 else 407 usPartSize = strlen(pszFname);648 usPartSize = strlen(pszFilename); 408 649 409 650 // get next parent to search for … … 426 667 /* 427 668 *@@ wphQueryHandleFromPath: 428 * find the object handle for pszName; this 429 * can either be an object ID ("<WP_DESKTOP>") 430 * or a fully qualified filename. 669 * finds the object handle for the given fully qualified 670 * filename. 431 671 * This is a one-shot function, using wphQueryActiveHandles, 432 672 * wphReadAllBlocks, and wphSearchBufferForHandle. 433 673 * 434 674 * Returns: 435 * -- -1: file does not exist 436 * -- -2: error querying handles buffer 437 * -- 0: object handle not found; might not exist 438 * -- other: found object handle 439 * 440 * NOTE: This function uses C runtime library 441 * string comparison functions. These only work 442 * properly if you have set the locale for the 443 * C runtime properly. This is, for example, a 444 * problem with file names containing German umlauts, 445 * which are not found properly. 446 * You should put some 447 + setlocale(LC_ALL, ""); 448 * statement somewhere, which reacts to the LANG 449 * variable which OS/2 puts into CONFIG.SYS per 450 * default. 451 */ 452 453 HOBJECT wphQueryHandleFromPath(HINI hIniUser, // in: user ini file 454 HINI hIniSystem, // in: system ini file 455 PSZ pszName) // in: fully qlf'd filename 456 { 457 PBYTE pHandlesBuffer = NULL; 458 ULONG cbHandlesBuffer = 0, 459 cbLocation = 0; 460 USHORT usObjID; 675 * 676 * -- NO_ERROR: *phobj has received the object handle. 677 * 678 * -- ERROR_FILE_NOT_FOUND: file does not exist. 679 * 680 * plus the error codes of the other wph* functions called. 681 * 682 *@@changed V0.9.16 (2001-10-02) [umoeller]: rewritten 683 */ 684 685 APIRET wphQueryHandleFromPath(HINI hiniUser, // in: HINI_USER or other INI handle 686 HINI hiniSystem, // in: HINI_SYSTEM or other INI handle 687 const char *pcszName, // in: fully qlf'd filename 688 HOBJECT *phobj) // out: object handle found if NO_ERROR 689 { 690 APIRET arc = NO_ERROR; 461 691 PVOID pvData; 462 HOBJECT hObject = 0L; 463 BYTE szFullPath[300]; 464 CHAR szActiveHandles[100]; 465 466 // _Pmpf(("wphQueryHandleFromPath: %s", pszName)); 467 468 // try to get the objectID via PM_Workplace:Location, since 469 // pszName might also be a "<WP_DESKTOP>" like thingy 470 pvData = wphQueryProfileData(hIniUser, 471 LOCATION, // "PM_Workplace:Location" (<WP_DESKTOP> etc.) 472 pszName, 473 &cbLocation); 474 if (pvData) 475 { 476 // found there: 477 if (cbLocation >= sizeof(HOBJECT)) 478 hObject = *(PULONG)pvData; 479 free(pvData); 480 // _Pmpf((" object ID found, hObject: %lX", hObject)); 481 } 482 if (hObject) 483 return (hObject); 484 485 // not found there: is pszName an existing pathname? 486 if (access(pszName, 0)) // check existence 487 { 488 // == -1: file does not exist 489 // _Pmpf((" path not found, returning -1")); 490 return (-1); 491 } 492 493 // else: make full path for pszName 494 _fullpath(szFullPath, pszName, sizeof(szFullPath)); 495 496 // check if the HandlesBlock is valid 497 wphQueryActiveHandles(hIniSystem, szActiveHandles, sizeof(szActiveHandles)); 498 // _Pmpf((" szActiveHandles: %s", szActiveHandles)); 499 500 // now load all the BLOCKs into a common buffer 501 if (!wphReadAllBlocks(hIniSystem, 502 szActiveHandles, 503 &pHandlesBuffer, &cbHandlesBuffer)) 504 // error: 505 return (-2); 506 507 // and search that buffer 508 usObjID = wphSearchBufferForHandle(pHandlesBuffer, 509 cbHandlesBuffer, 510 0, // usParent 511 szFullPath); 512 513 if (usObjID) 514 // found: OR 0x30000 515 hObject = MakeDiskHandle(usObjID); 516 517 free(pHandlesBuffer); 518 519 return (hObject); 692 693 TRY_LOUD(excpt1) 694 { 695 // not found there: check the handles then 696 PSZ pszActiveHandles; 697 if (arc = wphQueryActiveHandles(hiniSystem, &pszActiveHandles)) 698 _Pmpf((__FUNCTION__ ": wphQueryActiveHandles returned %d", arc)); 699 else 700 { 701 PHANDLESBUF pHandlesBuf; 702 if (arc = wphLoadHandles(hiniUser, 703 hiniSystem, 704 pszActiveHandles, 705 &pHandlesBuf)) 706 _Pmpf((__FUNCTION__ ": wphLoadHandles returned %d", arc)); 707 else 708 { 709 USHORT usObjID; 710 CHAR szFullPath[2*CCHMAXPATH]; 711 _fullpath(szFullPath, (PSZ)pcszName, sizeof(szFullPath)); 712 713 // search that buffer 714 if (usObjID = wphSearchBufferForHandle(pHandlesBuf->pbData, 715 pHandlesBuf->cbData, 716 0, // usParent 717 szFullPath)) 718 // found: OR 0x30000 719 *phobj = usObjID | (pHandlesBuf->usHiwordFileSystem << 16); 720 else 721 arc = ERROR_FILE_NOT_FOUND; 722 723 wphFreeHandles(&pHandlesBuf); 724 } 725 726 free(pszActiveHandles); 727 } 728 } 729 CATCH(excpt1) 730 { 731 arc = ERROR_WPH_CRASHED; 732 } END_CATCH(); 733 734 return (arc); 520 735 } 521 736 … … 527 742 528 743 /* 529 *@@ wphFindPartName: 530 * this searches pHandlesBuffer for usHandle and, if found, 531 * appends the object partname to pszFname. 532 * This function recurses, if neccessary. 533 * 534 * This gets called by the one-shot function 535 * wphQueryPathFromHandle. 536 */ 537 538 PNODE wphFindPartName(PBYTE pHandlesBuffer, // in: handles buffer 539 ULONG ulBufSize, // in: buffer size 540 USHORT usHandle, // in: handle to search for 541 PSZ pszFname, // out: object partname 542 USHORT usMax) // in: sizeof(pszFname) 543 { 544 PDRIV pDriv; 744 *@@ ComposeThis: 745 * helper for wphComposePath recursion. 746 * 747 *@@added V0.9.16 (2001-10-02) [umoeller] 748 */ 749 750 APIRET ComposeThis(PHANDLESBUF pHandlesBuf, 751 USHORT usHandle, // in: handle to search for 752 PXSTRING pstrFilename, // in/out: filename 753 PNODE *ppNode) // out: node found (ptr can be NULL) 754 { 755 APIRET arc = NO_ERROR; 545 756 PNODE pNode; 546 PBYTE p, pEnd; 547 USHORT usSize; 548 549 pEnd = pHandlesBuffer + ulBufSize; 550 p = pHandlesBuffer + 4; 551 while (p < pEnd) 552 { 553 if (!memicmp(p, "DRIV", 4)) 554 { 555 pDriv = (PDRIV)p; 556 p += sizeof(DRIV) + strlen(pDriv->szName); 557 } 558 else if (!memicmp(p, "NODE", 4)) 559 { 560 pNode = (PNODE)p; 561 p += sizeof (NODE) + pNode->usNameSize; 562 if (pNode->usHandle == usHandle) 563 { 564 usSize = usMax - strlen(pszFname); 565 if (usSize > pNode->usNameSize) 566 usSize = pNode->usNameSize; 567 if (pNode->usParentHandle) 568 { 569 if (!wphFindPartName(pHandlesBuffer, ulBufSize, 570 pNode->usParentHandle, 571 pszFname, 572 usMax)) 573 return (NULL); 574 strcat(pszFname, "\\"); 575 strncat(pszFname, pNode->szName, usSize); 576 return pNode; 577 } 757 if (pNode = pHandlesBuf->NodeHashTable[usHandle]) 758 { 759 // handle exists: 760 if (pNode->usParentHandle) 761 { 762 // node has parent: 763 // recurse first 764 if (arc = ComposeThis(pHandlesBuf, 765 pNode->usParentHandle, 766 pstrFilename, 767 ppNode)) 768 { 769 if (arc == ERROR_INVALID_HANDLE) 770 // parent handle not found: 771 arc = ERROR_WPH_INVALID_PARENT_HANDLE; 772 // else leave the APIRET, this might be dangerous 773 } 774 else 775 { 776 // no error: 777 xstrcatc(pstrFilename, '\\'); 778 xstrcat(pstrFilename, pNode->szName, pNode->usNameSize); 779 } 780 } 781 else 782 // no parent: 783 xstrcpy(pstrFilename, pNode->szName, pNode->usNameSize); 784 } 785 else 786 arc = ERROR_INVALID_HANDLE; 787 788 if (!arc) 789 if (ppNode) 790 *ppNode = pNode; 791 792 return (arc); 793 } 794 795 /* 796 *@@ wphComposePath: 797 * returns the fully qualified path name for the specified 798 * file-system handle. This function is very fast because 799 * it uses a hash table for all the handles internally. 800 * 801 * Warning: This calls a helper, which recurses. 802 * 803 * This returns: 804 * 805 * -- NO_ERROR 806 * 807 * -- ERROR_WPH_CORRUPT_HANDLES_DATA: buffer data cannot be parsed. 808 * 809 * -- ERROR_WPH_INVALID_HANDLE: usHandle cannot be found. 810 * 811 * -- ERROR_WPH_INVALID_PARENT_HANDLE: a handle was found 812 * that has a broken parent handle. 813 * 814 * -- ERROR_BUFFER_OVERFLOW: cbFilename is too small to 815 * hold the full path that was composed. 816 * 817 *@@added V0.9.16 (2001-10-02) [umoeller] 818 */ 819 820 APIRET wphComposePath(PHANDLESBUF pHandlesBuf, 821 USHORT usHandle, // in: loword of handle to search for 822 PSZ pszFilename, 823 ULONG cbFilename, 824 PNODE *ppNode) // out: node found (ptr can be NULL) 825 { 826 APIRET arc = NO_ERROR; 827 828 TRY_LOUD(excpt1) 829 { 830 if (!pHandlesBuf->fNodeHashTableValid) 831 arc = wphRebuildNodeHashTable(pHandlesBuf); 832 833 if (!arc) 834 { 835 XSTRING str; 836 xstrInit(&str, CCHMAXPATH); 837 if (!(arc = ComposeThis(pHandlesBuf, 838 usHandle, 839 &str, 840 ppNode))) 841 if (str.ulLength > cbFilename - 1) 842 arc = ERROR_BUFFER_OVERFLOW; 578 843 else 579 { 580 strncpy(pszFname, pNode->szName, usSize); 581 return pNode; 582 } 583 } 584 } 585 else 586 return (NULL); 587 } 588 return (NULL); 844 memcpy(pszFilename, 845 str.psz, 846 str.ulLength + 1); 847 } 848 } 849 CATCH(excpt1) 850 { 851 arc = ERROR_WPH_CRASHED; 852 } END_CATCH(); 853 854 return (arc); 589 855 } 590 856 … … 596 862 * wphReadAllBlocks, and wphFindPartName. 597 863 * 598 *@@changed V0.9.4 (2000-08-03) [umoeller]: now returning BOOL 599 */ 600 601 BOOL wphQueryPathFromHandle(HINI hIniSystem, // in: HINI_SYSTEM or other INI handle 602 HOBJECT hObject, // in: five-digit object handle 603 PSZ pszFname, // out: filename, if found 604 USHORT usMax) // in: sizeof(*pszFname) 605 { 606 BOOL brc = FALSE; 607 608 if (IsObjectDisk(hObject)) 609 { 610 // use lower byte only 611 USHORT usObjID = LOUSHORT(hObject); 612 613 PBYTE pHandlesBuffer = NULL; 614 ULONG cbHandlesBuffer = 0; 615 616 CHAR szActiveHandles[100]; 617 // PNODE pReturnNode = 0; 618 619 wphQueryActiveHandles(hIniSystem, szActiveHandles, sizeof(szActiveHandles)); 620 621 if (wphReadAllBlocks(hIniSystem, 622 szActiveHandles, 623 &pHandlesBuffer, 624 &cbHandlesBuffer)) 625 { 626 memset(pszFname, 0, usMax); 627 if (wphFindPartName(pHandlesBuffer, 628 cbHandlesBuffer, 629 usObjID, 630 pszFname, 631 usMax)) 632 brc = TRUE; 633 634 free(pHandlesBuffer); 635 } 636 } 637 638 return (brc); 864 * Returns: 865 * 866 * -- NO_ERROR 867 * 868 * -- ERROR_INVALID_HANDLE: hObject is invalid. 869 * 870 *@@changed V0.9.16 (2001-10-02) [umoeller]: rewritten 871 */ 872 873 APIRET wphQueryPathFromHandle(HINI hiniUser, // in: HINI_USER or other INI handle 874 HINI hiniSystem, // in: HINI_SYSTEM or other INI handle 875 HOBJECT hObject, // in: 32-bit object handle 876 PSZ pszFilename, // out: filename, if found 877 ULONG cbFilename) // in: sizeof(*pszFilename) 878 { 879 APIRET arc = NO_ERROR; 880 881 TRY_LOUD(excpt1) 882 { 883 PSZ pszActiveHandles; 884 if (arc = wphQueryActiveHandles(hiniSystem, &pszActiveHandles)) 885 _Pmpf((__FUNCTION__ ": wphQueryActiveHandles returned %d", arc)); 886 else 887 { 888 PHANDLESBUF pHandlesBuf; 889 if (arc = wphLoadHandles(hiniUser, 890 hiniSystem, 891 pszActiveHandles, 892 &pHandlesBuf)) 893 _Pmpf((__FUNCTION__ ": wphLoadHandles returned %d", arc)); 894 else 895 { 896 // is this really a file-system object? 897 if (HIUSHORT(hObject) == pHandlesBuf->usHiwordFileSystem) 898 { 899 // use loword only 900 USHORT usObjID = LOUSHORT(hObject); 901 902 memset(pszFilename, 0, cbFilename); 903 arc = wphComposePath(pHandlesBuf, 904 usObjID, 905 pszFilename, 906 cbFilename, 907 NULL); 908 909 _Pmpf((__FUNCTION__ ": wphFindPartName returned %d", arc)); 910 } 911 912 wphFreeHandles(&pHandlesBuf); 913 } 914 915 free(pszActiveHandles); 916 } 917 } 918 CATCH(excpt1) 919 { 920 arc = ERROR_WPH_CRASHED; 921 } END_CATCH(); 922 923 return (arc); 639 924 } 640 925 641 /* ****************************************************************** 642 * 643 * Manipulation functions 644 * 645 ********************************************************************/ 646 647 /* 648 *@@ WriteAllBlocks: 649 * writes all blocks back to OS2SYS.INI. 650 * 651 *@@added V0.9.5 (2000-08-20) [umoeller] 652 */ 653 654 BOOL WriteAllBlocks(HINI hini, PSZ pszHandles, PBYTE pBuffer, ULONG ulSize) 655 { 656 PSZ p, 657 pEnd; 658 BYTE szBlockName[10]; 659 INT iCurBlock; 660 ULONG ulCurSize; 661 PBYTE pStart; 662 PDRIV pDriv; 663 PNODE pNode; 664 665 pStart = pBuffer; 666 ulCurSize = 4; 667 p = pBuffer + 4; 668 pEnd = pBuffer + ulSize; 669 iCurBlock = 1; 670 while (p < pEnd) 671 { 672 // ULONG cbWrite = 0; 673 while (p < pEnd) 674 { 675 ULONG ulPartSize = 0; 676 if (!memicmp(p, "DRIV", 4)) 677 { 678 pDriv = (PDRIV)p; 679 ulPartSize = sizeof(DRIV) + strlen(pDriv->szName); 680 } 681 else if (!memicmp(p, "NODE", 4)) 682 { 683 pNode = (PNODE)p; 684 ulPartSize = sizeof (NODE) + pNode->usNameSize; 685 } 686 687 if (ulCurSize + ulPartSize > 0x0000FFFF) 688 break; 689 690 ulCurSize += ulPartSize; 691 p += ulPartSize; 692 } 693 sprintf(szBlockName, "BLOCK%d", iCurBlock++); 694 695 PrfWriteProfileData(hini, 696 pszHandles, // app 697 szBlockName, // key 698 pStart, 699 ulCurSize); 700 pStart = p; 701 ulCurSize = 0; 702 } 703 704 while (iCurBlock < 20) 705 { 706 ULONG ulBlockSize; 707 708 sprintf(szBlockName, "BLOCK%d", iCurBlock++); 709 710 if (PrfQueryProfileSize(hini, 711 pszHandles, 712 szBlockName, 713 &ulBlockSize) 714 && ulBlockSize > 0) 715 // delete block: 716 PrfWriteProfileData(hini, 717 pszHandles, 718 szBlockName, 719 NULL, 0); // delete 720 // WriteProfileData(pszHandles, szBlockName, hini, NULL, 0); 721 } 722 723 return TRUE; 724 } 725 726 /* 727 *@@ DeleteNode: 728 * deletes a NODE in the specified buffer. 729 * 730 *@@added V0.9.5 (2000-08-20) [umoeller] 731 */ 732 733 ULONG DeleteNode(PBYTE pBuffer, PNODE pNode, ULONG ulSize) 734 { 735 ULONG ulDelSize = sizeof (NODE) + pNode->usNameSize; 736 USHORT usID = pNode->usHandle; // pNode->usID; 737 ULONG ulMoveSize; 738 739 if (memcmp(pNode->chName, "NODE", 4)) 740 return ulSize; 741 742 ulMoveSize = (pBuffer + ulSize) - ((PBYTE)pNode + ulDelSize); 743 ulSize -= ulDelSize; 744 745 memmove(pNode, (PBYTE)pNode + ulDelSize, ulMoveSize); 746 747 while ( (PBYTE)pNode < pBuffer + ulSize 748 && !memcmp(pNode->chName, "NODE", 4) 749 && pNode->usParentHandle == usID) 750 ulSize = DeleteNode(pBuffer, pNode, ulSize); 751 752 return ulSize; 753 } 754 755 /* 756 *@@ DeleteDrive: 757 * delete all information about a drive. 758 * in the specified buffer. 759 * 760 *@@added V0.9.5 (2000-08-20) [umoeller] 761 */ 762 763 ULONG DeleteDrive(PBYTE pBuffer, PDRIV pDriv, ULONG ulSize) 764 { 765 ULONG ulDelSize; 766 ULONG ulMoveSize; 767 768 if (memcmp(pDriv->chName, "DRIV", 4)) 769 return ulSize; 770 771 ulDelSize = sizeof (DRIV) + strlen(pDriv->szName); 772 ulMoveSize = (pBuffer + ulSize) - ((PBYTE)pDriv + ulDelSize); 773 ulSize -= ulDelSize; 774 775 memmove(pDriv, (PBYTE)pDriv + ulDelSize, ulMoveSize); 776 return ulSize; 777 } 778 779 780 926 927 -
trunk/src/helpers/xml.c
r97 r106 2434 2434 2435 2435 // create the document node 2436 arc = xmlCreateDomNode(NULL, // no parent 2437 DOMNODE_DOCUMENT, 2438 NULL, 2439 0, 2440 &pDocument); 2441 2442 if (arc == NO_ERROR) 2436 if (!(arc = xmlCreateDomNode(NULL, // no parent 2437 DOMNODE_DOCUMENT, 2438 NULL, 2439 0, 2440 &pDocument))) 2443 2441 { 2444 2442 // store the document in the DOM … … 2553 2551 */ 2554 2552 2555 APIRET xmlParse(PXMLDOM pDom, 2556 const char *pcszBuf, 2557 ULONG cb, 2558 BOOL fIsLast) 2553 APIRET xmlParse(PXMLDOM pDom, // in: DOM created by xmlCreateDOM 2554 const char *pcszBuf, // in: chunk of XML document data (or full document) 2555 ULONG cb, // in: size of that chunk (required) 2556 BOOL fIsLast) // in: set to TRUE if this is the last chunk 2559 2557 { 2560 2558 APIRET arc = NO_ERROR;
Note:
See TracChangeset
for help on using the changeset viewer.