removed old libs
[TestXSLT.git] / libiconv / lib / genflags.c
1 /* Copyright (C) 2000-2002 Free Software Foundation, Inc.
2    This file is part of the GNU LIBICONV Library.
3
4    The GNU LIBICONV Library is free software; you can redistribute it
5    and/or modify it under the terms of the GNU Library General Public
6    License as published by the Free Software Foundation; either version 2
7    of the License, or (at your option) any later version.
8
9    The GNU LIBICONV Library is distributed in the hope that it will be
10    useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Library General Public License for more details.
13
14    You should have received a copy of the GNU Library General Public
15    License along with the GNU LIBICONV Library; see the file COPYING.LIB.
16    If not, write to the Free Software Foundation, Inc., 59 Temple Place -
17    Suite 330, Boston, MA 02111-1307, USA.  */
18
19 /* Creates the flags.h include file. */
20
21 #include <stdio.h>
22 #include <stdlib.h>
23
24 /* Consider all encodings, including the system dependent ones. */
25 #define USE_AIX
26 #define USE_OSF1
27 #define USE_DOS
28 #define USE_EXTRA
29
30 struct loop_funcs {};
31 #include "converters.h"
32
33 static void emit_encoding (struct wctomb_funcs * ofuncs, const char* c_name)
34 {
35   /* Prepare a converter struct. */
36   struct conv_struct conv;
37   memset(&conv,'\0',sizeof(conv));
38   conv.ofuncs = *ofuncs;
39
40   {
41     /* See whether the encoding can encode the accents and quotation marks. */
42     ucs4_t probe[6] = { 0x0060, 0x00b4, 0x2018, 0x2019, 0x3131, 0x3163, };
43     int res[6];
44     int i;
45     for (i = 0; i < 6; i++) {
46       unsigned char buf[10];
47       memset(&conv.ostate,'\0',sizeof(state_t));
48       res[i] = (conv.ofuncs.xxx_wctomb(&conv,buf,probe[i],sizeof(buf)) != RET_ILUNI);
49     }
50     printf("#define ei_%s_oflags (",c_name);
51     {
52       int first = 1;
53       if (res[0] && res[1]) {
54         printf("HAVE_ACCENTS");
55         first = 0;
56       }
57       if (res[2] && res[3]) {
58         if (!first) printf(" | ");
59         printf("HAVE_QUOTATION_MARKS");
60         first = 0;
61       }
62       if (res[4] && res[5]) {
63         if (!first) printf(" | ");
64         printf("HAVE_HANGUL_JAMO");
65         first = 0;
66       }
67       if (first) printf("0");
68     }
69     printf(")\n");
70   }
71 }
72
73 int main ()
74 {
75   int bitmask = 1;
76   printf("/* Generated automatically by genflags. */\n");
77   printf("\n");
78   printf("/* Set if the encoding can encode\n");
79   printf("   the acute and grave accents U+00B4 and U+0060. */\n");
80   printf("#define HAVE_ACCENTS %d\n",bitmask);
81   printf("\n");
82   bitmask = bitmask << 1;
83   printf("/* Set if the encoding can encode\n");
84   printf("   the single quotation marks U+2018 and U+2019. */\n");
85   printf("#define HAVE_QUOTATION_MARKS %d\n",bitmask);
86   printf("\n");
87   bitmask = bitmask << 1;
88   printf("/* Set if the encoding can encode\n");
89   printf("   the double-width Hangul letters (Jamo) U+3131 to U+3163. */\n");
90   printf("#define HAVE_HANGUL_JAMO %d\n",bitmask);
91   printf("\n");
92
93 #define DEFENCODING(xxx_names,xxx,xxx_ifuncs1,xxx_ifuncs2,xxx_ofuncs1,xxx_ofuncs2) \
94   {                                                       \
95     struct wctomb_funcs ofuncs = xxx_ofuncs1,xxx_ofuncs2; \
96     emit_encoding(&ofuncs,#xxx);                          \
97   }
98 /* Consider all encodings, including the system dependent ones. */
99 #include "encodings.def"
100 #include "encodings_aix.def"
101 #include "encodings_osf1.def"
102 #include "encodings_dos.def"
103 #include "encodings_extra.def"
104 #undef DEFENCODING
105
106   fflush(stdout);
107   if (ferror(stdout))
108     exit(1);
109   exit(0);
110 }