#include "mit-copyright.h"

#include "zephyr.h"
#include <string.h>
#include <netdb.h>
#include <pwd.h>
#include <ctype.h>

#include <math.h>

#include <stdio.h>

typedef struct BUF_node *BUF_node_ptr;

typedef struct BUF_node {
  unsigned int is_null    : 1; /* this is set if the current node is a null *
				* node (used to terminate the ends of the   *
				* bidirectional linked list which is being  *
				* built... this doesn't represent a node,   *
				* quite, but, rather, a terminator to       *
				* precede the first node and follow the     *
				* last node)                                */
  unsigned int is_unknown : 1; /* this is set if the current node is unread *
				* (that is, if there is an invalid value in *
				* CR_node.offset)                           */
  unsigned int is_real    : 1; /* this is set if the current node has been  *
				* read (if CR_node.offset is valid)         */

  unsigned int is_text_scanned : 1; /* this is true if the node's text is   *
				     * actually contained in node_text      */

  long offset;                     /* this is the offset relative to the    *
				    * beginning of the file                 */
 
  char *node_text;             /* this structure is the text which precedes *
				* the carriage return of the node.          */
  
  BUF_node_ptr next_node; /* duh */
  BUF_node_ptr prev_node; /* duh */
};


struct filethang {
  struct BUF_node *first_node_ptr;
  struct BUF_node *current_node_ptr;
  int             current_node;
};

void go_to_next_carriage_return() {
bar;
};
     
struct BUF_node fetch_node(struct filethang *file, int node) {
  if (file->current_node == node) { /* the current node is the right one */
    return file->current_node_ptr;
  };
  if (file->current_node > node) {
    file->current_node_ptr = file->current_node_ptr.prev_node;
    file->current_node     = (file->current_node - 1);
    if !(file->current_node_ptr.is_real) {
      if file->current_node_ptr.is_null {
	printf("KaBOOOOOOm. Filewalk.c died 'cos it tried to walk off the\n");
	printf("end of the list.\n");
      };
      if file->current_node_ptr.is_unknown {
	find_its_offset() ;
	/* implement this! */
      };
	   







