Kernel - Win16/32 Profile support split
Steven Edwards
steven_ed4153 at yahoo.com
Tue Mar 2 21:40:52 CST 2004
Lets give the ReactOS boys and girls a break on forking the profile
code. Sorry I didnt do a patch for the Makefile.in. I cant build
kernel32 on mingw so I dont know if putting this in C_SRC16 will break
the build.
Thanks
Steven
Changelog:
Win16/32 split of the Kernel32 Profile support.
__________________________________
Do you Yahoo!?
Yahoo! Search - Find what youre looking for faster
http://search.yahoo.com
-------------- next part --------------
Index: profile.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/profile.c,v
retrieving revision 1.6
diff -u -r1.6 profile.c
--- profile.c 7 Feb 2004 02:24:15 -0000 1.6
+++ profile.c 3 Mar 2004 03:31:26 -0000
@@ -90,14 +90,15 @@
static const WCHAR emptystringW[] = {0};
static const WCHAR wininiW[] = { 'w','i','n','.','i','n','i',0 };
-static CRITICAL_SECTION PROFILE_CritSect;
+CRITICAL_SECTION PROFILE_CritSect;
static CRITICAL_SECTION_DEBUG critsect_debug =
{
0, 0, &PROFILE_CritSect,
{ &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
0, 0, { 0, (DWORD)(__FILE__ ": PROFILE_CritSect") }
};
-static CRITICAL_SECTION PROFILE_CritSect = { &critsect_debug, -1, 0, 0, 0, 0 };
+
+CRITICAL_SECTION PROFILE_CritSect = { &critsect_debug, -1, 0, 0, 0, 0 };
static const char hex[16] = "0123456789ABCDEF";
@@ -642,7 +643,7 @@
*
* Flush the current profile to disk if changed.
*/
-static BOOL PROFILE_FlushFile(void)
+BOOL PROFILE_FlushFile(void)
{
HANDLE hFile = NULL;
FILETIME LastWriteTime;
@@ -1021,15 +1022,6 @@
/********************* API functions **********************************/
/***********************************************************************
- * GetProfileInt (KERNEL.57)
- */
-UINT16 WINAPI GetProfileInt16( LPCSTR section, LPCSTR entry, INT16 def_val )
-{
- return GetPrivateProfileInt16( section, entry, def_val, "win.ini" );
-}
-
-
-/***********************************************************************
* GetProfileIntA (KERNEL32.@)
*/
UINT WINAPI GetProfileIntA( LPCSTR section, LPCSTR entry, INT def_val )
@@ -1051,10 +1043,10 @@
* - of Keys in a Section if 'entry' is NULL
* (see MSDN doc for GetPrivateProfileString)
*/
-static int PROFILE_GetPrivateProfileString( LPCWSTR section, LPCWSTR entry,
- LPCWSTR def_val, LPWSTR buffer,
- UINT len, LPCWSTR filename,
- BOOL allow_section_name_copy )
+int PROFILE_GetPrivateProfileString( LPCWSTR section, LPCWSTR entry,
+ LPCWSTR def_val, LPWSTR buffer,
+ UINT len, LPCWSTR filename,
+ BOOL allow_section_name_copy )
{
int ret;
LPWSTR pDefVal = NULL;
@@ -1111,50 +1103,6 @@
}
/***********************************************************************
- * GetPrivateProfileString (KERNEL.128)
- */
-INT16 WINAPI GetPrivateProfileString16( LPCSTR section, LPCSTR entry,
- LPCSTR def_val, LPSTR buffer,
- UINT16 len, LPCSTR filename )
-{
- UNICODE_STRING sectionW, entryW, def_valW, filenameW;
- LPWSTR bufferW;
- INT16 retW, ret = 0;
-
- bufferW = buffer ? HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)) : NULL;
- if (section) RtlCreateUnicodeStringFromAsciiz(§ionW, section);
- else sectionW.Buffer = NULL;
- if (entry) RtlCreateUnicodeStringFromAsciiz(&entryW, entry);
- else entryW.Buffer = NULL;
- if (def_val) RtlCreateUnicodeStringFromAsciiz(&def_valW, def_val);
- else def_valW.Buffer = NULL;
- if (filename) RtlCreateUnicodeStringFromAsciiz(&filenameW, filename);
- else filenameW.Buffer = NULL;
-
- retW = PROFILE_GetPrivateProfileString( sectionW.Buffer, entryW.Buffer,
- def_valW.Buffer, bufferW, len,
- filenameW.Buffer, FALSE );
- if (len)
- {
- ret = WideCharToMultiByte(CP_ACP, 0, bufferW, retW + 1, buffer, len, NULL, NULL);
- if (!ret)
- {
- ret = len - 1;
- buffer[ret] = 0;
- }
- else
- ret--; /* strip terminating 0 */
- }
-
- RtlFreeUnicodeString(§ionW);
- RtlFreeUnicodeString(&entryW);
- RtlFreeUnicodeString(&def_valW);
- RtlFreeUnicodeString(&filenameW);
- if (bufferW) HeapFree(GetProcessHeap(), 0, bufferW);
- return ret;
-}
-
-/***********************************************************************
* GetPrivateProfileStringA (KERNEL32.@)
*/
INT WINAPI GetPrivateProfileStringA( LPCSTR section, LPCSTR entry,
@@ -1212,16 +1160,6 @@
}
/***********************************************************************
- * GetProfileString (KERNEL.58)
- */
-INT16 WINAPI GetProfileString16( LPCSTR section, LPCSTR entry, LPCSTR def_val,
- LPSTR buffer, UINT16 len )
-{
- return GetPrivateProfileString16( section, entry, def_val,
- buffer, len, "win.ini" );
-}
-
-/***********************************************************************
* GetProfileStringA (KERNEL32.@)
*/
INT WINAPI GetProfileStringA( LPCSTR section, LPCSTR entry, LPCSTR def_val,
@@ -1242,15 +1180,6 @@
}
/***********************************************************************
- * WriteProfileString (KERNEL.59)
- */
-BOOL16 WINAPI WriteProfileString16( LPCSTR section, LPCSTR entry,
- LPCSTR string )
-{
- return WritePrivateProfileString16( section, entry, string, "win.ini" );
-}
-
-/***********************************************************************
* WriteProfileStringA (KERNEL32.@)
*/
BOOL WINAPI WriteProfileStringA( LPCSTR section, LPCSTR entry,
@@ -1268,19 +1197,6 @@
return WritePrivateProfileStringW( section, entry, string, wininiW );
}
-
-/***********************************************************************
- * GetPrivateProfileInt (KERNEL.127)
- */
-UINT16 WINAPI GetPrivateProfileInt16( LPCSTR section, LPCSTR entry,
- INT16 def_val, LPCSTR filename )
-{
- /* we used to have some elaborate return value limitation (<= -32768 etc.)
- * here, but Win98SE doesn't care about this at all, so I deleted it.
- * AFAIR versions prior to Win9x had these limits, though. */
- return (INT16)GetPrivateProfileIntA(section,entry,def_val,filename);
-}
-
/***********************************************************************
* GetPrivateProfileIntW (KERNEL32.@)
*/
@@ -1336,15 +1252,6 @@
}
/***********************************************************************
- * GetPrivateProfileSection (KERNEL.418)
- */
-INT16 WINAPI GetPrivateProfileSection16( LPCSTR section, LPSTR buffer,
- UINT16 len, LPCSTR filename )
-{
- return GetPrivateProfileSectionA( section, buffer, len, filename );
-}
-
-/***********************************************************************
* GetPrivateProfileSectionW (KERNEL32.@)
*/
INT WINAPI GetPrivateProfileSectionW( LPCWSTR section, LPWSTR buffer,
@@ -1406,14 +1313,6 @@
}
/***********************************************************************
- * GetProfileSection (KERNEL.419)
- */
-INT16 WINAPI GetProfileSection16( LPCSTR section, LPSTR buffer, UINT16 len )
-{
- return GetPrivateProfileSection16( section, buffer, len, "win.ini" );
-}
-
-/***********************************************************************
* GetProfileSectionA (KERNEL32.@)
*/
INT WINAPI GetProfileSectionA( LPCSTR section, LPSTR buffer, DWORD len )
@@ -1429,16 +1328,6 @@
return GetPrivateProfileSectionW( section, buffer, len, wininiW );
}
-
-/***********************************************************************
- * WritePrivateProfileString (KERNEL.129)
- */
-BOOL16 WINAPI WritePrivateProfileString16( LPCSTR section, LPCSTR entry,
- LPCSTR string, LPCSTR filename )
-{
- return WritePrivateProfileStringA(section,entry,string,filename);
-}
-
/***********************************************************************
* WritePrivateProfileStringW (KERNEL32.@)
*/
@@ -1499,15 +1388,6 @@
}
/***********************************************************************
- * WritePrivateProfileSection (KERNEL.416)
- */
-BOOL16 WINAPI WritePrivateProfileSection16( LPCSTR section,
- LPCSTR string, LPCSTR filename )
-{
- return WritePrivateProfileSectionA( section, string, filename );
-}
-
-/***********************************************************************
* WritePrivateProfileSectionW (KERNEL32.@)
*/
BOOL WINAPI WritePrivateProfileSectionW( LPCWSTR section,
@@ -1582,14 +1462,6 @@
}
/***********************************************************************
- * WriteProfileSection (KERNEL.417)
- */
-BOOL16 WINAPI WriteProfileSection16( LPCSTR section, LPCSTR keys_n_values)
-{
- return WritePrivateProfileSection16( section, keys_n_values, "win.ini");
-}
-
-/***********************************************************************
* WriteProfileSectionA (KERNEL32.@)
*/
BOOL WINAPI WriteProfileSectionA( LPCSTR section, LPCSTR keys_n_values)
@@ -1607,26 +1479,6 @@
}
/***********************************************************************
- * GetPrivateProfileSectionNames (KERNEL.143)
- */
-WORD WINAPI GetPrivateProfileSectionNames16( LPSTR buffer, WORD size,
- LPCSTR filename )
-{
- return GetPrivateProfileSectionNamesA(buffer,size,filename);
-}
-
-
-/***********************************************************************
- * GetProfileSectionNames (KERNEL.142)
- */
-WORD WINAPI GetProfileSectionNames16(LPSTR buffer, WORD size)
-
-{
- return GetPrivateProfileSectionNamesA(buffer,size,"win.ini");
-}
-
-
-/***********************************************************************
* GetPrivateProfileSectionNamesW (KERNEL32.@)
*
* Returns the section names contained in the specified file.
@@ -1710,15 +1562,6 @@
}
/***********************************************************************
- * GetPrivateProfileStruct (KERNEL.407)
- */
-BOOL16 WINAPI GetPrivateProfileStruct16(LPCSTR section, LPCSTR key,
- LPVOID buf, UINT16 len, LPCSTR filename)
-{
- return GetPrivateProfileStructA( section, key, buf, len, filename );
-}
-
-/***********************************************************************
* GetPrivateProfileStructW (KERNEL32.@)
*
* Should match Win95's behaviour pretty much
@@ -1819,17 +1662,6 @@
return ret;
}
-
-
-/***********************************************************************
- * WritePrivateProfileStruct (KERNEL.406)
- */
-BOOL16 WINAPI WritePrivateProfileStruct16 (LPCSTR section, LPCSTR key,
- LPVOID buf, UINT16 bufsize, LPCSTR filename)
-{
- return WritePrivateProfileStructA( section, key, buf, bufsize, filename );
-}
-
/***********************************************************************
* WritePrivateProfileStructW (KERNEL32.@)
*/
@@ -1895,17 +1727,6 @@
RtlFreeUnicodeString(&keyW);
RtlFreeUnicodeString(&filenameW);
return ret;
-}
-
-
-/***********************************************************************
- * WriteOutProfiles (KERNEL.315)
- */
-void WINAPI WriteOutProfiles16(void)
-{
- RtlEnterCriticalSection( &PROFILE_CritSect );
- PROFILE_FlushFile();
- RtlLeaveCriticalSection( &PROFILE_CritSect );
}
/***********************************************************************
--- /dev/null Tue Mar 2 22:24:03 2004
+++ profile16.c Tue Mar 2 01:59:06 2004
@@ -0,0 +1,220 @@
+/*
+ * Profile functions
+ *
+ * Copyright 1993 Miguel de Icaza
+ * Copyright 1996 Alexandre Julliard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "config.h"
+#include "wine/port.h"
+
+#include <string.h>
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "winnls.h"
+#include "winerror.h"
+#include "winreg.h"
+#include "winternl.h"
+#include "wine/winbase16.h"
+#include "file.h"
+#include "wine/unicode.h"
+#include "wine/server.h"
+#include "wine/library.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(profile);
+
+CRITICAL_SECTION PROFILE_CritSect;
+BOOL PROFILE_FlushFile(void);
+int PROFILE_GetPrivateProfileString( LPCWSTR section, LPCWSTR entry,
+ LPCWSTR def_val, LPWSTR buffer,
+ UINT len, LPCWSTR filename,
+ BOOL allow_section_name_copy );
+
+/***********************************************************************
+ * GetProfileInt (KERNEL.57)
+ */
+UINT16 WINAPI GetProfileInt16( LPCSTR section, LPCSTR entry, INT16 def_val )
+{
+ return GetPrivateProfileInt16( section, entry, def_val, "win.ini" );
+}
+
+/***********************************************************************
+ * GetPrivateProfileString (KERNEL.128)
+ */
+INT16 WINAPI GetPrivateProfileString16( LPCSTR section, LPCSTR entry,
+ LPCSTR def_val, LPSTR buffer,
+ UINT16 len, LPCSTR filename )
+{
+ UNICODE_STRING sectionW, entryW, def_valW, filenameW;
+ LPWSTR bufferW;
+ INT16 retW, ret = 0;
+
+ bufferW = buffer ? HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)) : NULL;
+ if (section) RtlCreateUnicodeStringFromAsciiz(§ionW, section);
+ else sectionW.Buffer = NULL;
+ if (entry) RtlCreateUnicodeStringFromAsciiz(&entryW, entry);
+ else entryW.Buffer = NULL;
+ if (def_val) RtlCreateUnicodeStringFromAsciiz(&def_valW, def_val);
+ else def_valW.Buffer = NULL;
+ if (filename) RtlCreateUnicodeStringFromAsciiz(&filenameW, filename);
+ else filenameW.Buffer = NULL;
+
+ retW = PROFILE_GetPrivateProfileString( sectionW.Buffer, entryW.Buffer,
+ def_valW.Buffer, bufferW, len,
+ filenameW.Buffer, FALSE );
+ if (len)
+ {
+ ret = WideCharToMultiByte(CP_ACP, 0, bufferW, retW + 1, buffer, len, NULL, NULL);
+ if (!ret)
+ {
+ ret = len - 1;
+ buffer[ret] = 0;
+ }
+ else
+ ret--; /* strip terminating 0 */
+ }
+
+ RtlFreeUnicodeString(§ionW);
+ RtlFreeUnicodeString(&entryW);
+ RtlFreeUnicodeString(&def_valW);
+ RtlFreeUnicodeString(&filenameW);
+ if (bufferW) HeapFree(GetProcessHeap(), 0, bufferW);
+ return ret;
+}
+
+/***********************************************************************
+ * GetProfileString (KERNEL.58)
+ */
+INT16 WINAPI GetProfileString16( LPCSTR section, LPCSTR entry, LPCSTR def_val,
+ LPSTR buffer, UINT16 len )
+{
+ return GetPrivateProfileString16( section, entry, def_val,
+ buffer, len, "win.ini" );
+}
+
+/***********************************************************************
+ * WriteProfileString (KERNEL.59)
+ */
+BOOL16 WINAPI WriteProfileString16( LPCSTR section, LPCSTR entry,
+ LPCSTR string )
+{
+ return WritePrivateProfileString16( section, entry, string, "win.ini" );
+}
+
+/***********************************************************************
+ * GetPrivateProfileInt (KERNEL.127)
+ */
+UINT16 WINAPI GetPrivateProfileInt16( LPCSTR section, LPCSTR entry,
+ INT16 def_val, LPCSTR filename )
+{
+ /* we used to have some elaborate return value limitation (<= -32768 etc.)
+ * here, but Win98SE doesn't care about this at all, so I deleted it.
+ * AFAIR versions prior to Win9x had these limits, though. */
+ return (INT16)GetPrivateProfileIntA(section,entry,def_val,filename);
+}
+
+/***********************************************************************
+ * GetPrivateProfileSection (KERNEL.418)
+ */
+INT16 WINAPI GetPrivateProfileSection16( LPCSTR section, LPSTR buffer,
+ UINT16 len, LPCSTR filename )
+{
+ return GetPrivateProfileSectionA( section, buffer, len, filename );
+}
+
+/***********************************************************************
+ * GetProfileSection (KERNEL.419)
+ */
+INT16 WINAPI GetProfileSection16( LPCSTR section, LPSTR buffer, UINT16 len )
+{
+ return GetPrivateProfileSection16( section, buffer, len, "win.ini" );
+}
+
+/***********************************************************************
+ * WritePrivateProfileString (KERNEL.129)
+ */
+BOOL16 WINAPI WritePrivateProfileString16( LPCSTR section, LPCSTR entry,
+ LPCSTR string, LPCSTR filename )
+{
+ return WritePrivateProfileStringA(section,entry,string,filename);
+}
+
+/***********************************************************************
+ * WritePrivateProfileSection (KERNEL.416)
+ */
+BOOL16 WINAPI WritePrivateProfileSection16( LPCSTR section,
+ LPCSTR string, LPCSTR filename )
+{
+ return WritePrivateProfileSectionA( section, string, filename );
+}
+
+/***********************************************************************
+ * WriteProfileSection (KERNEL.417)
+ */
+BOOL16 WINAPI WriteProfileSection16( LPCSTR section, LPCSTR keys_n_values)
+{
+ return WritePrivateProfileSection16( section, keys_n_values, "win.ini");
+}
+
+/***********************************************************************
+ * GetPrivateProfileSectionNames (KERNEL.143)
+ */
+WORD WINAPI GetPrivateProfileSectionNames16( LPSTR buffer, WORD size,
+ LPCSTR filename )
+{
+ return GetPrivateProfileSectionNamesA(buffer,size,filename);
+}
+
+/***********************************************************************
+ * GetProfileSectionNames (KERNEL.142)
+ */
+WORD WINAPI GetProfileSectionNames16(LPSTR buffer, WORD size)
+
+{
+ return GetPrivateProfileSectionNamesA(buffer,size,"win.ini");
+}
+
+/***********************************************************************
+ * GetPrivateProfileStruct (KERNEL.407)
+ */
+BOOL16 WINAPI GetPrivateProfileStruct16(LPCSTR section, LPCSTR key,
+ LPVOID buf, UINT16 len, LPCSTR filename)
+{
+ return GetPrivateProfileStructA( section, key, buf, len, filename );
+}
+
+/***********************************************************************
+ * WritePrivateProfileStruct (KERNEL.406)
+ */
+BOOL16 WINAPI WritePrivateProfileStruct16 (LPCSTR section, LPCSTR key,
+ LPVOID buf, UINT16 bufsize, LPCSTR filename)
+{
+ return WritePrivateProfileStructA( section, key, buf, bufsize, filename );
+}
+
+/***********************************************************************
+ * WriteOutProfiles (KERNEL.315)
+ */
+void WINAPI WriteOutProfiles16(void)
+{
+ RtlEnterCriticalSection( &PROFILE_CritSect );
+ PROFILE_FlushFile();
+ RtlLeaveCriticalSection( &PROFILE_CritSect );
+}
More information about the wine-patches
mailing list