/* BDEIN: import IBM Basic Data Exchange data-sets to CPM files */ #define DID 1 /* default IBM diskette drive: A=0 B=1 ... P=15 */ #include "BDSCIO.H" #include "BIOS.H" #include "BDOS.H" char d1index[26][128] /* image (in EBCDIC) of diskette-1 index track */ , ascii[256] /* ASCII equivalents of EBCDIC characters */ , iobuf[BUFSIZ] /* BDS C I/O control */ ; int dfltdrv /* 0=A 1=B ... 15=P drive we were using at start */ , apcrlf /* true to append \r\n to every record on output */ ; help() {puts("BDEIN is a CP/M program to import data from IBM Basic Data Exchange Diskettes\n"); puts(" i.e. 8\" soft-sectored single-sided single-density IBM diskette-1 type.\n"); puts("Program is invoked by the following, where \"A>\" is the CP/M prompt:\n"); puts("A>BDEIN or: A>BDEIN filename\n"); puts("With no filename the diskette directory is displayed.\n"); puts("Witè á filename (8 or less characters, no spaces)\n"); puts(" the named dataset is copied from the IBM diskette to a CPM file (same name).\n"); puts("The CPM file-extension is the IBM dataset volume sequence number (if any).\n"); puts("The CPM file is output in ASCII to the same disk as BDEIN was run from.\n"); puts("The IBM dataset must be in EBCDIC, and is assumed to be in drive B: .\n"); puts("To tell BDEIN the IBM diskette is in a different drive,\n"); puts(" use the drive name (with :) before the filename. E.g.:\n"); puts("A>BDEIN C: gives a directory of an IBM diskette in drive C:\n"); puts("M>J:BDEIN C:FRED copys C:FRED (IBM) to M:FRED (CPM)\n"); puts(" M> is CPM prompt to show you are logged into disk M:\n"); puts(" J: is the drive that \"BDEIN.COM\" and \"ASCII\" are on.\n"); puts("BDEIN requires CPM file \"ASCII\" on the same disk as BDEIN.COM .\n"); puts("CPM forces your command to UPPER-CASE: so you can't use lower-case names\n"); puts("Normally CPM files have a Carriage-return-Line-feed inserted after each IBM\n"); puts(" record, but this feature is canceled by adding \" -n\" to the command\n"); puts("Type \"BDEIN -?\" for more help\n"); } helps() {puts("\n\n\nThe command line to BDEIN is of the form:\n"); puts("A>BDEIN a1 a2 a3\n"); puts("where \"A>\" is the CPM prompt, \"BDEIN\" is the program name,\n"); puts("and \"a1 a2 a3\" represent details of the command.\n"); puts("No details is OK, but often at least one detail is needed.\n"); puts("Details are seperated from the command name \"BDEIN\" and from\n"); puts("other details by at least one space (or tab).\n"); puts("There are two types of details: those that begin with \"-\" and\n"); puts("those that don\'t.\n"); puts("Details that begin with \"-\" are allowed anywhere.\n"); puts("Currently only two are recognised: \"-n\" turns off automatic appending\n"); puts("of new-lines to each output record; \"-?\" displays this text.\n"); puts("Only one (or no) detail is permitted to not begin with \"-\".\n"); puts("Such a detail is the destination (output) CPM filename if a file is\n"); puts("being transferred.\n"); puts("If the filename is \"?\" then help is given rather than a file transferred.\n"); } main(argc,argv) int argc; char **argv; { int bdos(); dfltdrv = bdos(BDOS_RCD); /* 0=A 1=B ... 15=P */ #define ARGSIZ 11 char arg[ARGSIZ]; /* "D:12345678" */ arg[0]=0; apcrlf=1; /* default: append cr-lf to each record */ while (--argc) {if (*argv[argc]=='-') {if (strcmp(argv[argc],"-?")==0) { helps(); exit(); } else {if ( toupper(argv[argc][1])=='N' && argv[argc][2]==0 ) { apcrlf=0; } else {puts("\7Ignoring unknown switch:"); puts(argv[argc]); puts("\n"); } ; } ; } else /* have a non-switch argument */ {if (*arg) {puts("\7You may only type 1 argument excluding switches, but you typed:\n"); printf("%s\n%s\nSo I QUIT in utter confusion!\n",arg,argv[argc]); exit(); } ; /* is first arg */ int bufcpy(); if ( bufcpy(ARGSIZ,arg,argv[argc]) ) {puts("\7command argument too long!\n"); help(); exit(); } ; } ; } ; /* here with argument in arg[] */ if (strcmp(arg,"?")==0) {help(); exit(); } ; fsuck("ASCII",iobuf,ascii,256); int ibmdrive; /* CPM drive #: A=0 B=1 ... P=15 */ /* where the IBM diskette lives */ char *ap; /* points into argument */ ap = arg; if ( isalpha(*ap++) && *ap++==':' ) ibmdrive = (toupper(*arg)-'A') & 0xF; else {ibmdrive = DID; ap = arg; } ; /* ibmdrive known */ if (ibmdrive==dfltdrv) {printf("\7drive %c can\'t be both IBM & CPM format\n",ibmdrive+'A'); exit(); } ; bdos(BDOS_RD,1<