ReactOS 0.4.15-dev-7968-g24a56f8
stringtable.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winreg.h"
#include "winnls.h"
#include "setupapi.h"
#include "wine/test.h"
Include dependency graph for stringtable.c:

Go to the source code of this file.

Classes

struct  stringtable
 

Macros

#define ST_CASE_SENSITIVE_COMPARE   0x00000001
 
#define X(f)
 

Functions

static DWORD (WINAPI *pStringTableAddString)(HSTRING_TABLE
 
static VOID (WINAPI *pStringTableDestroy)(HSTRING_TABLE)
 
static HSTRING_TABLE (WINAPI *pStringTableDuplicate)(HSTRING_TABLE hStringTable)
 
static LPWSTR (WINAPI *pStringTableStringFromId)(HSTRING_TABLE
 
static BOOL (WINAPI *pStringTableGetExtraData)(HSTRING_TABLE
 
static void load_it_up (void)
 
static void test_StringTableAddString (void)
 
static void test_StringTableAddStringEx (void)
 
static void test_StringTableDuplicate (void)
 
static void test_StringTableLookUpString (void)
 
static void test_StringTableLookUpStringEx (void)
 
static void test_StringTableStringFromId (void)
 
static void test_stringtable_layout (void)
 
 START_TEST (stringtable)
 

Variables

static LPWSTR
 
static DWORD
 
static LPVOID
 
static ULONG
 
static WCHAR string [] = {'s','t','r','i','n','g',0}
 
static WCHAR String [] = {'S','t','r','i','n','g',0}
 
static WCHAR foo [] = {'f','o','o',0}
 

Macro Definition Documentation

◆ ST_CASE_SENSITIVE_COMPARE

#define ST_CASE_SENSITIVE_COMPARE   0x00000001

Definition at line 41 of file stringtable.c.

◆ X

#define X (   f)
Value:
if (!(p##f = (void*)GetProcAddress(hdll, #f))) \
p##f = (void*)GetProcAddress(hdll, "pSetup"#f);
#define GetProcAddress(x, y)
Definition: compat.h:753
GLfloat f
Definition: glext.h:7540
GLfloat GLfloat p
Definition: glext.h:8902
static PVOID hdll
Definition: shimdbg.c:126

Function Documentation

◆ BOOL()

static BOOL ( WINAPI pStringTableGetExtraData)
static

◆ DWORD()

static DWORD ( WINAPI pStringTableAddString)
static

◆ HSTRING_TABLE()

static HSTRING_TABLE ( WINAPI pStringTableDuplicate)
static

◆ load_it_up()

static void load_it_up ( void  )
static

Definition at line 58 of file stringtable.c.

59{
60 HMODULE hdll = GetModuleHandleA("setupapi.dll");
61
62#define X(f) if (!(p##f = (void*)GetProcAddress(hdll, #f))) \
63 p##f = (void*)GetProcAddress(hdll, "pSetup"#f);
64 X(StringTableInitialize);
65 X(StringTableInitializeEx);
66 X(StringTableAddString);
67 X(StringTableAddStringEx);
68 X(StringTableDuplicate);
69 X(StringTableDestroy);
70 X(StringTableLookUpString);
71 X(StringTableLookUpStringEx);
72 X(StringTableStringFromId);
73 X(StringTableGetExtraData);
74#undef X
75}
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
#define X(f)

Referenced by START_TEST().

◆ LPWSTR()

static LPWSTR ( WINAPI pStringTableStringFromId)
static

◆ START_TEST()

START_TEST ( stringtable  )

Definition at line 363 of file stringtable.c.

364{
365 load_it_up();
366
374}
static void test_StringTableAddString(void)
Definition: stringtable.c:77
static void test_stringtable_layout(void)
Definition: stringtable.c:340
static void test_StringTableAddStringEx(void)
Definition: stringtable.c:104
static void test_StringTableLookUpStringEx(void)
Definition: stringtable.c:225
static void load_it_up(void)
Definition: stringtable.c:58
static void test_StringTableLookUpString(void)
Definition: stringtable.c:168
static void test_StringTableDuplicate(void)
Definition: stringtable.c:154
static void test_StringTableStringFromId(void)
Definition: stringtable.c:308

◆ test_stringtable_layout()

static void test_stringtable_layout ( void  )
static

Definition at line 340 of file stringtable.c.

341{
342 struct stringtable *ptr;
344
345 table = pStringTableInitialize();
346 ok(table != NULL,"failed to initialize string table\n");
347
348 ptr = (struct stringtable*)table;
349 ok(ptr->data != NULL, "got %p\n", ptr->data);
350 /* first data offset is right after bucket area */
351 ok(ptr->nextoffset == 509*sizeof(DWORD), "got %d\n", ptr->nextoffset);
352 ok(ptr->allocated != 0, "got %d\n", ptr->allocated);
353todo_wine {
354 ok(ptr->unk[0] != 0, "got %lx\n", ptr->unk[0]);
355 ok(ptr->unk[1] != 0, "got %lx\n", ptr->unk[1]);
356}
357 ok(ptr->max_extra_size == 0, "got %d\n", ptr->max_extra_size);
358 ok(ptr->lcid == GetThreadLocale(), "got %x, thread lcid %x\n", ptr->lcid, GetThreadLocale());
359
360 pStringTableDestroy(table);
361}
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
unsigned long DWORD
Definition: ntddk_ex.h:95
LCID WINAPI GetThreadLocale(void)
Definition: lang.c:1459
static PVOID ptr
Definition: dispmode.c:27
#define todo_wine
Definition: custom.c:79

Referenced by START_TEST().

◆ test_StringTableAddString()

static void test_StringTableAddString ( void  )
static

Definition at line 77 of file stringtable.c.

78{
79 DWORD retval, hstring, hString, hfoo;
81
82 table = pStringTableInitialize();
83 ok(table != NULL, "failed to initialize string table\n");
84
85 /* case insensitive */
86 hstring=pStringTableAddString(table,string,0);
87 ok(hstring!=-1,"Failed to add string to String Table\n");
88
89 retval=pStringTableAddString(table,String,0);
90 ok(retval!=-1,"Failed to add String to String Table\n");
91 ok(hstring==retval,"string handle %x != String handle %x in String Table\n", hstring, retval);
92
93 hfoo=pStringTableAddString(table,foo,0);
94 ok(hfoo!=-1,"Failed to add foo to String Table\n");
95 ok(hfoo!=hstring,"foo and string share the same ID %x in String Table\n", hfoo);
96
97 /* case sensitive */
98 hString=pStringTableAddString(table,String,ST_CASE_SENSITIVE_COMPARE);
99 ok(hstring!=hString,"String handle and string share same ID %x in Table\n", hstring);
100
101 pStringTableDestroy(table);
102}
#define ST_CASE_SENSITIVE_COMPARE
Definition: stringtable.c:41
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433

Referenced by START_TEST().

◆ test_StringTableAddStringEx()

static void test_StringTableAddStringEx ( void  )
static

Definition at line 104 of file stringtable.c.

105{
106 DWORD retval, hstring, hString, hfoo, extra;
108 BOOL ret;
109
110 table = pStringTableInitialize();
111 ok(table != NULL,"Failed to Initialize String Table\n");
112
113 /* case insensitive */
114 hstring = pStringTableAddStringEx(table, string, 0, NULL, 0);
115 ok(hstring != -1, "Failed to add string to String Table\n");
116
117 retval = pStringTableAddStringEx(table, String, 0, NULL, 0);
118 ok(retval != -1, "Failed to add String to String Table\n");
119 ok(hstring == retval, "string handle %x != String handle %x in String Table\n", hstring, retval);
120
121 hfoo = pStringTableAddStringEx(table, foo, 0, NULL, 0);
122 ok(hfoo != -1, "Failed to add foo to String Table\n");
123 ok(hfoo != hstring, "foo and string share the same ID %x in String Table\n", hfoo);
124
125 /* case sensitive */
126 hString = pStringTableAddStringEx(table, String, ST_CASE_SENSITIVE_COMPARE, NULL, 0);
127 ok(hstring != hString, "String handle and string share same ID %x in Table\n", hstring);
128
129 pStringTableDestroy(table);
130
131 /* set same string twice but with different extra */
132 table = pStringTableInitializeEx(4, 0);
133 ok(table != NULL, "Failed to Initialize String Table\n");
134
135 extra = 10;
136 hstring = pStringTableAddStringEx(table, string, 0, &extra, 4);
137 ok(hstring != -1, "failed to add string, %d\n", hstring);
138
139 extra = 0;
140 ret = pStringTableGetExtraData(table, hstring, &extra, 4);
141 ok(ret && extra == 10, "got %d, extra %d\n", ret, extra);
142
143 extra = 11;
144 hstring = pStringTableAddStringEx(table, string, 0, &extra, 4);
145 ok(hstring != -1, "failed to add string, %d\n", hstring);
146
147 extra = 0;
148 ret = pStringTableGetExtraData(table, hstring, &extra, 4);
149 ok(ret && extra == 10, "got %d, extra %d\n", ret, extra);
150
151 pStringTableDestroy(table);
152}
unsigned int BOOL
Definition: ntddk_ex.h:94
@ extra
Definition: id3.c:95
int ret

Referenced by START_TEST().

◆ test_StringTableDuplicate()

static void test_StringTableDuplicate ( void  )
static

Definition at line 154 of file stringtable.c.

155{
156 HSTRING_TABLE table, table2;
157
158 table = pStringTableInitialize();
159 ok(table != NULL,"Failed to Initialize String Table\n");
160
161 table2=pStringTableDuplicate(table);
162 ok(table2!=NULL,"Failed to duplicate String Table\n");
163
164 pStringTableDestroy(table);
165 pStringTableDestroy(table2);
166}

Referenced by START_TEST().

◆ test_StringTableLookUpString()

static void test_StringTableLookUpString ( void  )
static

Definition at line 168 of file stringtable.c.

169{
170 DWORD retval, retval2, hstring, hString, hfoo;
171 HSTRING_TABLE table, table2;
172
173 table = pStringTableInitialize();
174 ok(table != NULL,"failed to initialize string table\n");
175
176 hstring = pStringTableAddString(table, string, 0);
177 ok(hstring != ~0u, "failed to add 'string' to string table\n");
178
179 hString = pStringTableAddString(table, String, 0);
180 ok(hString != ~0u,"failed to add 'String' to string table\n");
181
182 hfoo = pStringTableAddString(table, foo, 0);
183 ok(hfoo != ~0u, "failed to add 'foo' to string table\n");
184
185 table2 = pStringTableDuplicate(table);
186 ok(table2 != NULL, "Failed to duplicate String Table\n");
187
188 /* case insensitive */
189 retval=pStringTableLookUpString(table,string,0);
190 ok(retval!=-1,"Failed find string in String Table 1\n");
191 ok(retval==hstring,
192 "Lookup for string (%x) does not match previous handle (%x) in String Table 1\n",
193 retval, hstring);
194
195 retval=pStringTableLookUpString(table2,string,0);
196 ok(retval!=-1,"Failed find string in String Table 2\n");
197
198 retval=pStringTableLookUpString(table,String,0);
199 ok(retval!=-1,"Failed find String in String Table 1\n");
200
201 retval=pStringTableLookUpString(table2,String,0);
202 ok(retval!=-1,"Failed find String in String Table 2\n");
203
204 retval=pStringTableLookUpString(table,foo,0);
205 ok(retval!=-1,"Failed find foo in String Table 1\n");
206 ok(retval==hfoo,
207 "Lookup for foo (%x) does not match previous handle (%x) in String Table 1\n",
208 retval, hfoo);
209
210 retval=pStringTableLookUpString(table2,foo,0);
211 ok(retval!=-1,"Failed find foo in String Table 2\n");
212
213 /* case sensitive */
214 retval=pStringTableLookUpString(table,string,ST_CASE_SENSITIVE_COMPARE);
215 retval2=pStringTableLookUpString(table,String,ST_CASE_SENSITIVE_COMPARE);
216 ok(retval!=retval2,"Lookup of string equals String in Table 1\n");
217 ok(retval==hString,
218 "Lookup for String (%x) does not match previous handle (%x) in String Table 1\n",
219 retval, hString);
220
221 pStringTableDestroy(table);
222 pStringTableDestroy(table2);
223}
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 * u
Definition: glfuncs.h:240

Referenced by START_TEST().

◆ test_StringTableLookUpStringEx()

static void test_StringTableLookUpStringEx ( void  )
static

Definition at line 225 of file stringtable.c.

226{
227 static WCHAR uilevel[] = {'U','I','L','E','V','E','L',0};
228 DWORD retval, retval2, hstring, hString, hfoo, data;
229 HSTRING_TABLE table, table2;
230 char buffer[4];
231
232 table = pStringTableInitialize();
233 ok(table != NULL,"Failed to Initialize String Table\n");
234
235 hstring = pStringTableAddString(table, string, 0);
236 ok(hstring != ~0u, "failed to add 'string' to string table\n");
237
238 hString = pStringTableAddString(table, String, 0);
239 ok(hString != ~0u,"failed to add 'String' to string table\n");
240
241 hfoo = pStringTableAddString(table, foo, 0);
242 ok(hfoo != ~0u, "failed to add 'foo' to string table\n");
243
244 table2 = pStringTableDuplicate(table);
245 ok(table2 != NULL, "Failed to duplicate String Table\n");
246
247 /* case insensitive */
248 retval = pStringTableLookUpStringEx(table, string, 0, NULL, 0);
249 ok(retval != ~0u, "Failed find string in String Table 1\n");
250 ok(retval == hstring,
251 "Lookup for string (%x) does not match previous handle (%x) in String Table 1\n",
252 retval, hstring);
253
254 retval = pStringTableLookUpStringEx(table2, string, 0, NULL, 0);
255 ok(retval != ~0u, "Failed find string in String Table 2\n");
256
257 retval = pStringTableLookUpStringEx(table, String, 0, NULL, 0);
258 ok(retval != ~0u, "Failed find String in String Table 1\n");
259
260 retval = pStringTableLookUpStringEx(table2, String, 0, NULL, 0);
261 ok(retval != ~0u, "Failed find String in String Table 2\n");
262
263 retval=pStringTableLookUpStringEx(table, foo, 0, NULL, 0);
264 ok(retval != ~0u, "Failed find foo in String Table 1\n");
265 ok(retval == hfoo,
266 "Lookup for foo (%x) does not match previous handle (%x) in String Table 1\n",
267 retval, hfoo);
268
269 retval = pStringTableLookUpStringEx(table2, foo, 0, NULL, 0);
270 ok(retval != ~0u, "Failed find foo in String Table 2\n");
271
272 /* case sensitive */
273 retval = pStringTableLookUpStringEx(table, string,ST_CASE_SENSITIVE_COMPARE, NULL, 0);
274 retval2 = pStringTableLookUpStringEx(table, String, ST_CASE_SENSITIVE_COMPARE, NULL, 0);
275 ok(retval != retval2, "Lookup of string equals String in Table 1\n");
276 ok(retval == hString,
277 "Lookup for String (%x) does not match previous handle (%x) in String Table 1\n",
278 retval, hString);
279
280 pStringTableDestroy(table);
281
282 table = pStringTableInitializeEx(0x1000, 0);
283 ok(table != NULL, "failed to initialize string table\n");
284
285 data = 0xaaaaaaaa;
286 retval = pStringTableAddStringEx(table, uilevel, 0x5, &data, sizeof(data));
287 ok(retval != ~0u, "failed to add 'UILEVEL' to string table\n");
288
289 memset(buffer, 0x55, sizeof(buffer));
290 retval = pStringTableLookUpStringEx(table, uilevel, ST_CASE_SENSITIVE_COMPARE, buffer, 0);
291 ok(retval != ~0u, "failed find 'UILEVEL' in string table\n");
292 ok(memcmp(buffer, &data, 4), "unexpected data\n");
293
294 memset(buffer, 0x55, sizeof(buffer));
295 retval = pStringTableLookUpStringEx(table, uilevel, ST_CASE_SENSITIVE_COMPARE, buffer, 2);
296 ok(retval != ~0u, "failed find 'UILEVEL' in string table\n");
297 ok(!memcmp(buffer, &data, 2), "unexpected data\n");
298
299 memset(buffer, 0x55, sizeof(buffer));
300 retval = pStringTableLookUpStringEx(table, uilevel, ST_CASE_SENSITIVE_COMPARE, buffer, sizeof(buffer));
301 ok(retval != ~0u, "failed find 'UILEVEL' in string table\n");
302 ok(!memcmp(buffer, &data, 4), "unexpected data\n");
303
304 pStringTableDestroy(table);
305 pStringTableDestroy(table2);
306}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint buffer
Definition: glext.h:5915
#define memset(x, y, z)
Definition: compat.h:39
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ test_StringTableStringFromId()

static void test_StringTableStringFromId ( void  )
static

Definition at line 308 of file stringtable.c.

309{
311 WCHAR *string2;
312 DWORD id, id2;
313
314 table = pStringTableInitialize();
315 ok(table != NULL, "Failed to Initialize String Table\n");
316
317 id = pStringTableAddString(table, string, 0);
318 ok(id != -1, "failed to add 'string' to string table\n");
319
320 /* correct */
321 id2 = pStringTableLookUpString(table, string, 0);
322 ok(id2 == id, "got %d and %d\n", id2, id);
323
324 string2 = pStringTableStringFromId(table, id2);
325 ok(string2 != NULL, "failed to lookup string %d\n", id2);
326 ok(!lstrcmpiW(string, string2), "got %s, expected %s\n", wine_dbgstr_w(string2), wine_dbgstr_w(string));
327
328 pStringTableDestroy(table);
329}
GLuint id
Definition: glext.h:5910
#define wine_dbgstr_w
Definition: kernel32.h:34
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
static CHAR string2[MAX_PATH]
Definition: automation.c:449

Referenced by START_TEST().

◆ VOID()

static VOID ( WINAPI pStringTableDestroy)
static

Variable Documentation

◆ DWORD

Definition at line 43 of file stringtable.c.

◆ foo

WCHAR foo[] = {'f','o','o',0}
static

Definition at line 56 of file stringtable.c.

◆ LPVOID

Definition at line 44 of file stringtable.c.

◆ LPWSTR

Definition at line 43 of file stringtable.c.

◆ string

WCHAR string[] = {'s','t','r','i','n','g',0}
static

Definition at line 54 of file stringtable.c.

◆ String

WCHAR String[] = {'S','t','r','i','n','g',0}
static

Definition at line 55 of file stringtable.c.

◆ ULONG

Definition at line 52 of file stringtable.c.