ReactOS 0.4.15-dev-7842-g558ab78
util.c File Reference
#include <stdio.h>
#include <wine/test.h>
#include <windef.h>
#include <snmp.h>
Include dependency graph for util.c:

Go to the source code of this file.

Macros

#define SNMPAPI_GET_PROC(func)
 

Functions

static INT (WINAPI *pSnmpUtilAsnAnyCpy)(AsnAny *
 
static AsnAny *static VOID (WINAPI *pSnmpUtilAsnAnyFree)(AsnAny *)
 
static void InitFunctionPtrs (void)
 
static void test_SnmpUtilOidToA (void)
 
static void test_SnmpUtilAsnAnyCpyFree (void)
 
static void test_SnmpUtilOctetsCpyFree (void)
 
static void test_SnmpUtilOidCpyFree (void)
 
static void test_SnmpUtilOctetsNCmp (void)
 
static void test_SnmpUtilOctetsCmp (void)
 
static void test_SnmpUtilOidNCmp (void)
 
static void test_SnmpUtilOidCmp (void)
 
static void test_SnmpUtilOidAppend (void)
 
static void test_SnmpUtilVarBindCpyFree (void)
 
static void test_SnmpUtilVarBindListCpyFree (void)
 
 START_TEST (util)
 

Variables

static AsnOctetString UINT
 

Macro Definition Documentation

◆ SNMPAPI_GET_PROC

#define SNMPAPI_GET_PROC (   func)
Value:
p ## func = (void*)GetProcAddress(hSnmpapi, #func); \
if(!p ## func) \
trace("GetProcAddress(%s) failed\n", #func);
#define GetProcAddress(x, y)
Definition: compat.h:753
GLenum func
Definition: glext.h:6028
GLfloat GLfloat p
Definition: glext.h:8902

Function Documentation

◆ InitFunctionPtrs()

static void InitFunctionPtrs ( void  )
static

Definition at line 33 of file util.c.

34{
35 HMODULE hSnmpapi = GetModuleHandleA("snmpapi.dll");
36
37#define SNMPAPI_GET_PROC(func) \
38 p ## func = (void*)GetProcAddress(hSnmpapi, #func); \
39 if(!p ## func) \
40 trace("GetProcAddress(%s) failed\n", #func);
41
48
49#undef SNMPAPI_GET_PROC
50}
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
VOID WINAPI SnmpUtilOctetsFree(AsnOctetString *octets)
Definition: main.c:242
INT WINAPI SnmpUtilOctetsCpy(AsnOctetString *dst, AsnOctetString *src)
Definition: main.c:215
INT WINAPI SnmpUtilOctetsCmp(AsnOctetString *octets1, AsnOctetString *octets2)
Definition: main.c:276
INT WINAPI SnmpUtilOctetsNCmp(AsnOctetString *octets1, AsnOctetString *octets2, UINT count)
Definition: main.c:258
VOID WINAPI SnmpUtilAsnAnyFree(AsnAny *any)
Definition: main.c:206
INT WINAPI SnmpUtilAsnAnyCpy(AsnAny *dst, AsnAny *src)
Definition: main.c:197
#define SNMPAPI_GET_PROC(func)

Referenced by START_TEST().

◆ INT()

static INT ( WINAPI pSnmpUtilAsnAnyCpy)
static

◆ START_TEST()

START_TEST ( util  )

Definition at line 546 of file util.c.

547{
549
551
552 if (!pSnmpUtilAsnAnyCpy || !pSnmpUtilAsnAnyFree)
553 win_skip("SnmpUtilAsnAnyCpy and/or SnmpUtilAsnAnyFree not available\n");
554 else
556
557 if (!pSnmpUtilOctetsCpy || !pSnmpUtilOctetsFree)
558 win_skip("SnmpUtilOctetsCpy and/or SnmpUtilOctetsFree not available\n");
559 else
561
563
564 if (!pSnmpUtilOctetsNCmp)
565 win_skip("SnmpUtilOctetsNCmp not available\n");
566 else
568
569 if (!pSnmpUtilOctetsCmp)
570 win_skip("SnmpUtilOctetsCmp not available\n");
571 else
573
579}
static void test_SnmpUtilVarBindCpyFree(void)
Definition: util.c:457
static void test_SnmpUtilOidCmp(void)
Definition: util.c:393
static void test_SnmpUtilOidNCmp(void)
Definition: util.c:336
static void test_SnmpUtilOctetsNCmp(void)
Definition: util.c:271
static void test_SnmpUtilOidAppend(void)
Definition: util.c:419
static void test_SnmpUtilOidToA(void)
Definition: util.c:52
static void test_SnmpUtilAsnAnyCpyFree(void)
Definition: util.c:149
static void test_SnmpUtilOctetsCmp(void)
Definition: util.c:310
static void test_SnmpUtilOctetsCpyFree(void)
Definition: util.c:177
static void test_SnmpUtilVarBindListCpyFree(void)
Definition: util.c:502
static void InitFunctionPtrs(void)
Definition: util.c:33
static void test_SnmpUtilOidCpyFree(void)
Definition: util.c:210
#define win_skip
Definition: test.h:160

◆ test_SnmpUtilAsnAnyCpyFree()

static void test_SnmpUtilAsnAnyCpyFree ( void  )
static

Definition at line 149 of file util.c.

150{
151 INT ret;
152 static AsnAny dst, src = { ASN_INTEGER, { 1 } };
153
154 if (0) { /* these crash on XP */
155 ret = pSnmpUtilAsnAnyCpy(NULL, NULL);
156 ok(!ret, "SnmpUtilAsnAnyCpy succeeded\n");
157
158 ret = pSnmpUtilAsnAnyCpy(&dst, NULL);
159 ok(!ret, "SnmpUtilAsnAnyCpy succeeded\n");
160
161 ret = pSnmpUtilAsnAnyCpy(NULL, &src);
162 ok(!ret, "SnmpUtilAsnAnyCpy succeeded\n");
163 }
164
165 ret = pSnmpUtilAsnAnyCpy(&dst, &src);
166 ok(ret, "SnmpUtilAsnAnyCpy failed\n");
167 ok(!memcmp(&src, &dst, sizeof(AsnAny)), "SnmpUtilAsnAnyCpy failed\n");
168
169 if (0) { /* crashes on XP */
170 pSnmpUtilAsnAnyFree(NULL);
171 }
172 pSnmpUtilAsnAnyFree(&dst);
173 ok(dst.asnType == ASN_NULL, "SnmpUtilAsnAnyFree failed\n");
174 ok(dst.asnValue.number == 1, "SnmpUtilAsnAnyFree failed\n");
175}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
#define ASN_NULL
Definition: snmp.h:106
#define ASN_INTEGER
Definition: snmp.h:103
Definition: snmp.h:54
int32_t INT
Definition: typedefs.h:58
int ret

Referenced by START_TEST().

◆ test_SnmpUtilOctetsCmp()

static void test_SnmpUtilOctetsCmp ( void  )
static

Definition at line 310 of file util.c.

311{
312 INT ret;
313 static BYTE stream1[] = { '1', '2', '3' };
314 static BYTE stream2[] = { '1', '2', '3', '4' };
315 static AsnOctetString octets1 = { stream1, 3, FALSE };
316 static AsnOctetString octets2 = { stream2, 4, FALSE };
317
318 if (0) { /* these crash on XP */
319 ret = pSnmpUtilOctetsCmp(NULL, NULL);
320 ok(!ret, "SnmpUtilOctetsCmp succeeded\n");
321
322 ret = pSnmpUtilOctetsCmp(&octets1, NULL);
323 ok(!ret, "SnmpUtilOctetsCmp succeeded\n");
324
325 ret = pSnmpUtilOctetsCmp(NULL, &octets2);
326 ok(!ret, "SnmpUtilOctetsCmp succeeded\n");
327 }
328
329 ret = pSnmpUtilOctetsCmp(&octets2, &octets1);
330 ok(ret == 1, "SnmpUtilOctetsCmp failed\n");
331
332 ret = pSnmpUtilOctetsCmp(&octets1, &octets2);
333 ok(ret < 0, "SnmpUtilOctetsCmp failed\n");
334}
#define FALSE
Definition: types.h:117
unsigned char BYTE
Definition: xxhash.c:193

Referenced by START_TEST().

◆ test_SnmpUtilOctetsCpyFree()

static void test_SnmpUtilOctetsCpyFree ( void  )
static

Definition at line 177 of file util.c.

178{
179 INT ret;
180 static BYTE stream[] = { '1', '2', '3', '4' };
181 static AsnOctetString dst, src = { stream, 4, TRUE };
182
183 ret = pSnmpUtilOctetsCpy(NULL, NULL);
184 ok(!ret, "SnmpUtilOctetsCpy succeeded\n");
185
186 memset(&dst, 1, sizeof(AsnOctetString));
187 ret = pSnmpUtilOctetsCpy(&dst, NULL);
188 ok(ret, "SnmpUtilOctetsCpy failed\n");
189 ok(dst.length == 0, "SnmpUtilOctetsCpy failed\n");
190 ok(dst.stream == NULL, "SnmpUtilOctetsCpy failed\n");
191 ok(dst.dynamic == FALSE, "SnmpUtilOctetsCpy failed\n");
192
193 ret = pSnmpUtilOctetsCpy(NULL, &src);
194 ok(!ret, "SnmpUtilOctetsCpy succeeded\n");
195
196 memset(&dst, 0, sizeof(AsnOctetString));
197 ret = pSnmpUtilOctetsCpy(&dst, &src);
198 ok(ret, "SnmpUtilOctetsCpy failed\n");
199 ok(src.length == dst.length, "SnmpUtilOctetsCpy failed\n");
200 ok(!memcmp(src.stream, dst.stream, dst.length), "SnmpUtilOctetsCpy failed\n");
201 ok(dst.dynamic == TRUE, "SnmpUtilOctetsCpy failed\n");
202
203 pSnmpUtilOctetsFree(NULL);
204 pSnmpUtilOctetsFree(&dst);
205 ok(dst.stream == NULL, "SnmpUtilOctetsFree failed\n");
206 ok(dst.length == 0, "SnmpUtilOctetsFree failed\n");
207 ok(dst.dynamic == FALSE, "SnmpUtilOctetsFree failed\n");
208}
#define TRUE
Definition: types.h:120
#define memset(x, y, z)
Definition: compat.h:39
Definition: parse.h:23

Referenced by START_TEST().

◆ test_SnmpUtilOctetsNCmp()

static void test_SnmpUtilOctetsNCmp ( void  )
static

Definition at line 271 of file util.c.

272{
273 INT ret;
274 static BYTE stream1[] = { '1', '2', '3', '4' };
275 static BYTE stream2[] = { '5', '6', '7', '8' };
276 static AsnOctetString octets1 = { stream1, 4, FALSE };
277 static AsnOctetString octets2 = { stream2, 4, FALSE };
278
279 ret = pSnmpUtilOctetsNCmp(NULL, NULL, 0);
280 ok(!ret, "SnmpUtilOctetsNCmp succeeded\n");
281
282 ret = pSnmpUtilOctetsNCmp(NULL, NULL, 1);
283 ok(!ret, "SnmpUtilOctetsNCmp succeeded\n");
284
285 ret = pSnmpUtilOctetsNCmp(&octets1, NULL, 0);
286 ok(!ret, "SnmpUtilOctetsNCmp succeeded\n");
287
288 ret = pSnmpUtilOctetsNCmp(&octets1, NULL, 1);
289 ok(!ret, "SnmpUtilOctetsNCmp succeeded\n");
290
291 ret = pSnmpUtilOctetsNCmp(NULL, &octets2, 0);
292 ok(!ret, "SnmpUtilOctetsNCmp succeeded\n");
293
294 ret = pSnmpUtilOctetsNCmp(NULL, &octets2, 1);
295 ok(!ret, "SnmpUtilOctetsNCmp succeeded\n");
296
297 ret = pSnmpUtilOctetsNCmp(&octets1, &octets1, 0);
298 ok(!ret, "SnmpUtilOctetsNCmp failed\n");
299
300 ret = pSnmpUtilOctetsNCmp(&octets1, &octets1, 4);
301 ok(!ret, "SnmpUtilOctetsNCmp failed\n");
302
303 ret = pSnmpUtilOctetsNCmp(&octets1, &octets2, 4);
304 ok(ret == -4, "SnmpUtilOctetsNCmp failed\n");
305
306 ret = pSnmpUtilOctetsNCmp(&octets2, &octets1, 4);
307 ok(ret == 4, "SnmpUtilOctetsNCmp failed\n");
308}

Referenced by START_TEST().

◆ test_SnmpUtilOidAppend()

static void test_SnmpUtilOidAppend ( void  )
static

Definition at line 419 of file util.c.

420{
421 INT ret;
422 UINT *ids1;
423 static UINT ids2[] = { 4, 5, 6 };
425 static AsnObjectIdentifier oid2 = { 3, ids2 };
426
427 ids1 = SnmpUtilMemAlloc(3 * sizeof(UINT));
428 ids1[0] = 1;
429 ids1[1] = 2;
430 ids1[2] = 3;
431
432 oid1.idLength = 3;
433 oid1.ids = ids1;
434
435 /* This crashes under win98 */
436 if(0)
437 {
439 ok(!ret, "SnmpUtilOidAppend succeeded\n");
440
442 ok(ret, "SnmpUtilOidAppend failed\n");
443
444 ret = SnmpUtilOidAppend(NULL, &oid2);
445 ok(!ret, "SnmpUtilOidAppend succeeded\n");
446 }
447
448 ret = SnmpUtilOidAppend(&oid1, &oid2);
449 ok(ret, "SnmpUtilOidAppend failed\n");
450 ok(oid1.idLength == 6, "SnmpUtilOidAppend failed\n");
451 ok(!memcmp(&oid1.ids[3], ids2, 3 * sizeof(UINT)),
452 "SnmpUtilOidAppend failed\n");
453
455}
INT WINAPI SnmpUtilOidAppend(AsnObjectIdentifier *dst, AsnObjectIdentifier *src)
Definition: main.c:289
LPVOID WINAPI SnmpUtilMemAlloc(UINT nbytes)
Definition: main.c:170
VOID WINAPI SnmpUtilOidFree(AsnObjectIdentifier *oid)
Definition: main.c:344
static char oid1[]
Definition: encode.c:7583
unsigned int UINT
Definition: ndis.h:50

Referenced by START_TEST().

◆ test_SnmpUtilOidCmp()

static void test_SnmpUtilOidCmp ( void  )
static

Definition at line 393 of file util.c.

394{
395 INT ret;
396 static UINT ids1[] = { 1, 2, 3 };
397 static UINT ids2[] = { 1, 2, 3, 4 };
398 static AsnObjectIdentifier oid1 = { 3, ids1 };
399 static AsnObjectIdentifier oid2 = { 4, ids2 };
400
401 if (0) { /* these crash on XP */
403 ok(!ret, "SnmpUtilOidCmp succeeded\n");
404
406 ok(!ret, "SnmpUtilOidCmp succeeded\n");
407
408 ret = SnmpUtilOidCmp(NULL, &oid2);
409 ok(!ret, "SnmpUtilOidCmp succeeded\n");
410 }
411
412 ret = SnmpUtilOidCmp(&oid2, &oid1);
413 ok(ret > 0, "SnmpUtilOidCmp failed\n");
414
415 ret = SnmpUtilOidCmp(&oid1, &oid2);
416 ok(ret < 0, "SnmpUtilOidCmp failed\n");
417}
INT WINAPI SnmpUtilOidCmp(AsnObjectIdentifier *oid1, AsnObjectIdentifier *oid2)
Definition: main.c:382

Referenced by START_TEST().

◆ test_SnmpUtilOidCpyFree()

static void test_SnmpUtilOidCpyFree ( void  )
static

Definition at line 210 of file util.c.

211{
212 INT ret;
213 static UINT ids[] = { 1, 3, 6, 1, 4, 1, 311 };
215
216 /* These crashes under win98 */
217 if(0)
218 {
220 ok(!ret, "SnmpUtilOidCpy succeeded\n");
221
222 memset(&dst, 1, sizeof(AsnObjectIdentifier));
224 ok(ret, "SnmpUtilOidCpy failed\n");
225 ok(dst.idLength == 0, "SnmpUtilOidCpy failed\n");
226 ok(dst.ids == NULL, "SnmpUtilOidCpy failed\n");
227
229 ok(!ret, "SnmpUtilOidCpy succeeded\n");
230 }
231
232 memset(&dst, 0, sizeof(AsnObjectIdentifier));
234 ok(ret, "SnmpUtilOidCpy failed\n");
235 ok(src.idLength == dst.idLength, "SnmpUtilOidCpy failed\n");
236 ok(!memcmp(src.ids, dst.ids, dst.idLength * sizeof(UINT)), "SnmpUtilOidCpy failed\n");
238
239 /* These crashes under win98 */
240 if(0)
241 {
243 ok(!ret, "SnmpUtilOidCpy succeeded\n");
244
245 memset(&dst, 1, sizeof(AsnObjectIdentifier));
247 ok(ret, "SnmpUtilOidCpy failed\n");
248 ok(dst.idLength == 0, "SnmpUtilOidCpy failed\n");
249 ok(dst.ids == NULL, "SnmpUtilOidCpy failed\n");
250
252 ok(!ret, "SnmpUtilOidCpy succeeded\n");
253 }
254
255 memset(&dst, 0, sizeof(AsnObjectIdentifier));
257 ok(ret, "SnmpUtilOidCpy failed\n");
258 ok(src.idLength == dst.idLength, "SnmpUtilOidCpy failed\n");
259 ok(!memcmp(src.ids, dst.ids, dst.idLength * sizeof(UINT)), "SnmpUtilOidCpy failed\n");
260
261 /* This crashes under win98 */
262 if(0)
263 {
265 }
267 ok(dst.idLength == 0, "SnmpUtilOidFree failed\n");
268 ok(dst.ids == NULL, "SnmpUtilOidFree failed\n");
269}
#define ARRAY_SIZE(A)
Definition: main.h:33
INT WINAPI SnmpUtilOidCpy(AsnObjectIdentifier *dst, AsnObjectIdentifier *src)
Definition: main.c:319
GLuint * ids
Definition: glext.h:5907

Referenced by START_TEST().

◆ test_SnmpUtilOidNCmp()

static void test_SnmpUtilOidNCmp ( void  )
static

Definition at line 336 of file util.c.

337{
338 INT ret;
339 static UINT ids1[] = { 1, 2, 3, 4 };
340 static UINT ids2[] = { 5, 6, 7, 8 };
341 static AsnObjectIdentifier oid1 = { 4, ids1 };
342 static AsnObjectIdentifier oid2 = { 4, ids2 };
343
344 /* This crashes under win98 */
345 if(0)
346 {
348 ok(!ret, "SnmpUtilOidNCmp succeeded\n");
349
351 ok(!ret, "SnmpUtilOidNCmp succeeded\n");
352
354 ok(!ret, "SnmpUtilOidNCmp succeeded\n");
355
357 ok(!ret, "SnmpUtilOidNCmp succeeded\n");
358
359 ret = SnmpUtilOidNCmp(NULL, &oid2, 0);
360 ok(!ret, "SnmpUtilOidNCmp succeeded\n");
361
362 ret = SnmpUtilOidNCmp(NULL, &oid2, 1);
363 ok(!ret, "SnmpUtilOidNCmp succeeded\n");
364 }
365
366 ret = SnmpUtilOidNCmp(&oid1, &oid1, 0);
367 ok(!ret, "SnmpUtilOidNCmp failed\n");
368
369 ret = SnmpUtilOidNCmp(&oid1, &oid1, 4);
370 ok(!ret, "SnmpUtilOidNCmp failed\n");
371
372 ret = SnmpUtilOidNCmp(&oid1, &oid2, 4);
373 ok(ret < 0, "SnmpUtilOidNCmp failed: %d\n", ret);
374
375 ret = SnmpUtilOidNCmp(&oid2, &oid1, 4);
376 ok(ret > 0, "SnmpUtilOidNCmp failed: %d\n", ret);
377
378 oid1.idLength = 3;
379 memcpy(oid1.ids, oid2.ids, sizeof(UINT) * 4);
380 ret = SnmpUtilOidNCmp(&oid1, &oid1, 4);
381 ok(!ret, "SnmpUtilOidNCmp failed: %d\n", ret);
382 ret = SnmpUtilOidNCmp(&oid2, &oid1, 4);
383 ok(ret > 0, "SnmpUtilOidNCmp failed: %d\n", ret);
384 ret = SnmpUtilOidNCmp(&oid1, &oid2, 4);
385 ok(ret < 0, "SnmpUtilOidNCmp failed: %d\n", ret);
386
387 ret = SnmpUtilOidNCmp(&oid1, &oid2, 2);
388 ok(!ret, "SnmpUtilOidNCmp failed: %d\n", ret);
389 ret = SnmpUtilOidNCmp(&oid2, &oid1, 2);
390 ok(!ret, "SnmpUtilOidNCmp failed: %d\n", ret);
391}
INT WINAPI SnmpUtilOidNCmp(AsnObjectIdentifier *oid1, AsnObjectIdentifier *oid2, UINT count)
Definition: main.c:358
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
UINT * ids
Definition: snmp.h:37

Referenced by START_TEST().

◆ test_SnmpUtilOidToA()

static void test_SnmpUtilOidToA ( void  )
static

Definition at line 52 of file util.c.

53{
54 LPSTR ret;
55 static UINT ids1[] = { 1,3,6,1,4,1,311 };
56 static UINT ids2[] = {
57 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
58 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
59 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
60 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
61 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
62 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
63 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
64 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
65 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 };
66 static UINT ids3[] = { 0xffffffff };
67 static AsnObjectIdentifier oid0 = { 0, ids1 };
68 static AsnObjectIdentifier oid1 = { 7, ids1 };
69 static AsnObjectIdentifier oid2 = { 256, ids2 };
70 static AsnObjectIdentifier oid3 = { 257, ids2 };
71 static AsnObjectIdentifier oid4 = { 258, ids2 };
72 static AsnObjectIdentifier oid5 = { 1, ids3 };
73 static const char expect0[] = "<null oid>";
74 static const char expect0_alt[] = "NUL";
75 static const char expect1[] = "1.3.6.1.4.1.311";
76 static const char expect2[] =
77 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
78 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
79 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
80 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
81 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
82 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
83 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
84 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1";
85 static const char expect3[] =
86 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
87 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
88 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
89 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
90 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
91 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
92 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
93 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1";
94 static const char expect3_alt[] =
95 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
96 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
97 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
98 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
99 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
100 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
101 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
102 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1";
103 static const char expect4[] = "-1";
104
105 /* This crashes under win98 */
106 if(0)
107 {
109 ok(ret != NULL, "SnmpUtilOidToA failed\n");
110 ok(!strcmp(ret, expect0), "SnmpUtilOidToA failed got\n%s\n expected\n%s\n",
111 ret, expect1);
112 }
113
114 ret = SnmpUtilOidToA(&oid0);
115 ok(ret != NULL, "SnmpUtilOidToA failed\n");
116 ok(!strcmp(ret, expect0) ||
117 broken(!strcmp(ret, expect0_alt)), /* Win98, WinMe, NT4 */
118 "SnmpUtilOidToA failed got\n%s\n expected\n%s\n",
119 ret, expect0);
120
122 ok(ret != NULL, "SnmpUtilOidToA failed\n");
123 ok(!strcmp(ret, expect1), "SnmpUtilOidToA failed got\n%s\n expected\n%s\n",
124 ret, expect1);
125
126 ret = SnmpUtilOidToA(&oid2);
127 ok(ret != NULL, "SnmpUtilOidToA failed\n");
128 ok(!strcmp(ret, expect2), "SnmpUtilOidToA failed got\n%s\n expected\n%s\n",
129 ret, expect2);
130
131 ret = SnmpUtilOidToA(&oid3);
132 ok(ret != NULL, "SnmpUtilOidToA failed\n");
133 ok(!strcmp(ret, expect3), "SnmpUtilOidToA failed got\n%s\n expected\n%s\n",
134 ret, expect3);
135
136 ret = SnmpUtilOidToA(&oid4);
137 ok(ret != NULL, "SnmpUtilOidToA failed\n");
138 ok(!strcmp(ret, expect3) ||
139 broken(!strcmp(ret, expect3_alt)), /* Win98, WinMe, NT4 */
140 "SnmpUtilOidToA failed got\n%s\n expected\n%s\n",
141 ret, expect3);
142
143 ret = SnmpUtilOidToA(&oid5);
144 ok(ret != NULL, "SnmpUtilOidToA failed\n");
145 ok(!strcmp(ret, expect4), "SnmpUtilOidToA failed got\n%s\n expected\n%s\n",
146 ret, expect4);
147}
#define broken(x)
Definition: _sntprintf.h:21
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
LPSTR WINAPI SnmpUtilOidToA(AsnObjectIdentifier *oid)
Definition: main.c:534
#define expect2(expected1, expected2, got1, got2)
Definition: listview.c:50
char * LPSTR
Definition: xmlstorage.h:182

Referenced by START_TEST().

◆ test_SnmpUtilVarBindCpyFree()

static void test_SnmpUtilVarBindCpyFree ( void  )
static

Definition at line 457 of file util.c.

458{
459 INT ret;
460 static UINT ids[] = { 1, 3, 6, 1, 4, 1, 311 };
461 static SnmpVarBind dst, src = { { 7, ids }, { ASN_INTEGER, { 1 } } };
462
463 /* This crashes under win98 */
464 if(0)
465 {
467 ok(!ret, "SnmpUtilVarBindCpy succeeded\n");
468
469 memset(&dst, 0, sizeof(SnmpVarBind));
471 ok(ret, "SnmpUtilVarBindCpy failed\n");
472 ok(dst.name.idLength == 0, "SnmpUtilVarBindCpy failed\n");
473 ok(dst.name.ids == NULL, "SnmpUtilVarBindCpy failed\n");
474 ok(dst.value.asnType == ASN_NULL, "SnmpUtilVarBindCpy failed\n");
475 ok(dst.value.asnValue.number == 0, "SnmpUtilVarBindCpy failed\n");
476
478 ok(!ret, "SnmpUtilVarBindCpy succeeded\n");
479 }
480
481 memset(&dst, 0, sizeof(SnmpVarBind));
483 ok(ret, "SnmpUtilVarBindCpy failed\n");
484 ok(src.name.idLength == dst.name.idLength, "SnmpUtilVarBindCpy failed\n");
485 ok(!memcmp(src.name.ids, dst.name.ids, dst.name.idLength * sizeof(UINT)),
486 "SnmpUtilVarBindCpy failed\n");
487 ok(!memcmp(&src.value, &dst.value, sizeof(AsnObjectSyntax)),
488 "SnmpUtilVarBindCpy failed\n");
489
490 /* This crashes under win98 */
491 if(0)
492 {
494 }
496 ok(dst.name.idLength == 0, "SnmpUtilVarBindFree failed\n");
497 ok(dst.name.ids == NULL, "SnmpUtilVarBindFree failed\n");
498 ok(dst.value.asnType == ASN_NULL, "SnmpUtilVarBindFree failed\n");
499 ok(dst.value.asnValue.number == 1, "SnmpUtilVarBindFree failed\n");
500}
INT WINAPI SnmpUtilVarBindCpy(SnmpVarBind *dst, SnmpVarBind *src)
Definition: main.c:395
VOID WINAPI SnmpUtilVarBindFree(SnmpVarBind *vb)
Definition: main.c:425

Referenced by START_TEST().

◆ test_SnmpUtilVarBindListCpyFree()

static void test_SnmpUtilVarBindListCpyFree ( void  )
static

Definition at line 502 of file util.c.

503{
504 INT ret;
505 static UINT ids[] = { 1, 3, 6, 1, 4, 1, 311 };
506 static SnmpVarBind src = { { 7, ids }, { ASN_INTEGER, { 1 } } };
507 static SnmpVarBindList dst_list, src_list = { &src, 1 };
508
509 if (0) { /* these crash on XP */
511 ok(!ret, "SnmpUtilVarBindCpy succeeded\n");
512
513 ret = SnmpUtilVarBindListCpy(NULL, &src_list);
514 ok(!ret, "SnmpUtilVarBindListCpy succeeded\n");
515 }
516
517 /* This crashes under win98 */
518 if(0)
519 {
520 memset(&dst_list, 0xff, sizeof(SnmpVarBindList));
521 ret = SnmpUtilVarBindListCpy(&dst_list, NULL);
522 ok(ret, "SnmpUtilVarBindListCpy failed\n");
523 ok(dst_list.list == NULL, "SnmpUtilVarBindListCpy failed\n");
524 ok(dst_list.len == 0, "SnmpUtilVarBindListCpy failed\n");
525 }
526
527 ret = SnmpUtilVarBindListCpy(&dst_list, &src_list);
528 ok(ret, "SnmpUtilVarBindListCpy failed\n");
529 ok(src_list.len == dst_list.len, "SnmpUtilVarBindListCpy failed\n");
530 ok(src_list.list->name.idLength == dst_list.list->name.idLength,
531 "SnmpUtilVarBindListCpy failed\n");
532 ok(!memcmp(src_list.list->name.ids, dst_list.list->name.ids,
533 dst_list.list->name.idLength * sizeof(UINT)),
534 "SnmpUtilVarBindListCpy failed\n");
535 ok(!memcmp(&src_list.list->value, &dst_list.list->value, sizeof(AsnAny)),
536 "SnmpUtilVarBindListCpy failed\n");
537
538 if (0) { /* crashes on XP */
540 }
541 SnmpUtilVarBindListFree(&dst_list);
542 ok(dst_list.list == NULL, "SnmpUtilVarBindListFree failed\n");
543 ok(dst_list.len == 0, "SnmpUtilVarBindListFree failed\n");
544}
INT WINAPI SnmpUtilVarBindListCpy(SnmpVarBindList *dst, SnmpVarBindList *src)
Definition: main.c:440
VOID WINAPI SnmpUtilVarBindListFree(SnmpVarBindList *vb)
Definition: main.c:480
SnmpVarBind * list
Definition: snmp.h:81
UINT len
Definition: snmp.h:82
AsnObjectName name
Definition: snmp.h:76
AsnObjectSyntax value
Definition: snmp.h:77

Referenced by START_TEST().

◆ VOID()

static AsnAny *static VOID ( WINAPI pSnmpUtilAsnAnyFree)
static

Variable Documentation

◆ UINT

Definition at line 31 of file util.c.