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