Back to index

tetex-bin  3.0
info-utils.h
Go to the documentation of this file.
00001 /* info-utils.h -- Exported functions and variables from info-utils.c.
00002    $Id: info-utils.h,v 1.4 2004/04/11 17:56:45 karl Exp $   
00003 
00004    Copyright (C) 1993, 1996, 1998, 2002, 2003, 2004 Free Software
00005    Foundation, Inc.
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 2, or (at your option)
00010    any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program; if not, write to the Free Software
00019    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00020 
00021    Written by Brian Fox (bfox@ai.mit.edu). */
00022 
00023 #ifndef INFO_UTILS_H
00024 #define INFO_UTILS_H
00025 
00026 #include "nodes.h"
00027 #include "window.h"
00028 #include "search.h"
00029 
00030 /* Structure which describes a node reference, such as a menu entry or
00031    cross reference.  Arrays of such references can be built by calling
00032    info_menus_of_node () or info_xrefs_of_node (). */
00033 typedef struct {
00034   char *label;          /* User Label. */
00035   char *filename;       /* File where this node can be found. */
00036   char *nodename;       /* Name of the node. */
00037   int start, end;       /* Offsets within the containing node of LABEL. */
00038   int line_number;      /* Specific line number a menu item points to.  */
00039 } REFERENCE;
00040 
00041 /* When non-zero, various display and input functions handle ISO Latin
00042    character sets correctly. */
00043 extern int ISO_Latin_p;
00044 
00045 /* Variable which holds the most recent filename parsed as a result of
00046    calling info_parse_xxx (). */
00047 extern char *info_parsed_filename;
00048 
00049 /* Variable which holds the most recent nodename parsed as a result of
00050    calling info_parse_xxx (). */
00051 extern char *info_parsed_nodename;
00052 
00053 /* Parse the filename and nodename out of STRING.  If STRING doesn't
00054    contain a filename (i.e., it is NOT (FILENAME)NODENAME) then set
00055    INFO_PARSED_FILENAME to NULL.  If second argument NEWLINES_OKAY is
00056    non-zero, it says to allow the nodename specification to cross a
00057    newline boundary (i.e., only `,', `.', or `TAB' can end the spec). */
00058 void info_parse_node (char *string, int newlines_okay);
00059 
00060 /* Return a NULL terminated array of REFERENCE * which represents the menu
00061    found in NODE.  If there is no menu in NODE, just return a NULL pointer. */
00062 extern REFERENCE **info_menu_of_node (NODE *node);
00063 
00064 /* Return a NULL terminated array of REFERENCE * which represents the cross
00065    refrences found in NODE.  If there are no cross references in NODE, just
00066    return a NULL pointer. */
00067 extern REFERENCE **info_xrefs_of_node (NODE *node);
00068 
00069 /* Glean cross references from BINDING->buffer + BINDING->start until
00070    BINDING->end.  Return an array of REFERENCE * that represents each
00071    cross reference in this range. */
00072 extern REFERENCE **info_xrefs (SEARCH_BINDING *binding);
00073 
00074 /* Get the entry associated with LABEL in REFERENCES.  Return a pointer to
00075    the reference if found, or NULL. */
00076 extern REFERENCE *info_get_labeled_reference (char *label,
00077     REFERENCE **references);
00078 
00079 /* Glean menu entries from BINDING->buffer + BINDING->start until we
00080    have looked at the entire contents of BINDING.  Return an array
00081    of REFERENCE * that represents each menu item in this range. */
00082 extern REFERENCE **info_menu_items (SEARCH_BINDING *binding);
00083 
00084 /* A utility function for concatenating REFERENCE **.  Returns a new
00085    REFERENCE ** which is the concatenation of REF1 and REF2.  The REF1
00086    and REF2 arrays are freed, but their contents are not. */
00087 REFERENCE **info_concatenate_references (REFERENCE **ref1, REFERENCE **ref2);
00088 
00089 /* Copy an existing reference into new memory.  */
00090 extern REFERENCE *info_copy_reference (REFERENCE *src);
00091 
00092 /* Free the data associated with REFERENCES. */
00093 extern void info_free_references (REFERENCE **references);
00094 
00095 /* Search for sequences of whitespace or newlines in STRING, replacing
00096    all such sequences with just a single space.  Remove whitespace from
00097    start and end of string. */
00098 void canonicalize_whitespace (char *string);
00099 
00100 /* Return a pointer to a string which is the printed representation
00101    of CHARACTER if it were printed at HPOS. */
00102 extern char *printed_representation (unsigned char character, int hpos);
00103 
00104 /* Return a pointer to the part of PATHNAME that simply defines the file. */
00105 extern char *filename_non_directory (char *pathname);
00106 
00107 /* Return non-zero if NODE is one especially created by Info. */
00108 extern int internal_info_node_p (NODE *node);
00109 
00110 /* Make NODE appear to be one especially created by Info, and give it NAME. */
00111 extern void name_internal_node (NODE *node, char *name);
00112 
00113 /* Return the window displaying NAME, the name of an internally created
00114    Info window. */
00115 extern WINDOW *get_internal_info_window (char *name);
00116 
00117 /* Return a window displaying the node NODE. */
00118 extern WINDOW *get_window_of_node (NODE *node);
00119 
00120 /* Return the node addressed by LABEL in NODE (usually one of "Prev:",
00121    "Next:", "Up:", "File:", or "Node:".  After a call to this function,
00122    the globals `info_parsed_nodename' and `info_parsed_filename' contain
00123    the information. */
00124 extern void info_parse_label (char *label, NODE *node);
00125 
00126 #define info_file_label_of_node(n) info_parse_label (INFO_FILE_LABEL, n)
00127 #define info_next_label_of_node(n) info_parse_label (INFO_NEXT_LABEL, n)
00128 #define info_up_label_of_node(n)   info_parse_label (INFO_UP_LABEL, n)
00129 #define info_prev_label_of_node(n) \
00130   do { \
00131     info_parse_label (INFO_PREV_LABEL, n); \
00132     if (!info_parsed_nodename && !info_parsed_filename) \
00133       info_parse_label (INFO_ALTPREV_LABEL, n); \
00134   } while (0)
00135 
00136 #endif /* not INFO_UTILS_H */