diff options
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/cmd/tic/Makefile.common | 3 | ||||
-rw-r--r-- | usr/src/cmd/tic/tic_main.c | 46 | ||||
-rw-r--r-- | usr/src/cmd/tic/tic_parse.c | 70 | ||||
-rw-r--r-- | usr/src/cmd/tic/tic_read.c | 20 | ||||
-rw-r--r-- | usr/src/cmd/tic/tic_scan.c | 4 | ||||
-rw-r--r-- | usr/src/lib/libxcurses/src/tic/Makefile | 78 | ||||
-rw-r--r-- | usr/src/lib/libxcurses/src/tic/tic.h | 152 | ||||
-rw-r--r-- | usr/src/lib/libxcurses/src/tic/ticerror.c | 97 | ||||
-rw-r--r-- | usr/src/lib/libxcurses/src/tic/ticmain.c | 208 | ||||
-rw-r--r-- | usr/src/lib/libxcurses/src/tic/ticparse.c | 701 | ||||
-rw-r--r-- | usr/src/lib/libxcurses/src/tic/ticscan.c | 417 | ||||
-rw-r--r-- | usr/src/lib/libxcurses/src/tic/untic.c | 264 |
12 files changed, 58 insertions, 2002 deletions
diff --git a/usr/src/cmd/tic/Makefile.common b/usr/src/cmd/tic/Makefile.common index 00c0948db7..07df0ca8aa 100644 --- a/usr/src/cmd/tic/Makefile.common +++ b/usr/src/cmd/tic/Makefile.common @@ -43,9 +43,6 @@ MAPFILES= $(MAPFILE.INT) $(MAPFILE.NGB) LDFLAGS += $(MAPFILES:%=-Wl,-M%) CERRWARN += -_gcc=-Wno-char-subscripts -CERRWARN += -_gcc=-Wno-implicit-function-declaration -CERRWARN += -_gcc=-Wno-parentheses -CERRWARN += $(CNOWARN_UNINIT) # not linted SMATCH=off diff --git a/usr/src/cmd/tic/tic_main.c b/usr/src/cmd/tic/tic_main.c index 99312d3093..bde662ed2c 100644 --- a/usr/src/cmd/tic/tic_main.c +++ b/usr/src/cmd/tic/tic_main.c @@ -24,14 +24,14 @@ * Use is subject to license terms. */ /* Copyright (c) 1988 AT&T */ -/* All Rights Reserved */ +/* All Rights Reserved */ -/* +/* * University Copyright- Copyright (c) 1982, 1986, 1988 * The Regents of the University of California * All Rights Reserved - * + * * University Acknowledgment- Portions of this document are derived from * software developed by the University of California, Berkeley, and its * contributors. @@ -233,43 +233,3 @@ check_dir(char dirletter) } return; } - -#include <curses.h> -#if (defined(SYSV) || defined(USG)) && !defined(SIGPOLL) -/* - * mkdir(dirname, mode) - * - * forks and execs the mkdir program to create the given directory - * - */ - -mkdir(dirname, mode) -#ifdef __STDC__ -const -#endif -char *dirname; -int mode; -{ - int fork_rtn; - int status; - - fork_rtn = fork(); - - switch (fork_rtn) { - case 0: /* Child */ - (void) execl("/bin/mkdir", "mkdir", dirname, (char *)0); - _exit(1); - - case -1: /* Error */ - fprintf(stderr, "%s: SYSTEM ERROR!! Fork failed!!!\n", - progname); - exit(1); - - default: - (void) wait(&status); - if ((status != 0) || (chmod(dirname, mode) == -1)) - return (-1); - return (0); - } -} -#endif diff --git a/usr/src/cmd/tic/tic_parse.c b/usr/src/cmd/tic/tic_parse.c index 37f5a7db6f..4afb2d2c62 100644 --- a/usr/src/cmd/tic/tic_parse.c +++ b/usr/src/cmd/tic/tic_parse.c @@ -122,9 +122,25 @@ struct use_header { struct use_header use_list = {NULL, NULL}; int use_count = 0; + +extern int get_token(void); +extern int must_swap(void); +extern void check_dir(char); +extern void err_abort(char *, ...); +extern void panic_mode(char); +extern int read_entry(char *, struct _bool_struct *, struct _num_struct *, + struct _str_struct *); +extern void reset_input(void); +extern void syserr_abort(char *, ...); +extern void warning(char *, ...); + +int do_entry(struct use_item *); +int handle_use(struct use_item *, long, short *, short *, short *); +int save_str(char *); +int write_object(FILE *, short *, short *, short *); void dequeue(struct use_item *); -void init_structure(short Booleans[], short Numbers[], short Strings[]); -void dump_structure(short Booleans[], short Numbers[], short Strings[]); +void dump_structure(short *, short *, short *); +void init_structure(short *, short *, short *); /* * The use_list is a doubly-linked list with NULLs terminating the lists: @@ -276,8 +292,7 @@ dump_list(char *str) */ int -do_entry(item_ptr) -struct use_item *item_ptr; +do_entry(struct use_item *item_ptr) { long entry_offset; int token_type; @@ -524,14 +539,13 @@ void dump_structure(short Booleans[], short Numbers[], short Strings[]) { struct stat64 statbuf; - FILE *fp; + FILE *fp = NULL; char name_list[1024]; char *first_name, *other_names, *cur_name; char filename[128 + 2 + 1]; char linkname[128 + 2 + 1]; int len; int alphastart = 0; - extern char *strchr(), *strrchr(); strcpy(name_list, term_names + string_table); DEBUG(7, "Name list = '%s'\n", name_list); @@ -666,11 +680,7 @@ dump_structure(short Booleans[], short Numbers[], short Strings[]) int -write_object(fp, Booleans, Numbers, Strings) -FILE *fp; -short Booleans[]; -short Numbers[]; -short Strings[]; +write_object(FILE *fp, short Booleans[], short Numbers[], short Strings[]) { struct header header; char *namelist; @@ -707,9 +717,8 @@ short Strings[]; cBooleans[i] = Booleans[i]; if (fwrite(&header, sizeof (header), 1, fp) != 1 || - fwrite(namelist, sizeof (char), namelen, fp) != namelen || - fwrite(cBooleans, sizeof (char), BoolCount, fp) != - BoolCount) + fwrite(namelist, sizeof (char), namelen, fp) != namelen || + fwrite(cBooleans, sizeof (char), BoolCount, fp) != BoolCount) return (-1); if ((namelen+BoolCount) % 2 != 0 && @@ -744,14 +753,13 @@ short Strings[]; */ int -save_str(string) -char *string; +save_str(char *string) { int old_next_free; /* Do not let an offset be 255. It reads as -1 in Vr2 binaries. */ if (next_free % 256 == 255) - next_free++; + string_table[next_free++] = '\0'; old_next_free = next_free; @@ -825,12 +833,8 @@ init_structure(short Booleans[], short Numbers[], short Strings[]) */ int -handle_use(item_ptr, entry_offset, Booleans, Numbers, Strings) -long entry_offset; -struct use_item *item_ptr; -short Booleans[]; -short Numbers[]; -short Strings[]; +handle_use(struct use_item *item_ptr, long entry_offset, + short Booleans[], short Numbers[], short Strings[]) { struct _bool_struct use_bools; struct _num_struct use_nums; @@ -848,8 +852,8 @@ short Strings[]; sprintf(filename, "%c/%s", curr_token.tk_valstring[0], curr_token.tk_valstring); - if (stat64(filename, &statbuf) < 0 || - part2 == 0 && statbuf.st_mtime < start_time) { + if ((stat64(filename, &statbuf) < 0) || + (part2 == 0 && statbuf.st_mtime < start_time)) { DEBUG(2, "Forward USE to %s", curr_token.tk_valstring); if (item_ptr == NULL) { @@ -865,11 +869,13 @@ short Strings[]; filename); for (i = 0; i < BoolCount; i++) { - if (Booleans[i] == FALSE) - if (UB[i] == TRUE) /* now true */ + if (Booleans[i] == FALSE) { + if (UB[i] == TRUE) { /* now true */ Booleans[i] = TRUE; - else if (UB[i] > TRUE) /* cancelled */ + } else if (UB[i] > TRUE) { /* cancelled */ Booleans[i] = -2; + } + } } for (i = 0; i < NumCount; i++) { @@ -878,11 +884,13 @@ short Strings[]; } for (i = 0; i < StrCount; i++) { - if (Strings[i] == -1) - if (US[i] == (char *)-1) + if (Strings[i] == -1) { + if (US[i] == (char *)-1) { Strings[i] = -2; - else if (US[i] != (char *)0) + } else if (US[i] != (char *)0) { Strings[i] = save_str(US[i]); + } + } } } diff --git a/usr/src/cmd/tic/tic_read.c b/usr/src/cmd/tic/tic_read.c index b6acd1d7ce..b1d017cb15 100644 --- a/usr/src/cmd/tic/tic_read.c +++ b/usr/src/cmd/tic/tic_read.c @@ -38,8 +38,6 @@ * contributors. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * ******************************************************************** * COPYRIGHT NOTICE * @@ -91,7 +89,12 @@ #include <sys/types.h> #include <sys/stat.h> +#include <sys/types.h> +#include <sys/stat.h> + +#include <fcntl.h> #include <stdlib.h> +#include <unistd.h> #include "curses_inc.h" #include "object.h" @@ -115,12 +118,15 @@ static char TermNames[128]; /* Buffer for terminal names for first term */ static char StringTable[2048]; /* String table for first terminal */ static int beencalled = 0; /* read_entry has been called before */ +extern void err_abort(char *, ...); +extern void syserr_abort(char *, ...); +extern void warning(char *, ...); + +int must_swap(void); + int -read_entry(filename, bptr, nptr, sptr) -char *filename; -struct _bool_struct *bptr; -struct _num_struct *nptr; -struct _str_struct *sptr; +read_entry(char *filename, struct _bool_struct *bptr, struct _num_struct *nptr, + struct _str_struct *sptr) { int fd; int numread; diff --git a/usr/src/cmd/tic/tic_scan.c b/usr/src/cmd/tic/tic_scan.c index c0f748f27f..460394aa99 100644 --- a/usr/src/cmd/tic/tic_scan.c +++ b/usr/src/cmd/tic/tic_scan.c @@ -90,6 +90,9 @@ #define iswhite(ch) (ch == ' ' || ch == '\t') +extern void err_abort(char *, ...); +extern void syserr_abort(char *, ...); +extern void warning(char *, ...); static int first_column; /* See 'next_char()' below */ @@ -128,7 +131,6 @@ void panic_mode(int); * EOF The end of the file has been reached. * */ - int get_token() { diff --git a/usr/src/lib/libxcurses/src/tic/Makefile b/usr/src/lib/libxcurses/src/tic/Makefile deleted file mode 100644 index 7caa48a036..0000000000 --- a/usr/src/lib/libxcurses/src/tic/Makefile +++ /dev/null @@ -1,78 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 1996, by Sun Microsystems, Inc. -# All rights reserved. -# -# lib/libxcurses/src/tic/Makefile -# - -# -# tic.mk -# -# Copyright 1990, 1995 by Mortice Kern Systems Inc. All rights reserved. -# -### -### This makefile INTENTIONALLY AVOIDS MKS MAKE EXTENSIONS in order -### to be portable to other systems that supply only a vanilla/POSIX -### make. -### -# -# -# This makefile assumes that a make wrapper, $RD/bin/$SYS/make, -# loads the required make config file, $RD/h/$SYS/config.mk. -# The make wrapper is a shell script that does : -# -# make -f $RD/h/$SYS/config.mk $@ -# -# Note that $RD/bin/$SYS should be ahead of /bin and /usr/bin in PATH. -# -# -#MAKE = rmake -# -#CFLAGS = -D_XOPEN_SOURCE -# -#HDR = tic.h -#TIC = ticmain.c ticscan.c ticerror.c ticparse.c -#UNTIC = untic.c -# -#EXE = tic$E untic$E -# -#$O$E : -# $(LD) $(LDFLAGS) $(CFLAGS) -o $@ $< -lcurses -# -#all :: $(EXE) -# -#install : all -# $(CP) $(EXE) $(RD)/bin/$(SYS) -# -#clobber :: clean -# $(RM) $(EXE) -# -#tic$E : $(TIC:.c=$O) -# $(LD) $(LDFLAGS) $(CFLAGS) -o $@ $(TIC:.c=$O) -lcurses - -all: - @echo this tic and untic is not currently used by Solaris - @echo use tic and untic in usr/src/lib/libcurses diff --git a/usr/src/lib/libxcurses/src/tic/tic.h b/usr/src/lib/libxcurses/src/tic/tic.h deleted file mode 100644 index 1ed52370c1..0000000000 --- a/usr/src/lib/libxcurses/src/tic/tic.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1996, by Sun Microsystems, Inc. - * All rights reserved. - */ - -/* - * tic.h Terminal Information Compiler - * - * Copyright 1990, 1992 by Mortice Kern Systems Inc. All rights reserved. - * - * Portions of this code Copyright 1982 by Pavel Curtis. - * - */ - -#ifndef tic_h -#define tic_h 1 - -#ifdef M_RCSID -#ifndef lint -static char const tic_h_rcsID[] = "$Header: /rd/src/tic/rcs/tic.h 1.11 1995/06/22 20:03:36 ant Exp $"; -#endif -#endif - -#include <mks.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <term.h> -#include <time.h> - -extern char *_cmdname; - -/* Exit Status */ -#define SUCCESS 0 -#define NOT_DEFINED 1 -#define USAGE 2 -#define BAD_TERMINAL 3 -#define NOT_VALID 4 -#define ERROR 5 - -#define TERM_NAMES_LENGTH 128 -#define TERM_ENTRY_LENGTH 4096 -#define swap(x) (((x >> 8) & 0377) + 256 * (x & 0377)) - -extern int term_names; /* string offset */ -extern char *string_table; -extern char *source_file; - -#ifdef _XOPEN_CURSES -/* - * MKS XCurses to be conforming has to avoid name space pollution - * by using reserved prefixes. Map the pre-XCurses names to the - * new ones. - */ -#define BOOLCOUNT __COUNT_BOOL -#define NUMCOUNT __COUNT_NUM -#define STRCOUNT __COUNT_STR -#define boolnames __m_boolnames -#define boolcodes __m_boolcodes -#define boolfnames __m_boolfnames -#define numnames __m_numnames -#define numcodes __m_numcodes -#define numfnames __m_numfnames -#define strnames __m_strnames -#define strcodes __m_strcodes -#define strfnames __m_strfnames -#define __t_term_header terminfo_header_t -#define TERMINFO_MAGIC __TERMINFO_MAGIC -#define Booleans _bool -#define Numbers _num -#define Strings _str -#endif - -extern char boolean[BOOLCOUNT]; /* 0, 1, cancel 2 */ -extern short number[NUMCOUNT]; /* positive value, missing -1, cancel -2 */ -extern short string[STRCOUNT]; /* positive offset, missing -1, cancel -2 */ - -extern int check_only; -extern char *destination; /* destination directory for object files */ -extern time_t start_time; /* time at start of compilation */ -extern int curr_line; /* current line # in input */ -extern long curr_file_pos; /* file offset of current line */ -extern int debug_level; /* level of debugging output */ - -#define DEBUG(level, fmt, a1) \ - if (level <= debug_level) \ - fprintf(stderr, fmt, a1); - -/* - * These are the types of tokens returned by the scanner. - * The first three are also used in the hash table of capability - * names. The scanner returns one of these values after loading - * the specifics into the global structure curr_token. - * - * Note that EOF is also, implicitly, a token type. - */ -#define BOOLEAN 0 /* Boolean capability */ -#define NUMBER 1 /* Numeric capability */ -#define STRING 2 /* String-valued capability */ -#define CANCEL 3 /* Capability to be cancelled in following tc's */ -#define NAMES 4 /* The names for a terminal type */ -#define UNDEF 5 /* Invalid token */ - -/* - * The global structure in which the specific parts of a - * scanned token are returned. - */ -typedef struct token { - char *tk_name; /* name of capability */ - int tk_valnumber; /* value of capability (if a number) */ - char *tk_valstring; /* value of capability (if a string) */ -} token; - -extern token curr_token; - -/* - * Functions - */ -extern void compile ANSI((void)); -extern void err_abort(char const *_Fmt, ...); /* GENTEXT: err_abort */ -extern int find(char const *_Capname, void **_Arrayp, int *_Indexp); -extern void panic_mode ANSI((int _Ch)); -extern void reset ANSI((void)); -extern void reset_input ANSI((void)); -extern void warning(char const *_Fmt, ...); /* GENTEXT: warning */ - -extern int warnings; - -#define syserr_abort err_abort - -#endif /* tic_h */ diff --git a/usr/src/lib/libxcurses/src/tic/ticerror.c b/usr/src/lib/libxcurses/src/tic/ticerror.c deleted file mode 100644 index 7363023548..0000000000 --- a/usr/src/lib/libxcurses/src/tic/ticerror.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1996, by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * ticerror.c Terminal Information Compiler - * - * Copyright 1990, 1992 by Mortice Kern Systems Inc. All rights reserved. - * - * Portions of this code Copyright 1982 by Pavel Curtis. - * - */ - -#ifdef M_RCSID -#ifndef lint -static char const rcsID[] = "$Header: /rd/src/tic/rcs/ticerror.c 1.14 1995/06/22 18:11:44 ant Exp $"; -#endif -#endif - -#include "tic.h" -#include <stdarg.h> - -int warnings = 0; - -/*f - * Display warning message. - */ -void -warning (char const *f, ...) -{ - va_list ap; - char *fmt = m_msgdup((char *) f); - - va_start(ap, f); - - (void) fprintf( - stderr, m_textmsg(3101, "%s: Warning in \"%s\" line %u,\n", "W _ filename line_num"), - _cmdname, source_file, curr_line - ); - - (void) vfprintf(stderr, fmt, ap); - va_end(ap); - (void) fputc('\n', stderr); - - m_msgfree(fmt); - warnings++; - return; -} - -/*f - * Display error message. - */ -void -err_abort (char const *f, ...) -{ - va_list ap; - char *fmt = m_msgdup((char *) f); - - va_start(ap, f); - - (void) fprintf( - stderr, m_textmsg(3102, "%s: Error in \"%s\" line %u,\n", "E _ filename line_num"), - _cmdname, source_file, curr_line - ); - - (void) vfprintf(stderr, fmt, ap); - va_end(ap); - (void) fputc('\n', stderr); - - m_msgfree(fmt); - exit(1); -} - diff --git a/usr/src/lib/libxcurses/src/tic/ticmain.c b/usr/src/lib/libxcurses/src/tic/ticmain.c deleted file mode 100644 index a1853c5737..0000000000 --- a/usr/src/lib/libxcurses/src/tic/ticmain.c +++ /dev/null @@ -1,208 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1996, by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * ticmain.c - * - * Terminal Information Compiler - * - * Copyright 1990, 1992 by Mortice Kern Systems Inc. All rights reserved. - * - * Portions of this code Copyright 1982 by Pavel Curtis. - * - */ - -#ifdef M_RCSID -#ifndef lint -static char const rcsID[] = "$Header: /rd/src/tic/rcs/ticmain.c 1.11 1995/06/22 18:40:30 ross Exp $"; -#endif -#endif - -#include "tic.h" -#include <ctype.h> -#include <sys/stat.h> - -int curr_line; -int check_only = 0; -int debug_level = 0; -time_t start_time; -char *source_file = M_TERMINFO_DIR; -char *destination = M_TERMINFO_DIR; - -char boolean[BOOLCOUNT]; -short number[NUMCOUNT]; -short string[STRCOUNT]; - -static char const usage[] = m_textstr(3103, "usage: %s [-v[n]] [-c] <file>\n", "U _"); -static char const src_err[] = m_textstr(3104, "terminfo definition file \"%s\" ", "E filename"); -static char const dst_err[] = m_textstr(3105, "terminfo database \"%s\" ", "E filename"); -static char const dstdir_err[] = m_textstr(3106, "terminfo database directory \"%s/%s\" ", "E pathname"); - -static void init(void); - -int -main(int argc, char **argv) -{ - char *ap; - setlocale(LC_ALL, ""); - _cmdname = m_cmdname(*argv); - for (--argc, ++argv; 0 < argc && **argv == '-'; --argc, ++argv) { - ap = &argv[0][1]; - if (*ap == '-' && ap[1] == '\0') { - --argc; - ++argv; - break; - } - while (*ap != '\0') { - switch (*ap++) { - case 'c': - check_only = 1; - continue; - case 'v': - debug_level = 1; - if (isdigit(*ap)) - debug_level = (int) strtol(ap, &ap, 0); - break; - default: - (void) fprintf(stderr, m_strmsg(usage), _cmdname); - return (USAGE); - } - break; - } - } - /* There must be only one source file. */ - if (argc != 1) { - (void) fprintf(stderr, m_strmsg(usage), _cmdname); - return (USAGE); - } - source_file = *argv; - init(); - compile(); - if (warnings > 0) { - return 1; - } - return (0); -} - -/*f - * Miscellaneous initializations - * - * Open source file as standard input - * Check for access rights to destination directories - * Create any directories which don't exist. - */ -static void -init(void) -{ - char *s; - char const *p; - char dir[2]; - struct stat statbuf; - static char const dirnames[] = "abcdefghijklmnopqrstuvwxyz0123456789"; - - curr_line = 0; - start_time = time(NULL); - if (freopen(source_file, "r", stdin) == NULL) { - (void) eprintf(m_strmsg(src_err), source_file); - exit(ERROR); - } - if ((s = getenv("TERMINFO")) != NULL) - destination = s; - if (access(destination, 7) < 0) { - (void) eprintf(m_strmsg(dst_err), destination); - exit(ERROR); - } - if (chdir(destination) < 0) { - (void) eprintf(m_strmsg(dst_err), destination); - exit(ERROR); - } - dir[1] = '\0'; - for (p = dirnames; *p != '\0'; ++p) { - *dir = *p; - if (stat(dir, &statbuf) < 0) { - (void) mkdir(dir, M_DIRMODE); - } else if (access(dir, 7) < 0) { - (void) eprintf(m_strmsg(dstdir_err), destination, dir); - exit(1); - } else if ((statbuf.st_mode & S_IFMT) != S_IFDIR) { - (void) eprintf(m_strmsg(dstdir_err), destination, dir); - exit(1); - } - } -} - -/*f - * Reset boolean[], number[], and string[]. - */ -void -reset(void) -{ - int i; - for (i = 0; i < BOOLCOUNT; ++i) - boolean[i] = 0; - for (i = 0; i < NUMCOUNT; ++i) - number[i] = -1; - for (i = 0; i < STRCOUNT; ++i) - string[i] = -1; -} - -/*f - * Return a linear index value. - * - * Search in the following order boolnames[], numnames[], and strnames[] - * for the matching capability name. Then map the array and index into - * a linear index. Return -1 if capname is not valid. - * - * While this linear approach is slow, TIC is seldom used once the - * database is created, therefore we don't bother spending extra - * effort to speed it up. - */ -int -find(char const *capname, void **arrayp, int *indexp) -{ - char **p; - for (p = boolnames; *p != NULL; ++p) - if (strcmp(*p, capname) == 0) { - *arrayp = (void*) boolean; - *indexp = (int)(p - boolnames); - return (0); - } - for (p = numnames; *p != NULL; ++p) - if (strcmp(*p, capname) == 0) { - *arrayp = (void*) number; - *indexp = (int)(p - numnames); - return (0); - } - for (p = strnames; *p != NULL; ++p) - if (strcmp(*p, capname) == 0) { - *arrayp = (void*) string; - *indexp = (int)(p - strnames); - return (0); - } - return (-1); -} diff --git a/usr/src/lib/libxcurses/src/tic/ticparse.c b/usr/src/lib/libxcurses/src/tic/ticparse.c deleted file mode 100644 index d1c5d0a473..0000000000 --- a/usr/src/lib/libxcurses/src/tic/ticparse.c +++ /dev/null @@ -1,701 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1996, by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * ticparse.c - * - * Terminal Information Compiler - * - * Copyright 1990, 1992 by Mortice Kern Systems Inc. All rights reserved. - * - * Portions of this code Copyright 1982 by Pavel Curtis. - */ - -#ifdef M_RCSID -#ifndef lint -static char rcsID[] = "$Header: /rd/src/tic/rcs/ticparse.c 1.22 1995/06/27 14:56:46 ant Exp $"; -#endif -#endif - -#include "tic.h" -#include <ctype.h> -#include <sys/stat.h> -#include <errno.h> - -extern int get_token ANSI((void)); /* from ticscan.c */ - -char *string_table; -int next_free; /* next free character in string_table */ -int table_size = 0; /* current string_table size */ -int term_names; /* string table offset - current terminal */ -int part2 = 0; /* set to allow old compiled defns to be used */ -int complete = 0; /* 1 if entry done with no forward uses */ - -struct use_item { - long offset; - struct use_item *fptr, *bptr; -}; - -struct use_header { - struct use_item *head, *tail; -}; - -struct use_header use_list = {NULL, NULL}; -int use_count = 0; - -/* - * The use_list is a doubly-linked list with NULLs terminating the lists: - * - * use_item use_item use_item - * --------- --------- --------- - * | | | | | | offset - * |-------| |-------| |-------| - * | ----+-->| ----+-->| NULL | fptr - * |-------| |-------| |-------| - * | NULL |<--+---- |<--+---- | bptr - * --------- --------- --------- - * ^ ^ - * | ------------------ | - * | | | | | - * +--+---- | ----+---+ - * | | | - * ------------------ - * head tail - * use_list - * - */ - -char bad_start[] = m_textstr( - 3107, "File does not start with terminal names in column one", "E" -); -char not_names[] = m_textstr(3108, "Token after a seek not NAMES", "E"); -char use_links[] = m_textstr(3109, "\ -\n\ -Error in following up use-links. Either there is\n\ -a loop in the links or they reference non-existant\n\ -terminals. The following is a list of the entries\n\ -involved:\n\n\ -", "E"); -char nomem_use_list[] = m_textstr( - 3110, "Not enough memory for use_list element", "E" -); -char long_path[] = m_textstr(3111, "Pathname \"%c/%s\" too long.", "W char term"); -char more_than_one[] = m_textstr( - 3112, "More than one entry defined for \"%s\".\n","W term" -); -char fail_open[] = m_textstr(3113, "Failed to open \"%s\".\n", "E filename"); -char write_err[] = m_textstr(3114, "Error in writing \"%s\".\n", "E filename"); -char synonym[] = m_textstr(3115, "Terminal \"%s\" is a synonym for itself.\n", "W term"); -char fail_link[] = m_textstr(3116, "Failed to link \"%s\" to \"%s\".\n", "E file1 file2"); -char name_check[] = m_textstr(3117, "\ -compile: Line %d: Illegal terminal name - '%s'\n\ -Terminal names must start with lowercase or digit.\n\ -", "E line_num term"); -char nomem[] = m_textstr(3118, "Failed to allocated memory.\n", "E"); -char unknown_term[] = m_textstr(202, "Unknown terminal \"%s\".\n", "E term"); -char no_terminfo[] = m_textstr(203, "No terminfo database.\n", "E"); -char unknown_cap[] = m_textstr(3119, "Unknown capability '%s'.", "E action"); -char unknown_token[] = m_textstr(3120, "Unknown token type.", "W"); -char wrong_type[] = m_textstr(3121, "Wrong type used for capability \"%s\".", "W type"); - - -/*f - * debugging routine to dump list - */ -STATIC int -dump_list(str) -char *str; -{ - struct use_item *ptr; - char line[512]; - - fprintf(stderr, "dump_list %s\n", str); - for (ptr = use_list.head; ptr != NULL; ptr = ptr->fptr) - { - fseek(stdin, ptr->offset, 0); - fgets(line, 1024, stdin); - fprintf(stderr, "ptr %x off %d bptr %x fptr %x str %s", - ptr, ptr->offset, ptr->bptr, ptr->fptr, line); - } - fprintf(stderr, "\n"); -} - - -/*f - * Generate an error message if given name does not begin with a - * digit or lower-case letter. - */ -STATIC int -check_name(name) -char *name; -{ - if (!isdigit(name[0]) && !isalpha(name[0])) { - fprintf(stderr, m_strmsg(name_check), curr_line, name); - exit(1); - } -} - -/*f - * Test whether this machine will need byte-swapping - */ -STATIC int -must_swap() -{ - union { - short num; - char byte[2]; - } test; - test.num = 1; - return (test.byte[1]); -} - - -/*f - * Put a record of the given offset onto the use-list. - */ -STATIC int -enqueue(offset) -long offset; -{ - struct use_item *item; - - item = (struct use_item *) malloc(sizeof(struct use_item)); - - if (item == NULL) - syserr_abort(m_strmsg(nomem_use_list)); - - item->offset = offset; - - if (use_list.head != NULL) - { - item->bptr = use_list.tail; - use_list.tail->fptr = item; - item->fptr = NULL; - use_list.tail = item; - } - else - { - use_list.tail = use_list.head = item; - item->fptr = item->bptr = NULL; - } - - use_count ++; -} - - - -/*f - * remove the pointed-to item from the use_list - */ -STATIC int -dequeue(ptr) -struct use_item *ptr; -{ - if (ptr->fptr == NULL) - use_list.tail = ptr->bptr; - else - (ptr->fptr)->bptr = ptr->bptr; - - if (ptr->bptr == NULL) - use_list.head = ptr->fptr; - else - (ptr->bptr)->fptr = ptr->fptr; - - use_count --; -} - - - -/*f - * Write out the compiled entry to the given file. - * Return 0 if OK or -1 if not. - */ -STATIC int -write_object(fp) -FILE *fp; -{ - int i, tlength; - __t_term_header header; - char *tnames, zero = '\0'; - - tnames = string_table + term_names; - tlength = strlen(tnames) + 1; - if (TERM_NAMES_LENGTH < tlength) - tlength = TERM_NAMES_LENGTH; - if (must_swap()) { - header.magic = swap(TERMINFO_MAGIC); - header.name_size = swap(tlength); - header.bool_count = swap(BOOLCOUNT); - header.num_count = swap(NUMCOUNT); - header.str_count = swap(STRCOUNT); - header.str_size = swap(next_free); - } else { - header.magic = TERMINFO_MAGIC; - header.name_size = tlength; - header.bool_count = BOOLCOUNT; - header.num_count = NUMCOUNT; - header.str_count = STRCOUNT; - header.str_size = next_free; - } - - if (fwrite(&header, sizeof (header), 1, fp) != 1 - || fwrite(tnames, sizeof (char), tlength, fp) != tlength - || fwrite(boolean, sizeof (char), BOOLCOUNT, fp) != BOOLCOUNT) - return (-1); - - if ((tlength+BOOLCOUNT) % 2 != 0 - && fwrite(&zero, sizeof (char), 1, fp) != 1) - return (-1); - - if (must_swap()) { - for (i = 0; i < NUMCOUNT; ++i) - number[i] = swap(number[i]); - for (i = 0; i < STRCOUNT; ++i) - string[i] = swap(string[i]); - } - - if (fwrite(number, sizeof (short), NUMCOUNT, fp) != NUMCOUNT - || fwrite(string, sizeof (short), STRCOUNT, fp) != STRCOUNT - || fwrite(string_table, sizeof (char), next_free, fp) != next_free) - return (-1); - return (0); -} - - - -/*f - * Save the compiled version of a description in the filesystem. - * - * make a copy of the name-list - * break it up into first-name and all-but-last-name - * creat(first-name) - * write object information to first-name - * close(first-name) - * for each name in all-but-last-name - * link to first-name - * - */ -STATIC void -dump_structure() -{ - FILE *fp; - struct stat sb; - char *p, *q, *first, *fn, *long_name, dir[2], tname[TERM_NAMES_LENGTH]; - - /* Bag copy of terminal name list. Parse off the last name, - * which should be the terminal's long name. Parse off the - * first name to be used for the terminal filename. - */ - (void) strncpy(tname, string_table + term_names, TERM_NAMES_LENGTH); - DEBUG(7, "Terminal names are \"%s\".\n", tname); - for (p = tname + strlen(tname); tname < p; --p) { - if (*p == '|') { - long_name = ++p; - break; - } - } - if (tname == p) - long_name = tname; - for (p = tname; p < long_name; ++p) { - if (*p == '|') { - if (tname < p) - *p++ = '\0'; - break; - } - } - if (check_only) { - DEBUG(1, "Checked \"%s\".\n", tname); - return; - } - DEBUG(7, "Terminfo file name is \"%s\".\n", tname); - DEBUG(7, "Terminal's long name is \"%s\".\n", long_name); - - /* Create terminfo object file. */ - check_name(tname); - *dir = tolower(*tname); - dir[1] = '\0'; - first = m_pathcat(dir, tname); - if (first == NULL) - err_abort(m_strmsg(long_path), *tname, tname); - if (0 <= stat(first, &sb) && start_time <= sb.st_mtime) - warning(m_strmsg(more_than_one), tname); - if (access(first, W_OK) == -1 && errno != ENOENT) { - perror(first); - err_abort(m_strmsg(write_err), first); - } - (void) unlink(first); - if ((fp = fopen(first, "w")) == NULL) - err_abort(m_strmsg(fail_open), first); - DEBUG(1, "Created \"%s\".\n", first); - if (write_object(fp) < 0) - err_abort(m_strmsg(write_err), first); - (void) fclose(fp); - - /* Create links for alternate names. */ - while (p < long_name) { - for (q = p; p < long_name; ++p) { - if (*p == '|') { - *p++ = '\0'; - break; - } - } - check_name(q); - *dir = tolower(*q); - dir[1] = '\0'; - fn = m_pathcat(dir, q); - if (fn == NULL) { - warning(m_strmsg(long_path), *q, q); - continue; - } - if (strcmp(q, tname) == 0) { - warning(m_strmsg(synonym), tname); - continue; - } - if (0 <= stat(fn, &sb) && start_time <= sb.st_mtime) { - warning(m_strmsg(more_than_one), q); - continue; - } - if (access(fn, W_OK) == -1 && errno != ENOENT) { - err_abort(m_strmsg(write_err), fn); - } - (void) unlink(fn); - if (link(first, fn) < 0) { - if ((fp = fopen(fn, "w")) == NULL) - err_abort(m_strmsg(fail_open), fn); - DEBUG(1, "Created \"%s\".\n", fn); - if (write_object(fp) < 0) - err_abort(m_strmsg(write_err), fn); - (void) fclose(fp); - } else { - DEBUG(1, "Linked \"%s\".\n", fn); - } - free(fn); - } - free(first); -} - - -/*f - * copy string into next free part of string_table, doing a realloc() - * if necessary. return offset of beginning of string from start of - * string_table. - */ -STATIC int -save_str(string) -char *string; -{ - int old_next_free = next_free; - - if (table_size == 0) - { - if ((string_table = malloc(1024)) == NULL) - syserr_abort(m_strmsg(nomem)); - table_size = 1024; - DEBUG(5, "Made initial string table allocation. Size is %d\n", - table_size); - } - - while (table_size < next_free + strlen(string)) - { - if ((string_table = realloc(string_table, table_size + 1024)) - == NULL) - syserr_abort(m_strmsg(nomem)); - table_size += 1024; - DEBUG(5, "Extended string table. Size now %d\n", table_size); - } - - strcpy(&string_table[next_free], string); - DEBUG(7, "Saved string '%s' ", string); - DEBUG(7, "at location %d\n", next_free); - next_free += strlen(string) + 1; - - return (old_next_free); -} - -/*f - * Merge the compiled file whose name is in cur_token.valstring - * with the current entry. - * - * if it's a forward use-link - * if item_ptr == NULL - * queue it up for later handling - * else - * ignore it (we're already going through the queue) - * else it's a backward use-link - * read in the object file for that terminal - * merge contents with current structure - * - * Returned value is 0 if it was a backward link and we - * successfully read it in, -1 if a forward link. - */ -STATIC int -handle_use(item_ptr, entry_offset) -struct use_item *item_ptr; -long entry_offset; -{ - int i, err; - struct stat sb; - char *filename, dir[2]; - - check_name(curr_token.tk_valstring); - *dir = tolower(*curr_token.tk_valstring); - dir[1] = '\0'; - filename = m_pathcat(dir, curr_token.tk_valstring); - if (filename == NULL) { - err_abort( - m_strmsg(long_path), - *curr_token.tk_valstring, curr_token.tk_valstring - ); - } - if (stat(filename, &sb) < 0 - || (part2 == 0 && sb.st_mtime < start_time)) { - DEBUG(2, "Forward USE to %s", curr_token.tk_valstring); - if (item_ptr == NULL) { - DEBUG(2, " (enqueued)\n", ""); - enqueue(entry_offset); - } else { - DEBUG(2, " (skipped)\n", ""); - } - free(filename); - return (-1); - } - DEBUG(2, "Backward USE to %s\n", curr_token.tk_valstring); - (void) setupterm(curr_token.tk_valstring, STDOUT_FILENO, &err); - switch (err) { - case 1: - for (i = 0; i < BOOLCOUNT; ++i) { - if (boolean[i] == 0 && cur_term->Booleans[i]) - boolean[i] = 1; - } - for (i = 0; i < NUMCOUNT; ++i) { - if (number[i] == -1 && cur_term->Numbers[i] != -1) - number[i] = cur_term->Numbers[i]; - } - for (i = 0; i < STRCOUNT; ++i) { - if (string[i] == -1 && cur_term->Strings[i] != NULL) - string[i] = save_str(cur_term->Strings[i]); - } - (void) del_curterm(cur_term); - free(filename); - break; - case 0: - err_abort(m_strmsg(unknown_term), filename); - exit(BAD_TERMINAL); - case -1: - err_abort(m_strmsg(no_terminfo)); - exit(BAD_TERMINAL); - } - return (0); -} - - - -/*f - * Compile one entry. During the first pass, item_ptr is NULL. In pass - * two, item_ptr points to the current entry in the use_list. - * - * found-forward-use = FALSE - * re-initialise internal arrays - * save names in string_table - * get_token() - * while (not EOF and not NAMES) - * if found-forward-use - * do nothing - * else if 'use' - * if handle_use() < 0 - * found-forward-use = TRUE - * else - * check for existance and type-correctness - * enter cap into structure - * if STRING - * save string in string_table - * get_token() - * if ! found-forward-use - * clear CANCELS out of the structure - * dump compiled entry into filesystem - */ -STATIC int -do_entry(item_ptr) -struct use_item *item_ptr; -{ - void *array; - long entry_offset; - int i, index; - register int token_type; - int found_forward_use = 0; - - reset(); - next_free = 0; - - complete = 0; - term_names = save_str(curr_token.tk_name); - DEBUG(2, "Starting '%s'\n", curr_token.tk_name); - entry_offset = curr_file_pos; - - for (token_type = get_token(); - token_type != EOF && token_type != NAMES; - token_type = get_token()) { - if (found_forward_use) { - ; - } else if (strcmp(curr_token.tk_name, "use") == 0) { - if (handle_use(item_ptr, entry_offset) < 0) - found_forward_use = 1; - } else { - if (find(curr_token.tk_name, &array, &index) < 0) { - warning( - m_strmsg(unknown_cap), - curr_token.tk_name - ); - continue; - } - switch (token_type) { - case CANCEL: - if (array == boolean) - boolean[index] = 2; - else - ((short*) array)[index] = -2; - continue; - case BOOLEAN: - if (array == boolean) { - boolean[index] = 1; - continue; - } - break; - case NUMBER: - if (array == number) { - number[index] = curr_token.tk_valnumber; - continue; - } - break; - case STRING: - if (array == string) { - string[index] = save_str( - curr_token.tk_valstring - ); - continue; - } - break; - default: - warning(m_strmsg(unknown_token)); - panic_mode(','); - continue; - } - warning(m_strmsg(wrong_type), curr_token.tk_name); - } - } - if (found_forward_use) - return (token_type); - - /* Changed canceled values into in-active values. */ - for (i = 0; i < BOOLCOUNT; ++i) - if (boolean[i] == 2) - boolean[i] = 0; - for (i = 0; i < NUMCOUNT; ++i) - if (number[i] == -2) - number[i] = -1; - for (i = 0; i < STRCOUNT; ++i) - if (string[i] == -2) - string[i] = -1; - dump_structure(); - complete = 1; - return (token_type); -} - - - -/*f - * Main loop of the compiler. - * - * get_token() - * if curr_token != NAMES - * err_abort() - * while (not at end of file) - * do an entry - */ -void -compile() -{ - char line[1024]; - int token_type; - struct use_item *ptr; - int old_use_count; - - token_type = get_token(); - - if (token_type != NAMES) - err_abort(m_strmsg(bad_start)); - - while (token_type != EOF) - token_type = do_entry(NULL); - - DEBUG(2, "Starting handling of forward USE's\n", ""); - - for (part2=0; part2<2; part2++) { - old_use_count = -1; - - DEBUG(2, "\n\nPART %d\n\n", part2); - - while (use_list.head != NULL && old_use_count != use_count) - { - old_use_count = use_count; - for (ptr = use_list.tail; ptr != NULL; ptr = ptr->bptr) - { - fseek(stdin, ptr->offset, 0); - reset_input(); - if ((token_type = get_token()) != NAMES) - syserr_abort(m_strmsg(not_names)); - (void) do_entry(ptr); - if (complete) - dequeue(ptr); - } - - for (ptr = use_list.head; ptr != NULL; ptr = ptr->fptr) - { - fseek(stdin, ptr->offset, 0); - reset_input(); - if ((token_type = get_token()) != NAMES) - syserr_abort(m_strmsg(not_names)); - (void) do_entry(ptr); - if (complete) - dequeue(ptr); - } - - DEBUG(2,"Finished a pass through enqueued forward USE's\n",""); - } - } - - if (use_list.head != NULL) { - fprintf(stderr, use_links); - for (ptr = use_list.head; ptr != NULL; ptr = ptr->fptr) { - fseek(stdin, ptr->offset, 0); - fgets(line, 1024, stdin); - fprintf(stderr, "%s", line); - } - exit(1); - } -} diff --git a/usr/src/lib/libxcurses/src/tic/ticscan.c b/usr/src/lib/libxcurses/src/tic/ticscan.c deleted file mode 100644 index ad16baf407..0000000000 --- a/usr/src/lib/libxcurses/src/tic/ticscan.c +++ /dev/null @@ -1,417 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1996, by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * ticscan.c Terminal Information Compiler - * - * Copyright 1990, 1992 by Mortice Kern Systems Inc. All rights reserved. - * - * Portions of this code Copyright 1982 by Pavel Curtis. - * - */ - -#ifdef M_RCSID -#ifndef lint -static char rcsID[] = "$Header: /rd/src/tic/rcs/ticscan.c 1.13 1994/02/08 20:19:29 rog Exp $"; -#endif -#endif - -#include "tic.h" -#include <limits.h> -#include <ctype.h> - -#define iswhite(ch) (ch == ' ' || ch == '\t') - - -token curr_token; -long curr_file_pos; -int curr_column = -1; -char line[LINE_MAX+1]; -static int first_column; /* See 'next_char()' below */ - -STATIC int next_char ANSI((void)); -STATIC int trans_string ANSI((char *)); -STATIC int escape ANSI((int)); -STATIC void backspace ANSI((void)); - -char early_eof[] = m_textstr(3122, "Premature EOF", "E"); -char nl_middle[] = m_textstr(3123, "Newline in middle of terminal name", "E"); -char ill_char[] = m_textstr(3124, "Illegal character - '%c'", "E char"); -char ill_ctrl[] = m_textstr(3125, "Illegal control character - '%c'", "E char"); -char off_beg[] = m_textstr(3126, "Backspaced off beginning of line", "E"); -char no_comma[] = m_textstr(3127, "Missing comma", "E"); -char very_long[] = m_textstr(3128, "Very long string found. Missing comma?", "E"); -char token_msg[] = m_textstr(3129, "Token: ", "I"); -char bool_msg[] = m_textstr(3130, "Boolean; name='%s'\n", "I string"); -char num_msg[] = m_textstr(3131, "Number; name='%s', value=%d\n", "I name value"); -char str_msg[] = m_textstr(3132, "String; name='%s', value='%s'\n", "I name value"); -char cancel[] = m_textstr(3133, "Cancel; name='%s'\n", "I name"); -char names[] = m_textstr(3134, "Names; value='%s'\n", "I value"); -char eof_msg[] = m_textstr(3135, "End of file.\n", "I"); -char bad_token[] = m_textstr(3136, "Bad token type", "E"); - - -/*f - * Scans the input for the next token, storing the specifics in the - * global structure 'curr_token' and returning one of the following: - * - * NAMES A line beginning in column 1. 'name' - * will be set to point to everything up to - * but not including the first comma on the line. - * BOOLEAN An entry consisting of a name followed by - * a comma. 'name' will be set to point to the - * name of the capability. - * NUMBER An entry of the form - * name#digits, - * 'name' will be set to point to the capability - * name and 'valnumber' to the number given. - * STRING An entry of the form - * name=characters, - * 'name' is set to the capability name and - * 'valstring' to the string of characters, with - * input translations done. - * CANCEL An entry of the form - * name@, - * 'name' is set to the capability name and - * 'valnumber' to -1. - * EOF The end of the file has been reached. - */ -int -get_token() -{ - long number; - int type; - int ch; - static char buffer[1024]; - register char *ptr; - int dot_flag = 0; - - while ((ch = next_char()) == '\n' || iswhite(ch)) { - ; - } - - if (ch == EOF) - type = EOF; - else - { - if (ch == '.') - { - dot_flag = 1; - - while ((ch = next_char()) == ' ' || ch == '\t') - ; - } - - if (! isalnum(ch)) { - warning(m_strmsg(ill_char), ch); - panic_mode(','); - } - - ptr = buffer; - *(ptr++) = ch; - - if (first_column) - { - while ((ch = next_char()) != ',' && ch != '\n' && ch != EOF) - *(ptr++) = ch; - - if (ch == EOF) - err_abort(m_strmsg(early_eof)); - else if (ch == '\n') { - warning(m_strmsg(nl_middle)); - panic_mode(','); - } - - *ptr = '\0'; - curr_token.tk_name = buffer; - type = NAMES; - } - else - { - ch = next_char(); - while (isalnum(ch)) - { - *(ptr++) = ch; - ch = next_char(); - } - - *ptr++ = '\0'; - switch (ch) - { - case ',': - curr_token.tk_name = buffer; - type = BOOLEAN; - break; - - case '@': - if (next_char() != ',') - warning(m_strmsg(no_comma)); - curr_token.tk_name = buffer; - type = CANCEL; - break; - - case '#': - number = 0; - while (isdigit(ch = next_char())) - number = number * 10 + ch - '0'; - if (ch != ',') - warning(m_strmsg(no_comma)); - curr_token.tk_name = buffer; - curr_token.tk_valnumber = number; - type = NUMBER; - break; - - case '=': - ch = trans_string(ptr); - if (ch != ',') - warning(m_strmsg(no_comma)); - curr_token.tk_name = buffer; - curr_token.tk_valstring = ptr; - type = STRING; - break; - - default: - warning(m_strmsg(ill_char), ch); - } - } /* end else (first_column == 0) */ - } /* end else (ch != EOF) */ - - if (dot_flag == 1) - DEBUG(8, "Commented out ", ""); - - if (debug_level >= 8) - { - fprintf(stderr, m_strmsg(token_msg)); - switch (type) - { - case BOOLEAN: - fprintf(stderr, m_strmsg(bool_msg), curr_token.tk_name); - break; - - case NUMBER: - fprintf( - stderr, m_strmsg(num_msg), - curr_token.tk_name, curr_token.tk_valnumber - ); - break; - - case STRING: - fprintf( - stderr, m_strmsg(str_msg), - curr_token.tk_name, curr_token.tk_valstring - ); - break; - - case CANCEL: - fprintf(stderr, m_strmsg(cancel), curr_token.tk_name); - break; - - case NAMES: - fprintf(stderr, m_strmsg(names), curr_token.tk_name); - break; - - case EOF: - fprintf(stderr, m_strmsg(eof_msg)); - break; - - default: - warning(m_strmsg(bad_token)); - } - } - - if (dot_flag == 1) /* if commented out, use the next one */ - type = get_token(); - - return(type); -} - - -/*f - * Returns the next character in the input stream. Comments and leading - * white space are stripped. The global state variable 'firstcolumn' is - * set TRUE if the character returned is from the first column of the input - * line. The global variable curr_line is incremented for each new line. - * The global variable curr_file_pos is set to the file offset of the - * beginning of each line. - */ -STATIC int -next_char() -{ - char *rtn_value; - - if (curr_column < 0 || LINE_MAX < curr_column - || line[curr_column] == '\0') { - do { - curr_file_pos = ftell(stdin); - if ((rtn_value = fgets(line, LINE_MAX, stdin)) != NULL) - curr_line++; - } while (rtn_value != NULL && line[0] == '#'); - - if (rtn_value == NULL) - return (EOF); - - curr_column = 0; - while (iswhite(line[curr_column])) - curr_column++; - } - first_column = curr_column == 0 && *line != '\n'; - return (line[curr_column++]); -} - - -/*f - * go back one character - */ -STATIC void -backspace() -{ - curr_column--; - - if (curr_column < 0) - syserr_abort(m_strmsg(off_beg)); -} - - -/*f - * Resets the input-reading routines. Used after a seek has been done. - */ -void -reset_input() -{ - curr_column = -1; -} - -/*f - * Reads characters using next_char() until encountering a comma, newline - * or end-of-file. The returned value is the character which caused - * reading to stop. The following translations are done on the input: - * - * ^X goes to ctrl-X (i.e. X & 037) - * {backslash-E,backslash-n,backslash-r,backslash-b, - * backslash-t,backslash-f} go to - * {ESCAPE,newline,carriage-return,backspace,tab,formfeed} - * {backslash-^,backslash-backslash} go to {carat,backslash} - * backslash-ddd (for ddd = up to three octal digits) goes to - * the character ddd - * - * backslash-e == backslash-E - * backslash-0 == backslash-200 - */ -STATIC int -trans_string(ptr) -char *ptr; -{ - int i, number, ch; - register int count = 0; - - while ((ch = next_char()) != ',' && ch != EOF) { - if (ch == '^') { - ch = next_char(); - if (ch == EOF) - err_abort(m_strmsg(early_eof)); - if (!isprint(ch)) - warning(m_strmsg(ill_ctrl), ch); - *(ptr++) = ch & 037; - } else if (ch == '\\') { - /* Try to read a three character octal number. */ - for (number = i = 0; i < 3; ++i) { - ch = next_char(); - if (ch == EOF) - err_abort(m_strmsg(early_eof)); - if (ch < '0' || '7' < ch) { - backspace(); - break; - } - number = number * 8 + ch - '0'; - } - if (0 < i) { - /* Read an octal number. */ - *ptr++ = number == 0 ? 0200 : (char) number; - } else { - /* Escape mapping translation. */ - ch = escape(next_char()); - *ptr++ = ch; - } - } else { - *(ptr++) = ch; - } - if (500 < ++count) - warning(m_strmsg(very_long)); - } - *ptr = '\0'; - return (ch); -} - -/*f - * Panic mode error recovery - skip everything until a "ch" is found. - */ -void -panic_mode(ch) -char ch; -{ - int c; - for (;;) { - c = next_char(); - if (c == ch) - return; - if (c == EOF); - return; - } -} - -/*f - * This routine is a codeset independent method of specifying a translation - * from an unambiguous printable form, to an internal binary value. - * This mapping is defined by Table 2-13 in section 2-12 of POSIX.2. - * - * This table has been extended to account for tic/infocmp specification - * of additional characters: <escape>, <space>, <colon>, <caret>, <comma> - * - * Assume that the escape lead-in character has been processed and - * any escaped octal sequence. - */ -STATIC int -escape(c) -int c; -{ - int i; - static int cntl_code[] = { - '\0', '\\', M_ALERT, '\b', '\f', '\n', '\r', '\t', - M_VTAB, M_ESCAPE, M_ESCAPE, ' ', ':', '^', ',', - -1 - }; - static int escape_char[] = { - '\0', '\\', 'a', 'b', 'f', 'n', 'r', 't', - 'v', 'E', 'e', 's', ':', '^', ',', - -1 - }; - for (i = 0; escape_char[i] != -1; ++i) - if (c == escape_char[i]) - return (cntl_code[i]); - return (c); -} diff --git a/usr/src/lib/libxcurses/src/tic/untic.c b/usr/src/lib/libxcurses/src/tic/untic.c deleted file mode 100644 index 15afd667e6..0000000000 --- a/usr/src/lib/libxcurses/src/tic/untic.c +++ /dev/null @@ -1,264 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1996, by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * untic.c CURSES Library - * - * Copyright 1990, 1992 by Mortice Kern Systems Inc. All rights reserved. - * - * Portions of this code Copyright 1982 by Pavel Curtis. - * - */ - -#ifdef M_RCSID -#ifndef lint -static char rcsID[] = "$Header: /rd/src/tic/rcs/untic.c 1.18 1995/06/22 20:04:01 ant Exp $"; -#endif -#endif - -#include <mks.h> -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <stdarg.h> -#include <term.h> -#include <unistd.h> -#include <m_ord.h> - -#ifdef _XOPEN_CURSES -/* - * MKS XCurses to be conforming has to avoid name space pollution - * by using reserved prefixes. Map the pre-XCurses names to the - * new ones. - */ -#define BOOLCOUNT __COUNT_BOOL -#define NUMCOUNT __COUNT_NUM -#define STRCOUNT __COUNT_STR -#define boolnames __m_boolnames -#define boolcodes __m_boolcodes -#define boolfnames __m_boolfnames -#define numnames __m_numnames -#define numcodes __m_numcodes -#define numfnames __m_numfnames -#define strnames __m_strnames -#define strcodes __m_strcodes -#define strfnames __m_strfnames -#define __t_term_header terminfo_header_t -#define TERMINFO_MAGIC __TERMINFO_MAGIC -#define Booleans _bool -#define Numbers _num -#define Strings _str -#define term_names _names -#endif - -extern char *_cmdname; - -/* Exit Status */ -#define SUCCESS 0 -#define NOT_DEFINED 1 -#define USAGE 2 -#define BAD_TERMINAL 3 -#define NOT_VALID 4 -#define ERROR 5 - -STATIC char *escape ANSI((int)); -STATIC void error ANSI((char *, ...)); /* GENTEXT: error */ -STATIC void untic ANSI((TERMINAL *)); - -char **Bool; -char **Num; -char **Str; - -char usage[] = m_textstr(3137, "usage: %s [-CILV] [term_name ...]\n", "U _"); -char version[] = m_textstr( - 3138, "%s - Display compiled terminfo database entry. Oct 92\n", "I _" -); - - -int -main(argc, argv) -int argc; -char **argv; -{ - int err; - char *ap, **av = argv; - setlocale(LC_ALL, ""); - _cmdname = *argv; - Bool = boolnames; - Num = numnames; - Str = strnames; - for (--argc, ++argv; 0 < argc && **argv == '-'; --argc, ++argv) { - ap = &argv[0][1]; - if (*ap == '-' && ap[1] == '\0') { - --argc; - ++argv; - break; - } - while (*ap != '\0') { - switch (*ap++) { - case 'C': - Bool = boolcodes; - Num = numcodes; - Str = strcodes; - break; - case 'I': - Bool = boolnames; - Num = numnames; - Str = strnames; - break; - case 'L': - Bool = boolfnames; - Num = numfnames; - Str = strfnames; - break; - case 'V': - (void) fprintf( - stderr, m_strmsg(version), _cmdname - ); - break; - default: - (void) fprintf( - stderr, m_strmsg(usage), _cmdname - ); - return (USAGE); - } - break; - } - } - if (argc <= 0) { - if ((ap = getenv("TERM")) == NULL) { - (void) fprintf(stderr, m_strmsg(usage), _cmdname); - return (USAGE); - } - /* Assume that, even if there were no parameters, space - * for argv[0] (the command name) and argv[1] (NULL) would - * have been put aside. We can use this space to fake a - * a single default parameter. - */ - argc = 1; - argv[0] = ap; - argv[1] = NULL; - - } - use_env(0); - for (; 0 < argc; --argc, ++argv) { - (void) setupterm(*argv, STDOUT_FILENO, &err); - switch (err) { - case 1: - untic(cur_term); - (void) del_curterm(cur_term); - break; - case 0: - error( - m_textmsg(202, "Unknown terminal \"%s\".\n", "E term"), - *argv - ); - return (BAD_TERMINAL); - case -1: - error(m_textmsg(203, "No terminfo database.\n", "E")); - return (BAD_TERMINAL); - } - } - return (SUCCESS); -} - -/*f - * Dump the contents of a compiled terminfo file into a - * human readable format. - */ -STATIC void -untic(tp) -TERMINAL *tp; -{ - int i; - char *p; - (void) printf("%s,\n", tp->term_names); - for (i = 0; i < BOOLCOUNT; ++i) { - if (tp->Booleans[i]) - (void) printf("\t%s,\n", Bool[i]); - } - for (i = 0; i < NUMCOUNT; ++i) { - if (tp->Numbers[i] != -1) - (void) printf("\t%s#%d,\n", Num[i],tp->Numbers[i]); - } - for (i = 0; i < STRCOUNT; ++i) { - if (tp->Strings[i] != NULL) { - (void) printf("\t%s=", Str[i]); - for (p = tp->Strings[i]; *p != '\0'; ++p) - (void) fputs(escape(*p), stdout); - (void) fputs(",\n", stdout); - } - } - (void) putchar('\n'); -} - -/*f - * Display error message. - */ -STATIC void -error VARARG1(char*, fmt) -{ - va_list ap; - (void) fprintf(stderr, "%s: ", _cmdname); - va_start(ap, fmt); - (void) vfprintf(stderr, fmt, ap); - va_end(ap); -} - -/*f - * This routine is a codeset independent method of specifying a translation - * from an internal binary value, to an unambiguous printable format. - * This mapping is defined by Table 2-13 in section 2-12 of POSIX.2. - * - * This table has been extended to account for tic/infocmp specification - * of additional characters: <escape>, <space>, <colon>, <caret>, <comma> - */ -char * -escape(c) -int c; -{ - int i; - static char buf[5]; - static int cntl_code[] = { - '\0', '\\', M_ALERT, '\b', '\f', '\n', '\r', '\t', - M_VTAB, M_ESCAPE, ' ', ':', '^', ',', - -1 - }; - static char *cntl_str[] = { - "\\0", "\\\\", "\\a", "\\b", "\\f", "\\n", "\\r", "\\t", - "\\v", "\\E", "\\s", "\\:", "\\^", "\\," - }; - for (i = 0; cntl_code[i] != -1; ++i) - if (c == cntl_code[i]) - return (cntl_str[i]); - if (!isprint(c)) - (void) sprintf(buf, "\\%03.3o", (unsigned char) c); - else - buf[0] = c, buf[1] = '\0'; - return (buf); -} |