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