home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / LASER / DJPRNT.ZIP / LIST.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1990-02-10  |  1.1 KB  |  53 lines

  1. /*
  2.     LIST.CPP
  3.     Copyright (c) Les Hancock 1990
  4. */
  5.  
  6. #include <string.h>
  7. #include "list.hpp"
  8.  
  9. /*
  10.     Add a filename to the fifo.
  11. */
  12. void
  13. file_list::push_file_name(const char *file_name)
  14. {
  15.     node *new_node = make_a_node(file_name);
  16.     if (head == 0)                    // if this is the first entry in the list
  17.         head = new_node;
  18.     else
  19.     {
  20.         for (node *ptr = head; ptr->next != 0; ptr = ptr->next);     // find end
  21.         ptr->next = new_node;
  22.     }
  23. }
  24.  
  25. /*
  26.     Create a new node and return its address.
  27. */
  28. node *
  29. file_list::make_a_node(const char *file_name)
  30. {
  31.     node *new_node = new node;
  32.     new_node->string = file_name;             // on command line, won't go away
  33.     new_node->next = 0;
  34.     return new_node;
  35. }
  36.  
  37. /*
  38.     Return ptr to the first string in the list of file names
  39.     and update head to take that node off the list.
  40. */
  41. const char *
  42. file_list::pop_file_name(void)
  43. {
  44.     if (head == 0)
  45.         return 0;                                    // nothing left in the fifo
  46.     node *old_head = head;
  47.     const char *old_string = head->string;
  48.     head = head->next;
  49.     delete old_head;
  50.     return old_string;
  51. }
  52.  
  53.