1set prototyped 2hdr iconv 3lib iconv_open,iconv_close,iconv iconv.h -liconv 4nxt iconv 5 6tst output{ 7 #if !_lib_iconv_open 8 #define _undef_hdr_iconv 1 9 #undef _hdr_iconv 10 #endif 11 #if !_hdr_iconv 12 #define _undef_lib_iconv_open 1 13 #undef _lib_iconv_open 14 #endif 15 #if _hdr_iconv 16 #include <sys/types.h> 17 #include <iconv.h> 18 #endif 19 20 int 21 main() 22 { 23 char* lib; 24 25 printf("#include <ast_common.h>\n"); 26 printf("#include <ccode.h>\n"); 27 #if _undef_hdr_iconv 28 printf("#undef _hdr_iconv\n"); 29 #endif 30 #if _undef_lib_iconv_open 31 printf("#undef _lib_iconv_open\n"); 32 #endif 33 #if _hdr_iconv && defined(_nxt_iconv_str) 34 printf("#include <%s> /* the native iconv.h */\n", _nxt_iconv_str); 35 #endif 36 printf("\n"); 37 printf("#define ICONV_VERSION 20110111L\n"); 38 printf("\n"); 39 printf("#define ICONV_FATAL 0x02\n"); 40 printf("#define ICONV_OMIT 0x04\n"); 41 printf("\n"); 42 printf("#define CC_ICONV (-1)\n"); 43 printf("#define CC_UCS (-2)\n"); 44 printf("#define CC_SCU (-3)\n"); 45 printf("#define CC_UTF (-4)\n"); 46 printf("#define CC_UME (-5)\n"); 47 printf("\n"); 48 #if _lib_iconv_open 49 lib = "_ast_"; 50 printf("#ifndef _ICONV_LIST_PRIVATE_\n"); 51 printf("#undef iconv_t\n"); 52 printf("#define iconv_t %siconv_t\n", lib); 53 printf("#undef iconv_f\n"); 54 printf("#define iconv_f %siconv_f\n", lib); 55 printf("#undef iconv_list_t\n"); 56 printf("#define iconv_list_t %siconv_list_t\n", lib); 57 printf("#undef iconv_open\n"); 58 printf("#define iconv_open %siconv_open\n", lib); 59 printf("#undef iconv\n"); 60 printf("#define iconv %siconv\n", lib); 61 printf("#undef iconv_close\n"); 62 printf("#define iconv_close %siconv_close\n", lib); 63 printf("#undef iconv_list\n"); 64 printf("#define iconv_list %siconv_list\n", lib); 65 printf("#undef iconv_move\n"); 66 printf("#define iconv_move %siconv_move\n", lib); 67 printf("#undef iconv_name\n"); 68 printf("#define iconv_name %siconv_name\n", lib); 69 printf("#undef iconv_write\n"); 70 printf("#define iconv_write %siconv_write\n", lib); 71 printf("#endif\n"); 72 #else 73 lib = ""; 74 #endif 75 printf("\n"); 76 printf("typedef int (*Iconv_error_f)(void*, void*, int, ...);\n"); 77 printf("\n"); 78 printf("typedef struct Iconv_disc_s\n"); 79 printf("{\n"); 80 printf(" uint32_t version;\n"); 81 printf(" Iconv_error_f errorf;\n"); 82 printf(" size_t errors;\n"); 83 printf(" uint32_t flags;\n"); 84 printf(" int fill;\n"); 85 printf("} Iconv_disc_t;\n"); 86 printf("\n"); 87 printf("typedef Ccmap_t %siconv_list_t;\n", lib); 88 printf("typedef void* %siconv_t;\n", lib); 89 printf("typedef size_t (*%siconv_f)(%siconv_t, char**, size_t*, char**, size_t*);\n", lib, lib); 90 printf("\n"); 91 printf("#define iconv_init(d,e) (memset(d,0,sizeof(*(d))),(d)->version=ICONV_VERSION,(d)->errorf=(Iconv_error_f)(e),(d)->fill=(-1))\n"); 92 printf("\n"); 93 printf("#if _BLD_ast && defined(__EXPORT__)\n"); 94 printf("#define extern __EXPORT__\n"); 95 printf("#endif\n"); 96 printf("\n"); 97 printf("extern %siconv_t %siconv_open(const char*, const char*);\n", lib, lib); 98 printf("extern size_t %siconv(%siconv_t, char**, size_t*, char**, size_t*);\n", lib, lib); 99 printf("extern int %siconv_close(%siconv_t);\n", lib, lib); 100 printf("extern %siconv_list_t* %siconv_list(%siconv_list_t*);\n", lib, lib, lib); 101 printf("extern int %siconv_name(const char*, char*, size_t);\n", lib); 102 printf("#if _SFIO_H\n"); 103 printf("extern ssize_t %siconv_move(%siconv_t, Sfio_t*, Sfio_t*, size_t, Iconv_disc_t*);\n", lib, lib); 104 printf("extern ssize_t %siconv_write(%siconv_t, Sfio_t*, char**, size_t*, Iconv_disc_t*);\n", lib, lib); 105 printf("#else\n"); 106 printf("#if _SFSTDIO_H\n"); 107 printf("extern ssize_t %siconv_move(%siconv_t, FILE*, FILE*, size_t, Iconv_disc_t*);\n", lib, lib); 108 printf("extern ssize_t %siconv_write(%siconv_t, FILE*, char**, size_t*, Iconv_disc_t*);\n", lib, lib); 109 printf("#endif\n"); 110 printf("#endif\n"); 111 printf("\n"); 112 printf("#undef extern\n"); 113 printf("\n"); 114 return 0; 115 } 116}end 117