1 /*	$OpenBSD: tag.h,v 1.3 2001/01/29 01:58:46 niklas Exp $	*/
2 
3 /*-
4  * Copyright (c) 1992, 1993, 1994
5  *	The Regents of the University of California.  All rights reserved.
6  * Copyright (c) 1992, 1993, 1994, 1995, 1996
7  *	Keith Bostic.  All rights reserved.
8  * Copyright (c) 1994, 1996
9  *	Rob Mayoff.  All rights reserved.
10  *
11  * See the LICENSE file for redistribution information.
12  *
13  *	@(#)tag.h	10.5 (Berkeley) 5/15/96
14  */
15 
16 /*
17  * Cscope connection information.  One of these is maintained per cscope
18  * connection, linked from the EX_PRIVATE structure.
19  */
20 struct _csc {
21 	LIST_ENTRY(_csc) q;	/* Linked list of cscope connections. */
22 
23 	char	*dname;		/* Base directory of this cscope connection. */
24 	size_t	 dlen;		/* Length of base directory. */
25 	pid_t	 pid;		/* PID of the connected cscope process. */
26 	time_t	 mtime;		/* Last modification time of cscope database. */
27 
28 	FILE	*from_fp;	/* from cscope: FILE. */
29 	int	 from_fd;	/* from cscope: file descriptor. */
30 	FILE	*to_fp;		/* to cscope: FILE. */
31 	int	 to_fd;		/* to cscope: file descriptor. */
32 
33 	char   **paths;		/* Array of search paths for this cscope. */
34 	char	*pbuf;		/* Search path buffer. */
35 	size_t	 pblen;		/* Search path buffer length. */
36 
37 	char	 buf[1];	/* Variable length buffer. */
38 };
39 
40 /*
41  * Tag file information.  One of these is maintained per tag file, linked
42  * from the EXPRIVATE structure.
43  */
44 struct _tagf {			/* Tag files. */
45 	TAILQ_ENTRY(_tagf) q;	/* Linked list of tag files. */
46 	char	*name;		/* Tag file name. */
47 	int	 errnum;	/* Errno. */
48 
49 #define	TAGF_ERR	0x01	/* Error occurred. */
50 #define	TAGF_ERR_WARN	0x02	/* Error reported. */
51 	u_int8_t flags;
52 };
53 
54 /*
55  * Tags are structured internally as follows:
56  *
57  * +----+    +----+	+----+     +----+
58  * | EP | -> | Q1 | <-- | T1 | <-- | T2 |
59  * +----+    +----+ --> +----+ --> +----+
60  *	     |
61  *	     +----+     +----+
62  *	     | Q2 | <-- | T1 |
63  *	     +----+ --> +----+
64  *	     |
65  *	     +----+	+----+
66  *	     | Q3 | <-- | T1 |
67  *	     +----+ --> +----+
68  *
69  * Each Q is a TAGQ, or tag "query", which is the result of one tag or cscope
70  * command.  Each Q references one or more TAG's, or tagged file locations.
71  *
72  * tag:		put a new Q at the head	(^])
73  * tagnext:	T1 -> T2 inside Q	(^N)
74  * tagprev:	T2 -> T1 inside Q	(^P)
75  * tagpop:	discard Q		(^T)
76  * tagtop:	discard all Q
77  */
78 struct _tag {			/* Tag list. */
79 	CIRCLEQ_ENTRY(_tag) q;	/* Linked list of tags. */
80 
81 				/* Tag pop/return information. */
82 	FREF	*frp;		/* Saved file. */
83 	recno_t	 lno;		/* Saved line number. */
84 	size_t	 cno;		/* Saved column number. */
85 
86 	char	*fname;		/* Filename. */
87 	size_t	 fnlen;		/* Filename length. */
88 	recno_t	 slno;		/* Search line number. */
89 	char	*search;	/* Search string. */
90 	size_t	 slen;		/* Search string length. */
91 
92 	char	 buf[1];	/* Variable length buffer. */
93 };
94 
95 struct _tagq {			/* Tag queue. */
96 	CIRCLEQ_ENTRY(_tagq) q;	/* Linked list of tag queues. */
97 				/* This queue's tag list. */
98 	CIRCLEQ_HEAD(_tagqh, _tag) tagq;
99 
100 	TAG	*current;	/* Current TAG within the queue. */
101 
102 	char	*tag;		/* Tag string. */
103 	size_t	 tlen;		/* Tag string length. */
104 
105 #define	TAG_CSCOPE	0x01	/* Cscope tag. */
106 	u_int8_t flags;
107 
108 	char	 buf[1];	/* Variable length buffer. */
109 };
110