1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1988 AT&T	*/
23*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
24*7c478bd9Sstevel@tonic-gate 
25*7c478bd9Sstevel@tonic-gate 
26*7c478bd9Sstevel@tonic-gate /*
27*7c478bd9Sstevel@tonic-gate  *	cscope - interactive C symbol cross-reference
28*7c478bd9Sstevel@tonic-gate  *
29*7c478bd9Sstevel@tonic-gate  *	preprocessor macro and constant definitions
30*7c478bd9Sstevel@tonic-gate  */
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate /*
33*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1999 by Sun Microsystems, Inc.
34*7c478bd9Sstevel@tonic-gate  * All rights reserved.
35*7c478bd9Sstevel@tonic-gate  */
36*7c478bd9Sstevel@tonic-gate 
37*7c478bd9Sstevel@tonic-gate #include <limits.h>
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate #define	ctrl(x)	(x & 037)	/* control character macro */
40*7c478bd9Sstevel@tonic-gate 
41*7c478bd9Sstevel@tonic-gate /* database output macros that update its offset */
42*7c478bd9Sstevel@tonic-gate #define	dbputc(c)		(++dboffset, (void) putc(c, newrefs))
43*7c478bd9Sstevel@tonic-gate #define	dbfputs(s)		(dboffset += fputs(s, newrefs))
44*7c478bd9Sstevel@tonic-gate #define	dbfprintf(s, f, a)	(dboffset += fprintf(s, f, a))
45*7c478bd9Sstevel@tonic-gate 
46*7c478bd9Sstevel@tonic-gate /* fast string equality tests (avoids most strcmp() calls) */
47*7c478bd9Sstevel@tonic-gate #define	strequal(s1, s2)	(*(s1) == *(s2) && strcmp(s1, s2) == 0)
48*7c478bd9Sstevel@tonic-gate #define	strnotequal(s1, s2)	(*(s1) != *(s2) || strcmp(s1, s2) != 0)
49*7c478bd9Sstevel@tonic-gate 
50*7c478bd9Sstevel@tonic-gate /* set the mark character for searching the cross-reference file */
51*7c478bd9Sstevel@tonic-gate #define	setmark(c)	(blockmark = c, block[blocklen] = blockmark)
52*7c478bd9Sstevel@tonic-gate 
53*7c478bd9Sstevel@tonic-gate /* get the next character in the cross-reference */
54*7c478bd9Sstevel@tonic-gate /* note that blockp is assumed not to be null */
55*7c478bd9Sstevel@tonic-gate #define	getrefchar()	(*(++blockp + 1) != '\0' ? *blockp : \
56*7c478bd9Sstevel@tonic-gate 			(readblock() != NULL ? *blockp : '\0'))
57*7c478bd9Sstevel@tonic-gate 
58*7c478bd9Sstevel@tonic-gate /* skip the next character in the cross-reference */
59*7c478bd9Sstevel@tonic-gate /*
60*7c478bd9Sstevel@tonic-gate  * note that blockp is assumed not to be null and that
61*7c478bd9Sstevel@tonic-gate  * this macro will always be in a statement by itself
62*7c478bd9Sstevel@tonic-gate  */
63*7c478bd9Sstevel@tonic-gate #define	skiprefchar()	if (*(++blockp + 1) == '\0') (void) readblock()
64*7c478bd9Sstevel@tonic-gate 
65*7c478bd9Sstevel@tonic-gate #define	ESC	'\033'		/* escape character */
66*7c478bd9Sstevel@tonic-gate #define	MSGLEN	PATLEN + 80	/* displayed message length */
67*7c478bd9Sstevel@tonic-gate #define	READ	4		/* access(2) parameter */
68*7c478bd9Sstevel@tonic-gate #define	WRITE	2		/* access(2) parameter */
69*7c478bd9Sstevel@tonic-gate 
70*7c478bd9Sstevel@tonic-gate /* these also appear in the fscanf format string in countrefs() */
71*7c478bd9Sstevel@tonic-gate #define	NUMLEN	6		/* line number length */
72*7c478bd9Sstevel@tonic-gate #define	PATHLEN	PATH_MAX	/* file pathname length */
73*7c478bd9Sstevel@tonic-gate 
74*7c478bd9Sstevel@tonic-gate /* default file names */
75*7c478bd9Sstevel@tonic-gate #define	INVNAME		"cscope.in.out"	/* inverted index to the database */
76*7c478bd9Sstevel@tonic-gate #define	INVPOST		"cscope.po.out"	/* inverted index postings */
77*7c478bd9Sstevel@tonic-gate #define	NAMEFILE	"cscope.files"	/* source file names and options */
78*7c478bd9Sstevel@tonic-gate #define	REFFILE		"cscope.out"	/* symbol database */
79*7c478bd9Sstevel@tonic-gate 
80*7c478bd9Sstevel@tonic-gate /*
81*7c478bd9Sstevel@tonic-gate  * cross-reference database mark characters (when new ones are added,
82*7c478bd9Sstevel@tonic-gate  * update the cscope.out format description in cscope.1)
83*7c478bd9Sstevel@tonic-gate  */
84*7c478bd9Sstevel@tonic-gate #define	ASSIGNMENT	'='
85*7c478bd9Sstevel@tonic-gate #define	CLASSDEF	'c'
86*7c478bd9Sstevel@tonic-gate #define	DEFINE		'#'
87*7c478bd9Sstevel@tonic-gate #define	DEFINEEND	')'
88*7c478bd9Sstevel@tonic-gate #define	ENUMDEF		'e'
89*7c478bd9Sstevel@tonic-gate #define	ESUEND		';'
90*7c478bd9Sstevel@tonic-gate #define	FCNCALL		'`'
91*7c478bd9Sstevel@tonic-gate #define	FCNDEF		'$'
92*7c478bd9Sstevel@tonic-gate #define	FCNEND		'}'
93*7c478bd9Sstevel@tonic-gate #define	GLOBALDEF	'g'
94*7c478bd9Sstevel@tonic-gate #define	INCLUDE		'~'
95*7c478bd9Sstevel@tonic-gate #define	LOCALDEF	'l'
96*7c478bd9Sstevel@tonic-gate #define	MEMBERDEF	'm'
97*7c478bd9Sstevel@tonic-gate #define	NEWFILE		'@'
98*7c478bd9Sstevel@tonic-gate #define	PARAMETER	'p'
99*7c478bd9Sstevel@tonic-gate #define	STRUCTDEF	's'
100*7c478bd9Sstevel@tonic-gate #define	TYPEDEF		't'
101*7c478bd9Sstevel@tonic-gate #define	UNIONDEF	'u'
102*7c478bd9Sstevel@tonic-gate 
103*7c478bd9Sstevel@tonic-gate /* other scanner token types */
104*7c478bd9Sstevel@tonic-gate #define	LEXEOF	0
105*7c478bd9Sstevel@tonic-gate #define	IDENT	1
106*7c478bd9Sstevel@tonic-gate #define	NEWLINE	2
107*7c478bd9Sstevel@tonic-gate 
108*7c478bd9Sstevel@tonic-gate /* screen lines */
109*7c478bd9Sstevel@tonic-gate #define	FLDLINE	(LINES - FIELDS - 1)	/* first input field line */
110*7c478bd9Sstevel@tonic-gate #define	MSGLINE	0			/* message line */
111*7c478bd9Sstevel@tonic-gate #define	PRLINE	(LINES - 1)		/* input prompt line */
112*7c478bd9Sstevel@tonic-gate #define	REFLINE	3			/* first displayed reference line */
113*7c478bd9Sstevel@tonic-gate 
114*7c478bd9Sstevel@tonic-gate /* input fields (value matches field order on screen) */
115*7c478bd9Sstevel@tonic-gate #define	SYMBOL		0
116*7c478bd9Sstevel@tonic-gate #define	DEFINITION	1
117*7c478bd9Sstevel@tonic-gate #define	CALLEDBY	2
118*7c478bd9Sstevel@tonic-gate #define	CALLING		3
119*7c478bd9Sstevel@tonic-gate #define	ASSIGN		4
120*7c478bd9Sstevel@tonic-gate #define	CHANGE		5
121*7c478bd9Sstevel@tonic-gate #define	STRING		6
122*7c478bd9Sstevel@tonic-gate #define	FILENAME	7
123*7c478bd9Sstevel@tonic-gate #define	INCLUDES	8
124*7c478bd9Sstevel@tonic-gate #define	FIELDS		9
125