142660Smarkm/* nodes.h -- How we represent nodes internally. 2146515Sru $Id: nodes.h,v 1.3 2004/04/11 17:56:46 karl Exp $ 321495Sjmacd 4146515Sru Copyright (C) 1993, 1997, 1998, 2002, 2004 Free Software Foundation, Inc. 521495Sjmacd 621495Sjmacd This program is free software; you can redistribute it and/or modify 721495Sjmacd it under the terms of the GNU General Public License as published by 821495Sjmacd the Free Software Foundation; either version 2, or (at your option) 921495Sjmacd any later version. 1021495Sjmacd 1121495Sjmacd This program is distributed in the hope that it will be useful, 1221495Sjmacd but WITHOUT ANY WARRANTY; without even the implied warranty of 1321495Sjmacd MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1421495Sjmacd GNU General Public License for more details. 1521495Sjmacd 1621495Sjmacd You should have received a copy of the GNU General Public License 1721495Sjmacd along with this program; if not, write to the Free Software 1821495Sjmacd Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 1921495Sjmacd 2021495Sjmacd Written by Brian Fox (bfox@ai.mit.edu). */ 2121495Sjmacd 2256160Sru#ifndef NODES_H 2342660Smarkm#define NODES_H 2421495Sjmacd 2542660Smarkm#include "info.h" 2621495Sjmacd 2756160Sru/* User code interface. */ 2821495Sjmacd 2921495Sjmacd/* Callers generally only want the node itself. This structure is used 3021495Sjmacd to pass node information around. None of the information in this 3121495Sjmacd structure should ever be directly freed. The structure itself can 3221495Sjmacd be passed to free (). Note that NODE->parent is non-null if this 3321495Sjmacd node's file is a subfile. In that case, NODE->parent is the logical 3421495Sjmacd name of the file containing this node. Both names are given as full 3521495Sjmacd paths, so you might have: node->filename = "/usr/gnu/info/emacs-1", 3621495Sjmacd with node->parent = "/usr/gnu/info/emacs". */ 3721495Sjmacdtypedef struct { 3842660Smarkm char *filename; /* The physical file containing this node. */ 3942660Smarkm char *parent; /* Non-null is the logical file name. */ 4042660Smarkm char *nodename; /* The name of this node. */ 4142660Smarkm char *contents; /* Characters appearing in this node. */ 4242660Smarkm long nodelen; /* The length of the CONTENTS member. */ 4356160Sru unsigned long display_pos; /* Where to display at, if nonzero. */ 4442660Smarkm int flags; /* See immediately below. */ 4521495Sjmacd} NODE; 4621495Sjmacd 4721495Sjmacd/* Defines that can appear in NODE->flags. All informative. */ 4842660Smarkm#define N_HasTagsTable 0x01 /* This node was found through a tags table. */ 4942660Smarkm#define N_TagsIndirect 0x02 /* The tags table was an indirect one. */ 5042660Smarkm#define N_UpdateTags 0x04 /* The tags table is out of date. */ 5142660Smarkm#define N_IsCompressed 0x08 /* The file is compressed on disk. */ 5242660Smarkm#define N_IsInternal 0x10 /* This node was made by Info. */ 5342660Smarkm#define N_CannotGC 0x20 /* File buffer cannot be gc'ed. */ 5456160Sru#define N_IsManPage 0x40 /* This node is a manpage. */ 5556160Sru#define N_FromAnchor 0x80 /* Synthesized for an anchor reference. */ 5621495Sjmacd 5756160Sru/* Internal data structures. */ 5821495Sjmacd 5956160Sru/* String constants. */ 6042660Smarkm#define INFO_FILE_LABEL "File:" 6156160Sru#define INFO_REF_LABEL "Ref:" 6242660Smarkm#define INFO_NODE_LABEL "Node:" 6342660Smarkm#define INFO_PREV_LABEL "Prev:" 6442660Smarkm#define INFO_ALTPREV_LABEL "Previous:" 6542660Smarkm#define INFO_NEXT_LABEL "Next:" 6642660Smarkm#define INFO_UP_LABEL "Up:" 6742660Smarkm#define INFO_MENU_LABEL "\n* Menu:" 6842660Smarkm#define INFO_MENU_ENTRY_LABEL "\n* " 6942660Smarkm#define INFO_XREF_LABEL "*Note" 7042660Smarkm#define TAGS_TABLE_END_LABEL "\nEnd Tag Table" 7142660Smarkm#define TAGS_TABLE_BEG_LABEL "Tag Table:\n" 7242660Smarkm#define INDIRECT_TAGS_TABLE_LABEL "Indirect:\n" 7342660Smarkm#define TAGS_TABLE_IS_INDIRECT_LABEL "(Indirect)" 7421495Sjmacd 7556160Sru/* Character constants. */ 7621495Sjmacd#define INFO_COOKIE '\037' 7721495Sjmacd#define INFO_FF '\014' 7821495Sjmacd#define INFO_TAGSEP '\177' 7921495Sjmacd 8021495Sjmacd/* For each logical file that we have loaded, we keep a list of the names 8121495Sjmacd of the nodes that are found in that file. A pointer to a node in an 8221495Sjmacd info file is called a "tag". For split files, the tag pointer is 8321495Sjmacd "indirect"; that is, the pointer also contains the name of the split 8421495Sjmacd file where the node can be found. For non-split files, the filename 8521495Sjmacd member in the structure below simply contains the name of the current 8621495Sjmacd file. The following structure describes a single node within a file. */ 8721495Sjmacdtypedef struct { 8842660Smarkm char *filename; /* The file where this node can be found. */ 8942660Smarkm char *nodename; /* The node pointed to by this tag. */ 9042660Smarkm long nodestart; /* The offset of the start of this node. */ 9142660Smarkm long nodelen; /* The length of this node. */ 9221495Sjmacd} TAG; 9321495Sjmacd 9421495Sjmacd/* The following structure is used to remember information about the contents 9521495Sjmacd of Info files that we have loaded at least once before. The FINFO member 9621495Sjmacd is present so that we can reload the file if it has been modified since 9721495Sjmacd last being loaded. All of the arrays appearing within this structure 9821495Sjmacd are NULL terminated, and each array which can change size has a 9921495Sjmacd corresponding SLOTS member which says how many slots have been allocated 10021495Sjmacd (with malloc ()) for this array. */ 10121495Sjmacdtypedef struct { 10242660Smarkm char *filename; /* The filename used to find this file. */ 10342660Smarkm char *fullpath; /* The full pathname of this info file. */ 10442660Smarkm struct stat finfo; /* Information about this file. */ 10542660Smarkm char *contents; /* The contents of this particular file. */ 10642660Smarkm long filesize; /* The number of bytes this file expands to. */ 10742660Smarkm char **subfiles; /* If non-null, the list of subfiles. */ 10842660Smarkm TAG **tags; /* If non-null, the indirect tags table. */ 10942660Smarkm int tags_slots; /* Number of slots allocated for TAGS. */ 11042660Smarkm int flags; /* Various flags. Mimics of N_* flags. */ 11121495Sjmacd} FILE_BUFFER; 11256160Sru 11356160Sru/* Externally visible functions. */ 11421495Sjmacd 11521495Sjmacd/* Array of FILE_BUFFER * which represents the currently loaded info files. */ 11621495Sjmacdextern FILE_BUFFER **info_loaded_files; 11721495Sjmacd 11821495Sjmacd/* The number of slots currently allocated to INFO_LOADED_FILES. */ 11921495Sjmacdextern int info_loaded_files_slots; 12021495Sjmacd 12121495Sjmacd/* Locate the file named by FILENAME, and return the information structure 12221495Sjmacd describing this file. The file may appear in our list of loaded files 12321495Sjmacd already, or it may not. If it does not already appear, find the file, 12421495Sjmacd and add it to the list of loaded files. If the file cannot be found, 12521495Sjmacd return a NULL FILE_BUFFER *. */ 126146515Sruextern FILE_BUFFER *info_find_file (char *filename); 12721495Sjmacd 12821495Sjmacd/* Force load the file named FILENAME, and return the information structure 12921495Sjmacd describing this file. Even if the file was already loaded, this loads 13021495Sjmacd a new buffer, rebuilds tags and nodes, and returns a new FILE_BUFFER *. */ 131146515Sruextern FILE_BUFFER *info_load_file (char *filename); 13221495Sjmacd 13321495Sjmacd/* Return a pointer to a NODE structure for the Info node (FILENAME)NODENAME. 13421495Sjmacd FILENAME can be passed as NULL, in which case the filename of "dir" is used. 13521495Sjmacd NODENAME can be passed as NULL, in which case the nodename of "Top" is used. 13621495Sjmacd If the node cannot be found, return a NULL pointer. */ 137146515Sruextern NODE *info_get_node (char *filename, char *nodename); 13821495Sjmacd 13921495Sjmacd/* Return a pointer to a NODE structure for the Info node NODENAME in 14021495Sjmacd FILE_BUFFER. NODENAME can be passed as NULL, in which case the 14121495Sjmacd nodename of "Top" is used. If the node cannot be found, return a 14221495Sjmacd NULL pointer. */ 143146515Sruextern NODE *info_get_node_of_file_buffer (char *nodename, 144146515Sru FILE_BUFFER *file_buffer); 14521495Sjmacd 14621495Sjmacd/* Grovel FILE_BUFFER->contents finding tags and nodes, and filling in the 14721495Sjmacd various slots. This can also be used to rebuild a tag or node table. */ 148146515Sruextern void build_tags_and_nodes (FILE_BUFFER *file_buffer); 14921495Sjmacd 15021495Sjmacd/* When non-zero, this is a string describing the most recent file error. */ 15121495Sjmacdextern char *info_recent_file_error; 15221495Sjmacd 15321495Sjmacd/* Create a new, empty file buffer. */ 154146515Sruextern FILE_BUFFER *make_file_buffer (void); 15521495Sjmacd 15656160Sru#endif /* not NODES_H */ 157