Refactor charset plugins a bit and add CP437 module.
[bbaumbach/samba-autobuild/.git] / source3 / script / gen-8bit-gap.sh.in
1 #!/bin/sh
2 if test $# -ne 2 ; then
3         echo "Usage: $0 <charmap file> <CHARSET NAME>"
4         exit 1
5 fi
6
7 CHARMAP=$1
8 CHARSETNAME=$2
9
10 echo "/* "
11 echo " * Conversion table for $CHARSETNAME charset "
12 echo " * "
13 echo " * Conversion tables are generated using $CHARMAP table "
14 echo " * and source/script/gen-8bit-gap.sh script "
15 echo " * "
16 echo " * This program is free software; you can redistribute it and/or modify "
17 echo " * it under the terms of the GNU General Public License as published by "
18 echo " * the Free Software Foundation; either version 2 of the License, or "
19 echo " * (at your option) any later version. "
20 echo " *  "
21 echo " * This program is distributed in the hope that it will be useful,"
22 echo " * but WITHOUT ANY WARRANTY; without even the implied warranty of "
23 echo " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the "
24 echo " * GNU General Public License for more details. "
25 echo " *  "
26 echo " * You should have received a copy of the GNU General Public License "
27 echo " * along with this program; if not, write to the Free Software "
28 echo " * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. "
29 echo " */"
30
31 echo '#include "includes.h"'
32 echo
33 echo "static const uint16 to_ucs2[256] = {"
34 sed -ne '/^[^[:space:]]*[[:space:]]*.x00/d' \
35     -e 's/^<U\(....\)>[[:space:]]*.x\(..\).*/  [0x\2] = 0x\1,/p' \
36     "$CHARMAP" | sort -u
37 echo "};"
38 echo
39 echo "static const struct charset_gap_table from_idx[] = {"
40 sed -ne 's/^<U\(....\).*/\1/p' \
41     "$CHARMAP" | sort -u | @AWK@ -f @srcdir@/script/gap.awk
42 echo "  { 0xffff, 0xffff, 0 }"
43 echo "};"
44 echo
45 echo "static const unsigned char from_ucs2[] = {"
46 sed -ne 's/^<U\(....\)>[[:space:]]*.x\(..\).*/\1 \2/p' \
47     "$CHARMAP" | sort -u | @AWK@ -f @srcdir@/script/gaptab.awk
48 echo "};"
49 echo 
50 echo "SMB_GENERATE_CHARSET_MODULE_8_BIT_GAP($CHARSETNAME)"
51 echo