home *** CD-ROM | disk | FTP | other *** search
/ Datatid 1999 #6 / Datatid_1999-06.iso / internet / Tango352Promo / P.SQL / PTKPKG.1 / BLOBHDR.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-01-31  |  8.3 KB  |  246 lines

  1. {*************************************************************************
  2. **
  3. **  Copyright 1982-1997 Pervasive Software Inc. All Rights Reserved
  4. **
  5. *************************************************************************}
  6. {***********************************************************************
  7.    BLOBHDR.PAS
  8.       This is the Pascal constants unit required for Btrieve chunk
  9.       operations for Btrieve 6.x.  This module is required when making
  10.       a 16-bit protected mode application, whether or not you use Blobs.
  11.  
  12. ************************************************************************}
  13. UNIT blobhdr;
  14.  
  15. INTERFACE
  16. CONST
  17. {*
  18. **
  19. ** Extractors are used for both Get and Put operations.  Every Get Extractor
  20. ** has a parallel Put Extractor; the only Put Extractor without a Get
  21. ** counterpart is Truncate.
  22. **
  23. ** There are two ways to classify all Extractors except Truncate:
  24. **
  25. **   1) Do they define chunks by Offset and Len, or do they instruct
  26. **      Btrieve to define chunks based on the notion of a rectangle?
  27. **
  28. **   2) Do they read/write user's data directly from/to the data buffer,
  29. **      or do they use pointers in the data buffer as source/destination?
  30. **
  31. *}
  32.  
  33.                                { "Actions" or opcodes for ProcessIndirect() }
  34. PREPROCESS_BLOBGET    = 0;
  35. PREPROCESS_BLOBPUT    = 1;
  36. POSTPROCESS_BLOBGET   = 2;
  37. INDIRECT_BIT          = $00000001;
  38. RECTANGLE_BIT         = $00000002;
  39. TRUNC_BIT             = $00000004;
  40.  
  41.  
  42. TYPE
  43.  
  44.    CHUNK_REC = RECORD
  45.       ChunkOffset: LONGINT;
  46.       ChunkLen:    LONGINT;
  47.       dataP:       PChar;           { When used w/ "direct" api, init to nil }
  48.    end;
  49.  
  50.    XTRACTR = RECORD
  51.       Signature:   LONGINT;
  52.       NumChunks:   LONGINT;
  53.       Chunk:       CHUNK_REC;
  54.    end;
  55.  
  56.    BRECTANGLE = RECORD
  57.       Signature:   LONGINT;
  58.       NumRows:     LONGINT;
  59.       Offset:      LONGINT;
  60.       BytesPerRow: LONGINT;
  61.       BtrDistanceBetweenRows: LONGINT;  { Btrieve's count of bytes between }
  62.                                         { beginning of two consecutive rows. }
  63.       dataP:       ^Char;
  64.       AppDistanceBetweenRows: LONGINT;      { App's count of bytes between }
  65.                                       { beginning of two consecutive rows.   }
  66.    end;
  67.  
  68. {============================================================================
  69.  
  70.                            Chunk PUT APIs:
  71.  
  72. ============================================================================}
  73.  
  74. {*
  75. **  1. Update a chunk at Offset, Len bytes.  New bytes are in data buffer,
  76. **     following the entire extractor.  Initialize the dummy Source ptr to
  77. **     NULL.
  78. *}
  79.  
  80.  
  81. {#define  XTRACTR_DIRECT_SIGN     0x80000000L}
  82.  
  83.  
  84.    PUT_XTRACTR = RECORD
  85.       Signature:        LONGINT;                    { XTRACTR_DIRECT_SIGN }
  86.       NumChunks:        LONGINT;
  87.       Chunk:            CHUNK_REC;
  88.    end;
  89.  
  90.  
  91. {
  92. **  2. Update a chunk at Offset, Len bytes.  Get new bytes by using a ptr(s)
  93. **     in the extractor.  Use PUT_XTRACTR, but initialize the Signature
  94. **     field to XTRACTR_INDIRECT_SIGN.  Initialize the Source ptr(s) to
  95. **     point to the chunks.
  96. }
  97.  
  98. { #define  XTRACTR_INDIRECT_SIGN     0x80000001L }
  99.  
  100. {
  101. **  3. Update a rectangle.  A series of NumRows chunks, beginning at Offset,
  102. **     bytesPerRow number of bytes per chunk.   Between rows (chunks),
  103. **     increment previous Offset by BtrDistanceBetweenRows to position
  104. **     into record for next chunk.  Data is sent in the data buffer.
  105. **     Initialize the dummy Destination ptr to NULL.  The
  106. **     AppDistanceBetweenRows field will be ignored.
  107. }
  108.  
  109. { #define  RECTANGLE_DIRECT_SIGN     0x80000002L }
  110.  
  111.    PUT_RECTANGLE = RECORD
  112.       Signature:        LONGINT;                   { RECTANGLE_DIRECT_SIGN }
  113.       NumRows:          LONGINT;
  114.       Offset:           LONGINT;
  115.       BytesPerRow:      LONGINT;
  116.       BtrDistanceBetweenRows: LONGINT;  { Btrieve's count of bytes between }
  117.                                         { beginning of two consecutive rows. }
  118.       dataP:            ^Char;
  119.       AppDistanceBetweenRows : LONGINT;     { App's count of bytes between }
  120.                                          { beginning of two consecutive rows.     }
  121.    end;
  122.  
  123.  
  124. {
  125. **  4. Update a rectangle - same as above except that the data is read from
  126. **     an address specified by the Source ptr in the incoming data buffer,
  127. **     following the rectangle definition.  Also, AppDistanceBetweenRows
  128. **     is specified as a value to use to increment the Destination ptr
  129. **     between rows (chunks).  Use the PUT_RECTANGLE struct, but init
  130. **     the Signature field to RECTANGLE_INDIRECT_SIGN.
  131. }
  132.  
  133.  
  134. { #define  RECTANGLE_INDIRECT_SIGN     0x80000003L }
  135.  
  136. {
  137. **  5. Truncate at Offset.
  138. }
  139.  
  140. {  #define TRUNC_SIGN 0x80000004L }
  141.  
  142.    PUT_TRUNC = RECORD
  143.       Signature:        LONGINT;        { TRUNC_SIGN }
  144.       ChunkOffset:      LONGINT;
  145.    end;
  146.  
  147.  
  148. {
  149. **  6. Put Next.  Combine with each option above, by biasing the signature
  150. **     with NEXT_IN_BLOB.  In each case, the Offset chunk is irrelevant,
  151. **     because it is computed by Btrieve, based on current position in
  152. **     record.  For the first two put options, if more than one chunk is
  153. **     used, each chunk's offset is computed by Btrieve.  For the "put a
  154. **     rectangle" options, the first Offset is computed from the current
  155. **     position in the record; computation of subsequent "row's"
  156. **     offsets is based on BtrDistanceBetweenRows.
  157. }
  158.  
  159. {   #define NEXT_IN_BLOB 0x40000000L }
  160.  
  161. {
  162. **  7. Append.  Combine with the first four options above, by biasing the
  163. **     signature with APPEND_TO_BLOB.  Behaves like Put Next in that Btrieve
  164. **     computes the same offset chunks as are computed with Put Next.  The
  165. **     difference is that value used for the offset is one byte beyond the end
  166. **     of record.  May not be used with the Put Next bias.
  167. }
  168.  
  169. {   #define APPEND_TO_BLOB 0x20000000L  }
  170.  
  171.  
  172. {============================================================================
  173.  
  174.                            Chunk Get APIs:
  175.  
  176. ============================================================================}
  177.  
  178. {
  179. **
  180. ** 1. Get a chunk(s) at Offset, Len bytes.  Data returned is placed into the
  181. **    data buffer.  Remember to initialize Chunk[x].dataP to NULL
  182. **    and set the Signature field to XTRACTR_DIRECT_SIGN.
  183. }
  184.  
  185.  
  186.    GET_XTRACTR = RECORD
  187.       RecordAddress:    LONGINT;
  188.       Signature:        LONGINT;
  189.       NumChunks:        LONGINT;
  190.       Chunk:            CHUNK_REC;
  191.    end;
  192.  
  193. {
  194. **
  195. ** 2. Get a chunk(s) at Offset, Len bytes.  Data returned is placed into a
  196. **    buffer whose address is given by a pointer sent by the application.
  197. **    Use the GET_XTRACTR.  Set the Signature field to XTRACTR_INDIRECT_SIGN.
  198. }
  199.  
  200.  
  201. {
  202. ** 3. Get a rectangle.  A series of NumRows chunks, beginning at Offset,
  203. **    bytesPerRow number of bytes per chunk.   Between rows (chunks),
  204. **    increment previous Offset by BtrDistanceBetweenRows to position
  205. **    into record for next chunk.  Data is returned in the data buffer.
  206. **    Initialize the dummy Destination ptr to NULL.  The
  207. **    AppDistanceBetweenRows field will be ignored.  Set the Signature
  208. **    field to RECTANGLE_DIRECT_SIGN.
  209. }
  210.  
  211.    GET_RECTANGLE = RECORD
  212.       RecordAddress:    LONGINT;
  213.       Signature:        LONGINT;
  214.       NumRows:          LONGINT;
  215.       Offset:           LONGINT;
  216.       BytesPerRow:      LONGINT;
  217.       BtrDistanceBetweenRows:   LONGINT; { Btrieve's count of bytes between }
  218.                                       { beginning of two consecutive rows. }
  219.       dataP:            ^Char;
  220.       AppDistanceBetweenRows: LONGINT;     { App's count of bytes between }
  221.                                        { beginning of two consecutive rows. }
  222.   end;
  223.  
  224. {
  225. **
  226. ** 4. Get a rectangle - same as above except that the data is returned to an
  227. **        address specified by the Destination pointer in the incoming data
  228. **        buffer, following the rectangle definition.  Also,
  229. **        AppDistanceBetweenRows is specified as a value to use to increment
  230. **        the Destination pointer between rows.  Set the Signature field to
  231. **        RECTANGLE_INDIRECT_SIGN.
  232. }
  233.  
  234. {
  235. **
  236. ** 5. Get Next Chunk.  Combine with each option above, by biasing the
  237. **    signature with NEXT_IN_BLOB.  In each case, the Offset chunk is
  238. **    irrelevant.  See details under Put Next Chunk, above.
  239. **
  240. }
  241.  
  242.  
  243. IMPLEMENTATION
  244. END.
  245.  
  246.