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