1 
2 #include <iconv.h>
3 #include <errno.h>
4 #include <stddef.h>
5 #include <stdio.h>
6 
7 #define BUFSIZE 10000
8 
9 static int
do_test(void)10 do_test (void)
11 {
12   char inbuf[BUFSIZE];
13   wchar_t outbuf[BUFSIZE];
14 
15   iconv_t cd;
16   int i;
17   char *inptr;
18   char *outptr;
19   size_t inbytes_left, outbytes_left;
20   int count;
21   int result = 0;
22 
23   for (i=0; i < BUFSIZE; i++)
24     inbuf[i] = 'a';
25 
26   cd = iconv_open ("UCS-4LE", "UTF-8");
27 
28   inbytes_left = BUFSIZE;
29   outbytes_left = BUFSIZE * 4;
30   inptr = inbuf;
31   outptr = (char *) outbuf;
32 
33   count = iconv (cd, &inptr, &inbytes_left, &outptr, &outbytes_left);
34 
35   if (count < 0)
36     {
37       if (errno == E2BIG)
38 	printf ("Received E2BIG\n");
39       else
40 	printf ("Received something else\n");
41 
42       printf ("inptr change: %td\n", inptr - inbuf);
43       printf ("inlen change: %zd\n", BUFSIZE - inbytes_left);
44       printf ("outptr change: %td\n", outptr - (char *) outbuf);
45       printf ("outlen change: %zd\n", BUFSIZE * 4 - outbytes_left);
46       result = 1;
47     }
48   else
49     printf ("Succeeded\n");
50 
51   iconv_close (cd);
52 
53   return result;
54 }
55 
56 #define TEST_FUNCTION do_test ()
57 #include "../test-skeleton.c"
58