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