home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / wkermit.zip / cdisk.h < prev    next >
C/C++ Source or Header  |  1985-11-11  |  4KB  |  124 lines

  1. /*  disk.h
  2.  *
  3.  *  Disk System and Diskette Primitive Access Header
  4.  *
  5.  *  The Greenleaf Functions - Copyright (C) 1983 Greenleaf Software
  6.  */
  7.  
  8. typedef long dword;
  9. #define dosint 0x21        /* DOS function interrupt        */
  10.  
  11. /*  Disk File Attribute bits are in the following structure        */
  12.  
  13. struct DISKATTR {
  14.     word rdo : 1;        /* bit 0 - Read Only attribute        */
  15.     word hid : 1;        /* bit 1 - Hidden attribute        */
  16.     word sys : 1;        /* bit 2 - System attribute        */
  17.     word vll : 1;        /* bit 3 - Volume Label    in 1st 11 bytes    */
  18.     word sbd : 1;        /* bit 4 - Sub Directory bit        */
  19.     word arc : 1;        /* bit 5 is archive bit            */
  20.     word _spares  :10;    /* bits 6,7, and  first byte . unused    */
  21.     };
  22.  
  23. /*  this union allows ease of access to the attribute as a word        */
  24.  
  25. union FILEATTR  {
  26.     word fattr;
  27.     struct DISKATTR dattr;
  28.     };
  29.  
  30. struct EXTFCB {
  31.     byte  extflag;        /* extension flag: 0FF=extd fcb        */
  32.     byte  sysreserve[4];    /* reserved DOS 2.0 - don't use        */
  33.     union FILEATTR dskattr;    /* Attribute in second byte, 1st unused */
  34.     byte  fdrive;        /* drive code: 0=default 1=A 2=B..    */
  35.     byte  fname[8];        /* filename UC left justify blank fill    */
  36.     byte  fext[3];        /* filename extension            */
  37.     word  blocknum;        /* current block number, first = 0    */
  38.     word  lrs;        /* logical record size (bytes): 80h opn    */
  39.     dword lfs;        /* logical file size bytes: wd 1 = lo    */
  40.  
  41.                 /* Create or Last Update Date       */
  42.     word   fcbyear : 7;    /* year  0..119    (1980..2099)        */
  43.     word   fcbmonth: 4;    /* month 1..12                */
  44.     word   fcbday  : 5;    /* day   1..31                */
  45.  
  46.     byte   fcbsys[10];    /*  reserved for DOS use        */
  47.     byte   fcbcr;        /* current record number (seq i/o)    */
  48.     dword  fcbrec;        /* random record number  (rand i/o)    */
  49.     };
  50.  
  51. /*  Structure for FATINFO part of DISKTABLE
  52.  */
  53. struct FATINFO {
  54.     word      fatid;        /* see function 1B            */
  55.     word     allocunits;    /* allocation units            */
  56.     word      sectsalloc;    /* sectors per allocation unit        */
  57.     word      sectsize;    /* sector size                */
  58.     };
  59.  
  60. /*  Structure for LOLEV part of DISKTABLE
  61.  */
  62. struct LOLEV {
  63.     int    head;        /* head 0..1 (0..7 for hard disk)    */
  64.     int    cylinder;    /* 0..39     (0..1023  hard disk)    */
  65.     int    track;        /* 0..39 ..synonym for cylinder        */
  66.     int    fsector;    /* first sector - 1..9 (1..17 hard dsk)    */
  67.     int    nsectors;    /* no. sectors  - 1..8 (1..128 harddsk) */
  68.     int    sectsdone;    /* sectors actually done (return value) */
  69.     };
  70.  
  71.  
  72.  
  73. /*  structure for lots of DOS disk access functions including members
  74.  *  to handle DOS 2.0 and 1.x functions.  Note that an Extended FCB is
  75.  *  an integral part of this structure.
  76.  *
  77.  *  The "lolev" structure part of this is used only for DOS interrupts
  78.  *  24h and 25h and for ALL "BIOS" or "LOLEV" disk functions "diskxxxx".
  79.  *
  80.  *  The "fatinfo" structure part is used only for "dosfatinfo".
  81.  */
  82. struct DISKTABLE {
  83.     char     *string;    /* drive:path\filename.ext        */
  84.     word     handle;    /* File Handle                */
  85.     int      drive;        /* drive code: 0=A, etc.        */
  86.  
  87.     byte     *bufoffset;    /* pointer to disk buffer (offset)    */
  88.     word      bufseg;    /* segment address of disk buffer    */
  89.                 /*  code as 0 to use current DS        */
  90.  
  91.     word     access;    /* file access method 1..6        */
  92.     word     mode;        /* mode ASCII or BINARY            */
  93.  
  94.     struct EXTFCB dskfcb;    /* FCB is used for some functions    */
  95.  
  96.     int     rbytes;    /* number of bytes to be read/written    */
  97.     int     abytes;    /* ..bytes actually read/written    */
  98.  
  99.     struct LOLEV lolev;    /* use for all "diskxxxx" functions only*/
  100.  
  101.     word     status;    /* status return from all functions    */
  102.     char     *save;        /* output string, as in fn 47h        */
  103.     word     dosver;    /* DOS version as read by functions    */
  104.     };
  105.  
  106. /*  structure to use when renaming a file
  107.  */
  108.  
  109. struct RENFILE {
  110.     byte drvcode;        /* drive                */
  111.     byte oldname[8];    /* DS:DX + 1..8 old filename        */
  112.     byte oldext[3];        /*       + 9..B old extension        */
  113.     byte dontuse[5];    /*       + C..10 .. do not use        */
  114.     byte newname[8];    /*       +11..18 .. new filename     */
  115.     byte newext[3];        /*     +19..1B .. new extension    */
  116.     byte padddd[8];        /* pad out to regular FCB size        */
  117.     };
  118.  
  119. struct FHANDLE {
  120.     unsigned xfhandle;
  121.     char     xfname[13];    /* filename, ext             */
  122.     };
  123.  
  124.