2000-07-26 17:51:32 +00:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2001-11-05 23:55:36 +00:00
|
|
|
#include <wctype.h>
|
2000-07-26 17:51:32 +00:00
|
|
|
|
|
|
|
#include "winerror.h"
|
2000-09-13 20:28:31 +00:00
|
|
|
#include "windef.h"
|
2000-09-26 00:00:55 +00:00
|
|
|
#include "winbase.h"
|
2000-09-13 20:28:31 +00:00
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "shlwapi.h"
|
2000-09-26 00:00:55 +00:00
|
|
|
#include "shlobj.h"
|
2000-07-26 17:51:32 +00:00
|
|
|
#include "wine/unicode.h"
|
|
|
|
#include "debugtools.h"
|
|
|
|
|
|
|
|
DEFAULT_DEBUG_CHANNEL(shell);
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrChrA [SHLWAPI.@]
|
2000-07-26 17:51:32 +00:00
|
|
|
*/
|
2000-09-13 20:28:31 +00:00
|
|
|
LPSTR WINAPI StrChrA (LPCSTR str, WORD c)
|
2000-07-26 17:51:32 +00:00
|
|
|
{
|
|
|
|
TRACE("%s %i\n", str,c);
|
|
|
|
return strchr(str, c);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrChrW [SHLWAPI.@]
|
2000-07-26 17:51:32 +00:00
|
|
|
*
|
|
|
|
*/
|
2000-09-13 20:28:31 +00:00
|
|
|
LPWSTR WINAPI StrChrW (LPCWSTR str, WCHAR x )
|
2000-07-26 17:51:32 +00:00
|
|
|
{
|
|
|
|
TRACE("%s 0x%04x\n",debugstr_w(str),x);
|
|
|
|
return strchrW(str, x);
|
|
|
|
}
|
|
|
|
|
2000-11-25 21:43:48 +00:00
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrCmpIW [SHLWAPI.@]
|
2000-11-25 21:43:48 +00:00
|
|
|
*/
|
|
|
|
int WINAPI StrCmpIW ( LPCWSTR wstr1, LPCWSTR wstr2 )
|
|
|
|
{
|
|
|
|
TRACE("%s %s\n", debugstr_w(wstr1),debugstr_w(wstr2));
|
|
|
|
return strcmpiW( wstr1, wstr2 );
|
|
|
|
}
|
|
|
|
|
2000-07-26 17:51:32 +00:00
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrCmpNA [SHLWAPI.@]
|
2000-07-26 17:51:32 +00:00
|
|
|
*/
|
|
|
|
INT WINAPI StrCmpNA ( LPCSTR str1, LPCSTR str2, INT len)
|
|
|
|
{
|
|
|
|
TRACE("%s %s %i stub\n", str1,str2,len);
|
|
|
|
return strncmp(str1, str2, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrCmpNW [SHLWAPI.@]
|
2000-07-26 17:51:32 +00:00
|
|
|
*/
|
|
|
|
INT WINAPI StrCmpNW ( LPCWSTR wstr1, LPCWSTR wstr2, INT len)
|
|
|
|
{
|
|
|
|
TRACE("%s %s %i stub\n", debugstr_w(wstr1),debugstr_w(wstr2),len);
|
|
|
|
return strncmpW(wstr1, wstr2, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrCmpNIA [SHLWAPI.@]
|
2000-07-26 17:51:32 +00:00
|
|
|
*/
|
|
|
|
int WINAPI StrCmpNIA ( LPCSTR str1, LPCSTR str2, int len)
|
|
|
|
{
|
|
|
|
TRACE("%s %s %i stub\n", str1,str2,len);
|
|
|
|
return strncasecmp(str1, str2, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrCmpNIW [SHLWAPI.@]
|
2000-07-26 17:51:32 +00:00
|
|
|
*/
|
|
|
|
int WINAPI StrCmpNIW ( LPCWSTR wstr1, LPCWSTR wstr2, int len)
|
|
|
|
{
|
|
|
|
TRACE("%s %s %i stub\n", debugstr_w(wstr1),debugstr_w(wstr2),len);
|
|
|
|
return strncmpiW(wstr1, wstr2, len);
|
|
|
|
}
|
|
|
|
|
2000-11-25 21:43:48 +00:00
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrCmpW [SHLWAPI.@]
|
2000-11-25 21:43:48 +00:00
|
|
|
*/
|
|
|
|
int WINAPI StrCmpW ( LPCWSTR wstr1, LPCWSTR wstr2 )
|
|
|
|
{
|
|
|
|
TRACE("%s %s\n", debugstr_w(wstr1),debugstr_w(wstr2));
|
|
|
|
return strcmpW( wstr1, wstr2 );
|
|
|
|
}
|
|
|
|
|
2000-08-14 14:42:41 +00:00
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrCatW [SHLWAPI.@]
|
2000-08-14 14:42:41 +00:00
|
|
|
*/
|
|
|
|
LPWSTR WINAPI StrCatW( LPWSTR wstr1, LPCWSTR wstr2 )
|
|
|
|
{
|
|
|
|
return strcatW( wstr1, wstr2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrCpyW [SHLWAPI.@]
|
2000-08-14 14:42:41 +00:00
|
|
|
*/
|
|
|
|
LPWSTR WINAPI StrCpyW( LPWSTR wstr1, LPCWSTR wstr2 )
|
|
|
|
{
|
|
|
|
return strcpyW( wstr1, wstr2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-25 21:43:48 +00:00
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrCpyNW [SHLWAPI.@]
|
2000-11-25 21:43:48 +00:00
|
|
|
*/
|
|
|
|
LPWSTR WINAPI StrCpyNW( LPWSTR wstr1, LPCWSTR wstr2, int n )
|
|
|
|
{
|
|
|
|
return lstrcpynW( wstr1, wstr2, n );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-26 17:51:32 +00:00
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrStrA [SHLWAPI.@]
|
2000-07-26 17:51:32 +00:00
|
|
|
*/
|
|
|
|
LPSTR WINAPI StrStrA(LPCSTR lpFirst, LPCSTR lpSrch)
|
|
|
|
{
|
|
|
|
while (*lpFirst)
|
|
|
|
{
|
|
|
|
LPCSTR p1 = lpFirst, p2 = lpSrch;
|
|
|
|
while (*p1 && *p2 && *p1 == *p2) { p1++; p2++; }
|
|
|
|
if (!*p2) return (LPSTR)lpFirst;
|
|
|
|
lpFirst++;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrStrW [SHLWAPI.@]
|
2000-07-26 17:51:32 +00:00
|
|
|
*/
|
|
|
|
LPWSTR WINAPI StrStrW(LPCWSTR lpFirst, LPCWSTR lpSrch)
|
|
|
|
{
|
|
|
|
while (*lpFirst)
|
|
|
|
{
|
|
|
|
LPCWSTR p1 = lpFirst, p2 = lpSrch;
|
|
|
|
while (*p1 && *p2 && *p1 == *p2) { p1++; p2++; }
|
|
|
|
if (!*p2) return (LPWSTR)lpFirst;
|
|
|
|
lpFirst++;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrStrIA [SHLWAPI.@]
|
2000-07-26 17:51:32 +00:00
|
|
|
*/
|
|
|
|
LPSTR WINAPI StrStrIA(LPCSTR lpFirst, LPCSTR lpSrch)
|
|
|
|
{
|
|
|
|
while (*lpFirst)
|
|
|
|
{
|
|
|
|
LPCSTR p1 = lpFirst, p2 = lpSrch;
|
|
|
|
while (*p1 && *p2 && toupper(*p1) == toupper(*p2)) { p1++; p2++; }
|
|
|
|
if (!*p2) return (LPSTR)lpFirst;
|
|
|
|
lpFirst++;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrStrIW [SHLWAPI.@]
|
2000-07-26 17:51:32 +00:00
|
|
|
*/
|
|
|
|
LPWSTR WINAPI StrStrIW(LPCWSTR lpFirst, LPCWSTR lpSrch)
|
|
|
|
{
|
|
|
|
while (*lpFirst)
|
|
|
|
{
|
|
|
|
LPCWSTR p1 = lpFirst, p2 = lpSrch;
|
|
|
|
while (*p1 && *p2 && toupperW(*p1) == toupperW(*p2)) { p1++; p2++; }
|
|
|
|
if (!*p2) return (LPWSTR)lpFirst;
|
|
|
|
lpFirst++;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrToIntA [SHLWAPI.@]
|
2000-07-26 17:51:32 +00:00
|
|
|
*/
|
|
|
|
int WINAPI StrToIntA(LPCSTR lpSrc)
|
|
|
|
{
|
|
|
|
TRACE("%s\n", lpSrc);
|
|
|
|
return atol(lpSrc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrToIntW [SHLWAPI.@]
|
2000-07-26 17:51:32 +00:00
|
|
|
*/
|
|
|
|
int WINAPI StrToIntW(LPCWSTR lpSrc)
|
|
|
|
{
|
2000-11-16 00:28:52 +00:00
|
|
|
char buffer[32];
|
2000-07-26 17:51:32 +00:00
|
|
|
|
2000-11-16 00:28:52 +00:00
|
|
|
TRACE("%s\n", debugstr_w(lpSrc));
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, lpSrc, -1, buffer, sizeof(buffer), NULL, NULL );
|
|
|
|
buffer[sizeof(buffer)-1] = 0;
|
|
|
|
return atol(buffer);
|
2000-07-26 17:51:32 +00:00
|
|
|
}
|
|
|
|
|
2001-04-25 19:51:56 +00:00
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrToIntExA [SHLWAPI.@]
|
2001-04-25 19:51:56 +00:00
|
|
|
*/
|
|
|
|
BOOL WINAPI StrToIntExA( LPCSTR pszString, DWORD dwFlags, LPINT piRet)
|
|
|
|
{
|
|
|
|
TRACE("%s %ld stub !\n", debugstr_a(pszString), dwFlags);
|
|
|
|
piRet = (LPINT) StrToIntA(pszString);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrToIntExW [SHLWAPI.@]
|
2001-04-25 19:51:56 +00:00
|
|
|
*/
|
|
|
|
BOOL WINAPI StrToIntExW( LPCWSTR pszString, DWORD dwFlags, LPINT piRet)
|
|
|
|
{
|
|
|
|
TRACE("%s %ld stub !\n", debugstr_w(pszString), dwFlags);
|
|
|
|
piRet = (LPINT) StrToIntW(pszString);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2000-07-26 17:51:32 +00:00
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrDupA [SHLWAPI.@]
|
2000-07-26 17:51:32 +00:00
|
|
|
*/
|
|
|
|
LPSTR WINAPI StrDupA (LPCSTR lpSrc)
|
|
|
|
{
|
|
|
|
int len = strlen(lpSrc);
|
|
|
|
LPSTR lpDest = (LPSTR) LocalAlloc(LMEM_FIXED, len+1);
|
|
|
|
|
|
|
|
TRACE("%s\n", lpSrc);
|
|
|
|
|
|
|
|
if (lpDest) strcpy(lpDest, lpSrc);
|
|
|
|
return lpDest;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrDupW [SHLWAPI.@]
|
2000-07-26 17:51:32 +00:00
|
|
|
*/
|
|
|
|
LPWSTR WINAPI StrDupW (LPCWSTR lpSrc)
|
|
|
|
{
|
2000-08-06 02:42:46 +00:00
|
|
|
int len = strlenW(lpSrc);
|
2000-07-26 17:51:32 +00:00
|
|
|
LPWSTR lpDest = (LPWSTR) LocalAlloc(LMEM_FIXED, sizeof(WCHAR) * (len+1));
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_w(lpSrc));
|
|
|
|
|
2000-08-14 14:42:41 +00:00
|
|
|
if (lpDest) strcpyW(lpDest, lpSrc);
|
2000-07-26 17:51:32 +00:00
|
|
|
return lpDest;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrCSpnA [SHLWAPI.@]
|
2000-07-26 17:51:32 +00:00
|
|
|
*/
|
|
|
|
int WINAPI StrCSpnA (LPCSTR lpStr, LPCSTR lpSet)
|
|
|
|
{
|
|
|
|
int i,j, pos = strlen(lpStr);
|
|
|
|
|
|
|
|
TRACE("(%p %s %p %s)\n",
|
|
|
|
lpStr, debugstr_a(lpStr), lpSet, debugstr_a(lpSet));
|
|
|
|
|
|
|
|
for (i=0; i < strlen(lpSet) ; i++ )
|
|
|
|
{
|
|
|
|
for (j = 0; j < pos;j++)
|
|
|
|
{
|
|
|
|
if (lpStr[j] == lpSet[i])
|
|
|
|
{
|
|
|
|
pos = j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TRACE("-- %u\n", pos);
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrCSpnW [SHLWAPI.@]
|
2000-07-26 17:51:32 +00:00
|
|
|
*/
|
|
|
|
int WINAPI StrCSpnW (LPCWSTR lpStr, LPCWSTR lpSet)
|
|
|
|
{
|
2000-08-06 02:42:46 +00:00
|
|
|
int i,j, pos = strlenW(lpStr);
|
2000-07-26 17:51:32 +00:00
|
|
|
|
|
|
|
TRACE("(%p %s %p %s)\n",
|
|
|
|
lpStr, debugstr_w(lpStr), lpSet, debugstr_w(lpSet));
|
|
|
|
|
2000-08-06 02:42:46 +00:00
|
|
|
for (i=0; i < strlenW(lpSet) ; i++ )
|
2000-07-26 17:51:32 +00:00
|
|
|
{
|
|
|
|
for (j = 0; j < pos;j++)
|
|
|
|
{
|
|
|
|
if (lpStr[j] == lpSet[i])
|
|
|
|
{
|
|
|
|
pos = j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TRACE("-- %u\n", pos);
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
2000-08-06 02:42:46 +00:00
|
|
|
/**************************************************************************
|
|
|
|
* StrRChrA [SHLWAPI.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
LPSTR WINAPI StrRChrA( LPCSTR lpStart, LPCSTR lpEnd, WORD wMatch )
|
|
|
|
{
|
|
|
|
LPCSTR lpGotIt = NULL;
|
|
|
|
BOOL dbcs = IsDBCSLeadByte( LOBYTE(wMatch) );
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %x)\n", lpStart, lpEnd, wMatch);
|
|
|
|
|
|
|
|
if (!lpEnd) lpEnd = lpStart + strlen(lpStart);
|
|
|
|
|
|
|
|
for(; lpStart < lpEnd; lpStart = CharNextA(lpStart))
|
|
|
|
{
|
|
|
|
if (*lpStart != LOBYTE(wMatch)) continue;
|
|
|
|
if (dbcs && lpStart[1] != HIBYTE(wMatch)) continue;
|
|
|
|
lpGotIt = lpStart;
|
|
|
|
}
|
|
|
|
return (LPSTR)lpGotIt;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* StrRChrW [SHLWAPI.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
LPWSTR WINAPI StrRChrW( LPCWSTR lpStart, LPCWSTR lpEnd, WORD wMatch)
|
|
|
|
{
|
|
|
|
LPCWSTR lpGotIt = NULL;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %x)\n", lpStart, lpEnd, wMatch);
|
|
|
|
if (!lpEnd) lpEnd = lpStart + strlenW(lpStart);
|
|
|
|
|
|
|
|
for(; lpStart < lpEnd; lpStart = CharNextW(lpStart))
|
|
|
|
if (*lpStart == wMatch) lpGotIt = lpStart;
|
|
|
|
|
|
|
|
return (LPWSTR)lpGotIt;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-05 23:55:36 +00:00
|
|
|
/**************************************************************************
|
|
|
|
* StrRChrIA [SHLWAPI.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
LPSTR WINAPI StrRChrIA( LPCSTR lpStart, LPCSTR lpEnd, WORD wMatch )
|
|
|
|
{
|
|
|
|
LPCSTR lpGotIt = NULL;
|
|
|
|
BOOL dbcs = IsDBCSLeadByte( LOBYTE(wMatch) );
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %x)\n", lpStart, lpEnd, wMatch);
|
|
|
|
|
|
|
|
if (!lpEnd) lpEnd = lpStart + strlen(lpStart);
|
|
|
|
|
|
|
|
for(; lpStart < lpEnd; lpStart = CharNextA(lpStart))
|
|
|
|
{
|
|
|
|
if (dbcs) {
|
|
|
|
/*
|
|
|
|
if (_mbctoupper(*lpStart) == _mbctoupper(wMatch))
|
|
|
|
lpGotIt = lpStart;
|
|
|
|
*/
|
|
|
|
if (toupper(*lpStart) == toupper(wMatch)) lpGotIt = lpStart;
|
|
|
|
} else {
|
|
|
|
if (toupper(*lpStart) == toupper(wMatch)) lpGotIt = lpStart;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (LPSTR)lpGotIt;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* StrRChrIW [SHLWAPI.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
LPWSTR WINAPI StrRChrIW( LPCWSTR lpStart, LPCWSTR lpEnd, WORD wMatch)
|
|
|
|
{
|
|
|
|
LPCWSTR lpGotIt = NULL;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %x)\n", lpStart, lpEnd, wMatch);
|
|
|
|
if (!lpEnd) lpEnd = lpStart + strlenW(lpStart);
|
|
|
|
|
|
|
|
for(; lpStart < lpEnd; lpStart = CharNextW(lpStart))
|
|
|
|
if (towupper(*lpStart) == towupper(wMatch)) lpGotIt = lpStart;
|
|
|
|
|
|
|
|
return (LPWSTR)lpGotIt;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-26 17:51:32 +00:00
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrCatBuffA [SHLWAPI.@]
|
2000-07-26 17:51:32 +00:00
|
|
|
*
|
|
|
|
* Appends back onto front, stopping when front is size-1 characters long.
|
|
|
|
* Returns front.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
LPSTR WINAPI StrCatBuffA(LPSTR front, LPCSTR back, INT size)
|
|
|
|
{
|
2000-08-06 02:42:46 +00:00
|
|
|
LPSTR dst = front + strlen(front);
|
2000-07-26 17:51:32 +00:00
|
|
|
LPCSTR src = back, end = front + size - 1;
|
|
|
|
|
|
|
|
while(dst < end && *src)
|
|
|
|
*dst++ = *src++;
|
|
|
|
*dst = '\0';
|
|
|
|
return front;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrCatBuffW [SHLWAPI.@]
|
2000-07-26 17:51:32 +00:00
|
|
|
*
|
|
|
|
* Appends back onto front, stopping when front is size-1 characters long.
|
|
|
|
* Returns front.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
LPWSTR WINAPI StrCatBuffW(LPWSTR front, LPCWSTR back, INT size)
|
|
|
|
{
|
2000-08-06 02:42:46 +00:00
|
|
|
LPWSTR dst = front + strlenW(front);
|
2000-07-26 17:51:32 +00:00
|
|
|
LPCWSTR src = back, end = front + size - 1;
|
|
|
|
|
|
|
|
while(dst < end && *src)
|
|
|
|
*dst++ = *src++;
|
|
|
|
*dst = '\0';
|
|
|
|
return front;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* StrRetToBufA [SHLWAPI.@]
|
|
|
|
*
|
|
|
|
* converts a STRRET to a normal string
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* the pidl is for STRRET OFFSET
|
2001-11-05 23:55:36 +00:00
|
|
|
*
|
|
|
|
* ***** NOTE *****
|
|
|
|
* This routine is identical to StrRetToStrNA in dlls/shell32/shellstring.c.
|
|
|
|
* It was duplicated there because not every version of Shlwapi.dll exports
|
|
|
|
* StrRetToBufA. If you change one routine, change them both. YOU HAVE BEEN
|
|
|
|
* WARNED.
|
|
|
|
* ***** NOTE *****
|
2000-07-26 17:51:32 +00:00
|
|
|
*/
|
2000-09-26 00:00:55 +00:00
|
|
|
HRESULT WINAPI StrRetToBufA (LPSTRRET src, const ITEMIDLIST *pidl, LPSTR dest, DWORD len)
|
2000-07-26 17:51:32 +00:00
|
|
|
{
|
2001-11-06 21:01:32 +00:00
|
|
|
TRACE("dest=%p len=0x%lx strret=%p pidl=%p stub\n",dest,len,src,pidl);
|
2000-07-26 17:51:32 +00:00
|
|
|
|
|
|
|
switch (src->uType)
|
|
|
|
{
|
|
|
|
case STRRET_WSTR:
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, src->u.pOleStr, -1, (LPSTR)dest, len, NULL, NULL);
|
|
|
|
/* SHFree(src->u.pOleStr); FIXME: is this right? */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case STRRET_CSTRA:
|
|
|
|
lstrcpynA((LPSTR)dest, src->u.cStr, len);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case STRRET_OFFSETA:
|
|
|
|
lstrcpynA((LPSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("unknown type!\n");
|
|
|
|
if (len)
|
|
|
|
{
|
|
|
|
*(LPSTR)dest = '\0';
|
|
|
|
}
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* StrRetToBufW [SHLWAPI.@]
|
|
|
|
*
|
|
|
|
* converts a STRRET to a normal string
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* the pidl is for STRRET OFFSET
|
2001-11-05 23:55:36 +00:00
|
|
|
*
|
|
|
|
* ***** NOTE *****
|
|
|
|
* This routine is identical to StrRetToStrNW in dlls/shell32/shellstring.c.
|
|
|
|
* It was duplicated there because not every version of Shlwapi.dll exports
|
|
|
|
* StrRetToBufW. If you change one routine, change them both. YOU HAVE BEEN
|
|
|
|
* WARNED.
|
|
|
|
* ***** NOTE *****
|
2000-07-26 17:51:32 +00:00
|
|
|
*/
|
2000-09-26 00:00:55 +00:00
|
|
|
HRESULT WINAPI StrRetToBufW (LPSTRRET src, const ITEMIDLIST *pidl, LPWSTR dest, DWORD len)
|
2000-07-26 17:51:32 +00:00
|
|
|
{
|
2001-11-06 21:01:32 +00:00
|
|
|
TRACE("dest=%p len=0x%lx strret=%p pidl=%p stub\n",dest,len,src,pidl);
|
2000-07-26 17:51:32 +00:00
|
|
|
|
|
|
|
switch (src->uType)
|
|
|
|
{
|
|
|
|
case STRRET_WSTR:
|
|
|
|
lstrcpynW((LPWSTR)dest, src->u.pOleStr, len);
|
|
|
|
/* SHFree(src->u.pOleStr); FIXME: is this right? */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case STRRET_CSTRA:
|
2000-11-16 00:28:52 +00:00
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, dest, len ) && len)
|
|
|
|
dest[len-1] = 0;
|
2000-07-26 17:51:32 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case STRRET_OFFSETA:
|
|
|
|
if (pidl)
|
|
|
|
{
|
2000-11-16 00:28:52 +00:00
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset, -1,
|
|
|
|
dest, len ) && len)
|
|
|
|
dest[len-1] = 0;
|
2000-07-26 17:51:32 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("unknown type!\n");
|
|
|
|
if (len)
|
|
|
|
{ *(LPSTR)dest = '\0';
|
|
|
|
}
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrFormatByteSizeA [SHLWAPI.@]
|
2000-07-26 17:51:32 +00:00
|
|
|
*/
|
|
|
|
LPSTR WINAPI StrFormatByteSizeA ( DWORD dw, LPSTR pszBuf, UINT cchBuf )
|
|
|
|
{ char buf[64];
|
|
|
|
TRACE("%lx %p %i\n", dw, pszBuf, cchBuf);
|
|
|
|
if ( dw<1024L )
|
2000-11-27 22:03:23 +00:00
|
|
|
{ sprintf (buf,"%ld bytes", dw);
|
2000-07-26 17:51:32 +00:00
|
|
|
}
|
|
|
|
else if ( dw<1048576L)
|
|
|
|
{ sprintf (buf,"%3.1f KB", (FLOAT)dw/1024);
|
|
|
|
}
|
|
|
|
else if ( dw < 1073741824L)
|
|
|
|
{ sprintf (buf,"%3.1f MB", (FLOAT)dw/1048576L);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ sprintf (buf,"%3.1f GB", (FLOAT)dw/1073741824L);
|
|
|
|
}
|
|
|
|
lstrcpynA (pszBuf, buf, cchBuf);
|
|
|
|
return pszBuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrFormatByteSizeW [SHLWAPI.@]
|
2000-07-26 17:51:32 +00:00
|
|
|
*/
|
|
|
|
LPWSTR WINAPI StrFormatByteSizeW ( DWORD dw, LPWSTR pszBuf, UINT cchBuf )
|
2000-11-27 22:03:23 +00:00
|
|
|
{
|
|
|
|
char buf[64];
|
|
|
|
StrFormatByteSizeA( dw, buf, sizeof(buf) );
|
2000-11-16 00:28:52 +00:00
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, buf, -1, pszBuf, cchBuf ) && cchBuf)
|
|
|
|
pszBuf[cchBuf-1] = 0;
|
2000-11-27 22:03:23 +00:00
|
|
|
return pszBuf;
|
2000-07-26 17:51:32 +00:00
|
|
|
}
|
|
|
|
|
2001-04-25 19:51:56 +00:00
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrNCatA [SHLWAPI.@]
|
2001-04-25 19:51:56 +00:00
|
|
|
*/
|
|
|
|
LPSTR WINAPI StrNCatA(LPSTR front, LPCSTR back, INT cchMax)
|
|
|
|
{
|
|
|
|
TRACE("%s %s %i stub\n", debugstr_a(front),debugstr_a(back),cchMax);
|
|
|
|
return (front);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrNCatW [SHLWAPI.@]
|
2001-04-25 19:51:56 +00:00
|
|
|
*/
|
|
|
|
LPWSTR WINAPI StrNCatW(LPWSTR front, LPCWSTR back, INT cchMax)
|
|
|
|
{
|
|
|
|
TRACE("%s %s %i stub\n", debugstr_w(front),debugstr_w(back),cchMax);
|
|
|
|
return (front);
|
|
|
|
}
|
|
|
|
|
2001-05-24 18:41:56 +00:00
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* StrTrimA [SHLWAPI.@]
|
2001-05-24 18:41:56 +00:00
|
|
|
*/
|
|
|
|
BOOL WINAPI StrTrimA(LPSTR pszSource, LPCSTR pszTrimChars)
|
|
|
|
{
|
|
|
|
BOOL trimmed = FALSE;
|
|
|
|
LPSTR pSrc;
|
|
|
|
LPCSTR pTrim;
|
|
|
|
|
|
|
|
TRACE("('%s', '%s');\n", pszSource, pszTrimChars);
|
|
|
|
for (pTrim = pszTrimChars; *pTrim; pTrim++)
|
|
|
|
{
|
|
|
|
for (pSrc = pszSource; *pSrc; pSrc++)
|
|
|
|
if (*pSrc == *pTrim)
|
|
|
|
{
|
|
|
|
/* match -> remove this char.
|
|
|
|
* strlen(pSrc) equiv. to the correct strlen(pSrc+1)+1 */
|
|
|
|
memmove(pSrc, pSrc+1, strlen(pSrc));
|
|
|
|
trimmed = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TRACE("<- '%s'\n", pszSource);
|
|
|
|
return trimmed;
|
|
|
|
}
|
|
|
|
|
2000-07-26 17:51:32 +00:00
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* wnsprintfA [SHLWAPI.@]
|
2000-07-26 17:51:32 +00:00
|
|
|
*/
|
|
|
|
int WINAPIV wnsprintfA(LPSTR lpOut, int cchLimitIn, LPCSTR lpFmt, ...)
|
|
|
|
{
|
|
|
|
va_list valist;
|
|
|
|
INT res;
|
|
|
|
|
|
|
|
va_start( valist, lpFmt );
|
|
|
|
res = wvsnprintfA( lpOut, cchLimitIn, lpFmt, valist );
|
|
|
|
va_end( valist );
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-06-20 23:03:14 +00:00
|
|
|
* wnsprintfW [SHLWAPI.@]
|
2000-07-26 17:51:32 +00:00
|
|
|
*/
|
|
|
|
int WINAPIV wnsprintfW(LPWSTR lpOut, int cchLimitIn, LPCWSTR lpFmt, ...)
|
|
|
|
{
|
|
|
|
va_list valist;
|
|
|
|
INT res;
|
|
|
|
|
|
|
|
va_start( valist, lpFmt );
|
|
|
|
res = wvsnprintfW( lpOut, cchLimitIn, lpFmt, valist );
|
|
|
|
va_end( valist );
|
|
|
|
return res;
|
|
|
|
}
|