MKnames.awk revision 166124
1166124Srafan##############################################################################
2166124Srafan# Copyright (c) 1998-2000,2006 Free Software Foundation, Inc.                #
3166124Srafan#                                                                            #
4166124Srafan# Permission is hereby granted, free of charge, to any person obtaining a    #
5166124Srafan# copy of this software and associated documentation files (the "Software"), #
6166124Srafan# to deal in the Software without restriction, including without limitation  #
7166124Srafan# the rights to use, copy, modify, merge, publish, distribute, distribute    #
8166124Srafan# with modifications, sublicense, and/or sell copies of the Software, and to #
9166124Srafan# permit persons to whom the Software is furnished to do so, subject to the  #
10166124Srafan# following conditions:                                                      #
11166124Srafan#                                                                            #
12166124Srafan# The above copyright notice and this permission notice shall be included in #
13166124Srafan# all copies or substantial portions of the Software.                        #
14166124Srafan#                                                                            #
15166124Srafan# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
16166124Srafan# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
17166124Srafan# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
18166124Srafan# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
19166124Srafan# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
20166124Srafan# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
21166124Srafan# DEALINGS IN THE SOFTWARE.                                                  #
22166124Srafan#                                                                            #
23166124Srafan# Except as contained in this notice, the name(s) of the above copyright     #
24166124Srafan# holders shall not be used in advertising or otherwise to promote the sale, #
25166124Srafan# use or other dealings in this Software without prior written               #
26166124Srafan# authorization.                                                             #
27166124Srafan##############################################################################
28166124Srafan# $Id: MKnames.awk,v 1.12 2006/04/22 21:46:17 tom Exp $
2950276SpeterBEGIN		{
3050276Speter			print  "/* This file was generated by MKnames.awk */" > "namehdr"
3150276Speter			print  ""				> "namehdr"
3250276Speter			print  "#include <curses.priv.h>"	> "namehdr"
3350276Speter			print  ""				> "namehdr"
3450276Speter			print  "#define IT NCURSES_CONST char * const"	> "namehdr"
3550276Speter			print  ""				> "namehdr"
3650276Speter			print  "#if BROKEN_LINKER"		> "namehdr"
3750276Speter			print  "#include <term.h>"		> "namehdr"
3850276Speter			print  "#define DCL(it) static IT data##it[]" > "namehdr"
3950276Speter			print  "#else"				> "namehdr"
4076726Speter			print  "#define DCL(it) NCURSES_EXPORT_VAR(IT) it[]"	> "namehdr"
4150276Speter			print  "#endif"				> "namehdr"
4250276Speter			print  ""				> "namehdr"
4350276Speter			print  "/*"				> "boolnames"
4450276Speter			print  " *	names.c - Arrays of capability names and codes"  > "boolnames"
4550276Speter			print  " *"				> "boolnames"
4650276Speter			print  " */"				> "boolnames"
4750276Speter			print  ""				> "boolnames"
4850276Speter			print  "DCL(boolnames)  = {"		> "boolnames"
4950276Speter			print  "DCL(boolfnames) = {"		> "boolfnames"
5050276Speter			print  "DCL(boolcodes)  = {"		> "boolcodes"
5150276Speter			print  "DCL(numnames)   = {"		> "numnames"
5250276Speter			print  "DCL(numfnames)  = {"		> "numfnames"
5350276Speter			print  "DCL(numcodes)   = {"		> "numcodes"
5450276Speter			print  "DCL(strnames)   = {"		> "strnames"
5550276Speter			print  "DCL(strfnames)  = {"		> "strfnames"
5650276Speter			print  "DCL(strcodes)   = {"		> "strcodes"
5750276Speter		}
5850276Speter
5950276Speter$1 ~ /^#/		{next;}
6050276Speter
6150276Speter$1 == "SKIPWARN"	{next;}
6250276Speter
6350276Speter$3 == "bool"	{
6450276Speter			printf "\t\t\"%s\",\n", $2 > "boolnames"
6550276Speter			printf "\t\t\"%s\",\n", $1 > "boolfnames"
6650276Speter			printf "\t\t\"%s\",\n", $4 > "boolcodes"
6750276Speter		}
6850276Speter
6950276Speter$3 == "num"	{
7050276Speter			printf "\t\t\"%s\",\n", $2 > "numnames"
7150276Speter			printf "\t\t\"%s\",\n", $1 > "numfnames"
7250276Speter			printf "\t\t\"%s\",\n", $4 > "numcodes"
7350276Speter		}
7450276Speter
7550276Speter$3 == "str"	{
7650276Speter			printf "\t\t\"%s\",\n", $2 > "strnames"
7750276Speter			printf "\t\t\"%s\",\n", $1 > "strfnames"
7850276Speter			printf "\t\t\"%s\",\n", $4 > "strcodes"
7950276Speter		}
8050276Speter
8150276SpeterEND		{
8250276Speter			print  "\t\t(NCURSES_CONST char *)0," > "boolnames"
8350276Speter			print  "};" > "boolnames"
8450276Speter			print  "" > "boolnames"
8550276Speter			print  "\t\t(NCURSES_CONST char *)0," > "boolfnames"
8650276Speter			print  "};" > "boolfnames"
8750276Speter			print  "" > "boolfnames"
8850276Speter			print  "\t\t(NCURSES_CONST char *)0," > "boolcodes"
8950276Speter			print  "};" > "boolcodes"
9050276Speter			print  "" > "boolcodes"
9150276Speter			print  "\t\t(NCURSES_CONST char *)0," > "numnames"
9250276Speter			print  "};" > "numnames"
9350276Speter			print  "" > "numnames"
9450276Speter			print  "\t\t(NCURSES_CONST char *)0," > "numfnames"
9550276Speter			print  "};" > "numfnames"
9650276Speter			print  "" > "numfnames"
9750276Speter			print  "\t\t(NCURSES_CONST char *)0," > "numcodes"
9850276Speter			print  "};" > "numcodes"
9950276Speter			print  "" > "numcodes"
10050276Speter			print  "\t\t(NCURSES_CONST char *)0," > "strnames"
10150276Speter			print  "};" > "strnames"
10250276Speter			print  "" > "strnames"
10350276Speter			print  "\t\t(NCURSES_CONST char *)0," > "strfnames"
10450276Speter			print  "};" > "strfnames"
10550276Speter			print  "" > "strfnames"
10650276Speter			print  "\t\t(NCURSES_CONST char *)0," > "strcodes"
10750276Speter			print  "};"				> "strcodes"
10850276Speter			print  ""				> "strcodes"
10950276Speter			print  "#if BROKEN_LINKER"		> "nameftr"
11076726Speter			print  "#define FIX(it) NCURSES_IMPEXP IT * NCURSES_API _nc_##it(void) { return data##it; }" > "nameftr"
11150276Speter			print  "FIX(boolnames)"			> "nameftr"
11250276Speter			print  "FIX(boolfnames)"		> "nameftr"
11350276Speter			print  "FIX(numnames)"			> "nameftr"
11450276Speter			print  "FIX(numfnames)"			> "nameftr"
11550276Speter			print  "FIX(strnames)"			> "nameftr"
11650276Speter			print  "FIX(strfnames)"			> "nameftr"
11750276Speter			print  "#endif /* BROKEN_LINKER */"	> "nameftr"
11850276Speter			print  ""				> "codeftr"
11950276Speter			print  "#if BROKEN_LINKER"		> "codeftr"
12076726Speter			print  "#define FIX(it) NCURSES_IMPEXP IT * NCURSES_API _nc_##it(void) { return data##it; }" > "codeftr"
12150276Speter			print  "FIX(boolcodes)"			> "codeftr"
12250276Speter			print  "FIX(numcodes)"			> "codeftr"
12350276Speter			print  "FIX(strcodes)"			> "codeftr"
12450276Speter			print  "#endif /* BROKEN_LINKER */"	> "codeftr"
12550276Speter		}
126