xref: /titanic_51/usr/src/lib/libxcurses/src/libc/xcurses/mkterm.awk (revision c10c16dec587a0662068f6e2991c29ed3a9db943)
1#
2# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
3# Use is subject to license terms.
4#
5# CDDL HEADER START
6#
7# The contents of this file are subject to the terms of the
8# Common Development and Distribution License, Version 1.0 only
9# (the "License").  You may not use this file except in compliance
10# with the License.
11#
12# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
13# or http://www.opensolaris.org/os/licensing.
14# See the License for the specific language governing permissions
15# and limitations under the License.
16#
17# When distributing Covered Code, include this CDDL HEADER in each
18# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
19# If applicable, add the following below this CDDL HEADER, with the
20# fields enclosed by brackets "[]" replaced with your own identifying
21# information: Portions Copyright [yyyy] [name of copyright owner]
22#
23# CDDL HEADER END
24#
25# ident	"%Z%%M%	%I%	%E% SMI"
26#
27# mkterm.awk
28#
29# XCurses Library
30#
31# Copyright 1990, 1995 by Mortice Kern Systems Inc.  All rights reserved.
32#
33# $Header: /rd/src/libc/xcurses/rcs/mkterm.awk 1.12 1995/07/26 17:40:26 ant Exp $
34#
35# USAGE:
36# 	awk -f mkterm.awk caps >term.h
37#
38
39BEGIN {
40print "/*"
41print " * term.h"
42print " *"
43print " * XCurses Library"
44print " *"
45print " * **** THIS FILE IS MACHINE GENERATED."
46print " * **** DO NOT EDIT THIS FILE."
47print " *"
48print " * Copyright 1990, 1995 by Mortice Kern Systems Inc.  All rights reserved."
49print " *"
50printf " * $Header%s\n", "$"
51print " */"
52print
53print "#ifndef __term_h__"
54print "#define __term_h__\t1"
55print
56print "#define _XOPEN_CURSES"
57print
58print "#ifndef NCCS"
59print "#include <termios.h>"
60print "#endif"
61print "#ifndef STDIN_FILENO"
62print "#include <sys/types.h>"
63print "#include <unistd.h>"
64print "#endif"
65print
66print "#define __TERM cur_term->"
67}
68
69$4 == "bool" {
70	printf "#define %-30s __TERM _bool[%d]\n", $1, BoolCount++
71}
72
73$4 == "number" {
74	printf "#define %-30s __TERM _num[%d]\n", $1, NumberCount++
75}
76
77$4 == "str" {
78	printf "#define %-30s __TERM _str[%d]\n", $1, StringCount++
79}
80
81END {
82print
83printf "#define __COUNT_BOOL\t\t%d\n", BoolCount
84printf "#define __COUNT_NUM\t\t%d\n", NumberCount
85printf "#define __COUNT_STR\t\t%d\n", StringCount
86print
87print "/*"
88print " * MKS Header format for terminfo database files."
89print " *"
90print " * The header consists of six short integers, stored using VAX/PDP style"
91print " * byte swapping (least-significant byte first).  The integers are"
92print " *"
93print " *  1) magic number (octal 0432);"
94print " *  2) the size, in bytes, of the names sections;"
95print " *  3) the number of bytes in the boolean section;"
96print " *  4) the number of short integers in the numbers section;"
97print " *  5) the number of offsets (short integers) in the strings section;"
98print " *  6) the size, in bytes, of the string table."
99print " *"
100print " * Between the boolean and number sections, a null byte is inserted, if"
101print " * necessary, to ensure that the number section begins on an even byte"
102print " * offset.  All short integers are aligned on a short word boundary."
103print " */"
104print
105print "#define __TERMINFO_MAGIC\t\t0432"
106print
107print "typedef struct {"
108print "\tshort magic;"
109print "\tshort name_size;"
110print "\tshort bool_count;"
111print "\tshort num_count;"
112print "\tshort str_count;"
113print "\tshort str_size;"
114print "} terminfo_header_t;"
115print
116print "/*"
117print " * The following __MOVE_ constants are indices into the _move[] member"
118print " * of a SCREEN structure.  The array is used by m_mvcur() for cursor"
119print " * motion costs and initialized by newterm()."
120print " *"
121print " * The following indices refer to relative cursor motion actions that"
122print " * have a base-cost times the distance/count."
123print " */"
124print "#define __MOVE_UP\t\t0"
125print "#define __MOVE_DOWN\t\t1"
126print "#define __MOVE_LEFT\t\t2"
127print "#define __MOVE_RIGHT\t\t3"
128print "#define __MOVE_TAB\t\t4"
129print "#define __MOVE_BACK_TAB\t\t5"
130print
131print "#define __MOVE_MAX_RELATIVE\t6"
132print
133print "/*"
134print " * These should have fixed costs."
135print " */"
136print "#define __MOVE_RETURN\t\t6"
137print "#define __MOVE_HOME\t\t7"
138print "#define __MOVE_LAST_LINE\t8"
139print
140print "/*"
141print " * These have worst case cost based on moving the maximum possible"
142print " * value for a parameter given the screen size."
143print " */"
144print "#define __MOVE_N_UP\t\t9"
145print "#define __MOVE_N_DOWN\t\t10"
146print "#define __MOVE_N_LEFT\t\t11"
147print "#define __MOVE_N_RIGHT\t\t12"
148print "#define __MOVE_ROW\t\t13"
149print "#define __MOVE_COLUMN\t\t14"
150print "#define __MOVE_ROW_COLUMN\t15"
151print
152print "#define __MOVE_MAX\t\t16"
153print
154print "/*"
155print " * For a cursor motion to be used there must be a base-cost of at least 1."
156print " */"
157print "#define __MOVE_INFINITY\t\t1000"
158print
159print "#define __TERM_ISATTY_IN\t0x0001\t/* Input is a terminal */"
160print "#define __TERM_ISATTY_OUT\t0x0002\t/* Output is a terminal */"
161print "#define __TERM_HALF_DELAY\t0x0004\t/* halfdelay() has priority. */"
162print "#define __TERM_INSERT_MODE\t0x0008\t/* Terminal is in insert mode. */"
163print "#define __TERM_NL_IS_CRLF\t0x8000\t/* Newline is mapped on output. */"
164print
165print "/***"
166print " *** Opaque data type.  Keep your grubby mits off."
167print " ***/"
168print "typedef struct {"
169print "\tint _ifd;\t\t\t/* Input file descriptor */"
170print "\tint _ofd;\t\t\t/* Output file descriptor */"
171print "\tstruct termios _prog;"
172print "\tstruct termios _shell;"
173print "\tstruct termios _save;"
174print "\tshort _co;\t\t\t/* Current colour-pair. */"
175print "\tunsigned short _at;\t\t/* Current attribute state. */"
176print "\tshort (*_pair)[2];"
177print "\tshort (*_color)[3];"
178print "\tunsigned short _flags;"
179print "\tchar _bool[__COUNT_BOOL];"
180print "\tshort _num[__COUNT_NUM];"
181print "\tchar *_str[__COUNT_STR];\t/* Pointers into _str_table. */"
182print "\tchar *_str_table;"
183print "\tchar *_names;\t\t\t/* Terminal alias in _str_table. */"
184print "\tchar *_term;\t\t\t/* TERM name loaded. */"
185print "\tstruct {"
186print "\t\tchar *_seq;"
187print "\t\tshort _cost;"
188print "\t} _move[__MOVE_MAX];"
189print "} TERMINAL;"
190print
191print "extern TERMINAL *cur_term;"
192print
193print "extern char *__m_boolnames[];"
194print "extern char *__m_boolcodes[];"
195print "extern char *__m_boolfnames[];"
196print "extern char *__m_numnames[];"
197print "extern char *__m_numcodes[];"
198print "extern char *__m_numfnames[];"
199print "extern char *__m_strnames[];"
200print "extern char *__m_strcodes[];"
201print "extern char *__m_strfnames[];"
202print
203print "#ifndef _XOPEN_SOURCE"
204print "/*"
205print " * Old System V array names."
206print " */"
207print "#define boolnames\t__m_boolnames"
208print "#define boolcodes\t__m_boolcodes"
209print "#define boolfnames\t__m_boolfnames"
210print "#define numnames\t__m_numnames"
211print "#define numcodes\t__m_numcodes"
212print "#define numfnames\t__m_numfnames"
213print "#define strnames\t__m_strnames"
214print "#define strcodes\t__m_strcodes"
215print "#define strfnames\t__m_strfnames"
216print "#endif /* _XOPEN_SOURCE */"
217print
218print "/*"
219print " * Exposed internal functions."
220print " */"
221print "extern int __m_putchar(int);"
222print "extern int __m_mvcur(int, int, int, int, int (*)(int));"
223print "extern int __m_read_terminfo(const char *, TERMINAL *);"
224print "extern int __m_setupterm(const char *, int, int, int *);"
225print
226print "/*"
227print " * Globals"
228print " */"
229print "extern int del_curterm(TERMINAL *);"
230print "extern TERMINAL *set_curterm(TERMINAL *);"
231print "extern int restartterm(const char *, int, int *);"
232print "extern int setupterm(const char *, int, int *);"
233print
234print "extern int tgetent(char *, char *);"
235print "extern int tgetflag(const char *);"
236print "extern int tgetnum(const char *);"
237print "extern char *tgetstr(const char *, char **);"
238print "extern char *tgoto(const char *, int, int);"
239print
240print "extern int tigetflag(const char *);"
241print "extern int tigetnum(const char *);"
242print "extern char *tigetstr(const char *);"
243print
244print "extern int putp(const char *);"
245print "extern const char *tparm("
246print "\tconst char *, long, long, long, long, long, long, long, long, long);"
247print "extern int tputs(const char *, int, int (*)(int));"
248print
249print "#ifndef _XOPEN_SOURCE_EXTENDED"
250print
251print "#define putp(str)\t\ttputs(str,1,__m_putchar)"
252print "#define del_term\t\tdel_curterm"
253print "#define setterm(t)\t\tsetupterm(t,STDOUT_FILENO,(int *) 0)"
254print "#define tgoto(cm,c,r)\t\ttparm((char *)(cm), (long)(r), (long)(c))"
255print
256print "#ifndef _XOPEN_SOURCE"
257print "#define beehive_glitch\t\tno_esc_ctrlc"
258print "#define teleray_glitch\t\tdest_tabs_magic_smso"
259print "#endif /* _XOPEN_SOURCE */"
260print
261print "#endif /* _XOPEN_SOURCE_EXTENDED */"
262print
263print "#endif /* __term_h__ */"
264}
265