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

Last change on this file since 231 was 229, checked in by umoeller, 23 years ago

Sources as of 1.0.0.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 9.5 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 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(const char *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 APIRET xprfWriteProfileData(PXINI hIni,
187 const char *pcszApp,
188 const char *pcszKey,
189 PVOID pData,
190 ULONG ulDataLen);
191
192 APIRET xprfQueryKeysForApp(PXINI hIni,
193 PCSZ pcszApp,
194 PSZ *ppszKeys);
195
196 /* ******************************************************************
197 *
198 * Copy API Functions
199 *
200 ********************************************************************/
201
202 /*
203 *@@ FN_PRF_PROGRESS:
204 * prototype for a progress callback used with
205 * xprfCopyProfile and xprfSaveINIs.
206 *
207 * Declare your callback like this:
208 + BOOL _Optlink fnProgress(ULONG ulUser,
209 + // in: use param specified with
210 + // xprfCopyProfile and xprfSaveINIs
211 + ULONG ulProgressNow,
212 + // in: current progress
213 + ULONG ulProgressMax)
214 + // in: maximum progress
215 *
216 * If this returns FALSE, processing is aborted.
217 */
218
219 typedef BOOL (_Optlink FN_PRF_PROGRESS)(ULONG, ULONG, ULONG);
220 typedef FN_PRF_PROGRESS *PFN_PRF_PROGRESS;
221
222 APIRET xprfCopyKey(HINI hiniSource,
223 PCSZ pszSourceApp,
224 PCSZ pszKey,
225 PXINI hiniTarget,
226 PCSZ pszTargetApp);
227
228 APIRET xprfCopyKey2(PXINI hiniSource,
229 PCSZ pszSourceApp,
230 PCSZ pszKey,
231 HINI hiniTarget,
232 PCSZ pszTargetApp);
233
234 APIRET xprfCopyApp(HINI hiniSource,
235 PCSZ pszSourceApp,
236 PXINI hiniTarget,
237 PCSZ pszTargetApp,
238 PSZ pszErrorKey);
239
240 APIRET xprfCopyApp2(PXINI hiniSource,
241 PCSZ pszSourceApp,
242 HINI hiniTarget,
243 PCSZ pszTargetApp,
244 PSZ pszErrorKey);
245
246 APIRET xprfCopyProfile(HINI hOld,
247 PCSZ pszNew,
248 PFN_PRF_PROGRESS pfnProgressCallback,
249 ULONG ulUser,
250 ULONG ulCount,
251 ULONG ulMax,
252 PSZ pszFailingApp);
253
254 APIRET xprfSaveINIs(HAB hab,
255 PFN_PRF_PROGRESS pfnProgressCallback,
256 ULONG ulUser,
257 PSZ pszFailingINI,
258 PSZ pszFailingApp,
259 PSZ pszFailingKey);
260#endif
261
262#if __cplusplus
263}
264#endif
265
Note: See TracBrowser for help on using the repository browser.