source: trunk/src/kernel32/profile.cpp@ 17

Last change on this file since 17 was 17, checked in by phaller, 26 years ago

Code cleanup #1 for build, mainly addresses linkage problems

File size: 24.8 KB
Line 
1/* $Id: profile.cpp,v 1.2 1999-05-31 22:08:12 phaller Exp $ */
2
3/*
4 *
5 * Project Odin Software License can be found in LICENSE.TXT
6 *
7 */
8/*
9 * Win32 profile API functions
10 *
11 * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
12 * Copyright 1998 Patrick Haller
13 *
14 */
15#include <os2win.h>
16#include <stdlib.h>
17#include <string.h>
18#include "unicode.h"
19#include "misc.h"
20
21//******************************************************************************
22//******************************************************************************
23UINT WIN32API GetPrivateProfileIntA(LPCSTR arg1, LPCSTR arg2, INT arg3, LPCSTR arg4)
24{
25 dprintf(("KERNEL32: OS2GetPrivateProfileIntA %s, %s, file %s\n", arg1, arg2, arg4));
26 return O32_GetPrivateProfileInt(arg1, arg2, arg3, arg4);
27}
28//******************************************************************************
29//******************************************************************************
30UINT WIN32API GetPrivateProfileIntW(LPCWSTR lpAppName, LPCWSTR lpKeyName,
31 INT nDefault, LPCWSTR lpFileName)
32{
33 char *asciiapp, *asciikey, *asciifile;
34 UINT rc;
35
36 dprintf(("KERNEL32: OS2GetPrivateProfileIntW\n"));
37 asciiapp = UnicodeToAsciiString((LPWSTR)lpAppName);
38 asciikey = UnicodeToAsciiString((LPWSTR)lpKeyName);
39 asciifile = UnicodeToAsciiString((LPWSTR)lpFileName);
40 rc = O32_GetPrivateProfileInt(asciiapp, asciikey, nDefault, asciifile);
41 FreeAsciiString(asciifile);
42 FreeAsciiString(asciikey);
43 FreeAsciiString(asciiapp);
44 return(rc);
45}
46//******************************************************************************
47//******************************************************************************
48UINT WIN32API GetProfileIntA( LPCSTR arg1, LPCSTR arg2, INT arg3)
49{
50 UINT rc;
51
52 rc = O32_GetProfileInt(arg1, arg2, arg3);
53 dprintf(("KERNEL32: OS2GetProfileIntA %s %s returned %d\n", arg1, arg2, rc));
54 return(rc);
55}
56//******************************************************************************
57//******************************************************************************
58UINT WIN32API GetProfileIntW(LPCWSTR lpAppName, LPCWSTR lpKeyName, int nDefault)
59{
60 char *asciiapp, *asciikey;
61 UINT rc;
62
63 dprintf(("KERNEL32: OS2GetProfileIntW\n"));
64 asciiapp = UnicodeToAsciiString((LPWSTR)lpAppName);
65 asciikey = UnicodeToAsciiString((LPWSTR)lpKeyName);
66 rc = O32_GetProfileInt(asciiapp, asciikey, nDefault);
67 FreeAsciiString(asciikey);
68 FreeAsciiString(asciiapp);
69 return(rc);
70}
71//******************************************************************************
72//******************************************************************************
73INT WIN32API GetPrivateProfileStringA(LPCSTR arg1,
74 LPCSTR arg2,
75 LPCSTR arg3,
76 LPSTR arg4,
77 UINT arg5,
78 LPCSTR arg6)
79{
80 dprintf(("KERNEL32: GetPrivateProfileStringA(%s,%s,%s,%08xh,%u,%s)\n",
81 arg1,
82 arg2,
83 arg3,
84 arg4,
85 arg5,
86 arg6));
87
88 return O32_GetPrivateProfileString(arg1,
89 arg2,
90 arg3,
91 arg4,
92 arg5,
93 arg6);
94}
95//******************************************************************************
96//******************************************************************************
97INT WIN32API GetPrivateProfileStringW(LPCWSTR lpAppName, LPCWSTR lpKeyName,
98 LPCWSTR lpDefault, LPWSTR lpReturnedString,
99 UINT nSize, LPCWSTR lpFileName)
100{
101 char *asciiapp, *asciikey, *asciifile, *asciidefault;
102 char *asciistring = (char *)malloc(nSize+1);
103 UINT rc;
104
105 dprintf(("KERNEL32: OS2GetPrivateProfileStringW\n"));
106 asciiapp = UnicodeToAsciiString((LPWSTR)lpAppName);
107 asciikey = UnicodeToAsciiString((LPWSTR)lpKeyName);
108 asciifile = UnicodeToAsciiString((LPWSTR)lpFileName);
109 asciidefault = UnicodeToAsciiString((LPWSTR)lpDefault);
110 rc = O32_GetPrivateProfileString(asciiapp, asciikey, asciidefault, asciistring,
111 nSize, asciifile);
112 if(rc) AsciiToUnicode(asciistring, lpReturnedString);
113 FreeAsciiString(asciidefault);
114 FreeAsciiString(asciifile);
115 FreeAsciiString(asciikey);
116 FreeAsciiString(asciiapp);
117 free(asciistring);
118 return(rc);
119}
120//******************************************************************************
121//******************************************************************************
122INT WIN32API GetProfileStringA( LPCSTR arg1, LPCSTR arg2, LPCSTR arg3, LPSTR arg4, UINT arg5)
123{
124 dprintf(("KERNEL32: GetProfileString %s\n", arg1));
125 return O32_GetProfileString(arg1, arg2, arg3, arg4, arg5);
126}
127//******************************************************************************
128//******************************************************************************
129INT WIN32API GetProfileStringW(LPCWSTR lpAppName, LPCWSTR lpKeyName,
130 LPCWSTR lpDefault, LPWSTR lpReturnedString,
131 UINT nSize)
132{
133 char *asciiapp, *asciikey, *asciifile, *asciidefault;
134 char *asciistring = (char *)malloc(nSize+1);
135 UINT rc;
136
137 dprintf(("KERNEL32: OS2GetProfileStringW\n"));
138 asciiapp = UnicodeToAsciiString((LPWSTR)lpAppName);
139 asciikey = UnicodeToAsciiString((LPWSTR)lpKeyName);
140 asciidefault = UnicodeToAsciiString((LPWSTR)lpDefault);
141 rc = O32_GetProfileString(asciiapp, asciikey, asciidefault, asciistring, nSize);
142 if(rc) AsciiToUnicode(asciistring, lpReturnedString);
143 FreeAsciiString(asciidefault);
144 FreeAsciiString(asciikey);
145 FreeAsciiString(asciiapp);
146 free(asciistring);
147 return(rc);
148}
149//******************************************************************************
150//******************************************************************************
151BOOL WIN32API WriteProfileStringA(LPCSTR arg1, LPCSTR arg2, LPCSTR arg3)
152{
153 dprintf(("KERNEL32: WriteProfileString %s key %s value %s\n", arg1, arg2, arg3));
154 return O32_WriteProfileString(arg1, arg2, arg3);
155}
156//******************************************************************************
157//******************************************************************************
158BOOL WIN32API WriteProfileStringW(LPCWSTR lpAppName, LPCWSTR lpKeyName,
159 LPCWSTR lpString)
160{
161 char *asciiapp, *asciikey, *asciistring;
162 UINT rc;
163
164 dprintf(("KERNEL32: OS2WriteProfileStringW\n"));
165 asciiapp = UnicodeToAsciiString((LPWSTR)lpAppName);
166 asciikey = UnicodeToAsciiString((LPWSTR)lpKeyName);
167 asciistring = UnicodeToAsciiString((LPWSTR)lpString);
168 rc = O32_WriteProfileString(asciiapp, asciikey, asciistring);
169 FreeAsciiString(asciistring);
170 FreeAsciiString(asciikey);
171 FreeAsciiString(asciiapp);
172 return(rc);
173}
174//******************************************************************************
175//******************************************************************************
176BOOL WIN32API WritePrivateProfileStringA( LPCSTR arg1, LPCSTR arg2, LPCSTR arg3, LPCSTR arg4)
177{
178 dprintf(("KERNEL32: WritePrivateProfileString\n"));
179 return O32_WritePrivateProfileString(arg1, arg2, arg3, arg4);
180}
181//******************************************************************************
182//******************************************************************************
183BOOL WIN32API WritePrivateProfileStringW(LPCWSTR lpAppName, LPCWSTR lpKeyName,
184 LPCWSTR lpString, LPCWSTR lpFileName)
185{
186 char *asciiapp, *asciikey, *asciifile, *asciistring;
187 UINT rc;
188
189 dprintf(("KERNEL32: OS2WritePrivateProfileStringW\n"));
190 asciiapp = UnicodeToAsciiString((LPWSTR)lpAppName);
191 asciikey = UnicodeToAsciiString((LPWSTR)lpKeyName);
192 asciifile = UnicodeToAsciiString((LPWSTR)lpFileName);
193 asciistring = UnicodeToAsciiString((LPWSTR)lpString);
194 rc = O32_WritePrivateProfileString(asciiapp, asciikey, asciistring, asciifile);
195 FreeAsciiString(asciistring);
196 FreeAsciiString(asciifile);
197 FreeAsciiString(asciikey);
198 FreeAsciiString(asciiapp);
199 return(rc);
200}
201//******************************************************************************
202//******************************************************************************
203INT WIN32API GetProfileSectionA(LPCSTR lpszSection, LPSTR lpszReturnBuffer,
204 DWORD cchBuffer)
205{
206 dprintf(("KERNEL32: OS2GetProfileSectionA %s, not implemented\n", lpszSection));
207 return(0);
208}
209//******************************************************************************
210INT WIN32API GetProfileSectionW(LPCWSTR lpszSection,
211 LPWSTR lpszReturnBuffer,
212 DWORD cchBuffer)
213{
214 dprintf(("KERNEL32: OS2GetProfileSectionW %s, not implemented\n", lpszSection));
215 return(0);
216}
217
218INT WIN32API GetPrivateProfileSectionA(
219 LPCSTR lpszSection, /* address of section name */
220 LPSTR lpszReturnBuffer,/* address of return buffer */
221 DWORD cchBuffer, /* size of return buffer */
222 LPCSTR lpszFile) /* address of initialization filename */
223
224
225 /* The GetPrivateProfileSection function retrieves all of the keys
226 * and values for the specified section from the given initialization
227 * file. This function is provided for compatibility with 16-bit
228 * applications written for Windows. New applications should store
229 * initialization information in the registry.
230 */
231{
232 dprintf(("GetPrivateProfileSection(%s, %s, %d) - not implemented\n",
233 lpszFile, lpszSection, cchBuffer));
234 return FALSE; // return error
235}
236
237
238INT WIN32API GetPrivateProfileSectionW(
239 LPCWSTR lpszSection, /* address of section name */
240 LPWSTR lpszReturnBuffer,/* address of return buffer */
241 DWORD cchBuffer, /* size of return buffer */
242 LPCWSTR lpszFile) /* address of initialization filename */
243
244
245 /* The GetPrivateProfileSection function retrieves all of the keys
246 * and values for the specified section from the given initialization
247 * file. This function is provided for compatibility with 16-bit
248 * applications written for Windows. New applications should store
249 * initialization information in the registry.
250 */
251{
252 dprintf(("GetPrivateProfileSectionW(%s, %s, %d) - not implemented\n",
253 lpszFile, lpszSection, cchBuffer));
254 return FALSE; // return error
255}
256/*****************************************************************************
257 * Name : BOOL WriteProfileSectionA
258 * Purpose : The WriteProfileSection function replaces the contents of the
259 * specified section in the WIN.INI file with the specified keys and values.
260 * This function is provided for compatibility with 16-bit Windows
261 * applications. Win32-based applications should store initialization
262 * information in the registry.
263 * Parameters: LPCTSTR lpszSection address of string with section name
264 * LPCTSTR lpszKeysAndValues address of string with data
265 * Variables :
266 * Result : TRUE / FALSE
267 * Remark :
268 * Status : UNTESTED STUB
269 *
270 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
271 *****************************************************************************/
272
273BOOL WIN32API WriteProfileSectionA(LPCTSTR lpszSection,
274 LPCTSTR lpszKeysAndValues)
275{
276 dprintf(("KERNEL32: WriteProfileSectionA(%s,%s,%s) not implemented.\n",
277 lpszSection,
278 lpszKeysAndValues));
279
280 return (FALSE);
281}
282
283
284/*****************************************************************************
285 * Name : BOOL WriteProfileSectionW
286 * Purpose : The WriteProfileSection function replaces the contents of the
287 * specified section in the WIN.INI file with the specified keys and values.
288 * This function is provided for compatibility with 16-bit Windows
289 * applications. Win32-based applications should store initialization
290 * information in the registry.
291 * Parameters: LPCWSTR lpszSection address of string with section name
292 * LPCWSTR lpszKeysAndValues address of string with data
293 * Variables :
294 * Result : TRUE / FALSE
295 * Remark :
296 * Status : UNTESTED STUB
297 *
298 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
299 *****************************************************************************/
300
301BOOL WIN32API WriteProfileSectionW(LPCWSTR lpszSection,
302 LPCWSTR lpszKeysAndValues)
303{
304 dprintf(("KERNEL32: WriteProfileSectionW(%s,%s,%s) not implemented.\n",
305 lpszSection,
306 lpszKeysAndValues));
307
308 return (FALSE);
309}
310/*****************************************************************************
311 * Name : BOOL GetPrivateProfileStructA
312 * Purpose : The GetPrivateProfileStructA function retrieves the data associated
313 * with the specified key in the given section of an initialization
314 * file. As it retrieves the data, the function calculates a checksum
315 * and compares it with the checksum calculated by the WritePrivateProfileStruct
316 * function when the data was added to the file. This function is provided
317 * for compatibility with 16-bit Windows-based applications. Win32-based
318 * applications should store initialization information in the registry.
319 * Parameters: LPCTSTR lpszSection address of section name
320 * LPCTSTR lpszKey address of key name
321 * LPVOID lpStruct address of return buffer
322 * UINT uSizeStruct size of return buffer
323 * LPCTSTR szFile address of initialization filename
324 * Variables :
325 * Result : TRUE / FALSE
326 * Remark :
327 * Status : UNTESTED STUB
328 *
329 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
330 *****************************************************************************/
331
332BOOL WIN32API GetPrivateProfileStructA(LPCTSTR lpszSection,
333 LPCTSTR lpszKey,
334 LPVOID lpStruct,
335 UINT uSizeStruct,
336 LPCTSTR szFile)
337{
338 dprintf(("KERNEL32: GetPrivateProfileStructA(%s,%s,%08xh,%08xh,%s) not implemented.\n",
339 lpszSection,
340 lpszKey,
341 lpStruct,
342 uSizeStruct,
343 szFile));
344
345 return FALSE;
346}
347
348
349/*****************************************************************************
350 * Name : BOOL GetPrivateProfileStructW
351 * Purpose : The GetPrivateProfileStructW function retrieves the data associated
352 * with the specified key in the given section of an initialization
353 * file. As it retrieves the data, the function calculates a checksum
354 * and compares it with the checksum calculated by the WritePrivateProfileStruct
355 * function when the data was added to the file. This function is provided
356 * for compatibility with 16-bit Windows-based applications. Win32-based
357 * applications should store initialization information in the registry.
358 * Parameters: LPCWSTR lpszSection address of section name
359 * LPCWSTR lpszKey address of key name
360 * LPVOID lpStruct address of return buffer
361 * UINT uSizeStruct size of return buffer
362 * LPCWSTR szFile address of initialization filename
363 * Variables :
364 * Result : TRUE / FALSE
365 * Remark :
366 * Status : UNTESTED STUB
367 *
368 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
369 *****************************************************************************/
370
371BOOL WIN32API GetPrivateProfileStructW(LPCWSTR lpszSection,
372 LPCWSTR lpszKey,
373 LPVOID lpStruct,
374 UINT uSizeStruct,
375 LPCWSTR szFile)
376{
377 dprintf(("KERNEL32: GetPrivateProfileStructW(%s,%s,%08xh,%08xh,%s) not implemented.\n",
378 lpszSection,
379 lpszKey,
380 lpStruct,
381 uSizeStruct,
382 szFile));
383
384 return FALSE;
385}
386
387
388/*****************************************************************************
389 * Name : BOOL GetPrivateProfileSectionNamesA
390 * Purpose : The GetPrivateProfileSectionNames function retrieves the names
391 * of all sections in an initialization file. This function is
392 * provided for compatibility with 16-bit Windows-based applications.
393 * Win32-based applications should store initialization information
394 * in the registry.
395 * Parameters: LPTSTR lpszReturnBuffer address of return buffer
396 * DWORD nSize size of return buffer
397 * LPCTSTR lpFileName address of initialization filename
398 * Variables :
399 * Result : TRUE / FALSE
400 * Remark :
401 * Status : UNTESTED STUB
402 *
403 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
404 *****************************************************************************/
405
406DWORD WIN32API GetPrivateProfileSectionNamesA(LPTSTR lpszReturnBuffer,
407 DWORD nSize,
408 LPCTSTR lpFileName)
409{
410 dprintf(("KERNEL32: GetPrivateProfileSectionNamesA(%08xh,%08xh,%s) not implemented.\n",
411 lpszReturnBuffer,
412 nSize,
413 lpFileName));
414
415 return FALSE;
416}
417
418
419/*****************************************************************************
420 * Name : BOOL GetPrivateProfileSectionNamesW
421 * Purpose : The GetPrivateProfileSectionNames function retrieves the names
422 * of all sections in an initialization file. This function is
423 * provided for compatibility with 16-bit Windows-based applications.
424 * Win32-based applications should store initialization information
425 * in the registry.
426 * Parameters: LPWSTR lpszReturnBuffer address of return buffer
427 * DWORD nSize size of return buffer
428 * LPCTSTR lpFileName address of initialization filename
429 * Variables :
430 * Result : TRUE / FALSE
431 * Remark :
432 * Status : UNTESTED STUB
433 *
434 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
435 *****************************************************************************/
436
437DWORD WIN32API GetPrivateProfileSectionNamesW(LPWSTR lpszReturnBuffer,
438 DWORD nSize,
439 LPCWSTR lpFileName)
440{
441 dprintf(("KERNEL32: GetPrivateProfileSectionNamesW(%08xh,%08xh,%s) not implemented.\n",
442 lpszReturnBuffer,
443 nSize,
444 lpFileName));
445
446 return FALSE;
447}
448/*****************************************************************************
449 * Name : BOOL WritePrivateProfileSectionA
450 * Purpose : The WritePrivateProfileSection function replaces the keys and
451 * values under the specified section in an initialization file.
452 * This function is provided for compatibility with 16-bit
453 * Windows-based applications. Win32-based applications should
454 * store initialization information in the registry.
455 * Parameters: LPCTSTR lpszSection address of string with section name
456 * LPCTSTR lpszKeysAndValues address of string with data
457 * LPCTSTR lpszFile address of string with filename
458 * Variables :
459 * Result : TRUE / FALSE
460 * Remark :
461 * Status : UNTESTED STUB
462 *
463 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
464 *****************************************************************************/
465
466BOOL WIN32API WritePrivateProfileSectionA(LPCTSTR lpszSection,
467 LPCTSTR lpszKeysAndValues,
468 LPCTSTR lpszFile)
469{
470 dprintf(("KERNEL32: WritePrivateProfileSectionA(%s,%s,%s) not implemented.\n",
471 lpszSection,
472 lpszKeysAndValues,
473 lpszFile));
474
475 return (FALSE);
476}
477
478
479/*****************************************************************************
480 * Name : BOOL WritePrivateProfileSectionW
481 * Purpose : The WritePrivateProfileSection function replaces the keys and
482 * values under the specified section in an initialization file.
483 * This function is provided for compatibility with 16-bit
484 * Windows-based applications. Win32-based applications should
485 * store initialization information in the registry.
486 * Parameters: LPCWSTR lpszSection address of string with section name
487 * LPCWSTR lpszKeysAndValues address of string with data
488 * LPCWSTR lpszFile address of string with filename
489 * Variables :
490 * Result : TRUE / FALSE
491 * Remark :
492 * Status : UNTESTED STUB
493 *
494 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
495 *****************************************************************************/
496
497BOOL WIN32API WritePrivateProfileSectionW(LPCWSTR lpszSection,
498 LPCWSTR lpszKeysAndValues,
499 LPCWSTR lpszFile)
500{
501 dprintf(("KERNEL32: WritePrivateProfileSectionW(%s,%s,%s) not implemented.\n",
502 lpszSection,
503 lpszKeysAndValues,
504 lpszFile));
505
506 return (FALSE);
507}
508
509
510/*****************************************************************************
511 * Name : BOOL WritePrivateProfileStructA
512 * Purpose : The WritePrivateProfileStruct function copies data into the
513 * specified key in the given section of an initialization file.
514 * As it copies the data, the function calculates a checksum and
515 * appends it to the end of the data. The GetPrivateProfileStruct
516 * function uses the checksum to ensure the integrity of the data.
517 * This function is provided for compatibility with 16-bit
518 * Windows-based applications. Win32-based applications should store
519 * initialization information in the registry.
520 * Parameters: LPCTSTR lpszSection address of section name
521 * LPCTSTR lpszKey address of key name
522 * LPVOID lpvStruct address of buffer that contains data to add
523 * UINT uSizeStruct size, in bytes, of the buffer
524 * LPCTSTR lpszFile address of initialization filename
525 * Variables :
526 * Result : TRUE / FALSE
527 * Remark :
528 * Status : UNTESTED STUB
529 *
530 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
531 *****************************************************************************/
532
533BOOL WIN32API WritePrivateProfileStructA(LPCTSTR lpszSection,
534 LPCTSTR lpszKey,
535 LPVOID lpvStruct,
536 UINT uSizeStruct,
537 LPCTSTR lpszFile)
538{
539 dprintf(("KERNEL32: WritePrivateProfileStructA(%s,%s,%08xh,%u,%s) not implemented.\n",
540 lpszSection,
541 lpszKey,
542 lpvStruct,
543 uSizeStruct,
544 lpszFile));
545
546 return (FALSE);
547}
548
549
550/*****************************************************************************
551 * Name : BOOL WritePrivateProfileStructW
552 * Purpose : The WritePrivateProfileStruct function copies data into the
553 * specified key in the given section of an initialization file.
554 * As it copies the data, the function calculates a checksum and
555 * appends it to the end of the data. The GetPrivateProfileStruct
556 * function uses the checksum to ensure the integrity of the data.
557 * This function is provided for compatibility with 16-bit
558 * Windows-based applications. Win32-based applications should store
559 * initialization information in the registry.
560 * Parameters: LPCWSTR lpszSection address of section name
561 * LPCWSTR lpszKey address of key name
562 * LPVOID lpvStruct address of buffer that contains data to add
563 * UINT uSizeStruct size, in bytes, of the buffer
564 * LPCWSTR lpszFile address of initialization filename
565 * Variables :
566 * Result : TRUE / FALSE
567 * Remark :
568 * Status : UNTESTED STUB
569 *
570 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
571 *****************************************************************************/
572
573BOOL WIN32API WritePrivateProfileStructW(LPCWSTR lpszSection,
574 LPCWSTR lpszKey,
575 LPVOID lpvStruct,
576 UINT uSizeStruct,
577 LPCWSTR lpszFile)
578{
579 dprintf(("KERNEL32: WritePrivateProfileStructW(%s,%s,%08xh,%u,%s) not implemented.\n",
580 lpszSection,
581 lpszKey,
582 lpvStruct,
583 uSizeStruct,
584 lpszFile));
585
586 return (FALSE);
587}
Note: See TracBrowser for help on using the repository browser.