home *** CD-ROM | disk | FTP | other *** search
/ Datatid 1999 #6 / Datatid_1999-06.iso / internet / Tango352Promo / P.SQL / PTKPKG.1 / BLOBHDR.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-17  |  8.5 KB  |  259 lines

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