#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>

#include "mystuff.h"

extern int errno;

void main (int argc, char **argv) {
   char *filename;
   int which;

   switch (argc) {
      case 0: printf ("This can't happen.\n");
              break;
      case 1: /* No arguments; use stdin. */
              {
              dumpfile (0); /* note that fd 0 is always stdin */
	      }
      default: {
              int thefd;
              int i;
              for (i=1; i<argc; i++) {
                  thefd = open (argv[i], O_RDONLY, 0);
                  if (thefd != -1) {
                     dumpfile (thefd);
                     }
                  else {
                     write (2, "Problem opening file ", 21);
                     write (2, argv[i], strlen (argv[i]));
                     write (2, ".\n", 2);
                     /* Note that fd 2 is always stderr */
                     }
                  }
              break;
	      }
      }
   }

