2004-11-29 00:08:59 +00:00
|
|
|
/*
|
|
|
|
* Profile functions
|
2004-01-30 21:48:09 +00:00
|
|
|
*
|
|
|
|
* Copyright 1993 Miguel de Icaza
|
|
|
|
* Copyright 1996 Alexandre Julliard
|
2001-03-31 01:17:30 +00:00
|
|
|
*
|
2004-11-29 00:08:59 +00:00
|
|
|
* 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
|
2009-08-24 12:17:02 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-11-29 00:08:59 +00:00
|
|
|
*/
|
|
|
|
|
2013-12-22 18:10:41 +00:00
|
|
|
#include <k32.h>
|
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
DEBUG_CHANNEL(profile);
|
2004-01-30 21:48:09 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
static const char bom_utf8[] = {0xEF,0xBB,0xBF};
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
ENCODING_ANSI = 1,
|
|
|
|
ENCODING_UTF8,
|
|
|
|
ENCODING_UTF16LE,
|
|
|
|
ENCODING_UTF16BE
|
|
|
|
} ENCODING;
|
2004-01-30 21:48:09 +00:00
|
|
|
|
|
|
|
typedef struct tagPROFILEKEY
|
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
WCHAR *value;
|
|
|
|
struct tagPROFILEKEY *next;
|
|
|
|
WCHAR name[1];
|
2004-01-30 21:48:09 +00:00
|
|
|
} PROFILEKEY;
|
|
|
|
|
|
|
|
typedef struct tagPROFILESECTION
|
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
struct tagPROFILEKEY *key;
|
|
|
|
struct tagPROFILESECTION *next;
|
|
|
|
WCHAR name[1];
|
2004-01-30 21:48:09 +00:00
|
|
|
} PROFILESECTION;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
BOOL changed;
|
|
|
|
PROFILESECTION *section;
|
|
|
|
WCHAR *filename;
|
|
|
|
FILETIME LastWriteTime;
|
|
|
|
ENCODING encoding;
|
2004-01-30 21:48:09 +00:00
|
|
|
} PROFILE;
|
|
|
|
|
|
|
|
|
|
|
|
#define N_CACHED_PROFILES 10
|
|
|
|
|
|
|
|
/* Cached profile files */
|
|
|
|
static PROFILE *MRUProfile[N_CACHED_PROFILES]={NULL};
|
|
|
|
|
|
|
|
#define CurProfile (MRUProfile[0])
|
|
|
|
|
|
|
|
/* Check for comments in profile */
|
|
|
|
#define IS_ENTRY_COMMENT(str) ((str)[0] == ';')
|
2001-06-07 21:27:45 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
static const WCHAR emptystringW[] = {0};
|
2009-05-24 12:14:42 +00:00
|
|
|
static const WCHAR wininiW[] = { 'w','i','n','.','i','n','i',0 };
|
2004-11-29 00:08:59 +00:00
|
|
|
|
2005-01-03 23:02:15 +00:00
|
|
|
static RTL_CRITICAL_SECTION PROFILE_CritSect;
|
|
|
|
static RTL_CRITICAL_SECTION_DEBUG critsect_debug =
|
2004-11-29 00:08:59 +00:00
|
|
|
{
|
|
|
|
0, 0, &PROFILE_CritSect,
|
|
|
|
{ &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
0, 0, 0
|
2004-11-29 00:08:59 +00:00
|
|
|
};
|
2005-01-03 23:02:15 +00:00
|
|
|
static RTL_CRITICAL_SECTION PROFILE_CritSect = { &critsect_debug, -1, 0, 0, 0, 0 };
|
2004-11-29 00:08:59 +00:00
|
|
|
|
|
|
|
static const char hex[16] = "0123456789ABCDEF";
|
2001-06-07 21:27:45 +00:00
|
|
|
|
2004-01-30 21:48:09 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* PROFILE_CopyEntry
|
|
|
|
*
|
|
|
|
* Copy the content of an entry into a buffer, removing quotes, and possibly
|
|
|
|
* translating environment variables.
|
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
static void PROFILE_CopyEntry( LPWSTR buffer, LPCWSTR value, int len,
|
|
|
|
BOOL strip_quote )
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
WCHAR quote = '\0';
|
2004-01-30 21:48:09 +00:00
|
|
|
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
if(!buffer) return;
|
2004-01-30 21:48:09 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
if (strip_quote && ((*value == '\'') || (*value == '\"')))
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
if (value[1] && (value[strlenW(value)-1] == *value)) quote = *value++;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
|
|
|
|
2005-08-21 15:54:48 +00:00
|
|
|
lstrcpynW( buffer, value, len );
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
if (quote && (len >= lstrlenW(value))) buffer[strlenW(buffer)-1] = '\0';
|
2004-11-29 00:08:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* byte-swaps shorts in-place in a buffer. len is in WCHARs */
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
static inline void PROFILE_ByteSwapShortBuffer(WCHAR * buffer, int len)
|
2004-11-29 00:08:59 +00:00
|
|
|
{
|
|
|
|
int i;
|
2009-05-09 12:40:35 +00:00
|
|
|
USHORT * shortbuffer = buffer;
|
2004-11-29 00:08:59 +00:00
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
shortbuffer[i] = RtlUshortByteSwap(shortbuffer[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* writes any necessary encoding marker to the file */
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
static inline void PROFILE_WriteMarker(HANDLE hFile, ENCODING encoding)
|
2004-11-29 00:08:59 +00:00
|
|
|
{
|
|
|
|
DWORD dwBytesWritten;
|
2008-12-27 08:34:30 +00:00
|
|
|
WCHAR bom;
|
2004-11-29 00:08:59 +00:00
|
|
|
switch (encoding)
|
|
|
|
{
|
|
|
|
case ENCODING_ANSI:
|
|
|
|
break;
|
|
|
|
case ENCODING_UTF8:
|
|
|
|
WriteFile(hFile, bom_utf8, sizeof(bom_utf8), &dwBytesWritten, NULL);
|
|
|
|
break;
|
|
|
|
case ENCODING_UTF16LE:
|
|
|
|
bom = 0xFEFF;
|
|
|
|
WriteFile(hFile, &bom, sizeof(bom), &dwBytesWritten, NULL);
|
|
|
|
break;
|
|
|
|
case ENCODING_UTF16BE:
|
|
|
|
bom = 0xFFFE;
|
|
|
|
WriteFile(hFile, &bom, sizeof(bom), &dwBytesWritten, NULL);
|
|
|
|
break;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
static void PROFILE_WriteLine( HANDLE hFile, WCHAR * szLine, int len, ENCODING encoding)
|
|
|
|
{
|
|
|
|
char * write_buffer;
|
|
|
|
int write_buffer_len;
|
|
|
|
DWORD dwBytesWritten;
|
|
|
|
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
TRACE("writing: %s\n", debugstr_wn(szLine, len));
|
2004-11-29 00:08:59 +00:00
|
|
|
|
|
|
|
switch (encoding)
|
|
|
|
{
|
|
|
|
case ENCODING_ANSI:
|
|
|
|
write_buffer_len = WideCharToMultiByte(CP_ACP, 0, szLine, len, NULL, 0, NULL, NULL);
|
|
|
|
write_buffer = HeapAlloc(GetProcessHeap(), 0, write_buffer_len);
|
|
|
|
if (!write_buffer) return;
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, szLine, len, write_buffer, write_buffer_len, NULL, NULL);
|
|
|
|
WriteFile(hFile, write_buffer, len, &dwBytesWritten, NULL);
|
|
|
|
HeapFree(GetProcessHeap(), 0, write_buffer);
|
|
|
|
break;
|
|
|
|
case ENCODING_UTF8:
|
|
|
|
write_buffer_len = WideCharToMultiByte(CP_UTF8, 0, szLine, len, NULL, 0, NULL, NULL);
|
|
|
|
write_buffer = HeapAlloc(GetProcessHeap(), 0, write_buffer_len);
|
|
|
|
if (!write_buffer) return;
|
|
|
|
len = WideCharToMultiByte(CP_UTF8, 0, szLine, len, write_buffer, write_buffer_len, NULL, NULL);
|
|
|
|
WriteFile(hFile, write_buffer, len, &dwBytesWritten, NULL);
|
|
|
|
HeapFree(GetProcessHeap(), 0, write_buffer);
|
|
|
|
break;
|
|
|
|
case ENCODING_UTF16LE:
|
|
|
|
WriteFile(hFile, szLine, len * sizeof(WCHAR), &dwBytesWritten, NULL);
|
|
|
|
break;
|
|
|
|
case ENCODING_UTF16BE:
|
|
|
|
PROFILE_ByteSwapShortBuffer(szLine, len);
|
|
|
|
WriteFile(hFile, szLine, len * sizeof(WCHAR), &dwBytesWritten, NULL);
|
|
|
|
break;
|
|
|
|
default:
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
FIXME("encoding type %d not implemented\n", encoding);
|
2004-11-29 00:08:59 +00:00
|
|
|
}
|
|
|
|
}
|
2004-01-30 21:48:09 +00:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* PROFILE_Save
|
|
|
|
*
|
|
|
|
* Save a profile tree to a file.
|
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
static void PROFILE_Save( HANDLE hFile, const PROFILESECTION *section, ENCODING encoding )
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
PROFILEKEY *key;
|
|
|
|
WCHAR *buffer, *p;
|
|
|
|
|
|
|
|
PROFILE_WriteMarker(hFile, encoding);
|
2004-01-30 21:48:09 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
for ( ; section; section = section->next)
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2009-04-17 16:40:31 +00:00
|
|
|
int len = 0;
|
2004-11-29 00:08:59 +00:00
|
|
|
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
if (section->name[0]) len += strlenW(section->name) + 4;
|
2004-11-29 00:08:59 +00:00
|
|
|
|
|
|
|
for (key = section->key; key; key = key->next)
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
len += strlenW(key->name) + 2;
|
|
|
|
if (key->value) len += strlenW(key->value) + 1;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
2004-11-29 00:08:59 +00:00
|
|
|
|
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
2005-11-12 01:11:28 +00:00
|
|
|
if (!buffer) return;
|
2004-11-29 00:08:59 +00:00
|
|
|
|
|
|
|
p = buffer;
|
|
|
|
if (section->name[0])
|
|
|
|
{
|
2009-04-17 16:40:31 +00:00
|
|
|
*p++ = '[';
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
strcpyW( p, section->name );
|
|
|
|
p += strlenW(p);
|
2009-04-17 16:40:31 +00:00
|
|
|
*p++ = ']';
|
|
|
|
*p++ = '\r';
|
|
|
|
*p++ = '\n';
|
2004-11-29 00:08:59 +00:00
|
|
|
}
|
2009-04-13 18:53:56 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
for (key = section->key; key; key = key->next)
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
strcpyW( p, key->name );
|
|
|
|
p += strlenW(p);
|
2004-11-29 00:08:59 +00:00
|
|
|
if (key->value)
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
*p++ = '=';
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
strcpyW( p, key->value );
|
|
|
|
p += strlenW(p);
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
2004-11-29 00:08:59 +00:00
|
|
|
*p++ = '\r';
|
|
|
|
*p++ = '\n';
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
2004-11-29 00:08:59 +00:00
|
|
|
PROFILE_WriteLine( hFile, buffer, len, encoding );
|
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* PROFILE_Free
|
|
|
|
*
|
|
|
|
* Free a profile tree.
|
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
static void PROFILE_Free( PROFILESECTION *section )
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
PROFILESECTION *next_section;
|
|
|
|
PROFILEKEY *key, *next_key;
|
2004-01-30 21:48:09 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
for ( ; section; section = next_section)
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
for (key = section->key; key; key = next_key)
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
next_key = key->next;
|
2005-11-12 01:11:28 +00:00
|
|
|
HeapFree( GetProcessHeap(), 0, key->value );
|
2004-11-29 00:08:59 +00:00
|
|
|
HeapFree( GetProcessHeap(), 0, key );
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
2004-11-29 00:08:59 +00:00
|
|
|
next_section = section->next;
|
|
|
|
HeapFree( GetProcessHeap(), 0, section );
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-27 18:46:45 +00:00
|
|
|
/* returns TRUE if a whitespace character, else FALSE */
|
|
|
|
static inline BOOL PROFILE_isspaceW(WCHAR c)
|
2004-11-29 00:08:59 +00:00
|
|
|
{
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
/* ^Z (DOS EOF) is a space too (found on CD-ROMs) */
|
|
|
|
return isspaceW(c) || c == 0x1a;
|
2004-11-29 00:08:59 +00:00
|
|
|
}
|
|
|
|
|
2013-12-22 18:10:41 +00:00
|
|
|
static inline ENCODING PROFILE_DetectTextEncoding(void * buffer, int * len)
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
int flags = IS_TEXT_UNICODE_SIGNATURE |
|
|
|
|
IS_TEXT_UNICODE_REVERSE_SIGNATURE |
|
|
|
|
IS_TEXT_UNICODE_ODD_LENGTH;
|
2009-05-09 12:40:35 +00:00
|
|
|
if (*len >= sizeof(bom_utf8) && !memcmp(buffer, bom_utf8, sizeof(bom_utf8)))
|
2004-11-29 00:08:59 +00:00
|
|
|
{
|
|
|
|
*len = sizeof(bom_utf8);
|
|
|
|
return ENCODING_UTF8;
|
|
|
|
}
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
RtlIsTextUnicode(buffer, *len, &flags);
|
2004-11-29 00:08:59 +00:00
|
|
|
if (flags & IS_TEXT_UNICODE_SIGNATURE)
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
*len = sizeof(WCHAR);
|
|
|
|
return ENCODING_UTF16LE;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
2004-11-29 00:08:59 +00:00
|
|
|
if (flags & IS_TEXT_UNICODE_REVERSE_SIGNATURE)
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
*len = sizeof(WCHAR);
|
|
|
|
return ENCODING_UTF16BE;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
2004-11-29 00:08:59 +00:00
|
|
|
*len = 0;
|
|
|
|
return ENCODING_ANSI;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* PROFILE_Load
|
|
|
|
*
|
|
|
|
* Load a profile tree from a file.
|
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
static PROFILESECTION *PROFILE_Load(HANDLE hFile, ENCODING * pEncoding)
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2008-12-27 08:34:30 +00:00
|
|
|
void *buffer_base, *pBuffer;
|
2004-11-29 00:08:59 +00:00
|
|
|
WCHAR * szFile;
|
|
|
|
const WCHAR *szLineStart, *szLineEnd;
|
2005-11-12 01:11:28 +00:00
|
|
|
const WCHAR *szValueStart, *szEnd, *next_line;
|
2004-11-29 00:08:59 +00:00
|
|
|
int line = 0, len;
|
|
|
|
PROFILESECTION *section, *first_section;
|
|
|
|
PROFILESECTION **next_section;
|
|
|
|
PROFILEKEY *key, *prev_key, **next_key;
|
|
|
|
DWORD dwFileSize;
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
|
|
|
|
TRACE("%p\n", hFile);
|
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
dwFileSize = GetFileSize(hFile, NULL);
|
2009-05-09 12:40:35 +00:00
|
|
|
if (dwFileSize == INVALID_FILE_SIZE || dwFileSize == 0)
|
2004-11-29 00:08:59 +00:00
|
|
|
return NULL;
|
|
|
|
|
2008-12-27 08:34:30 +00:00
|
|
|
buffer_base = HeapAlloc(GetProcessHeap(), 0 , dwFileSize);
|
2009-12-05 19:35:03 +00:00
|
|
|
if (!buffer_base) return NULL;
|
|
|
|
|
2008-12-27 08:34:30 +00:00
|
|
|
if (!ReadFile(hFile, buffer_base, dwFileSize, &dwFileSize, NULL))
|
2004-11-29 00:08:59 +00:00
|
|
|
{
|
2008-12-27 08:34:30 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, buffer_base);
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
WARN("Error %d reading file\n", GetLastError());
|
2004-11-29 00:08:59 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
len = dwFileSize;
|
2008-12-27 08:34:30 +00:00
|
|
|
*pEncoding = PROFILE_DetectTextEncoding(buffer_base, &len);
|
2004-11-29 00:08:59 +00:00
|
|
|
/* len is set to the number of bytes in the character marker.
|
|
|
|
* we want to skip these bytes */
|
2008-12-27 08:34:30 +00:00
|
|
|
pBuffer = (char *)buffer_base + len;
|
2004-11-29 00:08:59 +00:00
|
|
|
dwFileSize -= len;
|
|
|
|
switch (*pEncoding)
|
|
|
|
{
|
|
|
|
case ENCODING_ANSI:
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
TRACE("ANSI encoding\n");
|
2004-11-29 00:08:59 +00:00
|
|
|
|
2009-05-09 12:40:35 +00:00
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, pBuffer, dwFileSize, NULL, 0);
|
2004-11-29 00:08:59 +00:00
|
|
|
szFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
if (!szFile)
|
2004-10-09 18:46:41 +00:00
|
|
|
{
|
2008-12-27 08:34:30 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, buffer_base);
|
2004-11-29 00:08:59 +00:00
|
|
|
return NULL;
|
2004-10-09 18:46:41 +00:00
|
|
|
}
|
2009-05-09 12:40:35 +00:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, pBuffer, dwFileSize, szFile, len);
|
2004-11-29 00:08:59 +00:00
|
|
|
szEnd = szFile + len;
|
|
|
|
break;
|
|
|
|
case ENCODING_UTF8:
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
TRACE("UTF8 encoding\n");
|
2004-12-13 21:16:26 +00:00
|
|
|
|
2009-05-09 12:40:35 +00:00
|
|
|
len = MultiByteToWideChar(CP_UTF8, 0, pBuffer, dwFileSize, NULL, 0);
|
2004-11-29 00:08:59 +00:00
|
|
|
szFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
if (!szFile)
|
2004-10-09 18:46:41 +00:00
|
|
|
{
|
2008-12-27 08:34:30 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, buffer_base);
|
2004-11-29 00:08:59 +00:00
|
|
|
return NULL;
|
2004-10-09 18:46:41 +00:00
|
|
|
}
|
2009-05-09 12:40:35 +00:00
|
|
|
MultiByteToWideChar(CP_UTF8, 0, pBuffer, dwFileSize, szFile, len);
|
2004-11-29 00:08:59 +00:00
|
|
|
szEnd = szFile + len;
|
|
|
|
break;
|
|
|
|
case ENCODING_UTF16LE:
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
TRACE("UTF16 Little Endian encoding\n");
|
2009-08-24 12:17:02 +00:00
|
|
|
szFile = pBuffer;
|
2004-11-29 00:08:59 +00:00
|
|
|
szEnd = (WCHAR *)((char *)pBuffer + dwFileSize);
|
|
|
|
break;
|
|
|
|
case ENCODING_UTF16BE:
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
TRACE("UTF16 Big Endian encoding\n");
|
2009-08-24 12:17:02 +00:00
|
|
|
szFile = pBuffer;
|
2004-11-29 00:08:59 +00:00
|
|
|
szEnd = (WCHAR *)((char *)pBuffer + dwFileSize);
|
|
|
|
PROFILE_ByteSwapShortBuffer(szFile, dwFileSize / sizeof(WCHAR));
|
|
|
|
break;
|
|
|
|
default:
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
FIXME("encoding type %d not implemented\n", *pEncoding);
|
2008-12-27 08:34:30 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, buffer_base);
|
2004-11-29 00:08:59 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
first_section = HeapAlloc( GetProcessHeap(), 0, sizeof(*section) );
|
2009-12-05 19:35:03 +00:00
|
|
|
if(first_section == NULL)
|
2004-11-29 00:08:59 +00:00
|
|
|
{
|
|
|
|
if (szFile != pBuffer)
|
|
|
|
HeapFree(GetProcessHeap(), 0, szFile);
|
2008-12-27 08:34:30 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, buffer_base);
|
2004-11-29 00:08:59 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
first_section->name[0] = 0;
|
|
|
|
first_section->key = NULL;
|
|
|
|
first_section->next = NULL;
|
|
|
|
next_section = &first_section->next;
|
|
|
|
next_key = &first_section->key;
|
|
|
|
prev_key = NULL;
|
2005-11-12 01:11:28 +00:00
|
|
|
next_line = szFile;
|
2004-11-29 00:08:59 +00:00
|
|
|
|
2005-11-12 01:11:28 +00:00
|
|
|
while (next_line < szEnd)
|
2004-11-29 00:08:59 +00:00
|
|
|
{
|
2005-11-12 01:11:28 +00:00
|
|
|
szLineStart = next_line;
|
|
|
|
next_line = memchrW(szLineStart, '\n', szEnd - szLineStart);
|
2008-12-27 08:34:30 +00:00
|
|
|
if (!next_line) next_line = memchrW(szLineStart, '\r', szEnd - szLineStart);
|
2005-11-12 01:11:28 +00:00
|
|
|
if (!next_line) next_line = szEnd;
|
|
|
|
else next_line++;
|
|
|
|
szLineEnd = next_line;
|
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
line++;
|
2004-12-13 21:16:26 +00:00
|
|
|
|
2005-11-12 01:11:28 +00:00
|
|
|
/* get rid of white space */
|
|
|
|
while (szLineStart < szLineEnd && PROFILE_isspaceW(*szLineStart)) szLineStart++;
|
2008-12-27 08:34:30 +00:00
|
|
|
while ((szLineEnd > szLineStart) && PROFILE_isspaceW(szLineEnd[-1])) szLineEnd--;
|
2004-12-13 21:16:26 +00:00
|
|
|
|
2009-10-25 17:28:35 +00:00
|
|
|
if (szLineStart >= szLineEnd) continue;
|
2004-11-29 00:08:59 +00:00
|
|
|
|
|
|
|
if (*szLineStart == '[') /* section start */
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
const WCHAR * szSectionEnd;
|
|
|
|
if (!(szSectionEnd = memrchrW( szLineStart, ']', szLineEnd - szLineStart )))
|
|
|
|
{
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
WARN("Invalid section header at line %d: %s\n",
|
|
|
|
line, debugstr_wn(szLineStart, (int)(szLineEnd - szLineStart)) );
|
2004-11-29 00:08:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
szLineStart++;
|
|
|
|
len = (int)(szSectionEnd - szLineStart);
|
|
|
|
/* no need to allocate +1 for NULL terminating character as
|
|
|
|
* already included in structure */
|
|
|
|
if (!(section = HeapAlloc( GetProcessHeap(), 0, sizeof(*section) + len * sizeof(WCHAR) )))
|
|
|
|
break;
|
|
|
|
memcpy(section->name, szLineStart, len * sizeof(WCHAR));
|
|
|
|
section->name[len] = '\0';
|
|
|
|
section->key = NULL;
|
|
|
|
section->next = NULL;
|
|
|
|
*next_section = section;
|
|
|
|
next_section = §ion->next;
|
|
|
|
next_key = §ion->key;
|
|
|
|
prev_key = NULL;
|
|
|
|
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
TRACE("New section: %s\n", debugstr_w(section->name));
|
2004-11-29 00:08:59 +00:00
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
2004-11-29 00:08:59 +00:00
|
|
|
|
|
|
|
/* get rid of white space after the name and before the start
|
|
|
|
* of the value */
|
2005-11-12 01:11:28 +00:00
|
|
|
len = szLineEnd - szLineStart;
|
|
|
|
if ((szValueStart = memchrW( szLineStart, '=', szLineEnd - szLineStart )) != NULL)
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2005-11-12 01:11:28 +00:00
|
|
|
const WCHAR *szNameEnd = szValueStart;
|
|
|
|
while ((szNameEnd > szLineStart) && PROFILE_isspaceW(szNameEnd[-1])) szNameEnd--;
|
|
|
|
len = szNameEnd - szLineStart;
|
2004-11-29 00:08:59 +00:00
|
|
|
szValueStart++;
|
2005-11-12 01:11:28 +00:00
|
|
|
while (szValueStart < szLineEnd && PROFILE_isspaceW(*szValueStart)) szValueStart++;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
if (len || !prev_key || *prev_key->name)
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
/* no need to allocate +1 for NULL terminating character as
|
|
|
|
* already included in structure */
|
|
|
|
if (!(key = HeapAlloc( GetProcessHeap(), 0, sizeof(*key) + len * sizeof(WCHAR) ))) break;
|
|
|
|
memcpy(key->name, szLineStart, len * sizeof(WCHAR));
|
|
|
|
key->name[len] = '\0';
|
|
|
|
if (szValueStart)
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
len = (int)(szLineEnd - szValueStart);
|
|
|
|
key->value = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) );
|
|
|
|
memcpy(key->value, szValueStart, len * sizeof(WCHAR));
|
|
|
|
key->value[len] = '\0';
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
2004-11-29 00:08:59 +00:00
|
|
|
else key->value = NULL;
|
2004-01-30 21:48:09 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
key->next = NULL;
|
|
|
|
*next_key = key;
|
|
|
|
next_key = &key->next;
|
|
|
|
prev_key = key;
|
2004-01-30 21:48:09 +00:00
|
|
|
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
TRACE("New key: name=%s, value=%s\n",
|
2013-12-22 18:10:41 +00:00
|
|
|
debugstr_w(key->name), key->value ? debugstr_w(key->value) : L"(none)");
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
2004-11-29 00:08:59 +00:00
|
|
|
}
|
|
|
|
if (szFile != pBuffer)
|
|
|
|
HeapFree(GetProcessHeap(), 0, szFile);
|
2008-12-27 08:34:30 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, buffer_base);
|
2004-11-29 00:08:59 +00:00
|
|
|
return first_section;
|
|
|
|
}
|
2004-01-30 21:48:09 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* PROFILE_DeleteSection
|
|
|
|
*
|
|
|
|
* Delete a section from a profile tree.
|
|
|
|
*/
|
|
|
|
static BOOL PROFILE_DeleteSection( PROFILESECTION **section, LPCWSTR name )
|
|
|
|
{
|
|
|
|
while (*section)
|
|
|
|
{
|
2015-11-27 18:46:45 +00:00
|
|
|
if (!strcmpiW( (*section)->name, name ))
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
PROFILESECTION *to_del = *section;
|
|
|
|
*section = to_del->next;
|
|
|
|
to_del->next = NULL;
|
|
|
|
PROFILE_Free( to_del );
|
|
|
|
return TRUE;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
2004-11-29 00:08:59 +00:00
|
|
|
section = &(*section)->next;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-01-30 21:48:09 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* PROFILE_DeleteKey
|
|
|
|
*
|
|
|
|
* Delete a key from a profile tree.
|
|
|
|
*/
|
|
|
|
static BOOL PROFILE_DeleteKey( PROFILESECTION **section,
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
LPCWSTR section_name, LPCWSTR key_name )
|
2004-11-29 00:08:59 +00:00
|
|
|
{
|
|
|
|
while (*section)
|
|
|
|
{
|
2015-11-27 18:46:45 +00:00
|
|
|
if (!strcmpiW( (*section)->name, section_name ))
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
PROFILEKEY **key = &(*section)->key;
|
|
|
|
while (*key)
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
if (!strcmpiW( (*key)->name, key_name ))
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
PROFILEKEY *to_del = *key;
|
|
|
|
*key = to_del->next;
|
2005-11-12 01:11:28 +00:00
|
|
|
HeapFree( GetProcessHeap(), 0, to_del->value);
|
2004-11-29 00:08:59 +00:00
|
|
|
HeapFree( GetProcessHeap(), 0, to_del );
|
|
|
|
return TRUE;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
2004-11-29 00:08:59 +00:00
|
|
|
key = &(*key)->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
section = &(*section)->next;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-01-30 21:48:09 +00:00
|
|
|
|
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* PROFILE_DeleteAllKeys
|
|
|
|
*
|
|
|
|
* Delete all keys from a profile tree.
|
|
|
|
*/
|
2005-11-12 01:11:28 +00:00
|
|
|
static void PROFILE_DeleteAllKeys( LPCWSTR section_name)
|
2004-11-29 00:08:59 +00:00
|
|
|
{
|
|
|
|
PROFILESECTION **section= &CurProfile->section;
|
|
|
|
while (*section)
|
|
|
|
{
|
2015-11-27 18:46:45 +00:00
|
|
|
if (!strcmpiW( (*section)->name, section_name ))
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
PROFILEKEY **key = &(*section)->key;
|
|
|
|
while (*key)
|
|
|
|
{
|
|
|
|
PROFILEKEY *to_del = *key;
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
*key = to_del->next;
|
2005-11-12 01:11:28 +00:00
|
|
|
HeapFree( GetProcessHeap(), 0, to_del->value);
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
HeapFree( GetProcessHeap(), 0, to_del );
|
|
|
|
CurProfile->changed =TRUE;
|
2004-11-29 00:08:59 +00:00
|
|
|
}
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
2004-11-29 00:08:59 +00:00
|
|
|
section = &(*section)->next;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* PROFILE_Find
|
|
|
|
*
|
|
|
|
* Find a key in a profile tree, optionally creating it.
|
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
static PROFILEKEY *PROFILE_Find( PROFILESECTION **section, LPCWSTR section_name,
|
|
|
|
LPCWSTR key_name, BOOL create, BOOL create_always )
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
LPCWSTR p;
|
2015-11-27 18:46:45 +00:00
|
|
|
int seclen = 0, keylen = 0;
|
2004-01-30 21:48:09 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
while (PROFILE_isspaceW(*section_name)) section_name++;
|
2009-04-13 18:53:56 +00:00
|
|
|
if (*section_name)
|
2015-11-27 18:46:45 +00:00
|
|
|
{
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
p = section_name + strlenW(section_name) - 1;
|
2015-11-27 18:46:45 +00:00
|
|
|
while ((p > section_name) && PROFILE_isspaceW(*p)) p--;
|
|
|
|
seclen = p - section_name + 1;
|
|
|
|
}
|
2004-01-30 21:48:09 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
while (PROFILE_isspaceW(*key_name)) key_name++;
|
2009-04-13 18:53:56 +00:00
|
|
|
if (*key_name)
|
2015-11-27 18:46:45 +00:00
|
|
|
{
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
p = key_name + strlenW(key_name) - 1;
|
2015-11-27 18:46:45 +00:00
|
|
|
while ((p > key_name) && PROFILE_isspaceW(*p)) p--;
|
|
|
|
keylen = p - key_name + 1;
|
|
|
|
}
|
2004-01-30 21:48:09 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
while (*section)
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2015-11-27 18:46:45 +00:00
|
|
|
if (!strncmpiW((*section)->name, section_name, seclen) &&
|
|
|
|
((*section)->name)[seclen] == '\0')
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
PROFILEKEY **key = &(*section)->key;
|
2004-01-30 21:48:09 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
while (*key)
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
/* If create_always is FALSE then we check if the keyname
|
|
|
|
* already exists. Otherwise we add it regardless of its
|
|
|
|
* existence, to allow keys to be added more than once in
|
|
|
|
* some cases.
|
|
|
|
*/
|
|
|
|
if(!create_always)
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
if ( (!(strncmpiW( (*key)->name, key_name, keylen )))
|
2004-11-29 00:08:59 +00:00
|
|
|
&& (((*key)->name)[keylen] == '\0') )
|
|
|
|
return *key;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
2004-11-29 00:08:59 +00:00
|
|
|
key = &(*key)->next;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
if (!create) return NULL;
|
|
|
|
if (!(*key = HeapAlloc( GetProcessHeap(), 0, sizeof(PROFILEKEY) + strlenW(key_name) * sizeof(WCHAR) )))
|
2004-11-29 00:08:59 +00:00
|
|
|
return NULL;
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
strcpyW( (*key)->name, key_name );
|
2004-11-29 00:08:59 +00:00
|
|
|
(*key)->value = NULL;
|
|
|
|
(*key)->next = NULL;
|
|
|
|
return *key;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
2004-11-29 00:08:59 +00:00
|
|
|
section = &(*section)->next;
|
|
|
|
}
|
|
|
|
if (!create) return NULL;
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
*section = HeapAlloc( GetProcessHeap(), 0, sizeof(PROFILESECTION) + strlenW(section_name) * sizeof(WCHAR) );
|
2004-11-29 00:08:59 +00:00
|
|
|
if(*section == NULL) return NULL;
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
strcpyW( (*section)->name, section_name );
|
2004-11-29 00:08:59 +00:00
|
|
|
(*section)->next = NULL;
|
|
|
|
if (!((*section)->key = HeapAlloc( GetProcessHeap(), 0,
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
sizeof(PROFILEKEY) + strlenW(key_name) * sizeof(WCHAR) )))
|
2004-11-29 00:08:59 +00:00
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, *section);
|
|
|
|
return NULL;
|
|
|
|
}
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
strcpyW( (*section)->key->name, key_name );
|
2004-11-29 00:08:59 +00:00
|
|
|
(*section)->key->value = NULL;
|
|
|
|
(*section)->key->next = NULL;
|
|
|
|
return (*section)->key;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* PROFILE_FlushFile
|
|
|
|
*
|
|
|
|
* Flush the current profile to disk if changed.
|
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
static BOOL PROFILE_FlushFile(void)
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
HANDLE hFile = NULL;
|
|
|
|
FILETIME LastWriteTime;
|
2004-01-30 21:48:09 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
if(!CurProfile)
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
WARN("No current profile!\n");
|
2004-11-29 00:08:59 +00:00
|
|
|
return FALSE;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
if (!CurProfile->changed) return TRUE;
|
2004-01-30 21:48:09 +00:00
|
|
|
|
2008-12-27 08:34:30 +00:00
|
|
|
hFile = CreateFileW(CurProfile->filename, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
|
|
|
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
2004-01-30 21:48:09 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
if (hFile == INVALID_HANDLE_VALUE)
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
WARN("could not save profile file %s (error was %d)\n", debugstr_w(CurProfile->filename), GetLastError());
|
2004-11-29 00:08:59 +00:00
|
|
|
return FALSE;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
|
|
|
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
TRACE("Saving %s\n", debugstr_w(CurProfile->filename));
|
2004-11-29 00:08:59 +00:00
|
|
|
PROFILE_Save( hFile, CurProfile->section, CurProfile->encoding );
|
|
|
|
if(GetFileTime(hFile, NULL, NULL, &LastWriteTime))
|
|
|
|
CurProfile->LastWriteTime=LastWriteTime;
|
|
|
|
CloseHandle( hFile );
|
|
|
|
CurProfile->changed = FALSE;
|
|
|
|
return TRUE;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* PROFILE_ReleaseFile
|
|
|
|
*
|
|
|
|
* Flush the current profile to disk and remove it from the cache.
|
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
static void PROFILE_ReleaseFile(void)
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
PROFILE_FlushFile();
|
|
|
|
PROFILE_Free( CurProfile->section );
|
2005-11-12 01:11:28 +00:00
|
|
|
HeapFree( GetProcessHeap(), 0, CurProfile->filename );
|
2004-11-29 00:08:59 +00:00
|
|
|
CurProfile->changed = FALSE;
|
|
|
|
CurProfile->section = NULL;
|
|
|
|
CurProfile->filename = NULL;
|
|
|
|
CurProfile->encoding = ENCODING_ANSI;
|
|
|
|
ZeroMemory(&CurProfile->LastWriteTime, sizeof(CurProfile->LastWriteTime));
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
|
|
|
|
2008-12-27 08:34:30 +00:00
|
|
|
/***********************************************************************
|
|
|
|
*
|
|
|
|
* Compares a file time with the current time. If the file time is
|
|
|
|
* at least 2.1 seconds in the past, return true.
|
|
|
|
*
|
|
|
|
* Intended as cache safety measure: The time resolution on FAT is
|
|
|
|
* two seconds, so files that are not at least two seconds old might
|
|
|
|
* keep their time even on modification, so don't cache them.
|
|
|
|
*/
|
|
|
|
static BOOL is_not_current(FILETIME * ft)
|
|
|
|
{
|
|
|
|
FILETIME Now;
|
|
|
|
LONGLONG ftll, nowll;
|
|
|
|
GetSystemTimeAsFileTime(&Now);
|
|
|
|
ftll = ((LONGLONG)ft->dwHighDateTime << 32) + ft->dwLowDateTime;
|
|
|
|
nowll = ((LONGLONG)Now.dwHighDateTime << 32) + Now.dwLowDateTime;
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
TRACE("%08x;%08x\n",(unsigned)ftll+21000000,(unsigned)nowll);
|
2008-12-27 08:34:30 +00:00
|
|
|
return ftll + 21000000 < nowll;
|
|
|
|
}
|
|
|
|
|
2004-01-30 21:48:09 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* PROFILE_Open
|
|
|
|
*
|
|
|
|
* Open a profile file, checking the cached file first.
|
|
|
|
*/
|
2008-12-27 08:34:30 +00:00
|
|
|
static BOOL PROFILE_Open( LPCWSTR filename, BOOL write_access )
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
HANDLE hFile = INVALID_HANDLE_VALUE;
|
|
|
|
FILETIME LastWriteTime;
|
|
|
|
int i,j;
|
|
|
|
PROFILE *tempProfile;
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
ZeroMemory(&LastWriteTime, sizeof(LastWriteTime));
|
|
|
|
|
|
|
|
/* First time around */
|
|
|
|
|
|
|
|
if(!CurProfile)
|
|
|
|
for(i=0;i<N_CACHED_PROFILES;i++)
|
|
|
|
{
|
|
|
|
MRUProfile[i]=HeapAlloc( GetProcessHeap(), 0, sizeof(PROFILE) );
|
|
|
|
if(MRUProfile[i] == NULL) break;
|
|
|
|
MRUProfile[i]->changed=FALSE;
|
|
|
|
MRUProfile[i]->section=NULL;
|
|
|
|
MRUProfile[i]->filename=NULL;
|
|
|
|
MRUProfile[i]->encoding=ENCODING_ANSI;
|
|
|
|
ZeroMemory(&MRUProfile[i]->LastWriteTime, sizeof(FILETIME));
|
|
|
|
}
|
|
|
|
|
2008-09-13 08:23:32 +00:00
|
|
|
if (!filename)
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
filename = wininiW;
|
2008-09-13 08:23:32 +00:00
|
|
|
|
2013-06-07 20:40:34 +00:00
|
|
|
if ((RtlDetermineDosPathNameType_U(filename) == RtlPathTypeRelative) &&
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
!strchrW(filename, '\\') && !strchrW(filename, '/'))
|
2004-11-29 00:08:59 +00:00
|
|
|
{
|
|
|
|
static const WCHAR wszSeparator[] = {'\\', 0};
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
WCHAR windirW[MAX_PATH];
|
|
|
|
GetWindowsDirectoryW( windirW, MAX_PATH );
|
|
|
|
strcpyW(buffer, windirW);
|
|
|
|
strcatW(buffer, wszSeparator);
|
|
|
|
strcatW(buffer, filename);
|
2004-11-29 00:08:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LPWSTR dummy;
|
|
|
|
GetFullPathNameW(filename, sizeof(buffer)/sizeof(buffer[0]), buffer, &dummy);
|
|
|
|
}
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
|
|
|
|
TRACE("path: %s\n", debugstr_w(buffer));
|
2004-12-13 21:16:26 +00:00
|
|
|
|
2008-12-27 08:34:30 +00:00
|
|
|
hFile = CreateFileW(buffer, GENERIC_READ | (write_access ? GENERIC_WRITE : 0),
|
|
|
|
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL,
|
|
|
|
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
2004-12-13 21:16:26 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
if ((hFile == INVALID_HANDLE_VALUE) && (GetLastError() != ERROR_FILE_NOT_FOUND))
|
|
|
|
{
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
WARN("Error %d opening file %s\n", GetLastError(), debugstr_w(buffer));
|
2004-11-29 00:08:59 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
for(i=0;i<N_CACHED_PROFILES;i++)
|
2004-11-29 00:08:59 +00:00
|
|
|
{
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
if ((MRUProfile[i]->filename && !strcmpiW( buffer, MRUProfile[i]->filename )))
|
|
|
|
{
|
|
|
|
TRACE("MRU Filename: %s, new filename: %s\n", debugstr_w(MRUProfile[i]->filename), debugstr_w(buffer));
|
|
|
|
if(i)
|
|
|
|
{
|
|
|
|
PROFILE_FlushFile();
|
|
|
|
tempProfile=MRUProfile[i];
|
|
|
|
for(j=i;j>0;j--)
|
|
|
|
MRUProfile[j]=MRUProfile[j-1];
|
|
|
|
CurProfile=tempProfile;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hFile != INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
GetFileTime(hFile, NULL, NULL, &LastWriteTime);
|
|
|
|
if (!memcmp( &CurProfile->LastWriteTime, &LastWriteTime, sizeof(FILETIME) ) &&
|
|
|
|
is_not_current(&LastWriteTime))
|
|
|
|
TRACE("(%s): already opened (mru=%d)\n",
|
|
|
|
debugstr_w(buffer), i);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TRACE("(%s): already opened, needs refreshing (mru=%d)\n",
|
|
|
|
debugstr_w(buffer), i);
|
|
|
|
PROFILE_Free(CurProfile->section);
|
|
|
|
CurProfile->section = PROFILE_Load(hFile, &CurProfile->encoding);
|
|
|
|
CurProfile->LastWriteTime = LastWriteTime;
|
|
|
|
}
|
|
|
|
CloseHandle(hFile);
|
2013-05-09 21:04:49 +00:00
|
|
|
return TRUE;
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
}
|
|
|
|
else TRACE("(%s): already opened, not yet created (mru=%d)\n",
|
|
|
|
debugstr_w(buffer), i);
|
|
|
|
}
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/* Flush the old current profile */
|
|
|
|
PROFILE_FlushFile();
|
2004-01-30 21:48:09 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/* Make the oldest profile the current one only in order to get rid of it */
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
if(i==N_CACHED_PROFILES)
|
2004-11-29 00:08:59 +00:00
|
|
|
{
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
tempProfile=MRUProfile[N_CACHED_PROFILES-1];
|
|
|
|
for(i=N_CACHED_PROFILES-1;i>0;i--)
|
|
|
|
MRUProfile[i]=MRUProfile[i-1];
|
2004-11-29 00:08:59 +00:00
|
|
|
CurProfile=tempProfile;
|
|
|
|
}
|
2009-12-05 19:35:03 +00:00
|
|
|
if(CurProfile->filename) PROFILE_ReleaseFile();
|
2004-01-30 21:48:09 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/* OK, now that CurProfile is definitely free we assign it our new file */
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
CurProfile->filename = HeapAlloc( GetProcessHeap(), 0, (strlenW(buffer)+1) * sizeof(WCHAR) );
|
|
|
|
strcpyW( CurProfile->filename, buffer );
|
2004-01-30 21:48:09 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
if (hFile != INVALID_HANDLE_VALUE)
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
CurProfile->section = PROFILE_Load(hFile, &CurProfile->encoding);
|
|
|
|
GetFileTime(hFile, NULL, NULL, &CurProfile->LastWriteTime);
|
|
|
|
CloseHandle(hFile);
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
2004-11-29 00:08:59 +00:00
|
|
|
else
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
/* Does not exist yet, we will create it in PROFILE_FlushFile */
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
WARN("profile file %s not found\n", debugstr_w(buffer) );
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
2004-11-29 00:08:59 +00:00
|
|
|
return TRUE;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* PROFILE_GetSection
|
|
|
|
*
|
|
|
|
* Returns all keys of a section.
|
2004-11-29 00:08:59 +00:00
|
|
|
* If return_values is TRUE, also include the corresponding values.
|
2004-01-30 21:48:09 +00:00
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
static INT PROFILE_GetSection( PROFILESECTION *section, LPCWSTR section_name,
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
LPWSTR buffer, DWORD len, BOOL return_values )
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
PROFILEKEY *key;
|
2004-01-30 21:48:09 +00:00
|
|
|
|
2009-10-25 17:28:35 +00:00
|
|
|
if(!buffer) return 0;
|
2004-01-30 21:48:09 +00:00
|
|
|
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
TRACE("%s,%p,%u\n", debugstr_w(section_name), buffer, len);
|
2004-01-30 21:48:09 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
while (section)
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2015-11-27 18:46:45 +00:00
|
|
|
if (!strcmpiW( section->name, section_name ))
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
UINT oldlen = len;
|
|
|
|
for (key = section->key; key; key = key->next)
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2005-11-12 01:11:28 +00:00
|
|
|
if (len <= 2) break;
|
|
|
|
if (!*key->name) continue; /* Skip empty lines */
|
|
|
|
if (IS_ENTRY_COMMENT(key->name)) continue; /* Skip comments */
|
2009-10-25 17:28:35 +00:00
|
|
|
if (!return_values && !key->value) continue; /* Skip lines w.o. '=' */
|
2004-11-29 00:08:59 +00:00
|
|
|
PROFILE_CopyEntry( buffer, key->name, len - 1, 0 );
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
len -= strlenW(buffer) + 1;
|
|
|
|
buffer += strlenW(buffer) + 1;
|
|
|
|
if (len < 2)
|
|
|
|
break;
|
|
|
|
if (return_values && key->value) {
|
|
|
|
buffer[-1] = '=';
|
|
|
|
PROFILE_CopyEntry ( buffer, key->value, len - 1, 0 );
|
|
|
|
len -= strlenW(buffer) + 1;
|
|
|
|
buffer += strlenW(buffer) + 1;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
|
|
|
}
|
2004-11-29 00:08:59 +00:00
|
|
|
*buffer = '\0';
|
|
|
|
if (len <= 1)
|
|
|
|
/*If either lpszSection or lpszKey is NULL and the supplied
|
|
|
|
destination buffer is too small to hold all the strings,
|
|
|
|
the last string is truncated and followed by two null characters.
|
|
|
|
In this case, the return value is equal to cchReturnBuffer
|
|
|
|
minus two. */
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
{
|
|
|
|
buffer[-1] = '\0';
|
2004-11-29 00:08:59 +00:00
|
|
|
return oldlen - 2;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
2004-11-29 00:08:59 +00:00
|
|
|
return oldlen - len;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
2004-11-29 00:08:59 +00:00
|
|
|
section = section->next;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
2004-11-29 00:08:59 +00:00
|
|
|
buffer[0] = buffer[1] = '\0';
|
|
|
|
return 0;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/* See GetPrivateProfileSectionNamesA for documentation */
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
static INT PROFILE_GetSectionNames( LPWSTR buffer, DWORD len )
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
LPWSTR buf;
|
2005-11-12 01:11:28 +00:00
|
|
|
UINT buflen,tmplen;
|
2004-11-29 00:08:59 +00:00
|
|
|
PROFILESECTION *section;
|
|
|
|
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
TRACE("(%p, %d)\n", buffer, len);
|
2004-11-29 00:08:59 +00:00
|
|
|
|
|
|
|
if (!buffer || !len)
|
|
|
|
return 0;
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
if (len==1) {
|
|
|
|
*buffer='\0';
|
2004-11-29 00:08:59 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-12 01:11:28 +00:00
|
|
|
buflen=len-1;
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
buf=buffer;
|
2004-11-29 00:08:59 +00:00
|
|
|
section = CurProfile->section;
|
2005-11-12 01:11:28 +00:00
|
|
|
while ((section!=NULL)) {
|
|
|
|
if (section->name[0]) {
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
tmplen = strlenW(section->name)+1;
|
2008-09-13 08:23:32 +00:00
|
|
|
if (tmplen >= buflen) {
|
2005-11-12 01:11:28 +00:00
|
|
|
if (buflen > 0) {
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
memcpy(buf, section->name, (buflen-1) * sizeof(WCHAR));
|
|
|
|
buf += buflen-1;
|
|
|
|
*buf++='\0';
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
2004-11-29 00:08:59 +00:00
|
|
|
*buf='\0';
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
return len-2;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
2005-11-12 01:11:28 +00:00
|
|
|
memcpy(buf, section->name, tmplen * sizeof(WCHAR));
|
|
|
|
buf += tmplen;
|
|
|
|
buflen -= tmplen;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
2004-11-29 00:08:59 +00:00
|
|
|
section = section->next;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
*buf='\0';
|
|
|
|
return buf-buffer;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* PROFILE_GetString
|
|
|
|
*
|
|
|
|
* Get a profile string.
|
2004-11-29 00:08:59 +00:00
|
|
|
*
|
|
|
|
* Tests with GetPrivateProfileString16, W95a,
|
|
|
|
* with filled buffer ("****...") and section "set1" and key_name "1" valid:
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
* section key_name def_val res buffer
|
|
|
|
* "set1" "1" "x" 43 [data]
|
|
|
|
* "set1" "1 " "x" 43 [data] (!)
|
|
|
|
* "set1" " 1 "' "x" 43 [data] (!)
|
|
|
|
* "set1" "" "x" 1 "x"
|
|
|
|
* "set1" "" "x " 1 "x" (!)
|
|
|
|
* "set1" "" " x " 3 " x" (!)
|
|
|
|
* "set1" NULL "x" 6 "1\02\03\0\0"
|
|
|
|
* "set1" "" "x" 1 "x"
|
|
|
|
* NULL "1" "x" 0 "" (!)
|
|
|
|
* "" "1" "x" 1 "x"
|
|
|
|
* NULL NULL "" 0 ""
|
2004-11-29 00:08:59 +00:00
|
|
|
*
|
|
|
|
*
|
2004-01-30 21:48:09 +00:00
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
static INT PROFILE_GetString( LPCWSTR section, LPCWSTR key_name,
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
LPCWSTR def_val, LPWSTR buffer, DWORD len )
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
PROFILEKEY *key = NULL;
|
|
|
|
static const WCHAR empty_strW[] = { 0 };
|
2004-01-30 21:48:09 +00:00
|
|
|
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
if(!buffer || !len) return 0;
|
2004-01-30 21:48:09 +00:00
|
|
|
|
2005-11-12 01:11:28 +00:00
|
|
|
if (!def_val) def_val = empty_strW;
|
2004-11-29 00:08:59 +00:00
|
|
|
if (key_name)
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
key = PROFILE_Find( &CurProfile->section, section, key_name, FALSE, FALSE);
|
|
|
|
PROFILE_CopyEntry( buffer, (key && key->value) ? key->value : def_val,
|
|
|
|
len, TRUE );
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
TRACE("(%s,%s,%s): returning %s\n",
|
|
|
|
debugstr_w(section), debugstr_w(key_name),
|
|
|
|
debugstr_w(def_val), debugstr_w(buffer) );
|
|
|
|
return strlenW( buffer );
|
2004-11-29 00:08:59 +00:00
|
|
|
}
|
|
|
|
/* no "else" here ! */
|
2015-11-27 18:46:45 +00:00
|
|
|
if (section)
|
2004-11-29 00:08:59 +00:00
|
|
|
{
|
2009-10-25 17:28:35 +00:00
|
|
|
INT ret = PROFILE_GetSection(CurProfile->section, section, buffer, len, FALSE);
|
2004-11-29 00:08:59 +00:00
|
|
|
if (!buffer[0]) /* no luck -> def_val */
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
PROFILE_CopyEntry(buffer, def_val, len, TRUE);
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
ret = strlenW(buffer);
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
2004-11-29 00:08:59 +00:00
|
|
|
return ret;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
2004-11-29 00:08:59 +00:00
|
|
|
buffer[0] = '\0';
|
|
|
|
return 0;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
|
|
|
|
2004-01-31 23:52:42 +00:00
|
|
|
|
|
|
|
/***********************************************************************
|
2004-11-29 00:08:59 +00:00
|
|
|
* PROFILE_SetString
|
2004-01-31 23:52:42 +00:00
|
|
|
*
|
2004-11-29 00:08:59 +00:00
|
|
|
* Set a profile string.
|
2004-01-31 23:52:42 +00:00
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
static BOOL PROFILE_SetString( LPCWSTR section_name, LPCWSTR key_name,
|
|
|
|
LPCWSTR value, BOOL create_always )
|
2004-01-31 23:52:42 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
if (!key_name) /* Delete a whole section */
|
2004-01-31 23:52:42 +00:00
|
|
|
{
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
TRACE("(%s)\n", debugstr_w(section_name));
|
2004-11-29 00:08:59 +00:00
|
|
|
CurProfile->changed |= PROFILE_DeleteSection( &CurProfile->section,
|
|
|
|
section_name );
|
|
|
|
return TRUE; /* Even if PROFILE_DeleteSection() has failed,
|
|
|
|
this is not an error on application's level.*/
|
2004-01-31 23:52:42 +00:00
|
|
|
}
|
2004-11-29 00:08:59 +00:00
|
|
|
else if (!value) /* Delete a key */
|
|
|
|
{
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
TRACE("(%s,%s)\n", debugstr_w(section_name), debugstr_w(key_name) );
|
2004-11-29 00:08:59 +00:00
|
|
|
CurProfile->changed |= PROFILE_DeleteKey( &CurProfile->section,
|
|
|
|
section_name, key_name );
|
|
|
|
return TRUE; /* same error handling as above */
|
|
|
|
}
|
|
|
|
else /* Set the key value */
|
|
|
|
{
|
|
|
|
PROFILEKEY *key = PROFILE_Find(&CurProfile->section, section_name,
|
|
|
|
key_name, TRUE, create_always );
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
TRACE("(%s,%s,%s):\n",
|
|
|
|
debugstr_w(section_name), debugstr_w(key_name), debugstr_w(value) );
|
2005-11-12 01:11:28 +00:00
|
|
|
if (!key) return FALSE;
|
2004-01-31 23:52:42 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/* strip the leading spaces. We can safely strip \n\r and
|
|
|
|
* friends too, they should not happen here anyway. */
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
while (PROFILE_isspaceW(*value)) value++;
|
2004-01-31 23:52:42 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
if (key->value)
|
2004-01-31 23:52:42 +00:00
|
|
|
{
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
if (!strcmpW( key->value, value ))
|
2004-01-31 23:52:42 +00:00
|
|
|
{
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
TRACE(" no change needed\n" );
|
2004-11-29 00:08:59 +00:00
|
|
|
return TRUE; /* No change needed */
|
2004-01-31 23:52:42 +00:00
|
|
|
}
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
TRACE(" replacing %s\n", debugstr_w(key->value) );
|
2004-11-29 00:08:59 +00:00
|
|
|
HeapFree( GetProcessHeap(), 0, key->value );
|
2004-01-31 23:52:42 +00:00
|
|
|
}
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
else TRACE(" creating key\n" );
|
|
|
|
key->value = HeapAlloc( GetProcessHeap(), 0, (strlenW(value)+1) * sizeof(WCHAR) );
|
|
|
|
strcpyW( key->value, value );
|
2004-11-29 00:08:59 +00:00
|
|
|
CurProfile->changed = TRUE;
|
2004-01-31 23:52:42 +00:00
|
|
|
}
|
2004-11-29 00:08:59 +00:00
|
|
|
return TRUE;
|
2004-01-31 23:52:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/********************* API functions **********************************/
|
|
|
|
|
|
|
|
|
2004-01-31 23:52:42 +00:00
|
|
|
/***********************************************************************
|
2004-11-29 00:08:59 +00:00
|
|
|
* GetProfileIntA (KERNEL32.@)
|
2004-01-31 23:52:42 +00:00
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
UINT WINAPI GetProfileIntA( LPCSTR section, LPCSTR entry, INT def_val )
|
2004-01-31 23:52:42 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
return GetPrivateProfileIntA( section, entry, def_val, "win.ini" );
|
|
|
|
}
|
2004-01-31 23:52:42 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* GetProfileIntW (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
UINT WINAPI GetProfileIntW( LPCWSTR section, LPCWSTR entry, INT def_val )
|
|
|
|
{
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
return GetPrivateProfileIntW( section, entry, def_val, wininiW );
|
2004-01-31 23:52:42 +00:00
|
|
|
}
|
|
|
|
|
2010-03-16 17:50:04 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* GetPrivateProfileStringW (KERNEL32.@)
|
2004-01-30 21:48:09 +00:00
|
|
|
*/
|
2010-03-16 17:50:04 +00:00
|
|
|
DWORD WINAPI GetPrivateProfileStringW( LPCWSTR section, LPCWSTR entry,
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
LPCWSTR def_val, LPWSTR buffer,
|
|
|
|
DWORD len, LPCWSTR filename )
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
int ret;
|
|
|
|
LPWSTR defval_tmp = NULL;
|
2004-01-30 21:48:09 +00:00
|
|
|
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
TRACE("%s,%s,%s,%p,%u,%s\n", debugstr_w(section), debugstr_w(entry),
|
|
|
|
debugstr_w(def_val), buffer, len, debugstr_w(filename));
|
2004-01-30 21:48:09 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/* strip any trailing ' ' of def_val. */
|
|
|
|
if (def_val)
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
LPCWSTR p = def_val + strlenW(def_val) - 1;
|
2004-12-13 21:16:26 +00:00
|
|
|
|
2008-12-27 08:34:30 +00:00
|
|
|
while (p > def_val && *p == ' ')
|
2004-12-13 21:16:26 +00:00
|
|
|
p--;
|
|
|
|
|
2008-12-27 08:34:30 +00:00
|
|
|
if (p >= def_val)
|
2005-08-21 15:54:48 +00:00
|
|
|
{
|
2015-11-27 18:46:45 +00:00
|
|
|
int vlen = (int)(p - def_val) + 1;
|
2008-12-27 08:34:30 +00:00
|
|
|
|
2015-11-27 18:46:45 +00:00
|
|
|
defval_tmp = HeapAlloc(GetProcessHeap(), 0, (vlen + 1) * sizeof(WCHAR));
|
|
|
|
memcpy(defval_tmp, def_val, vlen * sizeof(WCHAR));
|
|
|
|
defval_tmp[vlen] = '\0';
|
2010-03-16 17:50:04 +00:00
|
|
|
def_val = defval_tmp;
|
2004-12-13 21:16:26 +00:00
|
|
|
}
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
2004-12-13 21:16:26 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
RtlEnterCriticalSection( &PROFILE_CritSect );
|
2004-01-30 21:48:09 +00:00
|
|
|
|
2008-12-27 08:34:30 +00:00
|
|
|
if (PROFILE_Open( filename, FALSE )) {
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
if (section == NULL)
|
2004-11-29 00:08:59 +00:00
|
|
|
ret = PROFILE_GetSectionNames(buffer, len);
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
else
|
|
|
|
/* PROFILE_GetString can handle the 'entry == NULL' case */
|
2010-03-16 17:50:04 +00:00
|
|
|
ret = PROFILE_GetString( section, entry, def_val, buffer, len );
|
2008-12-27 08:34:30 +00:00
|
|
|
} else if (buffer && def_val) {
|
|
|
|
lstrcpynW( buffer, def_val, len );
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
ret = strlenW( buffer );
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
2010-03-16 17:50:04 +00:00
|
|
|
else
|
|
|
|
ret = 0;
|
2004-01-30 21:48:09 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
RtlLeaveCriticalSection( &PROFILE_CritSect );
|
2004-01-30 21:48:09 +00:00
|
|
|
|
2008-12-27 08:34:30 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, defval_tmp);
|
2004-01-30 21:48:09 +00:00
|
|
|
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
TRACE("returning %s, %d\n", debugstr_w(buffer), ret);
|
2004-01-30 21:48:09 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
return ret;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* GetPrivateProfileStringA (KERNEL32.@)
|
2003-07-10 18:50:51 +00:00
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
DWORD WINAPI GetPrivateProfileStringA( LPCSTR section, LPCSTR entry,
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
LPCSTR def_val, LPSTR buffer,
|
|
|
|
DWORD len, LPCSTR filename )
|
2001-03-31 01:17:30 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
UNICODE_STRING sectionW, entryW, def_valW, filenameW;
|
|
|
|
LPWSTR bufferW;
|
|
|
|
INT 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 = GetPrivateProfileStringW( sectionW.Buffer, entryW.Buffer,
|
|
|
|
def_valW.Buffer, bufferW, len,
|
|
|
|
filenameW.Buffer);
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
if (len && buffer)
|
2004-11-29 00:08:59 +00:00
|
|
|
{
|
2009-12-05 19:35:03 +00:00
|
|
|
if (retW)
|
2004-11-29 00:08:59 +00:00
|
|
|
{
|
2009-12-05 19:35:03 +00:00
|
|
|
ret = WideCharToMultiByte(CP_ACP, 0, bufferW, retW, buffer, len - 1, NULL, NULL);
|
|
|
|
if (!ret)
|
|
|
|
ret = len - 1;
|
2004-11-29 00:08:59 +00:00
|
|
|
}
|
2009-12-05 19:35:03 +00:00
|
|
|
buffer[ret] = 0;
|
2004-11-29 00:08:59 +00:00
|
|
|
}
|
2001-03-31 01:17:30 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
RtlFreeUnicodeString(§ionW);
|
|
|
|
RtlFreeUnicodeString(&entryW);
|
|
|
|
RtlFreeUnicodeString(&def_valW);
|
|
|
|
RtlFreeUnicodeString(&filenameW);
|
2005-11-12 01:11:28 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, bufferW);
|
2004-11-29 00:08:59 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2001-06-07 21:27:45 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* GetProfileStringA (KERNEL32.@)
|
2003-07-10 18:50:51 +00:00
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
DWORD WINAPI GetProfileStringA( LPCSTR section, LPCSTR entry, LPCSTR def_val,
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
LPSTR buffer, DWORD len )
|
2001-03-31 01:17:30 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
return GetPrivateProfileStringA( section, entry, def_val,
|
|
|
|
buffer, len, "win.ini" );
|
2001-03-31 01:17:30 +00:00
|
|
|
}
|
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* GetProfileStringW (KERNEL32.@)
|
2003-07-10 18:50:51 +00:00
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
DWORD WINAPI GetProfileStringW( LPCWSTR section, LPCWSTR entry,
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
LPCWSTR def_val, LPWSTR buffer, DWORD len )
|
2001-03-31 01:17:30 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
return GetPrivateProfileStringW( section, entry, def_val,
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
buffer, len, wininiW );
|
2001-03-31 01:17:30 +00:00
|
|
|
}
|
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* WriteProfileStringA (KERNEL32.@)
|
2003-07-10 18:50:51 +00:00
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
BOOL WINAPI WriteProfileStringA( LPCSTR section, LPCSTR entry,
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
LPCSTR string )
|
2001-03-31 01:17:30 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
return WritePrivateProfileStringA( section, entry, string, "win.ini" );
|
|
|
|
}
|
2004-10-09 18:46:41 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* WriteProfileStringW (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WriteProfileStringW( LPCWSTR section, LPCWSTR entry,
|
|
|
|
LPCWSTR string )
|
|
|
|
{
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
return WritePrivateProfileStringW( section, entry, string, wininiW );
|
2004-11-29 00:08:59 +00:00
|
|
|
}
|
2004-10-09 18:46:41 +00:00
|
|
|
|
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* GetPrivateProfileIntW (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
UINT WINAPI GetPrivateProfileIntW( LPCWSTR section, LPCWSTR entry,
|
|
|
|
INT def_val, LPCWSTR filename )
|
|
|
|
{
|
|
|
|
WCHAR buffer[30];
|
|
|
|
UNICODE_STRING bufferW;
|
|
|
|
ULONG result;
|
|
|
|
|
2013-05-09 21:01:41 +00:00
|
|
|
if (GetPrivateProfileStringW( section, entry, emptystringW,
|
|
|
|
buffer, sizeof(buffer)/sizeof(WCHAR),
|
|
|
|
filename ) == 0)
|
2004-11-29 00:08:59 +00:00
|
|
|
return def_val;
|
|
|
|
|
|
|
|
/* FIXME: if entry can be found but it's empty, then Win16 is
|
|
|
|
* supposed to return 0 instead of def_val ! Difficult/problematic
|
|
|
|
* to implement (every other failure also returns zero buffer),
|
|
|
|
* thus wait until testing framework avail for making sure nothing
|
|
|
|
* else gets broken that way. */
|
2009-10-25 17:28:35 +00:00
|
|
|
if (!buffer[0]) return (UINT)def_val;
|
2004-11-29 00:08:59 +00:00
|
|
|
|
|
|
|
RtlInitUnicodeString( &bufferW, buffer );
|
2009-10-25 17:28:35 +00:00
|
|
|
RtlUnicodeStringToInteger( &bufferW, 0, &result);
|
2004-11-29 00:08:59 +00:00
|
|
|
return result;
|
2001-03-31 01:17:30 +00:00
|
|
|
}
|
|
|
|
|
2004-01-30 21:48:09 +00:00
|
|
|
/***********************************************************************
|
2004-11-29 00:08:59 +00:00
|
|
|
* GetPrivateProfileIntA (KERNEL32.@)
|
2004-01-30 21:48:09 +00:00
|
|
|
*
|
2004-11-29 00:08:59 +00:00
|
|
|
* FIXME: rewrite using unicode
|
2003-07-10 18:50:51 +00:00
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
UINT WINAPI GetPrivateProfileIntA( LPCSTR section, LPCSTR entry,
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
INT def_val, LPCSTR filename )
|
2001-03-31 01:17:30 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
UNICODE_STRING entryW, filenameW, sectionW;
|
|
|
|
UINT res;
|
|
|
|
if(entry) RtlCreateUnicodeStringFromAsciiz(&entryW, entry);
|
|
|
|
else entryW.Buffer = NULL;
|
|
|
|
if(filename) RtlCreateUnicodeStringFromAsciiz(&filenameW, filename);
|
|
|
|
else filenameW.Buffer = NULL;
|
|
|
|
if(section) RtlCreateUnicodeStringFromAsciiz(§ionW, section);
|
|
|
|
else sectionW.Buffer = NULL;
|
|
|
|
res = GetPrivateProfileIntW(sectionW.Buffer, entryW.Buffer, def_val,
|
|
|
|
filenameW.Buffer);
|
|
|
|
RtlFreeUnicodeString(§ionW);
|
|
|
|
RtlFreeUnicodeString(&filenameW);
|
|
|
|
RtlFreeUnicodeString(&entryW);
|
|
|
|
return res;
|
2001-03-31 01:17:30 +00:00
|
|
|
}
|
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* GetPrivateProfileSectionW (KERNEL32.@)
|
2003-07-10 18:50:51 +00:00
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
DWORD WINAPI GetPrivateProfileSectionW( LPCWSTR section, LPWSTR buffer,
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
DWORD len, LPCWSTR filename )
|
2001-03-31 01:17:30 +00:00
|
|
|
{
|
2008-09-13 08:23:32 +00:00
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (!section || !buffer)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return 0;
|
|
|
|
}
|
2004-01-30 21:48:09 +00:00
|
|
|
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
TRACE("(%s, %p, %d, %s)\n", debugstr_w(section), buffer, len, debugstr_w(filename));
|
2004-01-30 21:48:09 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
RtlEnterCriticalSection( &PROFILE_CritSect );
|
2004-01-30 21:48:09 +00:00
|
|
|
|
2008-12-27 08:34:30 +00:00
|
|
|
if (PROFILE_Open( filename, FALSE ))
|
2009-10-25 17:28:35 +00:00
|
|
|
ret = PROFILE_GetSection(CurProfile->section, section, buffer, len, TRUE);
|
2004-01-30 21:48:09 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
RtlLeaveCriticalSection( &PROFILE_CritSect );
|
2001-03-31 01:17:30 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
return ret;
|
2001-03-31 01:17:30 +00:00
|
|
|
}
|
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* GetPrivateProfileSectionA (KERNEL32.@)
|
2003-07-10 18:50:51 +00:00
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
DWORD WINAPI GetPrivateProfileSectionA( LPCSTR section, LPSTR buffer,
|
|
|
|
DWORD len, LPCSTR filename )
|
2001-03-31 01:17:30 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
UNICODE_STRING sectionW, filenameW;
|
|
|
|
LPWSTR bufferW;
|
|
|
|
INT retW, ret = 0;
|
|
|
|
|
2008-09-13 08:23:32 +00:00
|
|
|
if (!section || !buffer)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-10-25 17:28:35 +00:00
|
|
|
bufferW = HeapAlloc(GetProcessHeap(), 0, len * 2 * sizeof(WCHAR));
|
2008-09-13 08:23:32 +00:00
|
|
|
RtlCreateUnicodeStringFromAsciiz(§ionW, section);
|
2004-11-29 00:08:59 +00:00
|
|
|
if (filename) RtlCreateUnicodeStringFromAsciiz(&filenameW, filename);
|
|
|
|
else filenameW.Buffer = NULL;
|
|
|
|
|
2009-10-25 17:28:35 +00:00
|
|
|
retW = GetPrivateProfileSectionW(sectionW.Buffer, bufferW, len * 2, filenameW.Buffer);
|
|
|
|
if (retW)
|
2004-11-29 00:08:59 +00:00
|
|
|
{
|
2009-10-25 17:28:35 +00:00
|
|
|
if (retW == len * 2 - 2) retW++; /* overflow */
|
2008-09-13 08:23:32 +00:00
|
|
|
ret = WideCharToMultiByte(CP_ACP, 0, bufferW, retW + 1, buffer, len, NULL, NULL);
|
2009-10-25 17:28:35 +00:00
|
|
|
if (!ret || ret == len) /* overflow */
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2009-10-25 17:28:35 +00:00
|
|
|
ret = len - 2;
|
2004-11-29 00:08:59 +00:00
|
|
|
buffer[len-2] = 0;
|
|
|
|
buffer[len-1] = 0;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
2009-10-25 17:28:35 +00:00
|
|
|
else ret--;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
2004-11-29 00:08:59 +00:00
|
|
|
else
|
2004-01-30 21:48:09 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
buffer[0] = 0;
|
|
|
|
buffer[1] = 0;
|
2004-01-30 21:48:09 +00:00
|
|
|
}
|
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
RtlFreeUnicodeString(§ionW);
|
|
|
|
RtlFreeUnicodeString(&filenameW);
|
2005-11-12 01:11:28 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, bufferW);
|
2004-11-29 00:08:59 +00:00
|
|
|
return ret;
|
2001-03-31 01:17:30 +00:00
|
|
|
}
|
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* GetProfileSectionA (KERNEL32.@)
|
2003-07-10 18:50:51 +00:00
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
DWORD WINAPI GetProfileSectionA( LPCSTR section, LPSTR buffer, DWORD len )
|
2001-03-31 01:17:30 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
return GetPrivateProfileSectionA( section, buffer, len, "win.ini" );
|
2001-03-31 01:17:30 +00:00
|
|
|
}
|
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* GetProfileSectionW (KERNEL32.@)
|
2003-07-10 18:50:51 +00:00
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
DWORD WINAPI GetProfileSectionW( LPCWSTR section, LPWSTR buffer, DWORD len )
|
2001-03-31 01:17:30 +00:00
|
|
|
{
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
return GetPrivateProfileSectionW( section, buffer, len, wininiW );
|
2001-03-31 01:17:30 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* WritePrivateProfileStringW (KERNEL32.@)
|
2003-07-10 18:50:51 +00:00
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
BOOL WINAPI WritePrivateProfileStringW( LPCWSTR section, LPCWSTR entry,
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
LPCWSTR string, LPCWSTR filename )
|
2001-03-31 01:17:30 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
BOOL ret = FALSE;
|
2001-03-31 01:17:30 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
RtlEnterCriticalSection( &PROFILE_CritSect );
|
2001-03-31 01:17:30 +00:00
|
|
|
|
2005-11-12 01:11:28 +00:00
|
|
|
if (!section && !entry && !string) /* documented "file flush" case */
|
2004-11-29 00:08:59 +00:00
|
|
|
{
|
2008-12-27 08:34:30 +00:00
|
|
|
if (!filename || PROFILE_Open( filename, TRUE ))
|
2004-11-29 00:08:59 +00:00
|
|
|
{
|
2005-11-12 01:11:28 +00:00
|
|
|
if (CurProfile) PROFILE_ReleaseFile(); /* always return FALSE in this case */
|
2004-11-29 00:08:59 +00:00
|
|
|
}
|
2005-11-12 01:11:28 +00:00
|
|
|
}
|
2008-12-27 08:34:30 +00:00
|
|
|
else if (PROFILE_Open( filename, TRUE ))
|
2005-11-12 01:11:28 +00:00
|
|
|
{
|
|
|
|
if (!section) {
|
2009-05-09 12:40:35 +00:00
|
|
|
SetLastError(ERROR_FILE_NOT_FOUND);
|
2005-11-12 01:11:28 +00:00
|
|
|
} else {
|
|
|
|
ret = PROFILE_SetString( section, entry, string, FALSE);
|
|
|
|
PROFILE_FlushFile();
|
2004-12-13 21:16:26 +00:00
|
|
|
}
|
2004-11-29 00:08:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RtlLeaveCriticalSection( &PROFILE_CritSect );
|
|
|
|
return ret;
|
2001-03-31 01:17:30 +00:00
|
|
|
}
|
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* WritePrivateProfileStringA (KERNEL32.@)
|
2003-07-10 18:50:51 +00:00
|
|
|
*/
|
2015-11-27 18:46:45 +00:00
|
|
|
BOOL WINAPI DECLSPEC_HOTPATCH WritePrivateProfileStringA( LPCSTR section, LPCSTR entry,
|
|
|
|
LPCSTR string, LPCSTR filename )
|
2001-03-31 01:17:30 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
UNICODE_STRING sectionW, entryW, stringW, filenameW;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
if (section) RtlCreateUnicodeStringFromAsciiz(§ionW, section);
|
|
|
|
else sectionW.Buffer = NULL;
|
|
|
|
if (entry) RtlCreateUnicodeStringFromAsciiz(&entryW, entry);
|
|
|
|
else entryW.Buffer = NULL;
|
|
|
|
if (string) RtlCreateUnicodeStringFromAsciiz(&stringW, string);
|
|
|
|
else stringW.Buffer = NULL;
|
|
|
|
if (filename) RtlCreateUnicodeStringFromAsciiz(&filenameW, filename);
|
|
|
|
else filenameW.Buffer = NULL;
|
|
|
|
|
|
|
|
ret = WritePrivateProfileStringW(sectionW.Buffer, entryW.Buffer,
|
|
|
|
stringW.Buffer, filenameW.Buffer);
|
|
|
|
RtlFreeUnicodeString(§ionW);
|
|
|
|
RtlFreeUnicodeString(&entryW);
|
|
|
|
RtlFreeUnicodeString(&stringW);
|
|
|
|
RtlFreeUnicodeString(&filenameW);
|
|
|
|
return ret;
|
2001-03-31 01:17:30 +00:00
|
|
|
}
|
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* WritePrivateProfileSectionW (KERNEL32.@)
|
2003-07-10 18:50:51 +00:00
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
BOOL WINAPI WritePrivateProfileSectionW( LPCWSTR section,
|
|
|
|
LPCWSTR string, LPCWSTR filename )
|
2001-03-31 01:17:30 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
BOOL ret = FALSE;
|
|
|
|
LPWSTR p;
|
|
|
|
|
|
|
|
RtlEnterCriticalSection( &PROFILE_CritSect );
|
|
|
|
|
2005-11-12 01:11:28 +00:00
|
|
|
if (!section && !string)
|
2004-12-13 21:16:26 +00:00
|
|
|
{
|
2008-12-27 08:34:30 +00:00
|
|
|
if (!filename || PROFILE_Open( filename, TRUE ))
|
2004-12-13 21:16:26 +00:00
|
|
|
{
|
2005-11-12 01:11:28 +00:00
|
|
|
if (CurProfile) PROFILE_ReleaseFile(); /* always return FALSE in this case */
|
2004-12-13 21:16:26 +00:00
|
|
|
}
|
2009-10-25 17:28:35 +00:00
|
|
|
}
|
2008-12-27 08:34:30 +00:00
|
|
|
else if (PROFILE_Open( filename, TRUE )) {
|
2005-11-12 01:11:28 +00:00
|
|
|
if (!string) {/* delete the named section*/
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
ret = PROFILE_SetString(section,NULL,NULL, FALSE);
|
|
|
|
PROFILE_FlushFile();
|
2005-11-12 01:11:28 +00:00
|
|
|
} else {
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
PROFILE_DeleteAllKeys(section);
|
|
|
|
ret = TRUE;
|
2005-11-12 01:11:28 +00:00
|
|
|
while(*string) {
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
LPWSTR buf = HeapAlloc( GetProcessHeap(), 0, (strlenW(string)+1) * sizeof(WCHAR) );
|
|
|
|
strcpyW( buf, string );
|
|
|
|
if((p = strchrW( buf, '='))) {
|
|
|
|
*p='\0';
|
|
|
|
ret = PROFILE_SetString( section, buf, p+1, TRUE);
|
2004-11-29 00:08:59 +00:00
|
|
|
}
|
|
|
|
HeapFree( GetProcessHeap(), 0, buf );
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
string += strlenW(string)+1;
|
2004-11-29 00:08:59 +00:00
|
|
|
}
|
|
|
|
PROFILE_FlushFile();
|
|
|
|
}
|
|
|
|
}
|
2001-03-31 01:17:30 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
RtlLeaveCriticalSection( &PROFILE_CritSect );
|
|
|
|
return ret;
|
2001-03-31 01:17:30 +00:00
|
|
|
}
|
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* WritePrivateProfileSectionA (KERNEL32.@)
|
2003-07-10 18:50:51 +00:00
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
BOOL WINAPI WritePrivateProfileSectionA( LPCSTR section,
|
|
|
|
LPCSTR string, LPCSTR filename)
|
|
|
|
|
2001-03-31 01:17:30 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
UNICODE_STRING sectionW, filenameW;
|
|
|
|
LPWSTR stringW;
|
|
|
|
BOOL ret;
|
2001-03-31 01:17:30 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
if (string)
|
|
|
|
{
|
|
|
|
INT lenA, lenW;
|
|
|
|
LPCSTR p = string;
|
2001-06-07 21:27:45 +00:00
|
|
|
|
2005-11-12 01:11:28 +00:00
|
|
|
while(*p) p += strlen(p) + 1;
|
2004-11-29 00:08:59 +00:00
|
|
|
lenA = p - string + 1;
|
|
|
|
lenW = MultiByteToWideChar(CP_ACP, 0, string, lenA, NULL, 0);
|
|
|
|
if ((stringW = HeapAlloc(GetProcessHeap(), 0, lenW * sizeof(WCHAR))))
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, string, lenA, stringW, lenW);
|
|
|
|
}
|
|
|
|
else stringW = NULL;
|
|
|
|
if (section) RtlCreateUnicodeStringFromAsciiz(§ionW, section);
|
|
|
|
else sectionW.Buffer = NULL;
|
|
|
|
if (filename) RtlCreateUnicodeStringFromAsciiz(&filenameW, filename);
|
|
|
|
else filenameW.Buffer = NULL;
|
2001-03-31 01:17:30 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
ret = WritePrivateProfileSectionW(sectionW.Buffer, stringW, filenameW.Buffer);
|
2001-06-07 21:27:45 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, stringW);
|
|
|
|
RtlFreeUnicodeString(§ionW);
|
|
|
|
RtlFreeUnicodeString(&filenameW);
|
|
|
|
return ret;
|
2001-03-31 01:17:30 +00:00
|
|
|
}
|
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* WriteProfileSectionA (KERNEL32.@)
|
2003-07-10 18:50:51 +00:00
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
BOOL WINAPI WriteProfileSectionA( LPCSTR section, LPCSTR keys_n_values)
|
|
|
|
|
2001-03-31 01:17:30 +00:00
|
|
|
{
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
return WritePrivateProfileSectionA( section, keys_n_values, "win.ini");
|
2001-03-31 01:17:30 +00:00
|
|
|
}
|
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* WriteProfileSectionW (KERNEL32.@)
|
2003-07-10 18:50:51 +00:00
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
BOOL WINAPI WriteProfileSectionW( LPCWSTR section, LPCWSTR keys_n_values)
|
2001-03-31 01:17:30 +00:00
|
|
|
{
|
2009-05-24 12:14:42 +00:00
|
|
|
return WritePrivateProfileSectionW(section, keys_n_values, wininiW);
|
2001-03-31 01:17:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* GetPrivateProfileSectionNamesW (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Returns the section names contained in the specified file.
|
|
|
|
* FIXME: Where do we find this file when the path is relative?
|
|
|
|
* The section names are returned as a list of strings with an extra
|
|
|
|
* '\0' to mark the end of the list. Except for that the behavior
|
|
|
|
* depends on the Windows version.
|
|
|
|
*
|
|
|
|
* Win95:
|
|
|
|
* - if the buffer is 0 or 1 character long then it is as if it was of
|
|
|
|
* infinite length.
|
2009-08-24 12:17:02 +00:00
|
|
|
* - otherwise, if the buffer is too small only the section names that fit
|
2004-11-29 00:08:59 +00:00
|
|
|
* are returned.
|
2009-08-24 12:17:02 +00:00
|
|
|
* - note that this means if the buffer was too small to return even just
|
2004-11-29 00:08:59 +00:00
|
|
|
* the first section name then a single '\0' will be returned.
|
|
|
|
* - the return value is the number of characters written in the buffer,
|
2009-08-24 12:17:02 +00:00
|
|
|
* except if the buffer was too small in which case len-2 is returned
|
2004-11-29 00:08:59 +00:00
|
|
|
*
|
|
|
|
* Win2000:
|
|
|
|
* - if the buffer is 0, 1 or 2 characters long then it is filled with
|
|
|
|
* '\0' and the return value is 0
|
|
|
|
* - otherwise if the buffer is too small then the first section name that
|
|
|
|
* does not fit is truncated so that the string list can be terminated
|
|
|
|
* correctly (double '\0')
|
|
|
|
* - the return value is the number of characters written in the buffer
|
|
|
|
* except for the trailing '\0'. If the buffer is too small, then the
|
|
|
|
* return value is len-2
|
|
|
|
* - Win2000 has a bug that triggers when the section names and the
|
|
|
|
* trailing '\0' fit exactly in the buffer. In that case the trailing
|
|
|
|
* '\0' is missing.
|
|
|
|
*
|
|
|
|
* Wine implements the observed Win2000 behavior (except for the bug).
|
|
|
|
*
|
|
|
|
* Note that when the buffer is big enough then the return value may be any
|
|
|
|
* value between 1 and len-1 (or len in Win95), including len-2.
|
2003-07-10 18:50:51 +00:00
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
DWORD WINAPI GetPrivateProfileSectionNamesW( LPWSTR buffer, DWORD size,
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
LPCWSTR filename)
|
2001-03-31 01:17:30 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
DWORD ret = 0;
|
2004-01-31 23:52:42 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
RtlEnterCriticalSection( &PROFILE_CritSect );
|
2004-01-31 23:52:42 +00:00
|
|
|
|
2008-12-27 08:34:30 +00:00
|
|
|
if (PROFILE_Open( filename, FALSE ))
|
2004-11-29 00:08:59 +00:00
|
|
|
ret = PROFILE_GetSectionNames(buffer, size);
|
2004-01-31 23:52:42 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
RtlLeaveCriticalSection( &PROFILE_CritSect );
|
2004-01-31 23:52:42 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
return ret;
|
2001-03-31 01:17:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* GetPrivateProfileSectionNamesA (KERNEL32.@)
|
2003-07-10 18:50:51 +00:00
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
DWORD WINAPI GetPrivateProfileSectionNamesA( LPSTR buffer, DWORD size,
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
LPCSTR filename)
|
2001-03-31 01:17:30 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
UNICODE_STRING filenameW;
|
|
|
|
LPWSTR bufferW;
|
|
|
|
INT retW, ret = 0;
|
2004-01-31 23:52:42 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
bufferW = buffer ? HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR)) : NULL;
|
2009-10-25 17:28:35 +00:00
|
|
|
if (filename) RtlCreateUnicodeStringFromAsciiz(&filenameW, filename);
|
|
|
|
else filenameW.Buffer = NULL;
|
2004-01-31 23:52:42 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
retW = GetPrivateProfileSectionNamesW(bufferW, size, filenameW.Buffer);
|
|
|
|
if (retW && size)
|
2004-01-31 23:52:42 +00:00
|
|
|
{
|
2008-09-13 08:23:32 +00:00
|
|
|
ret = WideCharToMultiByte(CP_ACP, 0, bufferW, retW+1, buffer, size-1, NULL, NULL);
|
2004-11-29 00:08:59 +00:00
|
|
|
if (!ret)
|
2004-01-31 23:52:42 +00:00
|
|
|
{
|
2008-09-13 08:23:32 +00:00
|
|
|
ret = size-2;
|
2004-11-29 00:08:59 +00:00
|
|
|
buffer[size-1] = 0;
|
2004-01-31 23:52:42 +00:00
|
|
|
}
|
2008-09-13 08:23:32 +00:00
|
|
|
else
|
|
|
|
ret = ret-1;
|
2004-01-31 23:52:42 +00:00
|
|
|
}
|
2008-09-13 08:23:32 +00:00
|
|
|
else if(size)
|
|
|
|
buffer[0] = '\0';
|
2004-01-31 23:52:42 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
RtlFreeUnicodeString(&filenameW);
|
2005-11-12 01:11:28 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, bufferW);
|
2004-11-29 00:08:59 +00:00
|
|
|
return ret;
|
2001-03-31 01:17:30 +00:00
|
|
|
}
|
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* GetPrivateProfileStructW (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Should match Win95's behaviour pretty much
|
2003-07-10 18:50:51 +00:00
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
BOOL WINAPI GetPrivateProfileStructW (LPCWSTR section, LPCWSTR key,
|
|
|
|
LPVOID buf, UINT len, LPCWSTR filename)
|
2001-03-31 01:17:30 +00:00
|
|
|
{
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
BOOL ret = FALSE;
|
2004-11-29 00:08:59 +00:00
|
|
|
|
|
|
|
RtlEnterCriticalSection( &PROFILE_CritSect );
|
|
|
|
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
if (PROFILE_Open( filename, FALSE )) {
|
2004-11-29 00:08:59 +00:00
|
|
|
PROFILEKEY *k = PROFILE_Find ( &CurProfile->section, section, key, FALSE, FALSE);
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
if (k) {
|
|
|
|
TRACE("value (at %p): %s\n", k->value, debugstr_w(k->value));
|
|
|
|
if (((strlenW(k->value) - 2) / 2) == len)
|
|
|
|
{
|
|
|
|
LPWSTR end, p;
|
|
|
|
BOOL valid = TRUE;
|
|
|
|
WCHAR c;
|
|
|
|
DWORD chksum = 0;
|
|
|
|
|
|
|
|
end = k->value + strlenW(k->value); /* -> '\0' */
|
|
|
|
/* check for invalid chars in ASCII coded hex string */
|
|
|
|
for (p=k->value; p < end; p++)
|
|
|
|
{
|
|
|
|
if (!isxdigitW(*p))
|
|
|
|
{
|
|
|
|
WARN("invalid char '%x' in file %s->[%s]->%s !\n",
|
|
|
|
*p, debugstr_w(filename), debugstr_w(section), debugstr_w(key));
|
|
|
|
valid = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (valid)
|
|
|
|
{
|
|
|
|
BOOL highnibble = TRUE;
|
|
|
|
BYTE b = 0, val;
|
2009-05-09 12:40:35 +00:00
|
|
|
LPBYTE binbuf = buf;
|
2004-12-13 21:16:26 +00:00
|
|
|
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
end -= 2; /* don't include checksum in output data */
|
|
|
|
/* translate ASCII hex format into binary data */
|
|
|
|
for (p=k->value; p < end; p++)
|
|
|
|
{
|
|
|
|
c = toupperW(*p);
|
|
|
|
val = (c > '9') ?
|
|
|
|
(c - 'A' + 10) : (c - '0');
|
|
|
|
|
|
|
|
if (highnibble)
|
|
|
|
b = val << 4;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
b += val;
|
|
|
|
*binbuf++ = b; /* feed binary data into output */
|
|
|
|
chksum += b; /* calculate checksum */
|
|
|
|
}
|
|
|
|
highnibble ^= 1; /* toggle */
|
|
|
|
}
|
|
|
|
/* retrieve stored checksum value */
|
|
|
|
c = toupperW(*p++);
|
|
|
|
b = ( (c > '9') ? (c - 'A' + 10) : (c - '0') ) << 4;
|
|
|
|
c = toupperW(*p);
|
|
|
|
b += (c > '9') ? (c - 'A' + 10) : (c - '0');
|
|
|
|
if (b == (chksum & 0xff)) /* checksums match ? */
|
2004-11-29 00:08:59 +00:00
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
}
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
}
|
2004-11-29 00:08:59 +00:00
|
|
|
}
|
|
|
|
RtlLeaveCriticalSection( &PROFILE_CritSect );
|
2001-03-31 01:17:30 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2001-03-31 01:17:30 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* GetPrivateProfileStructA (KERNEL32.@)
|
2003-07-10 18:50:51 +00:00
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
BOOL WINAPI GetPrivateProfileStructA (LPCSTR section, LPCSTR key,
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
LPVOID buffer, UINT len, LPCSTR filename)
|
2001-03-31 01:17:30 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
UNICODE_STRING sectionW, keyW, filenameW;
|
|
|
|
INT ret;
|
|
|
|
|
|
|
|
if (section) RtlCreateUnicodeStringFromAsciiz(§ionW, section);
|
|
|
|
else sectionW.Buffer = NULL;
|
|
|
|
if (key) RtlCreateUnicodeStringFromAsciiz(&keyW, key);
|
|
|
|
else keyW.Buffer = NULL;
|
|
|
|
if (filename) RtlCreateUnicodeStringFromAsciiz(&filenameW, filename);
|
|
|
|
else filenameW.Buffer = NULL;
|
|
|
|
|
|
|
|
ret = GetPrivateProfileStructW(sectionW.Buffer, keyW.Buffer, buffer, len,
|
|
|
|
filenameW.Buffer);
|
|
|
|
/* Do not translate binary data. */
|
|
|
|
|
|
|
|
RtlFreeUnicodeString(§ionW);
|
|
|
|
RtlFreeUnicodeString(&keyW);
|
|
|
|
RtlFreeUnicodeString(&filenameW);
|
|
|
|
return ret;
|
2001-03-31 01:17:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-25 17:28:35 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* WritePrivateProfileStructW (KERNEL32.@)
|
2003-07-10 18:50:51 +00:00
|
|
|
*/
|
2004-11-29 00:08:59 +00:00
|
|
|
BOOL WINAPI WritePrivateProfileStructW (LPCWSTR section, LPCWSTR key,
|
|
|
|
LPVOID buf, UINT bufsize, LPCWSTR filename)
|
2001-03-31 01:17:30 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
BOOL ret = FALSE;
|
|
|
|
LPBYTE binbuf;
|
|
|
|
LPWSTR outstring, p;
|
|
|
|
DWORD sum = 0;
|
2001-03-31 01:17:30 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
if (!section && !key && !buf) /* flush the cache */
|
|
|
|
return WritePrivateProfileStringW( NULL, NULL, NULL, filename );
|
2001-03-31 01:17:30 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/* allocate string buffer for hex chars + checksum hex char + '\0' */
|
|
|
|
outstring = HeapAlloc( GetProcessHeap(), 0, (bufsize*2 + 2 + 1) * sizeof(WCHAR) );
|
|
|
|
p = outstring;
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
for (binbuf = (LPBYTE)buf; binbuf < (LPBYTE)buf+bufsize; binbuf++) {
|
|
|
|
*p++ = hex[*binbuf >> 4];
|
|
|
|
*p++ = hex[*binbuf & 0xf];
|
|
|
|
sum += *binbuf;
|
2004-11-29 00:08:59 +00:00
|
|
|
}
|
|
|
|
/* checksum is sum & 0xff */
|
|
|
|
*p++ = hex[(sum & 0xf0) >> 4];
|
|
|
|
*p++ = hex[sum & 0xf];
|
|
|
|
*p++ = '\0';
|
2001-03-31 01:17:30 +00:00
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
RtlEnterCriticalSection( &PROFILE_CritSect );
|
2001-03-31 01:17:30 +00:00
|
|
|
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
if (PROFILE_Open( filename, TRUE )) {
|
2004-11-29 00:08:59 +00:00
|
|
|
ret = PROFILE_SetString( section, key, outstring, FALSE);
|
|
|
|
PROFILE_FlushFile();
|
|
|
|
}
|
|
|
|
|
|
|
|
RtlLeaveCriticalSection( &PROFILE_CritSect );
|
|
|
|
|
|
|
|
HeapFree( GetProcessHeap(), 0, outstring );
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WritePrivateProfileStructA (KERNEL32.@)
|
2003-07-10 18:50:51 +00:00
|
|
|
*/
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
BOOL WINAPI WritePrivateProfileStructA (LPCSTR section, LPCSTR key,
|
|
|
|
LPVOID buf, UINT bufsize, LPCSTR filename)
|
2001-03-31 01:17:30 +00:00
|
|
|
{
|
2004-11-29 00:08:59 +00:00
|
|
|
UNICODE_STRING sectionW, keyW, filenameW;
|
|
|
|
INT ret;
|
|
|
|
|
|
|
|
if (section) RtlCreateUnicodeStringFromAsciiz(§ionW, section);
|
|
|
|
else sectionW.Buffer = NULL;
|
|
|
|
if (key) RtlCreateUnicodeStringFromAsciiz(&keyW, key);
|
|
|
|
else keyW.Buffer = NULL;
|
|
|
|
if (filename) RtlCreateUnicodeStringFromAsciiz(&filenameW, filename);
|
|
|
|
else filenameW.Buffer = NULL;
|
|
|
|
|
|
|
|
/* Do not translate binary data. */
|
|
|
|
ret = WritePrivateProfileStructW(sectionW.Buffer, keyW.Buffer, buf, bufsize,
|
|
|
|
filenameW.Buffer);
|
|
|
|
|
|
|
|
RtlFreeUnicodeString(§ionW);
|
|
|
|
RtlFreeUnicodeString(&keyW);
|
|
|
|
RtlFreeUnicodeString(&filenameW);
|
|
|
|
return ret;
|
2001-03-31 01:17:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-11-29 00:08:59 +00:00
|
|
|
/***********************************************************************
|
2010-03-16 17:50:04 +00:00
|
|
|
* OpenProfileUserMapping (KERNEL32.@)
|
2003-07-10 18:50:51 +00:00
|
|
|
*/
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
BOOL WINAPI OpenProfileUserMapping(void) {
|
|
|
|
FIXME("(), stub!\n");
|
2010-03-16 17:50:04 +00:00
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CloseProfileUserMapping (KERNEL32.@)
|
|
|
|
*/
|
[KERNEL32]: Winesync all there is to Winesync in ReactOS' kernel32. This mainly affects LZ*, Comm*, *ProfileString* (INI), and *Resource* APIs, however the changes in there are relatively minor. More substantial changes affect the locale/NLS/language functions, many which were bitrotting for 6+ years.
In theory, this code is "better" than before, and it is closer to Wine (which arguably has better compatibility). It also resets things in sync with Wine however, and may lose and "fixes" ReactOS may have added over the years. But this is a good thing, since these fixes have been "lost" (they obviously never made it into Wine), and if regressions are now found due to this, actual upstream patches can be sent and picked up on the next sync. This avoids maintaining duplicate code, at the expenses of some potential short-term regressions in i18n.
Finally, note that much of /string seems to be taken from Wine's Unicode library (which a host "unicode" already exists in ReactOS' tools/. It may be better (for someone with more experience as to these wine-isms) to simply just pull-in whatever winelib files are not currently present in ReactOS, and have kernel32 and tools/unicode use winelib, instead of having 2 or 3 copies of the code.
svn path=/trunk/; revision=52754
2011-07-21 05:24:59 +00:00
|
|
|
BOOL WINAPI CloseProfileUserMapping(void) {
|
|
|
|
FIXME("(), stub!\n");
|
2005-09-26 18:59:04 +00:00
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|