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