Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
2e2d6ec7
Commit
2e2d6ec7
authored
Feb 17, 2004
by
Jon Griffiths
Committed by
Alexandre Julliard
Feb 17, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stub the stopwatch API.
Implement DoesStringRoundTripW,@371-3,@392. Move a couple of string functions into string.c
parent
1c63357e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
480 additions
and
224 deletions
+480
-224
Makefile.in
dlls/shlwapi/Makefile.in
+1
-0
ordinal.c
dlls/shlwapi/ordinal.c
+2
-209
shlwapi.spec
dlls/shlwapi/shlwapi.spec
+15
-15
stopwatch.c
dlls/shlwapi/stopwatch.c
+228
-0
string.c
dlls/shlwapi/string.c
+234
-0
No files found.
dlls/shlwapi/Makefile.in
View file @
2e2d6ec7
...
...
@@ -17,6 +17,7 @@ C_SRCS = \
reg.c
\
regstream.c
\
shlwapi_main.c
\
stopwatch.c
\
string.c
\
thread.c
\
url.c
\
...
...
dlls/shlwapi/ordinal.c
View file @
2e2d6ec7
...
...
@@ -34,7 +34,6 @@
#include "winbase.h"
#include "winuser.h"
#include "winnls.h"
#include "ddeml.h"
#include "docobj.h"
#include "exdisp.h"
#include "shlguid.h"
...
...
@@ -70,7 +69,6 @@ extern HMODULE SHLWAPI_hwinmm;
extern
HMODULE
SHLWAPI_hcomdlg32
;
extern
HMODULE
SHLWAPI_hcomctl32
;
extern
HMODULE
SHLWAPI_hmpr
;
extern
HMODULE
SHLWAPI_hmlang
;
extern
HMODULE
SHLWAPI_hurlmon
;
extern
HMODULE
SHLWAPI_hversion
;
...
...
@@ -86,8 +84,6 @@ static DWORD id2[4] = {0x79eac9ee, 0x11cebaf9, 0xaa00828c, 0x0ba94b00};
/* Function pointers for GET_FUNC macro; these need to be global because of gcc bug */
typedef
LPITEMIDLIST
(
WINAPI
*
fnpSHBrowseForFolderW
)(
LPBROWSEINFOW
);
static
fnpSHBrowseForFolderW
pSHBrowseForFolderW
;
typedef
HRESULT
(
WINAPI
*
fnpConvertINetUnicodeToMultiByte
)(
LPDWORD
,
DWORD
,
LPCWSTR
,
LPINT
,
LPSTR
,
LPINT
);
static
fnpConvertINetUnicodeToMultiByte
pConvertINetUnicodeToMultiByte
;
typedef
BOOL
(
WINAPI
*
fnpPlaySoundW
)(
LPCWSTR
,
HMODULE
,
DWORD
);
static
fnpPlaySoundW
pPlaySoundW
;
typedef
DWORD
(
WINAPI
*
fnpSHGetFileInfoW
)(
LPCWSTR
,
DWORD
,
SHFILEINFOW
*
,
UINT
,
UINT
);
...
...
@@ -585,7 +581,7 @@ HRESULT WINAPI GetAcceptLanguagesA(
/*************************************************************************
* @ [SHLWAPI.15]
*
* Unicode version of
SHLWAPI_14
.
* Unicode version of
GetAcceptLanguagesA
.
*/
HRESULT
WINAPI
GetAcceptLanguagesW
(
LPWSTR
langbuf
,
...
...
@@ -670,7 +666,7 @@ INT WINAPI SHStringFromGUIDW(REFGUID guid, LPWSTR lpszDest, INT cchMax)
{
char
xguid
[
40
];
INT
iLen
=
SHStringFromGUIDA
(
guid
,
xguid
,
cchMax
);
if
(
iLen
)
MultiByteToWideChar
(
CP_ACP
,
0
,
xguid
,
-
1
,
lpszDest
,
cchMax
);
return
iLen
;
...
...
@@ -1169,38 +1165,6 @@ BOOL WINAPI SHAboutInfoW(LPWSTR lpszDest, DWORD dwDestLen)
}
/*************************************************************************
* @ [SHLWAPI.162]
*
* Remove a hanging lead byte from the end of a string, if present.
*
* PARAMS
* lpStr [I] String to check for a hanging lead byte
* size [I] Length of lpStr
*
* RETURNS
* Success: The new length of the string. Any hanging lead bytes are removed.
* Failure: 0, if any parameters are invalid.
*/
DWORD
WINAPI
SHTruncateString
(
LPSTR
lpStr
,
DWORD
size
)
{
if
(
lpStr
&&
size
)
{
LPSTR
lastByte
=
lpStr
+
size
-
1
;
while
(
lpStr
<
lastByte
)
lpStr
+=
IsDBCSLeadByte
(
*
lpStr
)
?
2
:
1
;
if
(
lpStr
==
lastByte
&&
IsDBCSLeadByte
(
*
lpStr
))
{
*
lpStr
=
'\0'
;
size
--
;
}
return
size
;
}
return
0
;
}
/*************************************************************************
* @ [SHLWAPI.163]
*
* Call IOleCommandTarget_QueryStatus() on an object.
...
...
@@ -2176,148 +2140,6 @@ DWORD WINAPI FDSA_DeleteItem(
return
1
;
}
/*************************************************************************
* @ [SHLWAPI.215]
*
* NOTES
* check me!
*/
DWORD
WINAPI
SHAnsiToUnicode
(
LPCSTR
lpStrSrc
,
LPWSTR
lpwStrDest
,
int
len
)
{
INT
len_a
,
ret
;
len_a
=
lstrlenA
(
lpStrSrc
);
ret
=
MultiByteToWideChar
(
0
,
0
,
lpStrSrc
,
len_a
,
lpwStrDest
,
len
);
TRACE
(
"%s %s %d, ret=%d
\n
"
,
debugstr_a
(
lpStrSrc
),
debugstr_w
(
lpwStrDest
),
len
,
ret
);
return
ret
;
}
/*************************************************************************
* @ [SHLWAPI.218]
*
* WideCharToMultiByte with support for multiple codepages.
*
* PARAMS
* CodePage [I] Code page to use for the conversion
* lpSrcStr [I] Source Unicode string to convert
* lpDstStr [O] Destination for converted Ascii string
* lpnMultiCharCount [O] Input length of lpDstStr/destination for length of lpDstStr
*
* RETURNS
* Success: The number of characters that result from the conversion.
* Failure: 0.
*/
INT
WINAPI
SHUnicodeToAnsiCP
(
UINT
CodePage
,
LPCWSTR
lpSrcStr
,
LPSTR
lpDstStr
,
LPINT
lpnMultiCharCount
)
{
WCHAR
emptyW
[]
=
{
'\0'
};
int
len
,
reqLen
;
LPSTR
mem
;
if
(
!
lpDstStr
||
!
lpnMultiCharCount
)
return
0
;
if
(
!
lpSrcStr
)
lpSrcStr
=
emptyW
;
*
lpDstStr
=
'\0'
;
len
=
strlenW
(
lpSrcStr
)
+
1
;
switch
(
CodePage
)
{
case
CP_WINUNICODE
:
CodePage
=
CP_UTF8
;
/* Fall through... */
case
0x0000C350
:
/* FIXME: CP_ #define */
case
CP_UTF7
:
case
CP_UTF8
:
{
DWORD
dwMode
=
0
;
INT
nWideCharCount
=
len
-
1
;
GET_FUNC
(
pConvertINetUnicodeToMultiByte
,
mlang
,
"ConvertINetUnicodeToMultiByte"
,
0
);
if
(
!
pConvertINetUnicodeToMultiByte
(
&
dwMode
,
CodePage
,
lpSrcStr
,
&
nWideCharCount
,
lpDstStr
,
lpnMultiCharCount
))
return
0
;
if
(
nWideCharCount
<
len
-
1
)
{
mem
=
(
LPSTR
)
HeapAlloc
(
GetProcessHeap
(),
0
,
*
lpnMultiCharCount
);
if
(
!
mem
)
return
0
;
*
lpnMultiCharCount
=
0
;
if
(
pConvertINetUnicodeToMultiByte
(
&
dwMode
,
CodePage
,
lpSrcStr
,
&
len
,
mem
,
lpnMultiCharCount
))
{
SHTruncateString
(
mem
,
*
lpnMultiCharCount
);
lstrcpynA
(
lpDstStr
,
mem
,
*
lpnMultiCharCount
+
1
);
return
*
lpnMultiCharCount
+
1
;
}
HeapFree
(
GetProcessHeap
(),
0
,
mem
);
return
*
lpnMultiCharCount
;
}
lpDstStr
[
*
lpnMultiCharCount
]
=
'\0'
;
return
*
lpnMultiCharCount
;
}
break
;
default:
break
;
}
reqLen
=
WideCharToMultiByte
(
CodePage
,
0
,
lpSrcStr
,
len
,
lpDstStr
,
*
lpnMultiCharCount
,
NULL
,
NULL
);
if
(
!
reqLen
&&
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
)
{
reqLen
=
WideCharToMultiByte
(
CodePage
,
0
,
lpSrcStr
,
len
,
NULL
,
0
,
NULL
,
NULL
);
if
(
reqLen
)
{
mem
=
(
LPSTR
)
HeapAlloc
(
GetProcessHeap
(),
0
,
reqLen
);
if
(
mem
)
{
reqLen
=
WideCharToMultiByte
(
CodePage
,
0
,
lpSrcStr
,
len
,
mem
,
reqLen
,
NULL
,
NULL
);
reqLen
=
SHTruncateString
(
mem
,
*
lpnMultiCharCount
);
reqLen
++
;
lstrcpynA
(
lpDstStr
,
mem
,
*
lpnMultiCharCount
);
HeapFree
(
GetProcessHeap
(),
0
,
mem
);
}
}
}
return
reqLen
;
}
/*************************************************************************
* @ [SHLWAPI.217]
*
* WideCharToMultiByte with support for multiple codepages.
*
* PARAMS
* lpSrcStr [I] Source Unicode string to convert
* lpDstStr [O] Destination for converted Ascii string
* lpnMultiCharCount [O] Input length of lpDstStr/destination for length of lpDstStr
*
* RETURNS
* See SHUnicodeToAnsiCP
* NOTES
* This function simply calls SHUnicodeToAnsiCP with CodePage = CP_ACP.
*/
INT
WINAPI
SHUnicodeToAnsi
(
LPCWSTR
lpSrcStr
,
LPSTR
lpDstStr
,
INT
MultiCharCount
)
{
INT
myint
=
MultiCharCount
;
return
SHUnicodeToAnsiCP
(
CP_ACP
,
lpSrcStr
,
lpDstStr
,
&
myint
);
}
typedef
struct
{
REFIID
refid
;
DWORD
indx
;
...
...
@@ -2515,16 +2337,6 @@ LRESULT CALLBACK SHDefWindowProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM
}
/*************************************************************************
* @ [SHLWAPI.241]
*
*/
DWORD
WINAPI
StopWatchMode
()
{
FIXME
(
"()stub
\n
"
);
return
/* 0xabba1243 */
0
;
}
/*************************************************************************
* @ [SHLWAPI.257]
*
* Create a worker window using CreateWindowExA().
...
...
@@ -3358,25 +3170,6 @@ HRESULT WINAPI SHInvokeCommand(HWND hWnd, IShellFolder* lpFolder, LPCITEMIDLIST
}
/*************************************************************************
* @ [SHLWAPI.364]
*
* Copy one string to another, up to a given length.
*
* PARAMS
* lpszSrc [I] Source string to copy
* lpszDst [O] Destination for copied string
* iLen [I] Number of characters to copy
*
* RETURNS
* TRUE.
*/
DWORD
WINAPI
DoesStringRoundTripA
(
LPCSTR
lpszSrc
,
LPSTR
lpszDst
,
INT
iLen
)
{
lstrcpynA
(
lpszDst
,
lpszSrc
,
iLen
);
return
TRUE
;
}
/*************************************************************************
* @ [SHLWAPI.370]
*
* See ExtractIconW.
...
...
dlls/shlwapi/shlwapi.spec
View file @
2e2d6ec7
...
...
@@ -239,17 +239,17 @@
239 stdcall -noname SHUnregisterClassesW(ptr ptr long)
240 stdcall -noname SHDefWindowProc(long long long long)
241 stdcall -noname StopWatchMode()
242 st
ub -noname StopWatchFlush
243 st
ub -noname StopWatchA
244 st
ub -noname StopWatchW
245 st
ub -noname StopWatch_TimerHandler
242 st
dcall -noname StopWatchFlush()
243 st
dcall -noname StopWatchA(long str long long long)
244 st
dcall -noname StopWatchW(long wstr long long long)
245 st
dcall -noname StopWatch_TimerHandler(ptr ptr long ptr)
246 stub -noname StopWatch_CheckMsg
247 st
ub -noname StopWatch_MarkFrameStart
248 stub -noname StopWatch_MarkSameFramStart
249 st
ub -noname StopWatch_MarkJavaStop
250 st
ub -noname GetPerfTime
247 st
dcall -noname StopWatch_MarkFrameStart(str)
248 stub -noname StopWatch_MarkSameFram
e
Start
249 st
dcall -noname StopWatch_MarkJavaStop(wstr ptr long)
250 st
dcall -noname GetPerfTime()
251 stub -noname StopWatch_DispatchTime
252 st
ub -noname StopWatch_SetMsgLastLocation
252 st
dcall -noname StopWatch_SetMsgLastLocation(long)
253 stub -noname StopWatchExA
254 stub -noname StopWatchExW
255 stub -noname EventTraceHandler
...
...
@@ -361,16 +361,16 @@
361 stdcall @(wstr ptr long) kernel32.GetShortPathNameW
362 stdcall @(ptr ptr) advapi32.GetUserNameW
363 stdcall -noname SHInvokeCommand(ptr ptr ptr long)
364 stdcall -noname DoesStringRoundTripA(str
s
tr long)
365 st
ub -noname DoesStringRoundTripW
364 stdcall -noname DoesStringRoundTripA(str
p
tr long)
365 st
dcall -noname DoesStringRoundTripW(wstr ptr long)
366 stdcall @(long long ptr ptr ptr ptr ptr ptr) advapi32.RegEnumValueW
367 stdcall @(wstr wstr ptr long wstr) kernel32.WritePrivateProfileStructW
368 stdcall @(wstr wstr ptr long wstr) kernel32.GetPrivateProfileStructW
369 stdcall @(wstr wstr ptr ptr long long ptr wstr ptr ptr) kernel32.CreateProcessW
370 stdcall -noname ExtractIconWrapW(long wstr long)
371 st
ub -noname DdeInitializeWrap
W
372 st
ub -noname DdeCreateStringHandleWrap
W
373 st
ub -noname DdeQueryStringWrap
W
371 st
dcall -noname DdeInitializeWrapW(ptr ptr long long) user32.DdeInitialize
W
372 st
dcall -noname DdeCreateStringHandleWrapW(long ptr long) user32.DdeCreateStringHandle
W
373 st
dcall -noname DdeQueryStringWrapW(long ptr wstr long long) user32.DdeQueryString
W
374 stub -noname SHCheckDiskForMediaA
375 stub -noname SHCheckDiskForMediaW
376 stdcall -noname MLGetUILanguage() # kernel32.GetUserDefaultUILanguage
...
...
@@ -389,7 +389,7 @@
389 stdcall -noname GetSaveFileNameWrapW(ptr)
390 stdcall -noname WNetRestoreConnectionWrapW(long wstr)
391 stdcall -noname WNetGetLastErrorWrapW(ptr ptr long ptr long)
392 st
ub -noname EndDialogWrap
392 st
dcall -noname EndDialogWrap(ptr ptr) user32.EndDialog
393 stdcall @(long ptr long ptr long) user32.CreateDialogIndirectParamW
394 stdcall @(long ptr long ptr long) user32.CreateDialogIndirectParamA
395 stub -noname MLWinHelpA
...
...
dlls/shlwapi/stopwatch.c
0 → 100644
View file @
2e2d6ec7
/*
* Stopwatch Functions
*
* Copyright 2004 Jon Griffiths
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* NOTES
* These functions probably never need to be implemented unless we
* A) Rewrite explorer from scratch, and
* B) Want to use a substandard API to tune its performance.
*/
#include "config.h"
#include "wine/port.h"
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "wine/unicode.h"
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winreg.h"
#define NO_SHLWAPI_STREAM
#include "shlwapi.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
shell
);
/*************************************************************************
* @ [SHLWAPI.241]
*
* Get the current performance monitoring mode.
*
* PARAMS
* None.
*
* RETURNS
* The current performance monitoring mode. This is zero if monitoring
* is disabled (the default).
*
* NOTES
* If this function returns 0, no further StopWatch functions should be called.
*/
DWORD
WINAPI
StopWatchMode
()
{
FIXME
(
"() stub!
\n
"
);
return
0
;
}
/*************************************************************************
* @ [SHLWAPI.242]
*
* Write captured performance nodes to a log file.
*
* PARAMS
* None.
*
* RETURNS
* Nothing.
*/
void
WINAPI
StopWatchFlush
()
{
FIXME
(
"() stub!
\n
"
);
}
/*************************************************************************
* @ [SHLWAPI.243]
*
* Write a performance event to a log file
*
* PARAMS
* dwClass [I] Class of event
* lpszStr [I] Text of event to log
* dwUnknown [I] Unknown
* dwMode [I] Mode flags
* dwTimeStamp [I] Timestamp
*
* RETURNS
* Success: ERROR_SUCCESS.
* Failure: A standard Win32 error code indicating the failure.
*/
DWORD
WINAPI
StopWatchA
(
DWORD
dwClass
,
LPCSTR
lpszStr
,
DWORD
dwUnknown
,
DWORD
dwMode
,
DWORD
dwTimeStamp
)
{
FIXME
(
"(%ld,%s,%ld,%ld,%ld) stub!
\n
"
,
dwClass
,
debugstr_a
(
lpszStr
),
dwUnknown
,
dwMode
,
dwTimeStamp
);
return
ERROR_SUCCESS
;
}
/*************************************************************************
* @ [SHLWAPI.244]
*
* See StopWatchA.
*/
DWORD
WINAPI
StopWatchW
(
DWORD
dwClass
,
LPCWSTR
lpszStr
,
DWORD
dwUnknown
,
DWORD
dwMode
,
DWORD
dwTimeStamp
)
{
char
szBuff
[
MAX_PATH
];
if
(
!
WideCharToMultiByte
(
0
,
0
,
lpszStr
,
-
1
,
szBuff
,
MAX_PATH
,
0
,
0
))
return
ERROR_NOT_ENOUGH_MEMORY
;
return
StopWatchA
(
dwClass
,
szBuff
,
dwUnknown
,
dwMode
,
dwTimeStamp
);
}
/*************************************************************************
* @ [SHLWAPI.245]
*
* Log a shell frame event.
*
* PARAMS
* hWnd [I] Window having the event
* pvUnknown1 [I] Unknown
* bUnknown2 [I] Unknown
* pClassWnd [I] Window of class to log
*
* RETURNS
* Nothing.
*/
void
WINAPI
StopWatch_TimerHandler
(
HWND
hWnd
,
PVOID
pvUnknown1
,
BOOL
bUnknown2
,
HWND
*
pClassWnd
)
{
FIXME
(
"(%p,%p,%d,%p) stub!
\n
"
,
hWnd
,
pvUnknown1
,
bUnknown2
,
pClassWnd
);
}
/* FIXME: Parameters for @246:StopWatch_CheckMsg unknown */
/*************************************************************************
* @ [SHLWAPI.247]
*
* Log the start of an applet.
*
* PARAMS
* lpszName [I] Name of the applet
*
* RETURNS
* Nothing.
*/
void
WINAPI
StopWatch_MarkFrameStart
(
LPCSTR
lpszName
)
{
FIXME
(
"(%s) stub!
\n
"
,
debugstr_a
(
lpszName
));
}
/* FIXME: Parameters for @248:StopWatch_MarkSameFrameStart unknown */
/*************************************************************************
* @ [SHLWAPI.249]
*
* Log a java applet stopping.
*
* PARAMS
* lpszEvent [I] Name of the event (applet)
* hWnd [I] Window running the applet
* dwReserved [I] Unused
*
* RETURNS
* Nothing.
*/
void
WINAPI
StopWatch_MarkJavaStop
(
LPCWSTR
lpszEvent
,
HWND
hWnd
,
DWORD
dwReserved
)
{
FIXME
(
"(%s,%p,0x%08lx) stub!
\n
"
,
debugstr_w
(
lpszEvent
),
hWnd
,
dwReserved
);
}
/*************************************************************************
* @ [SHLWAPI.250]
*
* Read the performance counter.
*
* PARAMS
* None.
*
* RETURNS
* The low 32 bits of the current performance counter reading.
*/
DWORD
WINAPI
GetPerfTime
()
{
static
LONG64
iCounterFreq
=
0
;
LARGE_INTEGER
iCounter
;
TRACE
(
"()
\n
"
);
if
(
!
iCounterFreq
)
QueryPerformanceFrequency
((
LARGE_INTEGER
*
)
&
iCounterFreq
);
QueryPerformanceCounter
(
&
iCounter
);
iCounter
.
QuadPart
=
iCounter
.
QuadPart
*
1000
/
iCounterFreq
;
return
iCounter
.
u
.
LowPart
;
}
/* FIXME: Parameters for @251:StopWatch_DispatchTime unknown */
/*************************************************************************
* @ [SHLWAPI.252]
*
* Set an as yet unidentified performance value.
*
* PARAMS
* dwUnknown [I] Value to set
*
* RETURNS
* dwUnknown.
*/
DWORD
WINAPI
StopWatch_SetMsgLastLocation
(
DWORD
dwUnknown
)
{
FIXME
(
"(%ld) stub!
\n
"
,
dwUnknown
);
return
dwUnknown
;
}
/* FIXME: Parameters for @253:StopWatchExA, 254:StopWatchExW unknown */
dlls/shlwapi/string.c
View file @
2e2d6ec7
...
...
@@ -38,11 +38,27 @@
#include "wingdi.h"
#include "winuser.h"
#include "shlobj.h"
#include "ddeml.h"
#include "wine/unicode.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
shell
);
/* Get a function pointer from a DLL handle */
#define GET_FUNC(func, module, name, fail) \
do { \
if (!func) { \
if (!SHLWAPI_h##module && !(SHLWAPI_h##module = LoadLibraryA(#module ".dll"))) return fail; \
func = (fn##func)GetProcAddress(SHLWAPI_h##module, name); \
if (!func) return fail; \
} \
} while (0)
extern
HMODULE
SHLWAPI_hmlang
;
typedef
HRESULT
(
WINAPI
*
fnpConvertINetUnicodeToMultiByte
)(
LPDWORD
,
DWORD
,
LPCWSTR
,
LPINT
,
LPSTR
,
LPINT
);
static
fnpConvertINetUnicodeToMultiByte
pConvertINetUnicodeToMultiByte
;
static
HRESULT
WINAPI
_SHStrDupAA
(
LPCSTR
,
LPSTR
*
);
static
HRESULT
WINAPI
_SHStrDupAW
(
LPCWSTR
,
LPSTR
*
);
...
...
@@ -2390,6 +2406,38 @@ LPSTR WINAPI StrFormatByteSizeA(DWORD dwBytes, LPSTR lpszDest, UINT cchMax)
}
/*************************************************************************
* @ [SHLWAPI.162]
*
* Remove a hanging lead byte from the end of a string, if present.
*
* PARAMS
* lpStr [I] String to check for a hanging lead byte
* size [I] Length of lpStr
*
* RETURNS
* Success: The new length of the string. Any hanging lead bytes are removed.
* Failure: 0, if any parameters are invalid.
*/
DWORD
WINAPI
SHTruncateString
(
LPSTR
lpStr
,
DWORD
size
)
{
if
(
lpStr
&&
size
)
{
LPSTR
lastByte
=
lpStr
+
size
-
1
;
while
(
lpStr
<
lastByte
)
lpStr
+=
IsDBCSLeadByte
(
*
lpStr
)
?
2
:
1
;
if
(
lpStr
==
lastByte
&&
IsDBCSLeadByte
(
*
lpStr
))
{
*
lpStr
=
'\0'
;
size
--
;
}
return
size
;
}
return
0
;
}
/*************************************************************************
* @ [SHLWAPI.203]
*
* Remove a single non-trailing ampersand ('&') from a string.
...
...
@@ -2429,3 +2477,189 @@ char WINAPI SHStripMneumonicA(LPCSTR lpszStr)
return
ch
;
}
/*************************************************************************
* @ [SHLWAPI.215]
*
* Convert an Ascii string to Unicode.
*
* PARAMS
* lpSrcStr [I] Source Ascii string to convert
* lpDstStr [O] Destination for converted Unicode string
* iLen [I] Length of lpDstStr
*
* RETURNS
* The return value of the MultiByteToWideChar() function called on lpSrcStr.
*/
DWORD
WINAPI
SHAnsiToUnicode
(
LPCSTR
lpSrcStr
,
LPWSTR
lpDstStr
,
int
iLen
)
{
DWORD
dwRet
;
dwRet
=
MultiByteToWideChar
(
CP_ACP
,
0
,
lpSrcStr
,
-
1
,
lpDstStr
,
iLen
);
TRACE
(
"%s->%s,ret=%ld
\n
"
,
debugstr_a
(
lpSrcStr
),
debugstr_w
(
lpDstStr
),
dwRet
);
return
dwRet
;
}
/*************************************************************************
* @ [SHLWAPI.218]
*
* Convert a Unicode string to Ascii.
*
* PARAMS
* CodePage [I] Code page to use for the conversion
* lpSrcStr [I] Source Unicode string to convert
* lpDstStr [O] Destination for converted Ascii string
* lpiLen [I/O] Input length of lpDstStr/destination for length of lpDstStr
*
* RETURNS
* Success: The number of characters that result from the conversion.
* Failure: 0.
*/
INT
WINAPI
SHUnicodeToAnsiCP
(
UINT
CodePage
,
LPCWSTR
lpSrcStr
,
LPSTR
lpDstStr
,
LPINT
lpiLen
)
{
WCHAR
emptyW
[]
=
{
'\0'
};
int
len
,
reqLen
;
LPSTR
mem
;
if
(
!
lpDstStr
||
!
lpiLen
)
return
0
;
if
(
!
lpSrcStr
)
lpSrcStr
=
emptyW
;
*
lpDstStr
=
'\0'
;
len
=
strlenW
(
lpSrcStr
)
+
1
;
switch
(
CodePage
)
{
case
CP_WINUNICODE
:
CodePage
=
CP_UTF8
;
/* Fall through... */
case
0x0000C350
:
/* FIXME: CP_ #define */
case
CP_UTF7
:
case
CP_UTF8
:
{
DWORD
dwMode
=
0
;
INT
nWideCharCount
=
len
-
1
;
GET_FUNC
(
pConvertINetUnicodeToMultiByte
,
mlang
,
"ConvertINetUnicodeToMultiByte"
,
0
);
if
(
!
pConvertINetUnicodeToMultiByte
(
&
dwMode
,
CodePage
,
lpSrcStr
,
&
nWideCharCount
,
lpDstStr
,
lpiLen
))
return
0
;
if
(
nWideCharCount
<
len
-
1
)
{
mem
=
(
LPSTR
)
HeapAlloc
(
GetProcessHeap
(),
0
,
*
lpiLen
);
if
(
!
mem
)
return
0
;
*
lpiLen
=
0
;
if
(
pConvertINetUnicodeToMultiByte
(
&
dwMode
,
CodePage
,
lpSrcStr
,
&
len
,
mem
,
lpiLen
))
{
SHTruncateString
(
mem
,
*
lpiLen
);
lstrcpynA
(
lpDstStr
,
mem
,
*
lpiLen
+
1
);
return
*
lpiLen
+
1
;
}
HeapFree
(
GetProcessHeap
(),
0
,
mem
);
return
*
lpiLen
;
}
lpDstStr
[
*
lpiLen
]
=
'\0'
;
return
*
lpiLen
;
}
break
;
default:
break
;
}
reqLen
=
WideCharToMultiByte
(
CodePage
,
0
,
lpSrcStr
,
len
,
lpDstStr
,
*
lpiLen
,
NULL
,
NULL
);
if
(
!
reqLen
&&
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
)
{
reqLen
=
WideCharToMultiByte
(
CodePage
,
0
,
lpSrcStr
,
len
,
NULL
,
0
,
NULL
,
NULL
);
if
(
reqLen
)
{
mem
=
(
LPSTR
)
HeapAlloc
(
GetProcessHeap
(),
0
,
reqLen
);
if
(
mem
)
{
reqLen
=
WideCharToMultiByte
(
CodePage
,
0
,
lpSrcStr
,
len
,
mem
,
reqLen
,
NULL
,
NULL
);
reqLen
=
SHTruncateString
(
mem
,
*
lpiLen
);
reqLen
++
;
lstrcpynA
(
lpDstStr
,
mem
,
*
lpiLen
);
HeapFree
(
GetProcessHeap
(),
0
,
mem
);
}
}
}
return
reqLen
;
}
/*************************************************************************
* @ [SHLWAPI.217]
*
* Convert a Unicode string to Ascii.
*
* PARAMS
* lpSrcStr [I] Source Unicode string to convert
* lpDstStr [O] Destination for converted Ascii string
* iLen [O] Length of lpDstStr in characters
*
* RETURNS
* See SHUnicodeToAnsiCP
* NOTES
* This function simply calls SHUnicodeToAnsiCP() with CodePage = CP_ACP.
*/
INT
WINAPI
SHUnicodeToAnsi
(
LPCWSTR
lpSrcStr
,
LPSTR
lpDstStr
,
INT
iLen
)
{
INT
myint
=
iLen
;
return
SHUnicodeToAnsiCP
(
CP_ACP
,
lpSrcStr
,
lpDstStr
,
&
myint
);
}
/*************************************************************************
* @ [SHLWAPI.364]
*
* Determine if an Ascii string converts to Unicode and back identically.
*
* PARAMS
* lpSrcStr [I] Source Unicode string to convert
* lpDst [O] Destination for resulting Ascii string
* iLen [I] Length of lpDst in characters
*
* RETURNS
* TRUE, since Ascii strings always convert identically.
*/
BOOL
WINAPI
DoesStringRoundTripA
(
LPCSTR
lpSrcStr
,
LPSTR
lpDst
,
INT
iLen
)
{
lstrcpynA
(
lpDst
,
lpSrcStr
,
iLen
);
return
TRUE
;
}
/*************************************************************************
* @ [SHLWAPI.365]
*
* Determine if a Unicode string converts to Ascii and back identically.
*
* PARAMS
* lpSrcStr [I] Source Unicode string to convert
* lpDst [O] Destination for resulting Ascii string
* iLen [I] Length of lpDst in characters
*
* RETURNS
* TRUE, if lpSrcStr converts to Ascii and back identically,
* FALSE otherwise.
*/
BOOL
WINAPI
DoesStringRoundTripW
(
LPCWSTR
lpSrcStr
,
LPSTR
lpDst
,
INT
iLen
)
{
WCHAR
szBuff
[
MAX_PATH
];
SHUnicodeToAnsi
(
lpSrcStr
,
lpDst
,
iLen
);
SHAnsiToUnicode
(
lpDst
,
szBuff
,
MAX_PATH
);
return
!
strcmpW
(
lpSrcStr
,
szBuff
);
}
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