xref: /openbsd-src/gnu/usr.bin/texinfo/makeinfo/node.h (revision a1acfa9b69ad64eb720639240c8438f11107dc85)
11cc83814Sespie /* node.h -- declarations for Node.
2*a1acfa9bSespie    $Id: node.h,v 1.1.1.3 2006/07/17 16:03:48 espie Exp $
31cc83814Sespie 
4*a1acfa9bSespie    Copyright (C) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
51cc83814Sespie 
61cc83814Sespie    This program is free software; you can redistribute it and/or modify
71cc83814Sespie    it under the terms of the GNU General Public License as published by
81cc83814Sespie    the Free Software Foundation; either version 2, or (at your option)
91cc83814Sespie    any later version.
101cc83814Sespie 
111cc83814Sespie    This program is distributed in the hope that it will be useful,
121cc83814Sespie    but WITHOUT ANY WARRANTY; without even the implied warranty of
131cc83814Sespie    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
141cc83814Sespie    GNU General Public License for more details.
151cc83814Sespie 
161cc83814Sespie    You should have received a copy of the GNU General Public License
171cc83814Sespie    along with this program; if not, write to the Free Software
181cc83814Sespie    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
191cc83814Sespie 
201cc83814Sespie    Written by Brian Fox (bfox@ai.mit.edu). */
211cc83814Sespie 
221cc83814Sespie #ifndef NODE_H
231cc83814Sespie #define NODE_H
241cc83814Sespie 
25*a1acfa9bSespie #include "xref.h"
26*a1acfa9bSespie 
271cc83814Sespie /* The various references that we know about. */
281cc83814Sespie /* What we remember for each node. */
291cc83814Sespie typedef struct tentry
301cc83814Sespie {
311cc83814Sespie   struct tentry *next_ent;
321cc83814Sespie   char *node;           /* Name of this node. */
331cc83814Sespie   char *prev;           /* Name of "Prev:" for this node. */
341cc83814Sespie   char *next;           /* Name of "Next:" for this node. */
351cc83814Sespie   char *up;             /* Name of "Up:" for this node.   */
361cc83814Sespie   int position;         /* Output file position of this node. */
371cc83814Sespie   int line_no;          /* Defining line in source file. */
381cc83814Sespie   char *filename;       /* The file that this node was found in. */
391cc83814Sespie   int touched;          /* Nonzero means this node has been referenced. */
401cc83814Sespie   int flags;
411cc83814Sespie   int number;           /* Number for this node, relevant for HTML
421cc83814Sespie                            splitting -- from use+define order, not just
431cc83814Sespie                            define. */
44*a1acfa9bSespie   int order;            /* The order of the tag, starting from zero.  */
453fb98d4aSespie   char *html_fname;	/* The HTML file to which this node is written
463fb98d4aSespie 			   (non-NULL only for HTML splitting).  */
471cc83814Sespie } TAG_ENTRY;
481cc83814Sespie 
491cc83814Sespie /* If node-a has a "Next" for node-b, but node-b has no "Prev" for node-a,
501cc83814Sespie    we turn on this flag bit in node-b's tag entry.  This means that when
511cc83814Sespie    it is time to validate node-b, we don't report an additional error
521cc83814Sespie    if there was no "Prev" field. */
531cc83814Sespie #define TAG_FLAG_PREV_ERROR  1
541cc83814Sespie #define TAG_FLAG_NEXT_ERROR  2
551cc83814Sespie #define TAG_FLAG_UP_ERROR    4
561cc83814Sespie #define TAG_FLAG_NO_WARN     8
571cc83814Sespie #define TAG_FLAG_IS_TOP     16
581cc83814Sespie #define TAG_FLAG_ANCHOR     32
591cc83814Sespie 
601cc83814Sespie /* Menu reference, *note reference, and validation hacking. */
611cc83814Sespie 
621cc83814Sespie /* A structure to remember references with.  A reference to a node is
631cc83814Sespie    either an entry in a menu, or a cross-reference made with [px]ref. */
641cc83814Sespie typedef struct node_ref
651cc83814Sespie {
661cc83814Sespie   struct node_ref *next;
671cc83814Sespie   char *node;                   /* Name of node referred to. */
681cc83814Sespie   char *containing_node;        /* Name of node containing this reference. */
691cc83814Sespie   int line_no;                  /* Line number where the reference occurs. */
701cc83814Sespie   int section;                  /* Section level where the reference occurs. */
711cc83814Sespie   char *filename;               /* Name of file where the reference occurs. */
721cc83814Sespie   enum reftype type;            /* Type of reference, either menu or note. */
731cc83814Sespie   int number;                   /* Number for this node, relevant for
741cc83814Sespie                                    HTML splitting -- from use+define
751cc83814Sespie                                    order, not just define. */
761cc83814Sespie } NODE_REF;
771cc83814Sespie 
781cc83814Sespie /* The linked list of such structures. */
791cc83814Sespie extern NODE_REF *node_references;
801cc83814Sespie 
811cc83814Sespie /* A similar list for references occuring in @node next
821cc83814Sespie    and similar references, needed for HTML. */
831cc83814Sespie extern NODE_REF *node_node_references;
841cc83814Sespie 
851cc83814Sespie /* List of all nodes.  */
861cc83814Sespie extern TAG_ENTRY *tag_table;
871cc83814Sespie 
881cc83814Sespie /* Counter for setting node_ref.number; zero is Top. */
891cc83814Sespie extern int node_number;
901cc83814Sespie 
91*a1acfa9bSespie /* Node order counter.  */
92*a1acfa9bSespie extern int node_order;
93*a1acfa9bSespie 
941cc83814Sespie /* The current node's section level. */
951cc83814Sespie extern int current_section;
961cc83814Sespie 
971cc83814Sespie /* Nonzero when the next sectioning command should generate an anchor
981cc83814Sespie    corresponding to the current node in HTML mode. */
991cc83814Sespie extern int outstanding_node;
1001cc83814Sespie 
101*a1acfa9bSespie extern TAG_ENTRY *find_node (char *name);
1021cc83814Sespie 
1031cc83814Sespie /* A search string which is used to find a line defining a node. */
1041cc83814Sespie DECLARE (char *, node_search_string, "\n@node ");
1051cc83814Sespie 
1061cc83814Sespie /* Extract node name from a menu item. */
107*a1acfa9bSespie extern char *glean_node_from_menu (int remember_ref, enum reftype ref_type);
1081cc83814Sespie 
1091cc83814Sespie /* Remember a node for later validation.  */
110*a1acfa9bSespie extern void remember_node_reference (char *node, int line, enum reftype type);
1111cc83814Sespie 
1121cc83814Sespie /* Remember the name of the current output file.  */
113*a1acfa9bSespie extern void set_current_output_filename (const char *fname);
1141cc83814Sespie 
1151cc83814Sespie /* Expand macros and commands in the node name and canonicalize
1161cc83814Sespie    whitespace in the resulting expansion.  */
117*a1acfa9bSespie extern char *expand_node_name (char *node);
118*a1acfa9bSespie 
119*a1acfa9bSespie extern int number_of_node (char *node);
120*a1acfa9bSespie 
121*a1acfa9bSespie extern void init_tag_table (void);
122*a1acfa9bSespie extern void write_tag_table (char *filename);
123*a1acfa9bSespie extern void free_node_references (void);
124*a1acfa9bSespie extern void free_node_node_references (void);
125*a1acfa9bSespie extern void validate_file (TAG_ENTRY *tag_table);
126*a1acfa9bSespie extern void split_file (char *filename, int size);
127*a1acfa9bSespie extern void clean_old_split_files (char *filename);
1281cc83814Sespie 
1291cc83814Sespie #endif /* NODE_H */
130