156160Sru/* node.h -- declarations for Node.
2146515Sru   $Id: node.h,v 1.2 2004/04/11 17:56:47 karl Exp $
356160Sru
4114472Sru   Copyright (C) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
556160Sru
656160Sru   This program is free software; you can redistribute it and/or modify
756160Sru   it under the terms of the GNU General Public License as published by
856160Sru   the Free Software Foundation; either version 2, or (at your option)
956160Sru   any later version.
1056160Sru
1156160Sru   This program is distributed in the hope that it will be useful,
1256160Sru   but WITHOUT ANY WARRANTY; without even the implied warranty of
1356160Sru   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1456160Sru   GNU General Public License for more details.
1556160Sru
1656160Sru   You should have received a copy of the GNU General Public License
1756160Sru   along with this program; if not, write to the Free Software
1856160Sru   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1956160Sru
2056160Sru   Written by Brian Fox (bfox@ai.mit.edu). */
2156160Sru
2256160Sru#ifndef NODE_H
2356160Sru#define NODE_H
2456160Sru
25146515Sru#include "xref.h"
26146515Sru
2756160Sru/* The various references that we know about. */
2856160Sru/* What we remember for each node. */
2956160Srutypedef struct tentry
3056160Sru{
3156160Sru  struct tentry *next_ent;
3256160Sru  char *node;           /* Name of this node. */
3356160Sru  char *prev;           /* Name of "Prev:" for this node. */
3456160Sru  char *next;           /* Name of "Next:" for this node. */
3556160Sru  char *up;             /* Name of "Up:" for this node.   */
3656160Sru  int position;         /* Output file position of this node. */
3756160Sru  int line_no;          /* Defining line in source file. */
3856160Sru  char *filename;       /* The file that this node was found in. */
3956160Sru  int touched;          /* Nonzero means this node has been referenced. */
4056160Sru  int flags;
4156160Sru  int number;           /* Number for this node, relevant for HTML
4256160Sru                           splitting -- from use+define order, not just
4356160Sru                           define. */
44146515Sru  int order;            /* The order of the tag, starting from zero.  */
4593139Sru  char *html_fname;	/* The HTML file to which this node is written
4693139Sru			   (non-NULL only for HTML splitting).  */
4756160Sru} TAG_ENTRY;
4856160Sru
4956160Sru/* If node-a has a "Next" for node-b, but node-b has no "Prev" for node-a,
5056160Sru   we turn on this flag bit in node-b's tag entry.  This means that when
5156160Sru   it is time to validate node-b, we don't report an additional error
5256160Sru   if there was no "Prev" field. */
5356160Sru#define TAG_FLAG_PREV_ERROR  1
5456160Sru#define TAG_FLAG_NEXT_ERROR  2
5556160Sru#define TAG_FLAG_UP_ERROR    4
5656160Sru#define TAG_FLAG_NO_WARN     8
5756160Sru#define TAG_FLAG_IS_TOP     16
5856160Sru#define TAG_FLAG_ANCHOR     32
5956160Sru
6056160Sru/* Menu reference, *note reference, and validation hacking. */
6156160Sru
6256160Sru/* A structure to remember references with.  A reference to a node is
6356160Sru   either an entry in a menu, or a cross-reference made with [px]ref. */
6456160Srutypedef struct node_ref
6556160Sru{
6656160Sru  struct node_ref *next;
6756160Sru  char *node;                   /* Name of node referred to. */
6856160Sru  char *containing_node;        /* Name of node containing this reference. */
6956160Sru  int line_no;                  /* Line number where the reference occurs. */
7056160Sru  int section;                  /* Section level where the reference occurs. */
7156160Sru  char *filename;               /* Name of file where the reference occurs. */
7256160Sru  enum reftype type;            /* Type of reference, either menu or note. */
7356160Sru  int number;                   /* Number for this node, relevant for
7456160Sru                                   HTML splitting -- from use+define
7556160Sru                                   order, not just define. */
7656160Sru} NODE_REF;
7756160Sru
7856160Sru/* The linked list of such structures. */
7956160Sruextern NODE_REF *node_references;
8056160Sru
8156160Sru/* A similar list for references occuring in @node next
8256160Sru   and similar references, needed for HTML. */
8356160Sruextern NODE_REF *node_node_references;
8456160Sru
8556160Sru/* List of all nodes.  */
8656160Sruextern TAG_ENTRY *tag_table;
8756160Sru
8856160Sru/* Counter for setting node_ref.number; zero is Top. */
8956160Sruextern int node_number;
9056160Sru
91146515Sru/* Node order counter.  */
92146515Sruextern int node_order;
93146515Sru
9456160Sru/* The current node's section level. */
9556160Sruextern int current_section;
9656160Sru
9756160Sru/* Nonzero when the next sectioning command should generate an anchor
9856160Sru   corresponding to the current node in HTML mode. */
9956160Sruextern int outstanding_node;
10056160Sru
101146515Sruextern TAG_ENTRY *find_node (char *name);
10256160Sru
10356160Sru/* A search string which is used to find a line defining a node. */
10456160SruDECLARE (char *, node_search_string, "\n@node ");
10556160Sru
10656160Sru/* Extract node name from a menu item. */
107146515Sruextern char *glean_node_from_menu (int remember_ref, enum reftype ref_type);
10856160Sru
10956160Sru/* Remember a node for later validation.  */
110146515Sruextern void remember_node_reference (char *node, int line, enum reftype type);
11156160Sru
11256160Sru/* Remember the name of the current output file.  */
113146515Sruextern void set_current_output_filename (const char *fname);
11456160Sru
11556160Sru/* Expand macros and commands in the node name and canonicalize
11656160Sru   whitespace in the resulting expansion.  */
117146515Sruextern char *expand_node_name (char *node);
11856160Sru
119146515Sruextern int number_of_node (char *node);
120146515Sru
121146515Sruextern void init_tag_table (void);
122146515Sruextern void write_tag_table (char *filename);
123146515Sruextern void free_node_references (void);
124146515Sruextern void free_node_node_references (void);
125146515Sruextern void validate_file (TAG_ENTRY *tag_table);
126146515Sruextern void split_file (char *filename, int size);
127146515Sruextern void clean_old_split_files (char *filename);
128146515Sru
12956160Sru#endif /* NODE_H */
130