summaryrefslogtreecommitdiff
path: root/usr.bin/vi/ex/tag.h
blob: ec72b1c8d13f67839bf91c88fc8446adef4b1c5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*	$OpenBSD: tag.h,v 1.4 2013/12/01 16:47:59 krw Exp $	*/

/*-
 * Copyright (c) 1992, 1993, 1994
 *	The Regents of the University of California.  All rights reserved.
 * Copyright (c) 1992, 1993, 1994, 1995, 1996
 *	Keith Bostic.  All rights reserved.
 * Copyright (c) 1994, 1996
 *	Rob Mayoff.  All rights reserved.
 *
 * See the LICENSE file for redistribution information.
 *
 *	@(#)tag.h	10.5 (Berkeley) 5/15/96
 */

/*
 * Cscope connection information.  One of these is maintained per cscope
 * connection, linked from the EX_PRIVATE structure.
 */
struct _csc {
	LIST_ENTRY(_csc) q;	/* Linked list of cscope connections. */

	char	*dname;		/* Base directory of this cscope connection. */
	size_t	 dlen;		/* Length of base directory. */
	pid_t	 pid;		/* PID of the connected cscope process. */
	time_t	 mtime;		/* Last modification time of cscope database. */

	FILE	*from_fp;	/* from cscope: FILE. */
	int	 from_fd;	/* from cscope: file descriptor. */
	FILE	*to_fp;		/* to cscope: FILE. */
	int	 to_fd;		/* to cscope: file descriptor. */

	char   **paths;		/* Array of search paths for this cscope. */
	char	*pbuf;		/* Search path buffer. */
	size_t	 pblen;		/* Search path buffer length. */

	char	 buf[1];	/* Variable length buffer. */
};

/*
 * Tag file information.  One of these is maintained per tag file, linked
 * from the EXPRIVATE structure.
 */
struct _tagf {			/* Tag files. */
	TAILQ_ENTRY(_tagf) q;	/* Linked list of tag files. */
	char	*name;		/* Tag file name. */
	int	 errnum;	/* Errno. */

#define	TAGF_ERR	0x01	/* Error occurred. */
#define	TAGF_ERR_WARN	0x02	/* Error reported. */
	u_int8_t flags;
};

/*
 * Tags are structured internally as follows:
 *
 * +----+    +----+	+----+     +----+
 * | EP | -> | Q1 | <-- | T1 | <-- | T2 |
 * +----+    +----+ --> +----+ --> +----+
 *	     |
 *	     +----+     +----+
 *	     | Q2 | <-- | T1 |
 *	     +----+ --> +----+
 *	     |
 *	     +----+	+----+
 *	     | Q3 | <-- | T1 |
 *	     +----+ --> +----+
 *
 * Each Q is a TAGQ, or tag "query", which is the result of one tag or cscope
 * command.  Each Q references one or more TAG's, or tagged file locations.
 *
 * tag:		put a new Q at the head	(^])
 * tagnext:	T1 -> T2 inside Q	(^N)
 * tagprev:	T2 -> T1 inside Q	(^P)
 * tagpop:	discard Q		(^T)
 * tagtop:	discard all Q
 */
struct _tag {			/* Tag list. */
	CIRCLEQ_ENTRY(_tag) q;	/* Linked list of tags. */

				/* Tag pop/return information. */
	FREF	*frp;		/* Saved file. */
	recno_t	 lno;		/* Saved line number. */
	size_t	 cno;		/* Saved column number. */

	char	*fname;		/* Filename. */
	size_t	 fnlen;		/* Filename length. */
	recno_t	 slno;		/* Search line number. */
	char	*search;	/* Search string. */
	size_t	 slen;		/* Search string length. */

	char	 buf[1];	/* Variable length buffer. */
};

struct _tagq {			/* Tag queue. */
	TAILQ_ENTRY(_tagq) q;	/* Linked list of tag queues. */
				/* This queue's tag list. */
	CIRCLEQ_HEAD(_tagqh, _tag) tagq;

	TAG	*current;	/* Current TAG within the queue. */

	char	*tag;		/* Tag string. */
	size_t	 tlen;		/* Tag string length. */

#define	TAG_CSCOPE	0x01	/* Cscope tag. */
	u_int8_t flags;

	char	 buf[1];	/* Variable length buffer. */
};