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