ReactOS 0.4.17-dev-357-ga8f14ff
string.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "shlwapi.h"
#include "winternl.h"
#include "kernelbase.h"
#include "wine/debug.h"
#include "wine/exception.h"
Include dependency graph for string.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (string)
 
static BOOL char_compare (WORD ch1, WORD ch2, DWORD flags)
 
int WINAPI lstrcmpA (LPCSTR str1, LPCSTR str2)
 
int WINAPI lstrcmpW (LPCWSTR str1, LPCWSTR str2)
 
int WINAPI lstrcmpiA (LPCSTR str1, LPCSTR str2)
 
int WINAPI lstrcmpiW (LPCWSTR str1, LPCWSTR str2)
 
LPSTR WINAPI KERNELBASE_lstrcpynA (LPSTR dst, LPCSTR src, INT n)
 
LPWSTR WINAPI KERNELBASE_lstrcpynW (LPWSTR dst, LPCWSTR src, INT n)
 
INT WINAPI KERNELBASE_lstrlenA (LPCSTR str)
 
INT WINAPI KERNELBASE_lstrlenW (LPCWSTR str)
 
DWORD WINAPI StrCmpCA (const char *str, const char *cmp)
 
DWORD WINAPI StrCmpCW (const WCHAR *str, const WCHAR *cmp)
 
DWORD WINAPI StrCmpICA (const char *str, const char *cmp)
 
DWORD WINAPI StrCmpICW (const WCHAR *str, const WCHAR *cmp)
 
DWORD WINAPI StrCmpNICA (const char *str, const char *cmp, DWORD len)
 
DWORD WINAPI StrCmpNICW (const WCHAR *str, const WCHAR *cmp, DWORD len)
 
char *WINAPI StrChrA (const char *str, WORD ch)
 
WCHAR *WINAPI StrChrW (const WCHAR *str, WCHAR ch)
 
char *WINAPI StrChrIA (const char *str, WORD ch)
 
WCHAR *WINAPI StrChrIW (const WCHAR *str, WCHAR ch)
 
WCHAR *WINAPI StrChrNW (const WCHAR *str, WCHAR ch, UINT max_len)
 
char *WINAPI StrDupA (const char *str)
 
WCHAR *WINAPI StrDupW (const WCHAR *str)
 
BOOL WINAPI ChrCmpIA (WORD ch1, WORD ch2)
 
BOOL WINAPI ChrCmpIW (WCHAR ch1, WCHAR ch2)
 
char *WINAPI StrStrA (const char *str, const char *search)
 
WCHAR *WINAPI StrStrW (const WCHAR *str, const WCHAR *search)
 
WCHAR *WINAPI StrStrNW (const WCHAR *str, const WCHAR *search, UINT max_len)
 
int WINAPI StrCmpNIA (const char *str, const char *cmp, int len)
 
WCHAR *WINAPI StrStrNIW (const WCHAR *str, const WCHAR *search, UINT max_len)
 
int WINAPI StrCmpNA (const char *str, const char *comp, int len)
 
int WINAPI StrCmpNW (const WCHAR *str, const WCHAR *comp, int len)
 
DWORD WINAPI StrCmpNCA (const char *str, const char *comp, int len)
 
DWORD WINAPI StrCmpNCW (const WCHAR *str, const WCHAR *comp, int len)
 
int WINAPI StrCmpNIW (const WCHAR *str, const WCHAR *comp, int len)
 
int WINAPI StrCmpW (const WCHAR *str, const WCHAR *comp)
 
int WINAPI StrCmpIW (const WCHAR *str, const WCHAR *comp)
 
WCHAR *WINAPI StrCpyNW (WCHAR *dst, const WCHAR *src, int count)
 
char *WINAPI StrStrIA (const char *str, const char *search)
 
WCHAR *WINAPI StrStrIW (const WCHAR *str, const WCHAR *search)
 
int WINAPI StrSpnA (const char *str, const char *match)
 
int WINAPI StrSpnW (const WCHAR *str, const WCHAR *match)
 
int WINAPI StrCSpnA (const char *str, const char *match)
 
int WINAPI StrCSpnW (const WCHAR *str, const WCHAR *match)
 
int WINAPI StrCSpnIA (const char *str, const char *match)
 
int WINAPI StrCSpnIW (const WCHAR *str, const WCHAR *match)
 
char *WINAPI StrRChrA (const char *str, const char *end, WORD ch)
 
WCHAR *WINAPI StrRChrW (const WCHAR *str, const WCHAR *end, WORD ch)
 
char *WINAPI StrRChrIA (const char *str, const char *end, WORD ch)
 
WCHAR *WINAPI StrRChrIW (const WCHAR *str, const WCHAR *end, WORD ch)
 
char *WINAPI StrRStrIA (const char *str, const char *end, const char *search)
 
WCHAR *WINAPI StrRStrIW (const WCHAR *str, const WCHAR *end, const WCHAR *search)
 
char *WINAPI StrPBrkA (const char *str, const char *match)
 
WCHAR *WINAPI StrPBrkW (const WCHAR *str, const WCHAR *match)
 
BOOL WINAPI StrTrimA (char *str, const char *trim)
 
BOOL WINAPI StrTrimW (WCHAR *str, const WCHAR *trim)
 
BOOL WINAPI StrToInt64ExA (const char *str, DWORD flags, LONGLONG *ret)
 
BOOL WINAPI StrToInt64ExW (const WCHAR *str, DWORD flags, LONGLONG *ret)
 
BOOL WINAPI StrToIntExA (const char *str, DWORD flags, INT *ret)
 
BOOL WINAPI StrToIntExW (const WCHAR *str, DWORD flags, INT *ret)
 
int WINAPI StrToIntA (const char *str)
 
int WINAPI StrToIntW (const WCHAR *str)
 
char *WINAPI StrCpyNXA (char *dst, const char *src, int len)
 
WCHAR *WINAPI StrCpyNXW (WCHAR *dst, const WCHAR *src, int len)
 
LPSTR WINAPI CharLowerA (char *str)
 
DWORD WINAPI CharLowerBuffA (char *str, DWORD len)
 
DWORD WINAPI CharLowerBuffW (WCHAR *str, DWORD len)
 
LPWSTR WINAPI CharLowerW (WCHAR *str)
 
LPSTR WINAPI CharNextA (const char *ptr)
 
LPSTR WINAPI CharNextExA (WORD codepage, const char *ptr, DWORD flags)
 
LPWSTR WINAPI CharNextW (const WCHAR *x)
 
LPSTR WINAPI CharPrevA (const char *start, const char *ptr)
 
LPSTR WINAPI CharPrevExA (WORD codepage, const char *start, const char *ptr, DWORD flags)
 
LPWSTR WINAPI CharPrevW (const WCHAR *start, const WCHAR *x)
 
LPSTR WINAPI CharUpperA (LPSTR str)
 
DWORD WINAPI CharUpperBuffA (LPSTR str, DWORD len)
 
DWORD WINAPI CharUpperBuffW (WCHAR *str, DWORD len)
 
LPWSTR WINAPI CharUpperW (WCHAR *str)
 
INT WINAPI DECLSPEC_HOTPATCH LoadStringW (HINSTANCE instance, UINT resource_id, LPWSTR buffer, INT buflen)
 
INT WINAPI DECLSPEC_HOTPATCH LoadStringA (HINSTANCE instance, UINT resource_id, LPSTR buffer, INT buflen)
 
int WINAPI StrCmpLogicalW (const WCHAR *str, const WCHAR *comp)
 
BOOL WINAPI StrIsIntlEqualA (BOOL case_sensitive, const char *str, const char *cmp, int len)
 
BOOL WINAPI StrIsIntlEqualW (BOOL case_sensitive, const WCHAR *str, const WCHAR *cmp, int len)
 
char *WINAPI StrCatBuffA (char *str, const char *cat, INT max_len)
 
WCHAR *WINAPI StrCatBuffW (WCHAR *str, const WCHAR *cat, INT max_len)
 
DWORD WINAPI StrCatChainW (WCHAR *str, DWORD max_len, DWORD at, const WCHAR *cat)
 
DWORD WINAPI SHTruncateString (char *str, DWORD size)
 
HRESULT WINAPI SHLoadIndirectString (const WCHAR *src, WCHAR *dst, UINT dst_len, void **reserved)
 

Function Documentation

◆ char_compare()

static BOOL char_compare ( WORD  ch1,
WORD  ch2,
DWORD  flags 
)
static

Definition at line 33 of file string.c.

34{
35 char str1[3], str2[3];
36
37 str1[0] = LOBYTE(ch1);
38 if (IsDBCSLeadByte(str1[0]))
39 {
40 str1[1] = HIBYTE(ch1);
41 str1[2] = '\0';
42 }
43 else
44 str1[1] = '\0';
45
46 str2[0] = LOBYTE(ch2);
47 if (IsDBCSLeadByte(str2[0]))
48 {
49 str2[1] = HIBYTE(ch2);
50 str2[2] = '\0';
51 }
52 else
53 str2[1] = '\0';
54
56}
LCID WINAPI GetThreadLocale(void)
Definition: locale.c:2803
BOOL WINAPI IsDBCSLeadByte(BYTE testchar)
Definition: locale.c:2126
INT WINAPI CompareStringA(LCID lcid, DWORD flags, LPCSTR str1, INT len1, LPCSTR str2, INT len2)
Definition: locale.c:4015
GLbitfield flags
Definition: glext.h:7161
#define LOBYTE(W)
Definition: jmemdos.c:487
#define HIBYTE(W)
Definition: jmemdos.c:486
XML_HIDDEN void xmlParserErrors const char const xmlChar const xmlChar * str2
Definition: parser.h:35
XML_HIDDEN void xmlParserErrors const char const xmlChar * str1
Definition: parser.h:35
#define CSTR_EQUAL
Definition: winnls.h:510

Referenced by ChrCmpIA(), StrChrA(), and StrRChrA().

◆ CharLowerA()

LPSTR WINAPI CharLowerA ( char str)

Definition at line 1087 of file string.c.

1088{
1089 if (IS_INTRESOURCE(str))
1090 {
1091 char ch = LOWORD(str);
1092 CharLowerBuffA( &ch, 1 );
1093 return (LPSTR)(UINT_PTR)(BYTE)ch;
1094 }
1095
1096 __TRY
1097 {
1099 }
1101 {
1103 return NULL;
1104 }
1105 __ENDTRY
1106 return str;
1107}
#define NULL
Definition: types.h:112
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
#define __TRY
Definition: compat.h:80
#define __ENDTRY
Definition: compat.h:82
#define __EXCEPT_PAGE_FAULT
Definition: compat.h:81
#define IS_INTRESOURCE(x)
Definition: loader.c:613
DWORD WINAPI CharLowerBuffA(char *str, DWORD len)
Definition: string.c:1109
unsigned char ch[4][2]
Definition: console.c:118
size_t __cdecl strlen(const char *str)
Definition: string.c:1597
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define LOWORD(l)
Definition: pedump.c:82
const WCHAR * str
char * LPSTR
Definition: typedefs.h:51
unsigned char BYTE
Definition: xxhash.c:193

Referenced by CharLowerTest(), ComboWndProc_common(), extract_test_proc(), and test_enumdisplaydevices_monitor().

◆ CharLowerBuffA()

DWORD WINAPI CharLowerBuffA ( char str,
DWORD  len 
)

Definition at line 1109 of file string.c.

1110{
1111 DWORD lenW;
1112 WCHAR buffer[32];
1113 WCHAR *strW = buffer;
1114
1115 if (!str) return 0; /* YES */
1116
1117 lenW = MultiByteToWideChar(CP_ACP, 0, str, len, NULL, 0);
1118 if (lenW > ARRAY_SIZE(buffer))
1119 {
1120 strW = HeapAlloc(GetProcessHeap(), 0, lenW * sizeof(WCHAR));
1121 if (!strW) return 0;
1122 }
1123 MultiByteToWideChar(CP_ACP, 0, str, len, strW, lenW);
1124 CharLowerBuffW(strW, lenW);
1125 len = WideCharToMultiByte(CP_ACP, 0, strW, lenW, str, len, NULL, NULL);
1126 if (strW != buffer) HeapFree(GetProcessHeap(), 0, strW);
1127 return len;
1128}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define GetProcessHeap()
Definition: compat.h:736
#define CP_ACP
Definition: compat.h:109
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
DWORD WINAPI CharLowerBuffW(WCHAR *str, DWORD len)
Definition: string.c:1130
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint buffer
Definition: glext.h:5915
GLenum GLsizei len
Definition: glext.h:6722
WCHAR strW[12]
Definition: clipboard.c:2216
short WCHAR
Definition: pedump.c:58

Referenced by CharLowerA(), ATL::ChTraitsCRT< char >::MakeLower(), and test_ExtractAssociatedIcon().

◆ CharLowerBuffW()

DWORD WINAPI CharLowerBuffW ( WCHAR str,
DWORD  len 
)

Definition at line 1130 of file string.c.

1131{
1132 if (!str) return 0; /* YES */
1134}
INT WINAPI LCMapStringW(LCID lcid, DWORD flags, LPCWSTR src, INT srclen, LPWSTR dst, INT dstlen)
Definition: locale.c:3808
#define LOCALE_USER_DEFAULT
#define LCMAP_LOWERCASE
Definition: winnls.h:201

Referenced by CharLowerBuffA(), CharLowerW(), EDIT_EM_ReplaceSel(), and ATL::ChTraitsCRT< _CharType >::MakeLower().

◆ CharLowerW()

◆ CharNextA()

◆ CharNextExA()

LPSTR WINAPI CharNextExA ( WORD  codepage,
const char ptr,
DWORD  flags 
)

Definition at line 1158 of file string.c.

1159{
1160 if (!*ptr) return (LPSTR)ptr;
1161 if (IsDBCSLeadByteEx( codepage, ptr[0] ) && ptr[1]) return (LPSTR)(ptr + 2);
1162 return (LPSTR)(ptr + 1);
1163}
BOOL WINAPI IsDBCSLeadByteEx(UINT codepage, BYTE testchar)
Definition: locale.c:2106
int codepage
Definition: win_iconv.c:156

Referenced by CharPrevExA(), testCharNext(), testStatCharNext(), and testStatCodePageCharNext().

◆ CharNextW()

LPWSTR WINAPI CharNextW ( const WCHAR x)

Definition at line 1165 of file string.c.

1166{
1167 if (*x) x++;
1168
1169 return (WCHAR *)x;
1170}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548

Referenced by _CopyAndUnquoteText(), _FindFirstField(), _FindNextArg(), SHELL_StripIllegalFsNameCharacters(), testCharNext(), and testStatCharNext().

◆ CharPrevA()

LPSTR WINAPI CharPrevA ( const char start,
const char ptr 
)

Definition at line 1172 of file string.c.

1173{
1174 while (*start && (start < ptr))
1175 {
1177 if (next >= ptr) break;
1178 start = next;
1179 }
1180 return (LPSTR)start;
1181}
LPSTR WINAPI CharNextA(const char *ptr)
Definition: string.c:1151
GLuint start
Definition: gl.h:1545
static unsigned __int64 next
Definition: rand_nt.c:6
const char * LPCSTR
Definition: typedefs.h:52

Referenced by myPathRemoveBackslashA(), PathRemoveArgsA(), PathRemoveBackslashA(), StrTrimA(), testCharPrev(), testCharPrevA(), and testStatCharPrev().

◆ CharPrevExA()

LPSTR WINAPI CharPrevExA ( WORD  codepage,
const char start,
const char ptr,
DWORD  flags 
)

Definition at line 1183 of file string.c.

1184{
1185 while (*start && (start < ptr))
1186 {
1188 if (next >= ptr) break;
1189 start = next;
1190 }
1191 return (LPSTR)start;
1192}
LPSTR WINAPI CharNextExA(WORD codepage, const char *ptr, DWORD flags)
Definition: string.c:1158

Referenced by testCharPrev(), testCharPrevA(), testStatCharPrev(), and testStatCodePageCharPrev().

◆ CharPrevW()

LPWSTR WINAPI CharPrevW ( const WCHAR start,
const WCHAR x 
)

Definition at line 1194 of file string.c.

1195{
1196 if (x > start) return (LPWSTR)(x - 1);
1197 else return (LPWSTR)x;
1198}

Referenced by _CopyAndUnquoteText(), PathQualifyExW(), testCharPrev(), testCharPrevW(), and testStatCharPrev().

◆ CharUpperA()

LPSTR WINAPI CharUpperA ( LPSTR  str)

Definition at line 1200 of file string.c.

1201{
1202 if (IS_INTRESOURCE(str))
1203 {
1204 char ch = LOWORD(str);
1205 CharUpperBuffA(&ch, 1);
1206 return (LPSTR)(UINT_PTR)(BYTE)ch;
1207 }
1208
1209 __TRY
1210 {
1212 }
1214 {
1216 return NULL;
1217 }
1218 __ENDTRY
1219 return str;
1220}
DWORD WINAPI CharUpperBuffA(LPSTR str, DWORD len)
Definition: string.c:1222

Referenced by CharUpperTest(), ComboWndProc_common(), MD_GetNotifyCode(), MD_msgdump_ex(), and MD_msgresult_ex().

◆ CharUpperBuffA()

DWORD WINAPI CharUpperBuffA ( LPSTR  str,
DWORD  len 
)

Definition at line 1222 of file string.c.

1223{
1224 DWORD lenW;
1225 WCHAR buffer[32];
1226 WCHAR *strW = buffer;
1227
1228 if (!str) return 0; /* YES */
1229
1230 lenW = MultiByteToWideChar(CP_ACP, 0, str, len, NULL, 0);
1231 if (lenW > ARRAY_SIZE(buffer))
1232 {
1233 strW = HeapAlloc(GetProcessHeap(), 0, lenW * sizeof(WCHAR));
1234 if (!strW) return 0;
1235 }
1236 MultiByteToWideChar(CP_ACP, 0, str, len, strW, lenW);
1237 CharUpperBuffW(strW, lenW);
1238 len = WideCharToMultiByte(CP_ACP, 0, strW, lenW, str, len, NULL, NULL);
1239 if (strW != buffer) HeapFree(GetProcessHeap(), 0, strW);
1240 return len;
1241}
DWORD WINAPI CharUpperBuffW(WCHAR *str, DWORD len)
Definition: string.c:1243

Referenced by CharUpperA(), and ATL::ChTraitsCRT< char >::MakeUpper().

◆ CharUpperBuffW()

DWORD WINAPI CharUpperBuffW ( WCHAR str,
DWORD  len 
)

◆ CharUpperW()

LPWSTR WINAPI CharUpperW ( WCHAR str)

Definition at line 1249 of file string.c.

1250{
1251 if (!IS_INTRESOURCE(str))
1252 {
1254 return str;
1255 }
1256 else
1257 {
1258 WCHAR ch = LOWORD(str);
1259 CharUpperBuffW(&ch, 1);
1260 return (LPWSTR)(UINT_PTR)ch;
1261 }
1262}

Referenced by COMBO_WindowProc(), ComboWndProc_common(), DIALOG_DlgDirListW(), InatCreateIconBySize(), MSI_InstallPackage(), str_dup_upper(), test_SetTargetComputer(), and testFmtId().

◆ ChrCmpIA()

BOOL WINAPI ChrCmpIA ( WORD  ch1,
WORD  ch2 
)

Definition at line 342 of file string.c.

343{
344 TRACE("%#x, %#x\n", ch1, ch2);
345
346 return char_compare(ch1, ch2, NORM_IGNORECASE);
347}
static BOOL char_compare(WORD ch1, WORD ch2, DWORD flags)
Definition: string.c:33
#define TRACE(s)
Definition: solgame.cpp:4
#define NORM_IGNORECASE
Definition: winnls.h:191

Referenced by StrChrIA(), StrRChrIA(), and StrRStrIA().

◆ ChrCmpIW()

BOOL WINAPI ChrCmpIW ( WCHAR  ch1,
WCHAR  ch2 
)

Definition at line 349 of file string.c.

350{
351 return CompareStringW(GetThreadLocale(), NORM_IGNORECASE, &ch1, 1, &ch2, 1) - CSTR_EQUAL;
352}
INT WINAPI CompareStringW(LCID lcid, DWORD flags, LPCWSTR str1, INT len1, LPCWSTR str2, INT len2)
Definition: locale.c:3946

Referenced by CAutoComplete::DoAutoAppend(), StrCmpLogicalW(), StrRChrIW(), StrRStrIW(), and url_guess_scheme().

◆ KERNELBASE_lstrcpynA()

LPSTR WINAPI KERNELBASE_lstrcpynA ( LPSTR  dst,
LPCSTR  src,
INT  n 
)

Definition at line 90 of file string.c.

91{
92 /* Note: this function differs from the UNIX strncpy, it _always_ writes
93 * a terminating \0.
94 *
95 * Note: n is an INT but Windows treats it as unsigned, and will happily
96 * copy a gazillion chars if n is negative.
97 */
98 __TRY
99 {
100 LPSTR d = dst;
101 LPCSTR s = src;
102 UINT count = n;
103
104 while ((count > 1) && *s)
105 {
106 count--;
107 *d++ = *s++;
108 }
109 if (count) *d = 0;
110 }
112 {
114 return 0;
115 }
117 return dst;
118}
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLdouble s
Definition: gl.h:2039
GLdouble n
Definition: glext.h:7729
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
#define d
Definition: ke_i.h:81
unsigned int UINT
Definition: ndis.h:50

◆ KERNELBASE_lstrcpynW()

LPWSTR WINAPI KERNELBASE_lstrcpynW ( LPWSTR  dst,
LPCWSTR  src,
INT  n 
)

Definition at line 120 of file string.c.

121{
122 /* Note: this function differs from the UNIX strncpy, it _always_ writes
123 * a terminating \0
124 *
125 * Note: n is an INT but Windows treats it as unsigned, and will happily
126 * copy a gazillion chars if n is negative.
127 */
128 __TRY
129 {
130 LPWSTR d = dst;
131 LPCWSTR s = src;
132 UINT count = n;
133
134 while ((count > 1) && *s)
135 {
136 count--;
137 *d++ = *s++;
138 }
139 if (count) *d = 0;
140 }
142 {
144 return 0;
145 }
147 return dst;
148}
const uint16_t * LPCWSTR
Definition: typedefs.h:57

◆ KERNELBASE_lstrlenA()

INT WINAPI KERNELBASE_lstrlenA ( LPCSTR  str)

Definition at line 150 of file string.c.

151{
152 INT ret;
153 __TRY
154 {
155 ret = strlen(str);
156 }
158 {
160 return 0;
161 }
163 return ret;
164}
return ret
Definition: mutex.c:146
int32_t INT
Definition: typedefs.h:58

◆ KERNELBASE_lstrlenW()

INT WINAPI KERNELBASE_lstrlenW ( LPCWSTR  str)

Definition at line 166 of file string.c.

167{
168 INT ret;
169 __TRY
170 {
171 ret = wcslen(str);
172 }
174 {
176 return 0;
177 }
179 return ret;
180}
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2988

◆ LoadStringA()

INT WINAPI DECLSPEC_HOTPATCH LoadStringA ( HINSTANCE  instance,
UINT  resource_id,
LPSTR  buffer,
INT  buflen 
)

Definition at line 1307 of file string.c.

1308{
1309 DWORD retval = 0;
1310 HGLOBAL hmem;
1311 HRSRC hrsrc;
1312
1313 TRACE("instance = %p, id = %04x, buffer = %p, length = %d\n", instance, resource_id, buffer, buflen);
1314
1315 if (!buflen) return -1;
1316
1317 /* Use loword (incremented by 1) as resourceid */
1318 if ((hrsrc = FindResourceW(instance, MAKEINTRESOURCEW((LOWORD(resource_id) >> 4) + 1), (LPWSTR)RT_STRING )) &&
1319 (hmem = LoadResource(instance, hrsrc)))
1320 {
1321 const WCHAR *p = LockResource(hmem);
1322 unsigned int id = resource_id & 0x000f;
1323
1324 while (id--) p += *p + 1;
1325
1326 RtlUnicodeToMultiByteN(buffer, buflen - 1, &retval, p + 1, *p * sizeof(WCHAR));
1327 }
1328 buffer[retval] = 0;
1329 TRACE("returning %s\n", debugstr_a(buffer));
1330 return retval;
1331}
static HINSTANCE instance
Definition: main.c:40
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
GLfloat GLfloat p
Definition: glext.h:8902
#define debugstr_a
Definition: kernel32.h:31
_Use_decl_annotations_ NTSTATUS NTAPI RtlUnicodeToMultiByteN(_Out_ PCHAR MbString, _In_ ULONG MbSize, _Out_opt_ PULONG ResultSize, _In_ PCWCH UnicodeString, _In_ ULONG UnicodeSize)
Definition: nlsboot.c:108
#define RT_STRING
Definition: pedump.c:368
int retval
Definition: wcstombs.cpp:91
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

Referenced by DirectDrawEnumerateExA(), extract_rev_infos(), BtrfsContextMenu::GetCommandString(), GetPredefinedClipboardFormatName(), GetStateTextA(), HCR_GetClassNameA(), HTTPREQ_QueryOption(), ldap_err2stringA(), LoadResourceString(), mciGetErrorStringA(), PRINTDLG_UpdatePrinterInfoTextsA(), RetrieveClipboardFormatName(), run_tests(), ShellMessageBoxA(), test_LoadStringA(), UIINSERTOBJECTDLG_AddControl(), UIINSERTOBJECTDLG_BrowseFile(), WINHELP_CreateHelpWindow(), WINHELP_CreateIndexWindow(), WINHELP_GetOpenFileName(), WINHELP_GetWindowInfo(), and WINHELP_MessageBoxIDS_s().

◆ LoadStringW()

INT WINAPI DECLSPEC_HOTPATCH LoadStringW ( HINSTANCE  instance,
UINT  resource_id,
LPWSTR  buffer,
INT  buflen 
)

Definition at line 1264 of file string.c.

1265{
1266 int string_num, i;
1267 HGLOBAL hmem;
1268 HRSRC hrsrc;
1269 WCHAR *p;
1270
1271 TRACE("instance = %p, id = %04x, buffer = %p, length = %d\n", instance, resource_id, buffer, buflen);
1272
1273 if (!buffer)
1274 return 0;
1275
1276 if (!(hrsrc = FindResourceW(instance, MAKEINTRESOURCEW((LOWORD(resource_id) >> 4) + 1), (LPWSTR)RT_STRING)) ||
1277 !(hmem = LoadResource(instance, hrsrc)))
1278 {
1279 TRACE( "Failed to load string.\n" );
1280 if (buflen > 0) buffer[0] = 0;
1281 return 0;
1282 }
1283
1284 p = LockResource(hmem);
1285 string_num = resource_id & 0x000f;
1286 for (i = 0; i < string_num; i++)
1287 p += *p + 1;
1288
1289 TRACE("strlen = %d\n", (int)*p );
1290
1291 /*if buflen == 0, then return a read-only pointer to the resource itself in buffer
1292 it is assumed that buffer is actually a (LPWSTR *) */
1293 if (buflen == 0)
1294 {
1295 *((LPWSTR *)buffer) = p + 1;
1296 return *p;
1297 }
1298
1299 i = min(buflen - 1, *p);
1300 memcpy(buffer, p + 1, i * sizeof(WCHAR));
1301 buffer[i] = 0;
1302
1303 TRACE("returning %s\n", debugstr_w(buffer));
1304 return i;
1305}
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
#define debugstr_w
Definition: kernel32.h:32
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define min(a, b)
Definition: monoChain.cc:55

◆ lstrcmpA()

int WINAPI lstrcmpA ( LPCSTR  str1,
LPCSTR  str2 
)

Definition at line 58 of file string.c.

59{
60 if (!str1 && !str2) return 0;
61 if (!str1) return -1;
62 if (!str2) return 1;
63 return CompareStringA( GetThreadLocale(), LOCALE_USE_CP_ACP, str1, -1, str2, -1 ) - 2;
64}
#define LOCALE_USE_CP_ACP
Definition: winnls.h:20

Referenced by StrCmpCA(), and strcomparefunc().

◆ lstrcmpiA()

int WINAPI lstrcmpiA ( LPCSTR  str1,
LPCSTR  str2 
)

Definition at line 74 of file string.c.

75{
76 if (!str1 && !str2) return 0;
77 if (!str1) return -1;
78 if (!str2) return 1;
80}

Referenced by istrcomparefunc(), and StrCmpICA().

◆ lstrcmpiW()

int WINAPI lstrcmpiW ( LPCWSTR  str1,
LPCWSTR  str2 
)

Definition at line 82 of file string.c.

83{
84 if (!str1 && !str2) return 0;
85 if (!str1) return -1;
86 if (!str2) return 1;
87 return CompareStringW( GetThreadLocale(), NORM_IGNORECASE, str1, -1, str2, -1 ) - 2;
88}

Referenced by StrCmpICW().

◆ lstrcmpW()

int WINAPI lstrcmpW ( LPCWSTR  str1,
LPCWSTR  str2 
)

Definition at line 66 of file string.c.

67{
68 if (!str1 && !str2) return 0;
69 if (!str1) return -1;
70 if (!str2) return 1;
71 return CompareStringW( GetThreadLocale(), 0, str1, -1, str2, -1 ) - 2;
72}

Referenced by StrCmpCW(), and test_wcscpy_s().

◆ SHLoadIndirectString()

HRESULT WINAPI SHLoadIndirectString ( const WCHAR src,
WCHAR dst,
UINT  dst_len,
void **  reserved 
)

Definition at line 1499 of file string.c.

1500{
1501 WCHAR *dllname = NULL;
1502 HMODULE hmod = NULL;
1503 HRESULT hr = E_FAIL;
1504#ifdef __REACTOS__
1505 WCHAR szExpanded[512];
1506#endif
1507
1508 TRACE("%s, %p, %#x, %p\n", debugstr_w(src), dst, dst_len, reserved);
1509
1510 if (src[0] == '@')
1511 {
1512 WCHAR *index_str;
1513 int index;
1514
1515#ifdef __REACTOS__
1516 if (wcschr(src, '%') != NULL)
1517 {
1518 ExpandEnvironmentStringsW(src, szExpanded, ARRAY_SIZE(szExpanded));
1519 src = szExpanded;
1520 }
1521#endif
1522 dst[0] = 0;
1523 dllname = StrDupW(src + 1);
1524 index_str = wcschr(dllname, ',');
1525
1526 if(!index_str) goto end;
1527
1528 *index_str = 0;
1529 index_str++;
1530 index = wcstol(index_str, NULL, 10);
1531
1532#ifdef __REACTOS__
1534#else
1535 hmod = LoadLibraryW(dllname);
1536#endif
1537 if (!hmod) goto end;
1538
1539 if (index < 0)
1540 {
1541 if (LoadStringW(hmod, -index, dst, dst_len))
1542 hr = S_OK;
1543 }
1544 else
1545 FIXME("can't handle non-negative indices (%d)\n", index);
1546 }
1547 else
1548 {
1549 if (dst != src)
1550 lstrcpynW(dst, src, dst_len);
1551 hr = S_OK;
1552 }
1553
1554 TRACE("returning %s\n", debugstr_w(dst));
1555end:
1556 if (hmod) FreeLibrary(hmod);
1557 LocalFree(dllname);
1558 return hr;
1559}
#define index(s, c)
Definition: various.h:29
#define FIXME(fmt,...)
Definition: precomp.h:53
#define E_FAIL
Definition: ddrawi.h:102
HRESULT hr
Definition: delayimp.cpp:582
#define wcschr
Definition: compat.h:17
#define FreeLibrary(x)
Definition: compat.h:748
#define LoadLibraryW(x)
Definition: compat.h:747
#define lstrcpynW
Definition: compat.h:738
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:492
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:288
WCHAR *WINAPI StrDupW(const WCHAR *str)
Definition: string.c:317
_ACRTIMP __msvcrt_long __cdecl wcstol(const wchar_t *, wchar_t **, int)
Definition: wcs.c:2752
r reserved
Definition: btrfs.c:3006
GLuint GLuint end
Definition: gl.h:1545
GLuint index
Definition: glext.h:6031
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define S_OK
Definition: intsafe.h:52
static NTSTATUS *static PWSTR CURDIR *static HMODULE hmod
Definition: security.c:104
#define LoadStringW
Definition: utils.h:64
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:338

Referenced by AllSysInfo(), execute_test(), CCleanupHandler::ReadProperty(), and SHLoadRegUIStringW().

◆ SHTruncateString()

DWORD WINAPI SHTruncateString ( char str,
DWORD  size 
)

Definition at line 1478 of file string.c.

1479{
1480 char *last_byte;
1481
1482 if (!str || !size)
1483 return 0;
1484
1485 last_byte = str + size - 1;
1486
1487 while (str < last_byte)
1488 str += IsDBCSLeadByte(*str) ? 2 : 1;
1489
1490 if (str == last_byte && IsDBCSLeadByte(*str))
1491 {
1492 *str = '\0';
1493 size--;
1494 }
1495
1496 return size;
1497}
GLsizeiptr size
Definition: glext.h:5919

Referenced by SHUnicodeToAnsiCP().

◆ StrCatBuffA()

char *WINAPI StrCatBuffA ( char str,
const char cat,
INT  max_len 
)

Definition at line 1417 of file string.c.

1418{
1419 INT len;
1420
1421 TRACE("%p, %s, %d\n", str, wine_dbgstr_a(cat), max_len);
1422
1423 if (!str)
1424 return NULL;
1425
1426 len = strlen(str);
1427 max_len -= len;
1428 if (max_len > 0)
1429 StrCpyNA(str + len, cat, max_len);
1430
1431 return str;
1432}
#define StrCpyNA
Definition: shlwapi.h:1104
const char int int int static __inline const char * wine_dbgstr_a(const char *s)
Definition: debug.h:152

◆ StrCatBuffW()

WCHAR *WINAPI StrCatBuffW ( WCHAR str,
const WCHAR cat,
INT  max_len 
)

Definition at line 1434 of file string.c.

1435{
1436 INT len;
1437
1438 TRACE("%p, %s, %d\n", str, wine_dbgstr_w(cat), max_len);
1439
1440 if (!str)
1441 return NULL;
1442
1443 len = lstrlenW(str);
1444 max_len -= len;
1445 if (max_len > 0)
1446 StrCpyNW(str + len, cat, max_len);
1447
1448 return str;
1449}
WCHAR *WINAPI StrCpyNW(WCHAR *dst, const WCHAR *src, int count)
Definition: string.c:470
#define wine_dbgstr_w
Definition: kernel32.h:34

Referenced by SHAboutInfoW(), SHAddToRecentDocs(), and StrFormatByteSizeEx().

◆ StrCatChainW()

DWORD WINAPI StrCatChainW ( WCHAR str,
DWORD  max_len,
DWORD  at,
const WCHAR cat 
)

Definition at line 1451 of file string.c.

1452{
1453 TRACE("%s, %lu, %ld, %s\n", wine_dbgstr_w(str), max_len, at, wine_dbgstr_w(cat));
1454
1455 if (at == -1)
1456 at = lstrlenW(str);
1457
1458 if (!max_len)
1459 return at;
1460
1461 if (at == max_len)
1462 at--;
1463
1464 if (cat && at < max_len)
1465 {
1466 str += at;
1467 while (at < max_len - 1 && *cat)
1468 {
1469 *str++ = *cat++;
1470 at++;
1471 }
1472 *str = 0;
1473 }
1474
1475 return at;
1476}

◆ StrChrA()

char *WINAPI StrChrA ( const char str,
WORD  ch 
)

Definition at line 212 of file string.c.

213{
214 TRACE("%s, %#x\n", wine_dbgstr_a(str), ch);
215
216 if (!str)
217 return NULL;
218
219 while (*str)
220 {
221 if (!char_compare(*str, ch, 0))
222 return (char *)str;
223 str = CharNextA(str);
224 }
225
226 return NULL;
227}

◆ StrChrIA()

char *WINAPI StrChrIA ( const char str,
WORD  ch 
)

Definition at line 239 of file string.c.

240{
241 TRACE("%s, %i\n", wine_dbgstr_a(str), ch);
242
243 if (!str)
244 return NULL;
245
246 while (*str)
247 {
248 if (!ChrCmpIA(*str, ch))
249 return (char *)str;
250 str = CharNextA(str);
251 }
252
253 return NULL;
254}
BOOL WINAPI ChrCmpIA(WORD ch1, WORD ch2)
Definition: string.c:342

◆ StrChrIW()

WCHAR *WINAPI StrChrIW ( const WCHAR str,
WCHAR  ch 
)

Definition at line 256 of file string.c.

257{
258 TRACE("%s, %#x\n", wine_dbgstr_w(str), ch);
259
260 if (!str)
261 return NULL;
262
263 ch = towupper(ch);
264 while (*str)
265 {
266 if (towupper(*str) == ch)
267 return (WCHAR *)str;
268 str++;
269 }
270 str = NULL;
271
272 return (WCHAR *)str;
273}
#define towupper(c)
Definition: wctype.h:99

◆ StrChrNW()

WCHAR *WINAPI StrChrNW ( const WCHAR str,
WCHAR  ch,
UINT  max_len 
)

Definition at line 275 of file string.c.

276{
277 TRACE("%s, %#x, %u\n", wine_dbgstr_wn(str, max_len), ch, max_len);
278
279 if (!str)
280 return NULL;
281
282 while (*str && max_len-- > 0)
283 {
284 if (*str == ch)
285 return (WCHAR *)str;
286 str++;
287 }
288
289 return NULL;
290}
#define wine_dbgstr_wn
Definition: testlist.c:2

◆ StrChrW()

WCHAR *WINAPI StrChrW ( const WCHAR str,
WCHAR  ch 
)

Definition at line 229 of file string.c.

230{
231 TRACE("%s, %#x\n", wine_dbgstr_w(str), ch);
232
233 if (!str)
234 return NULL;
235
236 return wcschr(str, ch);
237}

◆ StrCmpCA()

DWORD WINAPI StrCmpCA ( const char str,
const char cmp 
)

Definition at line 182 of file string.c.

183{
184 return lstrcmpA(str, cmp);
185}
int WINAPI lstrcmpA(LPCSTR str1, LPCSTR str2)
Definition: string.c:58
#define cmp(status, error)
Definition: error.c:118

◆ StrCmpCW()

DWORD WINAPI StrCmpCW ( const WCHAR str,
const WCHAR cmp 
)

Definition at line 187 of file string.c.

188{
189 return lstrcmpW(str, cmp);
190}
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: string.c:66

◆ StrCmpICA()

DWORD WINAPI StrCmpICA ( const char str,
const char cmp 
)

Definition at line 192 of file string.c.

193{
194 return lstrcmpiA(str, cmp);
195}
int WINAPI lstrcmpiA(LPCSTR str1, LPCSTR str2)
Definition: string.c:74

◆ StrCmpICW()

DWORD WINAPI StrCmpICW ( const WCHAR str,
const WCHAR cmp 
)

Definition at line 197 of file string.c.

198{
199 return lstrcmpiW(str, cmp);
200}
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: string.c:82

◆ StrCmpIW()

◆ StrCmpLogicalW()

int WINAPI StrCmpLogicalW ( const WCHAR str,
const WCHAR comp 
)

Definition at line 1333 of file string.c.

1334{
1335 TRACE("%s, %s\n", wine_dbgstr_w(str), wine_dbgstr_w(comp));
1336
1337 if (!str || !comp)
1338 return 0;
1339
1340 while (*str)
1341 {
1342 if (!*comp)
1343 return 1;
1344 else if (*str >= '0' && *str <= '9')
1345 {
1346 int str_value, comp_value;
1347
1348 if (*comp < '0' || *comp > '9')
1349 return -1;
1350
1351 /* Compare the numbers */
1352 StrToIntExW(str, 0, &str_value);
1353 StrToIntExW(comp, 0, &comp_value);
1354
1355 if (str_value < comp_value)
1356 return -1;
1357 else if (str_value > comp_value)
1358 return 1;
1359
1360 /* Skip */
1361 while (*str >= '0' && *str <= '9') str++;
1362 while (*comp >= '0' && *comp <= '9') comp++;
1363 }
1364 else if (*comp >= '0' && *comp <= '9')
1365 return 1;
1366 else
1367 {
1368 int diff = ChrCmpIW(*str, *comp);
1369 if (diff > 0)
1370 return 1;
1371 else if (diff < 0)
1372 return -1;
1373
1374 str++;
1375 comp++;
1376 }
1377 }
1378
1379 if (*comp)
1380 return -1;
1381
1382 return 0;
1383}
BOOL WINAPI ChrCmpIW(WCHAR ch1, WCHAR ch2)
Definition: string.c:349
BOOL WINAPI StrToIntExW(const WCHAR *str, DWORD flags, INT *ret)
Definition: string.c:1012
static int comp_value(const WCHAR *ptr, int dpc)
Definition: htmlbody.c:68

Referenced by CompareFunc(), CCabFolder::CompareID(), and SortListView().

◆ StrCmpNA()

int WINAPI StrCmpNA ( const char str,
const char comp,
int  len 
)

Definition at line 430 of file string.c.

431{
432 TRACE("%s, %s, %i\n", wine_dbgstr_a(str), wine_dbgstr_a(comp), len);
433 return CompareStringA(GetThreadLocale(), 0, str, len, comp, len) - CSTR_EQUAL;
434}

◆ StrCmpNCA()

DWORD WINAPI StrCmpNCA ( const char str,
const char comp,
int  len 
)

Definition at line 442 of file string.c.

443{
444 return StrCmpNA(str, comp, len);
445}
INT WINAPI StrCmpNA(LPCSTR lpszStr, LPCSTR lpszComp, INT iLen)
Definition: string.c:489

◆ StrCmpNCW()

DWORD WINAPI StrCmpNCW ( const WCHAR str,
const WCHAR comp,
int  len 
)

Definition at line 447 of file string.c.

448{
449 return StrCmpNW(str, comp, len);
450}
int WINAPI StrCmpNW(const WCHAR *str, const WCHAR *comp, int len)
Definition: string.c:436

◆ StrCmpNIA()

int WINAPI StrCmpNIA ( const char str,
const char cmp,
int  len 
)

Definition at line 404 of file string.c.

405{
406 TRACE("%s, %s, %i\n", wine_dbgstr_a(str), wine_dbgstr_a(cmp), len);
408}

◆ StrCmpNICA()

DWORD WINAPI StrCmpNICA ( const char str,
const char cmp,
DWORD  len 
)

Definition at line 202 of file string.c.

203{
204 return StrCmpNIA(str, cmp, len);
205}
INT WINAPI StrCmpNIA(LPCSTR lpszStr, LPCSTR lpszComp, INT iLen)
Definition: string.c:296

◆ StrCmpNICW()

DWORD WINAPI StrCmpNICW ( const WCHAR str,
const WCHAR cmp,
DWORD  len 
)

Definition at line 207 of file string.c.

208{
209 return StrCmpNIW(str, cmp, len);
210}
INT WINAPI StrCmpNIW(LPCWSTR lpszStr, LPCWSTR lpszComp, INT iLen)
Definition: string.c:307

◆ StrCmpNIW()

int WINAPI StrCmpNIW ( const WCHAR str,
const WCHAR comp,
int  len 
)

Definition at line 452 of file string.c.

453{
454 TRACE("%s, %s, %i\n", wine_dbgstr_w(str), wine_dbgstr_w(comp), len);
456}

◆ StrCmpNW()

int WINAPI StrCmpNW ( const WCHAR str,
const WCHAR comp,
int  len 
)

Definition at line 436 of file string.c.

437{
438 TRACE("%s, %s, %i\n", wine_dbgstr_w(str), wine_dbgstr_w(comp), len);
439 return CompareStringW(GetThreadLocale(), 0, str, len, comp, len) - CSTR_EQUAL;
440}

◆ StrCmpW()

◆ StrCpyNW()

WCHAR *WINAPI StrCpyNW ( WCHAR dst,
const WCHAR src,
int  count 
)

Definition at line 470 of file string.c.

471{
472 const WCHAR *s = src;
473 WCHAR *d = dst;
474
475 TRACE("%p, %s, %i\n", dst, wine_dbgstr_w(src), count);
476
477 if (s)
478 {
479 while ((count > 1) && *s)
480 {
481 count--;
482 *d++ = *s++;
483 }
484 }
485 if (count) *d = 0;
486
487 return dst;
488}

Referenced by CIniPropertyBag::_GetSectionAndName(), CZipExtract::Extract(), PathCreateFromUrlW(), SHCreatePropertyBagOnProfileSection(), Shell_ParseSpecialFolder(), ShellExec_RunDLL_Helper(), SHGlobalCounterCreateNamedW(), SHHandleUpdateImage(), SHPathPrepareForWriteW(), StrCatBuffW(), StrNCatW(), and test_StrXXX_overflows().

◆ StrCpyNXA()

char *WINAPI StrCpyNXA ( char dst,
const char src,
int  len 
)

Definition at line 1057 of file string.c.

1058{
1059 TRACE("%p, %s, %i\n", dst, wine_dbgstr_a(src), len);
1060
1061 if (dst && src && len > 0)
1062 {
1063 while ((len-- > 1) && *src)
1064 *dst++ = *src++;
1065 if (len >= 0)
1066 *dst = '\0';
1067 }
1068
1069 return dst;
1070}

◆ StrCpyNXW()

WCHAR *WINAPI StrCpyNXW ( WCHAR dst,
const WCHAR src,
int  len 
)

Definition at line 1072 of file string.c.

1073{
1074 TRACE("%p, %s, %i\n", dst, wine_dbgstr_w(src), len);
1075
1076 if (dst && src && len > 0)
1077 {
1078 while ((len-- > 1) && *src)
1079 *dst++ = *src++;
1080 if (len >= 0)
1081 *dst = '\0';
1082 }
1083
1084 return dst;
1085}

Referenced by SHUpdateImageW().

◆ StrCSpnA()

int WINAPI StrCSpnA ( const char str,
const char match 
)

Definition at line 555 of file string.c.

556{
557 const char *ptr = str;
558
559 TRACE("%s, %s\n", wine_dbgstr_a(str), wine_dbgstr_a(match));
560
561 if (!str || !match) return 0;
562
563 while (*ptr)
564 {
565 if (StrChrA(match, *ptr)) break;
566 ptr = CharNextA(ptr);
567 }
568 return ptr - str;
569}
LPSTR WINAPI StrChrA(LPCSTR lpszStr, WORD ch)
Definition: string.c:266
Definition: match.c:28

◆ StrCSpnIA()

int WINAPI StrCSpnIA ( const char str,
const char match 
)

Definition at line 579 of file string.c.

580{
581 const char *ptr = str;
582
583 TRACE("%s, %s\n", wine_dbgstr_a(str), wine_dbgstr_a(match));
584
585 if (!str || !match) return 0;
586
587 while (*ptr)
588 {
589 if (StrChrIA(match, *ptr)) break;
590 ptr = CharNextA(ptr);
591 }
592 return ptr - str;
593}
LPSTR WINAPI StrChrIA(LPCSTR lpszStr, WORD ch)
Definition: string.c:610

◆ StrCSpnIW()

int WINAPI StrCSpnIW ( const WCHAR str,
const WCHAR match 
)

Definition at line 595 of file string.c.

596{
597 const WCHAR *ptr = str;
598
599 TRACE("%s, %s\n", wine_dbgstr_w(str), wine_dbgstr_w(match));
600
601 if (!str || !*str || !match)
602 return 0;
603
604 while (*ptr)
605 {
606 if (StrChrIW(match, *ptr)) break;
607 ptr++;
608 }
609
610 return ptr - str;
611}
LPWSTR WINAPI StrChrIW(LPCWSTR lpszStr, WCHAR ch)
Definition: string.c:631

◆ StrCSpnW()

int WINAPI StrCSpnW ( const WCHAR str,
const WCHAR match 
)

Definition at line 571 of file string.c.

572{
573 if (!str || !match)
574 return 0;
575
576 return wcscspn(str, match);
577}
_ACRTIMP size_t __cdecl wcscspn(const wchar_t *, const wchar_t *)
Definition: wcs.c:503

◆ StrDupA()

char *WINAPI StrDupA ( const char str)

Definition at line 292 of file string.c.

293{
294 unsigned int len;
295 char *ret;
296
297 TRACE("%s\n", wine_dbgstr_a(str));
298
299#ifdef __REACTOS__
300 if (!str)
301 return NULL;
302#endif
303 len = str ? strlen(str) + 1 : 1;
305
306 if (ret)
307 {
308 if (str)
309 memcpy(ret, str, len);
310 else
311 *ret = '\0';
312 }
313
314 return ret;
315}
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
#define LMEM_FIXED
Definition: minwinbase.h:81

Referenced by SHLWAPI_GetModuleVersion(), TEST_StrDupA(), and test_StrDupA().

◆ StrDupW()

◆ StrIsIntlEqualA()

BOOL WINAPI StrIsIntlEqualA ( BOOL  case_sensitive,
const char str,
const char cmp,
int  len 
)

Definition at line 1385 of file string.c.

1386{
1387 DWORD flags;
1388
1389 TRACE("%d, %s, %s, %d\n", case_sensitive, wine_dbgstr_a(str), wine_dbgstr_a(cmp), len);
1390
1391 /* FIXME: This flag is undocumented and unknown by our CompareString.
1392 * We need a define for it.
1393 */
1394 flags = 0x10000000;
1395 if (!case_sensitive)
1397
1399}

◆ StrIsIntlEqualW()

BOOL WINAPI StrIsIntlEqualW ( BOOL  case_sensitive,
const WCHAR str,
const WCHAR cmp,
int  len 
)

Definition at line 1401 of file string.c.

1402{
1403 DWORD flags;
1404
1405 TRACE("%d, %s, %s, %d\n", case_sensitive, debugstr_w(str), debugstr_w(cmp), len);
1406
1407 /* FIXME: This flag is undocumented and unknown by our CompareString.
1408 * We need a define for it.
1409 */
1410 flags = 0x10000000;
1411 if (!case_sensitive)
1413
1415}

◆ StrPBrkA()

char *WINAPI StrPBrkA ( const char str,
const char match 
)

Definition at line 743 of file string.c.

744{
745 TRACE("%s, %s\n", wine_dbgstr_a(str), wine_dbgstr_a(match));
746
747 if (!str || !match || !*match)
748 return NULL;
749
750 while (*str)
751 {
752 if (StrChrA(match, *str))
753 return (char *)str;
754 str = CharNextA(str);
755 }
756
757 return NULL;
758}

◆ StrPBrkW()

WCHAR *WINAPI StrPBrkW ( const WCHAR str,
const WCHAR match 
)

Definition at line 760 of file string.c.

761{
762 if (!str || !match) return NULL;
763 return wcspbrk(str, match);
764}
_ACRTIMP wchar_t *__cdecl wcspbrk(const wchar_t *, const wchar_t *)
Definition: wcs.c:2021

Referenced by CheckEscapesW(), IsIllegalFsFileName(), parse_file_list(), and SHFindAttrW().

◆ StrRChrA()

char *WINAPI StrRChrA ( const char str,
const char end,
WORD  ch 
)

Definition at line 613 of file string.c.

614{
615 const char *ret = NULL;
616
617 TRACE("%s, %s, %#x\n", wine_dbgstr_a(str), wine_dbgstr_a(end), ch);
618
619 if (!str) return NULL;
620 if (!end) end = str + lstrlenA(str);
621 while (*str && str <= end)
622 {
623 WORD ch2 = IsDBCSLeadByte(*str) ? *str << 8 | str[1] : *str;
624 if (!char_compare(ch, ch2, 0)) ret = str;
625 str = CharNextA(str);
626 }
627 return (char *)ret;
628}
unsigned short WORD
Definition: ntddk_ex.h:93
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145

◆ StrRChrIA()

char *WINAPI StrRChrIA ( const char str,
const char end,
WORD  ch 
)

Definition at line 644 of file string.c.

645{
646 const char *ret = NULL;
647
648 TRACE("%s, %s, %#x\n", wine_dbgstr_a(str), wine_dbgstr_a(end), ch);
649
650 if (!str) return NULL;
651 if (!end) end = str + lstrlenA(str);
652
653 while (*str && str <= end)
654 {
655 WORD ch2 = IsDBCSLeadByte(*str) ? *str << 8 | str[1] : *str;
656 if (!ChrCmpIA(ch, ch2)) ret = str;
657 str = CharNextA(str);
658 }
659 return (char *)ret;
660}

◆ StrRChrIW()

WCHAR *WINAPI StrRChrIW ( const WCHAR str,
const WCHAR end,
WORD  ch 
)

Definition at line 662 of file string.c.

663{
664 WCHAR *ret = NULL;
665
666 if (!str) return NULL;
667 if (!end) end = str + lstrlenW(str);
668 while (str < end)
669 {
670 if (!ChrCmpIW(*str, ch)) ret = (WCHAR *)str;
671 str++;
672 }
673 return ret;
674}

◆ StrRChrW()

WCHAR *WINAPI StrRChrW ( const WCHAR str,
const WCHAR end,
WORD  ch 
)

Definition at line 630 of file string.c.

631{
632 WCHAR *ret = NULL;
633
634 if (!str) return NULL;
635 if (!end) end = str + lstrlenW(str);
636 while (str < end)
637 {
638 if (*str == ch) ret = (WCHAR *)str;
639 str++;
640 }
641 return ret;
642}

◆ StrRStrIA()

char *WINAPI StrRStrIA ( const char str,
const char end,
const char search 
)

Definition at line 676 of file string.c.

677{
678 char *ret = NULL;
679 WORD ch1, ch2;
680 int len;
681
683
684 if (!str || !search || !*search)
685 return NULL;
686
688 ch1 = *search << 8 | (UCHAR)search[1];
689 else
690 ch1 = *search;
692
693 if (!end)
694 end = str + lstrlenA(str);
695 else /* reproduce the broken behaviour on Windows */
696 end += min(len - 1, lstrlenA(end));
697
698 while (str + len <= end && *str)
699 {
700 ch2 = IsDBCSLeadByte(*str) ? *str << 8 | (UCHAR)str[1] : *str;
701 if (!ChrCmpIA(ch1, ch2))
702 {
703 if (!StrCmpNIA(str, search, len))
704 ret = (char *)str;
705 }
706
707 str = CharNextA(str);
708 }
709
710 return ret;
711}
static short search(int val, const short *table, int size)
Definition: msg711.c:255
unsigned char UCHAR
Definition: typedefs.h:53

◆ StrRStrIW()

WCHAR *WINAPI StrRStrIW ( const WCHAR str,
const WCHAR end,
const WCHAR search 
)

Definition at line 713 of file string.c.

714{
715 WCHAR *ret = NULL;
716 int len;
717
719
720 if (!str || !search || !*search)
721 return NULL;
722
724
725 if (!end)
726 end = str + lstrlenW(str);
727 else
728 end += min(len - 1, lstrlenW(end));
729
730 while (str + len <= end && *str)
731 {
732 if (!ChrCmpIW(*search, *str))
733 {
734 if (!StrCmpNIW(str, search, len))
735 ret = (WCHAR *)str;
736 }
737 str++;
738 }
739
740 return ret;
741}

◆ StrSpnA()

int WINAPI StrSpnA ( const char str,
const char match 
)

Definition at line 533 of file string.c.

534{
535 const char *ptr = str;
536
537 TRACE("%s, %s\n", wine_dbgstr_a(str), wine_dbgstr_a(match));
538
539 if (!str || !match) return 0;
540
541 while (*ptr)
542 {
543 if (!StrChrA(match, *ptr)) break;
544 ptr = CharNextA(ptr);
545 }
546 return ptr - str;
547}

◆ StrSpnW()

int WINAPI StrSpnW ( const WCHAR str,
const WCHAR match 
)

Definition at line 549 of file string.c.

550{
551 if (!str || !match) return 0;
552 return wcsspn(str, match);
553}
_ACRTIMP size_t __cdecl wcsspn(const wchar_t *, const wchar_t *)
Definition: wcs.c:513

◆ StrStrA()

char *WINAPI StrStrA ( const char str,
const char search 
)

Definition at line 354 of file string.c.

355{
356 const char *end;
357 size_t len;
358
360
361 if (!str || !search || !*search) return NULL;
362
363 len = strlen(search);
364 end = str + strlen(str);
365
366 while (str + len <= end)
367 {
368 if (!StrCmpNA(str, search, len)) return (char *)str;
369 str = CharNextA(str);
370 }
371 return NULL;
372}

◆ StrStrIA()

char *WINAPI StrStrIA ( const char str,
const char search 
)

Definition at line 490 of file string.c.

491{
492 const char *end;
493 size_t len;
494
495 TRACE("%s, %s\n", wine_dbgstr_a(str), debugstr_a(search));
496
497 if (!str || !search || !*search) return NULL;
498
499 len = strlen(search);
500 end = str + strlen(str);
501
502 while (str + len <= end)
503 {
504 if (!StrCmpNIA(str, search, len)) return (char *)str;
505 str = CharNextA(str);
506 }
507 return NULL;
508}

◆ StrStrIW()

WCHAR *WINAPI StrStrIW ( const WCHAR str,
const WCHAR search 
)

Definition at line 510 of file string.c.

511{
512 unsigned int len;
513 const WCHAR *end;
514
516
517 if (!str || !search || !*search)
518 return NULL;
519
521 end = str + lstrlenW(str);
522
523 while (str + len <= end)
524 {
525 if (!StrCmpNIW(str, search, len))
526 return (WCHAR *)str;
527 str++;
528 }
529
530 return NULL;
531}

◆ StrStrNIW()

WCHAR *WINAPI StrStrNIW ( const WCHAR str,
const WCHAR search,
UINT  max_len 
)

Definition at line 410 of file string.c.

411{
412 unsigned int i, len;
413
414 TRACE("%s, %s, %u\n", wine_dbgstr_w(str), wine_dbgstr_w(search), max_len);
415
416 if (!str || !search || !*search || !max_len)
417 return NULL;
418
420
421 for (i = max_len; *str && (i > 0); i--, str++)
422 {
423 if (!StrCmpNIW(str, search, len))
424 return (WCHAR *)str;
425 }
426
427 return NULL;
428}

◆ StrStrNW()

WCHAR *WINAPI StrStrNW ( const WCHAR str,
const WCHAR search,
UINT  max_len 
)

Definition at line 384 of file string.c.

385{
386 unsigned int i, len;
387
388 TRACE("%s, %s, %u\n", wine_dbgstr_w(str), wine_dbgstr_w(search), max_len);
389
390 if (!str || !search || !*search || !max_len)
391 return NULL;
392
394
395 for (i = max_len; *str && (i > 0); i--, str++)
396 {
397 if (!wcsncmp(str, search, len))
398 return (WCHAR *)str;
399 }
400
401 return NULL;
402}
_ACRTIMP int __cdecl wcsncmp(const wchar_t *, const wchar_t *, size_t)
Definition: wcs.c:523

◆ StrStrW()

WCHAR *WINAPI StrStrW ( const WCHAR str,
const WCHAR search 
)

Definition at line 374 of file string.c.

375{
377
378 if (!str || !search || !*search)
379 return NULL;
380
381 return wcsstr(str, search);
382}
_ACRTIMP wchar_t *__cdecl wcsstr(const wchar_t *, const wchar_t *)
Definition: wcs.c:2998

◆ StrToInt64ExA()

BOOL WINAPI StrToInt64ExA ( const char str,
DWORD  flags,
LONGLONG ret 
)

Definition at line 842 of file string.c.

843{
844 BOOL negative = FALSE;
845 LONGLONG value = 0;
846
847 TRACE("%s, %#lx, %p\n", wine_dbgstr_a(str), flags, ret);
848
849 if (!str || !ret)
850 return FALSE;
851
853 WARN("Unknown flags %#lx\n", flags);
854
855 /* Skip leading space, '+', '-' */
856 while (*str == ' ' || *str == '\t' || *str == '\n') str++;
857
858 if (*str == '-')
859 {
860 negative = TRUE;
861 str++;
862 }
863 else if (*str == '+')
864 str++;
865
866 if (flags & STIF_SUPPORT_HEX && *str == '0' && (str[1] == 'x' || str[1] == 'X'))
867 {
868 /* Read hex number */
869 str += 2;
870
871 if (!isxdigit(*str))
872#ifdef __REACTOS__
873 {
874 *ret = 0;
875 return FALSE;
876 }
877#else
878 return FALSE;
879#endif
880
881 while (isxdigit(*str))
882 {
883 value *= 16;
884 if (*str >= '0' && *str <= '9')
885 value += (*str - '0');
886 else if (*str >= 'A' && *str <= 'F')
887 value += 10 + *str - 'A';
888 else
889 value += 10 + *str - 'a';
890 str++;
891 }
892
893 *ret = value;
894 return TRUE;
895 }
896
897 /* Read decimal number */
898 if (*str < '0' || *str > '9')
899#ifdef __REACTOS__
900 {
901 *ret = 0;
902 return FALSE;
903 }
904#else
905 return FALSE;
906#endif
907
908 while (*str >= '0' && *str <= '9')
909 {
910 value *= 10;
911 value += (*str - '0');
912 str++;
913 }
914
915 *ret = negative ? -value : value;
916 return TRUE;
917}
#define isxdigit(c)
Definition: acclib.h:70
#define WARN(fmt,...)
Definition: precomp.h:61
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define STIF_SUPPORT_HEX
Definition: shlwapi.h:1059
int64_t LONGLONG
Definition: typedefs.h:68
Definition: pdh_main.c:96

Referenced by StrToIntExA(), and TEST_StrToIntA().

◆ StrToInt64ExW()

BOOL WINAPI StrToInt64ExW ( const WCHAR str,
DWORD  flags,
LONGLONG ret 
)

Definition at line 919 of file string.c.

920{
921 BOOL negative = FALSE;
922 LONGLONG value = 0;
923
924 TRACE("%s, %#lx, %p\n", wine_dbgstr_w(str), flags, ret);
925
926 if (!str || !ret)
927 return FALSE;
928
930 WARN("Unknown flags %#lx.\n", flags);
931
932 /* Skip leading space, '+', '-' */
933 while (*str == ' ' || *str == '\t' || *str == '\n') str++;
934
935 if (*str == '-')
936 {
937 negative = TRUE;
938 str++;
939 }
940 else if (*str == '+')
941 str++;
942
943 if (flags & STIF_SUPPORT_HEX && *str == '0' && (str[1] == 'x' || str[1] == 'X'))
944 {
945 /* Read hex number */
946 str += 2;
947
948 if (!isxdigit(*str))
949#ifdef __REACTOS__
950 {
951 *ret = 0;
952 return FALSE;
953 }
954#else
955 return FALSE;
956#endif
957
958 while (isxdigit(*str))
959 {
960 value *= 16;
961 if (*str >= '0' && *str <= '9')
962 value += (*str - '0');
963 else if (*str >= 'A' && *str <= 'Z')
964 value += 10 + (*str - 'A');
965 else
966 value += 10 + (*str - 'a');
967 str++;
968 }
969
970 *ret = value;
971 return TRUE;
972 }
973
974 /* Read decimal number */
975 if (*str < '0' || *str > '9')
976#ifdef __REACTOS__
977 {
978 *ret = 0;
979 return FALSE;
980 }
981#else
982 return FALSE;
983#endif
984
985 while (*str >= '0' && *str <= '9')
986 {
987 value *= 10;
988 value += (*str - '0');
989 str++;
990 }
991
992 *ret = negative ? -value : value;
993 return TRUE;
994}

Referenced by set_content_length(), StrToIntExW(), and TEST_StrToIntW().

◆ StrToIntA()

int WINAPI StrToIntA ( const char str)

Definition at line 1028 of file string.c.

1029{
1030 int value = 0;
1031
1032 TRACE("%s\n", wine_dbgstr_a(str));
1033
1034 if (!str)
1035 return 0;
1036
1037 if (*str == '-' || (*str >= '0' && *str <= '9'))
1038 StrToIntExA(str, 0, &value);
1039
1040 return value;
1041}
BOOL WINAPI StrToIntExA(const char *str, DWORD flags, INT *ret)
Definition: string.c:996

◆ StrToIntExA()

BOOL WINAPI StrToIntExA ( const char str,
DWORD  flags,
INT ret 
)

Definition at line 996 of file string.c.

997{
999 BOOL res;
1000
1001 TRACE("%s, %#lx, %p\n", wine_dbgstr_a(str), flags, ret);
1002
1004#ifdef __REACTOS__
1005 if (ret) *ret = res ? (INT)value : 0;
1006#else
1007 if (res) *ret = value;
1008#endif
1009 return res;
1010}
BOOL WINAPI StrToInt64ExA(const char *str, DWORD flags, LONGLONG *ret)
Definition: string.c:842
GLuint res
Definition: glext.h:9613
#define INT
Definition: polytest.cpp:20

Referenced by StrToIntA(), TEST_StrToIntA(), and test_StrToIntExA().

◆ StrToIntExW()

BOOL WINAPI StrToIntExW ( const WCHAR str,
DWORD  flags,
INT ret 
)

Definition at line 1012 of file string.c.

1013{
1015 BOOL res;
1016
1017 TRACE("%s, %#lx, %p\n", wine_dbgstr_w(str), flags, ret);
1018
1020#ifdef __REACTOS__
1021 if (ret) *ret = res ? (INT)value : 0;
1022#else
1023 if (res) *ret = value;
1024#endif
1025 return res;
1026}
BOOL WINAPI StrToInt64ExW(const WCHAR *str, DWORD flags, LONGLONG *ret)
Definition: string.c:919

Referenced by CompareVersion(), CAvailableApplicationInfo::RetrieveLanguages(), ShellExec_RunDLL_Helper(), StrCmpLogicalW(), StrToIntW(), test_StrToIntExW(), TEST_StrToIntW(), and UrlUnescapeW().

◆ StrToIntW()

int WINAPI StrToIntW ( const WCHAR str)

Definition at line 1043 of file string.c.

1044{
1045 int value = 0;
1046
1047 TRACE("%s\n", wine_dbgstr_w(str));
1048
1049 if (!str)
1050 return 0;
1051
1052 if (*str == '-' || (*str >= '0' && *str <= '9'))
1053 StrToIntExW(str, 0, &value);
1054 return value;
1055}

◆ StrTrimA()

BOOL WINAPI StrTrimA ( char str,
const char trim 
)

Definition at line 766 of file string.c.

767{
768 unsigned int len;
769 BOOL ret = FALSE;
770 char *ptr = str;
771
772 TRACE("%s, %s\n", debugstr_a(str), debugstr_a(trim));
773
774 if (!str || !*str)
775 return FALSE;
776
777 while (*ptr && StrChrA(trim, *ptr))
778 ptr = CharNextA(ptr); /* Skip leading matches */
779
780 len = strlen(ptr);
781
782 if (ptr != str)
783 {
784 memmove(str, ptr, len + 1);
785 ret = TRUE;
786 }
787
788 if (len > 0)
789 {
790 ptr = str + len;
791 while (StrChrA(trim, ptr[-1]))
792 ptr = CharPrevA(str, ptr); /* Skip trailing matches */
793
794 if (ptr != str + len)
795 {
796 *ptr = '\0';
797 ret = TRUE;
798 }
799 }
800
801 return ret;
802}
LPSTR WINAPI CharPrevA(const char *start, const char *ptr)
Definition: string.c:1172
char * trim(char *str, char **last_chr, BOOL strip_quotes)
Definition: inf.c:258
#define memmove(s1, s2, n)
Definition: mkisofs.h:881

◆ StrTrimW()

BOOL WINAPI StrTrimW ( WCHAR str,
const WCHAR trim 
)

Definition at line 804 of file string.c.

805{
806 unsigned int len;
807 WCHAR *ptr = str;
808 BOOL ret = FALSE;
809
810 TRACE("%s, %s\n", wine_dbgstr_w(str), wine_dbgstr_w(trim));
811
812 if (!str || !*str)
813 return FALSE;
814
815 while (*ptr && StrChrW(trim, *ptr))
816 ptr++;
817
818 len = lstrlenW(ptr);
819
820 if (ptr != str)
821 {
822 memmove(str, ptr, (len + 1) * sizeof(WCHAR));
823 ret = TRUE;
824 }
825
826 if (len > 0)
827 {
828 ptr = str + len;
829 while (StrChrW(trim, ptr[-1]))
830 ptr--; /* Skip trailing matches */
831
832 if (ptr != str + len)
833 {
834 *ptr = '\0';
835 ret = TRUE;
836 }
837 }
838
839 return ret;
840}
WCHAR *WINAPI StrChrW(const WCHAR *str, WCHAR ch)
Definition: string.c:229

Referenced by BrFolder_OnOK(), EditActionDlg_OnOK(), EditTypeDlg_OnOK(), EditTypeDlg_OnRemove(), FinishDlgProc(), CFSFolder::GetCustomViewInfo(), NewActionDlg_OnOK(), NewExtDlg_OnOK(), CShellLink::OnNotify(), RunDlgProc(), SHELL32_AssocGetExtensionDescription(), ShellExecCmdLine(), WelcomeDlgProc(), and WindowProc().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( string  )