[7] | 1 |
|
---|
| 2 | /*
|
---|
| 3 | *@@sourcefile xprf.h:
|
---|
| 4 | * header file for xprf.c. See remarks there.
|
---|
| 5 | *
|
---|
[64] | 6 | * This file was new with V0.9.5 (?).
|
---|
[7] | 7 | *
|
---|
| 8 | * Note: Version numbering in this file relates to XWorkplace version
|
---|
| 9 | * numbering.
|
---|
| 10 | *
|
---|
| 11 | *@@include #define INCL_WINSHELLDATA
|
---|
| 12 | *@@include #include <os2.h>
|
---|
[113] | 13 | *@@include #include "helpers\xprf.h"
|
---|
[7] | 14 | */
|
---|
| 15 |
|
---|
[372] | 16 | /* Copyright (C) 2000-2008 Ulrich Mller.
|
---|
[14] | 17 | * This file is part of the "XWorkplace helpers" source package.
|
---|
| 18 | * This is free software; you can redistribute it and/or modify
|
---|
[7] | 19 | * it under the terms of the GNU General Public License as published
|
---|
| 20 | * by the Free Software Foundation, in version 2 as it comes in the
|
---|
| 21 | * "COPYING" file of the XWorkplace main distribution.
|
---|
| 22 | * This program is distributed in the hope that it will be useful,
|
---|
| 23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 25 | * GNU General Public License for more details.
|
---|
| 26 | */
|
---|
| 27 |
|
---|
| 28 | #if __cplusplus
|
---|
| 29 | extern "C" {
|
---|
| 30 | #endif
|
---|
| 31 |
|
---|
| 32 | #ifndef XPRF_HEADER_INCLUDED
|
---|
| 33 | #define XPRF_HEADER_INCLUDED
|
---|
| 34 |
|
---|
| 35 | /* ******************************************************************
|
---|
[14] | 36 | *
|
---|
| 37 | * OS/2 INI file layout
|
---|
| 38 | *
|
---|
[7] | 39 | ********************************************************************/
|
---|
| 40 |
|
---|
| 41 | #pragma pack(1)
|
---|
| 42 |
|
---|
| 43 | /*
|
---|
| 44 | *@@ INIFILE_HEADER:
|
---|
| 45 | * header of OS/2 INI file. This is
|
---|
| 46 | * what an OS/2 .INI file starts with
|
---|
| 47 | * at byte 0.
|
---|
| 48 | *
|
---|
| 49 | * An OS/2 INI file has the following layout:
|
---|
| 50 | *
|
---|
| 51 | * -- INIFILE_HEADER
|
---|
| 52 | * -- first INIFILE_APP, if any
|
---|
| 53 | * -- name of first application (zero-terminated),
|
---|
| 54 | * of which the first INIFILE_APP.offAppName
|
---|
| 55 | * has the offset
|
---|
| 56 | * -- first INIFILE_KEY of first app
|
---|
| 57 | * -- name of first key (zero-terminated),
|
---|
| 58 | * of which the first INIFILE_KEY.offKeyName
|
---|
| 59 | * has the offset
|
---|
| 60 | * -- data block of first key, of which the first
|
---|
| 61 | * INIFILE_KEY.offKeyData has the offset;
|
---|
| 62 | * the length is in INIFILE_KEY.lenKeyData
|
---|
| 63 | *
|
---|
| 64 | * -- subsequent INIFILE_KEY's, names, data, if any
|
---|
| 65 | *
|
---|
| 66 | * -- subsequent INIFILE_APP's, if any
|
---|
| 67 | * ...
|
---|
| 68 | *
|
---|
| 69 | *@@added V0.9.5 (2000-08-10) [umoeller]
|
---|
| 70 | */
|
---|
| 71 |
|
---|
| 72 | typedef struct _INIFILE_HEADER
|
---|
| 73 | {
|
---|
| 74 | ULONG magic; // Magic Footprint, Always $FFFFFFFF (?)
|
---|
| 75 | ULONG offFirstApp; // Offset of First Application in File
|
---|
| 76 | ULONG lenFile; // Length of INI File
|
---|
| 77 | ULONG filler1; // Always $00000000 (?)
|
---|
| 78 | ULONG filler2; // Always $00000000 (?)
|
---|
| 79 | } INIFILE_HEADER, *PINIFILE_HEADER;
|
---|
| 80 |
|
---|
| 81 | /*
|
---|
| 82 | *@@ INIFILE_APP:
|
---|
| 83 | * application entry in OS/2 INI file.
|
---|
| 84 | * The first application comes right after
|
---|
| 85 | * INIFILE_HEADER. After INIFILE_APP, the
|
---|
| 86 | * Prf* functions store the app name and
|
---|
| 87 | * the keys which belong to this application
|
---|
| 88 | * (INIFILE_KEY).
|
---|
| 89 | *
|
---|
| 90 | *@@added V0.9.5 (2000-08-10) [umoeller]
|
---|
| 91 | */
|
---|
| 92 |
|
---|
| 93 | typedef struct _INIFILE_APP
|
---|
| 94 | {
|
---|
| 95 | ULONG offNextApp; // Offset of Next Application in File
|
---|
| 96 | // (0 No More Apps)
|
---|
| 97 | ULONG offFirstKeyInApp; // Offset of Application's First Key Entry
|
---|
| 98 | ULONG filler1; // Always $00000000 (?)
|
---|
| 99 | USHORT lenAppName; // Length of Application Name
|
---|
| 100 | // (incl. terminating \0)
|
---|
| 101 | USHORT _lenAppName; // Always same as above (?)
|
---|
| 102 | ULONG offAppName; // Offset of ASCIIZ Application Name
|
---|
| 103 | } INIFILE_APP, *PINIFILE_APP;
|
---|
| 104 |
|
---|
| 105 | /*
|
---|
| 106 | *@@ INIFILE_KEY:
|
---|
| 107 | * key entry in OS/2 INI file.
|
---|
| 108 | * The first key in an application comes right after
|
---|
| 109 | * its INIFILE_APP. After INIFILE_KEY, the Prf*
|
---|
| 110 | * functions store the key name and finally the
|
---|
| 111 | * data for that key.
|
---|
| 112 | *
|
---|
| 113 | *@@added V0.9.5 (2000-08-10) [umoeller]
|
---|
| 114 | */
|
---|
| 115 |
|
---|
| 116 | typedef struct _INIFILE_KEY
|
---|
| 117 | {
|
---|
| 118 | ULONG offNextKeyInApp; // Offset of Next Key in Application
|
---|
| 119 | // (0 = No More Keys)
|
---|
| 120 | ULONG filler1; // Always $00000000 (?)
|
---|
| 121 | USHORT lenKeyName; // Length of Key Name (incl. terminating \0)
|
---|
| 122 | USHORT _lenKeyName; // Always same as above (?)
|
---|
| 123 | ULONG offKeyName; // Offset of ASCIIZ Key Name
|
---|
| 124 | USHORT lenKeyData; // Length of Key Data
|
---|
| 125 | USHORT _lenKeyData; // Always same as above (?)
|
---|
| 126 | ULONG offKeyData; // Offset of Key Data (ASCII(Z) or Binary)
|
---|
| 127 | } INIFILE_KEY, *PINIFILE_KEY;
|
---|
| 128 |
|
---|
| 129 | #pragma pack()
|
---|
| 130 |
|
---|
| 131 | /* ******************************************************************
|
---|
[14] | 132 | *
|
---|
| 133 | * API Functions
|
---|
| 134 | *
|
---|
[7] | 135 | ********************************************************************/
|
---|
| 136 |
|
---|
[229] | 137 | #ifdef LINKLIST_HEADER_INCLUDED
|
---|
[7] | 138 |
|
---|
[229] | 139 | #define XINI_MAGIC_BYTES "xpRfMa\x03"
|
---|
| 140 |
|
---|
[7] | 141 | /*
|
---|
| 142 | *@@ XINI:
|
---|
| 143 | * open INI file. Returned by xprfOpenProfile
|
---|
| 144 | * and is used in place of HINI by the replacement
|
---|
| 145 | * INI functions.
|
---|
| 146 | *
|
---|
| 147 | * Do not modify any data in here.
|
---|
| 148 | */
|
---|
| 149 |
|
---|
| 150 | typedef struct _XINI
|
---|
| 151 | {
|
---|
| 152 | CHAR acMagic[sizeof(XINI_MAGIC_BYTES)];
|
---|
| 153 | // magic bytes for security
|
---|
[229] | 154 | // removed V1.0.0 (2002-09-20) [umoeller]
|
---|
[7] | 155 | CHAR szFilename[CCHMAXPATH];
|
---|
[229] | 156 |
|
---|
[7] | 157 | HFILE hFile; // returned by DosProtectOpen
|
---|
[229] | 158 | // FHLOCK hLock; // lock ID of DosProtectOpen
|
---|
| 159 | // removed V1.0.0 (2002-09-20) [umoeller]
|
---|
[7] | 160 | BOOL fDirty; // TRUE if changed and needs to be flushed
|
---|
| 161 | // on close
|
---|
| 162 |
|
---|
| 163 | // applications list
|
---|
| 164 | LINKLIST llApps; // contains PXINIAPPDATA items
|
---|
| 165 | } XINI, *PXINI;
|
---|
| 166 | #else
|
---|
| 167 | typedef void* PXINI;
|
---|
| 168 | #endif
|
---|
| 169 |
|
---|
[372] | 170 | APIRET xprfOpenProfile(PCSZ pcszFilename,
|
---|
[7] | 171 | PXINI *ppxini);
|
---|
| 172 |
|
---|
[229] | 173 | APIRET xprfCloseProfile(PXINI hIni);
|
---|
[7] | 174 |
|
---|
[229] | 175 | APIRET xprfQueryProfileSize(PXINI pXIni,
|
---|
| 176 | PCSZ pszAppName,
|
---|
| 177 | PCSZ pszKeyName,
|
---|
| 178 | PULONG pulDataLen);
|
---|
[7] | 179 |
|
---|
[229] | 180 | APIRET xprfQueryProfileData(PXINI pXIni,
|
---|
| 181 | PCSZ pszAppName,
|
---|
| 182 | PCSZ pszKeyName,
|
---|
| 183 | PVOID pBuffer,
|
---|
| 184 | PULONG pulBufferMax);
|
---|
[7] | 185 |
|
---|
[372] | 186 | LONG xprfQueryProfileInt(PXINI pXIni,
|
---|
| 187 | PCSZ pcszApp,
|
---|
| 188 | PCSZ pcszKey,
|
---|
| 189 | LONG lDefault);
|
---|
| 190 |
|
---|
[229] | 191 | APIRET xprfWriteProfileData(PXINI hIni,
|
---|
[372] | 192 | PCSZ pcszApp,
|
---|
| 193 | PCSZ pcszKey,
|
---|
[229] | 194 | PVOID pData,
|
---|
| 195 | ULONG ulDataLen);
|
---|
| 196 |
|
---|
[372] | 197 | APIRET xprfWriteProfileString(PXINI pXIni,
|
---|
| 198 | PCSZ pcszApp,
|
---|
| 199 | PCSZ pcszKey,
|
---|
| 200 | PCSZ pcszString);
|
---|
| 201 |
|
---|
[229] | 202 | APIRET xprfQueryKeysForApp(PXINI hIni,
|
---|
| 203 | PCSZ pcszApp,
|
---|
| 204 | PSZ *ppszKeys);
|
---|
| 205 |
|
---|
[372] | 206 | PSZ xprfhQueryProfileData(PXINI pXIni,
|
---|
| 207 | PCSZ pcszApp,
|
---|
| 208 | PCSZ pcszKey,
|
---|
| 209 | PULONG pcbBuf);
|
---|
| 210 |
|
---|
[7] | 211 | /* ******************************************************************
|
---|
[14] | 212 | *
|
---|
| 213 | * Copy API Functions
|
---|
| 214 | *
|
---|
[7] | 215 | ********************************************************************/
|
---|
| 216 |
|
---|
| 217 | /*
|
---|
| 218 | *@@ FN_PRF_PROGRESS:
|
---|
| 219 | * prototype for a progress callback used with
|
---|
| 220 | * xprfCopyProfile and xprfSaveINIs.
|
---|
| 221 | *
|
---|
| 222 | * Declare your callback like this:
|
---|
| 223 | + BOOL _Optlink fnProgress(ULONG ulUser,
|
---|
| 224 | + // in: use param specified with
|
---|
| 225 | + // xprfCopyProfile and xprfSaveINIs
|
---|
| 226 | + ULONG ulProgressNow,
|
---|
| 227 | + // in: current progress
|
---|
| 228 | + ULONG ulProgressMax)
|
---|
| 229 | + // in: maximum progress
|
---|
| 230 | *
|
---|
| 231 | * If this returns FALSE, processing is aborted.
|
---|
| 232 | */
|
---|
| 233 |
|
---|
| 234 | typedef BOOL (_Optlink FN_PRF_PROGRESS)(ULONG, ULONG, ULONG);
|
---|
| 235 | typedef FN_PRF_PROGRESS *PFN_PRF_PROGRESS;
|
---|
| 236 |
|
---|
| 237 | APIRET xprfCopyKey(HINI hiniSource,
|
---|
[229] | 238 | PCSZ pszSourceApp,
|
---|
| 239 | PCSZ pszKey,
|
---|
[7] | 240 | PXINI hiniTarget,
|
---|
[229] | 241 | PCSZ pszTargetApp);
|
---|
[7] | 242 |
|
---|
[229] | 243 | APIRET xprfCopyKey2(PXINI hiniSource,
|
---|
| 244 | PCSZ pszSourceApp,
|
---|
| 245 | PCSZ pszKey,
|
---|
| 246 | HINI hiniTarget,
|
---|
| 247 | PCSZ pszTargetApp);
|
---|
| 248 |
|
---|
[7] | 249 | APIRET xprfCopyApp(HINI hiniSource,
|
---|
[229] | 250 | PCSZ pszSourceApp,
|
---|
[7] | 251 | PXINI hiniTarget,
|
---|
[229] | 252 | PCSZ pszTargetApp,
|
---|
[7] | 253 | PSZ pszErrorKey);
|
---|
| 254 |
|
---|
[229] | 255 | APIRET xprfCopyApp2(PXINI hiniSource,
|
---|
| 256 | PCSZ pszSourceApp,
|
---|
| 257 | HINI hiniTarget,
|
---|
| 258 | PCSZ pszTargetApp,
|
---|
| 259 | PSZ pszErrorKey);
|
---|
| 260 |
|
---|
[7] | 261 | APIRET xprfCopyProfile(HINI hOld,
|
---|
[229] | 262 | PCSZ pszNew,
|
---|
[7] | 263 | PFN_PRF_PROGRESS pfnProgressCallback,
|
---|
| 264 | ULONG ulUser,
|
---|
| 265 | ULONG ulCount,
|
---|
[229] | 266 | ULONG ulMax,
|
---|
| 267 | PSZ pszFailingApp);
|
---|
[7] | 268 |
|
---|
| 269 | APIRET xprfSaveINIs(HAB hab,
|
---|
| 270 | PFN_PRF_PROGRESS pfnProgressCallback,
|
---|
[229] | 271 | ULONG ulUser,
|
---|
| 272 | PSZ pszFailingINI,
|
---|
| 273 | PSZ pszFailingApp,
|
---|
| 274 | PSZ pszFailingKey);
|
---|
[7] | 275 | #endif
|
---|
| 276 |
|
---|
| 277 | #if __cplusplus
|
---|
| 278 | }
|
---|
| 279 | #endif
|
---|
| 280 |
|
---|