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