ReactOS 0.4.17-dev-357-ga8f14ff
string.c File Reference
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "shlwapi.h"
#include "wingdi.h"
#include "winuser.h"
#include "shlobj.h"
#include "mlang.h"
#include "ddeml.h"
#include "wine/unicode.h"
#include "wine/debug.h"
#include "resource.h"
Include dependency graph for string.c:

Go to the source code of this file.

Classes

struct  tagSHLWAPI_BYTEFORMATS
 

Macros

#define NO_SHLWAPI_REG
 
#define NO_SHLWAPI_STREAM
 
#define KB   ((ULONGLONG)1024)
 
#define MB   (KB*KB)
 
#define GB   (KB*KB*KB)
 
#define TB   (KB*KB*KB*KB)
 
#define PB   (KB*KB*KB*KB*KB)
 

Typedefs

typedef struct tagSHLWAPI_BYTEFORMATS SHLWAPI_BYTEFORMATS
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
static HRESULT _SHStrDupAA (LPCSTR, LPSTR *)
 
static HRESULT _SHStrDupAW (LPCWSTR, LPSTR *)
 
DWORD WINAPI SHTruncateString (LPSTR lpStr, DWORD size)
 
static void FillNumberFmt (NUMBERFMTW *fmt, LPWSTR decimal_buffer, int decimal_bufwlen, LPWSTR thousand_buffer, int thousand_bufwlen)
 
static int FormatInt (LONGLONG qdwValue, LPWSTR pszBuf, int cchBuf)
 
static int FormatDouble (double value, int decimals, LPWSTR pszBuf, int cchBuf)
 
LPWSTR WINAPI StrCatW (LPWSTR lpszStr, LPCWSTR lpszSrc)
 
LPWSTR WINAPI StrCpyW (LPWSTR lpszStr, LPCWSTR lpszSrc)
 
HRESULT WINAPI StrRetToBufA (LPSTRRET src, const ITEMIDLIST *pidl, LPSTR dest, UINT len)
 
HRESULT WINAPI StrRetToBufW (LPSTRRET src, const ITEMIDLIST *pidl, LPWSTR dest, UINT len)
 
HRESULT WINAPI StrRetToStrA (LPSTRRET lpStrRet, const ITEMIDLIST *pidl, LPSTR *ppszName)
 
HRESULT WINAPI StrRetToStrW (LPSTRRET lpStrRet, const ITEMIDLIST *pidl, LPWSTR *ppszName)
 
static HRESULT _SHStrDupAToBSTR (LPCSTR src, BSTR *pBstrOut)
 
HRESULT WINAPI StrRetToBSTR (STRRET *lpStrRet, LPCITEMIDLIST pidl, BSTR *pBstrOut)
 
LPSTR WINAPI StrFormatKBSizeA (LONGLONG llBytes, LPSTR lpszDest, UINT cchMax)
 
LPWSTR WINAPI StrFormatKBSizeW (LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
 
LPSTR WINAPI StrNCatA (LPSTR lpszStr, LPCSTR lpszCat, INT cchMax)
 
LPWSTR WINAPI StrNCatW (LPWSTR lpszStr, LPCWSTR lpszCat, INT cchMax)
 
HRESULT WINAPI SHStrDupA (LPCSTR lpszStr, LPWSTR *lppszDest)
 
HRESULT WINAPI SHStrDupW (LPCWSTR src, LPWSTR *dest)
 
static LPWSTR SHLWAPI_WriteReverseNum (LPWSTR lpszOut, DWORD dwNum)
 
static int SHLWAPI_FormatSignificant (LPWSTR lpszNum, int dwDigits)
 
static int SHLWAPI_WriteTimeClass (LPWSTR lpszOut, DWORD dwValue, UINT uClassStringId, int iDigits)
 
INT WINAPI StrFromTimeIntervalA (LPSTR lpszStr, UINT cchMax, DWORD dwMS, int iDigits)
 
INT WINAPI StrFromTimeIntervalW (LPWSTR lpszStr, UINT cchMax, DWORD dwMS, int iDigits)
 
LPWSTR WINAPI StrFormatByteSizeW (LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
 
HRESULT WINAPI StrFormatByteSizeEx (LONGLONG llBytes, SFBS_FLAGS flags, LPWSTR lpszDest, UINT cchMax)
 
LPSTR WINAPI StrFormatByteSize64A (LONGLONG llBytes, LPSTR lpszDest, UINT cchMax)
 
LPSTR WINAPI StrFormatByteSizeA (DWORD dwBytes, LPSTR lpszDest, UINT cchMax)
 
char WINAPI SHStripMneumonicA (LPCSTR lpszStr)
 
WCHAR WINAPI SHStripMneumonicW (LPCWSTR lpszStr)
 
DWORD WINAPI SHAnsiToUnicodeCP (DWORD dwCp, LPCSTR lpSrcStr, LPWSTR lpDstStr, int iLen)
 
DWORD WINAPI SHAnsiToUnicode (LPCSTR lpSrcStr, LPWSTR lpDstStr, int iLen)
 
DWORD WINAPI SHUnicodeToAnsiCP (UINT CodePage, LPCWSTR lpSrcStr, LPSTR lpDstStr, int dstlen)
 
INT WINAPI SHUnicodeToAnsi (LPCWSTR lpSrcStr, LPSTR lpDstStr, INT iLen)
 
BOOL WINAPI DoesStringRoundTripA (LPCSTR lpSrcStr, LPSTR lpDst, INT iLen)
 
BOOL WINAPI DoesStringRoundTripW (LPCWSTR lpSrcStr, LPSTR lpDst, INT iLen)
 

Variables

HINSTANCE shlwapi_hInstance
 

Macro Definition Documentation

◆ GB

#define GB   (KB*KB*KB)

◆ KB

#define KB   ((ULONGLONG)1024)

◆ MB

#define MB   (KB*KB)

◆ NO_SHLWAPI_REG

#define NO_SHLWAPI_REG

Definition at line 29 of file string.c.

◆ NO_SHLWAPI_STREAM

#define NO_SHLWAPI_STREAM

Definition at line 30 of file string.c.

◆ PB

#define PB   (KB*KB*KB*KB*KB)

◆ TB

#define TB   (KB*KB*KB*KB)

Typedef Documentation

◆ SHLWAPI_BYTEFORMATS

Function Documentation

◆ _SHStrDupAA()

static HRESULT _SHStrDupAA ( LPCSTR  src,
LPSTR dest 
)
static

Definition at line 552 of file string.c.

553{
554 HRESULT hr;
555 int len = 0;
556
557 if (src) {
558 len = lstrlenA(src) + 1;
560 } else {
561 *dest = NULL;
562 }
563
564 if (*dest) {
566 hr = S_OK;
567 } else {
569 }
570
571 TRACE("%s->(%p)\n", debugstr_a(src), *dest);
572 return hr;
573}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
void *WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: malloc.c:381
#define lstrcpynA
Definition: compat.h:751
GLenum src
Definition: glext.h:6340
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:52
#define debugstr_a
Definition: kernel32.h:31
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
static char * dest
Definition: rtl.c:149
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by StrRetToStrA().

◆ _SHStrDupAToBSTR()

static HRESULT _SHStrDupAToBSTR ( LPCSTR  src,
BSTR pBstrOut 
)
static

Definition at line 382 of file string.c.

383{
384 *pBstrOut = NULL;
385
386 if (src)
387 {
388 INT len = MultiByteToWideChar(CP_ACP, 0, src, -1, NULL, 0);
389 WCHAR *szTemp = malloc(len * sizeof(WCHAR));
390
391 if (szTemp)
392 {
393 MultiByteToWideChar(CP_ACP, 0, src, -1, szTemp, len);
394 *pBstrOut = SysAllocString(szTemp);
395 free(szTemp);
396
397 if (*pBstrOut)
398 return S_OK;
399 }
400 }
401 return E_OUTOFMEMORY;
402}
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
short WCHAR
Definition: pedump.c:58
int32_t INT
Definition: typedefs.h:58

Referenced by StrRetToBSTR().

◆ _SHStrDupAW()

static HRESULT _SHStrDupAW ( LPCWSTR  src,
LPSTR dest 
)
static

Definition at line 619 of file string.c.

620{
621 HRESULT hr;
622 int len = 0;
623
624 if (src) {
625 len = WideCharToMultiByte(CP_ACP, 0, src, -1, NULL, 0, NULL, NULL);
627 } else {
628 *dest = NULL;
629 }
630
631 if (*dest) {
633 hr = S_OK;
634 } else {
636 }
637
638 TRACE("%s->(%p)\n", debugstr_w(src), *dest);
639 return hr;
640}
#define WideCharToMultiByte
Definition: compat.h:111
#define debugstr_w
Definition: kernel32.h:32

Referenced by StrRetToStrA().

◆ DoesStringRoundTripA()

BOOL WINAPI DoesStringRoundTripA ( LPCSTR  lpSrcStr,
LPSTR  lpDst,
INT  iLen 
)

Definition at line 1278 of file string.c.

1279{
1280 lstrcpynA(lpDst, lpSrcStr, iLen);
1281 return TRUE;
1282}
#define TRUE
Definition: types.h:120

◆ DoesStringRoundTripW()

BOOL WINAPI DoesStringRoundTripW ( LPCWSTR  lpSrcStr,
LPSTR  lpDst,
INT  iLen 
)

Definition at line 1298 of file string.c.

1299{
1300 WCHAR szBuff[MAX_PATH];
1301
1302 SHUnicodeToAnsi(lpSrcStr, lpDst, iLen);
1303 SHAnsiToUnicode(lpDst, szBuff, MAX_PATH);
1304 return !wcscmp(lpSrcStr, szBuff);
1305}
#define MAX_PATH
Definition: compat.h:34
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1977
DWORD WINAPI SHAnsiToUnicode(LPCSTR lpSrcStr, LPWSTR lpDstStr, int iLen)
Definition: string.c:1136
INT WINAPI SHUnicodeToAnsi(LPCWSTR lpSrcStr, LPSTR lpDstStr, INT iLen)
Definition: string.c:1260

◆ FillNumberFmt()

static void FillNumberFmt ( NUMBERFMTW fmt,
LPWSTR  decimal_buffer,
int  decimal_bufwlen,
LPWSTR  thousand_buffer,
int  thousand_bufwlen 
)
static

Definition at line 51 of file string.c.

53{
54 WCHAR grouping[64];
55 WCHAR *c;
56
57 GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_ILZERO|LOCALE_RETURN_NUMBER, (LPWSTR)&fmt->LeadingZero, sizeof(fmt->LeadingZero)/sizeof(WCHAR));
58 GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_INEGNUMBER|LOCALE_RETURN_NUMBER, (LPWSTR)&fmt->LeadingZero, sizeof(fmt->NegativeOrder)/sizeof(WCHAR));
59 fmt->NumDigits = 0;
60 GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, decimal_buffer, decimal_bufwlen);
61 GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, thousand_buffer, thousand_bufwlen);
62 fmt->lpThousandSep = thousand_buffer;
63 fmt->lpDecimalSep = decimal_buffer;
64
65 /*
66 * Converting grouping string to number as described on
67 * http://blogs.msdn.com/oldnewthing/archive/2006/04/18/578251.aspx
68 */
69 fmt->Grouping = 0;
71 for (c = grouping; *c; c++)
72 if (*c >= '0' && *c < '9')
73 {
74 fmt->Grouping *= 10;
75 fmt->Grouping += *c - '0';
76 }
77
78 if (fmt->Grouping % 10 == 0)
79 fmt->Grouping /= 10;
80 else
81 fmt->Grouping *= 10;
82}
#define ARRAY_SIZE(A)
Definition: main.h:20
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: locale.c:1675
const GLubyte * c
Definition: glext.h:8905
#define c
Definition: ke_i.h:80
#define LOCALE_USER_DEFAULT
Definition: dsound.c:943
uint16_t * LPWSTR
Definition: typedefs.h:56
#define LOCALE_SGROUPING
Definition: winnls.h:54
#define LOCALE_SDECIMAL
Definition: winnls.h:52
#define LOCALE_STHOUSAND
Definition: winnls.h:53
#define LOCALE_INEGNUMBER
Definition: winnls.h:57
#define LOCALE_ILZERO
Definition: winnls.h:56

Referenced by FormatDouble(), and FormatInt().

◆ FormatDouble()

static int FormatDouble ( double  value,
int  decimals,
LPWSTR  pszBuf,
int  cchBuf 
)
static

Definition at line 124 of file string.c.

125{
126 static const WCHAR flfmt[] = {'%','f',0};
127 WCHAR buf[64];
129 WCHAR decimal[8], thousand[8];
130
131 swprintf(buf, 64, flfmt, value);
132
133 FillNumberFmt(&fmt, decimal, ARRAY_SIZE(decimal), thousand, ARRAY_SIZE(thousand));
134 fmt.NumDigits = decimals;
135 return GetNumberFormatW(LOCALE_USER_DEFAULT, 0, buf, &fmt, pszBuf, cchBuf);
136}
static void FillNumberFmt(NUMBERFMTW *fmt, LPWSTR decimal_buffer, int decimal_bufwlen, LPWSTR thousand_buffer, int thousand_bufwlen)
Definition: string.c:51
#define swprintf
Definition: precomp.h:40
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
INT WINAPI GetNumberFormatW(LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const NUMBERFMTW *lpFormat, LPWSTR lpNumberStr, int cchOut)
Definition: lcformat.c:1130
_In_ UINT cchBuf
Definition: shlwapi.h:378
Definition: pdh_main.c:96

Referenced by StrFormatByteSizeEx().

◆ FormatInt()

static int FormatInt ( LONGLONG  qdwValue,
LPWSTR  pszBuf,
int  cchBuf 
)
static

Definition at line 92 of file string.c.

93{
95 WCHAR decimal[8], thousand[8];
96 WCHAR buf[24];
97 WCHAR *c;
98 BOOL neg = (qdwValue < 0);
99
100 FillNumberFmt(&fmt, decimal, ARRAY_SIZE(decimal), thousand, ARRAY_SIZE(thousand));
101
102 c = &buf[24];
103 *(--c) = 0;
104 do
105 {
106 *(--c) = '0' + (qdwValue%10);
107 qdwValue /= 10;
108 } while (qdwValue > 0);
109 if (neg)
110 *(--c) = '-';
111
112 return GetNumberFormatW(LOCALE_USER_DEFAULT, 0, c, &fmt, pszBuf, cchBuf);
113}
unsigned int BOOL
Definition: ntddk_ex.h:94

Referenced by StrFormatKBSizeW().

◆ SHAnsiToUnicode()

DWORD WINAPI SHAnsiToUnicode ( LPCSTR  lpSrcStr,
LPWSTR  lpDstStr,
int  iLen 
)

Definition at line 1136 of file string.c.

1137{
1138 return SHAnsiToUnicodeCP(CP_ACP, lpSrcStr, lpDstStr, iLen);
1139}
DWORD WINAPI SHAnsiToUnicodeCP(DWORD dwCp, LPCSTR lpSrcStr, LPWSTR lpDstStr, int iLen)
Definition: string.c:1111

Referenced by DoesStringRoundTripW().

◆ SHAnsiToUnicodeCP()

DWORD WINAPI SHAnsiToUnicodeCP ( DWORD  dwCp,
LPCSTR  lpSrcStr,
LPWSTR  lpDstStr,
int  iLen 
)

Definition at line 1111 of file string.c.

1112{
1113 DWORD dwRet;
1114
1115 dwRet = MultiByteToWideChar(dwCp, 0, lpSrcStr, -1, lpDstStr, iLen);
1116 TRACE("%s->%s,ret=%ld\n", debugstr_a(lpSrcStr), debugstr_w(lpDstStr), dwRet);
1117 return dwRet;
1118}
unsigned long DWORD
Definition: ntddk_ex.h:95

Referenced by SHAnsiToUnicode().

◆ SHLWAPI_FormatSignificant()

static int SHLWAPI_FormatSignificant ( LPWSTR  lpszNum,
int  dwDigits 
)
inlinestatic

Definition at line 695 of file string.c.

696{
697 /* Zero non significant digits, return remaining significant digits */
698 while (*lpszNum)
699 {
700 lpszNum++;
701 if (--dwDigits == 0)
702 {
703 while (*lpszNum)
704 *lpszNum++ = '0';
705 return 0;
706 }
707 }
708 return dwDigits;
709}

Referenced by SHLWAPI_WriteTimeClass().

◆ SHLWAPI_WriteReverseNum()

static LPWSTR SHLWAPI_WriteReverseNum ( LPWSTR  lpszOut,
DWORD  dwNum 
)
inlinestatic

Definition at line 675 of file string.c.

676{
677 *lpszOut-- = '\0';
678
679 /* Write a decimal number to a string, backwards */
680 do
681 {
682 DWORD dwNextDigit = dwNum % 10;
683 *lpszOut-- = '0' + dwNextDigit;
684 dwNum = (dwNum - dwNextDigit) / 10;
685 } while (dwNum > 0);
686
687 return lpszOut;
688}

Referenced by SHLWAPI_WriteTimeClass().

◆ SHLWAPI_WriteTimeClass()

static int SHLWAPI_WriteTimeClass ( LPWSTR  lpszOut,
DWORD  dwValue,
UINT  uClassStringId,
int  iDigits 
)
static

Definition at line 716 of file string.c.

718{
719 WCHAR szBuff[64], *szOut = szBuff + 32;
720
721 szOut = SHLWAPI_WriteReverseNum(szOut, dwValue);
722 iDigits = SHLWAPI_FormatSignificant(szOut + 1, iDigits);
723 *szOut = ' ';
724 LoadStringW(shlwapi_hInstance, uClassStringId, szBuff + 32, 32);
725 lstrcatW(lpszOut, szOut);
726 return iDigits;
727}
static int SHLWAPI_FormatSignificant(LPWSTR lpszNum, int dwDigits)
Definition: string.c:695
static LPWSTR SHLWAPI_WriteReverseNum(LPWSTR lpszOut, DWORD dwNum)
Definition: string.c:675
HINSTANCE shlwapi_hInstance
Definition: shlwapi_main.c:33
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define LoadStringW
Definition: utils.h:64

Referenced by StrFromTimeIntervalW().

◆ SHStrDupA()

HRESULT WINAPI SHStrDupA ( LPCSTR  lpszStr,
LPWSTR lppszDest 
)

Definition at line 589 of file string.c.

590{
591 HRESULT hRet;
592 int len = 0;
593
594 if (lpszStr)
595 {
596 len = MultiByteToWideChar(CP_ACP, 0, lpszStr, -1, NULL, 0) * sizeof(WCHAR);
597 *lppszDest = CoTaskMemAlloc(len);
598 }
599 else
600 *lppszDest = NULL;
601
602 if (*lppszDest)
603 {
604 MultiByteToWideChar(CP_ACP, 0, lpszStr, -1, *lppszDest, len/sizeof(WCHAR));
605 hRet = S_OK;
606 }
607 else
608 hRet = E_OUTOFMEMORY;
609
610 TRACE("%s->(%p)\n", debugstr_a(lpszStr), *lppszDest);
611 return hRet;
612}

Referenced by StrRetToStrW().

◆ SHStrDupW()

HRESULT WINAPI SHStrDupW ( LPCWSTR  src,
LPWSTR dest 
)

Definition at line 647 of file string.c.

648{
649 HRESULT hr;
650 int len = 0;
651
652 if (src) {
653 len = (lstrlenW(src) + 1) * sizeof(WCHAR);
655 } else {
656 *dest = NULL;
657 }
658
659 if (*dest) {
660 memcpy(*dest, src, len);
661 hr = S_OK;
662 } else {
664 }
665
666 TRACE("%s->(%p)\n", debugstr_w(src), *dest);
667 return hr;
668}
#define lstrlenW
Definition: compat.h:750
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878

Referenced by StrRetToStrW().

◆ SHStripMneumonicA()

char WINAPI SHStripMneumonicA ( LPCSTR  lpszStr)

Definition at line 1044 of file string.c.

1045{
1046 LPSTR lpszIter, lpszTmp;
1047 char ch;
1048
1049 TRACE("(%s)\n", debugstr_a(lpszStr));
1050
1051 ch = *lpszStr;
1052
1053 if ((lpszIter = StrChrA(lpszStr, '&')))
1054 {
1055 lpszTmp = CharNextA(lpszIter);
1056 if (*lpszTmp)
1057 {
1058 if (*lpszTmp != '&')
1059 ch = *lpszTmp;
1060
1061 memmove( lpszIter, lpszTmp, strlen(lpszTmp) + 1 );
1062 }
1063 }
1064
1065 return ch;
1066}
LPSTR WINAPI StrChrA(LPCSTR lpszStr, WORD ch)
Definition: string.c:266
LPSTR WINAPI CharNextA(const char *ptr)
Definition: string.c:1151
unsigned char ch[4][2]
Definition: console.c:118
size_t __cdecl strlen(const char *str)
Definition: string.c:1597
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
char * LPSTR
Definition: typedefs.h:51

◆ SHStripMneumonicW()

WCHAR WINAPI SHStripMneumonicW ( LPCWSTR  lpszStr)

Definition at line 1073 of file string.c.

1074{
1075 LPWSTR lpszIter, lpszTmp;
1076 WCHAR ch;
1077
1078 TRACE("(%s)\n", debugstr_w(lpszStr));
1079
1080 ch = *lpszStr;
1081
1082 if ((lpszIter = StrChrW(lpszStr, '&')))
1083 {
1084 lpszTmp = lpszIter + 1;
1085 if (*lpszTmp)
1086 {
1087 if (*lpszTmp != '&')
1088 ch = *lpszTmp;
1089
1090 memmove( lpszIter, lpszTmp, (lstrlenW(lpszTmp) + 1) * sizeof(WCHAR) );
1091 }
1092 }
1093
1094 return ch;
1095}
WCHAR *WINAPI StrChrW(const WCHAR *str, WCHAR ch)
Definition: string.c:229

◆ SHTruncateString()

DWORD WINAPI SHTruncateString ( LPSTR  lpStr,
DWORD  size 
)

◆ SHUnicodeToAnsi()

INT WINAPI SHUnicodeToAnsi ( LPCWSTR  lpSrcStr,
LPSTR  lpDstStr,
INT  iLen 
)

Definition at line 1260 of file string.c.

1261{
1262 return SHUnicodeToAnsiCP(CP_ACP, lpSrcStr, lpDstStr, iLen);
1263}
DWORD WINAPI SHUnicodeToAnsiCP(UINT CodePage, LPCWSTR lpSrcStr, LPSTR lpDstStr, int dstlen)
Definition: string.c:1161

Referenced by DoesStringRoundTripW().

◆ SHUnicodeToAnsiCP()

DWORD WINAPI SHUnicodeToAnsiCP ( UINT  CodePage,
LPCWSTR  lpSrcStr,
LPSTR  lpDstStr,
int  dstlen 
)

Definition at line 1161 of file string.c.

1162{
1163 static const WCHAR emptyW[] = { '\0' };
1164 int len , reqLen;
1165 LPSTR mem;
1166
1167 if (!lpDstStr || !dstlen)
1168 return 0;
1169
1170 if (!lpSrcStr)
1171 lpSrcStr = emptyW;
1172
1173 *lpDstStr = '\0';
1174
1175 len = lstrlenW(lpSrcStr) + 1;
1176
1177 switch (CodePage)
1178 {
1179 case CP_WINUNICODE:
1180 CodePage = CP_UTF8; /* Fall through... */
1181 case 0x0000C350: /* FIXME: CP_ #define */
1182 case CP_UTF7:
1183 case CP_UTF8:
1184 {
1185 DWORD dwMode = 0;
1186 INT lenW = len - 1;
1187 INT needed = dstlen - 1;
1188 HRESULT hr;
1189
1190 /* try the user supplied buffer first */
1191 hr = ConvertINetUnicodeToMultiByte(&dwMode, CodePage, lpSrcStr, &lenW, lpDstStr, &needed);
1192 if (hr == S_OK)
1193 {
1194 lpDstStr[needed] = '\0';
1195 return needed + 1;
1196 }
1197
1198 /* user buffer too small. exclude termination and copy as much as possible */
1199 lenW = len;
1200 hr = ConvertINetUnicodeToMultiByte(&dwMode, CodePage, lpSrcStr, &lenW, NULL, &needed);
1201 needed++;
1202 mem = malloc(needed);
1203 if (!mem)
1204 return 0;
1205
1206 hr = ConvertINetUnicodeToMultiByte(&dwMode, CodePage, lpSrcStr, &len, mem, &needed);
1207 if (hr == S_OK)
1208 {
1209 reqLen = SHTruncateString(mem, dstlen);
1210 if (reqLen > 0) memcpy(lpDstStr, mem, reqLen-1);
1211 }
1212 free(mem);
1213 return 0;
1214 }
1215 default:
1216 break;
1217 }
1218
1219 /* try the user supplied buffer first */
1220 reqLen = WideCharToMultiByte(CodePage, 0, lpSrcStr, len, lpDstStr, dstlen, NULL, NULL);
1221
1222 if (!reqLen && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
1223 {
1224 reqLen = WideCharToMultiByte(CodePage, 0, lpSrcStr, len, NULL, 0, NULL, NULL);
1225 if (reqLen)
1226 {
1227 mem = malloc(reqLen);
1228 if (mem)
1229 {
1230 WideCharToMultiByte(CodePage, 0, lpSrcStr, len, mem, reqLen, NULL, NULL);
1231
1232 reqLen = SHTruncateString(mem, dstlen -1);
1233 reqLen++;
1234
1235 lstrcpynA(lpDstStr, mem, reqLen);
1236 free(mem);
1237 lpDstStr[reqLen-1] = '\0';
1238 }
1239 }
1240 }
1241 return reqLen;
1242}
#define CP_WINUNICODE
Definition: ddeml.h:33
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
DWORD WINAPI SHTruncateString(LPSTR lpStr, DWORD size)
static const WCHAR emptyW[]
Definition: navigate.c:40
static DWORD dstlen
Definition: directory.c:51
#define CP_UTF8
Definition: nls.h:20
Definition: mem.c:349
static CONVERTINETUNICODETOMULTIBYTE ConvertINetUnicodeToMultiByte
Definition: win_iconv.c:706
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define CP_UTF7
Definition: winnls.h:263

Referenced by SHUnicodeToAnsi().

◆ StrCatW()

LPWSTR WINAPI StrCatW ( LPWSTR  lpszStr,
LPCWSTR  lpszSrc 
)

Definition at line 151 of file string.c.

152{
153 TRACE("(%s,%s)\n", debugstr_w(lpszStr), debugstr_w(lpszSrc));
154
155 if (lpszStr && lpszSrc)
156 lstrcatW(lpszStr, lpszSrc);
157 return lpszStr;
158}

Referenced by CRegistryFolder::FormatValueData().

◆ StrCpyW()

LPWSTR WINAPI StrCpyW ( LPWSTR  lpszStr,
LPCWSTR  lpszSrc 
)

Definition at line 173 of file string.c.

174{
175 TRACE("(%p,%s)\n", lpszStr, debugstr_w(lpszSrc));
176
177 if (lpszStr && lpszSrc)
178 lstrcpyW(lpszStr, lpszSrc);
179 return lpszStr;
180}
#define lstrcpyW
Definition: compat.h:749

Referenced by _ShowContextMenu(), and test_StrCpyW().

◆ StrFormatByteSize64A()

LPSTR WINAPI StrFormatByteSize64A ( LONGLONG  llBytes,
LPSTR  lpszDest,
UINT  cchMax 
)

Definition at line 997 of file string.c.

998{
999 WCHAR wszBuff[32];
1000
1001 StrFormatByteSizeW(llBytes, wszBuff, ARRAY_SIZE(wszBuff));
1002
1003 if (lpszDest)
1004 WideCharToMultiByte(CP_ACP, 0, wszBuff, -1, lpszDest, cchMax, 0, 0);
1005 return lpszDest;
1006}
UINT cchMax
WCHAR lpszDest[260]
LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:854

Referenced by CDrivesFolder::GetDetailsOf(), and StrFormatByteSizeA().

◆ StrFormatByteSizeA()

LPSTR WINAPI StrFormatByteSizeA ( DWORD  dwBytes,
LPSTR  lpszDest,
UINT  cchMax 
)

Definition at line 1025 of file string.c.

1026{
1027 TRACE("(%ld,%p,%d)\n", dwBytes, lpszDest, cchMax);
1028
1029 return StrFormatByteSize64A(dwBytes, lpszDest, cchMax);
1030}
LPSTR WINAPI StrFormatByteSize64A(LONGLONG llBytes, LPSTR lpszDest, UINT cchMax)
Definition: string.c:997

Referenced by CCabFolder::GetItemDetails().

◆ StrFormatByteSizeEx()

HRESULT WINAPI StrFormatByteSizeEx ( LONGLONG  llBytes,
SFBS_FLAGS  flags,
LPWSTR  lpszDest,
UINT  cchMax 
)

Definition at line 877 of file string.c.

879{
880#define KB ((ULONGLONG)1024)
881#define MB (KB*KB)
882#define GB (KB*KB*KB)
883#define TB (KB*KB*KB*KB)
884#define PB (KB*KB*KB*KB*KB)
885
886 static const SHLWAPI_BYTEFORMATS bfFormats[] =
887 {
888#ifdef __REACTOS__
889 { 10*KB, 10.24, 100.0, 2, IDS_KB_FORMAT }, /* 10 KB */
890 { 100*KB, 102.4, 10.0, 1, IDS_KB_FORMAT }, /* 100 KB */
891 { 1000*KB, 1024.0, 1.0, 0, IDS_KB_FORMAT }, /* 1000 KB */
892 { 10*MB, 10485.76, 100.0, 2, IDS_MB_FORMAT }, /* 10 MB */
893 { 100*MB, 104857.6, 10.0, 1, IDS_MB_FORMAT }, /* 100 MB */
894 { 1000*MB, 1048576.0, 1.0, 0, IDS_MB_FORMAT }, /* 1000 MB */
895 { 10*GB, 10737418.24, 100.0, 2, IDS_GB_FORMAT }, /* 10 GB */
896 { 100*GB, 107374182.4, 10.0, 1, IDS_GB_FORMAT }, /* 100 GB */
897 { 1000*GB, 1073741824.0, 1.0, 0, IDS_GB_FORMAT }, /* 1000 GB */
898 { 10*TB, 10485.76, 100.0, 2, IDS_TB_FORMAT }, /* 10 TB */
899 { 100*TB, 104857.6, 10.0, 1, IDS_TB_FORMAT }, /* 100 TB */
900 { 1000*TB, 1048576.0, 1.0, 0, IDS_TB_FORMAT }, /* 1000 TB */
901 { 10*PB, 10737418.24, 100.00, 2, IDS_PB_FORMAT }, /* 10 PB */
902 { 100*PB, 107374182.4, 10.00, 1, IDS_PB_FORMAT }, /* 100 PB */
903 { 1000*PB, 1073741824.0, 1.00, 0, IDS_PB_FORMAT }, /* 1000 PB */
904 { 0, 10995116277.76, 100.00, 2, IDS_EB_FORMAT } /* EB's, catch all */
905#else
906 { 10*KB, 10.24, 100.0, 2, 'K' }, /* 10 KB */
907 { 100*KB, 102.4, 10.0, 1, 'K' }, /* 100 KB */
908 { 1000*KB, 1024.0, 1.0, 0, 'K' }, /* 1000 KB */
909 { 10*MB, 10485.76, 100.0, 2, 'M' }, /* 10 MB */
910 { 100*MB, 104857.6, 10.0, 1, 'M' }, /* 100 MB */
911 { 1000*MB, 1048576.0, 1.0, 0, 'M' }, /* 1000 MB */
912 { 10*GB, 10737418.24, 100.0, 2, 'G' }, /* 10 GB */
913 { 100*GB, 107374182.4, 10.0, 1, 'G' }, /* 100 GB */
914 { 1000*GB, 1073741824.0, 1.0, 0, 'G' }, /* 1000 GB */
915 { 10*TB, 10485.76, 100.0, 2, 'T' }, /* 10 TB */
916 { 100*TB, 104857.6, 10.0, 1, 'T' }, /* 100 TB */
917 { 1000*TB, 1048576.0, 1.0, 0, 'T' }, /* 1000 TB */
918 { 10*PB, 10737418.24, 100.00, 2, 'P' }, /* 10 PB */
919 { 100*PB, 107374182.4, 10.00, 1, 'P' }, /* 100 PB */
920 { 1000*PB, 1073741824.0, 1.00, 0, 'P' }, /* 1000 PB */
921 { 0, 10995116277.76, 100.00, 2, 'E' } /* EB's, catch all */
922#endif
923 };
924#ifdef __REACTOS__
925 WCHAR szBuff[40], wszFormat[40];
926#else
927 WCHAR wszAdd[] = {' ','?','B',0};
928#endif
929 double dBytes;
930 UINT i = 0;
931
932 TRACE("(0x%s,%d,%p,%d)\n", wine_dbgstr_longlong(llBytes), flags, lpszDest, cchMax);
933
934 if (!cchMax)
935 return E_INVALIDARG;
936
937 if (llBytes < 1024) /* 1K */
938 {
939 WCHAR wszBytesFormat[64];
940 LoadStringW(shlwapi_hInstance, IDS_BYTES_FORMAT, wszBytesFormat, 64);
941 swprintf(lpszDest, cchMax, wszBytesFormat, (int)llBytes);
942 return S_OK;
943 }
944
945 /* Note that if this loop completes without finding a match, i will be
946 * pointing at the last entry, which is a catch all for > 1000 PB
947 */
948 while (i < ARRAY_SIZE(bfFormats) - 1)
949 {
950 if (llBytes < bfFormats[i].dLimit)
951 break;
952 i++;
953 }
954 /* Above 1 TB we encounter problems with FP accuracy. So for amounts above
955 * this number we integer shift down by 1 MB first. The table above has
956 * the divisors scaled down from the '< 10 TB' entry onwards, to account
957 * for this. We also add a small fudge factor to get the correct result for
958 * counts that lie exactly on a 1024 byte boundary.
959 */
960 if (i > 8)
961 dBytes = (double)(llBytes >> 20) + 0.001; /* Scale down by 1 MB */
962 else
963 dBytes = (double)llBytes + 0.00001;
964
965 switch(flags)
966 {
968 dBytes = round(dBytes / bfFormats[i].dDivisor) / bfFormats[i].dNormaliser;
969 break;
971 dBytes = floor(dBytes / bfFormats[i].dDivisor) / bfFormats[i].dNormaliser;
972 break;
973 default:
974 return E_INVALIDARG;
975 }
976
977#ifdef __REACTOS__
978 if (!FormatDouble(dBytes, bfFormats[i].nDecimals, szBuff, ARRAYSIZE(szBuff)))
979 return E_FAIL;
980 LoadStringW(shlwapi_hInstance, bfFormats[i].nFormatID, wszFormat, ARRAYSIZE(wszFormat));
981 snprintfW(lpszDest, cchMax, wszFormat, szBuff);
982#else
983 if (!FormatDouble(dBytes, bfFormats[i].nDecimals, lpszDest, cchMax))
984 return E_FAIL;
985
986 wszAdd[1] = bfFormats[i].wPrefix;
987 StrCatBuffW(lpszDest, wszAdd, cchMax);
988#endif
989 return S_OK;
990}
#define IDS_BYTES_FORMAT
Definition: resource.h:122
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_FAIL
Definition: ddrawi.h:102
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
WCHAR *WINAPI StrCatBuffW(WCHAR *str, const WCHAR *cat, INT max_len)
Definition: string.c:1434
_ACRTIMP double __cdecl floor(double)
Definition: floor.c:18
#define KB
#define PB
#define TB
#define GB
#define MB
static int FormatDouble(double value, int decimals, LPWSTR pszBuf, int cchBuf)
Definition: string.c:124
GLbitfield flags
Definition: glext.h:7161
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:91
unsigned int UINT
Definition: ndis.h:50
#define round(x)
Definition: opentype.c:47
@ SFBS_FLAGS_TRUNCATE_UNDISPLAYED_DECIMAL_DIGITS
Definition: shlwapi.h:1265
@ SFBS_FLAGS_ROUND_TO_NEAREST_DISPLAYED_DIGIT
Definition: shlwapi.h:1264
#define snprintfW
Definition: unicode.h:60

Referenced by StrFormatByteSizeW().

◆ StrFormatByteSizeW()

◆ StrFormatKBSizeA()

LPSTR WINAPI StrFormatKBSizeA ( LONGLONG  llBytes,
LPSTR  lpszDest,
UINT  cchMax 
)

Definition at line 459 of file string.c.

460{
461 WCHAR wszBuf[256];
462
463 if (!StrFormatKBSizeW(llBytes, wszBuf, 256))
464 return NULL;
465 if (!WideCharToMultiByte(CP_ACP, 0, wszBuf, -1, lpszDest, cchMax, NULL, NULL))
466 return NULL;
467 return lpszDest;
468}
LPWSTR WINAPI StrFormatKBSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:475

Referenced by CFontExt::GetDetailsOf().

◆ StrFormatKBSizeW()

LPWSTR WINAPI StrFormatKBSizeW ( LONGLONG  llBytes,
LPWSTR  lpszDest,
UINT  cchMax 
)

Definition at line 475 of file string.c.

476{
477 static const WCHAR kb[] = {' ','K','B',0};
478 LONGLONG llKB = (llBytes + 1023) >> 10;
479 int len;
480
481 TRACE("(0x%s,%p,%d)\n", wine_dbgstr_longlong(llBytes), lpszDest, cchMax);
482
483 if (!FormatInt(llKB, lpszDest, cchMax))
484 return NULL;
485
487 if (cchMax - len < 4)
488 return NULL;
489 lstrcatW(lpszDest, kb);
490 return lpszDest;
491}
static int FormatInt(LONGLONG qdwValue, LPWSTR pszBuf, int cchBuf)
Definition: string.c:92
int64_t LONGLONG
Definition: typedefs.h:68

Referenced by _ILGetFileSize(), CFSFolder::FormatSize(), and StrFormatKBSizeA().

◆ StrFromTimeIntervalA()

INT WINAPI StrFromTimeIntervalA ( LPSTR  lpszStr,
UINT  cchMax,
DWORD  dwMS,
int  iDigits 
)

Definition at line 760 of file string.c.

762{
763 INT iRet = 0;
764
765 TRACE("(%p,%d,%ld,%d)\n", lpszStr, cchMax, dwMS, iDigits);
766
767 if (lpszStr && cchMax)
768 {
769 WCHAR szBuff[128];
770 StrFromTimeIntervalW(szBuff, ARRAY_SIZE(szBuff), dwMS, iDigits);
771 WideCharToMultiByte(CP_ACP,0,szBuff,-1,lpszStr,cchMax,0,0);
772 }
773 return iRet;
774}
INT WINAPI StrFromTimeIntervalW(LPWSTR lpszStr, UINT cchMax, DWORD dwMS, int iDigits)
Definition: string.c:782

Referenced by test_StrFromTimeIntervalA().

◆ StrFromTimeIntervalW()

INT WINAPI StrFromTimeIntervalW ( LPWSTR  lpszStr,
UINT  cchMax,
DWORD  dwMS,
int  iDigits 
)

Definition at line 782 of file string.c.

784{
785 INT iRet = 0;
786
787 TRACE("(%p,%d,%ld,%d)\n", lpszStr, cchMax, dwMS, iDigits);
788
789 if (lpszStr && cchMax)
790 {
791 WCHAR szCopy[128];
792 DWORD dwHours, dwMinutes;
793
794 if (!iDigits || cchMax == 1)
795 {
796 *lpszStr = '\0';
797 return 0;
798 }
799
800 /* Calculate the time classes */
801 dwMS = (dwMS + 500) / 1000;
802 dwHours = dwMS / 3600;
803 dwMS -= dwHours * 3600;
804 dwMinutes = dwMS / 60;
805 dwMS -= dwMinutes * 60;
806
807 szCopy[0] = '\0';
808
809 if (dwHours)
810 iDigits = SHLWAPI_WriteTimeClass(szCopy, dwHours, IDS_TIME_INTERVAL_HOURS, iDigits);
811
812 if (dwMinutes && iDigits)
813 iDigits = SHLWAPI_WriteTimeClass(szCopy, dwMinutes, IDS_TIME_INTERVAL_MINUTES, iDigits);
814
815 if (iDigits) /* Always write seconds if we have significant digits */
817
818 lstrcpynW(lpszStr, szCopy, cchMax);
819 iRet = lstrlenW(lpszStr);
820 }
821 return iRet;
822}
#define lstrcpynW
Definition: compat.h:738
#define IDS_TIME_INTERVAL_MINUTES
Definition: resource.h:28
#define IDS_TIME_INTERVAL_HOURS
Definition: resource.h:27
#define IDS_TIME_INTERVAL_SECONDS
Definition: resource.h:29
static int SHLWAPI_WriteTimeClass(LPWSTR lpszOut, DWORD dwValue, UINT uClassStringId, int iDigits)
Definition: string.c:716

Referenced by dialog_proc(), and StrFromTimeIntervalA().

◆ StrNCatA()

LPSTR WINAPI StrNCatA ( LPSTR  lpszStr,
LPCSTR  lpszCat,
INT  cchMax 
)

Definition at line 510 of file string.c.

511{
512 LPSTR lpszRet = lpszStr;
513
514 TRACE("(%s,%s,%i)\n", debugstr_a(lpszStr), debugstr_a(lpszCat), cchMax);
515
516 if (!lpszStr)
517 {
518 WARN("Invalid lpszStr would crash under Win32!\n");
519 return NULL;
520 }
521
522 StrCpyNA(lpszStr + strlen(lpszStr), lpszCat, cchMax);
523 return lpszRet;
524}
#define WARN(fmt,...)
Definition: precomp.h:61
#define StrCpyNA
Definition: shlwapi.h:1104

◆ StrNCatW()

LPWSTR WINAPI StrNCatW ( LPWSTR  lpszStr,
LPCWSTR  lpszCat,
INT  cchMax 
)

Definition at line 531 of file string.c.

532{
533 LPWSTR lpszRet = lpszStr;
534
535 TRACE("(%s,%s,%i)\n", debugstr_w(lpszStr), debugstr_w(lpszCat), cchMax);
536
537 if (!lpszStr)
538 {
539 WARN("Invalid lpszStr would crash under Win32\n");
540 return NULL;
541 }
542
543 StrCpyNW(lpszStr + lstrlenW(lpszStr), lpszCat, cchMax);
544 return lpszRet;
545}
WCHAR *WINAPI StrCpyNW(WCHAR *dst, const WCHAR *src, int count)
Definition: string.c:470

◆ StrRetToBSTR()

HRESULT WINAPI StrRetToBSTR ( STRRET lpStrRet,
LPCITEMIDLIST  pidl,
BSTR pBstrOut 
)

Definition at line 418 of file string.c.

419{
420 HRESULT hRet = E_FAIL;
421
422 switch (lpStrRet->uType)
423 {
424 case STRRET_WSTR:
425 *pBstrOut = SysAllocString(lpStrRet->pOleStr);
426 if (*pBstrOut)
427 hRet = S_OK;
428 CoTaskMemFree(lpStrRet->pOleStr);
429 break;
430
431 case STRRET_CSTR:
432 hRet = _SHStrDupAToBSTR(lpStrRet->cStr, pBstrOut);
433 break;
434
435 case STRRET_OFFSET:
436 hRet = _SHStrDupAToBSTR(((LPCSTR)&pidl->mkid) + lpStrRet->uOffset, pBstrOut);
437 break;
438
439 default:
440 *pBstrOut = NULL;
441 }
442
443 return hRet;
444}
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
static HRESULT _SHStrDupAToBSTR(LPCSTR src, BSTR *pBstrOut)
Definition: string.c:382
@ STRRET_CSTR
Definition: shtypes.idl:87
@ STRRET_OFFSET
Definition: shtypes.idl:86
@ STRRET_WSTR
Definition: shtypes.idl:85
char cStr[MAX_PATH]
Definition: shtypes.idl:98
UINT uType
Definition: shtypes.idl:93
LPWSTR pOleStr
Definition: shtypes.idl:96
UINT uOffset
Definition: shtypes.idl:97
const char * LPCSTR
Definition: typedefs.h:52

Referenced by CFolderItem::get_Name(), CFolderItem::get_Path(), SHELL_GetDetailsOfAsStringVariant(), and StrRetToVariantBSTR().

◆ StrRetToBufA()

HRESULT WINAPI StrRetToBufA ( LPSTRRET  src,
const ITEMIDLIST pidl,
LPSTR  dest,
UINT  len 
)

Definition at line 199 of file string.c.

200{
201 /* NOTE:
202 * This routine is identical to that in dlls/shell32/shellstring.c.
203 * It was duplicated because not every version of Shlwapi.dll exports
204 * StrRetToBufA. If you change one routine, change them both.
205 */
206 TRACE("dest=%p len=0x%x strret=%p pidl=%p\n", dest, len, src, pidl);
207
208 if (!src)
209 {
210 WARN("Invalid lpStrRet would crash under Win32!\n");
211 if (dest)
212 *dest = '\0';
213 return E_FAIL;
214 }
215
216 if (!dest || !len)
217 return E_FAIL;
218
219 *dest = '\0';
220
221 switch (src->uType)
222 {
223 case STRRET_WSTR:
224 WideCharToMultiByte(CP_ACP, 0, src->pOleStr, -1, dest, len, NULL, NULL);
225 CoTaskMemFree(src->pOleStr);
226 break;
227
228 case STRRET_CSTR:
229 lstrcpynA(dest, src->cStr, len);
230 break;
231
232 case STRRET_OFFSET:
233 lstrcpynA(dest, ((LPCSTR)&pidl->mkid)+src->uOffset, len);
234 break;
235
236 default:
237 FIXME("unknown type!\n");
238 return E_NOTIMPL;
239 }
240 return S_OK;
241}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define E_NOTIMPL
Definition: ddrawi.h:99
SHITEMID mkid
Definition: shtypes.idl:34

◆ StrRetToBufW()

HRESULT WINAPI StrRetToBufW ( LPSTRRET  src,
const ITEMIDLIST pidl,
LPWSTR  dest,
UINT  len 
)

Definition at line 248 of file string.c.

249{
250 TRACE("dest=%p len=0x%x strret=%p pidl=%p\n", dest, len, src, pidl);
251
252 if (!dest || !len)
253 return E_FAIL;
254
255 if (!src)
256 {
257 WARN("Invalid lpStrRet would crash under Win32!\n");
258 if (dest)
259 *dest = '\0';
260 return E_FAIL;
261 }
262
263 *dest = '\0';
264
265 switch (src->uType) {
266 case STRRET_WSTR: {
267 size_t dst_len;
268 if (!src->pOleStr)
269 return E_FAIL;
270 dst_len = lstrlenW(src->pOleStr);
271 memcpy(dest, src->pOleStr, min(dst_len, len-1) * sizeof(WCHAR));
272 dest[min(dst_len, len-1)] = 0;
273 CoTaskMemFree(src->pOleStr);
274 if (len <= dst_len)
275 {
276 dest[0] = 0;
278 }
279 break;
280 }
281
282 case STRRET_CSTR:
283 if (!MultiByteToWideChar( CP_ACP, 0, src->cStr, -1, dest, len ))
284 dest[len-1] = 0;
285 break;
286
287 case STRRET_OFFSET:
288 if (pidl)
289 {
290 if (!MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->uOffset, -1,
291 dest, len ))
292 dest[len-1] = 0;
293 }
294 break;
295
296 default:
297 FIXME("unknown type!\n");
298 return E_NOTIMPL;
299 }
300
301 return S_OK;
302}
#define min(a, b)
Definition: monoChain.cc:55
#define E_NOT_SUFFICIENT_BUFFER
Definition: winerror.h:3437

Referenced by CFSDropTarget::_CopyItems(), CAddressEditBox::AddComboBoxItem(), CISFBand::AddToolbarButtons(), COMDLG32_GetDisplayNameOf(), COMDLG32_UpdateCurrentDir(), DisplayNameOfW(), CMyDocsDropHandler::Drop(), CDeskLinkDropHandler::Drop(), FindExpectedFile(), GetCommandString(), GetDisplayName(), GetDisplayNameOf(), CCommonFolder< TSelf, TItemId, TExtractIcon >::GetDisplayNameOf(), GetFullName(), IEGetNameAndFlagsEx(), ok_displayname_(), SHELL32_CompareDetails(), SHGetPathCchFromIDListW(), SHGetRealIDL(), SHIsRemovableDrive(), SHOpenFolderAndSelectItems(), test_desktop_displaynameof(), test_FolderShortcut(), test_GetDisplayName(), test_LocalizedNames(), test_SHGetNameFromIDList(), and test_SHGetPathFromIDList().

◆ StrRetToStrA()

HRESULT WINAPI StrRetToStrA ( LPSTRRET  lpStrRet,
const ITEMIDLIST pidl,
LPSTR ppszName 
)

Definition at line 318 of file string.c.

319{
320 HRESULT hRet = E_FAIL;
321
322 switch (lpStrRet->uType)
323 {
324 case STRRET_WSTR:
325 hRet = _SHStrDupAW(lpStrRet->pOleStr, ppszName);
326 CoTaskMemFree(lpStrRet->pOleStr);
327 break;
328
329 case STRRET_CSTR:
330 hRet = _SHStrDupAA(lpStrRet->cStr, ppszName);
331 break;
332
333 case STRRET_OFFSET:
334 hRet = _SHStrDupAA(((LPCSTR)&pidl->mkid) + lpStrRet->uOffset, ppszName);
335 break;
336
337 default:
338 *ppszName = NULL;
339 }
340
341 return hRet;
342}
static HRESULT _SHStrDupAA(LPCSTR, LPSTR *)
Definition: string.c:552
static HRESULT _SHStrDupAW(LPCWSTR, LPSTR *)
Definition: string.c:619
SIGDN PWSTR * ppszName
Definition: shobjidl.idl:606

◆ StrRetToStrW()

HRESULT WINAPI StrRetToStrW ( LPSTRRET  lpStrRet,
const ITEMIDLIST pidl,
LPWSTR ppszName 
)

Definition at line 349 of file string.c.

350{
351 HRESULT hRet = E_FAIL;
352
353 switch (lpStrRet->uType)
354 {
355 case STRRET_WSTR:
356#ifdef __REACTOS__
357 hRet = lpStrRet->pOleStr ? S_OK : E_FAIL;
358 *ppszName = lpStrRet->pOleStr;
359 lpStrRet->pOleStr = NULL; /* Windows does this, presumably in case someone calls SHFree */
360#else
361 hRet = SHStrDupW(lpStrRet->pOleStr, ppszName);
362 CoTaskMemFree(lpStrRet->pOleStr);
363#endif
364 break;
365
366 case STRRET_CSTR:
367 hRet = SHStrDupA(lpStrRet->cStr, ppszName);
368 break;
369
370 case STRRET_OFFSET:
371 hRet = SHStrDupA(((LPCSTR)&pidl->mkid) + lpStrRet->uOffset, ppszName);
372 break;
373
374 default:
375 *ppszName = NULL;
376 }
377
378 return hRet;
379}
HRESULT WINAPI SHStrDupW(LPCWSTR src, LPWSTR *dest)
Definition: string.c:647
HRESULT WINAPI SHStrDupA(LPCSTR lpszStr, LPWSTR *lppszDest)
Definition: string.c:589

Referenced by CEnumMergedFolder::Begin(), GetDetailsOf(), GetDisplayname(), CACListISF::GetDisplayName(), CSendToMenu::LoadAllItems(), CShellBrowser::OnAddToFavorites(), SHELL32_GetFSItemAttributes(), SHELL_DisplayNameOf(), SHGetNameFromIDList(), and TEST_StrRet().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )

Variable Documentation

◆ shlwapi_hInstance

HINSTANCE shlwapi_hInstance
extern

Definition at line 33 of file shlwapi_main.c.

Referenced by DllMain(), SHLWAPI_WriteTimeClass(), and StrFormatByteSizeEx().