home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the DOOM Programming Gurus / Tricks_of_the_Doom_Programming_Gurus.iso / bonus / linux / listlev / listlev.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-28  |  729 b   |  34 lines

  1.  
  2. /* This module lists the directory of a wadfile to stdout. */
  3.  
  4. #include    <stdio.h>
  5. #include    <ctype.h>
  6. #include    "doomdefs.h"
  7. #include    "directory.h"
  8.  
  9. #define ISMISSION(X)    ( \
  10.     X[0] == 'E' && isdigit(X[1]) && X[2] == 'M' && isdigit(X[3]) && !X[4] \
  11. )
  12.  
  13. int waddir(int fd)
  14. {
  15.     dir_entry entry;
  16.  
  17.     if ( set_directory(fd) < 0 ) {
  18.         fprintf(stderr, "Can't find the directory entries.\n");
  19.         return(-1);
  20.     }
  21.     while ( read(fd, (char *)&entry, ENTRY_SIZE) == ENTRY_SIZE ) {
  22.         /* Null terminate the name */
  23.         entry.name[8]='\0';
  24.         
  25.         /* Print it out, if it is a level... */
  26.         if ( ISMISSION(entry.name) ) printf("%s\n", entry.name);
  27.  
  28.         if ( strcasecmp(WADDIR_END, entry.name) == 0 )
  29.             break;
  30.     }
  31.     return(0);
  32. }
  33.  
  34.