home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / apple2 / 47 < prev    next >
Encoding:
Internet Message Format  |  1991-05-02  |  31.0 KB

  1. From: jac@yoko.rutgers.edu (Jonathan A. Chandross)
  2. Newsgroups: comp.sources.apple2
  3. Subject: v001SRC029:  BinSCII for Unix
  4. Message-ID: <May.1.17.10.24.1991.22822@yoko.rutgers.edu>
  5. Date: 1 May 91 21:10:26 GMT
  6. Approved: jac@paul.rutgers.edu
  7.  
  8.  
  9. Submitted-by: Neil Parker (parker@corona.uoregon.edu)
  10. Posting-number: Volume 1, Source:29
  11. Archive-name: archive/unix/binscii/bsc
  12. Architecture: UNIX
  13. Version-number: 1.00
  14.  
  15. bsc is a program which creates BinSCII files on UNIX systems.
  16.  
  17. Enjoy.
  18.  
  19. =Read.Me
  20. -
  21. -Bsc
  22. -Version 1.00
  23. -
  24. -Bsc is a program which creates BinSCII files on UNIX systems.
  25. -
  26. -
  27. -COMPILING
  28. ----------
  29. -
  30. -To compile:
  31. -
  32. -        cc -o bsc bsc.c
  33. -
  34. -Bsc was written and tested on a BSD-based UNIX system.  If you have a
  35. -System V-based UNIX, you might try compiling with the command
  36. -
  37. -        cc -DSYSTEMV -o bsc bsc.c
  38. -
  39. -However, I don't really know whether or not this will work, since I
  40. -don't have access to a true System V UNIX system.  You may be on your
  41. -own here.
  42. -
  43. -After you compile bsc, feel free to rename it to whatever you want--it's
  44. -smart enough to figure out its own name.
  45. -
  46. -EXECUTING
  47. ----------
  48. -
  49. -To run bsc, use:
  50. -
  51. -     bsc [<options>] <filename>
  52. -
  53. -The following options are available:
  54. -
  55. -     -t type            Sets the ProDOS filetype stored in the BinSCII
  56. -                        header to "type".  The type may be specified in
  57. -                        any of several ways:
  58. -                               Type             Meaning
  59. -                               ----             -----------
  60. -                                LLL             3-letter abbreviation
  61. -                                dd              decimal
  62. -                                0xdd            hexadecimal
  63. -                                $dd             hexadecimal
  64. -                                0dd             octal
  65. -                        Note that a 3-letter abbreviation must be specified
  66. -                        in lowercase, and that if you use a hex number in
  67. -                        $dd format you will have to quote or escape the $
  68. -                        to protect it from the shell.  If no "-t" option is
  69. -                        present, the filetype will default to 6 (BIN).  (See
  70. -                        the file "pftypes.h" for a complete list of recognized
  71. -                        3-letter ProDOS filetype abbreviations.)
  72. -
  73. -     -a auxtype         Sets the stored ProDOS auxiliary filetype to
  74. -                        "auxtype".  The auxiliary type may specified in
  75. -                        any of the following forms:
  76. -                               Syntax           Base
  77. -                               ------           -----------
  78. -                                dd              decimal
  79. -                                $dd             hexadecimal
  80. -                                0xdd            hexadecimal
  81. -                                0dd             octal
  82. -                        If no "-a" options is present, the auxiliary
  83. -                        filetype will default to 0.
  84. -
  85. -     -m mode            Sets the stored ProDOS access mode to "mode"  The
  86. -                        mode may be one or more of the following:
  87. -                              Mode              Meaning
  88. -                              ----              ---------
  89. -                                d               destroy
  90. -                                n               rename
  91. -                                b               backup-needed
  92. -                                i               invisible
  93. -                                w               write
  94. -                                r               read
  95. -                        If no "-m" option is present, the access mode
  96. -                        defaults to "dnwr", which corresponds to an
  97. -                        "unlocked" ProDOS file.  To create a "locked"
  98. -                        file, use "-m r".
  99. -
  100. -     -s num             Sets the number of BinSCII segments per output file
  101. -                        to "num".  As above, the number may be specified in
  102. -                        decimal, hex, or octal.  If no "-s" option is present,
  103. -                        or if "num" is 0, then all BinSCII segments will be
  104. -                        written to a single output file.  To cause each
  105. -                        segment to go into its own output file (like the
  106. -                        Apple II BINSCII program), use "-s 1".  See below
  107. -                        for an explanation of output files.
  108. -
  109. -     -h                 Print a short summary of bsc's options on the
  110. -                        standard output.
  111. -
  112. -These options, if present, may appear in any order, provided that they
  113. -appear before the filename.  Spaces may appear between an option letter
  114. -and its value, but are not necessary.
  115. -
  116. -The filename is the name of the UNIX file to be BinSCII'd.  The stored
  117. -ProDOS filename will be taken from the UNIX name, with lowercase letters
  118. -converted to uppercase and with invalid characters replaced with the
  119. -letter "X".  The ProDOS name will be truncated to 15 letters if the UNIX
  120. -name is longer than that.
  121. -
  122. -The stored ProDOS creation and modification times will be taken from the
  123. -UNIX input file.
  124. -
  125. -The output of bsc is a set of one or more files, each containing one or
  126. -more BinSCII segments.  By default, all BinSCII segments are written to
  127. -a single output file, which has the same name as the input file with a
  128. -".0" appended to the end.  If the "-s" option is given on the command
  129. -line with a value greater than zero, then the number of segments per
  130. -output file will be limited to the specified value, and if more than one
  131. -output file is needed, the second file will have ".1" appended to the
  132. -name, the third will have ".2" appended, and so forth.  For example, if
  133. -"foo" is a large UNIX file, the command "bsc -s3 foo" will create files
  134. -"foo.0", "foo.1", "foo.2", etc., each containing 3 BinSCII segments.
  135. -
  136. -WARNING:  IF A FILE WITH THE SAME NAME AS A BSC OUTPUT FILE ALREADY
  137. -EXISTS, THE PRE-EXISTING FILE WILL BE SILENTLY OVERWRITTEN BY THE BSC
  138. -OUTPUT FILE.  Before typing "bsc foo", it is probably a good idea to
  139. -make sure you don't already have an important data file called "foo.0".
  140. -
  141. -Bsc will refuse to BinSCII a file larger than 16777216 bytes (16 meg),
  142. -since that is the maximum size of a ProDOS file.
  143. -
  144. -An example:  Suppose a UNIX file called "picture" contains a standard
  145. -Apple IIGS super-hires screen image.  The command
  146. -
  147. -     bsc -tpic picture
  148. -
  149. -will create the file "picture.0" in a format suitable for downloading to
  150. -an Apple II and un-BinSCIIing, or for posting to comp.binaries.apple2.
  151. -When un-BinSCII'd on an Apple II, it will automatically be converted to
  152. -a PIC ($C1) file.
  153. -
  154. -INFORMATION
  155. ------------
  156. -
  157. -This program is freeware.  It comes with no warranty of any kind--in
  158. -particular, I cannot guarantee that it is free of bugs.  Use it at your
  159. -own risk.
  160. -
  161. -When the inevitable bugs DO appear, send e-mail to one of the addresses
  162. -below.  I welcome bug reports, comments, complaints, and suggestions for
  163. -improvement.
  164. -
  165. -Thanks to Marcel J. E. Mol, whose sciibin program was a valuable source
  166. -of technical information on BinSCII.
  167. -
  168. -               - Neil Parker
  169. -                 parker@corona.uoregon.edu
  170. -                 nparker@cie.uoregon.edu
  171. -                 parkern@jacobs.cs.orst.edu
  172. -
  173. =bsc.c
  174. -/*
  175. - * Program: bsc.c
  176. - * Version: 1.0
  177. - * Author:  Neil Parker
  178. - * Date:    14 Mar 1991
  179. - * Files:   bsc.c     (source code)
  180. - *          crc.h     (CRC generation routine)
  181. - *          pftypes.h (ProDOS file types)
  182. - * Purpose: Create BinSCII files on UNIX
  183. - *
  184. - * This program is freeware.  It comes with no warranty whatsoever; use
  185. - * at your own risk.
  186. - */
  187. -#include <stdio.h>
  188. -#ifdef SYSTEMV
  189. -#include <string.h>
  190. -#define rindex strrchr
  191. -#else
  192. -#include <strings.h>
  193. -#endif
  194. -#include <sys/types.h>
  195. -#include <sys/stat.h>
  196. -#include <time.h>
  197. -#include <ctype.h>
  198. -#include "crc.h"
  199. -#include "pftypes.h"
  200. -
  201. -unsigned int getnumber(),getftype();
  202. -
  203. -unsigned char inbuf[49],   /* buffer for reading from input */
  204. -              header[28];  /* buffer for BinSCII header */
  205. -
  206. -char outbuf[65],           /* buffer for coded output lines */
  207. -     binsciifile[256],     /* buffer for ProDOS filename in header */
  208. -     *infile,              /* name of input file */
  209. -     outfile[256],         /* name of current output file */
  210. -     *filestart="FiLeStArTfIlEsTaRt", /* BinSCII intro marker */
  211. -     *alphabet=            /* code alphabet */
  212. -     "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789()",
  213. -     *progname;            /* program name, for error messages */
  214. -
  215. -unsigned int crc,          /* running CRC counter */
  216. -             processed,    /* number of bytes already processed */
  217. -             remaining,    /* number of bytes yet to be processed */
  218. -             auxtype=0,    /* ProDOS aux type (default=0) */
  219. -             access=0xc3,  /* ProDOS access mode (default=dnwr) */
  220. -             filetype=6,   /* ProDOS file type (default=bin) */
  221. -             storagetype,  /* ProDOS file storage type */
  222. -             blocks,       /* number of blocks in ProDOS file */
  223. -             seqno,        /* output file sequence number */
  224. -             segsplit=0;   /* output segment split count (default=0) */
  225. -             segno;        /* output segment number */
  226. -
  227. -long filesize,             /* input file size */
  228. -     segmentlen;           /* count of bytes remaining in current segment */
  229. -
  230. -FILE *fi,                  /* input file pointer */
  231. -     *fo;                  /* current output file pointer */
  232. -
  233. -main(argc,argv)
  234. -int argc;
  235. -char **argv;
  236. -{
  237. -        char *c;
  238. -        unsigned char *uc;
  239. -        unsigned int numread;
  240. -        long lastbyte;
  241. -        struct stat statbuf;
  242. -        struct tm *timebuf;
  243. -
  244. -/* get program so we can print it in usage() and help() */
  245. -
  246. -        if((progname=rindex(*argv,'/'))==NULL)
  247. -                progname= *argv;
  248. -        else
  249. -                progname++;
  250. -
  251. -/* get and interpret command-line arguments */
  252. -
  253. -        if(argc<2)
  254. -                usage();
  255. -
  256. -        while(argc-- >1) {
  257. -                argv++;
  258. -                if(**argv=='-') {
  259. -                        switch(argv[0][1]) {
  260. -
  261. -                        case 'h': /* help */
  262. -                                help(); /* doesn't return */
  263. -
  264. -                        case 't': /* type */
  265. -                                c= *argv+2;
  266. -                                if(*c=='\0') {
  267. -                                        argv++;
  268. -                                        argc--;
  269. -                                        if(argc<1)
  270. -                                                usage();
  271. -                                        c= *argv;
  272. -                                }
  273. -                                filetype=getftype(c);
  274. -                                break;
  275. -
  276. -                        case 'a': /* auxtype */
  277. -                                c= *argv+2;
  278. -                                if(*c=='\0') {
  279. -                                        argv++;
  280. -                                        argc--;
  281. -                                        if(argc<1)
  282. -                                                usage();
  283. -                                        c= *argv;
  284. -                                }
  285. -                                auxtype=getnumber(c);
  286. -                                break;
  287. -                        
  288. -                        case 's': /* segments/file */
  289. -                                c= *argv+2;
  290. -                                if(*c=='\0') {
  291. -                                        argv++;
  292. -                                        argc--;
  293. -                                        if(argc<1)
  294. -                                                usage();
  295. -                                        c= *argv;
  296. -                                }
  297. -                                segsplit=getnumber(c);
  298. -                                segsplit=segsplit==0?32767:segsplit;
  299. -                                break;
  300. -
  301. -                        case 'm': /* access mode */
  302. -                                c= *argv+2;
  303. -                                if(*c=='\0') {
  304. -                                        argv++;
  305. -                                        argc--;
  306. -                                        if(argc<1)
  307. -                                                usage();
  308. -                                        c= *argv;
  309. -                                }
  310. -                                access=0;
  311. -                                while(*c!='\0') {
  312. -                                        switch(*c) {
  313. -                                        case 'd':
  314. -                                                access|=0x80;
  315. -                                                break;
  316. -                                        case 'n':
  317. -                                                access|=0x40;
  318. -                                                break;
  319. -                                        case 'b':
  320. -                                                access|=0x20;
  321. -                                                break;
  322. -                                        case 'i':
  323. -                                                access|=0x04;
  324. -                                                break;
  325. -                                        case 'w':
  326. -                                                access|=0x02;
  327. -                                                break;
  328. -                                        case 'r':
  329. -                                                access|=0x01;
  330. -                                                break;
  331. -                                        default:
  332. -                                                usage();
  333. -                                        }
  334. -                                        c++;
  335. -                                }
  336. -                                break;
  337. -
  338. -                        default:
  339. -                                usage();
  340. -
  341. -                        } /* END switch(argv[0][1]) */
  342. -                } else { /* **argv!='-' */
  343. -
  344. -                        infile= *argv;
  345. -                        if(argc>1) /* filename must be last arg */
  346. -                                usage();
  347. -
  348. -                } /* END if(**argv=='-') */
  349. -
  350. -        } /* END while(argc-->1) */
  351. -
  352. -/* Convert UNIX pathname into valid ProDOS file name */
  353. -
  354. -        if((c=rindex(infile,'/'))==NULL) /* delete leading path components */
  355. -                c=infile;
  356. -        else
  357. -                c++;
  358. -
  359. -        strcpy(&binsciifile[1],c);
  360. -        c=binsciifile+1;
  361. -
  362. -        if(!isalpha(*c)) /* initial invalid char -> 'X' */
  363. -                *c='X';
  364. -        for(;*c!='\0';c++)
  365. -                if(isalnum(*c)||*c=='.') {
  366. -                        if(islower(*c))        /* upshift lowercase */
  367. -                                *c=toupper(*c);
  368. -                } else                         /* invalid char -> 'X' */
  369. -                        *c='X';
  370. -
  371. -        c=binsciifile+1;
  372. -        if(*c=='\0') {
  373. -                fprintf(stderr,"empty ProDOS file name\n");
  374. -                exit(1);
  375. -        }
  376. -        c[15]='\0';  /* truncate name at 15 chars */
  377. -        binsciifile[0]=alphabet[strlen(c)-1]; /* encode name length */
  378. -        strcat(c,"                "); /* 16 spaces */
  379. -        c[15]='\0';  /* pad with spaces, and truncate to 15 again */
  380. -
  381. -/* Make sure input file exists, and get its size and dates */
  382. -
  383. -        if(stat(infile,&statbuf)<0) {
  384. -                perror("getting input file status");
  385. -                exit(1);
  386. -        }
  387. -
  388. -        filesize=statbuf.st_size;
  389. -        lastbyte=filesize-1;
  390. -        if(filesize>16777216L) { /* ProDOS can't handle files >16Mb */
  391. -                fprintf(stderr,"Input file too big for ProDOS\n");
  392. -                exit(1);
  393. -        }
  394. -
  395. -        if(filesize>131072L) {
  396. -                storagetype=3; /* tree */
  397. -                blocks=3+lastbyte/131072+lastbyte/512;
  398. -        } else if(filesize>512L) {
  399. -                storagetype=2; /* sapling */
  400. -                blocks=2+lastbyte/512;
  401. -        } else {
  402. -                storagetype=1; /* seedling */
  403. -                blocks=1;
  404. -        }
  405. -
  406. -/* Get file times into BinSCII header */
  407. -
  408. -        timebuf=localtime(&statbuf.st_ctime);
  409. -        timebuf->tm_mon+=1; /* UNIX month is 0-11, ProDOS is 1-12 */
  410. -        header[13]=timebuf->tm_mday|(timebuf->tm_mon<<5); /* create date */
  411. -        header[14]=(timebuf->tm_mon>>3)|(timebuf->tm_year<<1);
  412. -        header[15]=timebuf->tm_min; /* create time */
  413. -        header[16]=timebuf->tm_hour;
  414. -
  415. -        timebuf=localtime(&statbuf.st_mtime);
  416. -        timebuf->tm_mon+=1;
  417. -        header[17]=timebuf->tm_mday|(timebuf->tm_mon<<5); /* mod date */
  418. -        header[18]=(timebuf->tm_mon>>3)|(timebuf->tm_year<<1);
  419. -        header[19]=timebuf->tm_min; /* mod time */
  420. -        header[20]=timebuf->tm_hour;
  421. -
  422. -/* Fill out remaining constant portion of header */
  423. -
  424. -        header[0]=filesize&0xff;
  425. -        header[1]=(filesize>>8)&0xff;
  426. -        header[2]=(filesize>>16)&0xff;
  427. -
  428. -        header[6]=access;
  429. -
  430. -        header[7]=filetype;
  431. -
  432. -        header[8]=auxtype&0xff;
  433. -        header[9]=(auxtype>>8)&0xff;
  434. -
  435. -        header[10]=storagetype;
  436. -
  437. -        header[11]=blocks&0xff;
  438. -        header[12]=(blocks>>8)&0xff;
  439. -
  440. -        header[26]=0;
  441. -
  442. -/* open input file; initialize counters */
  443. -
  444. -        if((fi=fopen(infile,"r"))==NULL) {
  445. -                perror("opening input file");
  446. -                exit(1);
  447. -        }
  448. -
  449. -        processed=0;
  450. -        remaining=filesize;
  451. -        segno=0;
  452. -        seqno=0;
  453. -
  454. -        while(remaining>0) { /* loop until nothing left to process */
  455. -
  456. -                segmentlen=remaining>0x3000?0x3000:remaining;
  457. -                     /* max segment size is 0x3000 */
  458. -
  459. -/* see if new output file should be created--if so, form name and create
  460. -   it */
  461. -
  462. -                if(segno==0) {
  463. -                        sprintf(outfile,"%s.%d",infile,seqno++);
  464. -                        if((fo=fopen(outfile,"w"))==NULL) {
  465. -                                sprintf(outbuf,
  466. -                                        "opening output file %s",outfile);
  467. -                                perror(outbuf);
  468. -                                exit(1);
  469. -                        }
  470. -                }
  471. -
  472. -/* write headers to new file */
  473. -
  474. -                fprintf(fo,"%s\n",filestart);
  475. -                fprintf(fo,"%s\n",alphabet);
  476. -                fprintf(fo,"%s",binsciifile);
  477. -
  478. -/* set up variable part of header */
  479. -
  480. -                header[3]=processed&0xff; /* start addr of this seg */
  481. -                header[4]=(processed>>8)&0xff;
  482. -                header[5]=(processed>>16)&0xff;
  483. -
  484. -                header[21]=segmentlen&0xff; /* length of this seg */
  485. -                header[22]=(segmentlen>>8)&0xff;
  486. -                header[23]=(segmentlen>>16)&0xff;
  487. -
  488. -/* compute header CRC */
  489. -
  490. -                crc=0;
  491. -                for(uc=header;uc!=header+24;uc++)
  492. -                        crc=updcrc(*uc,crc);
  493. -
  494. -                header[24]=crc&0xff;
  495. -                header[25]=(crc>>8)&0xff;
  496. -
  497. -/* code header and send it on its way */
  498. -
  499. -                encode(header,outbuf,27);
  500. -                fprintf(fo,"%s\n",outbuf);
  501. -
  502. -/* start working on segment data */
  503. -
  504. -                crc=0;
  505. -                while(segmentlen>0) { /* loop until end of seg */
  506. -
  507. -                        bzero(inbuf,48); /* zero buffer in case there's
  508. -                             not enough data to fill it */
  509. -
  510. -/* get 48 bytes (or less if at end) from file */
  511. -
  512. -                        if((int)(numread=fread(inbuf,1,48,fi))<0) {
  513. -                                perror("reading input file");
  514. -                                exit(0);
  515. -                        }
  516. -
  517. -/* update CRC for this line */
  518. -
  519. -                        for(uc=inbuf;uc!=inbuf+48;uc++)
  520. -                                crc=updcrc(*uc,crc);
  521. -
  522. -/* code the line and send it on its way */
  523. -
  524. -                        encode(inbuf,outbuf,48);
  525. -                        fprintf(fo,"%s\n",outbuf);
  526. -
  527. -                        segmentlen-=numread;
  528. -                        remaining-=numread;
  529. -                        processed+=numread;
  530. -                } /* END while(segmentlen>0) */
  531. -
  532. -/* end of segment--code and write the CRC */
  533. -
  534. -                inbuf[0]=crc&0xff;
  535. -                inbuf[1]=(crc>>8)&0xff;
  536. -                inbuf[2]=0;
  537. -
  538. -                encode(inbuf,outbuf,3);
  539. -                fprintf(fo,"%s\n",outbuf);
  540. -
  541. -/* if end of output file, close it and prepare for next output file */
  542. -
  543. -                if(++segno==segsplit) {
  544. -                        segno=0;
  545. -                        fclose(fo);
  546. -                }
  547. -
  548. -        } /* END while(remaining>0) */
  549. -
  550. -/* all done--close and exit */
  551. -
  552. -        if(segno!=0)
  553. -                fclose(fo);
  554. -        fclose(fi);
  555. -        exit(0);
  556. -}
  557. -
  558. -/* subroutine to encode a line of data */
  559. -
  560. -encode(input,output,length)
  561. -unsigned char *input;
  562. -char *output;
  563. -int length;
  564. -{
  565. -        int i;
  566. -        char *o;
  567. -
  568. -        o=output;
  569. -        for(i=0;i<length;i+=3) {
  570. -                *o++ =alphabet[input[i+2]&0x3f];
  571. -                *o++ =alphabet[((input[i+2]>>6)|(input[i+1]<<2))&0x3f];
  572. -                *o++ =alphabet[((input[i+1]>>4)|(input[i]<<4))&0x3f];
  573. -                *o++ =alphabet[input[i]>>2];
  574. -        }
  575. -        *o='\0';
  576. -}
  577. -
  578. -/* subroutine to get a file type from the command line */
  579. -
  580. -unsigned int getftype(c)
  581. -char *c;
  582. -{
  583. -        int i;
  584. -        unsigned int retcode;
  585. -
  586. -        for(i=0;i<FTYPESIZE;i++) /* loop over file types */
  587. -                if(!strcmp(c,filetypes[i].name)) {
  588. -                        retcode=filetypes[i].code;
  589. -                        return retcode&0xff;
  590. -                }
  591. -        return getnumber(c)&0xff; /* if not found, try to parse a number */
  592. -}
  593. -
  594. -/* subroutine to get a decimal, hex, or octal number from command line */
  595. -
  596. -unsigned int getnumber(c)
  597. -char *c;
  598. -{
  599. -        unsigned int i;
  600. -
  601. -        if(*c=='$') { /* $nn -> hex */
  602. -                sscanf(c+1,"%x",&i);
  603. -                return i;
  604. -        }
  605. -        if(!isdigit(*c))
  606. -                usage();
  607. -        if(*c=='0')
  608. -                if(c[1]=='x'||c[1]=='X')
  609. -                        sscanf(c+2,"%x",&i); /* 0xnn or 0Xnn -> hex */
  610. -                else
  611. -                        sscanf(c,"%o",&i);   /* 0nn -> octal */
  612. -        else
  613. -                sscanf(c,"%d",&i);           /* nn -> decimal */
  614. -        return i;
  615. -}
  616. -
  617. -usage()
  618. -{
  619. -        fprintf(stderr,
  620. -                "usage: %s [-t <type>] [-a <aux>] [-m <mode>] [-s <num>] <file>\n",
  621. -                progname);
  622. -        fprintf(stderr,"       %s -h     (for help)\n",progname);
  623. -        exit(1);
  624. -}
  625. -
  626. -help()
  627. -{
  628. -        printf("Usage: %s [<args>] <file>\n",progname);
  629. -        printf("args: -t <type> = set ProDOS file type to <type>\n");
  630. -        printf("      -a <aux>  = set ProDOS aux type to <aux>\n");
  631. -        printf("      -m <mode> = set ProDOS access mode--<mode> may be any\n");
  632. -        printf("                  combination of d, n, b, i, w, or r\n");
  633. -        printf("      -s <num>  = set number of segs/output file to <num>\n");
  634. -        printf("      -h        = print this help message\n");
  635. -        exit(0);
  636. -}
  637. =crc.h
  638. -/*
  639. - * updcrc macro derived from article Copyright (C) 1986 Stephen Satchell. 
  640. - *  NOTE: First srgument must be in range 0 to 255.
  641. - *        Second argument is referenced twice.
  642. - * 
  643. - * Programmers may incorporate any or all code into their programs, 
  644. - * giving proper credit within the source. Publication of the 
  645. - * source routines is permitted so long as proper credit is given 
  646. - * to Stephen Satchell, Satchell Evaluations and Chuck Forsberg, 
  647. - * Omen Technology.
  648. - */
  649. -
  650. - /* #define updcrc(cp, crc) ( crctab[((crc >> 8) & 255)] ^ (crc << 8) ^ cp) */
  651. -#define updcrc(cp, crc) ( (crctab[((crc >> 8) & 0xFF) ^ cp] ^ (crc << 8)) & 0xFFFF)
  652. -
  653. -
  654. -/* crctab calculated by Mark G. Mendel, Network Systems Corporation */
  655. -static unsigned short crctab[256] = {
  656. -    0x0000,  0x1021,  0x2042,  0x3063,  0x4084,  0x50a5,  0x60c6,  0x70e7,
  657. -    0x8108,  0x9129,  0xa14a,  0xb16b,  0xc18c,  0xd1ad,  0xe1ce,  0xf1ef,
  658. -    0x1231,  0x0210,  0x3273,  0x2252,  0x52b5,  0x4294,  0x72f7,  0x62d6,
  659. -    0x9339,  0x8318,  0xb37b,  0xa35a,  0xd3bd,  0xc39c,  0xf3ff,  0xe3de,
  660. -    0x2462,  0x3443,  0x0420,  0x1401,  0x64e6,  0x74c7,  0x44a4,  0x5485,
  661. -    0xa56a,  0xb54b,  0x8528,  0x9509,  0xe5ee,  0xf5cf,  0xc5ac,  0xd58d,
  662. -    0x3653,  0x2672,  0x1611,  0x0630,  0x76d7,  0x66f6,  0x5695,  0x46b4,
  663. -    0xb75b,  0xa77a,  0x9719,  0x8738,  0xf7df,  0xe7fe,  0xd79d,  0xc7bc,
  664. -    0x48c4,  0x58e5,  0x6886,  0x78a7,  0x0840,  0x1861,  0x2802,  0x3823,
  665. -    0xc9cc,  0xd9ed,  0xe98e,  0xf9af,  0x8948,  0x9969,  0xa90a,  0xb92b,
  666. -    0x5af5,  0x4ad4,  0x7ab7,  0x6a96,  0x1a71,  0x0a50,  0x3a33,  0x2a12,
  667. -    0xdbfd,  0xcbdc,  0xfbbf,  0xeb9e,  0x9b79,  0x8b58,  0xbb3b,  0xab1a,
  668. -    0x6ca6,  0x7c87,  0x4ce4,  0x5cc5,  0x2c22,  0x3c03,  0x0c60,  0x1c41,
  669. -    0xedae,  0xfd8f,  0xcdec,  0xddcd,  0xad2a,  0xbd0b,  0x8d68,  0x9d49,
  670. -    0x7e97,  0x6eb6,  0x5ed5,  0x4ef4,  0x3e13,  0x2e32,  0x1e51,  0x0e70,
  671. -    0xff9f,  0xefbe,  0xdfdd,  0xcffc,  0xbf1b,  0xaf3a,  0x9f59,  0x8f78,
  672. -    0x9188,  0x81a9,  0xb1ca,  0xa1eb,  0xd10c,  0xc12d,  0xf14e,  0xe16f,
  673. -    0x1080,  0x00a1,  0x30c2,  0x20e3,  0x5004,  0x4025,  0x7046,  0x6067,
  674. -    0x83b9,  0x9398,  0xa3fb,  0xb3da,  0xc33d,  0xd31c,  0xe37f,  0xf35e,
  675. -    0x02b1,  0x1290,  0x22f3,  0x32d2,  0x4235,  0x5214,  0x6277,  0x7256,
  676. -    0xb5ea,  0xa5cb,  0x95a8,  0x8589,  0xf56e,  0xe54f,  0xd52c,  0xc50d,
  677. -    0x34e2,  0x24c3,  0x14a0,  0x0481,  0x7466,  0x6447,  0x5424,  0x4405,
  678. -    0xa7db,  0xb7fa,  0x8799,  0x97b8,  0xe75f,  0xf77e,  0xc71d,  0xd73c,
  679. -    0x26d3,  0x36f2,  0x0691,  0x16b0,  0x6657,  0x7676,  0x4615,  0x5634,
  680. -    0xd94c,  0xc96d,  0xf90e,  0xe92f,  0x99c8,  0x89e9,  0xb98a,  0xa9ab,
  681. -    0x5844,  0x4865,  0x7806,  0x6827,  0x18c0,  0x08e1,  0x3882,  0x28a3,
  682. -    0xcb7d,  0xdb5c,  0xeb3f,  0xfb1e,  0x8bf9,  0x9bd8,  0xabbb,  0xbb9a,
  683. -    0x4a75,  0x5a54,  0x6a37,  0x7a16,  0x0af1,  0x1ad0,  0x2ab3,  0x3a92,
  684. -    0xfd2e,  0xed0f,  0xdd6c,  0xcd4d,  0xbdaa,  0xad8b,  0x9de8,  0x8dc9,
  685. -    0x7c26,  0x6c07,  0x5c64,  0x4c45,  0x3ca2,  0x2c83,  0x1ce0,  0x0cc1,
  686. -    0xef1f,  0xff3e,  0xcf5d,  0xdf7c,  0xaf9b,  0xbfba,  0x8fd9,  0x9ff8,
  687. -    0x6e17,  0x7e36,  0x4e55,  0x5e74,  0x2e93,  0x3eb2,  0x0ed1,  0x1ef0
  688. -};
  689. -
  690. =pftypes.h
  691. -/*
  692. - * Apple II ProDOS file types as of September, 1990
  693. - *
  694. - * See "About Apple II File Type Notes" by Apple Developer Technical
  695. - * Support for more information.
  696. - * 
  697. - * This list is taken directly from the above named document, with the
  698. - * exception of the file types $B6 and $F9, for which the abbreviations
  699. - * "str" and "p16" are often found alongside the official abbreviations
  700. - * ("pif" and "os" respectively).
  701. - */
  702. -
  703. -struct ftypes {
  704. -        unsigned char code;
  705. -        char name[4];
  706. -} filetypes[] = {
  707. -        0x00, "unk", /* Unknown */
  708. -        0x01, "bad", /* Bad blocks */
  709. -        0x02, "pcd", /* Apple /// Pascal code */
  710. -        0x03, "ptx", /* Apple /// Pascal text */
  711. -        0x04, "txt", /* ASCII text */
  712. -        0x05, "pda", /* Apple /// Pascal data */
  713. -        0x06, "bin", /* Binary */
  714. -        0x07, "fnt", /* Apple /// Font */
  715. -        0x08, "fot", /* Apple II or /// Graphics */
  716. -        0x09, "ba3", /* Apple /// BASIC program */
  717. -        0x0A, "da3", /* Apple /// BASIC data */
  718. -        0x0B, "wpf", /* Apple /// Word Processor */
  719. -        0x0C, "sos", /* Apple /// SOS System */
  720. -        0x0F, "dir", /* Folder */
  721. -        0x10, "rpd", /* Apple /// RPS data */
  722. -        0x11, "rpi", /* Apple /// RPS index */
  723. -        0x12, "afd", /* Apple /// AppleFile discard */
  724. -        0x13, "afm", /* Apple /// AppleFile model */
  725. -        0x14, "afr", /* Apple /// AppleFile report format */
  726. -        0x15, "scl", /* Apple /// screen library */
  727. -        0x16, "pfs", /* PFS document */
  728. -        0x19, "adb", /* AppleWorks Data Base */
  729. -        0x1A, "awp", /* AppleWorks Word Processor */
  730. -        0x1B, "asp", /* AppleWorks Spreadsheet */
  731. -        0x20, "tdm", /* Desktop Manager document */
  732. -        0x2A, "8sc", /* Apple II Source Code */
  733. -        0x2B, "8ob", /* Apple II Object Code */
  734. -        0x2C, "8ic", /* Apple II Interpreted Code */
  735. -        0x2D, "8ld", /* Apple II Language Data */
  736. -        0x2E, "p8c", /* ProDOS 8 code module */
  737. -        0x42, "ftd", /* File Type Names */
  738. -        0x50, "gwp", /* Apple IIGS Word Processor */
  739. -        0x51, "gss", /* Apple IIGS Spreadsheet */
  740. -        0x52, "gdb", /* Apple IIGS Data Base */
  741. -        0x53, "drw", /* Drawing */
  742. -        0x54, "gdp", /* Desktop Publishing */
  743. -        0x55, "hmd", /* Hypermedia */
  744. -        0x56, "edu", /* Educational Data */
  745. -        0x57, "stn", /* Stationery */
  746. -        0x58, "hlp", /* Help File */
  747. -        0x59, "com", /* Communications File */
  748. -        0x5A, "cfg", /* Configuration file */
  749. -        0x5B, "anm", /* Animation file */
  750. -        0x5C, "mum", /* Multimedia document */
  751. -        0x5D, "ent", /* Game/Entertainment document */
  752. -        0x5E, "dvu", /* Development utility document */
  753. -        0x6B, "bio", /* PC Transporter BIOS */
  754. -        0x6D, "tdr", /* PC Transporter driver */
  755. -        0x6E, "pre", /* PC Transporter pre-boot */
  756. -        0x6F, "hdv", /* PC Transporter volume */
  757. -        0xA0, "wp",  /* WordPerfect document */
  758. -        0xAB, "gsb", /* Apple IIGS BASIC program */
  759. -        0xAC, "tdf", /* Apple IIGS BASIC TDF */
  760. -        0xAD, "bdf", /* Apple IIGS BASIC data */
  761. -        0xB0, "src", /* Apple IIGS  source code */
  762. -        0xB1, "obj", /* Apple IIGS object code */
  763. -        0xB2, "lib", /* Apple IIGS Library file */
  764. -        0xB3, "s16", /* GS/OS application */
  765. -        0xB4, "rtl", /* GS/OS Run-Time Library */
  766. -        0xB5, "exe", /* GS/OS Shell application */
  767. -        0xB6, "pif", /* Permanent initialization file */
  768. -        0xB6, "str", /* (alternate for PIF) */
  769. -        0xB7, "tif", /* Temporary initialization file */
  770. -        0xB8, "nda", /* New desk accessory */
  771. -        0xB9, "cda", /* Classic desk accessory */
  772. -        0xBA, "tol", /* Tool */
  773. -        0xBB, "dvr", /* Apple IIGS Device Driver File */
  774. -        0xBC, "ldf", /* Load file (generic) */
  775. -        0xBD, "fst", /* GS/OS File System Translator */
  776. -        0xBF, "doc", /* GS/OS document */
  777. -        0xC0, "pnt", /* Packed Super Hi-Res picture */
  778. -        0xC1, "pic", /* Super Hi-Res picture */
  779. -        0xC2, "ani", /* Paintworks animation */
  780. -        0xC3, "pal", /* Paintworks palette */
  781. -        0xC5, "oog", /* Object-oriented graphics */
  782. -        0xC6, "scr", /* Script */
  783. -        0xC7, "cdv", /* Control Panel document */
  784. -        0xC8, "fon", /* Font */
  785. -        0xC9, "fnd", /* Finder data */
  786. -        0xCA, "icn", /* Icons */
  787. -        0xD5, "mus", /* Music sequence */
  788. -        0xD6, "ins", /* Instrument */
  789. -        0xD7, "mdi", /* MIDI data */
  790. -        0xD8, "snd", /* Sampled sound */
  791. -        0xDB, "dbm", /* DB Master document */
  792. -        0xE0, "lbr", /* Archival library */
  793. -        0xE2, "atk", /* AppleTalk data */
  794. -        0xEE, "r16", /* EDASM 816 relocatable file */
  795. -        0xEF, "pas", /* Pascal area */
  796. -        0xF0, "cmd", /* BASIC command */
  797. -        0xF9, "os",  /* GS/OS System file */
  798. -        0xF9, "p16", /* (alternate for GS/OS System file) */
  799. -        0xFA, "int", /* Integer BASIC program */
  800. -        0xFB, "ivr", /* Integer BASIC variables */
  801. -        0xFC, "bas", /* AppleSoft BASIC program */
  802. -        0xFD, "var", /* AppleSoft BASIC variables */
  803. -        0xFE, "rel", /* Relocatable code */
  804. -        0xFF, "sys"  /* ProDOS 8 application */
  805. -};
  806. -
  807. -#define FTYPESIZE sizeof(filetypes)/sizeof(struct ftypes)
  808. + END OF ARCHIVE
  809.