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 
  39 BEGIN {
  40 print "/*"
  41 print " * Copyright (c) 1998 by Sun Microsystems, Inc."
  42 print " * All rights reserved."
  43 print " */"
  44 print 
  45 print "#ifndef  _TERM_H"
  46 print "#define  _TERM_H"
  47 print
  48 print "#pragma ident    \"@(#)term.h    %I%     %E% SMI\""
  49 print
  50 print "/*"
  51 print " * term.h"
  52 print " *"
  53 print " * XCurses Library"
  54 print " *"
  55 print " * **** THIS FILE IS MACHINE GENERATED."
  56 print " * **** DO NOT EDIT THIS FILE."
  57 print " *"
  58 print " * Copyright 1990, 1995 by Mortice Kern Systems Inc.  All rights reserved."
  59 print " *"
  60 printf " * $Header%s\n", "$"
  61 print " */"
  62 print
  63 print
  64 print "#ifdef   __cplusplus"
  65 print "extern \"C\" {"
  66 print "#endif"
  67 print
  68 print "#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 
  83 END {
  84 print
  85 printf "#define __COUNT_BOOL\t\t%d\n", BoolCount
  86 printf "#define __COUNT_NUM\t\t%d\n", NumberCount
  87 printf "#define __COUNT_STR\t\t%d\n", StringCount
  88 print
  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
 118 print "/*"
 119 print " * The following __MOVE_ constants are indices into the _move[] member"
 120 print " * of a SCREEN structure.  The array is used by m_mvcur() for cursor"
 121 print " * motion costs and initialized by newterm()."
 122 print " *"
 123 print " * The following indices refer to relative cursor motion actions that"
 124 print " * have a base-cost times the distance/count."
 125 print " */"
 126 print "#define  __MOVE_UP\t\t0"
 127 print "#define  __MOVE_DOWN\t\t1"
 128 print "#define  __MOVE_LEFT\t\t2"
 129 print "#define  __MOVE_RIGHT\t\t3"
 130 print "#define  __MOVE_TAB\t\t4"
 131 print "#define  __MOVE_BACK_TAB\t\t5"
 132 print
 133 print "#define  __MOVE_MAX_RELATIVE\t6"
 134 print
 135 print "/*"
 136 print " * These should have fixed costs."
 137 print " */"
 138 print "#define  __MOVE_RETURN\t\t6"
 139 print "#define  __MOVE_HOME\t\t7"
 140 print "#define  __MOVE_LAST_LINE\t8"
 141 print
 142 print "/*"
 143 print " * These have worst case cost based on moving the maximum possible"
 144 print " * value for a parameter given the screen size."
 145 print " */"
 146 print "#define  __MOVE_N_UP\t\t9"
 147 print "#define  __MOVE_N_DOWN\t\t10"
 148 print "#define  __MOVE_N_LEFT\t\t11"
 149 print "#define  __MOVE_N_RIGHT\t\t12"
 150 print "#define  __MOVE_ROW\t\t13"
 151 print "#define  __MOVE_COLUMN\t\t14"
 152 print "#define  __MOVE_ROW_COLUMN\t15"
 153 print
 154 print "#define  __MOVE_MAX\t\t16"
 155 print
 156 print "/*"
 157 print " * For a cursor motion to be used there must be a base-cost of at least 1."
 158 print " */"
 159 print "#define  __MOVE_INFINITY\t\t1000"
 160 print
 161 print "#define  __TERM_ISATTY_IN\t0x0001\t/* Input is a terminal */"
 162 print "#define  __TERM_ISATTY_OUT\t0x0002\t/* Output is a terminal */"
 163 print "#define  __TERM_HALF_DELAY\t0x0004\t/* halfdelay() has priority. */"
 164 print "#define  __TERM_INSERT_MODE\t0x0008\t/* Terminal is in insert mode. */"
 165 print "#define  __TERM_NL_IS_CRLF\t0x8000\t/* Newline is mapped on output. */"
 166 print
 167 print "/*"
 168 print " * Opaque data type.  Keep your grubby mits off."
 169 print " */"
 170 print "typedef struct {"
 171 print "\tint    _ifd;\t/* Input file descriptor */"
 172 print "\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 */"
 177 print "\tvoid   *_prog;"
 178 print "\tvoid   *_shell;"
 179 print "\tvoid   *_save;"
 180 print "\tvoid   *_actual;\t/* What has actually been set in the terminal */"
 181 print "\tshort  _co;\t/* Current color-pair. */"
 182 print "\tunsigned short _at;\t/* Current attribute state. */"
 183 print "\tshort  (*_pair)[2];"
 184 print "\tshort  (*_color)[3];"
 185 print "\tunsigned short _flags;"
 186 print "\tchar   _bool[__COUNT_BOOL];"
 187 print "\tshort  _num[__COUNT_NUM];"
 188 print "\tchar   *_str[__COUNT_STR];\t/* Pointers into _str_table. */"
 189 print "\tchar   *_str_table;"
 190 print "\tchar   *_names;\t/* Terminal alias in _str_table. */"
 191 print "\tchar   *_term;\t/* TERM name loaded. */"
 192 print "\tstruct {"
 193 print "\t\tchar *_seq;"
 194 print "\t\tshort        _cost;"
 195 print "\t} _move[__MOVE_MAX];"
 196 print "} TERMINAL;"
 197 print
 198 print "extern TERMINAL *cur_term;"
 199 print
 200 print "#if !(defined(__cplusplus) && defined(_BOOL))"
 201 print "#ifndef _BOOL_DEFINED"
 202 print "typedef short    bool;"
 203 print "#define  _BOOL_DEFINED"
 204 print "#endif"
 205 print "#endif"
 206 print
 207 print "/*"
 208 print " * Globals"
 209 print " */"
 210 print "extern int del_curterm(TERMINAL *);"
 211 print "extern int putp(const char *);"
 212 print "extern int restartterm(char *, int, int *);"
 213 print "extern TERMINAL *set_curterm(TERMINAL *);"
 214 print "extern int setupterm(char *, int, int *);"
 215 print "extern int tgetent(char *, const char *);"
 216 print "extern int tgetflag(char *);"
 217 print "extern int tgetnum(char *);"
 218 print "extern char *tgetstr(char *, char **);"
 219 print "extern char *tgoto(char *, int, int);"
 220 print "extern int tigetflag(char *);"
 221 print "extern int tigetnum(char *);"
 222 print "extern char *tigetstr(char *);"
 223 print "extern char *tparm("
 224 print "\tchar *, long, long, long, long, long, long, long, long, long);"
 225 print "extern int tputs(const char *, int, int (*)(int));"
 226 print
 227 print "#ifdef   __cplusplus"
 228 print "}"
 229 print "#endif"
 230 print
 231 print "#endif /* _TERM_H */"
 232 }