home *** CD-ROM | disk | FTP | other *** search
- /*
- LIST.CPP
- Copyright (c) Les Hancock 1990
- */
-
- #include <string.h>
- #include "list.hpp"
-
- /*
- Add a filename to the fifo.
- */
- void
- file_list::push_file_name(const char *file_name)
- {
- node *new_node = make_a_node(file_name);
- if (head == 0) // if this is the first entry in the list
- head = new_node;
- else
- {
- for (node *ptr = head; ptr->next != 0; ptr = ptr->next); // find end
- ptr->next = new_node;
- }
- }
-
- /*
- Create a new node and return its address.
- */
- node *
- file_list::make_a_node(const char *file_name)
- {
- node *new_node = new node;
- new_node->string = file_name; // on command line, won't go away
- new_node->next = 0;
- return new_node;
- }
-
- /*
- Return ptr to the first string in the list of file names
- and update head to take that node off the list.
- */
- const char *
- file_list::pop_file_name(void)
- {
- if (head == 0)
- return 0; // nothing left in the fifo
- node *old_head = head;
- const char *old_string = head->string;
- head = head->next;
- delete old_head;
- return old_string;
- }
-
-