Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / contrib / texinfo / info / nodes.h
1 /* nodes.h -- How we represent nodes internally.
2    $Id: nodes.h,v 1.8 1998/07/10 20:28:43 karl Exp $
3
4    Copyright (C) 1993, 97, 98 Free Software Foundation, Inc.
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2, or (at your option)
9    any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20    Written by Brian Fox (bfox@ai.mit.edu). */
21
22 #ifndef NODES_H
23 #define NODES_H
24
25 #include "info.h"
26
27 /* User code interface.  */
28
29 /* Callers generally only want the node itself.  This structure is used
30    to pass node information around.  None of the information in this
31    structure should ever be directly freed.  The structure itself can
32    be passed to free ().  Note that NODE->parent is non-null if this
33    node's file is a subfile.  In that case, NODE->parent is the logical
34    name of the file containing this node.  Both names are given as full
35    paths, so you might have: node->filename = "/usr/gnu/info/emacs-1",
36    with node->parent = "/usr/gnu/info/emacs". */
37 typedef struct {
38   char *filename;               /* The physical file containing this node. */
39   char *parent;                 /* Non-null is the logical file name. */
40   char *nodename;               /* The name of this node. */
41   char *contents;               /* Characters appearing in this node. */
42   long nodelen;                 /* The length of the CONTENTS member. */
43   unsigned long display_pos;    /* Where to display at, if nonzero.  */
44   int flags;                    /* See immediately below. */
45 } NODE;
46
47 /* Defines that can appear in NODE->flags.  All informative. */
48 #define N_HasTagsTable 0x01     /* This node was found through a tags table. */
49 #define N_TagsIndirect 0x02     /* The tags table was an indirect one. */
50 #define N_UpdateTags   0x04     /* The tags table is out of date. */
51 #define N_IsCompressed 0x08     /* The file is compressed on disk. */
52 #define N_IsInternal   0x10     /* This node was made by Info. */
53 #define N_CannotGC     0x20     /* File buffer cannot be gc'ed. */
54 #define N_IsManPage    0x40     /* This node is a manpage. */
55 #define N_FromAnchor   0x80     /* Synthesized for an anchor reference. */
56 \f
57 /* Internal data structures.  */
58
59 /* String constants. */
60 #define INFO_FILE_LABEL                 "File:"
61 #define INFO_REF_LABEL                  "Ref:"
62 #define INFO_NODE_LABEL                 "Node:"
63 #define INFO_PREV_LABEL                 "Prev:"
64 #define INFO_ALTPREV_LABEL              "Previous:"
65 #define INFO_NEXT_LABEL                 "Next:"
66 #define INFO_UP_LABEL                   "Up:"
67 #define INFO_MENU_LABEL                 "\n* Menu:"
68 #define INFO_MENU_ENTRY_LABEL           "\n* "
69 #define INFO_XREF_LABEL                 "*Note"
70 #define TAGS_TABLE_END_LABEL            "\nEnd Tag Table"
71 #define TAGS_TABLE_BEG_LABEL            "Tag Table:\n"
72 #define INDIRECT_TAGS_TABLE_LABEL       "Indirect:\n"
73 #define TAGS_TABLE_IS_INDIRECT_LABEL    "(Indirect)"
74
75 /* Character constants. */
76 #define INFO_COOKIE '\037'
77 #define INFO_FF     '\014'
78 #define INFO_TAGSEP '\177'
79
80 /* For each logical file that we have loaded, we keep a list of the names
81    of the nodes that are found in that file.  A pointer to a node in an
82    info file is called a "tag".  For split files, the tag pointer is
83    "indirect"; that is, the pointer also contains the name of the split
84    file where the node can be found.  For non-split files, the filename
85    member in the structure below simply contains the name of the current
86    file.  The following structure describes a single node within a file. */
87 typedef struct {
88   char *filename;               /* The file where this node can be found. */
89   char *nodename;               /* The node pointed to by this tag. */
90   long nodestart;               /* The offset of the start of this node. */
91   long nodelen;                 /* The length of this node. */
92 } TAG;
93
94 /* The following structure is used to remember information about the contents
95    of Info files that we have loaded at least once before.  The FINFO member
96    is present so that we can reload the file if it has been modified since
97    last being loaded.  All of the arrays appearing within this structure
98    are NULL terminated, and each array which can change size has a
99    corresponding SLOTS member which says how many slots have been allocated
100    (with malloc ()) for this array. */
101 typedef struct {
102   char *filename;               /* The filename used to find this file. */
103   char *fullpath;               /* The full pathname of this info file. */
104   struct stat finfo;            /* Information about this file. */
105   char *contents;               /* The contents of this particular file. */
106   long filesize;                /* The number of bytes this file expands to. */
107   char **subfiles;              /* If non-null, the list of subfiles. */
108   TAG **tags;                   /* If non-null, the indirect tags table. */
109   int tags_slots;               /* Number of slots allocated for TAGS. */
110   int flags;                    /* Various flags.  Mimics of N_* flags. */
111 } FILE_BUFFER;
112 \f
113 /* Externally visible functions.  */
114
115 /* Array of FILE_BUFFER * which represents the currently loaded info files. */
116 extern FILE_BUFFER **info_loaded_files;
117
118 /* The number of slots currently allocated to INFO_LOADED_FILES. */
119 extern int info_loaded_files_slots;
120
121 /* Locate the file named by FILENAME, and return the information structure
122    describing this file.  The file may appear in our list of loaded files
123    already, or it may not.  If it does not already appear, find the file,
124    and add it to the list of loaded files.  If the file cannot be found,
125    return a NULL FILE_BUFFER *. */
126 extern FILE_BUFFER *info_find_file ();
127
128 /* Force load the file named FILENAME, and return the information structure
129    describing this file.  Even if the file was already loaded, this loads
130    a new buffer, rebuilds tags and nodes, and returns a new FILE_BUFFER *. */
131 extern FILE_BUFFER *info_load_file ();
132
133 /* Return a pointer to a NODE structure for the Info node (FILENAME)NODENAME.
134    FILENAME can be passed as NULL, in which case the filename of "dir" is used.
135    NODENAME can be passed as NULL, in which case the nodename of "Top" is used.
136    If the node cannot be found, return a NULL pointer. */
137 extern NODE *info_get_node ();
138
139 /* Return a pointer to a NODE structure for the Info node NODENAME in
140    FILE_BUFFER.  NODENAME can be passed as NULL, in which case the
141    nodename of "Top" is used.  If the node cannot be found, return a
142    NULL pointer. */
143 extern NODE *info_get_node_of_file_buffer ();
144
145 /* Grovel FILE_BUFFER->contents finding tags and nodes, and filling in the
146    various slots.  This can also be used to rebuild a tag or node table. */
147 extern void build_tags_and_nodes ();
148
149 /* When non-zero, this is a string describing the most recent file error. */
150 extern char *info_recent_file_error;
151
152 /* Create a new, empty file buffer. */
153 extern FILE_BUFFER *make_file_buffer ();
154
155 #endif /* not NODES_H */