Home | History | Annotate | Line # | Download | only in info
      1  1.1  christos /*	$NetBSD: info-utils.h,v 1.1.1.1 2016/01/14 00:11:29 christos Exp $	*/
      2  1.1  christos 
      3  1.1  christos /* info-utils.h -- Exported functions and variables from info-utils.c.
      4  1.1  christos    Id: info-utils.h,v 1.4 2004/04/11 17:56:45 karl Exp
      5  1.1  christos 
      6  1.1  christos    Copyright (C) 1993, 1996, 1998, 2002, 2003, 2004 Free Software
      7  1.1  christos    Foundation, Inc.
      8  1.1  christos 
      9  1.1  christos    This program is free software; you can redistribute it and/or modify
     10  1.1  christos    it under the terms of the GNU General Public License as published by
     11  1.1  christos    the Free Software Foundation; either version 2, or (at your option)
     12  1.1  christos    any later version.
     13  1.1  christos 
     14  1.1  christos    This program is distributed in the hope that it will be useful,
     15  1.1  christos    but WITHOUT ANY WARRANTY; without even the implied warranty of
     16  1.1  christos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     17  1.1  christos    GNU General Public License for more details.
     18  1.1  christos 
     19  1.1  christos    You should have received a copy of the GNU General Public License
     20  1.1  christos    along with this program; if not, write to the Free Software
     21  1.1  christos    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
     22  1.1  christos 
     23  1.1  christos    Written by Brian Fox (bfox (at) ai.mit.edu). */
     24  1.1  christos 
     25  1.1  christos #ifndef INFO_UTILS_H
     26  1.1  christos #define INFO_UTILS_H
     27  1.1  christos 
     28  1.1  christos #include "nodes.h"
     29  1.1  christos #include "window.h"
     30  1.1  christos #include "search.h"
     31  1.1  christos 
     32  1.1  christos /* Structure which describes a node reference, such as a menu entry or
     33  1.1  christos    cross reference.  Arrays of such references can be built by calling
     34  1.1  christos    info_menus_of_node () or info_xrefs_of_node (). */
     35  1.1  christos typedef struct {
     36  1.1  christos   char *label;          /* User Label. */
     37  1.1  christos   char *filename;       /* File where this node can be found. */
     38  1.1  christos   char *nodename;       /* Name of the node. */
     39  1.1  christos   int start, end;       /* Offsets within the containing node of LABEL. */
     40  1.1  christos   int line_number;      /* Specific line number a menu item points to.  */
     41  1.1  christos } REFERENCE;
     42  1.1  christos 
     43  1.1  christos /* When non-zero, various display and input functions handle ISO Latin
     44  1.1  christos    character sets correctly. */
     45  1.1  christos extern int ISO_Latin_p;
     46  1.1  christos 
     47  1.1  christos /* Variable which holds the most recent filename parsed as a result of
     48  1.1  christos    calling info_parse_xxx (). */
     49  1.1  christos extern char *info_parsed_filename;
     50  1.1  christos 
     51  1.1  christos /* Variable which holds the most recent nodename parsed as a result of
     52  1.1  christos    calling info_parse_xxx (). */
     53  1.1  christos extern char *info_parsed_nodename;
     54  1.1  christos 
     55  1.1  christos /* Parse the filename and nodename out of STRING.  If STRING doesn't
     56  1.1  christos    contain a filename (i.e., it is NOT (FILENAME)NODENAME) then set
     57  1.1  christos    INFO_PARSED_FILENAME to NULL.  If second argument NEWLINES_OKAY is
     58  1.1  christos    non-zero, it says to allow the nodename specification to cross a
     59  1.1  christos    newline boundary (i.e., only `,', `.', or `TAB' can end the spec). */
     60  1.1  christos void info_parse_node (char *string, int newlines_okay);
     61  1.1  christos 
     62  1.1  christos /* Return a NULL terminated array of REFERENCE * which represents the menu
     63  1.1  christos    found in NODE.  If there is no menu in NODE, just return a NULL pointer. */
     64  1.1  christos extern REFERENCE **info_menu_of_node (NODE *node);
     65  1.1  christos 
     66  1.1  christos /* Return a NULL terminated array of REFERENCE * which represents the cross
     67  1.1  christos    refrences found in NODE.  If there are no cross references in NODE, just
     68  1.1  christos    return a NULL pointer. */
     69  1.1  christos extern REFERENCE **info_xrefs_of_node (NODE *node);
     70  1.1  christos 
     71  1.1  christos /* Glean cross references from BINDING->buffer + BINDING->start until
     72  1.1  christos    BINDING->end.  Return an array of REFERENCE * that represents each
     73  1.1  christos    cross reference in this range. */
     74  1.1  christos extern REFERENCE **info_xrefs (SEARCH_BINDING *binding);
     75  1.1  christos 
     76  1.1  christos /* Get the entry associated with LABEL in REFERENCES.  Return a pointer to
     77  1.1  christos    the reference if found, or NULL. */
     78  1.1  christos extern REFERENCE *info_get_labeled_reference (char *label,
     79  1.1  christos     REFERENCE **references);
     80  1.1  christos 
     81  1.1  christos /* Glean menu entries from BINDING->buffer + BINDING->start until we
     82  1.1  christos    have looked at the entire contents of BINDING.  Return an array
     83  1.1  christos    of REFERENCE * that represents each menu item in this range. */
     84  1.1  christos extern REFERENCE **info_menu_items (SEARCH_BINDING *binding);
     85  1.1  christos 
     86  1.1  christos /* A utility function for concatenating REFERENCE **.  Returns a new
     87  1.1  christos    REFERENCE ** which is the concatenation of REF1 and REF2.  The REF1
     88  1.1  christos    and REF2 arrays are freed, but their contents are not. */
     89  1.1  christos REFERENCE **info_concatenate_references (REFERENCE **ref1, REFERENCE **ref2);
     90  1.1  christos 
     91  1.1  christos /* Copy an existing reference into new memory.  */
     92  1.1  christos extern REFERENCE *info_copy_reference (REFERENCE *src);
     93  1.1  christos 
     94  1.1  christos /* Free the data associated with REFERENCES. */
     95  1.1  christos extern void info_free_references (REFERENCE **references);
     96  1.1  christos 
     97  1.1  christos /* Search for sequences of whitespace or newlines in STRING, replacing
     98  1.1  christos    all such sequences with just a single space.  Remove whitespace from
     99  1.1  christos    start and end of string. */
    100  1.1  christos void canonicalize_whitespace (char *string);
    101  1.1  christos 
    102  1.1  christos /* Return a pointer to a string which is the printed representation
    103  1.1  christos    of CHARACTER if it were printed at HPOS. */
    104  1.1  christos extern char *printed_representation (unsigned char character, int hpos);
    105  1.1  christos 
    106  1.1  christos /* Return a pointer to the part of PATHNAME that simply defines the file. */
    107  1.1  christos extern char *filename_non_directory (char *pathname);
    108  1.1  christos 
    109  1.1  christos /* Return non-zero if NODE is one especially created by Info. */
    110  1.1  christos extern int internal_info_node_p (NODE *node);
    111  1.1  christos 
    112  1.1  christos /* Make NODE appear to be one especially created by Info, and give it NAME. */
    113  1.1  christos extern void name_internal_node (NODE *node, char *name);
    114  1.1  christos 
    115  1.1  christos /* Return the window displaying NAME, the name of an internally created
    116  1.1  christos    Info window. */
    117  1.1  christos extern WINDOW *get_internal_info_window (char *name);
    118  1.1  christos 
    119  1.1  christos /* Return a window displaying the node NODE. */
    120  1.1  christos extern WINDOW *get_window_of_node (NODE *node);
    121  1.1  christos 
    122  1.1  christos /* Return the node addressed by LABEL in NODE (usually one of "Prev:",
    123  1.1  christos    "Next:", "Up:", "File:", or "Node:".  After a call to this function,
    124  1.1  christos    the globals `info_parsed_nodename' and `info_parsed_filename' contain
    125  1.1  christos    the information. */
    126  1.1  christos extern void info_parse_label (char *label, NODE *node);
    127  1.1  christos 
    128  1.1  christos #define info_file_label_of_node(n) info_parse_label (INFO_FILE_LABEL, n)
    129  1.1  christos #define info_next_label_of_node(n) info_parse_label (INFO_NEXT_LABEL, n)
    130  1.1  christos #define info_up_label_of_node(n)   info_parse_label (INFO_UP_LABEL, n)
    131  1.1  christos #define info_prev_label_of_node(n) \
    132  1.1  christos   do { \
    133  1.1  christos     info_parse_label (INFO_PREV_LABEL, n); \
    134  1.1  christos     if (!info_parsed_nodename && !info_parsed_filename) \
    135  1.1  christos       info_parse_label (INFO_ALTPREV_LABEL, n); \
    136  1.1  christos   } while (0)
    137  1.1  christos 
    138  1.1  christos #endif /* not INFO_UTILS_H */
    139