xref: /titanic_51/usr/src/tools/cscope-fast/global.h (revision 45e662eb8429b38c18931ebeed30f2e5287ae51b)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
24  */
25 
26 /*	Copyright (c) 1988 AT&T	*/
27 /*	  All Rights Reserved  	*/
28 
29 /*
30  *	cscope - interactive C symbol cross-reference
31  *
32  *	global type, data, and function definitions
33  */
34 
35 #include <ctype.h>	/* isalpha, isdigit, etc. */
36 #include <signal.h>	/* SIGINT and SIGQUIT */
37 #include <stdio.h>	/* standard I/O package */
38 #include <sys/types.h>
39 #include "constants.h"	/* misc. constants */
40 #include "invlib.h"	/* inverted index library */
41 #include "library.h"	/* library function return values */
42 #include "mouse.h"	/* mouse interface */
43 #define	SIGTYPE void
44 
45 typedef	enum	{		/* boolean data type */
46 	NO,
47 	YES
48 } BOOL;
49 
50 typedef	enum	{		/* findinit return code */
51 	NOERROR,
52 	NOTSYMBOL,
53 	REGCMPERROR
54 } FINDINIT;
55 
56 typedef	struct	history	{		/* command history */
57 	int	field;
58 	char	*text;
59 	struct	history *previous;
60 	struct	history *next;
61 } HISTORY;
62 
63 typedef	enum	{			/* keyword type */
64 	DECL,	/* type declaration */
65 	FLOW,	/* control flow (do, if, for, while, switch, etc.) */
66 	MISC	/* misc.: sizeof or table placeholder for compression */
67 } KEYWORD;
68 
69 /* digraph data for text compression */
70 extern	char	dichar1[];	/* 16 most frequent first chars */
71 extern	char	dichar2[];	/* 8 most frequent second chars */
72 				/* using the above as first chars */
73 extern	char	dicode1[];	/* digraph first character code */
74 extern	char	dicode2[];	/* digraph second character code */
75 
76 /* main.c global data */
77 extern	char	*editor, *home, *shell;	/* environment variables */
78 extern	BOOL	compress;	/* compress the characters in the crossref */
79 extern	int	cscopedepth;	/* cscope invocation nesting depth */
80 extern	char	currentdir[];	/* current directory */
81 extern	BOOL	dbtruncated;	/* database symbols are truncated to 8 chars */
82 extern	char	**dbvpdirs;	/* directories (including current) in */
83 				/* database view path */
84 extern	int	dbvpndirs;	/* number of directories in database */
85 				/* view path */
86 extern	int	dispcomponents;	/* file path components to display */
87 extern	BOOL	editallprompt;	/* prompt between editing files */
88 extern	int	fileargc;	/* file argument count */
89 extern	char	**fileargv;	/* file argument values */
90 extern	int	fileversion;	/* cross-reference file version */
91 extern	BOOL	incurses;	/* in curses */
92 extern	INVCONTROL invcontrol;	/* inverted file control structure */
93 extern	BOOL	invertedindex;	/* the database has an inverted index */
94 extern	BOOL	isuptodate;	/* consider the crossref up-to-date */
95 extern	BOOL	linemode;	/* use line oriented user interface */
96 extern	char	*namefile;	/* file of file names */
97 extern	char	*newreffile;	/* new cross-reference file name */
98 extern	FILE	*newrefs;	/* new cross-reference */
99 extern	BOOL	noacttimeout;	/* no activity timeout occurred */
100 extern	BOOL	ogs;		/* display OGS book and subsystem names */
101 extern	FILE	*postings;	/* new inverted index postings */
102 extern	char	*prependpath;	/* prepend path to file names */
103 extern	BOOL	returnrequired;	/* RETURN required after selection number */
104 extern	int	symrefs;	/* cross-reference file */
105 extern	char	temp1[];	/* temporary file name */
106 extern	char	temp2[];	/* temporary file name */
107 extern	long	totalterms;	/* total inverted index terms */
108 extern	BOOL	truncatesyms;	/* truncate symbols to 8 characters */
109 
110 /* command.c global data */
111 extern	BOOL	caseless;	/* ignore letter case when searching */
112 extern	BOOL	*change;	/* change this line */
113 extern	BOOL	changing;	/* changing text */
114 extern	char	newpat[];	/* new pattern */
115 extern	char	pattern[];	/* symbol or text pattern */
116 
117 /* crossref.c global data */
118 extern	long	dboffset;	/* new database offset */
119 extern	BOOL	errorsfound;	/* prompt before clearing error messages */
120 extern	long	fileindex;	/* source file name index */
121 extern	long	lineoffset;	/* source line database offset */
122 extern	long	npostings;	/* number of postings */
123 extern	int	symbols;	/* number of symbols */
124 
125 /* dir.c global data */
126 extern	char	**incdirs;	/* #include directories */
127 extern	char	**srcdirs;	/* source directories */
128 extern	char	**srcfiles;	/* source files */
129 extern	int	nincdirs;	/* number of #include directories */
130 extern	int	nsrcdirs;	/* number of source directories */
131 extern	int	nsrcfiles;	/* number of source files */
132 extern	int	msrcfiles;	/* maximum number of source files */
133 
134 /* display.c global data */
135 extern	int	*displine;	/* screen line of displayed reference */
136 extern	int	disprefs;	/* displayed references */
137 extern	int	field;		/* input field */
138 extern	unsigned fldcolumn;	/* input field column */
139 extern	int	mdisprefs;	/* maximum displayed references */
140 extern	int	selectlen;		/* selection number field length */
141 extern	int	nextline;	/* next line to be shown */
142 extern	int	topline;	/* top line of page */
143 extern	int	bottomline;	/* bottom line of page */
144 extern	int	totallines;	/* total reference lines */
145 extern	FILE	*refsfound;	/* references found file */
146 extern	FILE	*nonglobalrefs;	/* non-global references file */
147 
148 /* exec.c global data */
149 extern	pid_t	childpid;	/* child's process ID */
150 
151 /* find.c global data */
152 extern	char	block[];	/* cross-reference file block */
153 extern	int	blocklen;	/* length of disk block read */
154 extern	char	blockmark;	/* mark character to be searched for */
155 extern	long	blocknumber;	/* block number */
156 extern	char	*blockp;	/* pointer to current character in block */
157 extern	char	lastfilepath[];	/* last file that full path was computed for */
158 
159 /* lookup.c global data */
160 extern	struct	keystruct {
161 	char	*text;
162 	char	delim;
163 	KEYWORD	type;
164 	struct	keystruct *next;
165 } keyword[];
166 
167 /* scanner.l global data */
168 extern	int	first;		/* buffer index for first char of symbol */
169 extern	int	last;		/* buffer index for last char of symbol */
170 extern	int	lineno;		/* symbol line number */
171 extern	FILE	*yyin;		/* input file descriptor */
172 extern	int	yyleng;		/* input line length */
173 extern	int	yylineno;	/* input line number */
174 #if hpux
175 extern	unsigned char	yytext[];	/* input line text */
176 #else
177 extern	char	yytext[];	/* input line text */
178 #endif
179 
180 /* vpinit.c global data */
181 extern	char	*argv0;		/* command name */
182 
183 /* cscope functions called from more than one function or between files */
184 /* cgrep.c */
185 void	egrepcaseless(int i);
186 char	*egrepinit(char *expression);
187 int	egrep(char *f, FILE *o, char *fo);
188 
189 /* command.c */
190 BOOL	command(int commandc);
191 void	clearprompt(void);
192 BOOL	readrefs(char *filename);
193 BOOL	changestring(void);
194 void	mark(int i);
195 
196 /* crossref.c */
197 void	crossref(char *srcfile);
198 void	savesymbol(int token);
199 void	putfilename(char *srcfile);
200 void	putposting(char *term, int type);
201 void	putstring(char *s);
202 void	warning(char *text);
203 
204 /* dir.c */
205 void	sourcedir(char *dirlist);
206 void	includedir(char *dirlist);
207 void	makefilelist(void);
208 void	incfile(char *file, int type);
209 BOOL	infilelist(char *file);
210 void	addsrcfile(char *path);
211 void	freefilelist(void);
212 
213 /* display.c */
214 void	dispinit(void);
215 void	display(void);
216 void	setfield(void);
217 void	atfield(void);
218 void	jumpback(int sig);
219 BOOL	search(void);
220 BOOL	writerefsfound(void);
221 void	countrefs(void);
222 void	myperror(char *text);
223 void	putmsg(char *msg);
224 void	clearmsg2(void);
225 void	putmsg2(char *msg);
226 void	seekline(int line);
227 void	ogsnames(char *file, char **subsystem, char **book);
228 char	*pathcomponents(char *path, int components);
229 void	strtoupper(char *s);
230 
231 /* edit.c */
232 void	editref(int i);
233 void	editall(void);
234 void	edit(char *file, char *linenum);
235 
236 /* find.c */
237 void	findsymbol(void);
238 void	finddef(void);
239 void	findallfcns(void);
240 void	findcalledby(void);
241 void	findcalling(void);
242 void	findassignments(void);
243 char	*findgreppat(void);
244 char	*findegreppat(char *egreppat);
245 void	findfile(void);
246 void	findinclude(void);
247 FINDINIT findinit(void);
248 void	findcleanup(void);
249 void	initprogress(void);
250 void	progress(char *format, long n1, long n2);
251 BOOL	match(void);
252 BOOL	matchrest(void);
253 void	getstring(char *s);
254 char	*scanpast(int c);
255 char	*readblock(void);
256 long	dbseek(long offset);
257 
258 /* help.c */
259 void	help(void);
260 
261 /* history.c */
262 void	addcmd(int f, char *s);
263 void	resetcmd(void);
264 HISTORY *currentcmd(void);
265 HISTORY *prevcmd(void);
266 HISTORY *nextcmd(void);
267 
268 /* input.c */
269 void	catchint(int sig);
270 int	ungetch(int c);
271 int	mygetch(void);
272 int	getaline(char s[], size_t size, int firstchar, BOOL iscaseless);
273 void	askforchar(void);
274 void	askforreturn(void);
275 void	shellpath(char *out, int limit, char *in);
276 
277 /* lookup.c */
278 void	initsymtab(void);
279 struct	keystruct *lookup(char *ident);
280 int	hash(char *s);
281 
282 /* main.c */
283 void	rebuild(void);
284 void	entercurses(void);
285 void	exitcurses(void);
286 void	myexit(int sig);
287 void	cannotopen(char *file);
288 void	cannotwrite(char *file);
289 
290 /* menu.c */
291 void	initmenu(void);
292 
293 extern void initscanner(char *srcfile);
294 extern int yylex(void);
295 extern int execute(char *, ...);
296