xref: /minix/external/bsd/nvi/dist/ex/tag.h (revision 0a6a1f1d)
1*0a6a1f1dSLionel Sambuc /*	$NetBSD: tag.h,v 1.4 2014/08/22 21:28:20 aymeric Exp $	*/
284d9c625SLionel Sambuc /*-
384d9c625SLionel Sambuc  * Copyright (c) 1992, 1993, 1994
484d9c625SLionel Sambuc  *	The Regents of the University of California.  All rights reserved.
584d9c625SLionel Sambuc  * Copyright (c) 1992, 1993, 1994, 1995, 1996
684d9c625SLionel Sambuc  *	Keith Bostic.  All rights reserved.
784d9c625SLionel Sambuc  * Copyright (c) 1994, 1996
884d9c625SLionel Sambuc  *	Rob Mayoff.  All rights reserved.
984d9c625SLionel Sambuc  *
1084d9c625SLionel Sambuc  * See the LICENSE file for redistribution information.
1184d9c625SLionel Sambuc  *
1284d9c625SLionel Sambuc  *	Id: tag.h,v 10.8 2000/07/14 14:29:22 skimo Exp  (Berkeley) Date: 2000/07/14 14:29:22
1384d9c625SLionel Sambuc  */
1484d9c625SLionel Sambuc 
1584d9c625SLionel Sambuc /*
1684d9c625SLionel Sambuc  * Cscope connection information.  One of these is maintained per cscope
1784d9c625SLionel Sambuc  * connection, linked from the EX_PRIVATE structure.
1884d9c625SLionel Sambuc  */
1984d9c625SLionel Sambuc struct _csc {
2084d9c625SLionel Sambuc 	LIST_ENTRY(_csc) q;	/* Linked list of cscope connections. */
2184d9c625SLionel Sambuc 
2284d9c625SLionel Sambuc 	char	*dname;		/* Base directory of this cscope connection. */
2384d9c625SLionel Sambuc 	size_t	 dlen;		/* Length of base directory. */
2484d9c625SLionel Sambuc 	pid_t	 pid;		/* PID of the connected cscope process. */
2584d9c625SLionel Sambuc 	time_t	 mtime;		/* Last modification time of cscope database. */
2684d9c625SLionel Sambuc 
2784d9c625SLionel Sambuc 	FILE	*from_fp;	/* from cscope: FILE. */
2884d9c625SLionel Sambuc 	int	 from_fd;	/* from cscope: file descriptor. */
2984d9c625SLionel Sambuc 	FILE	*to_fp;		/* to cscope: FILE. */
3084d9c625SLionel Sambuc 	int	 to_fd;		/* to cscope: file descriptor. */
3184d9c625SLionel Sambuc 
3284d9c625SLionel Sambuc 	char   **paths;		/* Array of search paths for this cscope. */
3384d9c625SLionel Sambuc 	char	*pbuf;		/* Search path buffer. */
3484d9c625SLionel Sambuc 	size_t	 pblen;		/* Search path buffer length. */
3584d9c625SLionel Sambuc 
3684d9c625SLionel Sambuc 	char	 buf[1];	/* Variable length buffer. */
3784d9c625SLionel Sambuc };
3884d9c625SLionel Sambuc 
3984d9c625SLionel Sambuc /*
4084d9c625SLionel Sambuc  * Tag file information.  One of these is maintained per tag file, linked
4184d9c625SLionel Sambuc  * from the EXPRIVATE structure.
4284d9c625SLionel Sambuc  */
4384d9c625SLionel Sambuc struct _tagf {			/* Tag files. */
4484d9c625SLionel Sambuc 	TAILQ_ENTRY(_tagf) q;	/* Linked list of tag files. */
4584d9c625SLionel Sambuc 	char	*name;		/* Tag file name. */
4684d9c625SLionel Sambuc 	int	 errnum;	/* Errno. */
4784d9c625SLionel Sambuc 
4884d9c625SLionel Sambuc #define	TAGF_ERR	0x01	/* Error occurred. */
4984d9c625SLionel Sambuc #define	TAGF_ERR_WARN	0x02	/* Error reported. */
5084d9c625SLionel Sambuc 	u_int8_t flags;
5184d9c625SLionel Sambuc };
5284d9c625SLionel Sambuc 
5384d9c625SLionel Sambuc /*
5484d9c625SLionel Sambuc  * Tags are structured internally as follows:
5584d9c625SLionel Sambuc  *
5684d9c625SLionel Sambuc  * +----+    +----+	+----+     +----+
5784d9c625SLionel Sambuc  * | EP | -> | Q1 | <-- | T1 | <-- | T2 |
5884d9c625SLionel Sambuc  * +----+    +----+ --> +----+ --> +----+
5984d9c625SLionel Sambuc  *	     |
6084d9c625SLionel Sambuc  *	     +----+     +----+
6184d9c625SLionel Sambuc  *	     | Q2 | <-- | T1 |
6284d9c625SLionel Sambuc  *	     +----+ --> +----+
6384d9c625SLionel Sambuc  *	     |
6484d9c625SLionel Sambuc  *	     +----+	+----+
6584d9c625SLionel Sambuc  *	     | Q3 | <-- | T1 |
6684d9c625SLionel Sambuc  *	     +----+ --> +----+
6784d9c625SLionel Sambuc  *
6884d9c625SLionel Sambuc  * Each Q is a TAGQ, or tag "query", which is the result of one tag or cscope
6984d9c625SLionel Sambuc  * command.  Each Q references one or more TAG's, or tagged file locations.
7084d9c625SLionel Sambuc  *
7184d9c625SLionel Sambuc  * tag:		put a new Q at the head	(^])
7284d9c625SLionel Sambuc  * tagnext:	T1 -> T2 inside Q	(^N)
7384d9c625SLionel Sambuc  * tagprev:	T2 -> T1 inside Q	(^P)
7484d9c625SLionel Sambuc  * tagpop:	discard Q		(^T)
7584d9c625SLionel Sambuc  * tagtop:	discard all Q
7684d9c625SLionel Sambuc  */
7784d9c625SLionel Sambuc struct _tag {			/* Tag list. */
7884d9c625SLionel Sambuc 	TAILQ_ENTRY(_tag) q;	/* Linked list of tags. */
7984d9c625SLionel Sambuc 
8084d9c625SLionel Sambuc 				/* Tag pop/return information. */
8184d9c625SLionel Sambuc 	FREF	*frp;		/* Saved file. */
8284d9c625SLionel Sambuc 	db_recno_t	 lno;		/* Saved line number. */
8384d9c625SLionel Sambuc 	size_t	 cno;		/* Saved column number. */
8484d9c625SLionel Sambuc 
8584d9c625SLionel Sambuc 	char	*fname;		/* Filename. */
8684d9c625SLionel Sambuc 	size_t	 fnlen;		/* Filename length. */
8784d9c625SLionel Sambuc 	db_recno_t	 slno;		/* Search line number. */
8884d9c625SLionel Sambuc 	CHAR_T	*search;	/* Search string. */
8984d9c625SLionel Sambuc 	size_t	 slen;		/* Search string length. */
9084d9c625SLionel Sambuc 	CHAR_T	*msg;		/* Message string. */
9184d9c625SLionel Sambuc 	size_t	 mlen;		/* Message string length. */
9284d9c625SLionel Sambuc 
9384d9c625SLionel Sambuc 	CHAR_T	 buf[1];	/* Variable length buffer. */
9484d9c625SLionel Sambuc };
9584d9c625SLionel Sambuc 
9684d9c625SLionel Sambuc struct _tagq {			/* Tag queue. */
9784d9c625SLionel Sambuc 	TAILQ_ENTRY(_tagq) q;	/* Linked list of tag queues. */
9884d9c625SLionel Sambuc 				/* This queue's tag list. */
9984d9c625SLionel Sambuc 	TAILQ_HEAD(_tagqh, _tag) tagq;
10084d9c625SLionel Sambuc 
10184d9c625SLionel Sambuc 	TAG	*current;	/* Current TAG within the queue. */
10284d9c625SLionel Sambuc 
10384d9c625SLionel Sambuc 	char	*tag;		/* Tag string. */
10484d9c625SLionel Sambuc 	size_t	 tlen;		/* Tag string length. */
10584d9c625SLionel Sambuc 
10684d9c625SLionel Sambuc #define	TAG_CSCOPE	0x01	/* Cscope tag. */
107*0a6a1f1dSLionel Sambuc #define	TAG_IS_LINKED	0x02	/* Tag was inserted into linked list */
10884d9c625SLionel Sambuc 	u_int8_t flags;
10984d9c625SLionel Sambuc 
11084d9c625SLionel Sambuc 	char	 buf[1];	/* Variable length buffer. */
11184d9c625SLionel Sambuc };
112