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