/* * MS2RT.C Program to copy MS-DOS files to RT-11 * * 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 #ifdef __STDC__ # include #else # include "stdlib.h" #endif #include "msport.h" #include "msdefs.h" #include "msfio.h" #include "msdir.h" #include "msstat.h" #define BUFSIZE (16*512) /* Read 16 blocks (sectors) at a time */ UCHAR buf[BUFSIZE]; char sInSpec[MSFILENAME_MAX+1]; /* Buffer for input file spec */ char sOutSpec[FILENAME_MAX+1]; /* " output */ MSSTAT fs; /* Wild-card structure */ main(argc,argv) int argc; char *argv[]; { MSDEV *pd; /* " device we're reading from */ char *pInName; /* Where to stuff the file name */ char *pOutName; /* " */ if (argc != 3) { printf("Usage: MS2RT wildspec dev:"); exit(EXIT_FAILURE); } switch (msffirst(argv[1], 0, &fs)) { case 0: pd = fs.pDEV; strcpy(sInSpec, pd->sName); /* Insert device name */ pInName = &sInSpec[strlen(sInSpec)]; /* Point to its end */ if (*(pInName-1) != ':') strcat(pInName++, ":"); strcpy(sOutSpec, argv[2]); /* Same for output device */ pOutName = strchr(sOutSpec, ':'); if (pOutName != NULL) pOutName++; else pOutName = sOutSpec; do { strcpy(pInName, fs.name); /* Append name to input device */ strcpy(pOutName, fs.name); /* Append name to output device */ FCopy(sOutSpec, sInSpec); } while ( msfnext(&fs) == 0); break; default: Fail(argv[1]); } } FCopy(sOut, sIn) char *sOut; char *sIn; { FILE *pFout; MSFILE *pFin; int len; int buflen; int fDone; int i; char busy[5]; if ((pFin = msfopen(sIn, "rb")) == NULL) Fail(sIn); if ((pFout = fopen(sOut, "wn")) == NULL) Fail(sOut); printf("Copying %s:%-12s to %s ", ((MSDEV *)pFin->pDEV)->sName, pFin->sName, pFout->io_name); i = 0; strcpy(busy, "-\\|/"); fDone = FALSE; while (!fDone) { buflen = 0; do { len = msfread(&buf[buflen], 1, SECTOR, pFin); if (len == 0) fDone = TRUE; buflen += len; printf("\b%c", busy[i]); i = ++i & 3; fflush(stdout); } while ( (buflen < BUFSIZE) && (len != 0)); if (fwrite(buf, 1, buflen, pFout) != buflen) Fail(pFout->io_name); } printf("\b \n"); if (fclose(pFout) != 0) Fail(pFout->io_name); if (msfclose(pFin) != 0) Fail(pFin->sName); } Fail(s) /* Print a message and exit */ char *s; { fprintf(stderr, "?MS2RT-F-"); msperror(s); exit(EXIT_FAILURE); }