Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
86c6021c
Commit
86c6021c
authored
Oct 08, 2009
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Reimplement GetPrivateProfileString16 on top of 32-bit functions and move it to file16.c.
parent
362ecd06
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
96 additions
and
84 deletions
+96
-84
file16.c
dlls/kernel32/file16.c
+84
-0
kernel_main.c
dlls/kernel32/kernel_main.c
+1
-1
profile.c
dlls/kernel32/profile.c
+11
-83
No files found.
dlls/kernel32/file16.c
View file @
86c6021c
...
...
@@ -428,6 +428,81 @@ UINT16 WINAPI GetPrivateProfileInt16( LPCSTR section, LPCSTR entry,
/***********************************************************************
* GetPrivateProfileString (KERNEL.128)
*/
INT16
WINAPI
GetPrivateProfileString16
(
LPCSTR
section
,
LPCSTR
entry
,
LPCSTR
def_val
,
LPSTR
buffer
,
UINT16
len
,
LPCSTR
filename
)
{
if
(
!
section
)
{
if
(
buffer
&&
len
)
buffer
[
0
]
=
0
;
return
0
;
}
if
(
!
entry
)
{
/* We have to return the list of keys in the section but without the values
* so we need to massage the results of GetPrivateProfileSectionA.
*/
UINT
ret
,
oldlen
=
len
,
size
=
min
(
len
,
1024
);
LPSTR
data
,
src
;
for
(;;)
{
if
(
!
(
data
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
)))
return
0
;
ret
=
GetPrivateProfileSectionA
(
section
,
data
,
size
,
filename
);
if
(
!
ret
)
{
HeapFree
(
GetProcessHeap
(),
0
,
data
);
return
0
;
}
if
(
ret
!=
size
-
2
)
break
;
/* overflow, try again */
size
*=
2
;
HeapFree
(
GetProcessHeap
(),
0
,
data
);
}
src
=
data
;
while
(
len
&&
*
src
)
{
char
*
p
=
strchr
(
src
,
'='
);
if
(
!
p
)
p
=
src
+
strlen
(
src
);
if
(
p
-
src
<
len
)
{
memcpy
(
buffer
,
src
,
p
-
src
);
buffer
+=
p
-
src
;
*
buffer
++
=
0
;
len
-=
(
p
-
src
)
+
1
;
src
+=
strlen
(
src
)
+
1
;
}
else
/* overflow */
{
memcpy
(
buffer
,
src
,
len
);
buffer
+=
len
;
len
=
0
;
}
}
HeapFree
(
GetProcessHeap
(),
0
,
data
);
if
(
len
)
{
*
buffer
=
0
;
return
oldlen
-
len
;
}
if
(
oldlen
>
2
)
{
buffer
[
-
2
]
=
0
;
buffer
[
-
1
]
=
0
;
return
oldlen
-
2
;
}
return
0
;
}
return
GetPrivateProfileStringA
(
section
,
entry
,
def_val
,
buffer
,
len
,
filename
);
}
/***********************************************************************
* WritePrivateProfileString (KERNEL.129)
*/
BOOL16
WINAPI
WritePrivateProfileString16
(
LPCSTR
section
,
LPCSTR
entry
,
...
...
@@ -549,6 +624,15 @@ WORD WINAPI GetShortPathName16( LPCSTR longpath, LPSTR shortpath, WORD len )
/***********************************************************************
* WriteOutProfiles (KERNEL.315)
*/
void
WINAPI
WriteOutProfiles16
(
void
)
{
WritePrivateProfileSectionW
(
NULL
,
NULL
,
NULL
);
}
/***********************************************************************
* WritePrivateProfileStruct (KERNEL.406)
*/
BOOL16
WINAPI
WritePrivateProfileStruct16
(
LPCSTR
section
,
LPCSTR
key
,
...
...
dlls/kernel32/kernel_main.c
View file @
86c6021c
...
...
@@ -199,7 +199,7 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
thread_detach
();
break
;
case
DLL_PROCESS_DETACH
:
Write
OutProfiles16
(
);
Write
PrivateProfileSectionW
(
NULL
,
NULL
,
NULL
);
break
;
}
return
TRUE
;
...
...
dlls/kernel32/profile.c
View file @
86c6021c
...
...
@@ -30,7 +30,6 @@
#include "winnls.h"
#include "winerror.h"
#include "winternl.h"
#include "wine/winbase16.h"
#include "wine/unicode.h"
#include "wine/library.h"
#include "wine/debug.h"
...
...
@@ -865,7 +864,7 @@ static BOOL PROFILE_Open( LPCWSTR filename, BOOL write_access )
* If return_values is TRUE, also include the corresponding values.
*/
static
INT
PROFILE_GetSection
(
PROFILESECTION
*
section
,
LPCWSTR
section_name
,
LPWSTR
buffer
,
UINT
len
,
BOOL
return_values
,
BOOL
return_noequalkeys
)
LPWSTR
buffer
,
UINT
len
,
BOOL
return_values
)
{
PROFILEKEY
*
key
;
...
...
@@ -883,7 +882,7 @@ static INT PROFILE_GetSection( PROFILESECTION *section, LPCWSTR section_name,
if
(
len
<=
2
)
break
;
if
(
!*
key
->
name
)
continue
;
/* Skip empty lines */
if
(
IS_ENTRY_COMMENT
(
key
->
name
))
continue
;
/* Skip comments */
if
(
!
return_
noequalkeys
&&
!
return_
values
&&
!
key
->
value
)
continue
;
/* Skip lines w.o. '=' */
if
(
!
return_values
&&
!
key
->
value
)
continue
;
/* Skip lines w.o. '=' */
PROFILE_CopyEntry
(
buffer
,
key
->
name
,
len
-
1
,
0
);
len
-=
strlenW
(
buffer
)
+
1
;
buffer
+=
strlenW
(
buffer
)
+
1
;
...
...
@@ -980,7 +979,7 @@ static INT PROFILE_GetSectionNames( LPWSTR buffer, UINT len )
*
*/
static
INT
PROFILE_GetString
(
LPCWSTR
section
,
LPCWSTR
key_name
,
LPCWSTR
def_val
,
LPWSTR
buffer
,
UINT
len
,
BOOL
win32
)
LPCWSTR
def_val
,
LPWSTR
buffer
,
UINT
len
)
{
PROFILEKEY
*
key
=
NULL
;
static
const
WCHAR
empty_strW
[]
=
{
0
};
...
...
@@ -1006,7 +1005,7 @@ static INT PROFILE_GetString( LPCWSTR section, LPCWSTR key_name,
/* no "else" here ! */
if
(
section
&&
section
[
0
])
{
INT
ret
=
PROFILE_GetSection
(
CurProfile
->
section
,
section
,
buffer
,
len
,
FALSE
,
!
win32
);
INT
ret
=
PROFILE_GetSection
(
CurProfile
->
section
,
section
,
buffer
,
len
,
FALSE
);
if
(
!
buffer
[
0
])
/* no luck -> def_val */
{
PROFILE_CopyEntry
(
buffer
,
def_val
,
len
,
TRUE
);
...
...
@@ -1092,16 +1091,12 @@ UINT WINAPI GetProfileIntW( LPCWSTR section, LPCWSTR entry, INT def_val )
return
GetPrivateProfileIntW
(
section
,
entry
,
def_val
,
wininiW
);
}
/*
* if win32, copy:
* - Section names if 'section' is NULL
* - Keys in a Section if 'entry' is NULL
* (see MSDN doc for GetPrivateProfileString)
/***********************************************************************
* GetPrivateProfileStringW (KERNEL32.@)
*/
static
int
PROFILE_GetPrivateProfileString
(
LPCWSTR
section
,
LPCWSTR
entry
,
INT
WINAPI
GetPrivateProfileStringW
(
LPCWSTR
section
,
LPCWSTR
entry
,
LPCWSTR
def_val
,
LPWSTR
buffer
,
UINT
len
,
LPCWSTR
filename
,
BOOL
win32
)
UINT
len
,
LPCWSTR
filename
)
{
int
ret
;
LPWSTR
defval_tmp
=
NULL
;
...
...
@@ -1131,11 +1126,11 @@ static int PROFILE_GetPrivateProfileString( LPCWSTR section, LPCWSTR entry,
RtlEnterCriticalSection
(
&
PROFILE_CritSect
);
if
(
PROFILE_Open
(
filename
,
FALSE
))
{
if
(
win32
&&
(
section
==
NULL
)
)
if
(
section
==
NULL
)
ret
=
PROFILE_GetSectionNames
(
buffer
,
len
);
else
/* PROFILE_GetString can handle the 'entry == NULL' case */
ret
=
PROFILE_GetString
(
section
,
entry
,
def_val
,
buffer
,
len
,
win32
);
ret
=
PROFILE_GetString
(
section
,
entry
,
def_val
,
buffer
,
len
);
}
else
if
(
buffer
&&
def_val
)
{
lstrcpynW
(
buffer
,
def_val
,
len
);
ret
=
strlenW
(
buffer
);
...
...
@@ -1153,50 +1148,6 @@ static int PROFILE_GetPrivateProfileString( LPCWSTR section, LPCWSTR entry,
}
/***********************************************************************
* GetPrivateProfileString (KERNEL.128)
*/
INT16
WINAPI
GetPrivateProfileString16
(
LPCSTR
section
,
LPCSTR
entry
,
LPCSTR
def_val
,
LPSTR
buffer
,
UINT16
len
,
LPCSTR
filename
)
{
UNICODE_STRING
sectionW
,
entryW
,
def_valW
,
filenameW
;
LPWSTR
bufferW
;
INT16
retW
,
ret
=
0
;
bufferW
=
buffer
?
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
))
:
NULL
;
if
(
section
)
RtlCreateUnicodeStringFromAsciiz
(
&
sectionW
,
section
);
else
sectionW
.
Buffer
=
NULL
;
if
(
entry
)
RtlCreateUnicodeStringFromAsciiz
(
&
entryW
,
entry
);
else
entryW
.
Buffer
=
NULL
;
if
(
def_val
)
RtlCreateUnicodeStringFromAsciiz
(
&
def_valW
,
def_val
);
else
def_valW
.
Buffer
=
NULL
;
if
(
filename
)
RtlCreateUnicodeStringFromAsciiz
(
&
filenameW
,
filename
);
else
filenameW
.
Buffer
=
NULL
;
retW
=
PROFILE_GetPrivateProfileString
(
sectionW
.
Buffer
,
entryW
.
Buffer
,
def_valW
.
Buffer
,
bufferW
,
len
,
filenameW
.
Buffer
,
FALSE
);
if
(
len
)
{
ret
=
WideCharToMultiByte
(
CP_ACP
,
0
,
bufferW
,
retW
+
1
,
buffer
,
len
,
NULL
,
NULL
);
if
(
!
ret
)
{
ret
=
len
-
1
;
buffer
[
ret
]
=
0
;
}
else
ret
--
;
/* strip terminating 0 */
}
RtlFreeUnicodeString
(
&
sectionW
);
RtlFreeUnicodeString
(
&
entryW
);
RtlFreeUnicodeString
(
&
def_valW
);
RtlFreeUnicodeString
(
&
filenameW
);
HeapFree
(
GetProcessHeap
(),
0
,
bufferW
);
return
ret
;
}
/***********************************************************************
* GetPrivateProfileStringA (KERNEL32.@)
*/
INT
WINAPI
GetPrivateProfileStringA
(
LPCSTR
section
,
LPCSTR
entry
,
...
...
@@ -1241,19 +1192,6 @@ INT WINAPI GetPrivateProfileStringA( LPCSTR section, LPCSTR entry,
}
/***********************************************************************
* GetPrivateProfileStringW (KERNEL32.@)
*/
INT
WINAPI
GetPrivateProfileStringW
(
LPCWSTR
section
,
LPCWSTR
entry
,
LPCWSTR
def_val
,
LPWSTR
buffer
,
UINT
len
,
LPCWSTR
filename
)
{
TRACE
(
"(%s, %s, %s, %p, %d, %s)
\n
"
,
debugstr_w
(
section
),
debugstr_w
(
entry
),
debugstr_w
(
def_val
),
buffer
,
len
,
debugstr_w
(
filename
));
return
PROFILE_GetPrivateProfileString
(
section
,
entry
,
def_val
,
buffer
,
len
,
filename
,
TRUE
);
}
/***********************************************************************
* GetProfileStringA (KERNEL32.@)
*/
INT
WINAPI
GetProfileStringA
(
LPCSTR
section
,
LPCSTR
entry
,
LPCSTR
def_val
,
...
...
@@ -1363,7 +1301,7 @@ INT WINAPI GetPrivateProfileSectionW( LPCWSTR section, LPWSTR buffer,
RtlEnterCriticalSection
(
&
PROFILE_CritSect
);
if
(
PROFILE_Open
(
filename
,
FALSE
))
ret
=
PROFILE_GetSection
(
CurProfile
->
section
,
section
,
buffer
,
len
,
TRUE
,
FALSE
);
ret
=
PROFILE_GetSection
(
CurProfile
->
section
,
section
,
buffer
,
len
,
TRUE
);
RtlLeaveCriticalSection
(
&
PROFILE_CritSect
);
...
...
@@ -1847,16 +1785,6 @@ BOOL WINAPI WritePrivateProfileStructA (LPCSTR section, LPCSTR key,
/***********************************************************************
* WriteOutProfiles (KERNEL.315)
*/
void
WINAPI
WriteOutProfiles16
(
void
)
{
RtlEnterCriticalSection
(
&
PROFILE_CritSect
);
PROFILE_FlushFile
();
RtlLeaveCriticalSection
(
&
PROFILE_CritSect
);
}
/***********************************************************************
* OpenProfileUserMapping (KERNEL32.@)
*/
BOOL
WINAPI
OpenProfileUserMapping
(
void
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment