xref: /netbsd-src/external/gpl2/texinfo/dist/makeinfo/node.h (revision 29619d2afe564e54d657b83e5a3ae89584f83720)
1 /*	$NetBSD: node.h,v 1.1.1.1 2016/01/14 00:11:29 christos Exp $	*/
2 
3 /* node.h -- declarations for Node.
4    Id: node.h,v 1.2 2004/04/11 17:56:47 karl Exp
5 
6    Copyright (C) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
7 
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2, or (at your option)
11    any later version.
12 
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17 
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 
22    Written by Brian Fox (bfox@ai.mit.edu). */
23 
24 #ifndef NODE_H
25 #define NODE_H
26 
27 #include "xref.h"
28 
29 /* The various references that we know about. */
30 /* What we remember for each node. */
31 typedef struct tentry
32 {
33   struct tentry *next_ent;
34   char *node;           /* Name of this node. */
35   char *prev;           /* Name of "Prev:" for this node. */
36   char *next;           /* Name of "Next:" for this node. */
37   char *up;             /* Name of "Up:" for this node.   */
38   int position;         /* Output file position of this node. */
39   int line_no;          /* Defining line in source file. */
40   char *filename;       /* The file that this node was found in. */
41   int touched;          /* Nonzero means this node has been referenced. */
42   int flags;
43   int number;           /* Number for this node, relevant for HTML
44                            splitting -- from use+define order, not just
45                            define. */
46   int order;            /* The order of the tag, starting from zero.  */
47   char *html_fname;	/* The HTML file to which this node is written
48 			   (non-NULL only for HTML splitting).  */
49 } TAG_ENTRY;
50 
51 /* If node-a has a "Next" for node-b, but node-b has no "Prev" for node-a,
52    we turn on this flag bit in node-b's tag entry.  This means that when
53    it is time to validate node-b, we don't report an additional error
54    if there was no "Prev" field. */
55 #define TAG_FLAG_PREV_ERROR  1
56 #define TAG_FLAG_NEXT_ERROR  2
57 #define TAG_FLAG_UP_ERROR    4
58 #define TAG_FLAG_NO_WARN     8
59 #define TAG_FLAG_IS_TOP     16
60 #define TAG_FLAG_ANCHOR     32
61 
62 /* Menu reference, *note reference, and validation hacking. */
63 
64 /* A structure to remember references with.  A reference to a node is
65    either an entry in a menu, or a cross-reference made with [px]ref. */
66 typedef struct node_ref
67 {
68   struct node_ref *next;
69   char *node;                   /* Name of node referred to. */
70   char *containing_node;        /* Name of node containing this reference. */
71   int line_no;                  /* Line number where the reference occurs. */
72   int section;                  /* Section level where the reference occurs. */
73   char *filename;               /* Name of file where the reference occurs. */
74   enum reftype type;            /* Type of reference, either menu or note. */
75   int number;                   /* Number for this node, relevant for
76                                    HTML splitting -- from use+define
77                                    order, not just define. */
78 } NODE_REF;
79 
80 /* The linked list of such structures. */
81 extern NODE_REF *node_references;
82 
83 /* A similar list for references occuring in @node next
84    and similar references, needed for HTML. */
85 extern NODE_REF *node_node_references;
86 
87 /* List of all nodes.  */
88 extern TAG_ENTRY *tag_table;
89 
90 /* Counter for setting node_ref.number; zero is Top. */
91 extern int node_number;
92 
93 /* Node order counter.  */
94 extern int node_order;
95 
96 /* The current node's section level. */
97 extern int current_section;
98 
99 /* Nonzero when the next sectioning command should generate an anchor
100    corresponding to the current node in HTML mode. */
101 extern int outstanding_node;
102 
103 extern TAG_ENTRY *find_node (char *name);
104 
105 /* A search string which is used to find a line defining a node. */
106 DECLARE (char *, node_search_string, "\n@node ");
107 
108 /* Extract node name from a menu item. */
109 extern char *glean_node_from_menu (int remember_ref, enum reftype ref_type);
110 
111 /* Remember a node for later validation.  */
112 extern void remember_node_reference (char *node, int line, enum reftype type);
113 
114 /* Remember the name of the current output file.  */
115 extern void set_current_output_filename (const char *fname);
116 
117 /* Expand macros and commands in the node name and canonicalize
118    whitespace in the resulting expansion.  */
119 extern char *expand_node_name (char *node);
120 
121 extern int number_of_node (char *node);
122 
123 extern void init_tag_table (void);
124 extern void write_tag_table (char *filename);
125 extern void free_node_references (void);
126 extern void free_node_node_references (void);
127 extern void validate_file (TAG_ENTRY *tag_table);
128 extern void split_file (char *filename, int size);
129 extern void clean_old_split_files (char *filename);
130 
131 #endif /* NODE_H */
132