4 * Copyright 1993 Miguel de Icaza
5 * Copyright 1996 Alexandre Julliard
18 typedef struct tagPROFILEKEY
22 struct tagPROFILEKEY *next;
25 typedef struct tagPROFILESECTION
28 struct tagPROFILEKEY *key;
29 struct tagPROFILESECTION *next;
36 PROFILESECTION *section;
43 /* Cached profile file */
44 static PROFILE CurProfile = { FALSE, NULL, NULL };
46 /* wine.ini profile content */
47 static PROFILESECTION *WineProfile;
49 #define PROFILE_MAX_LINE_LEN 1024
51 /* Wine profile name in $HOME directory; must begin with slash */
52 static const char PROFILE_WineIniName[] = "/.winerc";
54 /* Check for comments in profile */
55 #define IS_ENTRY_COMMENT(str) ((str)[0] == ';')
57 #define WINE_INI_GLOBAL ETCDIR "/wine.conf"
59 static LPCWSTR wininiW = NULL;
61 /***********************************************************************
64 * Copy the content of an entry into a buffer, removing quotes, and possibly
65 * translating environment variables.
67 static void PROFILE_CopyEntry( char *buffer, const char *value, int len,
73 if ((*value == '\'') || (*value == '\"'))
75 if (value[1] && (value[strlen(value)-1] == *value)) quote = *value++;
80 lstrcpyn32A( buffer, value, len );
81 if (quote && (len >= strlen(value))) buffer[strlen(buffer)-1] = '\0';
85 for (p = value; (*p && (len > 1)); *buffer++ = *p++, len-- )
87 if ((*p == '$') && (p[1] == '{'))
91 const char *p2 = strchr( p, '}' );
92 if (!p2) continue; /* ignore it */
93 lstrcpyn32A(env_val, p + 2, MIN( sizeof(env_val), (int)(p2-p)-1 ));
94 if ((env_p = getenv( env_val )) != NULL)
96 lstrcpyn32A( buffer, env_p, len );
97 buffer += strlen( buffer );
98 len -= strlen( buffer );
107 /***********************************************************************
110 * Save a profile tree to a file.
112 static void PROFILE_Save( FILE *file, PROFILESECTION *section )
116 for ( ; section; section = section->next)
118 if (section->name) fprintf( file, "\r\n[%s]\r\n", section->name );
119 for (key = section->key; key; key = key->next)
121 fprintf( file, "%s", key->name );
122 if (key->value) fprintf( file, "=%s", key->value );
123 fprintf( file, "\r\n" );
129 /***********************************************************************
132 * Free a profile tree.
134 static void PROFILE_Free( PROFILESECTION *section )
136 PROFILESECTION *next_section;
137 PROFILEKEY *key, *next_key;
139 for ( ; section; section = next_section)
141 if (section->name) HeapFree( SystemHeap, 0, section->name );
142 for (key = section->key; key; key = next_key)
144 next_key = key->next;
145 if (key->name) HeapFree( SystemHeap, 0, key->name );
146 if (key->value) HeapFree( SystemHeap, 0, key->value );
147 HeapFree( SystemHeap, 0, key );
149 next_section = section->next;
150 HeapFree( SystemHeap, 0, section );
155 /***********************************************************************
158 * Load a profile tree from a file.
160 static PROFILESECTION *PROFILE_Load( FILE *file )
162 char buffer[PROFILE_MAX_LINE_LEN];
165 PROFILESECTION *section, *first_section;
166 PROFILESECTION **prev_section;
167 PROFILEKEY *key, **prev_key;
169 first_section = HEAP_xalloc( SystemHeap, 0, sizeof(*section) );
170 first_section->name = NULL;
171 first_section->key = NULL;
172 first_section->next = NULL;
173 prev_section = &first_section->next;
174 prev_key = &first_section->key;
176 while (fgets( buffer, PROFILE_MAX_LINE_LEN, file ))
179 p = buffer + strlen(buffer) - 1;
180 while ((p > buffer) && ((*p == '\n') || isspace(*p))) *p-- = '\0';
182 while (*p && isspace(*p)) p++;
183 if (*p == '[') /* section start */
185 if (!(p2 = strrchr( p, ']' )))
187 WARN(profile, "Invalid section header at line %d: '%s'\n",
194 section = HEAP_xalloc( SystemHeap, 0, sizeof(*section) );
195 section->name = HEAP_strdupA( SystemHeap, 0, p );
197 section->next = NULL;
198 *prev_section = section;
199 prev_section = §ion->next;
200 prev_key = §ion->key;
204 if ((p2 = strchr( p, '=' )) != NULL)
207 while ((p3 > p) && isspace(*p3)) *p3-- = '\0';
209 while (*p2 && isspace(*p2)) p2++;
211 key = HEAP_xalloc( SystemHeap, 0, sizeof(*key) );
212 key->name = HEAP_strdupA( SystemHeap, 0, p );
213 key->value = p2 ? HEAP_strdupA( SystemHeap, 0, p2 ) : NULL;
216 prev_key = &key->next;
218 if (TRACE_ON(profile))
220 TRACE(profile, "dump:\n" );
221 /* FIXME: improper use of stddeb! */
222 PROFILE_Save(stddeb, first_section );
223 TRACE(profile, "finished.\n" );
225 return first_section;
229 /***********************************************************************
230 * PROFILE_DeleteSection
232 * Delete a section from a profile tree.
234 static BOOL32 PROFILE_DeleteSection( PROFILESECTION **section, LPCSTR name )
238 if ((*section)->name && !lstrcmpi32A( (*section)->name, name ))
240 PROFILESECTION *to_del = *section;
241 *section = to_del->next;
243 PROFILE_Free( to_del );
246 section = &(*section)->next;
252 /***********************************************************************
255 * Delete a key from a profile tree.
257 static BOOL32 PROFILE_DeleteKey( PROFILESECTION **section,
258 LPCSTR section_name, LPCSTR key_name )
262 if ((*section)->name && !lstrcmpi32A( (*section)->name, section_name ))
264 PROFILEKEY **key = &(*section)->key;
267 if (!lstrcmpi32A( (*key)->name, key_name ))
269 PROFILEKEY *to_del = *key;
271 if (to_del->name) HeapFree( SystemHeap, 0, to_del->name );
272 if (to_del->value) HeapFree( SystemHeap, 0, to_del->value);
273 HeapFree( SystemHeap, 0, to_del );
279 section = &(*section)->next;
285 /***********************************************************************
288 * Find a key in a profile tree, optionally creating it.
290 static PROFILEKEY *PROFILE_Find( PROFILESECTION **section,
291 const char *section_name,
292 const char *key_name, int create )
296 if ((*section)->name && !lstrcmpi32A( (*section)->name, section_name ))
298 PROFILEKEY **key = &(*section)->key;
301 if (!lstrcmpi32A( (*key)->name, key_name )) return *key;
304 if (!create) return NULL;
305 *key = HEAP_xalloc( SystemHeap, 0, sizeof(PROFILEKEY) );
306 (*key)->name = HEAP_strdupA( SystemHeap, 0, key_name );
307 (*key)->value = NULL;
311 section = &(*section)->next;
313 if (!create) return NULL;
314 *section = HEAP_xalloc( SystemHeap, 0, sizeof(PROFILESECTION) );
315 (*section)->name = HEAP_strdupA( SystemHeap, 0, section_name );
316 (*section)->next = NULL;
317 (*section)->key = HEAP_xalloc( SystemHeap, 0, sizeof(PROFILEKEY) );
318 (*section)->key->name = HEAP_strdupA( SystemHeap, 0, key_name );
319 (*section)->key->value = NULL;
320 (*section)->key->next = NULL;
321 return (*section)->key;
325 /***********************************************************************
328 * Flush the current profile to disk if changed.
330 static BOOL32 PROFILE_FlushFile(void)
332 char *p, buffer[MAX_PATHNAME_LEN];
333 const char *unix_name;
336 if (!CurProfile.changed || !CurProfile.dos_name) return TRUE;
337 if (!(unix_name = CurProfile.unix_name) || !(file = fopen(unix_name, "w")))
339 /* Try to create it in $HOME/.wine */
340 /* FIXME: this will need a more general solution */
341 if ((p = getenv( "HOME" )) != NULL)
344 strcat( buffer, "/.wine/" );
345 p = buffer + strlen(buffer);
346 strcpy( p, strrchr( CurProfile.dos_name, '\\' ) + 1 );
348 file = fopen( buffer, "w" );
355 WARN(profile, "could not save profile file %s\n", CurProfile.dos_name);
359 TRACE(profile, "Saving '%s' into '%s'\n", CurProfile.dos_name, unix_name );
360 PROFILE_Save( file, CurProfile.section );
362 CurProfile.changed = FALSE;
367 /***********************************************************************
370 * Open a profile file, checking the cached file first.
372 static BOOL32 PROFILE_Open( LPCSTR filename )
374 DOS_FULL_NAME full_name;
375 char buffer[MAX_PATHNAME_LEN];
376 char *newdos_name, *p;
379 if (CurProfile.filename && !strcmp( filename, CurProfile.filename ))
381 TRACE(profile, "(%s): already opened\n",
386 if (strchr( filename, '/' ) || strchr( filename, '\\' ) ||
387 strchr( filename, ':' ))
389 if (!DOSFS_GetFullName( filename, FALSE, &full_name )) return FALSE;
393 GetWindowsDirectory32A( buffer, sizeof(buffer) );
394 strcat( buffer, "\\" );
395 strcat( buffer, filename );
396 if (!DOSFS_GetFullName( buffer, FALSE, &full_name )) return FALSE;
398 if (CurProfile.dos_name &&
399 !strcmp( full_name.short_name, CurProfile.dos_name ))
401 TRACE(profile, "(%s): already opened\n",
406 /* Flush the previous profile */
408 newdos_name = HEAP_strdupA( SystemHeap, 0, full_name.short_name );
410 PROFILE_Free( CurProfile.section );
411 if (CurProfile.dos_name) HeapFree( SystemHeap, 0, CurProfile.dos_name );
412 if (CurProfile.unix_name) HeapFree( SystemHeap, 0, CurProfile.unix_name );
413 if (CurProfile.filename) HeapFree( SystemHeap, 0, CurProfile.filename );
414 CurProfile.section = NULL;
415 CurProfile.dos_name = newdos_name;
416 CurProfile.filename = HEAP_strdupA( SystemHeap, 0, filename );
418 /* Try to open the profile file, first in $HOME/.wine */
420 /* FIXME: this will need a more general solution */
421 if ((p = getenv( "HOME" )) != NULL)
424 strcat( buffer, "/.wine/" );
425 p = buffer + strlen(buffer);
426 strcpy( p, strrchr( newdos_name, '\\' ) + 1 );
428 if ((file = fopen( buffer, "r" )))
430 TRACE(profile, "(%s): found it in %s\n",
432 CurProfile.unix_name = HEAP_strdupA( SystemHeap, 0, buffer );
438 CurProfile.unix_name = HEAP_strdupA( SystemHeap, 0,
439 full_name.long_name );
440 if ((file = fopen( full_name.long_name, "r" )))
441 TRACE(profile, "(%s): found it in %s\n",
442 filename, full_name.long_name );
447 CurProfile.section = PROFILE_Load( file );
452 /* Does not exist yet, we will create it in PROFILE_FlushFile */
453 WARN(profile, "profile file %s not found\n", newdos_name );
459 /***********************************************************************
462 * Enumerate all the keys of a section.
464 static INT32 PROFILE_GetSection( PROFILESECTION *section, LPCSTR section_name,
465 LPSTR buffer, INT32 len, BOOL32 handle_env )
470 if (section->name && !lstrcmpi32A( section->name, section_name ))
473 for (key = section->key; key; key = key->next)
476 if (IS_ENTRY_COMMENT(key->name)) continue; /* Skip comments */
477 PROFILE_CopyEntry( buffer, key->name, len - 1, handle_env );
478 len -= strlen(buffer) + 1;
479 buffer += strlen(buffer) + 1;
483 PROFILE_CopyEntry(buffer, key->value, len - 1, handle_env);
484 len -= strlen(buffer) + 1;
485 buffer += strlen(buffer) + 1;
489 return oldlen - len + 1;
491 section = section->next;
493 buffer[0] = buffer[1] = '\0';
498 /***********************************************************************
501 * Get a profile string.
503 static INT32 PROFILE_GetString( LPCSTR section, LPCSTR key_name,
504 LPCSTR def_val, LPSTR buffer, INT32 len )
506 PROFILEKEY *key = NULL;
508 if (!def_val) def_val = "";
509 if (key_name && key_name[0])
511 key = PROFILE_Find( &CurProfile.section, section, key_name, FALSE );
512 PROFILE_CopyEntry( buffer, (key && key->value) ? key->value : def_val,
514 TRACE(profile, "('%s','%s','%s'): returning '%s'\n",
515 section, key_name, def_val, buffer );
516 return strlen( buffer );
518 return PROFILE_GetSection(CurProfile.section, section, buffer, len, FALSE);
522 /***********************************************************************
525 * Set a profile string.
527 static BOOL32 PROFILE_SetString( LPCSTR section_name, LPCSTR key_name,
530 if (!key_name) /* Delete a whole section */
532 TRACE(profile, "('%s')\n", section_name);
533 CurProfile.changed |= PROFILE_DeleteSection( &CurProfile.section,
535 return TRUE; /* Even if PROFILE_DeleteSection() has failed,
536 this is not an error on application's level.*/
538 else if (!value) /* Delete a key */
540 TRACE(profile, "('%s','%s')\n",
541 section_name, key_name );
542 CurProfile.changed |= PROFILE_DeleteKey( &CurProfile.section,
543 section_name, key_name );
544 return TRUE; /* same error handling as above */
546 else /* Set the key value */
548 PROFILEKEY *key = PROFILE_Find( &CurProfile.section, section_name,
550 TRACE(profile, "('%s','%s','%s'): \n",
551 section_name, key_name, value );
552 if (!key) return FALSE;
555 if (!strcmp( key->value, value ))
557 TRACE(profile, " no change needed\n" );
558 return TRUE; /* No change needed */
560 TRACE(profile, " replacing '%s'\n", key->value );
561 HeapFree( SystemHeap, 0, key->value );
563 else TRACE(profile, " creating key\n" );
564 key->value = HEAP_strdupA( SystemHeap, 0, value );
565 CurProfile.changed = TRUE;
571 /***********************************************************************
572 * PROFILE_GetWineIniString
574 * Get a config string from the wine.ini file.
576 int PROFILE_GetWineIniString( const char *section, const char *key_name,
577 const char *def, char *buffer, int len )
581 PROFILEKEY *key = PROFILE_Find(&WineProfile, section, key_name, FALSE);
582 PROFILE_CopyEntry( buffer, (key && key->value) ? key->value : def,
584 TRACE(profile, "('%s','%s','%s'): returning '%s'\n",
585 section, key_name, def, buffer );
586 return strlen( buffer );
588 return PROFILE_GetSection( WineProfile, section, buffer, len, TRUE );
592 /***********************************************************************
593 * PROFILE_GetWineIniInt
595 * Get a config integer from the wine.ini file.
597 int PROFILE_GetWineIniInt( const char *section, const char *key_name, int def )
603 PROFILEKEY *key = PROFILE_Find( &WineProfile, section, key_name, FALSE );
604 if (!key || !key->value) return def;
605 PROFILE_CopyEntry( buffer, key->value, sizeof(buffer), TRUE );
606 result = strtol( buffer, &p, 0 );
607 if (p == buffer) return 0; /* No digits at all */
612 /******************************************************************************
614 * int PROFILE_EnumerateWineIniSection(
615 * char const *section, // Name of the section to enumerate
616 * void (*cbfn)(char const *key, char const *value, void *user),
617 // Address of the callback function
618 * void *user ) // User-specified pointer.
620 * For each entry in a section in the wine.conf file, this function will
621 * call the specified callback function, informing it of each key and
622 * value. An optional user pointer may be passed to it (if this is not
623 * needed, pass NULL through it and ignore the value in the callback
626 * The callback function must accept three parameters:
627 * The name of the key (char const *)
628 * The value of the key (char const *)
629 * A user-specified parameter (void *)
630 * Note that the first two are char CONST *'s, not char *'s! The callback
631 * MUST not modify these strings!
633 * The return value indicates the number of times the callback function
636 int PROFILE_EnumerateWineIniSection(
638 void (*cbfn)(char const *, char const *, void *),
641 PROFILESECTION *scansect;
645 /* Search for the correct section */
646 for(scansect = WineProfile; scansect; scansect = scansect->next) {
647 if(scansect->name && !lstrcmpi32A(scansect->name, section)) {
649 /* Enumerate each key with the callback */
650 for(scankey = scansect->key; scankey; scankey = scankey->next) {
652 /* Ignore blank entries -- these shouldn't exist, but let's
654 if(scankey->name[0]) {
655 cbfn(scankey->name, scankey->value, userptr);
668 /******************************************************************************
670 * int PROFILE_GetWineIniBool(
671 * char const *section,
672 * char const *key_name,
675 * Reads a boolean value from the wine.ini file. This function attempts to
676 * be user-friendly by accepting 'n', 'N' (no), 'f', 'F' (false), or '0'
677 * (zero) for false, 'y', 'Y' (yes), 't', 'T' (true), or '1' (one) for
678 * true. Anything else results in the return of the default value.
680 * This function uses 1 to indicate true, and 0 for false. You can check
681 * for existence by setting def to something other than 0 or 1 and
682 * examining the return value.
684 int PROFILE_GetWineIniBool(
686 char const *key_name,
692 PROFILE_GetWineIniString(section, key_name, "~", key_value, 2);
694 switch(key_value[0]) {
715 TRACE(profile, "(\"%s\", \"%s\", %s), "
716 "[%c], ret %s.\n", section, key_name,
717 def ? "TRUE" : "FALSE", key_value[0],
718 retval ? "TRUE" : "FALSE");
724 /***********************************************************************
725 * PROFILE_LoadWineIni
727 * Load the wine.ini file.
729 int PROFILE_LoadWineIni(void)
731 char buffer[MAX_PATHNAME_LEN];
735 if ((p = getenv( "HOME" )) != NULL)
737 lstrcpyn32A(buffer, p, MAX_PATHNAME_LEN - sizeof(PROFILE_WineIniName));
738 strcat( buffer, PROFILE_WineIniName );
739 if ((f = fopen( buffer, "r" )) != NULL)
741 WineProfile = PROFILE_Load( f );
746 else WARN(profile, "could not get $HOME value for config file.\n" );
748 /* Try global file */
750 if ((f = fopen( WINE_INI_GLOBAL, "r" )) != NULL)
752 WineProfile = PROFILE_Load( f );
756 WARN(profile, "Can't open configuration file %s or $HOME%s\n",
757 WINE_INI_GLOBAL, PROFILE_WineIniName );
762 /***********************************************************************
763 * PROFILE_GetStringItem
765 * Convenience function that turns a string 'xxx, yyy, zzz' into
766 * the 'xxx\0 yyy, zzz' and returns a pointer to the 'yyy, zzz'.
768 char* PROFILE_GetStringItem( char* start )
772 for (lpchX = start, lpch = NULL; *lpchX != '\0'; lpchX++ )
776 if( lpch ) *lpch = '\0'; else *lpchX = '\0';
778 if( !isspace(*lpchX) ) return lpchX;
780 else if( isspace( *lpchX ) && !lpch ) lpch = lpchX;
783 if( lpch ) *lpch = '\0';
788 /********************* API functions **********************************/
790 /***********************************************************************
791 * GetProfileInt16 (KERNEL.57)
793 UINT16 WINAPI GetProfileInt16( LPCSTR section, LPCSTR entry, INT16 def_val )
795 return GetPrivateProfileInt16( section, entry, def_val, "win.ini" );
799 /***********************************************************************
800 * GetProfileInt32A (KERNEL32.264)
802 UINT32 WINAPI GetProfileInt32A( LPCSTR section, LPCSTR entry, INT32 def_val )
804 return GetPrivateProfileInt32A( section, entry, def_val, "win.ini" );
807 /***********************************************************************
808 * GetProfileInt32W (KERNEL32.264)
810 UINT32 WINAPI GetProfileInt32W( LPCWSTR section, LPCWSTR entry, INT32 def_val )
812 if (!wininiW) wininiW = HEAP_strdupAtoW( SystemHeap, 0, "win.ini" );
813 return GetPrivateProfileInt32W( section, entry, def_val, wininiW );
816 /***********************************************************************
817 * GetProfileString16 (KERNEL.58)
819 INT16 WINAPI GetProfileString16( LPCSTR section, LPCSTR entry, LPCSTR def_val,
820 LPSTR buffer, INT16 len )
822 return GetPrivateProfileString16( section, entry, def_val,
823 buffer, len, "win.ini" );
826 /***********************************************************************
827 * GetProfileString32A (KERNEL32.268)
829 INT32 WINAPI GetProfileString32A( LPCSTR section, LPCSTR entry, LPCSTR def_val,
830 LPSTR buffer, INT32 len )
832 return GetPrivateProfileString32A( section, entry, def_val,
833 buffer, len, "win.ini" );
836 /***********************************************************************
837 * GetProfileString32W (KERNEL32.269)
839 INT32 WINAPI GetProfileString32W( LPCWSTR section, LPCWSTR entry,
840 LPCWSTR def_val, LPWSTR buffer, INT32 len )
842 if (!wininiW) wininiW = HEAP_strdupAtoW( SystemHeap, 0, "win.ini" );
843 return GetPrivateProfileString32W( section, entry, def_val,
844 buffer, len, wininiW );
847 /***********************************************************************
848 * GetProfileSection32A (KERNEL32.268)
850 INT32 WINAPI GetProfileSection32A( LPCSTR section, LPSTR buffer, INT32 len )
852 return GetPrivateProfileSection32A( section, buffer, len, "win.ini" );
856 /***********************************************************************
857 * WriteProfileString16 (KERNEL.59)
859 BOOL16 WINAPI WriteProfileString16( LPCSTR section, LPCSTR entry,
862 return WritePrivateProfileString16( section, entry, string, "win.ini" );
865 /***********************************************************************
866 * WriteProfileString32A (KERNEL32.587)
868 BOOL32 WINAPI WriteProfileString32A( LPCSTR section, LPCSTR entry,
871 return WritePrivateProfileString32A( section, entry, string, "win.ini" );
874 /***********************************************************************
875 * WriteProfileString32W (KERNEL32.588)
877 BOOL32 WINAPI WriteProfileString32W( LPCWSTR section, LPCWSTR entry,
880 if (!wininiW) wininiW = HEAP_strdupAtoW( SystemHeap, 0, "win.ini" );
881 return WritePrivateProfileString32W( section, entry, string, wininiW );
885 /***********************************************************************
886 * GetPrivateProfileInt16 (KERNEL.127)
888 UINT16 WINAPI GetPrivateProfileInt16( LPCSTR section, LPCSTR entry,
889 INT16 def_val, LPCSTR filename )
891 long result=(long)GetPrivateProfileInt32A(section,entry,def_val,filename);
893 if (result > 65535) return 65535;
894 if (result >= 0) return (UINT16)result;
895 if (result < -32768) return -32768;
896 return (UINT16)(INT16)result;
899 /***********************************************************************
900 * GetPrivateProfileInt32A (KERNEL32.251)
902 UINT32 WINAPI GetPrivateProfileInt32A( LPCSTR section, LPCSTR entry,
903 INT32 def_val, LPCSTR filename )
909 GetPrivateProfileString32A( section, entry, "",
910 buffer, sizeof(buffer), filename );
911 if (!buffer[0]) return (UINT32)def_val;
912 result = strtol( buffer, &p, 0 );
913 if (p == buffer) return 0; /* No digits at all */
914 return (UINT32)result;
917 /***********************************************************************
918 * GetPrivateProfileInt32W (KERNEL32.252)
920 UINT32 WINAPI GetPrivateProfileInt32W( LPCWSTR section, LPCWSTR entry,
921 INT32 def_val, LPCWSTR filename )
923 LPSTR sectionA = HEAP_strdupWtoA( GetProcessHeap(), 0, section );
924 LPSTR entryA = HEAP_strdupWtoA( GetProcessHeap(), 0, entry );
925 LPSTR filenameA = HEAP_strdupWtoA( GetProcessHeap(), 0, filename );
926 UINT32 res = GetPrivateProfileInt32A(sectionA, entryA, def_val, filenameA);
927 HeapFree( GetProcessHeap(), 0, sectionA );
928 HeapFree( GetProcessHeap(), 0, filenameA );
929 HeapFree( GetProcessHeap(), 0, entryA );
933 /***********************************************************************
934 * GetPrivateProfileString16 (KERNEL.128)
936 INT16 WINAPI GetPrivateProfileString16( LPCSTR section, LPCSTR entry,
937 LPCSTR def_val, LPSTR buffer,
938 INT16 len, LPCSTR filename )
940 return GetPrivateProfileString32A(section,entry,def_val,buffer,len,filename);
943 /***********************************************************************
944 * GetPrivateProfileString32A (KERNEL32.255)
946 INT32 WINAPI GetPrivateProfileString32A( LPCSTR section, LPCSTR entry,
947 LPCSTR def_val, LPSTR buffer,
948 INT32 len, LPCSTR filename )
951 filename = "win.ini";
952 if (PROFILE_Open( filename ))
953 return PROFILE_GetString( section, entry, def_val, buffer, len );
954 lstrcpyn32A( buffer, def_val, len );
955 return strlen( buffer );
958 /***********************************************************************
959 * GetPrivateProfileString32W (KERNEL32.256)
961 INT32 WINAPI GetPrivateProfileString32W( LPCWSTR section, LPCWSTR entry,
962 LPCWSTR def_val, LPWSTR buffer,
963 INT32 len, LPCWSTR filename )
965 LPSTR sectionA = HEAP_strdupWtoA( GetProcessHeap(), 0, section );
966 LPSTR entryA = HEAP_strdupWtoA( GetProcessHeap(), 0, entry );
967 LPSTR filenameA = HEAP_strdupWtoA( GetProcessHeap(), 0, filename );
968 LPSTR def_valA = HEAP_strdupWtoA( GetProcessHeap(), 0, def_val );
969 LPSTR bufferA = HeapAlloc( GetProcessHeap(), 0, len );
970 INT32 ret = GetPrivateProfileString32A( sectionA, entryA, def_valA,
971 bufferA, len, filenameA );
972 lstrcpynAtoW( buffer, bufferA, len );
973 HeapFree( GetProcessHeap(), 0, sectionA );
974 HeapFree( GetProcessHeap(), 0, entryA );
975 HeapFree( GetProcessHeap(), 0, filenameA );
976 HeapFree( GetProcessHeap(), 0, def_valA );
977 HeapFree( GetProcessHeap(), 0, bufferA);
981 /***********************************************************************
982 * GetPrivateProfileSection32A (KERNEL32.255)
984 INT32 WINAPI GetPrivateProfileSection32A( LPCSTR section, LPSTR buffer,
985 INT32 len, LPCSTR filename )
987 if (PROFILE_Open( filename ))
988 return PROFILE_GetString( section, NULL, NULL, buffer, len );
992 /***********************************************************************
993 * WritePrivateProfileString16 (KERNEL.129)
995 BOOL16 WINAPI WritePrivateProfileString16( LPCSTR section, LPCSTR entry,
996 LPCSTR string, LPCSTR filename )
998 return WritePrivateProfileString32A(section,entry,string,filename);
1001 /***********************************************************************
1002 * WritePrivateProfileString32A (KERNEL32.582)
1004 BOOL32 WINAPI WritePrivateProfileString32A( LPCSTR section, LPCSTR entry,
1005 LPCSTR string, LPCSTR filename )
1007 if (!PROFILE_Open( filename )) return FALSE;
1008 if (!section) return PROFILE_FlushFile();
1009 return PROFILE_SetString( section, entry, string );
1012 /***********************************************************************
1013 * WritePrivateProfileString32W (KERNEL32.583)
1015 BOOL32 WINAPI WritePrivateProfileString32W( LPCWSTR section, LPCWSTR entry,
1016 LPCWSTR string, LPCWSTR filename )
1018 LPSTR sectionA = HEAP_strdupWtoA( GetProcessHeap(), 0, section );
1019 LPSTR entryA = HEAP_strdupWtoA( GetProcessHeap(), 0, entry );
1020 LPSTR stringA = HEAP_strdupWtoA( GetProcessHeap(), 0, string );
1021 LPSTR filenameA = HEAP_strdupWtoA( GetProcessHeap(), 0, filename );
1022 BOOL32 res = WritePrivateProfileString32A( sectionA, entryA,
1023 stringA, filenameA );
1024 HeapFree( GetProcessHeap(), 0, sectionA );
1025 HeapFree( GetProcessHeap(), 0, entryA );
1026 HeapFree( GetProcessHeap(), 0, stringA );
1027 HeapFree( GetProcessHeap(), 0, filenameA );
1031 /***********************************************************************
1032 * WritePrivateProfileSection32A (KERNEL32)
1034 BOOL32 WINAPI WritePrivateProfileSection32A( LPCSTR section,
1035 LPCSTR string, LPCSTR filename )
1037 char *p =(char*)string;
1039 FIXME(profile, "WritePrivateProfileSection32A empty stup\n");
1040 if (TRACE_ON(profile)) {
1041 TRACE(profile, "(%s) => [%s]\n", filename, section);
1043 TRACE(profile, "%s\n", p);
1053 /***********************************************************************
1054 * WriteOutProfiles (KERNEL.315)
1056 void WINAPI WriteOutProfiles(void)
1058 PROFILE_FlushFile();