/* [<][>][^][v][top][bottom][index][help] */
DEFINITIONS
This source file includes following definitions.
- check_push_ucs2
- main
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
10 static int check_push_ucs2(const char *orig)
/* [<][>][^][v][top][bottom][index][help] */
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
31 int main(int argc, char *argv[])
/* [<][>][^][v][top][bottom][index][help] */
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 }