/* * MSTY.C Program to type files from an MS-DOS directory format disk * * Copyright (c) 1991 Shal Farley * Cheshire Engineering Corporation * 650 Sierra Madre Villa Avenue, Suite 201 * Pasadena, California 91107 * (818) 351-5493 * (818) 351-8645 FAX * shal@alumni.caltech.edu * * This software may be used and distributed for any purpose without license or * royalty payments so long as the above copyright notice is preserved. If you * have any comments, bug fixes, improvements, or new programs based upon this * software I'd like to hear from you. */ #include #include "msport.h" #include "msdefs.h" #include "msfio.h" #include "msdir.h" #include "msstat.h" #include "mserrn.h" #define BUFSIZE 512 /* Read one block (sector) at a time */ #if 0 /* Make this a zero when not debugging */ # define SONAR(s) fprintf(stderr, s) #else # define SONAR(s) #endif char buf[BUFSIZE]; main(argc,argv) int argc; char *argv[]; { MSSTAT fs; char sfs[FILENAME_MAX+1+MSFILENAME_MAX+1]; if (argc != 2) { fprintf(stderr, "?MSTY-F-Usage: MSTY DEV:FILENAME.TYP or DEV:DIRNAM.TYP:FILENAME.TYP\n"); exit(1); } switch (msffirst(argv[1], 0, &fs)) { case 0: do { printf("============================"); printf(" %s ", fs.name); printf("============================\n"); strcpy(sfs, ((MSDEV *)fs.pDEV)->sName); strcat(sfs, ":"); strcat(sfs, fs.name); TypeFile(sfs); } while ( msfnext(&fs) == 0); case MSE_FNF: break; default: fprintf(stderr, "?MSDIR-F-"); msperror(NULL); fprintf(stderr, " %s\n", argv[1]); exit(1); } } TypeFile(s) /* Open and type a file */ char *s; /* File specification "DEV:FILENAME.TYP" */ { MSFILE *pf; int len; SONAR(("TypeFile(\"%s\")\n", s)); if ((pf = msfopen(s, "r")) == NULL) { msperror(s); exit(1); } while ( (len = msfread(buf, 1, BUFSIZE, pf)) != 0) { if (fwrite(buf, 1, len, stdout) != len) { perror("TypeFile: fwrite to stdout failed"); exit(1); } } }