source: branches/branch-1-0/include/helpers/xprf.h@ 443

Last change on this file since 443 was 372, checked in by pr, 17 years ago

Add missing xprf() functions. Fix broken ones also.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 10.0 KB
Line 
1
2/*
3 *@@sourcefile xprf.h:
4 * header file for xprf.c. See remarks there.
5 *
6 * This file was new with V0.9.5 (?).
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>
13 *@@include #include "helpers\xprf.h"
14 */
15
16/* Copyright (C) 2000-2008 Ulrich M”ller.
17 * This file is part of the "XWorkplace helpers" source package.
18 * This is free software; you can redistribute it and/or modify
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
29extern "C" {
30#endif
31
32#ifndef XPRF_HEADER_INCLUDED
33 #define XPRF_HEADER_INCLUDED
34
35 /* ******************************************************************
36 *
37 * OS/2 INI file layout
38 *
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 /* ******************************************************************
132 *
133 * API Functions
134 *
135 ********************************************************************/
136
137 #ifdef LINKLIST_HEADER_INCLUDED
138
139 #define XINI_MAGIC_BYTES "xpRfMa\x03"
140
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
154 // removed V1.0.0 (2002-09-20) [umoeller]
155 CHAR szFilename[CCHMAXPATH];
156
157 HFILE hFile; // returned by DosProtectOpen
158 // FHLOCK hLock; // lock ID of DosProtectOpen
159 // removed V1.0.0 (2002-09-20) [umoeller]
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
170 APIRET xprfOpenProfile(PCSZ pcszFilename,
171 PXINI *ppxini);
172
173 APIRET xprfCloseProfile(PXINI hIni);
174
175 APIRET xprfQueryProfileSize(PXINI pXIni,
176 PCSZ pszAppName,
177 PCSZ pszKeyName,
178 PULONG pulDataLen);
179
180 APIRET xprfQueryProfileData(PXINI pXIni,
181 PCSZ pszAppName,
182 PCSZ pszKeyName,
183 PVOID pBuffer,
184 PULONG pulBufferMax);
185
186 LONG xprfQueryProfileInt(PXINI pXIni,
187 PCSZ pcszApp,
188 PCSZ pcszKey,
189 LONG lDefault);
190
191 APIRET xprfWriteProfileData(PXINI hIni,
192 PCSZ pcszApp,
193 PCSZ pcszKey,
194 PVOID pData,
195 ULONG ulDataLen);
196
197 APIRET xprfWriteProfileString(PXINI pXIni,
198 PCSZ pcszApp,
199 PCSZ pcszKey,
200 PCSZ pcszString);
201
202 APIRET xprfQueryKeysForApp(PXINI hIni,
203 PCSZ pcszApp,
204 PSZ *ppszKeys);
205
206 PSZ xprfhQueryProfileData(PXINI pXIni,
207 PCSZ pcszApp,
208 PCSZ pcszKey,
209 PULONG pcbBuf);
210
211 /* ******************************************************************
212 *
213 * Copy API Functions
214 *
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,
238 PCSZ pszSourceApp,
239 PCSZ pszKey,
240 PXINI hiniTarget,
241 PCSZ pszTargetApp);
242
243 APIRET xprfCopyKey2(PXINI hiniSource,
244 PCSZ pszSourceApp,
245 PCSZ pszKey,
246 HINI hiniTarget,
247 PCSZ pszTargetApp);
248
249 APIRET xprfCopyApp(HINI hiniSource,
250 PCSZ pszSourceApp,
251 PXINI hiniTarget,
252 PCSZ pszTargetApp,
253 PSZ pszErrorKey);
254
255 APIRET xprfCopyApp2(PXINI hiniSource,
256 PCSZ pszSourceApp,
257 HINI hiniTarget,
258 PCSZ pszTargetApp,
259 PSZ pszErrorKey);
260
261 APIRET xprfCopyProfile(HINI hOld,
262 PCSZ pszNew,
263 PFN_PRF_PROGRESS pfnProgressCallback,
264 ULONG ulUser,
265 ULONG ulCount,
266 ULONG ulMax,
267 PSZ pszFailingApp);
268
269 APIRET xprfSaveINIs(HAB hab,
270 PFN_PRF_PROGRESS pfnProgressCallback,
271 ULONG ulUser,
272 PSZ pszFailingINI,
273 PSZ pszFailingApp,
274 PSZ pszFailingKey);
275#endif
276
277#if __cplusplus
278}
279#endif
280
Note: See TracBrowser for help on using the repository browser.