source: trunk/server/source3/torture/t_push_ucs2.c@ 690

Last change on this file since 690 was 414, checked in by Herwig Bauernfeind, 16 years ago

Samba 3.5.0: Initial import

File size: 1.1 KB
Line 
1/*
2 * Copyright (C) 2003 by Martin Pool
3 * Copyright (C) 2003 by Andrew Bartlett
4 *
5 * Test harness for push_ucs2
6 */
7
8#include "includes.h"
9
10static int check_push_ucs2(const char *orig)
11{
12 smb_ucs2_t *dest = NULL;
13 char *orig2 = NULL;
14 int ret;
15 size_t converted_size;
16
17 push_ucs2_talloc(NULL, &dest, orig, &converted_size);
18 pull_ucs2_talloc(NULL, &orig2, dest, &converted_size);
19 ret = strcmp(orig, orig2);
20 if (ret) {
21 fprintf(stderr, "orig: %s\n", orig);
22 fprintf(stderr, "orig (UNIX -> UCS2 -> UNIX): %s\n", orig2);
23 }
24
25 TALLOC_FREE(dest);
26 TALLOC_FREE(orig2);
27
28 return ret;
29}
30
31int main(int argc, char *argv[])
32{
33 int i, ret = 0;
34 int count = 1;
35
36 /* Needed to initialize character set */
37 lp_load("/dev/null", True, False, False, True);
38
39 if (argc < 2) {
40 fprintf(stderr, "usage: %s STRING1 [COUNT]\n"
41 "Checks that a string translated UNIX->UCS2->UNIX is unchanged\n"
42 "Should be always 0\n",
43 argv[0]);
44 return 2;
45 }
46 if (argc >= 3)
47 count = atoi(argv[2]);
48
49 for (i = 0; ((i < count) && (!ret)); i++)
50 ret = check_push_ucs2(argv[1]);
51
52 printf("%d\n", ret);
53
54 return 0;
55}
Note: See TracBrowser for help on using the repository browser.