home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / clarion / brokcode.zip / READHD2.EXE / lha / FILE2.DOC next >
Text File  |  1988-08-01  |  7KB  |  199 lines

  1.  
  2.     COPYRIGHT 1988 CLARION SOFTWARE CORP. ALL RIGHTS RESERVED.
  3.  
  4. #define FILESG2 0x3343        /*  file signature            */
  5. #define MEMOSG2 0x334D        /*  file signature            */
  6. #define FLDNMSIZ 16        /*  max size of a field name        */
  7. #define PRESIZ 3        /*  max size field name prefix        */
  8. #define MAXFLDS 256        /*  max number of fields per record    */
  9. #define DEFEXT ".DAT"        /*  default file extension for sfiles    */
  10. #define KEYEXT ".K00"        /*  default file extension for indices    */
  11. #define IDXEXT ".I00"        /*  default file extension for indices    */
  12. #define TMPEXT ".T00"        /*  default file extension for temps    */
  13. #define MEMEXT ".MEM"        /*  default file extension for temps    */
  14. #define MEMTMP ".M00"        /*  default file extension for temps    */
  15. #define LOGEXT ".LOG"        /*  default file extension for logout    */
  16. #define BUFMAX 20        /*  maximum number of requested buffers */
  17. #define NODESIZE 512        /*  size of nodes in key files        */
  18. #define MEMOSIZE 256        /*  size of memo text block        */
  19. #define MAXKEYSIZ 245        /*  maximum length of key        */
  20. #define MAXKEYS 255        /*  maximum number of keys        */
  21. #define MAXPICLEN 256        /*  maximum length of picture        */
  22. #define DTODEF 0xFFFF        /*  default dto is -1            */
  23.  
  24. /*                 record status types            */
  25.  
  26. #define NEWREC    0x01
  27. #define OLDREC    0x02
  28. #define RVISED    0x04
  29. #define BACKED    0x08
  30. #define DELTED    0x10
  31. #define EMPTY    0x20
  32. #define RDLOCK    0x40
  33. #define WTLOCK    0x80
  34.  
  35. /*            sf file status defines for sfatr              */
  36.  
  37. #define FILLOCK 0x01       /*         file is locked              */
  38. #define FILOWN    0x02       /*         file is owned              */
  39. #define FILCRYP 0x04       /*         records are encrypted          */
  40. #define FILMEMO 0x08       /*         memo file exists              */
  41. #define FILCOMP 0x10       /*         file is compressed              */
  42. #define FILRCLM 0x20       /*         reclaim deleted records          */
  43. #define FILREAD 0x40       /*         file is read only              */
  44. #define FILCRET 0x80       /*         file may be created          */
  45.  
  46. /*              field types                      */
  47.  
  48. #define FLNG 0x01    /*   LONG - long       */
  49. #define FREL 0x02    /*   REAL - double     */
  50. #define FSTR 0x03    /*   STRING - char[]   */
  51. #define FPIC 0x04    /*   PICTURE - char[]  */
  52. #define FBYT 0x05    /*   BYTE - char       */
  53. #define FSHT 0x06    /*   SHORT - int       */
  54. #define FGRP 0x07    /*   GROUP           */
  55. #define FDEC 0x08    /*   DECIMAL           */
  56.  
  57. /************************************************************************/
  58.  
  59. /******************* ON DISK STRUCTURES NEEDED BY EXEC ******************/
  60.  
  61. /************************************************************************/
  62.  
  63. /*                   data file header                */
  64.  
  65. typedef struct {
  66.     unsigned filesig;        /*    signature              */
  67.     unsigned sfatr;        /*    file attributes              */
  68.     unsigned char numbkeys;    /*    number of keys in this file      */
  69.     unsigned long numrecs;    /*    number of records in file      */
  70.     unsigned long numdels;    /*    number of deleted records      */
  71.     unsigned numflds;        /*    number of fields          */
  72.     unsigned numpics;        /*    number of pictures          */
  73.     unsigned numarrs;        /*    number of arrays          */
  74.     unsigned reclen;        /*    record length              */
  75.     unsigned long offset;    /*    start of data area          */
  76.     unsigned long logeof;    /*    logical end of file          */
  77.     unsigned long logbof;    /*    logical beginning of file      */
  78.     unsigned long freerec;    /*    first usable deleted record      */
  79.     unsigned char recnam[FLDNMSIZ-4];    /* record name without pre      */
  80.     unsigned char memnam[FLDNMSIZ-4];    /* memo name without pre      */
  81.     unsigned char filpre[PRESIZ];    /* file name prefix          */
  82.     unsigned char recpre[PRESIZ];    /* record name prefix          */
  83.     unsigned      memolen;    /*    size of memo              */
  84.     unsigned      memowid;    /*    column length of memo          */
  85.     unsigned long lockcnt;    /*    file locked counter          */
  86.     unsigned long chgtime;    /*    time of last change          */
  87.     unsigned long chgdate;    /*    date of last change          */
  88.     unsigned      chcksum;    /*    checksum used for encrypt      */
  89. } FILEHEAD;
  90.  
  91. typedef struct {
  92.     unsigned char fldtype;    /*    type of field              */
  93.     char fldname[FLDNMSIZ];    /*    name of field              */
  94.     unsigned foffset;        /*    offset into record          */
  95.     unsigned length;        /*    length of field              */
  96.     unsigned char   decsig;    /*    significance for decimals      */
  97.     unsigned char   decdec;    /*    number of decimal places      */
  98.     unsigned arrnum;        /*    array number              */
  99.     unsigned picnum;        /*    picture number              */
  100. } FLDDESC;
  101.  
  102. typedef struct {
  103.     unsigned char numcomps;    /*    number of components for key      */
  104.     char keynams[FLDNMSIZ];    /*    name of this key          */
  105.     unsigned char comptyp;    /*    type of composite          */
  106.     unsigned char complen;    /*    length of composite          */
  107. } KEYSECT;
  108.  
  109. typedef struct {
  110.     unsigned char fldtype;    /*    field type              */
  111.     unsigned fldnum;        /*    field number              */
  112.     unsigned elmoff;        /*    record offset of this element      */
  113.     unsigned char elmlen;    /*    length of element          */
  114. } KEYPART;
  115.  
  116. typedef struct {
  117.     unsigned piclen;
  118.     char     picstr[MAXPICLEN];
  119. } PICDESC;
  120.  
  121. typedef struct {
  122.     unsigned maxdim;
  123.     unsigned lendim;
  124. } ARRPART;
  125.  
  126. typedef struct {
  127.     unsigned numdim;
  128.     unsigned totdim;
  129.     unsigned elmsiz;
  130.     ARRPART  arrprt[(sizeof(ARRPART)*MAXTOTDIM)];
  131. } ARRDESC;
  132.  
  133. /*                 record header                */
  134.  
  135. typedef struct {
  136.     unsigned char rhd;
  137.     unsigned long rptr;
  138. } RECHEAD;
  139.  
  140.  
  141.     Graphical repesentation of header
  142.  
  143.     ┌─
  144.     │
  145.     │ FILEHEAD
  146.     │
  147.     └─
  148.     ┌─ should be FILEHEAD.numflds of these
  149.     │ Field 1 FLDDSC
  150.     ├─
  151.     │ Field 2 FLDDSC
  152.     :
  153.     :    etc.
  154.     └─
  155.      Key definitions FILEHEAD.numbkeys of these
  156.     ┌─ ┌─
  157.     │  │ Key 1 KEYSECT
  158.     │  └─
  159.     │     ┌─   Key components KEYSECT.numcomps of these
  160.     │     │  Key 1 Part 1 KEYPART
  161.     │     ├─
  162.     │     :
  163.     │     └─
  164.     ├─
  165.     :
  166.     :
  167.     └─
  168.        PICDESC are variable length. Read the length first to get the number
  169.                     of additional bytes to read.
  170.     ┌─ FILEHEAD.numpics of these
  171.     │  PICDESC 1
  172.     :     etc.
  173.     └─
  174.      Array definitions FILEHEAD.numarrs of these
  175.     ┌─ ┌─
  176.     │  │ Array 1 ARRDESC
  177.     │  └─
  178.     │     ┌─   Array parts ARRDESC.totdims of these
  179.     │     │  Array 1 Part 1 ARRPART
  180.     │     ├─
  181.     │     :
  182.     │     └─
  183.     ├─
  184.     :
  185.     :
  186.     └─
  187.     Start  of data records    use FILEHEAD.offset to get relative position
  188.                 within the file to get to here.
  189.     ┌─
  190.     │    RECHEAD
  191.     └─
  192.     ┌─    Data record get length from FILEHEAD.reclen
  193.     │
  194.     │
  195.     :
  196.     :
  197.     └─
  198.  
  199.