xref: /onnv-gate/usr/src/tools/cscope-fast/global.h (revision 13093:48f2dbca79a2)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*13093SRoger.Faulkner@Oracle.COM  * Common Development and Distribution License (the "License").
6*13093SRoger.Faulkner@Oracle.COM  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
21*13093SRoger.Faulkner@Oracle.COM 
22*13093SRoger.Faulkner@Oracle.COM /*
23*13093SRoger.Faulkner@Oracle.COM  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
24*13093SRoger.Faulkner@Oracle.COM  */
25*13093SRoger.Faulkner@Oracle.COM 
260Sstevel@tonic-gate /*	Copyright (c) 1988 AT&T	*/
270Sstevel@tonic-gate /*	  All Rights Reserved  	*/
280Sstevel@tonic-gate 
290Sstevel@tonic-gate /*
300Sstevel@tonic-gate  *	cscope - interactive C symbol cross-reference
310Sstevel@tonic-gate  *
320Sstevel@tonic-gate  *	global type, data, and function definitions
330Sstevel@tonic-gate  */
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #include <ctype.h>	/* isalpha, isdigit, etc. */
360Sstevel@tonic-gate #include <signal.h>	/* SIGINT and SIGQUIT */
370Sstevel@tonic-gate #include <stdio.h>	/* standard I/O package */
380Sstevel@tonic-gate #include <sys/types.h>
390Sstevel@tonic-gate #include "constants.h"	/* misc. constants */
400Sstevel@tonic-gate #include "invlib.h"	/* inverted index library */
410Sstevel@tonic-gate #include "library.h"	/* library function return values */
420Sstevel@tonic-gate #include "mouse.h"	/* mouse interface */
430Sstevel@tonic-gate #define	SIGTYPE void
440Sstevel@tonic-gate 
450Sstevel@tonic-gate typedef	enum	{		/* boolean data type */
460Sstevel@tonic-gate 	NO,
470Sstevel@tonic-gate 	YES
480Sstevel@tonic-gate } BOOL;
490Sstevel@tonic-gate 
500Sstevel@tonic-gate typedef	enum	{		/* findinit return code */
510Sstevel@tonic-gate 	NOERROR,
520Sstevel@tonic-gate 	NOTSYMBOL,
530Sstevel@tonic-gate 	REGCMPERROR
540Sstevel@tonic-gate } FINDINIT;
550Sstevel@tonic-gate 
560Sstevel@tonic-gate typedef	struct	history	{		/* command history */
570Sstevel@tonic-gate 	int	field;
580Sstevel@tonic-gate 	char	*text;
590Sstevel@tonic-gate 	struct	history *previous;
600Sstevel@tonic-gate 	struct	history *next;
610Sstevel@tonic-gate } HISTORY;
620Sstevel@tonic-gate 
630Sstevel@tonic-gate typedef	enum	{			/* keyword type */
640Sstevel@tonic-gate 	DECL,	/* type declaration */
650Sstevel@tonic-gate 	FLOW,	/* control flow (do, if, for, while, switch, etc.) */
660Sstevel@tonic-gate 	MISC	/* misc.: sizeof or table placeholder for compression */
670Sstevel@tonic-gate } KEYWORD;
680Sstevel@tonic-gate 
690Sstevel@tonic-gate /* digraph data for text compression */
700Sstevel@tonic-gate extern	char	dichar1[];	/* 16 most frequent first chars */
710Sstevel@tonic-gate extern	char	dichar2[];	/* 8 most frequent second chars */
720Sstevel@tonic-gate 				/* using the above as first chars */
730Sstevel@tonic-gate extern	char	dicode1[];	/* digraph first character code */
740Sstevel@tonic-gate extern	char	dicode2[];	/* digraph second character code */
750Sstevel@tonic-gate 
760Sstevel@tonic-gate /* main.c global data */
770Sstevel@tonic-gate extern	char	*editor, *home, *shell;	/* environment variables */
780Sstevel@tonic-gate extern	BOOL	compress;	/* compress the characters in the crossref */
790Sstevel@tonic-gate extern	int	cscopedepth;	/* cscope invocation nesting depth */
800Sstevel@tonic-gate extern	char	currentdir[];	/* current directory */
810Sstevel@tonic-gate extern	BOOL	dbtruncated;	/* database symbols are truncated to 8 chars */
820Sstevel@tonic-gate extern	char	**dbvpdirs;	/* directories (including current) in */
830Sstevel@tonic-gate 				/* database view path */
840Sstevel@tonic-gate extern	int	dbvpndirs;	/* number of directories in database */
850Sstevel@tonic-gate 				/* view path */
860Sstevel@tonic-gate extern	int	dispcomponents;	/* file path components to display */
870Sstevel@tonic-gate extern	BOOL	editallprompt;	/* prompt between editing files */
880Sstevel@tonic-gate extern	int	fileargc;	/* file argument count */
890Sstevel@tonic-gate extern	char	**fileargv;	/* file argument values */
900Sstevel@tonic-gate extern	int	fileversion;	/* cross-reference file version */
910Sstevel@tonic-gate extern	BOOL	incurses;	/* in curses */
920Sstevel@tonic-gate extern	INVCONTROL invcontrol;	/* inverted file control structure */
930Sstevel@tonic-gate extern	BOOL	invertedindex;	/* the database has an inverted index */
940Sstevel@tonic-gate extern	BOOL	isuptodate;	/* consider the crossref up-to-date */
950Sstevel@tonic-gate extern	BOOL	linemode;	/* use line oriented user interface */
960Sstevel@tonic-gate extern	char	*namefile;	/* file of file names */
970Sstevel@tonic-gate extern	char	*newreffile;	/* new cross-reference file name */
980Sstevel@tonic-gate extern	FILE	*newrefs;	/* new cross-reference */
990Sstevel@tonic-gate extern	BOOL	noacttimeout;	/* no activity timeout occurred */
1000Sstevel@tonic-gate extern	BOOL	ogs;		/* display OGS book and subsystem names */
1010Sstevel@tonic-gate extern	FILE	*postings;	/* new inverted index postings */
1020Sstevel@tonic-gate extern	char	*prependpath;	/* prepend path to file names */
1030Sstevel@tonic-gate extern	BOOL	returnrequired;	/* RETURN required after selection number */
1040Sstevel@tonic-gate extern	int	symrefs;	/* cross-reference file */
1050Sstevel@tonic-gate extern	char	temp1[];	/* temporary file name */
1060Sstevel@tonic-gate extern	char	temp2[];	/* temporary file name */
1070Sstevel@tonic-gate extern	long	totalterms;	/* total inverted index terms */
1080Sstevel@tonic-gate extern	BOOL	truncatesyms;	/* truncate symbols to 8 characters */
1090Sstevel@tonic-gate 
1100Sstevel@tonic-gate /* command.c global data */
1110Sstevel@tonic-gate extern	BOOL	caseless;	/* ignore letter case when searching */
1120Sstevel@tonic-gate extern	BOOL	*change;	/* change this line */
1130Sstevel@tonic-gate extern	BOOL	changing;	/* changing text */
1140Sstevel@tonic-gate extern	char	newpat[];	/* new pattern */
1150Sstevel@tonic-gate extern	char	pattern[];	/* symbol or text pattern */
1160Sstevel@tonic-gate 
1170Sstevel@tonic-gate /* crossref.c global data */
1180Sstevel@tonic-gate extern	long	dboffset;	/* new database offset */
1190Sstevel@tonic-gate extern	BOOL	errorsfound;	/* prompt before clearing error messages */
1200Sstevel@tonic-gate extern	long	fileindex;	/* source file name index */
1210Sstevel@tonic-gate extern	long	lineoffset;	/* source line database offset */
1220Sstevel@tonic-gate extern	long	npostings;	/* number of postings */
1230Sstevel@tonic-gate extern	int	symbols;	/* number of symbols */
1240Sstevel@tonic-gate 
1250Sstevel@tonic-gate /* dir.c global data */
1260Sstevel@tonic-gate extern	char	**incdirs;	/* #include directories */
1270Sstevel@tonic-gate extern	char	**srcdirs;	/* source directories */
1280Sstevel@tonic-gate extern	char	**srcfiles;	/* source files */
1290Sstevel@tonic-gate extern	int	nincdirs;	/* number of #include directories */
1300Sstevel@tonic-gate extern	int	nsrcdirs;	/* number of source directories */
1310Sstevel@tonic-gate extern	int	nsrcfiles;	/* number of source files */
1320Sstevel@tonic-gate extern	int	msrcfiles;	/* maximum number of source files */
1330Sstevel@tonic-gate 
1340Sstevel@tonic-gate /* display.c global data */
1350Sstevel@tonic-gate extern	int	*displine;	/* screen line of displayed reference */
1360Sstevel@tonic-gate extern	int	disprefs;	/* displayed references */
1370Sstevel@tonic-gate extern	int	field;		/* input field */
1380Sstevel@tonic-gate extern	unsigned fldcolumn;	/* input field column */
1390Sstevel@tonic-gate extern	int	mdisprefs;	/* maximum displayed references */
1400Sstevel@tonic-gate extern	int	selectlen;		/* selection number field length */
1410Sstevel@tonic-gate extern	int	nextline;	/* next line to be shown */
1420Sstevel@tonic-gate extern	int	topline;	/* top line of page */
1430Sstevel@tonic-gate extern	int	bottomline;	/* bottom line of page */
1440Sstevel@tonic-gate extern	int	totallines;	/* total reference lines */
1450Sstevel@tonic-gate extern	FILE	*refsfound;	/* references found file */
1460Sstevel@tonic-gate extern	FILE	*nonglobalrefs;	/* non-global references file */
1470Sstevel@tonic-gate 
1480Sstevel@tonic-gate /* exec.c global data */
1490Sstevel@tonic-gate extern	pid_t	childpid;	/* child's process ID */
1500Sstevel@tonic-gate 
1510Sstevel@tonic-gate /* find.c global data */
1520Sstevel@tonic-gate extern	char	block[];	/* cross-reference file block */
1530Sstevel@tonic-gate extern	int	blocklen;	/* length of disk block read */
1540Sstevel@tonic-gate extern	char	blockmark;	/* mark character to be searched for */
1550Sstevel@tonic-gate extern	long	blocknumber;	/* block number */
1560Sstevel@tonic-gate extern	char	*blockp;	/* pointer to current character in block */
1570Sstevel@tonic-gate extern	char	lastfilepath[];	/* last file that full path was computed for */
1580Sstevel@tonic-gate 
1590Sstevel@tonic-gate /* lookup.c global data */
1600Sstevel@tonic-gate extern	struct	keystruct {
1610Sstevel@tonic-gate 	char	*text;
1620Sstevel@tonic-gate 	char	delim;
1630Sstevel@tonic-gate 	KEYWORD	type;
1640Sstevel@tonic-gate 	struct	keystruct *next;
1650Sstevel@tonic-gate } keyword[];
1660Sstevel@tonic-gate 
1670Sstevel@tonic-gate /* scanner.l global data */
1680Sstevel@tonic-gate extern	int	first;		/* buffer index for first char of symbol */
1690Sstevel@tonic-gate extern	int	last;		/* buffer index for last char of symbol */
1700Sstevel@tonic-gate extern	int	lineno;		/* symbol line number */
1710Sstevel@tonic-gate extern	FILE	*yyin;		/* input file descriptor */
1720Sstevel@tonic-gate extern	int	yyleng;		/* input line length */
1730Sstevel@tonic-gate extern	int	yylineno;	/* input line number */
1740Sstevel@tonic-gate #if hpux
1750Sstevel@tonic-gate extern	unsigned char	yytext[];	/* input line text */
1760Sstevel@tonic-gate #else
1770Sstevel@tonic-gate extern	char	yytext[];	/* input line text */
1780Sstevel@tonic-gate #endif
1790Sstevel@tonic-gate 
1800Sstevel@tonic-gate /* vpinit.c global data */
1810Sstevel@tonic-gate extern	char	*argv0;		/* command name */
1820Sstevel@tonic-gate 
1830Sstevel@tonic-gate /* cscope functions called from more than one function or between files */
1840Sstevel@tonic-gate /* cgrep.c */
1850Sstevel@tonic-gate void	egrepcaseless(int i);
1860Sstevel@tonic-gate char	*egrepinit(char *expression);
1870Sstevel@tonic-gate int	egrep(char *f, FILE *o, char *fo);
1880Sstevel@tonic-gate 
1890Sstevel@tonic-gate /* command.c */
1900Sstevel@tonic-gate BOOL	command(int commandc);
1910Sstevel@tonic-gate void	clearprompt(void);
1920Sstevel@tonic-gate BOOL	readrefs(char *filename);
1930Sstevel@tonic-gate BOOL	changestring(void);
1940Sstevel@tonic-gate void	mark(int i);
1950Sstevel@tonic-gate 
1960Sstevel@tonic-gate /* crossref.c */
1970Sstevel@tonic-gate void	crossref(char *srcfile);
1980Sstevel@tonic-gate void	savesymbol(int token);
1990Sstevel@tonic-gate void	putfilename(char *srcfile);
2000Sstevel@tonic-gate void	putposting(char *term, int type);
2010Sstevel@tonic-gate void	putstring(char *s);
2020Sstevel@tonic-gate void	warning(char *text);
2030Sstevel@tonic-gate 
2040Sstevel@tonic-gate /* dir.c */
2050Sstevel@tonic-gate void	sourcedir(char *dirlist);
2060Sstevel@tonic-gate void	includedir(char *dirlist);
2070Sstevel@tonic-gate void	makefilelist(void);
2080Sstevel@tonic-gate void	incfile(char *file, int type);
2090Sstevel@tonic-gate BOOL	infilelist(char *file);
2100Sstevel@tonic-gate void	addsrcfile(char *path);
2110Sstevel@tonic-gate void	freefilelist(void);
2120Sstevel@tonic-gate 
2130Sstevel@tonic-gate /* display.c */
2140Sstevel@tonic-gate void	dispinit(void);
2150Sstevel@tonic-gate void	display(void);
2160Sstevel@tonic-gate void	setfield(void);
2170Sstevel@tonic-gate void	atfield(void);
2180Sstevel@tonic-gate void	jumpback(int sig);
2190Sstevel@tonic-gate BOOL	search(void);
2200Sstevel@tonic-gate BOOL	writerefsfound(void);
2210Sstevel@tonic-gate void	countrefs(void);
2220Sstevel@tonic-gate void	myperror(char *text);
2230Sstevel@tonic-gate void	putmsg(char *msg);
2240Sstevel@tonic-gate void	clearmsg2(void);
2250Sstevel@tonic-gate void	putmsg2(char *msg);
2260Sstevel@tonic-gate void	seekline(int line);
2270Sstevel@tonic-gate void	ogsnames(char *file, char **subsystem, char **book);
2280Sstevel@tonic-gate char	*pathcomponents(char *path, int components);
2290Sstevel@tonic-gate void	strtoupper(char *s);
2300Sstevel@tonic-gate 
2310Sstevel@tonic-gate /* edit.c */
2320Sstevel@tonic-gate void	editref(int i);
2330Sstevel@tonic-gate void	editall(void);
2340Sstevel@tonic-gate void	edit(char *file, char *linenum);
2350Sstevel@tonic-gate 
2360Sstevel@tonic-gate /* find.c */
2370Sstevel@tonic-gate void	findsymbol(void);
2380Sstevel@tonic-gate void	finddef(void);
2390Sstevel@tonic-gate void	findallfcns(void);
2400Sstevel@tonic-gate void	findcalledby(void);
2410Sstevel@tonic-gate void	findcalling(void);
2420Sstevel@tonic-gate void	findassignments(void);
2430Sstevel@tonic-gate char	*findgreppat(void);
2440Sstevel@tonic-gate char	*findegreppat(char *egreppat);
2450Sstevel@tonic-gate void	findfile(void);
2460Sstevel@tonic-gate void	findinclude(void);
2470Sstevel@tonic-gate FINDINIT findinit(void);
2480Sstevel@tonic-gate void	findcleanup(void);
2490Sstevel@tonic-gate void	initprogress(void);
2500Sstevel@tonic-gate void	progress(char *format, long n1, long n2);
2510Sstevel@tonic-gate BOOL	match(void);
2520Sstevel@tonic-gate BOOL	matchrest(void);
2530Sstevel@tonic-gate void	getstring(char *s);
2540Sstevel@tonic-gate char	*scanpast(int c);
2550Sstevel@tonic-gate char	*readblock(void);
2560Sstevel@tonic-gate long	dbseek(long offset);
2570Sstevel@tonic-gate 
2580Sstevel@tonic-gate /* help.c */
2590Sstevel@tonic-gate void	help(void);
2600Sstevel@tonic-gate 
2610Sstevel@tonic-gate /* history.c */
2620Sstevel@tonic-gate void	addcmd(int f, char *s);
2630Sstevel@tonic-gate void	resetcmd(void);
2640Sstevel@tonic-gate HISTORY *currentcmd(void);
2650Sstevel@tonic-gate HISTORY *prevcmd(void);
2660Sstevel@tonic-gate HISTORY *nextcmd(void);
2670Sstevel@tonic-gate 
2680Sstevel@tonic-gate /* input.c */
2690Sstevel@tonic-gate void	catchint(int sig);
2700Sstevel@tonic-gate int	ungetch(int c);
2710Sstevel@tonic-gate int	mygetch(void);
272*13093SRoger.Faulkner@Oracle.COM int	getaline(char s[], size_t size, int firstchar, BOOL iscaseless);
2730Sstevel@tonic-gate void	askforchar(void);
2740Sstevel@tonic-gate void	askforreturn(void);
2750Sstevel@tonic-gate void	shellpath(char *out, int limit, char *in);
2760Sstevel@tonic-gate 
2770Sstevel@tonic-gate /* lookup.c */
2780Sstevel@tonic-gate void	initsymtab(void);
2790Sstevel@tonic-gate struct	keystruct *lookup(char *ident);
2800Sstevel@tonic-gate int	hash(char *s);
2810Sstevel@tonic-gate 
2820Sstevel@tonic-gate /* main.c */
2830Sstevel@tonic-gate void	rebuild(void);
2840Sstevel@tonic-gate void	entercurses(void);
2850Sstevel@tonic-gate void	exitcurses(void);
2860Sstevel@tonic-gate void	myexit(int sig);
2870Sstevel@tonic-gate void	cannotopen(char *file);
2880Sstevel@tonic-gate void	cannotwrite(char *file);
2890Sstevel@tonic-gate 
2900Sstevel@tonic-gate /* menu.c */
2910Sstevel@tonic-gate void	initmenu(void);
2920Sstevel@tonic-gate 
2930Sstevel@tonic-gate extern void initscanner(char *srcfile);
2940Sstevel@tonic-gate extern int yylex(void);
2950Sstevel@tonic-gate extern int execute(char *, ...);
296