source: branches/samba-3.0/source/torture/t_push_ucs2.c@ 710

Last change on this file since 710 was 1, checked in by Paul Smedley, 19 years ago

Initial code import

File size: 1.0 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
16 push_ucs2_allocate(&dest, orig);
17 pull_ucs2_allocate(&orig2, dest);
18 ret = strcmp(orig, orig2);
19 if (ret) {
20 fprintf(stderr, "orig: %s\n", orig);
21 fprintf(stderr, "orig (UNIX -> UCS2 -> UNIX): %s\n", orig2);
22 }
23
24 SAFE_FREE(dest);
25 SAFE_FREE(orig2);
26
27 return ret;
28}
29
30int main(int argc, char *argv[])
31{
32 int i, ret = 0;
33 int count = 1;
34
35 /* Needed to initialize character set */
36 lp_load("/dev/null", True, False, False, True);
37
38 if (argc < 2) {
39 fprintf(stderr, "usage: %s STRING1 [COUNT]\n"
40 "Checks that a string translated UNIX->UCS2->UNIX is unchanged\n"
41 "Should be always 0\n",
42 argv[0]);
43 return 2;
44 }
45 if (argc >= 3)
46 count = atoi(argv[2]);
47
48 for (i = 0; ((i < count) && (!ret)); i++)
49 ret = check_push_ucs2(argv[1]);
50
51 printf("%d\n", ret);
52
53 return 0;
54}
Note: See TracBrowser for help on using the repository browser.