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