#include "request.h"

long do_list( FILE *input )
{

  struct file_pos *help, *start;
  unsigned long lineno = 1;
  int c;
  int counter = 0;

  start = line;
  while( (c = getc( input )) != EOF )
    {
      line->string[counter] = c;
      if ( c == 10 )
	{
	  lineno++;
          help = (struct file_pos *)malloc( sizeof(struct file_pos) );
	    if (help == NULL)
	      {
	        fprintf( stderr, "Not enough memory to complete!\n" );
	        exit( -1 );
	      }
	    line->next = help;
	    help->prev = line;
	    line = help;
	    line->next = NULL;
            line->position = ftell( input );
            line->marked = 0;
            line->lineno = lineno;
	    line->string[counter] = 0;
	    counter = 0;
	    continue;
       	}
      counter++;
    }
  
  line = start;
  rewind( input );
  return lineno;

}    









