~vcs-imports/samba/main

« back to all changes in this revision

Viewing changes to source/torture/t_push_ucs2.c

  • Committer: jerry
  • Date: 2006-07-14 21:48:39 UTC
  • Revision ID: vcs-imports@canonical.com-20060714214839-586d8c489a8fcead
gutting trunk to move to svn:externals

Show diffs side-by-side

added added

removed removed

Lines of Context:
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) 
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
 
 
30
 
int 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
 
}