Back to index

tetex-bin  3.0
Defines | Functions
man.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define MANPAGE_FILE_BUFFER_NAME   "*manpages*"

Functions

NODEmake_manpage_node (char *pagename)
NODEget_manpage_node (FILE_BUFFER *file_buffer, char *pagename)
FILE_BUFFERcreate_manpage_file_buffer (void)
long locate_manpage_xref (NODE *node, long int start, int dir)
REFERENCE ** xrefs_of_manpage (NODE *node)
REFERENCE ** manpage_xrefs_in_binding (NODE *node, SEARCH_BINDING *binding)

Define Documentation

#define MANPAGE_FILE_BUFFER_NAME   "*manpages*"

Definition at line 28 of file man.h.


Function Documentation

Definition at line 154 of file man.c.

{
  FILE_BUFFER *file_buffer = make_file_buffer ();
  file_buffer->filename = xstrdup (MANPAGE_FILE_BUFFER_NAME);
  file_buffer->fullpath = xstrdup (MANPAGE_FILE_BUFFER_NAME);
  file_buffer->finfo.st_size = 0;
  file_buffer->filesize = 0;
  file_buffer->contents = (char *)NULL;
  file_buffer->flags = (N_IsInternal | N_CannotGC | N_IsManPage);

  return (file_buffer);
}

Here is the call graph for this function:

Here is the caller graph for this function:

NODE* get_manpage_node ( FILE_BUFFER file_buffer,
char *  pagename 
)

Definition at line 69 of file man.c.

{
  NODE *node;

  node = manpage_node_of_file_buffer (file_buffer, pagename);

  if (!node)
    {
      char *page;

      page = get_manpage_contents (pagename);

      if (page)
        {
          char header[1024];
          long oldsize, newsize;
          int hlen, plen;
         char *old_contents = file_buffer->contents;

          sprintf (header, "\n\n%c\n%s %s,  %s %s,  %s (dir)\n\n",
                   INFO_COOKIE,
                   INFO_FILE_LABEL, file_buffer->filename,
                   INFO_NODE_LABEL, pagename,
                   INFO_UP_LABEL);
          oldsize = file_buffer->filesize;
          hlen = strlen (header);
          plen = strlen (page);
          newsize = (oldsize + hlen + plen);
          file_buffer->contents =
            (char *)xrealloc (file_buffer->contents, 1 + newsize);
          memcpy (file_buffer->contents + oldsize, header, hlen);
          memcpy (file_buffer->contents + oldsize + hlen, page, plen);
          file_buffer->contents[newsize] = '\0';
          file_buffer->filesize = newsize;
          file_buffer->finfo.st_size = newsize;
          build_tags_and_nodes (file_buffer);
          free (page);
         /* We have just relocated file_buffer->contents from under
            the feet of info_windows[] array.  Therefore, all the
            nodes on that list which are showing man pages have their
            contents member pointing into the blue.  Undo that harm.  */
         if (old_contents && oldsize && old_contents != file_buffer->contents)
           {
             int iw;
             INFO_WINDOW *info_win;
             char *old_contents_end = old_contents + oldsize;

             for (iw = 0; (info_win = info_windows[iw]); iw++)
              {
                int in;

                for (in = 0; in < info_win->nodes_index; in++)
                  {
                    NODE *tmp_node = info_win->nodes[in];

                    /* It really only suffices to see that node->filename
                      is "*manpages*".  But after several hours of
                      debugging this, would you blame me for being a bit
                      paranoid?  */
                    if (tmp_node && tmp_node->filename
                          && tmp_node->contents
                          && strcmp (tmp_node->filename,
                              MANPAGE_FILE_BUFFER_NAME) == 0
                          && tmp_node->contents >= old_contents
                          && tmp_node->contents + tmp_node->nodelen
                                <= old_contents_end)
                     {
                       info_win->nodes[in] =
                         manpage_node_of_file_buffer (file_buffer,
                                tmp_node->nodename);
                       free (tmp_node->nodename);
                       free (tmp_node);
                     }
                  }
              }
           }
        }

      node = manpage_node_of_file_buffer (file_buffer, pagename);
    }

  return (node);
}

Here is the call graph for this function:

Here is the caller graph for this function:

long locate_manpage_xref ( NODE node,
long int  start,
int  dir 
)

Definition at line 653 of file man.c.

{
  REFERENCE **refs;
  long position = -1;

  refs = xrefs_of_manpage (node);

  if (refs)
    {
      register int i, count;
      REFERENCE *entry;

      for (i = 0; refs[i]; i++);
      count = i;

      if (dir > 0)
        {
          for (i = 0; (entry = refs[i]); i++)
            if (entry->start > start)
              {
                position = entry->start;
                break;
              }
        }
      else
        {
          for (i = count - 1; i > -1; i--)
            {
              entry = refs[i];

              if (entry->start < start)
                {
                  position = entry->start;
                  break;
                }
            }
        }

      info_free_references (refs);
    }
  return (position);
}

Here is the call graph for this function:

Here is the caller graph for this function:

NODE* make_manpage_node ( char *  pagename)

Definition at line 63 of file man.c.

{
  return (info_get_node (MANPAGE_FILE_BUFFER_NAME, pagename));
}

Here is the call graph for this function:

REFERENCE** manpage_xrefs_in_binding ( NODE node,
SEARCH_BINDING binding 
)

Definition at line 700 of file man.c.

{
  register int i;
  REFERENCE **all_refs = xrefs_of_manpage (node);
  REFERENCE **brefs = (REFERENCE **)NULL;
  REFERENCE *entry;
  int brefs_index = 0;
  int brefs_slots = 0;
  int start, end;

  if (!all_refs)
    return ((REFERENCE **)NULL);

  start = binding->start + (binding->buffer - node->contents);
  end = binding->end + (binding->buffer - node->contents);

  for (i = 0; (entry = all_refs[i]); i++)
    {
      if ((entry->start > start) && (entry->end < end))
        {
          add_pointer_to_array
            (entry, brefs_index, brefs, brefs_slots, 10, REFERENCE *);
        }
      else
        {
          maybe_free (entry->label);
          maybe_free (entry->filename);
          maybe_free (entry->nodename);
          free (entry);
        }
    }

  free (all_refs);
  return (brefs);
}

Here is the call graph for this function:

Definition at line 585 of file man.c.

{
  SEARCH_BINDING *reference_section;
  REFERENCE **refs = (REFERENCE **)NULL;
  int refs_index = 0;
  int refs_slots = 0;
  long position;

  reference_section = find_reference_section (node);

  if (reference_section == (SEARCH_BINDING *)NULL)
    return ((REFERENCE **)NULL);

  /* Grovel the reference section building a list of references found there.
     A reference is alphabetic characters followed by non-whitespace text
     within parenthesis. */
  reference_section->flags = 0;

  while ((position = search_forward ("(", reference_section)) != -1)
    {
      register int start, end;

      for (start = position; start > reference_section->start; start--)
        if (whitespace (reference_section->buffer[start]))
          break;

      start++;

      for (end = position; end < reference_section->end; end++)
        {
          if (whitespace (reference_section->buffer[end]))
            {
              end = start;
              break;
            }

          if (reference_section->buffer[end] == ')')
            {
              end++;
              break;
            }
        }

      if (end != start)
        {
          REFERENCE *entry;
          int len = end - start;

          entry = (REFERENCE *)xmalloc (sizeof (REFERENCE));
          entry->label = (char *)xmalloc (1 + len);
          strncpy (entry->label, (reference_section->buffer) + start, len);
          entry->label[len] = '\0';
          entry->filename = xstrdup (node->filename);
          entry->nodename = xstrdup (entry->label);
          entry->start = start;
          entry->end = end;

          add_pointer_to_array
            (entry, refs_index, refs, refs_slots, 10, REFERENCE *);
        }

      reference_section->start = position + 1;
    }

  return (refs);
}

Here is the call graph for this function:

Here is the caller graph for this function: