Back to index

tetex-bin  3.0
Classes | Defines | Functions | Variables
nodes.h File Reference
#include "info.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  NODE
struct  TAG
struct  FILE_BUFFER

Defines

#define N_HasTagsTable   0x01 /* This node was found through a tags table. */
#define N_TagsIndirect   0x02 /* The tags table was an indirect one. */
#define N_UpdateTags   0x04 /* The tags table is out of date. */
#define N_IsCompressed   0x08 /* The file is compressed on disk. */
#define N_IsInternal   0x10 /* This node was made by Info. */
#define N_CannotGC   0x20 /* File buffer cannot be gc'ed. */
#define N_IsManPage   0x40 /* This node is a manpage. */
#define N_FromAnchor   0x80 /* Synthesized for an anchor reference. */
#define INFO_FILE_LABEL   "File:"
#define INFO_REF_LABEL   "Ref:"
#define INFO_NODE_LABEL   "Node:"
#define INFO_PREV_LABEL   "Prev:"
#define INFO_ALTPREV_LABEL   "Previous:"
#define INFO_NEXT_LABEL   "Next:"
#define INFO_UP_LABEL   "Up:"
#define INFO_MENU_LABEL   "\n* Menu:"
#define INFO_MENU_ENTRY_LABEL   "\n* "
#define INFO_XREF_LABEL   "*Note"
#define TAGS_TABLE_END_LABEL   "\nEnd Tag Table"
#define TAGS_TABLE_BEG_LABEL   "Tag Table:\n"
#define INDIRECT_TAGS_TABLE_LABEL   "Indirect:\n"
#define TAGS_TABLE_IS_INDIRECT_LABEL   "(Indirect)"
#define INFO_COOKIE   '\037'
#define INFO_FF   '\014'
#define INFO_TAGSEP   '\177'

Functions

FILE_BUFFERinfo_find_file (char *filename)
FILE_BUFFERinfo_load_file (char *filename)
NODEinfo_get_node (char *filename, char *nodename)
NODEinfo_get_node_of_file_buffer (char *nodename, FILE_BUFFER *file_buffer)
void build_tags_and_nodes (FILE_BUFFER *file_buffer)
FILE_BUFFERmake_file_buffer (void)

Variables

FILE_BUFFER ** info_loaded_files
int info_loaded_files_slots
char * info_recent_file_error

Class Documentation

struct NODE

Definition at line 37 of file nodes.h.

Class Members
char * contents
unsigned long display_pos
char * filename
int flags
long nodelen
char * nodename
char * parent
struct TAG

Definition at line 87 of file nodes.h.

Class Members
char * filename
long nodelen
char * nodename
long nodestart
struct FILE_BUFFER

Definition at line 101 of file nodes.h.

Collaboration diagram for FILE_BUFFER:
Class Members
char * contents
char * filename
long filesize
int flags
char * fullpath
char ** subfiles
TAG ** tags
int tags_slots

Define Documentation

#define INDIRECT_TAGS_TABLE_LABEL   "Indirect:\n"

Definition at line 72 of file nodes.h.

#define INFO_ALTPREV_LABEL   "Previous:"

Definition at line 64 of file nodes.h.

#define INFO_COOKIE   '\037'

Definition at line 76 of file nodes.h.

#define INFO_FF   '\014'

Definition at line 77 of file nodes.h.

#define INFO_FILE_LABEL   "File:"

Definition at line 60 of file nodes.h.

#define INFO_MENU_ENTRY_LABEL   "\n* "

Definition at line 68 of file nodes.h.

#define INFO_MENU_LABEL   "\n* Menu:"

Definition at line 67 of file nodes.h.

#define INFO_NEXT_LABEL   "Next:"

Definition at line 65 of file nodes.h.

#define INFO_NODE_LABEL   "Node:"

Definition at line 62 of file nodes.h.

#define INFO_PREV_LABEL   "Prev:"

Definition at line 63 of file nodes.h.

#define INFO_REF_LABEL   "Ref:"

Definition at line 61 of file nodes.h.

#define INFO_TAGSEP   '\177'

Definition at line 78 of file nodes.h.

#define INFO_UP_LABEL   "Up:"

Definition at line 66 of file nodes.h.

#define INFO_XREF_LABEL   "*Note"

Definition at line 69 of file nodes.h.

#define N_CannotGC   0x20 /* File buffer cannot be gc'ed. */

Definition at line 53 of file nodes.h.

#define N_FromAnchor   0x80 /* Synthesized for an anchor reference. */

Definition at line 55 of file nodes.h.

#define N_HasTagsTable   0x01 /* This node was found through a tags table. */

Definition at line 48 of file nodes.h.

#define N_IsCompressed   0x08 /* The file is compressed on disk. */

Definition at line 51 of file nodes.h.

#define N_IsInternal   0x10 /* This node was made by Info. */

Definition at line 52 of file nodes.h.

#define N_IsManPage   0x40 /* This node is a manpage. */

Definition at line 54 of file nodes.h.

#define N_TagsIndirect   0x02 /* The tags table was an indirect one. */

Definition at line 49 of file nodes.h.

#define N_UpdateTags   0x04 /* The tags table is out of date. */

Definition at line 50 of file nodes.h.

#define TAGS_TABLE_BEG_LABEL   "Tag Table:\n"

Definition at line 71 of file nodes.h.

#define TAGS_TABLE_END_LABEL   "\nEnd Tag Table"

Definition at line 70 of file nodes.h.

#define TAGS_TABLE_IS_INDIRECT_LABEL   "(Indirect)"

Definition at line 73 of file nodes.h.


Function Documentation

Definition at line 386 of file nodes.c.

{
  SEARCH_BINDING binding;
  long position;

  free_file_buffer_tags (file_buffer);
  file_buffer->flags &= ~N_HasTagsTable;

  /* See if there is a tags table in this info file. */
  binding.buffer = file_buffer->contents;
  binding.start = file_buffer->filesize;
  binding.end = binding.start - 1000;
  if (binding.end < 0)
    binding.end = 0;
  binding.flags = S_FoldCase;

  position = search_backward (TAGS_TABLE_END_LABEL, &binding);

  /* If there is a tag table, find the start of it, and grovel over it
     extracting tag information. */
  if (position != -1)
    while (1)
      {
        long tags_table_begin, tags_table_end;

        binding.end = position;
        binding.start = binding.end - 5 - strlen (TAGS_TABLE_END_LABEL);
        if (binding.start < 0)
          binding.start = 0;

        position = find_node_separator (&binding);

        /* For this test, (and all others here) failure indicates a bogus
           tags table.  Grovel the file. */
        if (position == -1)
          break;

        /* Remember the end of the tags table. */
        binding.start = position;
        tags_table_end = binding.start;
        binding.end = 0;

        /* Locate the start of the tags table. */
        position = search_backward (TAGS_TABLE_BEG_LABEL, &binding);

        if (position == -1)
          break;

        binding.end = position;
        binding.start = binding.end - 5 - strlen (TAGS_TABLE_BEG_LABEL);
        position = find_node_separator (&binding);

        if (position == -1)
          break;

        /* The file contains a valid tags table.  Fill the FILE_BUFFER's
           tags member. */
        file_buffer->flags |= N_HasTagsTable;
        tags_table_begin = position;

        /* If this isn't an indirect tags table, just remember the nodes
           described locally in this tags table.  Note that binding.end
           is pointing to just after the beginning label. */
        binding.start = binding.end;
        binding.end = file_buffer->filesize;

        if (!looking_at (TAGS_TABLE_IS_INDIRECT_LABEL, &binding))
          {
            binding.start = tags_table_begin;
            binding.end = tags_table_end;
            get_nodes_of_tags_table (file_buffer, &binding);
            return;
          }
        else
          {
            /* This is an indirect tags table.  Build TAGS member. */
            SEARCH_BINDING indirect;

            indirect.start = tags_table_begin;
            indirect.end = 0;
            indirect.buffer = binding.buffer;
            indirect.flags = S_FoldCase;

            position = search_backward (INDIRECT_TAGS_TABLE_LABEL, &indirect);

            if (position == -1)
              {
                /* This file is malformed.  Give up. */
                return;
              }

            indirect.start = position;
            indirect.end = tags_table_begin;
            binding.start = tags_table_begin;
            binding.end = tags_table_end;
            get_tags_of_indirect_tags_table (file_buffer, &indirect, &binding);
            return;
          }
      }

  /* This file doesn't contain any kind of tags table.  Grovel the
     file and build node entries for it. */
  get_nodes_of_info_file (file_buffer);
}

Here is the call graph for this function:

Here is the caller graph for this function:

FILE_BUFFER* info_find_file ( char *  filename)

Definition at line 195 of file nodes.c.

Here is the call graph for this function:

Here is the caller graph for this function:

NODE* info_get_node ( char *  filename,
char *  nodename 
)

Definition at line 82 of file nodes.c.

{
  NODE *node;
  FILE_BUFFER *file_buffer = NULL;

  info_recent_file_error = NULL;
  info_parse_node (nodename, DONT_SKIP_NEWLINES);
  nodename = NULL;

  if (info_parsed_filename)
    filename = info_parsed_filename;

  if (info_parsed_nodename)
    nodename = info_parsed_nodename;

  /* If FILENAME is not specified, it defaults to "dir". */
  if (!filename)
    filename = "dir";

  /* If the file to be looked up is "dir", build the contents from all of
     the "dir"s and "localdir"s found in INFOPATH. */
  if (is_dir_name (filename))
    maybe_build_dir_node (filename);

  /* Find the correct info file, or give up.  */
  file_buffer = info_find_file (filename);
  if (!file_buffer)
    {
      if (filesys_error_number)
        info_recent_file_error =
          filesys_error_string (filename, filesys_error_number);
      return NULL;
    }

  /* Look for the node.  */
  node = info_get_node_of_file_buffer (nodename, file_buffer);

  /* If the node not found was "Top", try again with different case.  */
  if (!node && (nodename == NULL || strcasecmp (nodename, "Top") == 0))
    {
      node = info_get_node_of_file_buffer ("Top", file_buffer);
      if (!node)
        node = info_get_node_of_file_buffer ("top", file_buffer);
      if (!node)
        node = info_get_node_of_file_buffer ("TOP", file_buffer);
    }

  return node;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NODE* info_get_node_of_file_buffer ( char *  nodename,
FILE_BUFFER file_buffer 
)

Definition at line 137 of file nodes.c.

{
  NODE *node = NULL;

  /* If we are unable to find the file, we have to give up.  There isn't
     anything else we can do. */
  if (!file_buffer)
    return NULL;

  /* If the file buffer was gc'ed, reload the contents now. */
  if (!file_buffer->contents)
    info_reload_file_buffer_contents (file_buffer);

  /* If NODENAME is not specified, it defaults to "Top". */
  if (!nodename)
    nodename = "Top";

  /* If the name of the node that we wish to find is exactly "*", then the
     node body is the contents of the entire file.  Create and return such
     a node. */
  if (strcmp (nodename, "*") == 0)
    {
      node = (NODE *)xmalloc (sizeof (NODE));
      node->filename = file_buffer->fullpath;
      node->parent   = NULL;
      node->nodename = xstrdup ("*");
      node->contents = file_buffer->contents;
      node->nodelen = file_buffer->filesize;
      node->flags = 0;
      node->display_pos = 0;
    }
#if defined (HANDLE_MAN_PAGES)
  /* If the file buffer is the magic one associated with manpages, call
     the manpage node finding function instead. */
  else if (file_buffer->flags & N_IsManPage)
    {
        node = get_manpage_node (file_buffer, nodename);
    }
#endif /* HANDLE_MAN_PAGES */
  /* If this is the "main" info file, it might contain a tags table.  Search
     the tags table for an entry which matches the node that we want.  If
     there is a tags table, get the file which contains this node, but don't
     bother building a node list for it. */
  else if (file_buffer->tags)
    {
      node = info_node_of_file_buffer_tags (file_buffer, nodename);
    }

  /* Return the results of our node search. */
  return node;
}

Here is the call graph for this function:

Here is the caller graph for this function:

FILE_BUFFER* info_load_file ( char *  filename)

Definition at line 203 of file nodes.c.

Here is the call graph for this function:

Definition at line 1053 of file nodes.c.

{
  FILE_BUFFER *file_buffer = xmalloc (sizeof (FILE_BUFFER));

  file_buffer->filename = file_buffer->fullpath = NULL;
  file_buffer->contents = NULL;
  file_buffer->tags = NULL;
  file_buffer->subfiles = NULL;
  file_buffer->tags_slots = 0;
  file_buffer->flags = 0;

  return file_buffer;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 67 of file nodes.c.

Definition at line 70 of file nodes.c.

Definition at line 64 of file nodes.c.