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