1 | /* nodes.h -- How we represent nodes internally.
|
---|
2 | $Id: nodes.h,v 1.3 2004/04/11 17:56:46 karl Exp $
|
---|
3 |
|
---|
4 | Copyright (C) 1993, 1997, 1998, 2002, 2004 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 | |
---|
57 |
|
---|
58 | /* Internal data structures. */
|
---|
59 |
|
---|
60 | /* String constants. */
|
---|
61 | #define INFO_FILE_LABEL "File:"
|
---|
62 | #define INFO_REF_LABEL "Ref:"
|
---|
63 | #define INFO_NODE_LABEL "Node:"
|
---|
64 | #define INFO_PREV_LABEL "Prev:"
|
---|
65 | #define INFO_ALTPREV_LABEL "Previous:"
|
---|
66 | #define INFO_NEXT_LABEL "Next:"
|
---|
67 | #define INFO_UP_LABEL "Up:"
|
---|
68 | #define INFO_MENU_LABEL "\n* Menu:"
|
---|
69 | #define INFO_MENU_ENTRY_LABEL "\n* "
|
---|
70 | #define INFO_XREF_LABEL "*Note"
|
---|
71 | #define TAGS_TABLE_END_LABEL "\nEnd Tag Table"
|
---|
72 | #define TAGS_TABLE_BEG_LABEL "Tag Table:\n"
|
---|
73 | #define INDIRECT_TAGS_TABLE_LABEL "Indirect:\n"
|
---|
74 | #define TAGS_TABLE_IS_INDIRECT_LABEL "(Indirect)"
|
---|
75 |
|
---|
76 | /* Character constants. */
|
---|
77 | #define INFO_COOKIE '\037'
|
---|
78 | #define INFO_FF '\014'
|
---|
79 | #define INFO_TAGSEP '\177'
|
---|
80 |
|
---|
81 | /* For each logical file that we have loaded, we keep a list of the names
|
---|
82 | of the nodes that are found in that file. A pointer to a node in an
|
---|
83 | info file is called a "tag". For split files, the tag pointer is
|
---|
84 | "indirect"; that is, the pointer also contains the name of the split
|
---|
85 | file where the node can be found. For non-split files, the filename
|
---|
86 | member in the structure below simply contains the name of the current
|
---|
87 | file. The following structure describes a single node within a file. */
|
---|
88 | typedef struct {
|
---|
89 | char *filename; /* The file where this node can be found. */
|
---|
90 | char *nodename; /* The node pointed to by this tag. */
|
---|
91 | long nodestart; /* The offset of the start of this node. */
|
---|
92 | long nodelen; /* The length of this node. */
|
---|
93 | } TAG;
|
---|
94 |
|
---|
95 | /* The following structure is used to remember information about the contents
|
---|
96 | of Info files that we have loaded at least once before. The FINFO member
|
---|
97 | is present so that we can reload the file if it has been modified since
|
---|
98 | last being loaded. All of the arrays appearing within this structure
|
---|
99 | are NULL terminated, and each array which can change size has a
|
---|
100 | corresponding SLOTS member which says how many slots have been allocated
|
---|
101 | (with malloc ()) for this array. */
|
---|
102 | typedef struct {
|
---|
103 | char *filename; /* The filename used to find this file. */
|
---|
104 | char *fullpath; /* The full pathname of this info file. */
|
---|
105 | struct stat finfo; /* Information about this file. */
|
---|
106 | char *contents; /* The contents of this particular file. */
|
---|
107 | long filesize; /* The number of bytes this file expands to. */
|
---|
108 | char **subfiles; /* If non-null, the list of subfiles. */
|
---|
109 | TAG **tags; /* If non-null, the indirect tags table. */
|
---|
110 | int tags_slots; /* Number of slots allocated for TAGS. */
|
---|
111 | int flags; /* Various flags. Mimics of N_* flags. */
|
---|
112 | } FILE_BUFFER;
|
---|
113 | |
---|
114 |
|
---|
115 | /* Externally visible functions. */
|
---|
116 |
|
---|
117 | /* Array of FILE_BUFFER * which represents the currently loaded info files. */
|
---|
118 | extern FILE_BUFFER **info_loaded_files;
|
---|
119 |
|
---|
120 | /* The number of slots currently allocated to INFO_LOADED_FILES. */
|
---|
121 | extern int info_loaded_files_slots;
|
---|
122 |
|
---|
123 | /* Locate the file named by FILENAME, and return the information structure
|
---|
124 | describing this file. The file may appear in our list of loaded files
|
---|
125 | already, or it may not. If it does not already appear, find the file,
|
---|
126 | and add it to the list of loaded files. If the file cannot be found,
|
---|
127 | return a NULL FILE_BUFFER *. */
|
---|
128 | extern FILE_BUFFER *info_find_file (char *filename);
|
---|
129 |
|
---|
130 | /* Force load the file named FILENAME, and return the information structure
|
---|
131 | describing this file. Even if the file was already loaded, this loads
|
---|
132 | a new buffer, rebuilds tags and nodes, and returns a new FILE_BUFFER *. */
|
---|
133 | extern FILE_BUFFER *info_load_file (char *filename);
|
---|
134 |
|
---|
135 | /* Return a pointer to a NODE structure for the Info node (FILENAME)NODENAME.
|
---|
136 | FILENAME can be passed as NULL, in which case the filename of "dir" is used.
|
---|
137 | NODENAME can be passed as NULL, in which case the nodename of "Top" is used.
|
---|
138 | If the node cannot be found, return a NULL pointer. */
|
---|
139 | extern NODE *info_get_node (char *filename, char *nodename);
|
---|
140 |
|
---|
141 | /* Return a pointer to a NODE structure for the Info node NODENAME in
|
---|
142 | FILE_BUFFER. NODENAME can be passed as NULL, in which case the
|
---|
143 | nodename of "Top" is used. If the node cannot be found, return a
|
---|
144 | NULL pointer. */
|
---|
145 | extern NODE *info_get_node_of_file_buffer (char *nodename,
|
---|
146 | FILE_BUFFER *file_buffer);
|
---|
147 |
|
---|
148 | /* Grovel FILE_BUFFER->contents finding tags and nodes, and filling in the
|
---|
149 | various slots. This can also be used to rebuild a tag or node table. */
|
---|
150 | extern void build_tags_and_nodes (FILE_BUFFER *file_buffer);
|
---|
151 |
|
---|
152 | /* When non-zero, this is a string describing the most recent file error. */
|
---|
153 | extern char *info_recent_file_error;
|
---|
154 |
|
---|
155 | /* Create a new, empty file buffer. */
|
---|
156 | extern FILE_BUFFER *make_file_buffer (void);
|
---|
157 |
|
---|
158 | #endif /* not NODES_H */
|
---|