home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume8 / ansitape / part02 / ansitape.h < prev    next >
Encoding:
C/C++ Source or Header  |  1987-03-02  |  5.4 KB  |  150 lines

  1.  
  2. /*
  3.  * This file contains the definitions of the tape control records. This
  4.  * is to be used when developing a program to work with ANSI standard
  5.  * labelled tapes. 
  6.  */
  7.  
  8. /*
  9.  * Actually, these should be upper case.  The ansitape program doesn't
  10.  * convert things to upper case until the headers are made -- the tape
  11.  * control block has everything in lower case.  For the sake of easy
  12.  * comparisons, we define them here as lower case. 
  13.  */
  14.  
  15. #define NOPROTECT ' '        /* space if no protection */
  16. #define REC_FIXED 'f'        /* Records are all fixed length */
  17. #define REC_VARIABLE 'd'    /* Records are preceeded by a 4-digit
  18.                  * zero-filled count of their length,
  19.                  * including the 4 digits themselves */
  20. #define IBM_VARIABLE 'v'    /* IBM's version of ANSI D format */
  21. #define CC_FORTRAN 'a'        /* First char of rec is f-77 carriage
  22.                  * control */
  23. #define CC_EMBEDDED 'm'        /* Carriage control is part of the data
  24.                  * contained in each record */
  25. #define CC_IMPLIED ' '        /* Each record goes on a separate line
  26.                  * when printed */
  27.  
  28. /*
  29.  * VOLUME 1 Describes the owner of and access to the volume. 
  30.  */
  31.  
  32. struct ansi_vol1 {
  33.     char            header[4];    /* VOL1 */
  34.     char            label[6];    /* volume name, A-Z0-9 */
  35.     char            access;    /* access code */
  36.     char            __ignored1[20];    /* reserved, space fill */
  37.     char            __ignored2[6];    /* reserved, space fill */
  38.     char            owner[14];    /* user name */
  39.     char            __ignored3[28];    /* reserved, space fill */
  40.     char            ansi_level;    /* ansi standard level, always 3 */
  41. };
  42.  
  43. /*
  44.  * VOLUME 2 optional, ignored by this software. 
  45.  */
  46.  
  47. /*
  48.  * HEADER 1 Begins basic description of a tape file. 
  49.  */
  50.  
  51. struct ansi_hdr1 {
  52.     char            header[4];    /* HDR1 */
  53.     char            name[17];    /* rightmost 17 characters of filename */
  54.     char            fileset[6];    /* should be same as volume id of 1st
  55.                  * tape */
  56.     char            volume_num[4];    /* number of volume in set */
  57.     char            file_num[4];/* number of file on tape */
  58.     char            gen[4];    /* generation number */
  59.     char            genver[2];    /* generation version number */
  60.     char            created[6];    /* date of creation, "bYYDDD" */
  61.     char            expires[6];    /* expiration date "bYYDDD" */
  62.     char            access;    /* protection, space = unprotected */
  63.     char            blockcount[6];    /* zero in header */
  64.     char            tapesys[13];/* name of software creating tape */
  65.     char            __ignored[7];    /* reserved, space fill */
  66. };
  67.  
  68. /*
  69.  * HEADER 2 Record format, record size, block size. 
  70.  */
  71.  
  72. struct ansi_hdr2 {
  73.     char            header[4];    /* HDR2 */
  74.     char            recfmt;    /* record format */
  75.     char            blocklen[5];/* file tape block length */
  76.     char            reclen[5];    /* file logical record length */
  77.     char            density;    /* density/recording mode. Should be 2
  78.                  * for 800 bpi, 3 for 1600 bpi. */
  79.     char            vol_switch;    /* 0, or 1 if this file was continued */
  80.     char            job[17];    /* job name (8), /, job step (8) of
  81.                  * creator */
  82.     char            recording[2];    /* parity/conversion, space
  83.                      * fill */
  84.     char            carriage_control;
  85.     char            alignment;    /* reserved, space fill */
  86.     char            blocked_records;    /* 'B' if records are blocked */
  87.     char            __ignored2[11];
  88.     char            block_offset[2];    /* ingore 1st n char of each
  89.                      * block */
  90.     char            __ignored3[28];
  91. };
  92.  
  93. /*
  94.  * HEADER 3 This contains a bunch of rms-dependent data.  We will
  95.  * ignore it for now, and hope that it doesnt screw up VMS too badly. 
  96.  */
  97.  
  98. struct ansi_hdr3 {
  99.     char            header[4];    /* HDR3 */
  100.     char            os_reserved[76];    /* reserved to OS, space fill */
  101. };
  102.  
  103. /*
  104.  * HEADER 4 This is the rest of the filename if its longer than 17
  105.  * characters.  We should have no trouble fitting UNIX filenames into
  106.  * this. 
  107.  */
  108.  
  109. struct ansi_hdr4 {
  110.     char            header[4];    /* HDR4 */
  111.     char            name2[63];    /* leftmost char, if name is more than
  112.                  * 17 characters long. */
  113.     char            unknown[2];    /* fill with 00 */
  114.     char            __ignored[11];
  115. };
  116.  
  117.  
  118. /*
  119.  * FORMAT NOTES 
  120.  *
  121.  * 1.  The tape always starts with a VOL1 record.  Other volume records
  122.  * are optional.  We ignore them, and do not generate them on output. 
  123.  *
  124.  * 2.  Each file starts with a set of HDRn records.  The headers are
  125.  * followed by a tape mark. 
  126.  *
  127.  * 3.  The data is written to the tape in fixed-length blocks.  Valid ANSI
  128.  * block lengths are 18 to 2048 bytes, although VMS will support longer
  129.  * blocks. The block does not have to be full.  If the block is not
  130.  * completely filled, the remainder of the block is padded with
  131.  * circumflex (^) characters.  The file is followed by a tape mark. 
  132.  *
  133.  * 4.  Trailing records are written.  Either EOF or EOV records may be
  134.  * used. The record formats are the same as the HDR records, expect: 
  135.  *
  136.  * a. the "HDR" is replaced by "EOF" or "EOV". 
  137.  *
  138.  * b. the blockcount field in EOF1/EOV1 contains the actual number of
  139.  * physical tape blocks written in the preceding file section.  In the
  140.  * HDR1 record, the blockcount is 000000. 
  141.  *
  142.  * 5.  A tape file may extend across a volume boundary.  If it does, EOV
  143.  * labels are used, indicating that another tape must be read.  If the
  144.  * file ends here, an EOF label is used. 
  145.  *
  146.  * 6.  After the EOF records, a tape mark is written.  This separates the
  147.  * trailers from the headers for the next file.  At the end of the
  148.  * tape, two tape marks are written. 
  149.  */
  150.