home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / blt2rx_o.zip / bullet2.inf (.txt) < prev    next >
OS/2 Help File  |  1996-10-15  |  273KB  |  11,249 lines

  1.  
  2. ΓòÉΓòÉΓòÉ 1. Copyright ΓòÉΓòÉΓòÉ
  3.  
  4. 15-Oct-1996 
  5.  
  6.           BULLET is Copyright 1992-96, and is owned by the author, Cornel Huth, 
  7.           and is protected by United States copyright laws and international 
  8.           treaty provisions.  License restrictions apply. 
  9.  
  10.  
  11. ΓòÉΓòÉΓòÉ 2. License Agreement ΓòÉΓòÉΓòÉ
  12.  
  13. Before using this software, BULLET you must agree to the following: 
  14.  
  15.    1. A BULLET license grants you the right to use the BULLET library code on a 
  16.       royalty-free basis according to the terms of this License Agreement. 
  17.  
  18.    2. You are not permitted to operate more than one copy of this software 
  19.       package at one time per license.  For example, if you have ten 
  20.       programmers that have access to the BULLET package at the same time, you 
  21.       are required to have ten BULLET licenses. 
  22.  
  23.    3. There is no restriction on the number of users you may support, and no 
  24.       restriction on the number of different end-user programs you may 
  25.       distribute that use BULLET.  You may allow any number of simultaneous 
  26.       users to use your end-user program. 
  27.  
  28.    4. The dynamic link library, BULLET2.DLL, may be distributed with your 
  29.       end-user program.  No other BULLET product may be distributed without 
  30.       permission (for example, you may not distribute Bullet's import library, 
  31.       BULLET2I.LIB). 
  32.  
  33.    5. You are not permitted to distribute non-executable code containing BULLET 
  34.       code.  This means that may not redistribute BULLET with your program if 
  35.       your program can be used by other programmers to develop executable code. 
  36.       BULLET must be part of an end-user product only.  This means that you 
  37.       cannot provide an overlay or other such external code containing BULLET 
  38.       code if that code is to be used as a programming library for other 
  39.       programmers, from which the other programmers can create programs.  If 
  40.       you require distributing a non-end-user package containing BULLET, you 
  41.       must obtain written permission from the author.  This limitation pertains 
  42.       to the distribution of BULLET library code.  You may, however, develop 
  43.       and distribute your programmer package (ie non-end-user) as you wish, but 
  44.       you may not distribute BULLET library code with that package without 
  45.       written permission.  For example, you may develop class libraries that 
  46.       use the BULLET library code, and distribute those tools that you have 
  47.       written, but you may not include BULLET library code, or BULLET 
  48.       activation methods, in that package.  The programmer using your package 
  49.       would need a BULLET license to make use of your package. 
  50.  
  51.    6. The static link library, BULLET2.LIB, may not be distributed except in 
  52.       executable form as a component in your executable program (EXE). 
  53.       BULLET2.LIB may not be placed into a DLL.  BULLET2.LIB, if part of your 
  54.       license/Option, may only be linked directly to your end-user program. 
  55.       BULLET2.LIB is available with Option C licenses only. 
  56.  
  57.    7. Shareware use is limited to 28 days, and for the sole purpose of 
  58.       evaluating the software.  The BULLET library code may not be distributed 
  59.       in any form without a registered BULLET license.  A BULLET license is 
  60.       obtained only with purchase of a BULLET package, purchased from an 
  61.       authorized BULLET distributor. 
  62.  
  63.    8. A BULLET license is specific to the option level purchased.  License 
  64.       holders with a lower Option may not use any higher level Option code. 
  65.       For example, if you find another product using the Option C DLL, and you 
  66.       have an Option A license, you are not permitted to use the Option C DLL 
  67.       in your development, nor may you distribute any code that is not part of 
  68.       your Option level. 
  69.  
  70.    9. Your end-user program using the BULLET DLL is required to be a 
  71.       copyrighted work, and must contain a valid copyright notice in the form, 
  72.       'Program-name Copyright (C)Year Your-Name', or similar.  No notice of 
  73.       BULLET's copyright need be further specified in your program (in other 
  74.       words, you don't need to mention BULLET, but you may if you wish).  This 
  75.       applies only if you distribute the BULLET DLL with your product. 
  76.       Programs that are linked using the BULLET2.LIB static link library need 
  77.       not display a copyright notice.  In other words, if you must distribute 
  78.       to the Public Domain, where no copyright is desired for your program, you 
  79.       must link using the static link library, and not the DLL. 
  80.  
  81.   10. BULLET is owned by the author, Cornel Huth, and is protected by United 
  82.       States copyright laws and international treaty provisions.  You are not 
  83.       permitted to make copies of this software except for archival purposes. 
  84.  
  85.   11. You may not rent or lease BULLET. You may not transfer this license 
  86.       without the written permission of the author.  If this software is an 
  87.       update or upgrade, you may not sell or give away previous versions. 
  88.  
  89.   12. You may not reverse engineer, decompile, or disassemble this software if 
  90.       the intent or result is to alter the software. 
  91.  
  92.   13. You may not reproduce the printed manual. 
  93.  
  94.   14. There are no expressed or implied warranties with this software. 
  95.  
  96.   15. All liabilities in the use of this software rest with the user. 
  97.  
  98.   16. U.S. Government Restricted Rights.  This software is provided with 
  99.       restricted rights.  Use, duplication, or disclosure by the Government is 
  100.       subject to restrictions as set forth in subparagraph (c)(1)(ii) of the 
  101.       Rights in Technical Data and Computer Software clause at 52.227-7013. The 
  102.       software is owned by Cornel Huth/6402 Ingram Rd/San Antonio Texas 
  103.       78238/USA.  This agreement is governed by the laws of the Great State of 
  104.       Texas, the United States of America, and all other countries of Earth. 
  105.  
  106.  Any questions concerning this License Agreement should be directed to Product 
  107.  Support. 
  108.  
  109.  Failure to comply with any part of this License Agreement may result in 
  110.  license revocation. 
  111.  
  112.  
  113. ΓòÉΓòÉΓòÉ 3. Installation ΓòÉΓòÉΓòÉ
  114.  
  115. Installation instructions are located in the README text file included with 
  116. your package. 
  117.  
  118.  
  119. ΓòÉΓòÉΓòÉ 4. Product Support ΓòÉΓòÉΓòÉ
  120.  
  121. Technical support in the use of Bullet is available for licensed users at the 
  122. 40th Floor BBS or by way of the Internet. 
  123.  
  124. 40th Floor BBS: +1(210)684-8065  N-8-1 
  125.  
  126. Internet e-mail: support@40th.com 
  127.       www: http://www.40th.com 
  128.  
  129. The latest in-version (2.x) release of BULLET/2 is available for download from 
  130. the BBS by registered users, or $5 by postal mail.  Re-createable bugs are 
  131. fixed immediately.  Report a program bug and get the fix shipped free.  Past 
  132. bugs are listed at the BBS and the web site.  Contact support if you have any 
  133. questions or requests. 
  134.  
  135. For general information send e-mail to: 
  136.  
  137.       info@40th.com 
  138.  
  139.  
  140. ΓòÉΓòÉΓòÉ 4.1. Bug Report Form ΓòÉΓòÉΓòÉ
  141.  
  142. When requesting support for possible bug(s) use the following as a guideline: 
  143.  
  144.    1. Include a complete problem description. 
  145.    2. Include sample source of the problem, if necessary (small is best). 
  146.    3. Include necessary data files, include files, etc. 
  147.    4. Include step-by-step procedure to follow in order to recreate the 
  148.       problem. 
  149.  
  150.  Once done, send it to support by way of the BBS, e-mail, or postal mail to 
  151.  addresses listed in Product Support. 
  152.  
  153.  
  154. ΓòÉΓòÉΓòÉ 5. Ordering Information ΓòÉΓòÉΓòÉ
  155.  
  156. To order Bullet by check, bank check, money-order, or cash, use form 
  157. !ORDER.FRM.  For credit card order, use form !ORDER.CC. 
  158.  
  159. Payment Options 
  160.  
  161. Γûá Check, money-order, cash 
  162.  
  163. Your funds have to be in US Dollars and, if by check, have to be drawn on or 
  164. payable through a US bank.  If sending currency, use Registered AirMail. 
  165. Personal checks may require 10 working days to clear.  Most major non-American 
  166. banks have branch banks in the US.  Contact your bank for details.  Direct 
  167. wire-transfer is available: enquire to sales@40th.com. 
  168.  
  169. To order, send payment and the order form !ORDER.FRM to: 
  170.  
  171.    Cornel Huth
  172.    6402 Ingram Rd
  173.    San Antonio, Texas 78238-3915
  174.    USA
  175.  
  176. Γûá Credit card 
  177.  
  178. For credit card orders (Visa, MC, Amex, Discover), call (800)242-4775 (outside 
  179. US, call 1(713)524-6394), or fax to 1(713)524-6398, or via CompuServe e-mail to 
  180. 71355,470 (or internet e-mail to 71355.470@compuserve.com), requesting 'Bullet 
  181. for OS/2' (item# 11185). Include the completed credit card order form when 
  182. using e-mail or fax. 
  183.  
  184. Phone orders are taken during business hours, which for PsL is weekdays from 
  185. 7AM to 6PM, USA Central Time (7AM to 12:30PM on Friday).  Fax or CompuServe 
  186. orders are accepted at any time. 
  187.  
  188. Credit card ordering can be done through the mail by writing to: 
  189.  
  190.    PsL 
  191.    PO Box 35705 
  192.    Houston, Texas 77235-5705 
  193.    USA. 
  194.  
  195. Note:  This is for Bullet orders.  Please do not use these numbers for any 
  196. other purpose, such as contacting Bullet support, except as a last resort.  PsL 
  197. only handles your initial order.  For order status, contact support@40th.com or 
  198. call the BBS.  There is no delay in Bullet order processing; your order is 
  199. processed as quickly as possible. 
  200.  
  201. When ordering without an order form, specify 'Bullet for OS/2' and your license 
  202. option, as shown in the schedule below.  Your shipping address should be the 
  203. same as your billing address for fastest processing.  Fax or postal orders 
  204. should use order form !ORDER.CC.  Please type, or print using large characters. 
  205. Double-check your information to make sure it is correct. 
  206.  
  207. Order Options 
  208.  
  209. Prices are: 
  210.  
  211. Option A is $ 99 for 2-process/100 open files per process, DLL 
  212. Option B is $198 for 32-process/250 open files per process, DLL 
  213. Option C is $297 for unlimited-process/1024 open files per process, DLL and LIB 
  214.  
  215. All Bullet/2 versions include a printed manual and standard AirMail shipping at 
  216. no extra charge. 
  217.  
  218. The BULLET2.DLL may be distributed with your end-user program.  There are no 
  219. run-time fees and there are no royalty fees.  Refer to the LICENSE AGREEMENT 
  220. for limitations on distributing BULLET2.DLL with a non-end-user package. 
  221.  
  222. Γûá Option A permits two processes to use the Bullet DLL at the same time.  This 
  223. is not a user limit, but a process limit.  This two-process limit means that 
  224. you can start two different programs that use BULLET2.DLL, and have them both 
  225. run at the same time, on the same machine.  Before starting a third program 
  226. that uses BULLET2.DLL, you must end one or both of the previous two.  Most 
  227. programmers should need only 1 Bullet process active at a time.  There's an 
  228. extra process should you need it.  The total number of Bullet DBF and index 
  229. files open at any one time may be up to 100 files per process, total (sum of 
  230. data and index; memo files are not counted against this).  Most programmers 
  231. should not need more than 100 files open at the same time. 
  232.  
  233. Γûá Option B permits 32 processes to use the Bullet DLL at the same time.  The 
  234. total number of Bullet DBF and index files open at any one time may be up to 
  235. 250 files per process, total (sum of data and index; memo files are not counted 
  236. against this). 
  237.  
  238. Γûá Option C permits an unlimited number of processes (limited only by the OS 
  239. itself) to use the Bullet DLL at the same time.  In addition to the BULLET 
  240. dynamic link library (BULLET2.DLL), Option C provides the BULLET static link 
  241. library (BULLET2.LIB), which may be directly linked into your end-user 
  242. executable program so as to not require BULLET2.DLL.  The total number of 
  243. Bullet DBF and index files open at any one time may be up to 1024 files per 
  244. process, total (sum of data and index; memo files are not counted against 
  245. this).  Special-order versions with more than 1024 files are available. 
  246.  
  247. Delivery Options 
  248.  
  249. Standard AirMail to all destinations is available at no extra charge.  Shipping 
  250. weight is approximately 4lbs (2kg) and 10x12x1" (25x30x3cm). 
  251.  
  252. Note:  All shipments outside of the US may go through your country's Customs. 
  253. Each package is valued at the total price of the order, less any shipping 
  254. costs, if any, unless pre-arranged otherwise.  Your Customs Office may delay 
  255. mail delivery if duty is required. 
  256.  
  257. Click here [Γûá] for the check, money-order, cash order form. 
  258.  
  259. Click here [Γûá] for the credit card order from. 
  260.  
  261.  
  262. ΓòÉΓòÉΓòÉ 5.1. Order Form for Check, Money-order, or Cash ΓòÉΓòÉΓòÉ
  263.  
  264. Printing this section from here may not fit on a single page.  Use the file 
  265. !ORDER.FRM instead, or select the 'Services' menu item from here (upper-left), 
  266. and select 'Copy to file' to print this to .\TEXT.TMP. 
  267.  
  268. Bullet/2 2.1 for OS/2 Order Form for Check, Money-order, or Cash
  269. Details on Options A-C are in 'Ordering Information' in the documentation.
  270.  
  271.                                     Cost Per    Number of
  272.                                     License     Licenses    Extended
  273.  --------------------------------------------------------------------
  274.  Option A.  Single-license, 2 processes/100 files per process DLL
  275.  
  276.                                     $  99.00  x          =
  277.  ------------------------------------------------------     ---------
  278.  Option B.  Single-license, 32 processes/250 files per process DLL
  279.  
  280.                                     $ 198.00  x          =
  281.  ------------------------------------------------------     ---------
  282.  Option C.  Single-license, unlimited processes/1024 files per process
  283.             DLL and static link library
  284.                                     $ 297.00  X          =
  285.  ------------------------------------------------------     ---------
  286.         For Texas shipping destinations only, add 7.75%  =
  287.  
  288.                                                 TOTAL =
  289.                                                             =========
  290.  
  291. Send TOTAL payment on check (US Dollars/US bank), money-order, or cash to
  292.  
  293.         CORNEL HUTH                       Always endorse your letter
  294.         6402 INGRAM RD                             AirMail
  295.         SAN ANTONIO TX 78238-3915          if you are not in the USA
  296.         USA
  297.  
  298.    PLEASE PRINT - For comments add a separate page and mark here [  ]
  299.  
  300. Your Name>
  301.            -------------------------------------------------- (required)
  302.  
  303.   Company>
  304.            -------------------------------------------------- (optional)
  305.  
  306.   Address>
  307.            -------------------------------------------------------------
  308.  
  309.  
  310.            -------------------------------------------------------------
  311.  
  312.  
  313.            -------------------------------------------------------------
  314.  
  315.     E-mail>                                               Disk
  316.            ---------------------------------------------- Size> --------
  317.  
  318.  Telephone                             Fax
  319.    Number> --------------------------- No.> ----------------------------
  320.  
  321.                                               Today's Date>
  322.            ----------------------------------               ---/----/---
  323.  
  324.  
  325. ΓòÉΓòÉΓòÉ 5.2. Order Form for Credit Card ΓòÉΓòÉΓòÉ
  326.  
  327. Printing this section from here may not fit on a single page.  Use the file 
  328. !ORDER.CC instead, or select the 'Services' menu item from here (upper-left), 
  329. and select 'Copy to file' to print this to .\TEXT.TMP. 
  330.  
  331. Bullet/2 2.1 for OS/2 Order Form for Credit Card         (PsL Item# 11185)
  332. Details on Options A-C are in 'Ordering Information' in the documentation.
  333.  
  334.                                     Cost Per    Number of
  335.                                     License     Licenses    Extended
  336.  --------------------------------------------------------------------
  337.  Option A.  Single-license, 2 processes/100 files per process DLL
  338.  
  339.                                     $  99.00  x          =
  340.  ------------------------------------------------------     ---------
  341.  Option B.  Single-license, 32 processes/250 files per process DLL
  342.  
  343.                                     $ 198.00  x          =
  344.  ------------------------------------------------------     ---------
  345.  Option C.  Single-license, unlimited processes/1024 files per process
  346.             DLL and static link library
  347.                                     $ 297.00  X          =
  348.  ------------------------------------------------------     ---------
  349.         For Texas shipping destinations only, add 7.75%  =
  350.  
  351.                                                 TOTAL =
  352.                                                             =========
  353.  
  354. Call this in by telephone voice @ 1(800)242-4775 or 1(713)524-6394, or
  355. fax this to 1(713)524-6398, or Compuserve e-mail to 71355,470, or
  356. internet e-mail to 71355.470@compuserve.com.  For postal address see docs.
  357.  
  358.    PLEASE PRINT - For comments add a separate page and mark here [  ]
  359.  
  360. Your Name>
  361.            -------------------------------------------------- (required)
  362.  
  363.   Company>
  364.            -------------------------------------------------- (optional)
  365.  
  366.   Address>
  367.            -------------------------------------------------------------
  368.  
  369.  
  370.            -------------------------------------------------------------
  371.  
  372.  
  373.            -------------------------------------------------------------
  374.  
  375.     E-mail>                                               Disk
  376.            ---------------------------------------------- Size> --------
  377.  
  378.  Telephone                             Fax
  379.    Number> --------------------------- No.> ----------------------------
  380.  
  381.  Credit
  382. Card Type> ---------- Number> ----------------------------- Exp> ---/---
  383.  
  384.      Sign>                                    Today's Date>
  385.            ----------------------------------               ---/----/---
  386.  
  387.  
  388. ΓòÉΓòÉΓòÉ 6. Tutorial ΓòÉΓòÉΓòÉ
  389.  
  390. This tutorial describes how to set up a basic database.  It describes file 
  391. layout and how to use Bullet to enter into and read from the database.  It does 
  392. not describe aspects that do not relate to Bullet, such as how to load list 
  393. boxes, create dialogs, etc.  This tutorial creates a music CD collection 
  394. database. 
  395.  
  396. The tutorial follows. 
  397.  
  398.  
  399. ΓòÉΓòÉΓòÉ 6.1. Tutorial: Output Requirements ΓòÉΓòÉΓòÉ
  400.  
  401. The goal of this tutorial is to create a database for a music CD collection. 
  402. The method used is a suggested method; it is by no means the only way to 
  403. develop a database, and only touches the surface of database programming.  That 
  404. said... 
  405.  
  406. The most important thing to do is to know what output you want.  From that, you 
  407. know what input is needed.  For the 'CD database', I've drawn up a list of 
  408. things that I want: 
  409.  
  410. Title, artist, and year.  Must have those.  Track name (the song name), track 
  411. number, and play time would be essential, too.  How about who was playing on 
  412. the track and instruments they used?  Put that on your list -- it's not on this 
  413. one. 
  414.  
  415. All these could be entered into a single file as a single database record, but 
  416. that would be a pretty poor design.  A single data file may seem to be the 
  417. obvious way, but in the long run, it's not very good at all.  This database 
  418. uses two data files.  This concept -- multiple data files -- is especially 
  419. useful when the database is more complex.  For example, an accounting system 
  420. would employ many physical data files.  It could be done in one, sure, but the 
  421. maintenance would be very difficult. 
  422.  
  423. Two tables are used:  The Title-Artist-Year table (Title/CTAY), and the 
  424. TrackNumber-TrackName-Time table (Tracks/CTTT).  A table is a file composed of 
  425. rows and columns.  A row is a record; a column is a field.  No two rows may be 
  426. exactly alike (what would be the point?).  In addition to the fields listed 
  427. (the Title, Artist, and Year, for instance), each table includes a Code field. 
  428. TrackNumber is included as a field value in the second table since the physical 
  429. ordering of rows cannot be used for this purpose (it could, technically, but it 
  430. is unwise to depend on row order being preserved since there is nothing 
  431. enforcing the physical ordering of records). 
  432.  
  433. The Code field for the Title table (CTAY) is generated by the program and is 
  434. composed of the first 4 characters of the Title, plus the first 4 characters of 
  435. the Artist, plus the year (all four characters of it).  This code is also used 
  436. in the Tracks table (CTTT).  This serves two purposes:  First, it ensures that 
  437. each Track record is unique (with pretty good certainty; without it, it is 
  438. possible that TrackNumber-TrackName-Time alone may occur more than once), and 
  439. second, it can be used as the primary key when being accessed through the 
  440. foreign key in the Title table (see Record Layout Diagrams).  By searching CTAY 
  441. (the Title Table) for a desired title, or artist, or even year, and using the 
  442. Code field from that row, you can match it to the Code in CTTT (Track Table) to 
  443. find the tracks that belong to that title row (or artist, or year -- whatever 
  444. the search was based on).  To speed up searching, indexes are maintained and 
  445. used for lookups.  For a very large CD collection (say, several thousand CD 
  446. titles, and tens of thousands of tracks), the database can still be very 
  447. quickly queried for whatever information you need (and have programmed). 
  448.  
  449.  
  450. ΓòÉΓòÉΓòÉ 6.2. Tutorial: Record Layout ΓòÉΓòÉΓòÉ
  451.  
  452. The Code field is generated by your program.  Other fields are input data.  The 
  453. following are the data record layouts of the DBF files (tag fields not shown). 
  454. The time field may be created as a text field with the form "mm:ss", or could 
  455. even be made into a 'seconds' field.  This database uses the more direct 
  456. "mm:ss" since that's how it's read off the CD. Note that this information is 
  457. already stored digitally on the CD itself (running time), but that would 
  458. require additional coding and is not relevant to this tutorial (but oh, how 
  459. sweet it could be). 
  460.  
  461.  CTAY TABLE
  462. ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  463. Γöé   CODE     Γöé      TITLE      Γöé     ARTIST      ΓöéYEAR Γöé
  464. Γöé            Γöé                 Γöé                 Γöé     Γöé
  465. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  466.  MexiConc1993  Mexican Moon      Concrete Blonde  1993
  467.  No NCran1994  No Need to Argue  Cranberries, The 1994
  468.  MachDeep1972  Machine Head      Deep Purple      1972
  469.  
  470.  
  471.               CTTT TABLE
  472.              ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  473.              Γöé    CODE    ΓöéTRKΓöé     TRACKNAME      ΓöéTIME Γöé
  474.              Γöé            Γöé   Γöé                    Γöé     Γöé
  475.              ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  476.               MexiConc1993  01 Jenny I Read         05:18
  477.               MexiConc1993  02 Mexican Moon         05:03
  478.               MexiConc1993  03 Heal It Up           04:21
  479.               MexiConc1993  04 Jonestown            06:06
  480.               MexiConc1993  05 Rain                 03:28
  481.               MexiConc1993  06 I Call It Love       05:15
  482.               MexiConc1993  07 Jesus Forgive Me     05:17
  483.               MexiConc1993  08 When You Smile       04:18
  484.               MexiConc1993  09 Close To Home        03:31
  485.               MexiConc1993  10 One Of My Kind       03:55
  486.               MexiConc1993  11 End Of The Line      04:39
  487.               MexiConc1993  12 Blind Ambition       06:10
  488.               MexiConc1993  13 Bajo La Lune         05:07
  489.               No NCran1994  01 Ode To My Family     04:30
  490.               No NCran1994  02 I Can't Be With You  03:07
  491.               No NCran1994  03 Twenty One           03:08
  492.               No NCran1994  04 Zombie               05:06
  493.               No NCran1994  05 Empty                03:26
  494.               No NCran1994  06 Everything I Said    03:53
  495.               No NCran1994  07 The Icicle Melts     02:54
  496.               No NCran1994  08 Disappointment       04:14
  497.               No NCran1994  09 Ridiculous Thoughts  04:31
  498.               No NCran1994  10 Dreaming My Dreams   03:37
  499.               No NCran1994  11 Yeat's Grave         02:59
  500.               No NCran1994  12 Daffodil Lament      06:09
  501.               No NCran1994  13 No Need To Argue     02:56
  502.               MachDeep1972  01 Highway Star         06:05
  503.               MachDeep1972  02 Maybe I'm A Leo      04:51
  504.               MachDeep1972  03 Pictures Of Home     05:03
  505.               MachDeep1972  04 Never Before         03:56
  506.               MachDeep1972  05 Smoke On The Water   05:40
  507.               MachDeep1972  06 Lazy                 07:19
  508.               MachDeep1972  07 Space Truckin'       04:31
  509.  
  510.  
  511. ΓòÉΓòÉΓòÉ 6.3. Tutorial: Index Files Used ΓòÉΓòÉΓòÉ
  512.  
  513. The index files created for this database are, for CTAY: Title+Artist and 
  514. Artist+Title (the + indicates a compound key made up of more than one field); 
  515. for CTTT: Code+TrackName and TrackName+Code.  With these indexes, searching can 
  516. be made on CD title, by Artist, or by TrackName.  If searching by year is 
  517. required, an additional index could be used, such as Year+Artist+Title (Title 
  518. being used as part of the key in case an Artist releases more than one title in 
  519. a year). 
  520.  
  521. To search by CD title, a title is used as the key.  Even a partial title can be 
  522. used during the actual lookup.  For example, 'Mexican'.  From this, a search is 
  523. made in the Title+Artist index.  The first key starting with 'Mexican' is 
  524. returned.  The index can then be traversed to find any other keys also starting 
  525. with this (by getting the next key).  Since Bullet has high-level access 
  526. routines (GET_FIRST_XB, for example), where a key search returns the data 
  527. record, once a key is found its data is already in memory (the record is 
  528. typically read directly into a structure variable you have set up).  This lets 
  529. you move through the CTAY file getting each record in key order, one at a time 
  530. (one key and record per call to Bullet). 
  531.  
  532. With the data record in memory, the Code field in the record (CTAY table) is 
  533. used as a foreign key into CTTT.  A new search needs to be done, this time on 
  534. the Code+TrackName index of the CTTT table.  With the search key set to 
  535. 'MexiConc1993' (the foreign key field in CTAY of the record that first matched 
  536. 'Mexican'), the Code+TrackName index for CTTT is searched.  The first key 
  537. starting with 'MexiConc1993' is returned, and its data record.  In that record 
  538. is the track name, track number, and track time.  When done with that record, 
  539. the index can be tranversed in-order (forward, or even backward), and, so long 
  540. as the first 12 characters of the Code+TrackName key match 'MexiConc1993', that 
  541. key's record is used.  When the match is no longer true in those first 12 
  542. characters, which in the example data occurs after 13 tracks have been read, it 
  543. means that all matching keys in that index file have been found, and there are 
  544. no others matching the criterion. 
  545.  
  546. The TrackName part of Code+TrackName (the part of the key after the first 12 
  547. characters) is not needed as a match criterion in this case; TrackName is being 
  548. used solely for the purpose of making the key unique to that particular CD 
  549. Title (all Code fields are the same for each trackname on the CD). 
  550.  
  551. A possible additional index file would be a key based on Code, for CTAY (there 
  552. is such an index already for CTTT).  This would allow indexed access to the 
  553. CTAY table when looking for the Title of a track name.  (In other words, you 
  554. have a list of track names of all CDs in the database, in track name order, and 
  555. want to know the CD Title for each track you see.)  Even without an index this 
  556. can be done by using the Code value in CTTT as a sequential search lookup value 
  557. in CTAY (searching for the matching Code value in CTAY).  This additional index 
  558. is not used here. 
  559.  
  560.  
  561. ΓòÉΓòÉΓòÉ 6.4. Tutorial: Creating the Data Files ΓòÉΓòÉΓòÉ
  562.  
  563. Now that the output requirements are known, and the layout of the data records 
  564. of the two data files constructed, and the index access methods designed, the 
  565. database can be created.  Bullet provides routines to create the files of the 
  566. database according to specifications that you supply. 
  567.  
  568. The CTAY (Code-Title-Artist-Year) and CTTT (Code-Track-TrackName-Time) tables 
  569. are to be in this format: 
  570.  
  571.   CTAY TABLE
  572.  ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  573.  Γöé   CODE     Γöé      TITLE      Γöé     ARTIST      ΓöéYEAR Γöé
  574.  ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  575.   MexiConc1993  Mexican Moon      Concrete Blonde  1993   (sample record)
  576.      :
  577.  
  578.  CODE      character data, 12 bytes
  579.  TITLE     character data, 32 bytes
  580.  ARTIST    character data, 35 bytes
  581.  YEAR      character data, 4 bytes
  582.  
  583.  
  584.   CTTT TABLE
  585.  ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  586.  Γöé    CODE    ΓöéTRKΓöé     TRACKNAME      ΓöéTIME Γöé
  587.  ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  588.   MexiConc1993  01 Jenny I Read         05:18   (sample record)
  589.       :
  590.  
  591.  CODE      character data, 12 bytes
  592.  TRK       character data, 2 bytes
  593.  TRACKNAME character data, 40 bytes
  594.  TIME      character data, 5 bytes
  595.  
  596. The fields are sized primarily on expected need.  Since each DBF record has a 
  597. 1-byte tag field, the sum of the above record layouts, including the tag byte, 
  598. is aligned to an even 4-byte size.  An admirable goal, but not a primary design 
  599. consideration.  CTAY is 84 bytes per record; CTTT is 60 bytes per record. 
  600.  
  601. Data is not entered during the create process.  That comes later.  The create 
  602. is only to make the physical files.  The following is the Bullet code required 
  603. to build the two data files.  The index files are covered later. 
  604.  
  605. typedef struct _CTAY {
  606.  CHAR tag;
  607.  CHAR code[12];
  608.  CHAR title[32];
  609.  CHAR artist[35];
  610.  CHAR year[4];
  611. } CTAY;         // (total CTAY record length is 84 bytes)
  612. CTAY ctayRec;
  613.  
  614. CHAR ctayName[] = "CTAY.DBF";
  615. ULONG ctayID=0;                             // handle of CTAY file
  616. FIELDDESCTYPE ctayFieldList[4];             // 4 fields used by the record
  617. memset(ctayFieldList,0,sizeof(ctayFieldList));  // init unused bytes to 0
  618.  
  619. typedef struct _CTTT {
  620.  CHAR tag;
  621.  CHAR code[12];
  622.  CHAR trk[2];
  623.  CHAR trackName[40];
  624.  CHAR time[5];
  625. } CTTT;         // (total CTTT record length is 60 bytes)
  626. CTTT ctttRec;
  627.  
  628. CHAR ctttName[] = "CTTT.DBF";
  629. ULONG ctttID=0;
  630. FIELDDESCTYPE ctttFieldList[4];
  631. memset(ctttFieldList,0,sizeof(ctttFieldList));
  632.  
  633. // field descriptor info for CTAY
  634.  
  635. strcpy(ctayFieldList[0].fieldName, "CODE");
  636. ctayFieldList[0].fieldType = 'C';
  637. ctayFieldList[0].fieldLen = 12;
  638. ctayFieldList[0].fieldDC = 0;
  639.  
  640. strcpy(ctayFieldList[1].fieldName, "TITLE");
  641. ctayFieldList[1].fieldType = 'C';
  642. ctayFieldList[1].fieldLen = 32;
  643. ctayFieldList[1].fieldDC = 0;
  644.  
  645. strcpy(ctayFieldList[2].fieldName, "ARTIST");
  646. ctayFieldList[2].fieldType = 'C';
  647. ctayFieldList[2].fieldLen = 35;
  648. ctayFieldList[2].fieldDC = 0;
  649.  
  650. strcpy(ctayFieldList[3].fieldName, "YEAR");
  651. ctayFieldList[3].fieldType = 'C';
  652. ctayFieldList[3].fieldLen = 4;
  653. ctayFieldList[3].fieldDC = 0;
  654.  
  655. // field descriptor info for CTTT
  656.  
  657. strcpy(ctttFieldList[0].fieldName, "CODE");
  658. ctttFieldList[0].fieldType = 'C';
  659. ctttFieldList[0].fieldLen = 12;
  660. ctttFieldList[0].fieldDC = 0;
  661.  
  662. strcpy(ctttFieldList[1].fieldName, "TRACK");
  663. ctttFieldList[1].fieldType = 'C';
  664. ctttFieldList[1].fieldLen = 2;
  665. ctttFieldList[1].fieldDC = 0;
  666.  
  667. strcpy(ctttFieldList[2].fieldName, "TRACKNAME");
  668. ctttFieldList[2].fieldType = 'C';
  669. ctttFieldList[2].fieldLen = 40;
  670. ctttFieldList[2].fieldDC = 0;
  671.  
  672. strcpy(ctttFieldList[3].fieldName, "TIME");
  673. ctttFieldList[3].fieldType = 'C';
  674. ctttFieldList[3].fieldLen = 5;
  675. ctttFieldList[3].fieldDC = 0;
  676.  
  677. // create the CTAY file
  678.  
  679. CDP.func = CREATE_DATA_XB;
  680. CDP.filenamePtr = ctayName;
  681. CDP.noFields = 4;
  682. CDP.fieldListPtr = ctayFieldList;
  683. CDP.fileID = 3;
  684. rez = BULLET(&CDP);
  685. if (rez) {
  686.    printf("Failed CTAY create.  Err: %d\n",rez);
  687.    return(rez);
  688. }
  689.  
  690. // create the CTTT file
  691.  
  692. CDP.func = CREATE_DATA_XB;
  693. CDP.filenamePtr = ctttName;
  694. CDP.noFields = 4;
  695. CDP.fieldListPtr = ctttFieldList;
  696. CDP.fileID = 3;
  697. rez = BULLET(&CDP);
  698. if (rez) {
  699.    printf("Failed CTTT create.  Err: %d\n",rez);
  700.    return(rez);
  701. }
  702.  
  703.  
  704. ΓòÉΓòÉΓòÉ 6.5. Tutorial: Opening the Data Files ΓòÉΓòÉΓòÉ
  705.  
  706. Before using a data file it must be opened.  Any DBF file can be opened, 
  707. whether created by Bullet or another program.  Before creating indexes for the 
  708. data files created here, the data files must be open.  The handles of the open 
  709. data files are used in the index file create process. 
  710.  
  711.  
  712. // open CTAY and store handle to ctayID
  713.  
  714. OP.func = OPEN_DATA_XB;
  715. OP.filenamePtr = ctayData;
  716. OP.asMode = READWRITE | DENYNONE;
  717. rez = BULLET(&OP);
  718. if (rez) {
  719.    printf("Failed CTAY file open.  Err: %d\n",rez);
  720.    return(rez);
  721. }
  722. ctayID = OP.handle;
  723.  
  724. // open CTTT and store handle to ctttID
  725.  
  726. OP.func = OPEN_DATA_XB;
  727. OP.filenamePtr = ctttData;
  728. OP.asMode = READWRITE | DENYNONE;
  729. rez = BULLET(&OP);
  730. if (rez) {
  731.    printf("Failed CTTT file open.  Err: %d\n",rez);
  732.    return(rez);
  733. }
  734. ctttID = OP.handle;
  735.  
  736.  
  737. ΓòÉΓòÉΓòÉ 6.6. Tutorial: Creating the Index Files ΓòÉΓòÉΓòÉ
  738.  
  739. Two pairs of index files are used.  For CTAY, Title+Artist and Artist+Title; 
  740. for CTTT, Code+TrackName and TrackName+Code.  These are expected to be unique, 
  741. and so the index files are specified to not accept duplicate keys.  Also, 
  742. rather than using the full field sizes for key expressions, substrings are 
  743. specified.  Long keys affect performance, both in index file size and general 
  744. access speed (smaller is usually better), and using the entire field data does 
  745. little to differentiate the key (for the uniqueness requirement).  If 
  746. DUPS_ALLOWED were specified, even shorter keys could be used, though duplicates 
  747. generally are not desirable.  If there comes a record whose generated key is 
  748. not unique (i.e., it already belongs to another already-added record), either 
  749. modify the data entered so that its key is different, if possible, or redo your 
  750. index files to allow duplicates.  You could also play if 'safe' and permit 
  751. duplicates keys to occur from the outset, knowing that not many duplicates will 
  752. occur, where if they do, you can continue and let Bullet managed the duplicate 
  753. key with an enumerator.  If many duplicates of keys are possible, re-evaluate 
  754. your key expression to make it more unique.  This is done by using a compound 
  755. key with more field components.  Still, the fewer components in a key, and the 
  756. shorter, the better the key is. 
  757.  
  758. Index file creation: 
  759.  
  760. CHAR xTitleName[] = "TITLE.IX3";
  761. CHAR xTitleExp[] = "SUBSTR(TITLE,1,8)+SUBSTR(ARTIST,1,8)";
  762. CHAT xTitleBuffer[16];          // key buffer for later use
  763.                                 // note that if DUPS_ALLOWED, the key buffer must
  764.                                 // provide room for the enumerator (2 bytes more)
  765.  
  766. CHAR xArtistName[] = "ARTIST.IX3";
  767. CHAR xArtistExp[] = "SUBSTR(ARTIST,1,8)+SUBSTR(TITLE,1,8)";
  768. CHAT xArtistBuffer[16];
  769.  
  770. CHAR xCodeName[] = "CODETRK.IX3";
  771. CHAR xCodeExp[] = "CODE+SUBSTR(TRACKNAME,1,12)";
  772. CHAT xCodeBuffer[24];
  773.  
  774. CHAR xTrackName[] = "TRKNAME.IX3";
  775. CHAR xTrackExp[] = "SUBSTR(TRACKNAME,1,12)+CODE";
  776. CHAT xTrackBuffer[24];
  777.  
  778. // create two index files for CTAY
  779.  
  780. CIP.func = CREATE_INDEX_XB;
  781. CIP.filenamePtr = xTitleName;
  782. CIP.keyExpPtr = xTitleExp;
  783. CIP.xbLink = ctayID;            // the handle of the open CTAY file
  784. CIP.sortFunction = NLS_SORT;    // sort key by NLS for proper mixed-case order
  785. CIP.codePage = 0;               // use OS-default code page
  786. CIP.countryCode = 0;            // use OS-default country code
  787. CIP.collatePtr = NULL;          // no need for a special collate table
  788. CIP.nodeSize = 512;             // 512-byte node size (or 1024, 2048 bytes)
  789. rez = BULLET(&CIP);
  790. if (rez) {
  791.    printf("Failed Title index create.  Err: %d\n",rez);
  792.    return(rez);
  793. }
  794.  
  795. CIP.filenamePtr = xArtistName;
  796. CIP.keyExpPtr = xArtistExp;     // other values still valid from above
  797. rez = BULLET(&CIP);
  798. if (rez) {
  799.    printf("Failed Artist index create.  Err: %d\n",rez);
  800.    return(rez);
  801. }
  802.  
  803. // create two index files for CTTT
  804.  
  805. CIP.func = CREATE_INDEX_XB;
  806. CIP.filenamePtr = xCodeName;
  807. CIP.keyExpPtr = xCodeExp;
  808. CIP.xbLink = ctttID;            // as above...
  809. CIP.sortFunction = NLS_SORT;
  810. CIP.codePage = 0;
  811. CIP.countryCode = 0;
  812. CIP.collatePtr = NULL;
  813. CIP.nodeSize = 512;
  814. rez = BULLET(&CIP);
  815. if (rez) {
  816.    printf("Failed Code index create.  Err: %d\n",rez);
  817.    return(rez);
  818. }
  819.  
  820. CIP.filenamePtr = xTrackName;
  821. CIP.keyExpPtr = xTrackExp;      // other values still valid from above
  822. rez = BULLET(&CIP);
  823. if (rez) {
  824.    printf("Failed TrackName index create.  Err: %d\n",rez);
  825.    return(rez);
  826. }
  827.  
  828.  
  829. ΓòÉΓòÉΓòÉ 6.7. Tutorial: Opening the Index Files ΓòÉΓòÉΓòÉ
  830.  
  831. Before using an index file it must be opened.  Only Bullet index files can be 
  832. opened. 
  833.  
  834. // open Title index and store handle to xTitleID
  835.  
  836. OP.func = OPEN_INDEX_XB;
  837. OP.filenamePtr = xTitleName;
  838. OP.asMode = READWRITE | DENYNONE;
  839. OP.xbLink = ctayID;                     // note xbLink
  840. rez = BULLET(&OP);
  841. if (rez) {
  842.    printf("Failed Title index open.  Err: %d\n",rez);
  843.    return(rez);
  844. }
  845. xTitleID = OP.handle;
  846.  
  847. // open Artist index and store handle to artistID
  848.  
  849. OP.func = OPEN_INDEX_XB;
  850. OP.filenamePtr = xArtistName;
  851. OP.asMode = READWRITE | DENYNONE;
  852. OP.xbLink = ctayID;
  853. rez = BULLET(&OP);
  854. if (rez) {
  855.    printf("Failed Artist index open.  Err: %d\n",rez);
  856.    return(rez);
  857. }
  858. xArtistID = OP.handle;
  859.  
  860. // open Code index and store handle to xCodeID
  861.  
  862. OP.func = OPEN_INDEX_XB;
  863. OP.filenamePtr = xCodeName;
  864. OP.asMode = READWRITE | DENYNONE;
  865. OP.xbLink = ctttID;
  866. rez = BULLET(&OP);
  867. if (rez) {
  868.    printf("Failed Code index open.  Err: %d\n",rez);
  869.    return(rez);
  870. }
  871. xCodeID = OP.handle;
  872.  
  873. // open TrackName index and store handle to xTrackNameID
  874.  
  875. OP.func = OPEN_INDEX_XB;
  876. OP.filenamePtr = xTrackName;
  877. OP.asMode = READWRITE | DENYNONE;
  878. OP.xbLink = ctttID;
  879. rez = BULLET(&OP);
  880. if (rez) {
  881.    printf("Failed TrackName index open.  Err: %d\n",rez);
  882.    return(rez);
  883. }
  884. xTrackNameID = OP.handle;
  885.  
  886.  
  887. ΓòÉΓòÉΓòÉ 6.8. Tutorial: Inserting CD Title Data ΓòÉΓòÉΓòÉ
  888.  
  889. The files have been created, and are open.  Data may now inserted into the 
  890. database.  The term 'inserted' is used in contrast to 'added' since Bullet 
  891. 'adds' data only, while it 'inserts' data and key information together (and 
  892. especially, the key is inserted, in order).  The CD data entry would typically 
  893. be done via the keyboard.  This tutorial assumes that this has already been 
  894. done, and that the data items are in the following structure variables: 
  895. ctayRec for CD title data; ctttRec for track data. 
  896.  
  897. First, the CD title record is added to CTAY with a key inserted into the Title 
  898. index and another key into Artist index.  Data entered by the user consists of 
  899. CD title, artist, and year.  The Code field is generated by the program code, 
  900. shown below. 
  901.  
  902. // ctayRec has CD title, artist, and year -- generate Code field data
  903.  
  904. strncpy(ctayRec.code  ,ctayRec.title,4);   // first 4 of title
  905. strncpy(ctayRec.code+4,ctayRec.artist,4);  // first 4 of artist
  906. strncpy(ctayRec.code+8,ctayRec.year,4);    // and 4 of year make the Code field
  907.  
  908. // insert CD title data (one data record added, two index files inserted into)
  909.  
  910. AP[0].func = INSERT_XB;
  911. AP[0].handle = xTitleID;        // handle of Title index
  912. AP[0].recNo = 0;                // required
  913. AP[0].recPtr = &ctayRec;        // the CD title record
  914. AP[0].keyPtr = xTitleBuffer;    // key buffer
  915. AP[0].nextPtr = &AP[1];         // since two index files, point to next
  916. AP[1].handle = xArtistID:       // handle of Artist index
  917. AP[1].recNo = 0x80000000;       // required
  918. AP[1].recPtr = &ctayRec;        // the CD title record
  919. AP[1].keyPtr = xArtistBuffer;   // key buffer
  920. AP[1].nextPtr = NULL;
  921.  
  922. rez = BULLET(&AP[0]);
  923. if (rez) {                      // rez is not error, but pack index of error
  924.    rc = AP[abs(rez)-1].stat;
  925.    printf("Insert failed, pack: %d, err: %d\n",rez,rc);
  926.    return(rc);
  927. }
  928.  
  929. A CD title has been entered.  That's the first part of the data entry.  Next, 
  930. each track on that CD needs to be entered.  It needs the Code field data 
  931. generated above, along with the general track data (track name, etc.). 
  932.  
  933.  
  934. ΓòÉΓòÉΓòÉ 6.9. Tutorial: Inserting CD Track Data ΓòÉΓòÉΓòÉ
  935.  
  936. During the CD title insert, a Code field value was generated.  That field value 
  937. is used for each of the track entries inserted into database for this CD.  The 
  938. actual track data has already been placed in the ctttRec structure variable (by 
  939. the main program code, not shown here), and only the Code field of ctttRec 
  940. needs to be set.  Once done, the track record is inserted, this time into the 
  941. CTTT data file and the Code and Track index files. 
  942.  
  943. //
  944. // this code section is repeated for each track on the CD
  945. //
  946.  
  947. // copy Code field data from CTAY
  948.  
  949. strncpy(ctttRec.code,ctayRec.code,12); // use Title's Code for each Track entry
  950.  
  951. // insert track data (one data record added, two index files inserted into)
  952.  
  953. AP[0].func = INSERT_XB;
  954. AP[0].handle = xCodeID;         // handle of Code index
  955. AP[0].recNo = 0;                // required
  956. AP[0].recPtr = &ctttRec;        // the track record
  957. AP[0].keyPtr = xCodeBuffer;     // key buffer
  958. AP[0].nextPtr = &AP[1];         // since two index files, point to next
  959. AP[1].handle = xTrackID:        // handle of TrackName index
  960. AP[1].recNo = 0x80000000;       // required
  961. AP[1].recPtr = &ctttRec;        // the track record
  962. AP[1].keyPtr = xTrackBuffer;    // key buffer
  963. AP[1].nextPtr = NULL;
  964.  
  965. rez = BULLET(&AP[0]);
  966. if (rez) {                      // rez is not error, but pack index of error
  967.    rc = AP[abs(rez)-1].stat;
  968.    printf("Insert failed, pack: %d, err: %d\n",rez,rc);
  969.    return(rc);
  970. }
  971.  
  972. // and repeat for each track on the CD
  973.  
  974. The database now contains a complete entry for the one CD.  This process is 
  975. repeated for each CD that is to entered into the database.  This is the data 
  976. entry process.  Data retrieval is covered next. 
  977.  
  978.  
  979. ΓòÉΓòÉΓòÉ 6.10. Tutorial: Retrieving Data ΓòÉΓòÉΓòÉ
  980.  
  981. The database can be accessed in several different ways.  For indexed access, 
  982. any index file can be used.  Alternatively, direct access without an index 
  983. could also be used.  Generally, since there's no guarantee that the physical 
  984. order of rows in the database is in any order at all, index access is usually 
  985. desired.  Possible retrievals are by: 
  986.  
  987. 1. CD title, in alphabetical order, and, from information from the CD title, 
  988. all tracks on the CD.  The tracks are read into an array and sorted by track 
  989. number.  Alternatively, a separate index could be used to order track entries 
  990. by TrackNo+TrackName(+etc.), but since there are so few tracks per CD 
  991. (generally less than 20), it's much more efficient to simply get all tracks for 
  992. a CD title into an array, and then sort that array for presentation. 
  993. Otherwise, an index file would need to be maintained on a permanent basis, and 
  994. for something that can easily be done at run-time (and then discarded). 
  995.  
  996. 2. Artist, in alpha order.  Access is similar to CD title, above, since it uses 
  997. the same data file (CTAY).  As above, tracks for each artist's title can then 
  998. be retrieved.  The only difference between this and the CD title access is that 
  999. this lists CDs by artist, rather than by title. 
  1000.  
  1001. 3. Track name, in alphabetical order.  This lists all tracks by track name, in 
  1002. order, with different tracks intermixed with CD titles.  In other words, if 
  1003. three CDs had the track called "In the Summer Time", then each of those tracks 
  1004. would appear together, one after the other.  There is no index available in 
  1005. this database to access the CD on which the track name appears, so you cannot 
  1006. go from trackname alone to CD title (by index).  However, since the Code field 
  1007. is available, and is common to each data file, the Code field value of a track 
  1008. record can be used to sequentially search the Title records for a match.  This 
  1009. is a non-indexed search.  Access is slower than if an index were available, but 
  1010. unless you created indexes for all possible search methods, some sequential 
  1011. (read: slow) searching may be required.  For smaller files (less than 10,000 
  1012. records), or where only a few such searches occur, this may be perfectly 
  1013. acceptable. 
  1014.  
  1015. An index on Code exists (for CTTT, but not CTAY), and you may find a use for 
  1016. this other than for use as a foreign key lookup.  Also, you may create ad hoc 
  1017. index files whenever you need to, and these can be deleted when no longer 
  1018. required.  Since Bullet can create an index for even a large file in just a few 
  1019. seconds, this is a viable option; the few seconds needed to create an index may 
  1020. be many times repaid in the time saved in sequential searches on a non-indexed 
  1021. access. 
  1022.  
  1023. The first retrieval mentioned is shown next. 
  1024.  
  1025. // for each CD title in the database, display all its tracks
  1026.  
  1027.                         // ctayRec already defined
  1028. CTTT cttyRecs[59];      // store each Track record for later sorting by track#
  1029.  
  1030. // This would be repeated for each CD title (only the first is shown).
  1031. // Note: For the next CD title, GET_NEXT_XB would be used.  If necessary,
  1032. // the key just accessed could be stored (preserved), then laster reaccessed
  1033. // using GET_EQUAL_XB again, and then immediately followed with a GET_NEXT_XB.
  1034. // This way, you can stop processing completely, and restart up where you left
  1035. // off.
  1036.  
  1037. // files are locked as required (e.g., full-lock, shared)
  1038.  
  1039. AP.func = GET_FIRST_XB;
  1040. AP.handle = xTitleID;
  1041. AP.recPtr = &ctayRec;
  1042. AP.keyPtr = xTitleBuffer;
  1043. rez = BULLET(&AP);
  1044. while (rez==0) {
  1045.    printf("Title: %s  Artist: %s  Year: %s\n",
  1046.            ctayRec.title,
  1047.            ctayRec.artist,
  1048.            ctayRec.year);
  1049.  
  1050.    // get each track belonging to this CD title (same Code values)
  1051.  
  1052.    int trk=0;                            // counter
  1053.    memset(xCodeBuffer,0,sizeof(xCodeBuffer)); // clear it to 0
  1054.    strncpy(xCodeBuffer,ctayRec.code,12); // copy Code to search-for buffer
  1055.  
  1056.    AP.func = GET_EQUAL_XB;
  1057.    AP.handle = xCodeID;
  1058.    AP.recPtr = &ctttRecs[trk];
  1059.    AP.keyPtr = xCodeBuffer;             // find Code
  1060.    rez = BULLET(&AP);
  1061.  
  1062.    // rather than print each when gotten, collect them, sort, then display
  1063.    // if rez==0 here then Code matched exactly, no strncmp needed, otherwise,
  1064.    // there's no match on the first 12 characters of Code
  1065.  
  1066.    AP.func = GET_NEXT_XB;               // continue getting while same Code
  1067.    while (rez==0) {
  1068.       trk++;                            // limit to array size...
  1069.       AP.recPtr = &ctttRecs[trk];       // read into next array record
  1070.       rez = BULLET(&AP);
  1071.       if (rez==0) {
  1072.  
  1073.          // if code field in CTTT no longer the same as CTAY, then have them all
  1074.  
  1075.          if (strncmp(ctttRecs[trk].code,ctayRec.code,12)!=0) {
  1076.             rez = 1;
  1077.             break;                      // different Code fields
  1078.          }
  1079.       }
  1080.    }
  1081.  
  1082.    // if rez==1 or at end of file then no error, sort and display --
  1083.    // trk at this point is number of tracks that matched Code (1-based)
  1084.    // DoSortOf... routine sorts the ctttRecs array with trk count of elements
  1085.  
  1086.    if ((rez==1) | (rez==EXB_END_OF_FILE)) {
  1087.       DoSortOfTheTrackRecordsByTrackNumber(&ctttRecs[0],trk);
  1088.  
  1089.       // print each track record, now sorted by track number
  1090.  
  1091.       for (i=0;i < trk;i++) {
  1092.          printf("Trk: %s  Name: %s   Time: %s\n",
  1093.                  ctttRecs[i].trk,
  1094.                  ctttRecs[i].trackName,
  1095.                  ctttRecs[i].time);
  1096.       }
  1097.    else {
  1098.        printf("failed, rez: %d\n",rez);
  1099.        return(rez);
  1100.    }
  1101. }
  1102.  
  1103.  
  1104. ΓòÉΓòÉΓòÉ 6.11. Tutorial: Preparing to End Your Program ΓòÉΓòÉΓòÉ
  1105.  
  1106. It's proper programming practice to perform an orderly shutdown of Bullet when 
  1107. ending your program.  This also extends to files, too, where even if you are 
  1108. not ending your program, but are finished using a file, close that file so that 
  1109. you release the resources allocated for it. 
  1110.  
  1111. In the event that an abnormal termination occurs, and you are unable to release 
  1112. outstanding locks and close all files, you may choose to call EXIT_XB and allow 
  1113. that to close files (the OS releases locks when the file is closed).  If you 
  1114. are unable to call even EXIT_XB, there is still another method that gets 
  1115. Bullet's attention.  During Bullet initialization, the EXIT_XB routine is 
  1116. registered with the OS so that whenever your program terminates (or is 
  1117. terminated), EXIT_XB is called automatically.  This ensures that headers are 
  1118. properly written in all but the most severe of abnormal terminations (abend), 
  1119. such as a lockup. 
  1120.  
  1121. // all outstanding locks should have been released immediately after use
  1122.  
  1123. // close each file that was opened
  1124.  
  1125. HP.func = CLOSE_DATA_XB
  1126. HP.handle = xTitleID;
  1127. if (HP.handle) rez = BULLET(&HP);
  1128. if (rez) printf("close failed, err: %d\n",rez);
  1129.  
  1130. HP.handle = xArtistID;
  1131. if (HP.handle) rez = BULLET(&HP);
  1132. if (rez) printf("close failed, err: %d\n",rez);
  1133.  
  1134. HP.handle = xCodeID;
  1135. if (HP.handle) rez = BULLET(&HP);
  1136. if (rez) printf("close failed, err: %d\n",rez);
  1137.  
  1138. HP.handle = xTrackID;
  1139. if (HP.handle) rez = BULLET(&HP);
  1140. if (rez) printf("close failed, err: %d\n",rez);
  1141.  
  1142. EP.func = EXIT_XB;
  1143. rez = BULLET(&EP);
  1144. if (rez) printf("exit failed, err: %d\n",rez);
  1145.  
  1146. // Bullet is now deinitialized, and must be INIT_XB'ed before further use
  1147.  
  1148.  
  1149. ΓòÉΓòÉΓòÉ 7. History of Changes ΓòÉΓòÉΓòÉ
  1150.  
  1151. Changes Made 
  1152.  
  1153. 2.105 11-Oct-96: 
  1154.  
  1155.    1. Added OS function override revectoring for all OS calls made, and added 
  1156.       supporting query/set routines, QUERY/SET_VECTORS_XB. 
  1157.    2. Added USE_ANSI_SET flag for index file collate sequence table (esp. for 
  1158.       Windows), in addition to standard OEM character set, for use at 
  1159.       CREATE_INDEX_XB. 
  1160.    3. Added shared/exclusive region locking mode for NT. 
  1161.    4. UPDATE_XB efficiency improved, esp. with large number of index files. 
  1162.    5. Internal sort efficiency improved (even faster). 
  1163.    6. Improved demo program samples; also added compile option for generating 
  1164.       console or windowed app. 
  1165.    7. Consolidated Bullet header files into one, for all platforms, with 
  1166.       minimal conditionals; the file is named bullet_2.h. 
  1167.  
  1168.  2.103 4-Oct-1996: 
  1169.  
  1170.    1. Win32 version would fail under NT (and Win32s) because of un-saved 
  1171.       register into consecutive kernel calls. 
  1172.    2. Win32s now supported. 
  1173.    3. Win32 version now in a single DLL (supports Watcom (old and new) and VC4, 
  1174.       both, and both Win32 and Win32s). 
  1175.    4. CREATE_INDEX_XB was always using OS-supplied codepage/country code. 
  1176.    5. Added callback support in reindex and pack records, esp. useful for 
  1177.       DOSX32 and Win32s. 
  1178.    6. UPPER() in key expression would fail. 
  1179.  
  1180.  2.101 28-Aug-1996: 
  1181.  
  1182.    1. REINDEX_XB would fail on certain key sizes, causing an access 
  1183.       violation/GPF. 
  1184.  
  1185.  2.100 3-Aug-1996: 
  1186.  
  1187.    1. REINDEX_XB and GET_LAST_XB could fail if DUPS_ALLOWED. 
  1188.    2. Sort functions 1, 2, and 3 were operating as expected but 4-6 were using 
  1189.       3. 
  1190.    3. Node scanning was using the wrong sort-compare function (1 was using 3, 2 
  1191.       was using 1, and 3 was using 2). 
  1192.    4. UPDATE_XB was returning failed pack's AP[].stat=1 instead of true error 
  1193.       code if the update failed when inserting a new key. 
  1194.    5. BUILD_KEY_XB was not issuing skip tag warning, and was not passing 
  1195.       .recPtr to external build key function. 
  1196.    6. PACK_RECORDS_XB and DEBUMP_RECORD_XB values in bullet2.h were 
  1197.       interchanged: Pack is 47; Debump is 46. 
  1198.    7. DEBUMP_RECORD_XB requires FLUSH_DATA_HEADER_XB call prior to use. 
  1199.    8. Documentation errata: GET_DESCRIPTOR_XB uses DP.handle for IN; includes 
  1200.       DP.FD.altFieldLength for OUT (DP.fieldOffset noted previously) 
  1201.    9. GET_DESCRIPTOR_XB was not returning info in DP.FD.* when accessed by 
  1202.       fieldName. 
  1203.   10. SDP.lastUpdate year was returned with year-256 (1996 was 1740). 
  1204.   11. GET_ERROR_CLASS_XB was not returning useful info. 
  1205.   12. ZAP_INDEX_HEADER_XB had been making index data start at 16KB size. 
  1206.   13. DosExitList() handler is now dropped after calling EXIT_XB. 
  1207.  
  1208.  2.051 24-Apr-96: 
  1209.  
  1210.    1. Fixes to transaction routines InsertXB and UpdateXB, including Insert 
  1211.       rollback fix with multiple packs. 
  1212.    2. Update pack number return value fix. 
  1213.    3. Update w/ multiple packs fix, and an Update rollback fix. 
  1214.    4. Fix of GetKeyForRecordXB when DUPS_ALLOWED. 
  1215.  
  1216.  2.050 26-Feb-96: 
  1217.  
  1218.    1. Shareware refresh released. 
  1219.  
  1220.  2.044 31-Jan-96: 
  1221.  
  1222.    1. Fixed DUPS_ALLOWED bug at INSERT_XB where error EXB_TOP_OF_FILE or error 
  1223.       EXB_TOO_MANY_DUPLICATES would be returned. 
  1224.  
  1225.  2.043  3-Jan-96: 
  1226.  
  1227.    1. Added atomic key access for NEXT_KEY, PREV_KEY, GET_NEXT, and GET_PREV 
  1228.       for simpler use in multi-threaded programs. 
  1229.    2. Changed EXB_SHARED_LOCK_ON in BULLET2.H (was ERR_ rather than EXB_). 
  1230.  
  1231.  2.042 20-Dec-95: 
  1232.  
  1233.    1. MAKE_DIR_DOS was expecting directory name in DFP.bufferPtr.  Changed to 
  1234.       expect path in DFP.filenamePtr. 
  1235.  
  1236.  2.040 28-Oct-95: 
  1237.  
  1238.    1. BACKUP_FILE_XB extended to back up related memo file on DBF backup. 
  1239.    2. [2.033] Fixed memo file problems. 
  1240.    3. [2.032] Win95 version available. 
  1241.    4. [2.031] DOSX32 version available. 
  1242.  
  1243.  2.031 11-Sep-95: 
  1244.  
  1245.    1. Added DP.fieldOffset to documentation for GET_DESCRIPTOR_XB. 
  1246.    2. Instance tracker purified of DosEnterCritSec need. 
  1247.  
  1248.  2.030 9-Sep-95: 
  1249.  
  1250.    1. Removed erroneous '...header reload...' in online docs of RELOCK_DATA_XB. 
  1251.    2. Default maximum filesizes set to 2047 MB from 2048 MB (absolute max is 
  1252.       4095 MB). 
  1253.    3. Fixed REINDEX_XB so that it actually uses re-evaluted key expression. 
  1254.    4. ATEXIT_XB is obsolete. 
  1255.    5. BREAK_XB is obsolete. 
  1256.  
  1257.  2.020 31-Aug-95: 
  1258.  
  1259.    1. Locality and other cache-related options can be set at file open. 
  1260.    2. IP.versionBullet changed to *1000 from *100 (2020 is version 2.020). 
  1261.    3. Instance tracker corrected. 
  1262.  
  1263.  2.01  22-Aug-95: 
  1264.  
  1265.    1. Changed index header to 1024 bytes from 768 for sector-alignment. 
  1266.    2. Changed header ID to '31ch' from '30ch'. 
  1267.  
  1268.  2.00  20-Aug-95: 
  1269.  
  1270.  Preliminary release. 
  1271.  
  1272.  
  1273. ΓòÉΓòÉΓòÉ 8. Bullet Include File ΓòÉΓòÉΓòÉ
  1274.  
  1275. The Bullet/2 C/C++ header file, BULLET_2.H: 
  1276.  
  1277.  
  1278. /* BULLET_2.H    15-Oct-96-chh
  1279.  *
  1280.  *  Bullet header for 32-bit C/C++ (DOSX32, OS/2, and Win32s/Win32)
  1281.  *  Bullet call numbers, parameter packs, and error number equates
  1282.  *
  1283.  *  Requires PLATFORM defined and set to ON_DOSX32 (3), ON_OS2 (4),
  1284.  *  or ON_WIN32 (5) before getting here.  For example:
  1285.  *    #define PLATFORM ON_DOSX32  (ON_DOSX32 defined as 3)
  1286.  *
  1287.  */
  1288.  
  1289. #ifndef __BULLET_H
  1290. #define __BULLET_H
  1291.  
  1292. /*
  1293.  * The #pragma pack(1)/#pragma pack() is no longer required since all
  1294.  * structure members in this header will align properly -- all are
  1295.  * 32-bit size except for the structure "FieldDescType", but fieldDA
  1296.  * member (a LONG) is at a 32-bit alignment already (at byte offset +12).
  1297.  * The altFieldLength member, same structure, is also already at
  1298.  * proper alignment for a 16-bit value (at byte offset +18).  If, for
  1299.  * some reason, your compiler aligns the members differently, then you
  1300.  * must use the appropriate compiler pragma to prevent this -- the
  1301.  * FieldDescType size is 32 bytes exactly.  It is not likely that any
  1302.  * conforming compiler will alter this structure, but, now you know what
  1303.  * to do if it does.
  1304.  *
  1305.  * #pragma pack(1)
  1306.  *
  1307.  * NOTE: In your program source code, when you layout your record buffer
  1308.  * structure, you must use the #pragma pack(1)/#pragma pack() directives
  1309.  * around it since it will be, most likely, modified.  The reason is that
  1310.  * this structure MUST start with the implicit TAG field (a BYTE), and so,
  1311.  * unless you use only BYTE/CHAR members in your structure (Bullet can use
  1312.  * binary field values), or take special care to align the record layout
  1313.  * so no padding is performed by the compiler, then you will need to use
  1314.  * the pack(1) pragma.
  1315.  *
  1316.  * #pragma pack()
  1317.  */
  1318.  
  1319. /* Re: Bullet/X for DOSX32:
  1320.  * (refer to ccdosfn.c for more)
  1321.  * Bullet ccdosfn.c provides no OS call support to determine the
  1322.  * system country code and code page ID.  This can be coded in
  1323.  * ccdosfn.c, but it is quite compiler- and extender-dependent.
  1324.  * The current state is to supply a collate sequence table for
  1325.  * country code=1 and code page=437 (the table is statically coded).
  1326.  * For other sort tables, modify as required.  If support for this
  1327.  * at the system level is made available at run-time, you may
  1328.  * want to change the following to 0, for both CTRYCODE and CODEPAGE.
  1329.  * Until this is so coded, you cannot use 0 here (as with the Win32
  1330.  * and OS/2 versions), else error EXB_216501 (8251) is the result.
  1331.  * This table is added to each index file (if NLS or a user sort).
  1332.  */
  1333.  
  1334. #ifndef ON_DOSX32
  1335.  ON_DOSX32 3
  1336.  ON_OS2    4
  1337.  ON_WIN32  5
  1338. #endif
  1339.  
  1340. #if PLATFORM == ON_DOSX32
  1341.  #define CTRYCODE 1     /* 0 signifies default country code (at index create) */
  1342.  #define CODEPAGE 437   /* 0 signifies default code page (at index create) */
  1343.                         /* but DOS extender may not support OS call to get info */
  1344.                         /* see ccdosfn.c for making changes for DOSX32 platform */
  1345.  #define RELOCK_AVAIL 0 /* relock not supported */
  1346.  
  1347.  #define VOID void      /* these are already defined if Win32 or OS/2, but not DOS */
  1348.  #define SHORT short
  1349.  #define LONG long
  1350.  #define CHAR char
  1351.  
  1352.  typedef unsigned char BYTE;
  1353.  typedef unsigned short USHORT;
  1354.  typedef unsigned long ULONG;
  1355.  typedef unsigned char *PSZ;
  1356.  typedef VOID *PVOID;
  1357.  
  1358.  #define APIENTRY __cdecl
  1359.  
  1360. #elif PLATFORM == ON_OS2
  1361.  #define CTRYCODE 0
  1362.  #define CODEPAGE 0
  1363.  #define RELOCK_AVAIL 1    /* relock is supported */
  1364.  
  1365.  /* above types are assumed defined in os2def.h */
  1366.  
  1367. #elif PLATFORM == ON_WIN32
  1368.  #define CTRYCODE 0
  1369.  #define CODEPAGE 0     /* may be ANSI or OEM code page value, depending on SORT_SET flag */
  1370.  #define RELOCK_AVAIL 0 /* relock not supported */
  1371.  
  1372.  /* above types are assume defined in windef.h and winnt.h */
  1373.  
  1374. #else
  1375.  #error No PLATFORM specified
  1376.  #error ---------------------
  1377.  
  1378. #endif
  1379.  
  1380. #ifndef __BLT_DYNA    // define this if using run-time loading of BULLET*.DLL
  1381.                       // via LoadLibrary(Win32) or DosLoadModule(OS/2)
  1382.  #ifdef __cplusplus
  1383.   extern "C" LONG APIENTRY BULLET(PVOID datapack);
  1384.  #else
  1385.   extern LONG APIENTRY BULLET(PVOID datapack);
  1386.  #endif
  1387.  
  1388. #else
  1389.  
  1390.   LONG (* APIENTRY BULLET)(PVOID datapack);
  1391.  
  1392. #endif
  1393.  
  1394.  
  1395.  
  1396. /* The following on mutex-semaphore protection does not apply to Bullet/X */
  1397. /* unless the semaphore routines (in ccdosfn.c) are coded to do something */
  1398.  
  1399. /* All Bullet routines are mutex-semaphore protected except the following:
  1400.  *
  1401.  * MEMORY_XB            STAT_HANDLE_XB          GET_ERROR_CLASS_XB
  1402.  * QUERY_SYSVARS_XB     QUERY_VECTORS_XB        CHECK_REMOTE_XB
  1403.  * STAT_DATA_XB         STAT_INDEX_XB
  1404.  *
  1405.  * This means that any thread can call the above routines at any time.  All
  1406.  * other calls in the current process block until the previous thread exits
  1407.  * BULLET.  The default mutex wait is 0 milliseconds, and can be set via
  1408.  * SET_SYSVARS_XB using the MUTEX_SEM_TIMEOUT index.  In the case of
  1409.  * STAT_DATA_XB and STAT_INDEX_XB, these should be used only when there
  1410.  * is no chance that another thread may close that file handle while the
  1411.  * routine is working.
  1412.  *
  1413.  */
  1414.  
  1415.  
  1416.  
  1417. /* ************************************************************************
  1418.  *
  1419.  * xxx.func call numbers
  1420.  *
  1421.  * ************************************************************************/
  1422.  
  1423. #define GEN_ERR_XB              0
  1424. #define INIT_XB                 1  /* system */
  1425. #define EXIT_XB                 2
  1426. #define MEMORY_XB               4
  1427. #define BACKUP_FILE_XB          6
  1428. #define STAT_HANDLE_XB          7
  1429. #define GET_ERROR_CLASS_XB      8
  1430.  
  1431. #define QUERY_SYSVARS_XB        10 /* advanced system */
  1432. #define SET_SYSVARS_XB          11
  1433. #define SET_DVMON_XB            12 /* reserved */
  1434. #define QUERY_VECTORS_XB        13
  1435. #define SET_VECTORS_XB          14
  1436.  
  1437. #define CREATE_DATA_XB          20 /* data control mid-level */
  1438. #define OPEN_DATA_XB            21
  1439. #define CLOSE_DATA_XB           22
  1440. #define STAT_DATA_XB            23
  1441. #define READ_DATA_HEADER_XB     24
  1442. #define FLUSH_DATA_HEADER_XB    25
  1443. #define COPY_DATA_HEADER_XB     26
  1444. #define ZAP_DATA_HEADER_XB      27
  1445.  
  1446. #define CREATE_INDEX_XB         30 /* key control mid-level */
  1447. #define OPEN_INDEX_XB           31
  1448. #define CLOSE_INDEX_XB          32
  1449. #define STAT_INDEX_XB           33
  1450. #define READ_INDEX_HEADER_XB    34
  1451. #define FLUSH_INDEX_HEADER_XB   35
  1452. #define COPY_INDEX_HEADER_XB    36
  1453. #define ZAP_INDEX_HEADER_XB     37
  1454.  
  1455. #define GET_DESCRIPTOR_XB       40 /* data access mid-level */
  1456. #define GET_RECORD_XB           41
  1457. #define ADD_RECORD_XB           42
  1458. #define UPDATE_RECORD_XB        43
  1459. #define DELETE_RECORD_XB        44
  1460. #define UNDELETE_RECORD_XB      45
  1461. #define DEBUMP_RECORD_XB        46
  1462. #define PACK_RECORDS_XB         47
  1463.  
  1464. #define GET_MEMO_SIZE_XB        50 /* memo access mid-level */
  1465. #define GET_MEMO_XB             51
  1466. #define ADD_MEMO_XB             52
  1467. #define UPDATE_MEMO_XB          53
  1468. #define DELETE_MEMO_XB          54
  1469. #define MEMO_BYPASS_XB          59 /* see below for bypass ordinals */
  1470.  
  1471. #define BYPASS_CREATE_MEMO       1 /* The bypass routines are automatically */
  1472. #define BYPASS_OPEN_MEMO         2 /* performed by BULLET but can be done */
  1473. #define BYPASS_CLOSE_MEMO        3 /* manually, if needed - these numbers are */
  1474. #define BYPASS_READ_MEMO_HEADER  4 /* put in MDP.memoBypass, with MDP.func */
  1475. #define BYPASS_FLUSH_MEMO_HEADER 5 /* set to MEMO_BYPASS_XB */
  1476.  
  1477. #define FIRST_KEY_XB            60 /* key access mid-level */
  1478. #define EQUAL_KEY_XB            61
  1479. #define NEXT_KEY_XB             62
  1480. #define PREV_KEY_XB             63
  1481. #define LAST_KEY_XB             64
  1482. #define STORE_KEY_XB            65
  1483. #define DELETE_KEY_XB           66
  1484. #define BUILD_KEY_XB            67
  1485. #define GET_CURRENT_KEY_XB      68
  1486. #define GET_KEY_FOR_RECORD_XB   69
  1487.  
  1488. #define GET_FIRST_XB            70 /* key and data access high-level */
  1489. #define GET_EQUAL_XB            71
  1490. #define GET_NEXT_XB             72
  1491. #define GET_PREV_XB             73
  1492. #define GET_LAST_XB             74
  1493. #define INSERT_XB               75
  1494. #define UPDATE_XB               76
  1495. #define REINDEX_XB              77
  1496.  
  1497. #define LOCK_XB                 80 /* network control */
  1498. #define UNLOCK_XB               81
  1499. #define LOCK_INDEX_XB           82
  1500. #define UNLOCK_INDEX_XB         83
  1501. #define LOCK_DATA_XB            84
  1502. #define UNLOCK_DATA_XB          85
  1503. #define CHECK_REMOTE_XB         86
  1504. #define RELOCK_XB               87
  1505. #define RELOCK_INDEX_XB         88
  1506. #define RELOCK_DATA_XB          89
  1507.  
  1508. #define DELETE_FILE_DOS         90 /* DOS file I/O low-level */
  1509. #define RENAME_FILE_DOS         91
  1510. #define CREATE_FILE_DOS         92
  1511. #define OPEN_FILE_DOS           93
  1512. #define SEEK_FILE_DOS           94
  1513. #define READ_FILE_DOS           95
  1514. #define WRITE_FILE_DOS          96
  1515. #define CLOSE_FILE_DOS          97
  1516. #define ACCESS_FILE_DOS         98
  1517. #define EXPAND_FILE_DOS         99
  1518. #define MAKE_DIR_DOS            100
  1519. #define COMMIT_FILE_DOS         101
  1520.  
  1521. /* ************************************************************************
  1522.  *
  1523.  * operating system file I/O equates
  1524.  *
  1525.  * ************************************************************************/
  1526.  
  1527. #define READONLY        0x00000000 /* std file access mode */
  1528. #define WRITEONLY       0x00000001 /* no underscore used for std equates */
  1529. #define READWRITE       0x00000002
  1530.  
  1531. #define DENYREADWRITE   0x00000010 /* std file share mode, cannot be 0 */
  1532. #define DENYWRITE       0x00000020
  1533. #define DENYREAD        0x00000030
  1534. #define DENYNONE        0x00000040
  1535. #define NOINHERIT       0x00000080
  1536.  
  1537. #define NO_LOCALITY     0x00000000 /* optional cache modes */
  1538. #define SEQ_LOCALITY    0x00010000
  1539. #define RND_LOCALITY    0x00020000
  1540. #define MIX_LOCALITY    0x00030000
  1541. #define SKIP_CACHE      0x00100000 /* not inherited by child process */
  1542. #define WRITE_THROUGH   0x00400000 /* not inherited by child process */
  1543.  
  1544.  
  1545. #define LOCK_SHARED      1         /* a read-only lock, OS/2 and NT only */
  1546. #define LOCK_EXCLUSIVE   0         /* default */
  1547.  
  1548. /* ************************************************************************
  1549.  *
  1550.  * .sortFunction IDs, Query/SetSysVars|Vectors item IDs
  1551.  *
  1552.  * ************************************************************************/
  1553.  
  1554. // SORT_SET flag:  USE_*_SET defaults to OEM character set, and is used (either
  1555. // OEM or ANSI) whenever the .sortFunction used is NLS or a custom sort-compare.
  1556.  
  1557. #define USE_OEM_CHARSET  (0 << 17) /* for DOSX32, OS/2, and Windows */
  1558. #define USE_ANSI_CHARSET (1 << 17) /* for Windows (.sortFunction flag) */
  1559.  
  1560. #define DUPS_ALLOWED (1 << 16) /* allow duplicate keys (.sortFunction flag) */
  1561.  
  1562. /* All Bullet system vars set to default values at INIT_XB */
  1563. /* Sorts 1-19 also used as CIP.sortFunction (can be OR'ed with DUPS_ALLOWED) */
  1564. /* Intrinsic sorts (1-6) are read-only (R-O) */
  1565.  
  1566. #define ASCII_SORT 1    /* sort by: ASCII value (R-O) */
  1567. #define NLS_SORT   2    /* NLS (R-O) */
  1568. #define S16_SORT   3    /* 16-bit signed integer (R-O) */
  1569. #define U16_SORT   4    /* 16-bit unsigned integer (R-O) */
  1570. #define S32_SORT   5    /* 32-bit signed integer (R-O) */
  1571. #define U32_SORT   6    /* 32-bit unsigned integer (R-O) */
  1572.  
  1573. /* sorts 7 to 9 are reserved */
  1574. /* Custom sort-compare functions are from 10 to 19 */
  1575.  
  1576. #define BUILD_KEY_FUNC  20      /* key build function ptr */
  1577. #define PARSER_FUNC     21      /* key expression parser function ptr */
  1578.  
  1579. #define MUTEX_SEM_HANDLE     29 /* handle of Bullet's mutex semaphore (R-O) */
  1580. #define LOCK_TIMEOUT         30 /* lock-wait timeout (default=0, no wait)*/
  1581. #define MUTEX_SEM_TIMEOUT    31 /* mutex semaphore-wait timeout (def=0,none) */
  1582. #define PACK_BUFFER_SIZE     32 /* pack buffer size (def=0, min autosize) */
  1583. #define REINDEX_BUFFER_SIZE  33 /* reindex buffer size (def=0, min autosize) */
  1584. #define REINDEX_PACK_PCT     34 /* reindex node pack % (default=100, max) */
  1585. #define TMP_PATH_PTR         35 /* temporary file path ptr (default=NULL) */
  1586. #define REINDEX_SKIP_TAG     36 /* index skip tag select (default=0, none) */
  1587. #define COMMIT_AT_EACH       37 /* commit each insert/update in pack (def=0) */
  1588. #define MEMO_BLOCKSIZE       38 /* memo block size (default=512 bytes) */
  1589. #define MEMO_EXTENSION       39 /* memo filename extension (default='DBT\0') */
  1590. #define MAX_DATAFILE_SIZE    40 /* max data size (default=0x7FEFFFFF=2095MB) */
  1591. #define MAX_INDEXFILE_SIZE   41 /* max index size (default=0x7FEFFFFF=2095MB)*/
  1592. #define ATOMIC_MODE          42 /* bit0=1 atomic next/prev key access (def=0)*/
  1593. #define CALLBACK_PTR         43 /* callback at reindex/pack (def=0, none) */
  1594.  
  1595. /* ************************************************************************
  1596.  *
  1597.  * Query/SetVectors vector IDs
  1598.  *
  1599.  * ************************************************************************/
  1600.  
  1601. #define VECTOR_CLOSE_FILE           2
  1602. #define VECTOR_CREATE_DIR           3
  1603. #define VECTOR_CREATE_FILE          4
  1604. #define VECTOR_CREATE_UNIQUE_FILE   5
  1605. #define VECTOR_DELETE_FILE          6
  1606. #define VECTOR_LENGTH_FILE          7
  1607. #define VECTOR_MOVE_FILE            8
  1608. #define VECTOR_OPEN_FILE            9
  1609. #define VECTOR_READ_FILE           10
  1610. #define VECTOR_SEEK_FILE           11
  1611. #define VECTOR_UPDATE_DIR_ENTRY    12
  1612. #define VECTOR_WRITE_FILE          13
  1613. #define VECTOR_LOCK_FILE           14
  1614. #define VECTOR_IS_DRIVE_REMOTE     15
  1615. #define VECTOR_IS_FILE_REMOTE      16
  1616. #define VECTOR_EXITLIST            17
  1617. #define VECTOR_REMOVE_EXITLIST     18
  1618. #define VECTOR_FREE                19
  1619. #define VECTOR_GET_SORT_TABLE      20
  1620. #define VECTOR_GET_COUNTRY_INFO    21
  1621. #define VECTOR_GET_ERROR_CLASS     22
  1622. #define VECTOR_GET_MEMORY          23
  1623. #define VECTOR_GET_TMP_DIR         24
  1624. #define VECTOR_GET_VERSION         25
  1625. #define VECTOR_MALLOC              26
  1626. #define VECTOR_SET_HANDLE_COUNT    27
  1627. #define VECTOR_GET_TIME_INFO       28
  1628. #define VECTOR_UPPERCASE           29
  1629. #define VECTOR_CLOSE_MUTEX_SEM     30
  1630. #define VECTOR_CREATE_MUTEX_SEM    31
  1631. #define VECTOR_RELEASE_MUTEX_SEM   32
  1632. #define VECTOR_REQUEST_MUTEX_SEM   33
  1633.  
  1634.  
  1635. /* ************************************************************************
  1636.  *
  1637.  * Parameter pack structures, typedefs
  1638.  *
  1639.  * ************************************************************************/
  1640.  
  1641. /* AP, CP, CDP, etc., are suggested variable names */
  1642.  
  1643. typedef struct _ACCESSPACK {
  1644. ULONG func;
  1645. ULONG stat;
  1646. ULONG handle;         /* I, handle of Bullet file to access */
  1647. LONG  recNo;          /* IO, record number */
  1648. PVOID recPtr;         /* I, programmer's record buffer */
  1649. PVOID keyPtr;         /* I, programmer's key buffer */
  1650. PVOID nextPtr;        /* I, NULL if not xaction, else next AP in list */
  1651. } ACCESSPACK; /* AP */
  1652. typedef ACCESSPACK *PACCESSPACK;
  1653.  
  1654. /* CBP is the structure received by the callback procedure */
  1655. /* structure members are filled in by Bullet */
  1656.  
  1657. typedef struct _CALLBACKPACK {
  1658. ULONG sizeIs;         /* structure size (current 16 bytes) */
  1659. ULONG callMode;       /* 0=from reindex; 1=from DBF pack */
  1660. ULONG handle;         /* file handle */
  1661. ULONG data1;          /* for callMode=0/1: progress percent (1-99,0) */
  1662. } CALLBACKPACK; /* CBP */
  1663. typedef CALLBACKPACK *PCALLBACKPACK;
  1664.  
  1665. typedef struct _COPYPACK {
  1666. ULONG func;
  1667. ULONG stat;
  1668. ULONG handle;         /* I, handle of Bullet file to copy */
  1669. PSZ   filenamePtr;    /* I, filename to use (drv+path must exist if used) */
  1670. } COPYPACK; /* CP */
  1671. typedef COPYPACK *PCOPYPACK;
  1672.  
  1673. typedef struct _CREATEDATAPACK {
  1674. ULONG func;
  1675. ULONG stat;
  1676. PSZ   filenamePtr;    /* I, filename to use */
  1677. ULONG noFields;       /* I, 1 to 254 */
  1678. PVOID fieldListPtr;   /* I, descriptor list, 1 per field */
  1679. ULONG fileID;         /* I, 0x03 for standard DBF, 0x8B if memo file also */
  1680. } CREATEDATAPACK; /* CDP */
  1681. typedef CREATEDATAPACK *PCREATEDATAPACK;
  1682.  
  1683. typedef struct _CREATEINDEXPACK {
  1684. ULONG func;
  1685. ULONG stat;
  1686. PSZ   filenamePtr;    /* I, filename to use */
  1687. PSZ   keyExpPtr;      /* I, e.g., "SUBSTR(LNAME,1,4)+SSN" */
  1688. LONG  xbLink;         /* I, opened data file handle this indexes */
  1689. ULONG sortFunction;   /* I, 1-9 system, 10-19 custom */
  1690. ULONG codePage;       /* I, 0=use process default */
  1691. ULONG countryCode;    /* I, 0=use process default */
  1692. PVOID collatePtr;     /* I, NULL=use cc/cp else use passed table for sort */
  1693. ULONG nodeSize;       /* I, 512, 1024, or 2048 */
  1694. } CREATEINDEXPACK; /* CIP */
  1695. typedef CREATEINDEXPACK *PCREATEINDEXPACK;
  1696.  
  1697. typedef struct _FIELDDESCTYPE {
  1698. BYTE  fieldName[11];  /* IO, upper A-Z and _; 1-10 chars, 0-filled, 0-term */
  1699. BYTE  fieldType;      /* IO, C,D,L,N, or M */
  1700. LONG  fieldDA;        /* x, offset within record (run-time storage option) */
  1701. BYTE  fieldLen;       /* IO, C=1-255,D=8,L=1,N=1-19,M=10 */
  1702. BYTE  fieldDC;        /* IO, fieldType=N then 0-15 else 0 */
  1703. USHORT altFieldLength;/* IO, 0 */
  1704. BYTE  filler[12];     /* I, 0 */
  1705. } FIELDDESCTYPE; /* nested in _DESCRIPTORPACK */
  1706. typedef FIELDDESCTYPE *PFIELDDESCTYPE;
  1707.  
  1708. typedef struct _DESCRIPTORPACK {
  1709. ULONG func;
  1710. ULONG stat;
  1711. ULONG handle;         /* I, handle of DBF file */
  1712. ULONG fieldNumber;    /* IO, first field is 1 */
  1713. ULONG fieldOffset;    /* O, offset of field within record (tag=offset 0) */
  1714. FIELDDESCTYPE FD;     /* IO FD.fieldName only, O for rest of FD */
  1715. } DESCRIPTORPACK; /* DP */
  1716. typedef DESCRIPTORPACK *PDESCRIPTORPACK;
  1717.  
  1718. typedef struct _DOSFILEPACK {
  1719. ULONG func;
  1720. ULONG stat;
  1721. PSZ   filenamePtr;    /* I, filename to use */
  1722. ULONG handle;         /* IO, handle of open file */
  1723. ULONG asMode;         /* I, access-sharing mode */
  1724. ULONG bytes;          /* IO, bytes to read, write, length of */
  1725. LONG  seekTo;         /* IO, seek to offset, current offset */
  1726. ULONG method;         /* I, seek method (0=start of file, 1=current, 2=end) */
  1727. PVOID bufferPtr;      /* I, buffer to read into or write from */
  1728. ULONG attr;           /* I, attribute to create file with */
  1729. PSZ   newNamePtr;     /* I, name to use on rename */
  1730. } DOSFILEPACK; /* DFP */
  1731. typedef DOSFILEPACK *PDOSFILEPACK;
  1732.  
  1733. typedef struct _EXITPACK {
  1734. ULONG func;
  1735. ULONG stat;
  1736. } EXITPACK; /* EP */
  1737. typedef EXITPACK *PEXITPACK;
  1738.  
  1739. typedef struct _HANDLEPACK {
  1740. ULONG func;
  1741. ULONG stat;
  1742. ULONG handle;         /* I, handle of Bullet file */
  1743. } HANDLEPACK; /* HP */
  1744. typedef HANDLEPACK *PHANDLEPACK;
  1745.  
  1746. typedef struct _INITPACK {
  1747. ULONG func;
  1748. ULONG stat;
  1749. ULONG JFTsize;        /* I, max opened files (20-1024+) */
  1750. ULONG versionDOS;     /* O, e.g., 230 for 2.30 */
  1751. ULONG versionBullet;  /* O, e.g., 2019 for 2.019 */
  1752. ULONG versionOS;      /* O, e.g., 4=OS/2 32-bit */
  1753. PVOID exitPtr;        /* O, function pointer to EXIT_XB routine */
  1754. } INITPACK; /* IP */
  1755. typedef INITPACK *PINITPACK;
  1756.  
  1757. typedef struct _LOCKPACK {
  1758. ULONG func;
  1759. ULONG stat;
  1760. ULONG handle;         /* I, handle of Bullet file to lock */
  1761. ULONG xlMode;         /* I, index lock mode (0=exclusive, 1=shared) */
  1762. ULONG dlMode;         /* I, data lock mode (0=exclusive, 1=shared) */
  1763. LONG  recStart;       /* I, if data, first record # to lock, or 0 for all */
  1764. ULONG recCount;       /* I, if data and recStart!=0, # records to lock */
  1765. PVOID nextPtr;        /* I, NULL if not xaction, else next LP in list */
  1766. } LOCKPACK; /* LP */
  1767. typedef LOCKPACK *PLOCKPACK;
  1768.  
  1769. typedef struct _MEMODATAPACK {
  1770. ULONG func;
  1771. ULONG stat;
  1772. ULONG dbfHandle;      /* I, handle of DBF file to which this memo file belongs */
  1773. ULONG memoBypass;     /* I, memo bypass function to do, if any */
  1774. PVOID memoPtr;        /* I, ptr to memo record buffer */
  1775. ULONG memoNo;         /* IO, memo record number (aka block number) */
  1776. ULONG memoOffset;     /* I, position within record to start read/update */
  1777. ULONG memoBytes;      /* IO, number of bytes to read/update */
  1778. } MEMODATAPACK; /* MDP */
  1779. typedef MEMODATAPACK *PMEMODATAPACK;
  1780.  
  1781. typedef struct _MEMORYPACK {
  1782. ULONG func;
  1783. ULONG stat;
  1784. ULONG memory;         /* O, not used in OS/2 */
  1785. } MEMORYPACK; /* MP */
  1786. typedef MEMORYPACK *PMEMORYPACK;
  1787.  
  1788. typedef struct _OPENPACK {
  1789. ULONG func;
  1790. ULONG stat;
  1791. ULONG handle;         /* O, handle of file opened */
  1792. PSZ   filenamePtr;    /* I, Bullet file to open */
  1793. ULONG asMode;         /* I, access-sharing-cache mode */
  1794. LONG  xbLink;         /* I, if index open, xbLink=handle of its opened DBF */
  1795. } OPENPACK; /* OP */
  1796. typedef OPENPACK *POPENPACK;
  1797.  
  1798. typedef struct _QUERYSETPACK {
  1799. ULONG func;
  1800. ULONG stat;
  1801. ULONG item;           /* I, Bullet sysvar item to get/set */
  1802. ULONG itemValue;      /* IO, current/new value */
  1803. } QUERYSETPACK; /* QSP */
  1804. typedef QUERYSETPACK *PQUERYSETPACK;
  1805.  
  1806. typedef struct _REMOTEPACK {
  1807. ULONG func;
  1808. ULONG stat;
  1809. ULONG handle;         /* I, handle of file, or if 0, use RP.drive */
  1810. ULONG drive;          /* I, drive (1=A,2=B,3=C,...0=current) to check */
  1811. ULONG isRemote;       /* O, =1 of handle/drive is remote, =0 if local */
  1812. ULONG flags;          /* O, 0 */
  1813. ULONG isShare;        /* O, 1 */
  1814. } REMOTEPACK; /* RP */
  1815. typedef REMOTEPACK *PREMOTEPACK;
  1816.  
  1817. typedef struct _STATDATAPACK {
  1818. ULONG func;
  1819. ULONG stat;
  1820. ULONG handle;         /* I, handle to check */
  1821. ULONG fileType;       /* O, bit0=1 data file */
  1822. ULONG flags;          /* O, bit0=1 dirty, bit1=1 full-lock, bit2=1 shared */
  1823. ULONG progress;       /* O, 0,1-99% pack progress */
  1824. PVOID morePtr;        /* O, 0 */
  1825. ULONG fields;         /* O, fields per record */
  1826. ULONG asMode;         /* O, access-sharing-cache mode */
  1827. PSZ   filenamePtr;    /* O, filename used in open */
  1828. ULONG fileID;         /* O, first byte of DBF file */
  1829. ULONG lastUpdate;     /* O, high word=year,low byte=day, high byte=month */
  1830. ULONG records;        /* O, data records (including "deleted") */
  1831. ULONG recordLength;   /* O, record length */
  1832. ULONG xactionFlag;    /* O, 0 */
  1833. ULONG encryptFlag;    /* O, 0 */
  1834. PVOID herePtr;        /* O, this file's control address */
  1835. ULONG memoHandle;     /* O, handle of open memo file (0 if none) */
  1836. ULONG memoBlockSize;  /* O, memo file block size */
  1837. ULONG memoFlags;      /* O, bit0=1 dirty */
  1838. ULONG memoLastRecord; /* O, last accessed memo record (0 if none) */
  1839. ULONG memoLastSize;   /* O, size of last accessed memo record (in bytes, +8) */
  1840. ULONG lockCount;      /* O, number of full-locks in force */
  1841. } STATDATAPACK; /* SDP */
  1842. typedef STATDATAPACK *PSTATDATAPACK;
  1843.  
  1844. typedef struct _STATHANDLEPACK {
  1845. ULONG func;
  1846. ULONG stat;
  1847. ULONG handle;         /* I, handle to check */
  1848. LONG  ID;             /* O, bit0=1 data file, bit0=1 index file */
  1849. } STATHANDLEPACK; /* SHP */
  1850. typedef STATHANDLEPACK *PSTATHANDLEPACK;
  1851.  
  1852. typedef struct _STATINDEXPACK {
  1853. ULONG func;
  1854. ULONG stat;
  1855. ULONG handle;         /* I, handle to check */
  1856. ULONG fileType;       /* O, bit0=0 index file */
  1857. ULONG flags;          /* O, bit0=1 dirty, bit1=1 full-lock, bit2=1 shared */
  1858. ULONG progress;       /* O, 0,1-99% reindex progress */
  1859. PVOID morePtr;        /* O, 0 */
  1860. ULONG xbLink;         /* O, XB file link handle */
  1861. ULONG asMode;         /* O, access-sharing-cache mode */
  1862. PSZ   filenamePtr;    /* O, pointer to filename used in open */
  1863. ULONG fileID;         /* O, "31ch" */
  1864. PSZ   keyExpPtr;      /* O, pointer to key expression */
  1865. ULONG keys;           /* O, keys in file */
  1866. ULONG keyLength;      /* O, key length */
  1867. ULONG keyRecNo;       /* O, record number of current key */
  1868. PVOID keyPtr;         /* O, ptr to current key value (valid to keyLength) */
  1869. PVOID herePtr;        /* O, this file's control address */
  1870. ULONG codePage;       /* O, code page at create time */
  1871. ULONG countryCode;    /* O, country code at create time */
  1872. PVOID CTptr;          /* O, collate table ptr, NULL=no collate table present */
  1873. ULONG nodeSize;       /* O, node size */
  1874. ULONG sortFunction;   /* O, sort function ID */
  1875. ULONG lockCount;      /* O, number of full-locks in force */
  1876. } STATINDEXPACK; /* SIP */
  1877. typedef STATINDEXPACK *PSTATINDEXPACK;
  1878.  
  1879. typedef struct _XERRORPACK {
  1880. ULONG func;
  1881. ULONG stat;           /* I, error to check */
  1882. ULONG errClass;       /* O, class of error */
  1883. ULONG action;         /* O, action recommended for error */
  1884. ULONG location;       /* O, location of error */
  1885. } XERRORPACK; /* XEP */
  1886. typedef XERRORPACK *PXERRORPACK;
  1887.  
  1888.  
  1889. /* ************************************************************************
  1890.  *
  1891.  * Error codes
  1892.  *
  1893.  * ************************************************************************/
  1894.  
  1895. #define EXB_NOT_ENOUGH_MEMORY   8  /* cannot get memory requested */
  1896. #define ERR_INVALID_DRIVE       15 /* not a valid drive letter */
  1897. #define EXB_UNEXPECTED_EOF      38 /* unexpect EOF (bytes read != bytes asked) */
  1898. #define EXB_DISK_FULL           39 /* disk full on WriteFile */
  1899. #define EXB_FILE_EXISTS         80 /* cannot create file since it already exists */
  1900. #define EXB_SEM_OWNER_DIED      105 /* in place of Win32 error 80h (mutex) */
  1901. #define EXB_TIMEOUT             640 /* in place of Win32 error 102h (mutex) */
  1902.  
  1903. /* Other operating system errors are as returned by OS itself */
  1904.  
  1905. /* System/general error codes */
  1906.  
  1907. #define EXB_OR_WITH_FAULTS      8192 /* 8192+1 to +4, close-type errors */
  1908.  
  1909.                                      /* ERR_216501/6 are for Bullet/x only */
  1910. #define EXB_216501              8251 /* INT21/6501h not supported by DOS extender */
  1911.                                      /* (do not use default cc/cp) */
  1912. #define EXB_216506              8256 /* INT21/6506h not supported by DOS extender */
  1913.                                      /* (provide a custom collate table) */
  1914.  
  1915. #define EXB_ILLEGAL_CMD         8300 /* function not allowed */
  1916. #define EXB_OLD_DOS             8301 /* OS version < MIN_DOS_NEEDED */
  1917. #define EXB_NOT_INITIALIZED     8302 /* init not active, must do INIT_XB */
  1918. #define EXB_ALREADY_INITIALIZED 8303 /* init already active, must do EXIT_XB */
  1919. #define EXB_TOO_MANY_HANDLES    8304 /* more than 1024 opens requested */
  1920. #define EXB_SYSTEM_HANDLE       8305 /* Bullet won't use or close handles 0-2 */
  1921. #define EXB_FILE_NOT_OPEN       8306 /* file not open (not Bullet handle, including xbLink) */
  1922. #define EXB_FILE_IS_DIRTY       8307 /* tried to reload header but current still dirty */
  1923. #define EXB_BAD_FILETYPE        8308 /* tried key op on non-key file, data op on non... */
  1924. #define EXB_TOO_MANY_PACKS      8309 /* too many INSERT,UPDATE,REINDEX,LOCK_XB packs */
  1925. #define EXB_NULL_RECPTR         8310 /* null record pointer passed to Bullet */
  1926. #define EXB_NULL_KEYPTR         8311 /* null key pointer passed to Bullet */
  1927. #define EXB_NULL_MEMOPTR        8312 /* null memo pointer passed to Bullet */
  1928. #define EXB_EXPIRED             8313 /* evaluation time period has expired */
  1929. #define EXB_BAD_INDEX           8314 /* Query/SetSysVars index beyond last one */
  1930. #define EXB_RO_INDEX            8315 /* SetSysVar index item is read-only */
  1931. #define EXB_FILE_BOUNDS         8316 /* file size > 4GB, or > system var sets */
  1932.  
  1933. /* Multi-access error codes */
  1934.  
  1935. #define EXB_BAD_LOCK_MODE       8401 /* lock mode (LP) not valid */
  1936. #define EXB_NOTHING_TO_RELOCK   8402 /* cannot relock without existing full-lock */
  1937. #define EXB_SHARED_LOCK_ON      8403 /* write access needed but lock is shared (flush on backup) */
  1938.  
  1939. /* Index error codes */
  1940.  
  1941. #define EXB_KEY_NOT_FOUND       8501 /* exact match of key not found */
  1942. #define EXB_KEY_EXISTS          8502 /* key exists already and dups not allowed */
  1943. #define EXB_END_OF_FILE         8503 /* already at last index order */
  1944. #define EXB_TOP_OF_FILE         8504 /* already at first index order */
  1945. #define EXB_EMPTY_FILE          8505 /* nothing to do since no keys */
  1946. #define EXB_CANNOT_GET_LAST     8506 /* cannot locate last key */
  1947. #define EXB_BAD_INDEX_STACK     8507 /* index file is corrupt */
  1948. #define EXB_BAD_INDEX_READ0     8508 /* index file is corrupt */
  1949. #define EXB_BAD_INDEX_WRITE0    8509 /* index file is corrupt */
  1950.  
  1951. #define EXB_OLD_INDEX           8521 /* old index, run through ReindexOld to update */
  1952. #define EXB_UNKNOWN_INDEX       8522 /* not a Bullet index file */
  1953. #define EXB_KEY_TOO_LONG        8523 /* keylength > 62 (or 64 if unique), or is 0 */
  1954.  
  1955. #define EXB_PARSER_NULL         8531 /* parser function pointer is NULL */
  1956. #define EXB_BUILDER_NULL        8532 /* build key function pointer is NULL */
  1957. #define EXB_BAD_SORT_FUNC       8533 /* CIP.sortFunction not valid */
  1958. #define EXB_BAD_NODE_SIZE       8534 /* CIP.nodeSize is not 512, 1024, or 2048 */
  1959. #define EXB_FILENAME_TOO_LONG   8535 /* CIP.filenamePtr->pathname > max path length */
  1960.  
  1961. #define EXB_KEYX_NULL           8541 /* expression is effectively NULL */
  1962. #define EXB_KEYX_TOO_LONG       8542 /* CIP.keyExpPtr->expression > 159 */
  1963. #define EXB_KEYX_SYM_TOO_LONG   8543 /* fieldname/funcname in expression > 10 chars */
  1964. #define EXB_KEYX_SYM_UNKNOWN    8544 /* fieldname/funcname in expression unknown */
  1965. #define EXB_KEYX_TOO_MANY_SYMS  8545 /* too many symbols/fields used in expression */
  1966. #define EXB_KEYX_BAD_SUBSTR     8546 /* invalid SUBSTR() operand in expression */
  1967. #define EXB_KEYX_BAD_SUBSTR_SZ  8547 /* SUBSTR() exceeds field's size */
  1968. #define EXB_KEYX_BAD_FORM       8548 /* didn't match expected symbol in expression */
  1969.  
  1970. #define EXB_NO_READS_FOR_RUN    8551 /* unlikely, use different reindex buffer size */
  1971. #define EXB_TOO_MANY_RUNS       8552 /* unlikely, too many runs (64K or more runs) */
  1972. #define EXB_TOO_MANY_RUNS_FOR_BUFFER 8553 /* unlikely, too many runs for run buffer */
  1973. #define EXB_TOO_MANY_DUPLICATES 8554 /* more than 64K "identical" keys */
  1974.  
  1975. #define EXB_INSERT_RECNO_BAD    8561 /* AP.recNo cannot be > 0 if inserting */
  1976. #define EXB_PREV_APPEND_EMPTY   8562 /* no prev append for insert yet AP.recNo==80000000h */
  1977. #define EXB_PREV_APPEND_MISMATCH 8563 /* prev append's xbLink does not match this */
  1978. #define EXB_INSERT_KBO_FAILED   8564 /* could not back out key at INSERT_XB */
  1979. #define EXB_INSERT_DBO_FAILED   8565 /* could not back out data records at INSERT_XB */
  1980.  
  1981. #define WRN_NOTHING_TO_UPDATE   8571 /* all AP.recNo=0 at UPDATE_XB */
  1982. #define EXB_INTERNAL_UPDATE     8572 /* internal error UPDATE_XB, not in hdl/rec# list */
  1983.  
  1984. #define EXB_FAILED_DATA_RESTORE 8573 /* could not restore original data record (*) */
  1985. #define EXB_FAILED_KEY_DELETE   8574 /* could not remove new key (*) */
  1986. #define EXB_FAILED_KEY_RESTORE  8575 /* could not restore original key(*) */
  1987. /* *original error, which forced a back-out, has been replaced by this error */
  1988. /* this error is always returned in the first AP.stat (-1 on data, 1 on index) */
  1989.  
  1990. /* Data error codes */
  1991.  
  1992. #define EXB_EXT_XBLINK          8601 /* xbLink handle is not internal DBF (is -1) */
  1993. #define EXB_FIELDNAME_TOO_LONG  8602 /* fieldname is > 10 characters */
  1994. #define EXB_RECORD_TOO_LONG     8603 /* record length is > 64K */
  1995. #define EXB_FIELD_NOT_FOUND     8604 /* fieldname not found in descriptor info */
  1996. #define EXB_BAD_FIELD_COUNT     8605 /* fields <= 0 or >= MAX_FIELDS (Init,Open) */
  1997.                                      /* and also GetDescriptor by field number */
  1998. #define EXB_BAD_HEADER          8606 /* bad header (reclen=0, etc., from LocateTo, Flush) */
  1999. #define EXB_BUFFER_TOO_SMALL    8607 /* buffer too small (pack buffer < reclen in pack) */
  2000. #define EXB_INTERNAL_PACK       8608 /* internal error in PackRecords */
  2001. #define EXB_BAD_RECNO           8609 /* record number=0 or > records in data file hdr */
  2002.                                      /* or Pack on empty data file */
  2003. #define WRN_RECORD_TAGGED       8610 /* record's tag field matches skip tag */
  2004.  
  2005. /* Memo error codes */
  2006.  
  2007. #define WRN_CANNOT_OPEN_MEMO    8701 /* DBF says memo file but memo open fails */
  2008. #define EXB_MEMO_NOT_OPEN       8702 /* no open memo file for operation */
  2009. #define EXB_BAD_BLOCKSIZE       8703 /* memo blocksize must be at least 24 bytes */
  2010. #define EXB_MEMO_DELETED        8704 /* memo is deleted */
  2011. #define EXB_MEMO_PAST_END       8705 /* memo data requested is past end of record */
  2012. #define EXB_BAD_MEMONO          8706 /* memo number is not valid */
  2013. #define EXB_MEMO_IN_USE         8707 /* memo add encountered likely corrupt memo file */
  2014. #define EXB_BAD_AVAIL_LINK      8708 /* memo avail link cannot be valid (is 0) */
  2015. #define EXB_MEMO_ZERO_SIZE      8709 /* memo data has no size */
  2016. #define EXB_MEMO_IS_SMALLER     8710 /* memo attempt to shrink but already <= size */
  2017.  
  2018. #endif /* ifndef __BULLET_H */
  2019.  
  2020.  
  2021. ΓòÉΓòÉΓòÉ 9. Bullet Functions ΓòÉΓòÉΓòÉ
  2022.  
  2023. System level                    Advanced system-level 
  2024.  
  2025.  INIT_XB                        QUERY_SYSVARS_XB 
  2026.  EXIT_XB                        SET_SYSVARS_XB 
  2027.  MEMORY_XB                      SET_DVMON_XB 
  2028.  BACKUP_FILE_XB                 QUERY_VECTORS_XB 
  2029.  STAT_HANDLE_XB                 SET_VECTORS_XB 
  2030.  GET_ERROR_CLASS_XB 
  2031.  
  2032.  Data low-level                 Data mid-level                Memo mid-level 
  2033.  
  2034.  CREATE_DATA_XB                 GET_DESCRIPTOR_XB             GET_MEMO_SIZE_XB 
  2035.  OPEN_DATA_XB                   GET_RECORD_XB                 GET_MEMO_XB 
  2036.  CLOSE_DATA_XB                  ADD_RECORD_XB                 ADD_MEMO_XB 
  2037.  STAT_DATA_XB                   UPDATE_RECORD_XB              UPDATE_MEMO_XB 
  2038.  READ_DATA_HEADER_XB            DELETE_RECORD_XB              DELETE_MEMO_XB 
  2039.  FLUSH_DATA_HEADER_XB           UNDELETE_RECORD_XB            MEMO_BYPASS_XB 
  2040.  COPY_DATA_HEADER_XB            DEBUMP_RECORD_XB 
  2041.  ZAP_DATA_HEADER_XB             PACK_RECORDS_XB 
  2042.  
  2043.  Index low-level                Index mid-level               Index high-level 
  2044.  
  2045.  CREATE_INDEX_XB                FIRST_KEY_XB                  GET_FIRST_XB 
  2046.  OPEN_INDEX_XB                  EQUAL_KEY_XB                  GET_EQUAL_XB 
  2047.  CLOSE_INDEX                    NEXT_KEY_XB                   GET_NEXT_XB 
  2048.  STAT_INDEX_XB                  PREV_KEY_XB                   GET_PREV_XB 
  2049.  READ_INDEX_HEADER_XB           LAST_KEY_XB                   GET_LAST_XB 
  2050.  FLUSH_INDEX_HEADER_XB          STORE_KEY_XB                  INSERT_XB 
  2051.  COPY_INDEX_HEADER_XB           DELETE_KEY_XB                 UPDATE_XB 
  2052.  ZAP_INDEX_HEADER_XB            BUILD_KEY_XB                  REINDEX_XB 
  2053.                                 GET_CURRENT_KEY_XB 
  2054.                                 GET_KEY_FOR_RECORD_XB 
  2055.  
  2056.  Network level                  CP level 
  2057.  
  2058.  LOCK_XB                        DELETE_FILE_DOS 
  2059.  UNLOCK_XB                      RENAME_FILE_DOS 
  2060.  LOCK_INDEX_XB                  CREATE_FILE_DOS 
  2061.  UNLOCK_INDEX_XB                OPEN_FILE_DOS 
  2062.  LOCK_DATA_XB                   SEEK_FILE_DOS 
  2063.  UNLOCK_DATA_XB                 READ_FILE_DOS 
  2064.  CHECK_REMOTE_XB                WRITE_FILE_DOS 
  2065.  RELOCK_XB                      CLOSE_FILE_DOS 
  2066.  RELOCK_INDEX_XB                ACCESS_FILE_DOS 
  2067.  RELOCK_DATA_XB                 EXPAND_FILE_DOS 
  2068.                                 MAKE_DIR_DOS 
  2069.                                 COMMIT_FILE_DOS 
  2070.  
  2071.  
  2072. ΓòÉΓòÉΓòÉ 9.1. INIT_XB ΓòÉΓòÉΓòÉ
  2073.  
  2074. Pack: INITPACK                 Source Example 
  2075.  
  2076.      IN               OUT
  2077.    IP.func          IP.stat
  2078.    IP.JFTsize       IP.versionDOS
  2079.                     IP.versionBullet
  2080.                     IP.versionOS
  2081.                     IP.exitPtr
  2082.  
  2083.  This must be the first routine called.  If it has already been called the 
  2084.  system variables are restored to their defaults, and an error is returned. 
  2085.  Otherwise, the entire Bullet system is initialized, and EXIT_XB is registered 
  2086.  with the OS ExitList handler (DosExitList). 
  2087.  
  2088.  For more than the default open files (generally 20), set IP.JFTsize to the 
  2089.  total number of concurrently open files you need.  Depending on your version, 
  2090.  Bullet manages up to 1024 Bullet files per process (total data and index; memo 
  2091.  files are not counted against this total).  Setting this less than 20 does 
  2092.  nothing.  This number is for Bullet files, your files, pipes -- anything using 
  2093.  a handle.  If you need to account for handles that you are managing, you 
  2094.  should add those to IP.JFTsize.  For example, if you need 10 data files, each 
  2095.  with a memo file, and 2 index files per data file, that is 40 total Bullet 
  2096.  files.  If you need to use 15 other handles, for whatever use, add that number 
  2097.  to the 40 Bullet files, for a total setting of 55.  The OS also uses 3 handles 
  2098.  for itself, so, for all these, IP.JFTsize=58 would be the minimum.  You can 
  2099.  set it higher, but unused handles are wasted handles. In addition, if the 
  2100.  current process has fewer total handles available than the number you 
  2101.  specified in IP.JFTsize, Bullet sets the total available handles to IP.JFTsize 
  2102.  (as the absolute number of handles required).  If the current process already 
  2103.  has more total handles than IP.JFTsize, no action is taken. 
  2104.  
  2105.  On return (where no error occurred), the operating system version is in 
  2106.  IP.versionDOS (*100) and the Bullet version (*1000) in IP.versionBullet. 
  2107.  IP.versionOS return is based on the following table: 
  2108.  
  2109.       Bullet Platform   IP.versionOS
  2110.          MS-DOS 16-bit      0
  2111.           Win3x 16-bit      1
  2112.            DOSX 32-bit      3
  2113.            OS/2 32-bit      4
  2114.     WinNT/Win9x 32-bit      5
  2115.  
  2116.  IP.exitPtr returns with the function pointer to the EXIT_XB routine. This 
  2117.  function pointer is redundant unless specifically mentioned as being required 
  2118.  for your platform.  It is not needed in OS/2. 
  2119.  
  2120.  Note:  References under OUT using *AP.keyPtr or similar (note then *) are used 
  2121.  throughout this manual and indicate that Bullet updates the contents at 
  2122.  AP.keyPtr with data (i.e., Bullet filled the buffer). 
  2123.  
  2124.  
  2125. ΓòÉΓòÉΓòÉ 9.2. EXIT_XB ΓòÉΓòÉΓòÉ
  2126.  
  2127. Pack: EXITPACK                 Source Example 
  2128.  
  2129.      IN               OUT
  2130.    EP.func          EP.stat
  2131.  
  2132.  Call EXIT_XB before ending your program to release any remaining resources 
  2133.  back to the OS.  Open files should be closed by using CLOSE_DATA_XB and 
  2134.  CLOSE_INDEX_XB. EXIT_XB closes any Bullet files that are still open. 
  2135.  
  2136.  This routine is registered with the operating system and so is called 
  2137.  automatically when your program terminates. 
  2138.  
  2139.  
  2140. ΓòÉΓòÉΓòÉ 9.3. ATEXIT_XB ΓòÉΓòÉΓòÉ
  2141.  
  2142. This routine is obsolete.  In OS/2, the EXIT_XB shutdown procedure is 
  2143. registered with the operating system.  For those systems that do not offer this 
  2144. feature in the OS, the compiler run-time routine atexit() is used immediately 
  2145. after calling INIT_XB, using IP.exitPtr as the function pointer for atexit(). 
  2146.  
  2147.  
  2148. ΓòÉΓòÉΓòÉ 9.4. MEMORY_XB ΓòÉΓòÉΓòÉ
  2149.  
  2150. Pack: MEMORYPACK               Source Example 
  2151.  
  2152.      IN               OUT
  2153.    MP.func          MP.stat
  2154.                     MP.memory
  2155.  
  2156.  MP.memory returns with the number of bytes in the private memory arena 
  2157.  allocatable by the process according to DosQuerySysInfo for QSV_MAXPRMEM. 
  2158.  
  2159.  Note:  This routine is not mutex-protected. 
  2160.  
  2161.  
  2162. ΓòÉΓòÉΓòÉ 9.5. BACKUP_FILE_XB ΓòÉΓòÉΓòÉ
  2163.  
  2164. Pack: COPYPACK                 Source Example 
  2165.  
  2166.      IN               OUT
  2167.    CP.func          CP.stat
  2168.    CP.handle
  2169.    CP.filenamePtr
  2170.  
  2171.  Copy an open BULLET index file or data/memo files.  BULLET repacks and 
  2172.  reindexes files in place, requiring less disk space to perform the function. 
  2173.  This routine allows a file to be safely copied for a possible later restore. 
  2174.  
  2175.  This function is recommended prior to packing a data file with 
  2176.  PACK_RECORDS_XB.  For index files, COPY_INDEX_HEADER_XB is sufficient since 
  2177.  index files are easily recreated so long as you have the data file along with 
  2178.  the index file header. 
  2179.  
  2180.  A full-lock should be in force before copying.  A shared lock may be used. 
  2181.  
  2182.  If CP.handle belongs to a DBF data file, and if a memo file is attached, the 
  2183.  memo file backup name is as CP.filenamePtr, the backup DBF pathname, but the 
  2184.  extension is always set to "._BT".  For example, if CP.handle is for a DBF 
  2185.  that has a DBT memo file attached, then the current state of the DBF file is 
  2186.  copied to CP.filenamePtr, say, "\CURRBACK\ACCT.DBF", and, in this case, the 
  2187.  DBT memo file is copied to "\CURRBACK\ACCT._BT".  The name of the original 
  2188.  DBF/DBT does not matter.  If MEMO_EXTENSION of SET_SYSVARS_XB has changed the 
  2189.  default, then that extension is used on the memo copy, with '_' replacing its 
  2190.  first character. 
  2191.  
  2192.  To prevent the backing up of a DBT memo file when backing up a DBF data file, 
  2193.  set CP.handle = -CP.handle (i.e., negative CP.handle).  This way, the DBT memo 
  2194.  file is not copied.  To backup only a DBT file, close the DBF and copy the DBT 
  2195.  by some other means. 
  2196.  
  2197.  
  2198. ΓòÉΓòÉΓòÉ 9.6. STAT_HANDLE_XB ΓòÉΓòÉΓòÉ
  2199.  
  2200. Pack: STATHANDLEPACK           Source Example 
  2201.  
  2202.      IN               OUT
  2203.    SHP.func         SHP.stat
  2204.    SHP.handle       SHP.ID
  2205.  
  2206.  Get information on a file handle number to determine if it is a BULLET file, 
  2207.  and if so, its type:  index or data. 
  2208.  
  2209.       SHP.ID   File type
  2210.          0     index, IX3  use STAT_INDEX_XB for file stats
  2211.          1     data, DBF   use STAT_DATA_XB for file stats
  2212.         -1     unknown
  2213.  
  2214.  Only bit0 of SHP.ID is significant if not -1.  So, if bit0=0 then the handle 
  2215.  belongs to an index file.  If bit0=1 then it's a data file. 
  2216.  
  2217.  Memo file handles return as unknown.  A DBF file's memo file handle is stored 
  2218.  in the DBF file's data area, and is returned by STAT_DATA_XB in 
  2219.  SDP.memoHandle. 
  2220.  
  2221.  Note:  This routine is not mutex-protected. 
  2222.  
  2223.  
  2224. ΓòÉΓòÉΓòÉ 9.7. GET_ERROR_CLASS_XB ΓòÉΓòÉΓòÉ
  2225.  
  2226. Pack: XERRORPACK               Source Example 
  2227.  
  2228.      IN               OUT
  2229.    XEP.func         XEP.errClass
  2230.    XEP.stat         XEP.action
  2231.                     XEP.location
  2232.  
  2233.  Get the extended error information for the code passed in XEP.stat. This 
  2234.  information includes the error classification, recommended action, and origin 
  2235.  of the error. 
  2236.  
  2237.  Any system error code can be specified, not necessarily the one that last 
  2238.  occurred.  If a return code is not a BULLET code, then it is a system error 
  2239.  code (from the CP, DosXXX routines). 
  2240.  
  2241.  The ERRCLASS, ERRACT, and ERRLOC items below are OS/2 values, names and 
  2242.  descriptions for DosErrClass(). 
  2243.  
  2244.   Error Classification
  2245.  
  2246.     Value   Name                Description
  2247.       1    ERRCLASS_OUTRES     Out of resources
  2248.       2    ERRCLASS_TEMPSIT    Temporary situation
  2249.       3    ERRCLASS_AUTH       Authorization failed
  2250.       4    ERRCLASS_INTRN      Internal error
  2251.       5    ERRCLASS_HRDFAIL    Device hardware failure
  2252.       6    ERRCLASS_SYSFAIL    System failure
  2253.       7    ERRCLASS_APPEAR     Probably application error
  2254.       8    ERRCLASS_NOTFND     Item not located
  2255.       9    ERRCLASS_BADFMT     Bad format for function or data
  2256.      10    ERRCLASS_LOCKED     Resource or data locked
  2257.      11    ERRCLASS_MEDIA      Incorrect media, CRC error
  2258.      12    ERRCLASS_ALREADY    Action already taken or done, or resource already exists
  2259.      13    ERRCLASS_UNK        Unclassified
  2260.      14    ERRCLASS_CANT       Cannot perform requested action
  2261.      15    ERRCLASS_TIME       Timeout
  2262.  
  2263.  
  2264.   Recommended Action
  2265.  
  2266.     Value   Name                Description
  2267.       1    ERRACT_RETRY        Retry immediately
  2268.       2    ERRACT_DLYRET       Delay and retry
  2269.       3    ERRACT_USER         Bad user input - get new values
  2270.       4    ERRACT_ABORT        Terminate in an orderly manner
  2271.       5    ERRACT_PANIC        Terminate immediately
  2272.       6    ERRACT_IGNORE       Ignore error
  2273.       7    ERRACT_INTRET       Retry after user intervention
  2274.  
  2275.  
  2276.   Origin
  2277.  
  2278.     Value   Name                Description
  2279.       1    ERRLOC_UNK          Unknown
  2280.       2    ERRLOC_DISK         Disk
  2281.       3    ERRLOC_NET          Network
  2282.       4    ERRLOC_SERDEV       Serial device
  2283.       5    ERRLOC_MEM          Memory
  2284.  
  2285.  Note:  This routine is not mutex-protected. 
  2286.  
  2287.  
  2288. ΓòÉΓòÉΓòÉ 9.8. QUERY_SYSVARS_XB ΓòÉΓòÉΓòÉ
  2289.  
  2290. Pack: QUERYSETPACK             Source Example 
  2291.  
  2292.      IN               OUT
  2293.    QSP.func         QSP.stat
  2294.    QSP.item         QSP.itemValue
  2295.  
  2296.  Query a BULLET system variable. 
  2297.  
  2298.  To get the function pointers to the sort-compare functions, use: 
  2299.  
  2300.    QSP.item           FuncPtr To
  2301.    ASCII_SORT        ASCII sort compare
  2302.    NLS_SORT          NLS sort compare
  2303.    S16_SORT          16-bit signed integer
  2304.    U16_SORT          16-bit unsigned integer
  2305.    S32_SORT          32-bit signed integer
  2306.    U32_SORT          32-bit unsigned integer
  2307.  
  2308.  All intrinsic sort compares (1-6) point to the same function. They cannot be 
  2309.  called except by BULLET itself.  The integer compare routines are based on 
  2310.  Intel byte order.  For Motorola byte order, ASCII sort can be used for 
  2311.  all-positive numbers, otherwise a custom sort-compare should be used. 
  2312.  
  2313.     QSP.item          FuncPtr To
  2314.      10-19           Custom sort-compare functions
  2315.  
  2316.  Before creating or opening an index file with a custom sort-compare function 
  2317.  (which is specified during CREATE_INDEX_XB), that function's address must 
  2318.  first be sent to BULLET using SET_SYSVARS_XB. Thereafter, that function must 
  2319.  be available whenever that index file is accessed.  See Custom Sort-Compare 
  2320.  Function for creating custom sort-compare functions. 
  2321.  
  2322.  To get the function pointers to the build key and expression parser routines, 
  2323.  use: 
  2324.  
  2325.     QSP.item          FuncPtr To
  2326.    BUILD_KEY_FUNC    Build key routine
  2327.    PARSER_FUNC       Key expression parser routine
  2328.  
  2329.  Before creating or opening an index file with a custom build key or expression 
  2330.  parser routine (which is specified at any time, but must be used in a 
  2331.  consistent manner), that routine's address must first be sent to BULLET using 
  2332.  SET_SYSVARS_XB.  Thereafter, that routine should be available since it may be 
  2333.  required again.  See Custom Build-Key Routine for creating a custom build-key 
  2334.  routine and Custom Expression Parser Routine for creating a custom key 
  2335.  expression parser. 
  2336.  
  2337.  To get the BULLET system variables' values, use: 
  2338.  
  2339.     QSP.item             Value To
  2340.    26 (read-only)        low-word: number of xb$Malloc(), high-word: number of xb$Free()
  2341.    27 (read-only)        Max instances (2, 32, 999)
  2342.    28 (read-only)        Max files (100, 250, 1024)
  2343.    29 (read-only)        Handle of Bullet's mutex semaphore
  2344.  
  2345.    LOCK_TIMEOUT          Lock file bytes timeout, in milliseconds (default=0)
  2346.    MUTEX_SEM_TIMEOUT     Mutex semaphore request timeout, in milliseconds (default=0)
  2347.    PACK_BUFFER_SIZE      Pack buffer size, in bytes (default=0: autosize)
  2348.    REINDEX_BUFFER_SIZE   Reindex buffer size, in bytes (default=0: autosize)
  2349.    REINDEX_PACK_PCT      Reindex node pack percentage, 50-100% (default=100)
  2350.    TMP_PATH_PTR          Temporary file path pointer (default=NULL, where TMP= used, then .\)
  2351.    REINDEX_SKIP_TAG      Reindex tag field character to skip (default=0, no skip)
  2352.    COMMIT_AT_EACH        Commit each individual file during INSERT/UPDATE_XB (default=0, defer until flush)
  2353.    MEMO_BLOCKSIZE        Memo file block size (default=512 bytes; minimum is 24 bytes)
  2354.    MEMO_EXTENSION        Memo file extension (default is "DBT\0")
  2355.    MAX_DATAFILE_SIZE     Max data file size-1 (default=2047MB, absolute max is 4095MB)
  2356.    MAX_INDEXFILE_SIZE    Max index file size-1 (default=2047MB, absolute max is 4095MB)
  2357.    ATOMIC_MODE           Atomic mode (bit0=1 then atomic Next and Prev access, default=0)
  2358.    CALLBACK_PTR          Callback routine at reindex/pack (def=0, none)
  2359.  
  2360.  The timeout values determine if the kernel should wait for a pre-determined 
  2361.  time before returning an error if the resource cannot be obtained.  The lock 
  2362.  timeout specifies how long to wait for a lock to be obtained in case some 
  2363.  other process has a lock on the same resource.  The mutex timeout specifies 
  2364.  how long to wait for access to BULLET in case some other thread in this 
  2365.  process is in BULLET.  Multiple processes can access BULLET at the same time, 
  2366.  but only one thread in each process can be inside BULLET at any one time. 
  2367.  
  2368.  The buffer sizes, when 0, default to a minimum reasonable size.  Performance 
  2369.  is acceptable at these sizes.  For best performance, provide as much real 
  2370.  memory as possible, up to 512KB.  Larger buffers can be used. 
  2371.  
  2372.  The reindex node pack percentage determines how many keys are packed on a 
  2373.  node.  100% forces as many keys as possible, minus 1. 
  2374.  
  2375.  If the temporary file path pointer is NULL (the default), then the TMP= 
  2376.  environment variable is used to locate any temporary files created by BULLET, 
  2377.  or if that is not found, then the current directory is used.  The pointer 
  2378.  supplied, if any, should be to a string containing an existing path (drive 
  2379.  should be included; a trailing '\' is optional, but recommended).  See 
  2380.  REINDEX_XB for size requirements. 
  2381.  
  2382.  The reindex skip tag character, if encountered in the DBF record's tag field 
  2383.  (the first byte of each record), causes the reindex routine to not place that 
  2384.  record's key value into the index file.  Also, BUILD_KEY_XB returns a warning 
  2385.  if the record supplied has a matching tag character. To disable skip tag 
  2386.  processing, set it to 0. 
  2387.  
  2388.  Inserts and Updates, by default, do not commit each file when that pack is 
  2389.  processed.  Instead, it is left to the programmer to issue a FLUSH_XB to 
  2390.  commit.  To force a commit after each pack file is processed, set CommitAtEach 
  2391.  to 1.  This is not one single commit, but a commit for each file in the pack, 
  2392.  after that file has been processed, but before the next file in the pack is. 
  2393.  This will not prevent a roll-back should it be needed. 
  2394.  
  2395.  A memo file can have at most 589,822 blocks.  At the default 512 bytes per 
  2396.  block, that equates to about 288MB.  If you need more memo space, increase the 
  2397.  block size.  The memo extension default is "DBT\0".  Generally, it's a good 
  2398.  idea to leave it at this. 
  2399.  
  2400.  The maximum file sizes are enforced when adding to or reading from DBF files, 
  2401.  and when inserting into or reading from index files.  The default is 2047 MB 
  2402.  (0x7FEFFFFF).  If your file system permits 4GB files, set the values to 4095 
  2403.  MB (0xFFEFFFFF). 
  2404.  
  2405.  The Atomic mode flag determines how key access is handled.  When bit0=0, the 
  2406.  default, the key routines, NEXT_KEY_XB, PREV_KEY_XB, and GET_NEXT_XB, 
  2407.  GET_PREV_XB, use the internal position of the last gotten key as their 
  2408.  starting point.  In multi-threaded code, it's possible that another thread has 
  2409.  since accessed the same file handle and altered the last gotten key.  By 
  2410.  setting bit0=1, key access (next or previous) can now specify a starting point 
  2411.  (typically already set up in AP.keyPtr), rather than starting at the last 
  2412.  accessed key for that handle (which may have been changed by another thread). 
  2413.  
  2414.  The Callback routine receives a pointer to a CALLBACK structure on the stack. 
  2415.  The callback routine may clean the stack (e.g., a _syscall routine).  It may 
  2416.  also leave it for the caller to clean (e.g., a _stdcall or __cdecl routine). 
  2417.  See bd_rix.c on the distribution disk for an example.  When the CALLBACK_PTR 
  2418.  == NULL (default), no callback is made.  Currently, the callback is made 
  2419.  during REINDEX_XB and PACK_RECORDS calls, at a rate dependent on the 
  2420.  *_BUFFER_SIZE. 
  2421.  
  2422.  Note:  This routine is not mutex-protected. 
  2423.  
  2424.  
  2425. ΓòÉΓòÉΓòÉ 9.9. SET_SYSVARS_XB ΓòÉΓòÉΓòÉ
  2426.  
  2427. Pack: QUERYSETPACK             Source Example 
  2428.  
  2429.      IN               OUT
  2430.    QSP.func         QSP.stat
  2431.    QSP.item         QSP.itemValue
  2432.    QSP.itemValue
  2433.  
  2434.  Set a BULLET system variable, returning the previous value. 
  2435.  
  2436.  To use, set QSP.item to the item to set, and QSP.itemValue with the value to 
  2437.  use (function's address, variable's timeout value, etc., whatever the case may 
  2438.  be).  On return, QSP.itemValue is the previous value that QSP.item was set to. 
  2439.  
  2440.    QSP.item           FuncPtr To
  2441.    ASCII_SORT        ASCII sort compare
  2442.    NLS_SORT          NLS sort compare
  2443.    S16_SORT          16-bit signed integer
  2444.    U16_SORT          16-bit unsigned integer
  2445.    S32_SORT          32-bit signed integer
  2446.    U32_SORT          32-bit unsigned integer
  2447.  
  2448.  All intrinsic sort compares (1-6) point to the same function. They cannot be 
  2449.  called except by BULLET itself.  They should not be overloaded with custom 
  2450.  functions.  If you have a custom sort-compare, use one of the custom slots. 
  2451.  The integer compare routines are based on Intel byte order.  For Motorola byte 
  2452.  order, ASCII sort can be used for all-positive numbers, otherwise a custom 
  2453.  sort-compare should be used. 
  2454.  
  2455.     QSP.item          FuncPtr To
  2456.      10-19           Custom sort-compare functions
  2457.  
  2458.  Before creating or opening an index file with a custom sort-compare function 
  2459.  (which is specified during CREATE_INDEX_XB), that function's address must 
  2460.  first be sent to BULLET using this routine. Thereafter, that function must be 
  2461.  available whenever that index file is accessed.  See Custom Sort-Compare 
  2462.  Function for creating custom sort-compare functions. 
  2463.  
  2464.  To set the function pointers to the build key and expression parser routines, 
  2465.  use: 
  2466.  
  2467.     QSP.item          FuncPtr To
  2468.    BUILD_KEY_FUNC    Build key routine
  2469.    PARSER_FUNC       Key expression parser routine
  2470.  
  2471.  Before creating or opening an index file with a custom build key or expression 
  2472.  parser routine (which is specified at any time, but must be used in a 
  2473.  consistent manner), that routine's address must first be sent to BULLET using 
  2474.  this routine.  Thereafter, that routine should always be ready (in a callable 
  2475.  state) since it may be required again.  See Custom Build-Key Routine for 
  2476.  creating a custom build-key routine and Custom Expression Parser Routine for 
  2477.  creating a custom key expression parser. 
  2478.  
  2479.  To set the BULLET system variables' values, use: 
  2480.  
  2481.     QSP.item             Value To
  2482.    LOCK_TIMEOUT          Lock file bytes timeout, in milliseconds (default=0)
  2483.    MUTEX_SEM_TIMEOUT     Mutex semaphore request timeout, in milliseconds (default=0)
  2484.    PACK_BUFFER_SIZE      Pack buffer size, in bytes (default=0: autosize)
  2485.    REINDEX_BUFFER_SIZE   Reindex buffer size, in bytes (default=0: autosize)
  2486.    REINDEX_PACK_PCT      Reindex node pack percentage, 50-100% (default=100)
  2487.    TMP_PATH_PTR          Temporary file path pointer (default=NULL, where TMP= used, then .\)
  2488.    REINDEX_SKIP_TAG      Reindex tag field character to skip (default=0, no skip)
  2489.    COMMIT_AT_EACH        Commit each individual file during INSERT/UPDATE_XB (default=0, defer until flush)
  2490.    MEMO_BLOCKSIZE        Memo file block size (default=512 bytes; minimum is 24 bytes)
  2491.    MEMO_EXTENSION        Memo file extension (default is "DBT\0")
  2492.    MAX_DATAFILE_SIZE     Max data file size-1 (default=2047MB, absolute max is 4095MB)
  2493.    MAX_INDEXFILE_SIZE    Max index file size-1 (default=2047MB, absolute max is 4095MB)
  2494.    ATOMIC_MODE           Atomic mode (bit0=1 then atomic Next and Prev access, default=0)
  2495.    CALLBACK_PTR          Callback routine at reindex/pack (def=0, none)
  2496.  
  2497.  The timeout values determine if the kernel should wait for a pre-determined 
  2498.  time before returning an error if the resource cannot be obtained.  The lock 
  2499.  timeout specifies how long to wait for a lock to be obtained in case some 
  2500.  other process has a lock on the same resource.  The mutex timeout specifies 
  2501.  how long to wait for access to BULLET in case some other thread in this 
  2502.  process is in BULLET.  Multiple processes can access BULLET at the same time, 
  2503.  but only one thread in each process can be inside BULLET at any one time. 
  2504.  
  2505.  The buffer sizes, when 0, default to a minimum reasonable size.  Performance 
  2506.  is acceptable at these sizes.  For best performance, provide as much real 
  2507.  memory as possible, up to 512KB.  Larger buffers can be used. 
  2508.  
  2509.  The reindex node pack percentage determines how many keys are packed on a 
  2510.  node.  100% forces as many keys as possible, minus 1. 
  2511.  
  2512.  If the temporary file path pointer is NULL (the default), then the TMP= 
  2513.  environment variable is used to locate any temporary files created by BULLET, 
  2514.  or if that is not found, then the current directory is used.  The pointer 
  2515.  supplied, if any, should be to a string containing an existing path (drive 
  2516.  should be included; a trailing '\' is optional, but recommended).  See 
  2517.  REINDEX_XB for size requirements. 
  2518.  
  2519.  The reindex skip tag character, if encountered in the DBF record's tag field 
  2520.  (the first byte of each record), causes the reindex routine to not place that 
  2521.  record's key value into the index file.  Also, BUILD_KEY_XB returns a warning 
  2522.  if the record supplied has a matching tag character. To disable skip tag 
  2523.  processing, set it to 0. 
  2524.  
  2525.  Inserts and Updates, by default, do not commit each file when that pack is 
  2526.  processed.  Instead, it is left to the programmer to issue a FLUSH_XB to 
  2527.  commit.  To force a commit after each pack file is processed, set CommitAtEach 
  2528.  to 1.  This is not one single commit, but a commit for each file in the pack, 
  2529.  after that file has been processed, but before the next file in the pack is. 
  2530.  This will not prevent a roll-back should it be needed. 
  2531.  
  2532.  A memo file can have at most 589,822 blocks.  At the default 512 bytes per 
  2533.  block, that equates to about 288MB.  If you need more memo space, increase the 
  2534.  block size.  The memo extension default is "DBT\0".  Generally, it's a good 
  2535.  idea to leave it at this. 
  2536.  
  2537.  The maximum file sizes are enforced when adding to or reading from DBF files, 
  2538.  and when inserting into or reading from index files.  The default is 2047 MB 
  2539.  (0x7FEFFFFF).  If your file system permits 4GB files, set the values to 4095 
  2540.  MB (0xFFEFFFFF). 
  2541.  
  2542.  The Atomic mode flag determines how key access is handled.  When bit0=0, the 
  2543.  default, the key routines, NEXT_KEY_XB, PREV_KEY_XB, and GET_NEXT_XB, 
  2544.  GET_PREV_XB, use the internal position of the last gotten key as their 
  2545.  starting point.  In multi-threaded code, it's possible that another thread has 
  2546.  since accessed the same file handle and altered the last gotten key.  By 
  2547.  setting bit0=1, key access (next or previous) can now specify a starting point 
  2548.  (typically already set up in AP.keyPtr), rather than starting at the last 
  2549.  accessed key for that handle (which may have been changed by another thread). 
  2550.  
  2551.  The Callback routine receives a pointer to a CALLBACK structure on the stack. 
  2552.  The callback routine may clean the stack (e.g., a _syscall routine).  It may 
  2553.  also leave it for the caller to clean (e.g., a _stdcall or __cdecl routine). 
  2554.  See bd_rix.c on the distribution disk for an example.  When the CALLBACK_PTR 
  2555.  == NULL (default), no callback is made.  Currently, the callback is made 
  2556.  during REINDEX_XB and PACK_RECORDS calls, at a rate dependent on the 
  2557.  *_BUFFER_SIZE. 
  2558.  
  2559.  Note:  Issuing INIT_XB restores all system variables (those setable via this 
  2560.  routine) and function pointers, but not vectors, to their default values. 
  2561.  This is done even if INIT_XB returns an error that BULLET has already been 
  2562.  initialized. 
  2563.  
  2564.  
  2565. ΓòÉΓòÉΓòÉ 9.10. SET_DVMON_XB ΓòÉΓòÉΓòÉ
  2566.  
  2567. This routine is not currently used. 
  2568.  
  2569.  
  2570. ΓòÉΓòÉΓòÉ 9.11. QUERY_VECTORS_XB ΓòÉΓòÉΓòÉ
  2571.  
  2572. Pack: QUERYSETPACK             Source Example 
  2573.  
  2574.      IN               OUT
  2575.    QSP.func         QSP.stat
  2576.    QSP.item         QSP.itemValue
  2577.  
  2578.  Query a BULLET OS API vector. 
  2579.  
  2580.  To get the vectors that Bullet makes to access OS API calls, set QSP.item to 
  2581.  the desired VECTOR_* constant below.  On return, QSP.itemValue has the 
  2582.  function pointer for that item. 
  2583.  
  2584.        QSP.item
  2585.    VECTOR_CLOSE_FILE
  2586.    VECTOR_CREATE_DIR
  2587.    VECTOR_CREATE_FILE
  2588.    VECTOR_CREATE_UNIQUE_FILE
  2589.    VECTOR_DELETE_FILE
  2590.    VECTOR_LENGTH_FILE
  2591.    VECTOR_MOVE_FILE
  2592.    VECTOR_OPEN_FILE
  2593.    VECTOR_READ_FILE
  2594.    VECTOR_SEEK_FILE
  2595.    VECTOR_UPDATE_DIR_ENTRY
  2596.    VECTOR_WRITE_FILE
  2597.    VECTOR_LOCK_FILE
  2598.    VECTOR_IS_DRIVE_REMOTE
  2599.    VECTOR_IS_FILE_REMOTE
  2600.    VECTOR_EXITLIST
  2601.    VECTOR_REMOVE_EXITLIST
  2602.    VECTOR_FREE
  2603.    VECTOR_GET_SORT_TABLE
  2604.    VECTOR_GET_COUNTRY_INFO
  2605.    VECTOR_GET_ERROR_CLASS
  2606.    VECTOR_GET_MEMORY
  2607.    VECTOR_GET_TMP_DIR
  2608.    VECTOR_GET_VERSION
  2609.    VECTOR_MALLOC
  2610.    VECTOR_SET_HANDLE_COUNT
  2611.    VECTOR_GET_TIME_INFO
  2612.    VECTOR_UPPERCASE
  2613.    VECTOR_CLOSE_MUTEX_SEM
  2614.    VECTOR_CREATE_MUTEX_SEM
  2615.    VECTOR_RELEASE_MUTEX_SEM
  2616.    VECTOR_REQUEST_MUTEX_SEM
  2617.  
  2618.  If QSP.itemValue is returned NULL, the default Bullet OS API call is being 
  2619.  used. 
  2620.  
  2621.  Note:  This routine is not mutex-protected. 
  2622.  
  2623.  
  2624. ΓòÉΓòÉΓòÉ 9.12. SET_VECTORS_XB ΓòÉΓòÉΓòÉ
  2625.  
  2626. Pack: QUERYSETPACK             Source Example 
  2627.  
  2628.      IN               OUT
  2629.    QSP.func         QSP.stat
  2630.    QSP.item         QSP.itemValue
  2631.    QSP.itemValue
  2632.  
  2633.  Set a BULLET OS API vector. 
  2634.  
  2635.  To set the vectors that Bullet makes to access OS API calls, set QSP.item to 
  2636.  the desired VECTOR_* constant below, and QSP.itemValue to its replacement's 
  2637.  address.  On return, QSP.itemValue has the previous function pointer for that 
  2638.  item. 
  2639.  
  2640.        QSP.item
  2641.    VECTOR_CLOSE_FILE
  2642.    VECTOR_CREATE_DIR
  2643.    VECTOR_CREATE_FILE
  2644.    VECTOR_CREATE_UNIQUE_FILE
  2645.    VECTOR_DELETE_FILE
  2646.    VECTOR_LENGTH_FILE
  2647.    VECTOR_MOVE_FILE
  2648.    VECTOR_OPEN_FILE
  2649.    VECTOR_READ_FILE
  2650.    VECTOR_SEEK_FILE
  2651.    VECTOR_UPDATE_DIR_ENTRY
  2652.    VECTOR_WRITE_FILE
  2653.    VECTOR_LOCK_FILE
  2654.    VECTOR_IS_DRIVE_REMOTE
  2655.    VECTOR_IS_FILE_REMOTE
  2656.    VECTOR_EXITLIST
  2657.    VECTOR_REMOVE_EXITLIST
  2658.    VECTOR_FREE
  2659.    VECTOR_GET_SORT_TABLE
  2660.    VECTOR_GET_COUNTRY_INFO
  2661.    VECTOR_GET_ERROR_CLASS
  2662.    VECTOR_GET_MEMORY
  2663.    VECTOR_GET_TMP_DIR
  2664.    VECTOR_GET_VERSION
  2665.    VECTOR_MALLOC
  2666.    VECTOR_SET_HANDLE_COUNT
  2667.    VECTOR_GET_TIME_INFO
  2668.    VECTOR_UPPERCASE
  2669.    VECTOR_CLOSE_MUTEX_SEM
  2670.    VECTOR_CREATE_MUTEX_SEM
  2671.    VECTOR_RELEASE_MUTEX_SEM
  2672.    VECTOR_REQUEST_MUTEX_SEM
  2673.  
  2674.  Example replacement routines are in ccdosfn.c.  Many of the routines in 
  2675.  ccdosfn.c are standard C, but some are OS-specific and must be updated for the 
  2676.  OS being used. 
  2677.  
  2678.  If QSP.itemValue is set to NULL, the default Bullet OS API call is used. 
  2679.  
  2680.  On return from a successful call, QSP.itemValue is the value of the previous 
  2681.  function pointer for that item, which may be returned NULL, indicating that 
  2682.  the default Bullet OS API call was being used. 
  2683.  
  2684.  
  2685. ΓòÉΓòÉΓòÉ 9.13. CREATE_DATA_XB ΓòÉΓòÉΓòÉ
  2686.  
  2687. Pack: CREATEDATAPACK           Source Example 
  2688.  
  2689.      IN               OUT
  2690.    CDP.func         CDP.stat
  2691.    CDP.filenamePtr
  2692.    CDP.noFields
  2693.    CDP.fieldListPtr
  2694.    CDP.fileID
  2695.  
  2696.  Create a new BULLET DBF data file with the name at CDP.filenamePtr, and an 
  2697.  optional DBT memo file. 
  2698.  
  2699.  Before using this routine, allocate an array of field descriptors of type 
  2700.  FIELDDESCTYPE, one for each field in the record (number of fields as set in 
  2701.  CDP.noFields). It is recommended  that this allocation be zeroed before use 
  2702.  since fieldnames and reserved entries must be 0-filled: 
  2703.  
  2704.      FIELDDESCTYPE fieldList[12];  // 12 fields used in data record
  2705.        :
  2706.      memset(fieldList,0,sizeof(fieldList)); // init unused bytes to 0 (required)
  2707.  
  2708.  Filename 
  2709.  
  2710.  The drive and path must exist if used as part of the filename. Long filenames 
  2711.  may be used if supported by the file system in use. As with all text strings 
  2712.  used by Bullet, the filename must end in a '\0'. 
  2713.  
  2714.  Number of Fields 
  2715.  
  2716.  The number of descriptors in the array, described next.  Each field has a 
  2717.  descriptor.  The tag field is not a formal field, and so has no descriptor, 
  2718.  and is not counted in the number of fields.  The maximum fields is 254 
  2719.  according to the DBF standard.  Bullet allows 255, but 254 should be used if 
  2720.  creating a standard DBF file. 
  2721.  
  2722.  Field Descriptors 
  2723.  
  2724.  For each field, a descriptor is used to identify and type it.  These 
  2725.  descriptors are assigned to an array; the pointer to that array is assigned to 
  2726.  CDP.fieldListPtr.  The format of the descriptor follows, with a physical 
  2727.  format in DBF File Format. 
  2728.  
  2729.  Γûá Fieldname 
  2730.  
  2731.  10 characters plus null byte terminator.  Valid fieldname characters are ASCII 
  2732.  A-Z (upper-case) and the underscore (ASCII 95).  All bytes after the fieldname 
  2733.  must be null bytes.  E.g., if the fieldname is "LNAME", five characters, the 
  2734.  following six bytes (including the 11th byte) are set to 0. The eleventh byte 
  2735.  is always a null byte since 10 characters is the maximum fieldname length. 
  2736.  Extended ASCII characters (above 127) should not be used. 
  2737.  
  2738.   fieldList[0].fieldname = "ANYNAME";   // see memset() above
  2739.  
  2740.  Γûá Field type and size 
  2741.  
  2742.  Standard Xbase field types are C, D, L, M, and N: 
  2743.  
  2744.  Type   Description 
  2745.    C    Character field, any code page character, 1 to 255 characters. 
  2746.         Null bytes are not desirable except as a string terminator.  There is 
  2747.         no requirement that strings be terminated with a '\0'.  The field data 
  2748.         should be left-justified within the field, but this is not required (in 
  2749.         which case use leading spaces, not 0 bytes). 
  2750.  
  2751.                        fieldList[0].fieldType = 'C';
  2752.                        fieldList[0].fieldLen = 25;   // since C type, space fill field data
  2753.                        fieldList[0].fieldDC = 0;
  2754.  
  2755.    D    Date field, valid ASCII digits for date, 8 characters. 
  2756.         The physical format is YYYYMMDD, where YYYY is the year (1999), MM is 
  2757.         the month (1-12), and DD the day (1-31).  The date field is always 8 
  2758.         bytes long, and is in ASCII digits ('19991231').  If no date, set to 
  2759.         all spaces. 
  2760.  
  2761.                        fieldList[0].fieldType = 'D';
  2762.                        fieldList[0].fieldLen = 8;
  2763.                        fieldList[0].fieldDC = 0;
  2764.  
  2765.    L    Logical field, <SPACE> Y N T F y n t f, 1 character. 
  2766.         A single-byte field.  When not yet initialized the value will be a 
  2767.         <SPACE> (ASCII 32).  This is typically displayed as a '?' to the user, 
  2768.         indicating that the field has not been initialized.  Initialized values 
  2769.         are variations of yes, no, true, false ('Y', 'y', etc.). 
  2770.  
  2771.                        fieldList[0].fieldType = 'L';
  2772.                        fieldList[0].fieldLen = 1;
  2773.                        fieldList[0].fieldDC = 0;
  2774.  
  2775.    M    Memo field, 10 ASCII digits, 10 characters. 
  2776.         Field data is used as the block number of the corresponding DBT memo 
  2777.         file.  Each block is typically 512 bytes, with the first block (block 
  2778.         #0) used as the memo file header.  If no block is used in the .DBT by 
  2779.         this record, the field is set to <SPACES>.  The first memo block is 
  2780.         stored as "0000000001".  (This description is valid for dBASE IV and 
  2781.         later memo files, as created and used by BULLET.) Some Xbase versions 
  2782.         use field types B and G as variations of memo files.  They are as M, 
  2783.         but contain general data (as in anything), while memo files contain 
  2784.         only text. BULLET supports any type data in its memo files, and you may 
  2785.         use the CDP.fieldType of 'B' or 'G'. 
  2786.  
  2787.         More than one memo field per record is permitted.  For example, you may 
  2788.         need a memo for the printable address, where the address is free-form 
  2789.         rather than in separate fields (i.e., you have both forms), and another 
  2790.         memo for general notes, and yet a third for problem reports, and so on. 
  2791.         All these, and all memos for the rest of the DBF file, are stored in 
  2792.         the same DBT memo file. 
  2793.  
  2794.         Note:  BULLET does not use the fieldType with regard to identifying 
  2795.         memo field type; it is the programmer's responsibility to check the 
  2796.         fieldType and act on it accordingly. 
  2797.  
  2798.                        fieldList[0].fieldType = 'M';
  2799.                        fieldList[0].fieldLen = 10;
  2800.                        fieldList[0].fieldDC = 0;
  2801.  
  2802.    N    Numeric field, ASCII digits, 19 digits maximum (see below). 
  2803.         All standard Xbase data is stored in ASCII form (for universal 
  2804.         exchange).  Numeric fields are to be right-justified, with leading 
  2805.         spaces, and an aligned decimal point, if any (relative this field in 
  2806.         other records).  Do not end the field with a null byte. 
  2807.  
  2808.         The total size of the numeric field is specified in .fieldLen, which 
  2809.         includes any leading sign, the decimal point, and decimal digits to the 
  2810.         right of the decimal point (if any decimal point). The maximum total 
  2811.         size is 19 places.  If a decimal point, then the number of digits to 
  2812.         the right may be from 1 to 15 digits, but must be no more than the 
  2813.         total-2. 
  2814.  
  2815.                    FieldLen.FieldDC    Example
  2816.                            8.2          " 2345.78"
  2817.                            8.2          "12345.78"
  2818.                            8.2          "-2345.78"
  2819.                            8.1          "123456.8"
  2820.                            8.0          "12345678"
  2821.                            5.3          "2.235"
  2822.                            5.4          (not valid)
  2823.  
  2824.                        fieldList[0].fieldType = 'N';
  2825.                        fieldList[0].fieldLen = 8;
  2826.                        fieldList[0].fieldDC = 2;
  2827.  
  2828.  Although not dBASE compatible, you may use binary fields in your data records. 
  2829.  The Xbase standard always has ASCII data in the data fields, even if the field 
  2830.  is numeric.  For example, an 'N' type field of 8.2 (total 
  2831.  length.decimal-count) is stored as an ASCII text string in the data record, 
  2832.  say, a string like " 1100.55".  If you want dBASE compatibility your field 
  2833.  data must also be ASCII.  However, if you can forgo this requirement, you can 
  2834.  use binary values in the fields. 
  2835.  
  2836.  To do this you must specify a field type of 'Y' (actually, anything but an 
  2837.  'N') and, if it is to be used as a key field, also set the sort function to 
  2838.  the appropriate type (S16_SORT, etc.).  The field length 
  2839.  (fieldList[x].fieldLen) for a 'Y' field type is 2 if 16-bit, and 4 if 32-bit. 
  2840.  Also possible is floating-point (with a custom sort-compare function).  A 
  2841.  likely field type marker for this would be 'F'.  Note that both 'Y' and 'F' 
  2842.  are completely non-standard Xbase types, and only your programs will 
  2843.  understand them. 
  2844.  
  2845.  Note:  'B' should not be used as a binary field type marker since dBASE V uses 
  2846.  'B' to signify a binary-data memo file field.  Bullet makes no distinction in 
  2847.  its memo file data; anything can be placed in them.  Typically, your memo 
  2848.  fields are marked as 'M' in Bullet, but could also be 'B' or 'G'. 
  2849.  
  2850.  File ID 
  2851.  
  2852.  Conventional dBASE DBF files have a CDP.fileID=3.  To create a memo file (DBT, 
  2853.  dBASE IV compatible), set CDP.fileID=x8B.  For the DBT to be created, both 
  2854.  bits 3 and 7 (0x88) must be set.  The other bits may be anything, and are not 
  2855.  checked.  See  In creating your DBF files, specify CDP.fileID=3 to ensure 
  2856.  compatibility across Xbase versions, and limit record length to 4000 
  2857.  characters.  If creating a non-standard DBF (e.g., non-standard field types, 
  2858.  extended field lengths, etc.) it's recommended to use CDP.fileID=0 or 
  2859.  CDP.fileID=1.  For a standard DBF file with a memo file (dBASE IV or later), 
  2860.  use CDP.fileID=0x8B (that's a B, as in bee). 
  2861.  
  2862.  Generally, field data is space-filled.  String terminators are allowed in 
  2863.  C-haracter field types, but should not be used in other fields. 
  2864.  
  2865.  Memo File Creation 
  2866.  
  2867.  If bits 3 and 7 are set in CDP.fileID, a memo file is created for the DBF. The 
  2868.  memo filename will be the same as the DBF name except the extension. The memo 
  2869.  file is created after the DBF, with a block size of 512 bytes, and filename 
  2870.  extension of ".DBT".  The default block size and extension can be overridden 
  2871.  (see SET_SYSVARS_XB) prior to calling this routine. 
  2872.  
  2873.  Note:  A simple way to check that your record description in the field list 
  2874.  matches your source code structure is to compare the number of bytes used by 
  2875.  all fields in the field list (+1 for the delete tag byte) with the size of 
  2876.  your program's structure.  They must equal.  Also verify each field's size to 
  2877.  make sure they match. 
  2878.  
  2879.  
  2880. ΓòÉΓòÉΓòÉ 9.14. OPEN_DATA_XB ΓòÉΓòÉΓòÉ
  2881.  
  2882. Pack: OPENPACK                 Source Example 
  2883.  
  2884.      IN               OUT
  2885.    OP.func          OP.stat
  2886.    OP.filenamePtr   OP.handle
  2887.    OP.asMode
  2888.  
  2889.  Open an existing DBF data file for use.  For DBF opens, two parameters are 
  2890.  specified:  the filename and the access-sharing mode.  The OP.xbLink parameter 
  2891.  is used only for index opens, and so is not used here. 
  2892.  
  2893.  The OP.asMode has optional cache mode settings.  The caching modes cover 
  2894.  locality, write-through, and skip cache.  Locality is typically mostly random 
  2895.  (RND_LOCALITY), but may be mostly sequential if the data file has been sorted 
  2896.  and the index file recently reindexed and processing is mostly in-order (first 
  2897.  to last, rather than random).  Locality is used to tune the cache.  Also, 
  2898.  normally, data is written to the cache with control returning immediately to 
  2899.  the program before the disk is written (an asynchronous write).  To force the 
  2900.  write to take place before control is returned (a synchronous write), use the 
  2901.  WRITE_THROUGH mode.  To skip the cache completely, use the SKIP_CACHE mode. 
  2902.  This, as all OP.asMode settings, affects this file handle only. 
  2903.  
  2904.  On a successful open, the file handle is returned.  Use this handle for all 
  2905.  further access to this file.  If the DBF was created with a compatible memo 
  2906.  file, it is also opened.  The handle of the memo file is available via 
  2907.  STAT_DATA_XB, but all access to the memo file is made with the handle of the 
  2908.  memo file's master DBF (the handle returned by this routine in OP.handle). 
  2909.  The memo file is opened using the same OP.asMode. 
  2910.  
  2911.  Note:  FoxPro DBF files with Fox memo files (FPT) use an ID of 0xFF.  Bullet 
  2912.  does not support FoxPro memo files, and so opening a FoxPro DBF with a Fox 
  2913.  memo file returns the warning message, WRN_CANNOT_OPEN_MEMO.  The DBF file is 
  2914.  opened, and the warning can be ignored. 
  2915.  
  2916.  Once open, you can get information on the data file by using STAT_DATA_XB. 
  2917.  
  2918.  Each DBF data file opened allocates and commits at least 4K bytes for internal 
  2919.  use: 
  2920.  
  2921.    Number of Fields     Memory
  2922.         1 to 121            4KB
  2923.       122 to 249            8KB
  2924.       250 to 255           12KB
  2925.  
  2926.  This memory is released when you close the file with CLOSE_DATA_XB. or issue 
  2927.  EXIT_XB. 
  2928.  
  2929.  Note:  You must open the data file before you can open or create any of its 
  2930.  index files. 
  2931.  
  2932.  When BULLET creates a DBF, it forces all fieldnames to upper-case (it's a DBF 
  2933.  requirement) and 0-fills them as well.  On data file opens (OPEN_DATA_XB), it 
  2934.  also does this, and so any header copy (COPY_DATA_HEADER_XB) will have 
  2935.  upper-cased fieldnames (the original file is not changed).  To prevent BULLET 
  2936.  from mapping the fieldnames to upper-case (NLS mapping, though fieldnames 
  2937.  should be standard ASCII characters only), set bit31 of OP.asMode to 1 
  2938.  (0x80000042, for example).  This skips the case mapping.  Zero-filling always 
  2939.  takes place, and starts after the first ' \0' byte in the fieldname. 
  2940.  
  2941.  
  2942. ΓòÉΓòÉΓòÉ 9.15. CLOSE_DATA_XB ΓòÉΓòÉΓòÉ
  2943.  
  2944. Pack: HANDLEPACK               Source Example 
  2945.  
  2946.      IN               OUT
  2947.    HP.func          HP.stat
  2948.    HP.handle
  2949.  
  2950.  Close an existing data file. 
  2951.  
  2952.  Closing the file updates the file header and releases the memory used by the 
  2953.  file.  Any associated memo file is closed, too.  Any outstanding locks should 
  2954.  be unlocked before calling this routine. 
  2955.  
  2956.  Note:  Remaining locks belonging to this handle are released by the OS upon 
  2957.  the successful close. 
  2958.  
  2959.  
  2960. ΓòÉΓòÉΓòÉ 9.16. STAT_DATA_XB ΓòÉΓòÉΓòÉ
  2961.  
  2962. Pack: STATDATAPACK             Source Example 
  2963.  
  2964.      IN               OUT
  2965.    SDP.func         SDP.stat         SDP.recordLength
  2966.    SDP.handle       SDP.fileType     SDP.xactionFlag
  2967.                     SDP.flags        SDP.encryptFlag
  2968.                     SDP.progress     SDP.herePtr
  2969.                     SDP.morePtr      SDP.memoHandle
  2970.                     SDP.fields       SDP.memoBlockSize
  2971.                     SDP.asMode       SDP.memoFlags
  2972.                     SDP.filenamePtr  SDP.memoLastRecord
  2973.                     SDP.fileID       SDP.memoLastSize
  2974.                     SDP.lastUpdate   SDP.lockCount
  2975.                     SDP.records
  2976.  
  2977.  Return information BULLET has on the DBF data file specified by SDP.handle. 
  2978.  
  2979.    Item             Description 
  2980.  stat               Return code of operation 
  2981.  fileType           1 for DBF 
  2982.  flags              Bit0=1 if file has changed since last flush (dirty) 
  2983.                     Bit1=1 if the file has its entire region locked (full lock) 
  2984.                     Bit2=1 if the file has a shared lock in use (cannot write 
  2985.                     to it if so) 
  2986.  progress           Percentage of pack operation completed, 1-99, or 0 if done 
  2987.  morePtr            Always 0 
  2988.  fields             Number of fields per record (does not included implicit tag 
  2989.                     field) 
  2990.  asMode             Access-sharing-cache mode as specified at open (excludes 
  2991.                     NoCaseMap bit31) 
  2992.  filenamePtr        Pointer to the filename as used in OPEN_DATA_XB 
  2993.  fileID             ID byte used when the DBF was created (the first byte of 
  2994.                     the file) 
  2995.  lastUpdate         Date of last change (binary: high word=year (1999), low 
  2996.                     byte=day, high byte=month) 
  2997.  records            Number of records in the DBF (includes any delete-tagged 
  2998.                     records) 
  2999.  recordLength       Total length of a data record, including tag field 
  3000.  xactionFlag        Not currently used 
  3001.  encryptFlag        Not currently used 
  3002.  herePtr            Pointer to the internal data control area for this file 
  3003.                     handle 
  3004.  memoHandle         Handle of open memo file (0 if none) 
  3005.  memoBlockSize      Memo file block size (512 is typical, 24 is minimum) 
  3006.  memoFlags          Bit0=1 dirty 
  3007.  memoLastRecord     Last accessed memo record (0 if none; same as 'block 
  3008.                     number') 
  3009.  memoLastSize       Size of last accessed memo record (in bytes, including 8 
  3010.                     bytes overhead) 
  3011.  lockCount          Number of full-locks in force (locked on first, unlocked on 
  3012.                     last) 
  3013.  
  3014.  Typically, your program tracks whether a particular handle belongs to an index 
  3015.  file or data file.  In cases where this is not possible, call the 
  3016.  STAT_HANDLE_XB. routine to determine what file type a handle is. 
  3017.  
  3018.  Note:  In network environments, you should have an exclusive lock on the data 
  3019.  file (and implicitly, therefore, the memo file, if any) before using this 
  3020.  routine to ensure that the information is current.  This also applies to 
  3021.  multi-process environments on a single machine.  This routine is not 
  3022.  mutex-protected.  During the call, the file handle must not be closed by 
  3023.  another thread. 
  3024.  
  3025.  
  3026. ΓòÉΓòÉΓòÉ 9.17. READ_DATA_HEADER_XB ΓòÉΓòÉΓòÉ
  3027.  
  3028. Pack: HANDLEPACK               Source Example 
  3029.  
  3030.      IN               OUT
  3031.    HP.func          HP.stat
  3032.    HP.handle
  3033.  
  3034.  Reload the disk copy of the data header for the opened DBF data file handle, 
  3035.  refreshing the in-memory copy.  Any associated memo file is refreshed, too. 
  3036.  
  3037.  Normally, this routine is not called directly but rather is done automatically 
  3038.  when you full-lock the file (LOCK_XB).  This routine does not refresh the 
  3039.  header if the current state is dirty (SDP.flags, bit0=1); it returns an error 
  3040.  if tried. Since it is recommended that a full-lock be in force before using 
  3041.  this routine (shared or exclusive), and since a full-lock always reloads the 
  3042.  header anyway, calling this routine should never be required.  If ever there 
  3043.  is a reason to use this routine without having a full-lock in force, then, of 
  3044.  course, you may need to.  However, it is not wise to reload the header without 
  3045.  a full-lock (which locks the header).  If you are using your own lock 
  3046.  routines, this call will be very useful. 
  3047.  
  3048.  In single-user, single-tasking systems this routine is not needed.  However, 
  3049.  in a multi-user or multi-tasking system it's possible, and desirable, for two 
  3050.  or more programs to use the same data file.  Consider this scenario: A data 
  3051.  file has 100 records.  Two programs access this data file, both opening it. 
  3052.  Program 1 locks the file, adds a new record, then flushes and unlocks the 
  3053.  file.  Program 1 knows that there are now 101 records in the file.  However, 
  3054.  Program 2 is not aware of the changes that Program 1 made--it thinks that 
  3055.  there are still 100 records in the file.  This out-of-sync situation is easily 
  3056.  remedied by having Program 2 reload the data header from the file on disk. 
  3057.  
  3058.  How does Program 2 know that it needs to reload the header? It doesn't. 
  3059.  Instead, BULLET uses a simple, yet effective, approach when dealing with this. 
  3060.  When BULLET full-locks a file, BULLET automatically reloads the header by 
  3061.  using this routine.  When removing the full-lock, BULLET automatically flushes 
  3062.  the header using FLUSH_DATA_HEADER_XB (unless the current lock is a shared 
  3063.  lock (SDP.flags bit2=1)). 
  3064.  
  3065.  
  3066. ΓòÉΓòÉΓòÉ 9.18. FLUSH_DATA_HEADER_XB ΓòÉΓòÉΓòÉ
  3067.  
  3068. Pack: HANDLEPACK               Source Example 
  3069.  
  3070.      IN               OUT
  3071.    HP.func          HP.stat
  3072.    HP.handle
  3073.  
  3074.  Write the in-memory copy of the data header for the opened DBF data file 
  3075.  handle to disk.  The actual write occurs only if the header has been changed 
  3076.  (the dirty bit is set).  Any associated memo file is flushed, too.  This 
  3077.  routine ensures that the data header on disk matches exactly the data header 
  3078.  that is being maintained by BULLET. 
  3079.  
  3080.  Normally, this routine is not called directly but rather is done automatically 
  3081.  when you unlock the file (UNLOCK_XB).  This routine does not write out the 
  3082.  header if the current lock state is shared (SDP.flags, bit2=1); it returns an 
  3083.  error if tried.  Unlocking a full-lock performs a flush automatically, and so 
  3084.  you may never need to explicitly call this routine.  Also, when relocking from 
  3085.  an exclusive full-lock to a shared full-lock, an automatic flush is performed. 
  3086.  
  3087.  Assume the following: A data file with 100 records.  Your program opens the 
  3088.  data file and adds 1 record.  Physically, there are 101 records on disk. 
  3089.  However, the header image of the data file on disk still reads 100 records. 
  3090.  This isn't a problem, BULLET uses its internal copy of the data header and the 
  3091.  internal copy does read 101 records.  But, if there were a system failure now, 
  3092.  the image of the header would not get updated since the disk image is written 
  3093.  only on a CLOSE_ or FLUSH_DATA_XB, or on EXIT_XB (and also prior to 
  3094.  PACK_RECORDS_XB).  After the system restarts, BULLET opens the file, reads the 
  3095.  header and thinks that there are 100 records.  You lost a record.  Now, if 
  3096.  after that record add your program issues FLUSH_DATA_HEADER_XB, the header on 
  3097.  disk is refreshed with the in-memory copy, keeping the two in sync.  This 
  3098.  routine also updates the directory entry for the file, keeping things neat 
  3099.  there (file size).  Still, it doesn't come without cost: flushing takes 
  3100.  additional time, therefore, you may elect to flush periodically, or whenever 
  3101.  the system is idle. 
  3102.  
  3103.  Note:  You should have a full-lock on the file before using this routine. 
  3104.  
  3105.  
  3106. ΓòÉΓòÉΓòÉ 9.19. COPY_DATA_HEADER_XB ΓòÉΓòÉΓòÉ
  3107.  
  3108. Pack: COPYPACK                 Source Example 
  3109.  
  3110.      IN               OUT
  3111.    CP.func          CP.stat
  3112.    CP.handle
  3113.    CP.filenamePtr
  3114.  
  3115.  Copy the DBF file structure of an open data file to a new file. 
  3116.  
  3117.  This routine makes it easy for you to duplicate the structure of an existing 
  3118.  DBF file without having to specify all the information needed by 
  3119.  CREATE_DATA_XB. The resultant DBF will be exactly like the source, including 
  3120.  number of fields and field descriptions, and an empty memo file, if 
  3121.  applicable. It contains 0 records.  It may be opened as a regular Bullet data 
  3122.  file. 
  3123.  
  3124.  A typical use for this is to create a work file, where only a subset of 
  3125.  records are required.  For example:  You want to process all records of those 
  3126.  whose last name starts with A.  Copy the header to a work file, use GET_XB 
  3127.  routines to get records meeting the criterion, writing those that fit the 
  3128.  criterion to the work file (using either Add/Reindex, or Insert).  A new index 
  3129.  can be specified, or an existing index can be copied using 
  3130.  COPY_INDEX_HEADER_XB. 
  3131.  
  3132.  
  3133. ΓòÉΓòÉΓòÉ 9.20. ZAP_DATA_HEADER_XB ΓòÉΓòÉΓòÉ
  3134.  
  3135. Pack: HANDLEPACK               Source Example 
  3136.  
  3137.      IN               OUT
  3138.    HP.func          HP.stat
  3139.    HP.handle
  3140.  
  3141.  Delete all records in a DBF data file. 
  3142.  
  3143.  This routine is similar to COPY_DATA_HEADER_XB except for one major 
  3144.  difference: All data records in the source file are physically deleted.  No 
  3145.  action is performed on the DBF's memo file, if any. 
  3146.  
  3147.  If you have a DBF file with 100 records and use ZAP_DATA_HEADER_XB on it, all 
  3148.  100 records will be physically deleted and the file truncated as if no records 
  3149.  were ever in the file.  All data records are lost forever. 
  3150.  
  3151.  
  3152. ΓòÉΓòÉΓòÉ 9.21. CREATE_INDEX_XB ΓòÉΓòÉΓòÉ
  3153.  
  3154. Pack: CREATEINDEXPACK          Source Example 
  3155.  
  3156.      IN               OUT
  3157.    CIP.func         CIP.stat
  3158.    CIP.filenamePtr
  3159.    CIP.keyExpPtr
  3160.    CIP.xbLink
  3161.    CIP.sortFunction
  3162.    CIP.codePage
  3163.    CIP.countryCode
  3164.    CIP.collatePtr
  3165.    CIP.nodeSize
  3166.  
  3167.  Create a new BULLET index file. 
  3168.  
  3169.  Before you can create an index file, you must first have opened (and have 
  3170.  created if necessary) the BULLET DBF data file that it is to index. To open 
  3171.  the data file, use OPEN_DATA_XB.  To create the index file, you need to 
  3172.  provide the name to use, the key expression, the DBF file link handle 
  3173.  (obtained from the OPEN_DATA_XB call), sort function/flags, and optionally, 
  3174.  the code page, country code, and collate table.  There's also a node size 
  3175.  parameter.  Select 512, 1024, or 2048 bytes. 
  3176.  
  3177.  Note:  BULLET has an optional external data mode where only indexing is done 
  3178.  -- no data file link is used.  In this mode, BULLET manages the index files of 
  3179.  the key and key data you provide (key data is any 32-bit item, e.g., a record 
  3180.  number, offset, etc.).  This would be useful for indexing non-DBF files, even 
  3181.  files with variable-length records. 
  3182.  
  3183.  Filename 
  3184.  
  3185.  The drive and path must exist if used as part of the filename. Long filenames 
  3186.  may be used if supported by the file system in use. 
  3187.  
  3188.  Key Expression 
  3189.  
  3190.  The key expression is an ASCIIZ string composed of the elements that are to 
  3191.  make up this index file's key.  The key can be composed of any or all of the 
  3192.  fields in the DBF data record, or sub-strings within any of those fields. Up 
  3193.  to 16 component parts can be used in the expression. 
  3194.  
  3195.  Two functions are supported in evaluating a key expression. These are SUBSTR() 
  3196.  and UPPER(): 
  3197.  
  3198.  SUBSTR() extracts part of a field's data starting at a particular position for 
  3199.  x number of characters.  The first position is 1. 
  3200.  
  3201.  UPPER() converts all lower-case letters to their upper-case equivalent.  Since 
  3202.  BULLET supports NLS, UPPER() conversion is not required for proper sorting of 
  3203.  mixed-case text strings. 
  3204.  
  3205.  Any name used in the key expression must be a valid field name in the DBF data 
  3206.  file.  Below are a few sample key expressions for the given data file 
  3207.  structure: 
  3208.  
  3209.      Name  Type Len DC
  3210.     FNAME    C   25  0
  3211.     LNAME    C   25  0
  3212.     SSN      C    9  0
  3213.     DEPT     N    5  0
  3214.  
  3215.  A few example key expression strings for this structure: 
  3216.  
  3217.     keyExpression[]="LNAME";
  3218.     keyExpression[]="LNAME+FNAME";
  3219.     keyExpression[]="SUBSTR(LNAME,1,4)+SUBSTR(FNAME,1,1)+SUBSTR(SSN,6,4)";
  3220.     keyExpression[]="UPPER(LNAME+FNAME)";  // for ASCII sort function only
  3221.     keyExpression[]="DEPT+SSN";
  3222.  
  3223.  In the last example above, even though DEPT is a numeric field type (N), it 
  3224.  can still be used as a component of a multi-part character key with SSN (whose 
  3225.  type is set to character).  This because numeric fields in dBASE DBF data 
  3226.  files are ASCII digits, not binary values, and are sorted according to the 
  3227.  ASCII value or NLS weight. 
  3228.  
  3229.  The key expression is parsed when the index file is created (this routine) and 
  3230.  also when reindexed (REINDEX_XB.). The parser() function, which parses the key 
  3231.  expression, may be replaced by a programmer-supplied function if additional 
  3232.  functionality is needed.  See Custom Expression Parser Routine for details. 
  3233.  
  3234.  DBF File Link Handle (xbLink) 
  3235.  
  3236.  Since BULLET evaluates the key expression when the file is created (this 
  3237.  routine) or during reindex, it must have access to the DBF file to verify that 
  3238.  the key expression is valid.  You must, therefore, supply the OS file handle 
  3239.  of the opened DBF data file.  If you later change the structure of the DBF 
  3240.  data file (add new fields, remove others, etc.), you must use the reindex 
  3241.  routine to re-evaluate the key expression.  If the key expression is no longer 
  3242.  valid after the data file changes (key field has changed names, etc.), then 
  3243.  you must create a brand new index file with this routine, supplying the new 
  3244.  key expression, rather than reindexing. 
  3245.  
  3246.  Note:  Handles 0-2 are reserved handles and should never be used for any 
  3247.  BULLET routine.  Also, .xbLink of -1 is reserved by BULLET to indicate an 
  3248.  external data index for index create and open routines. 
  3249.  
  3250.  Sort Function 
  3251.  
  3252.  The sort function specifies the sort method for the index file. Essentially, 
  3253.  this defines the compare function used by the access methods employed by 
  3254.  BULLET when doing any type of key access (reading and writing).  There are six 
  3255.  intrinsic sort compare functions available, with an additional 10 sort compare 
  3256.  functions that can be specified by the programmer (see Custom Sort-Compare 
  3257.  Functions). 
  3258.  
  3259.  While not recommended, duplicate key values are supported and managed by 
  3260.  BULLET.  The flag DUPS_ALLOWED is OR'ed with the sort function value to 
  3261.  specify this.  Generally, it is not acceptable to allow duplicate keys for an 
  3262.  index; there should be one key identifying one record without any further 
  3263.  investigation needed to determine if the key is indeed for that record.  This 
  3264.  is not possible, not consistently so, when duplicate keys exist.  It is much 
  3265.  simpler to define your key so that duplicates are not generated, than it is to 
  3266.  deal with duplicate keys once you have them.  If an attempt to insert a key 
  3267.  that already exists in the index file is made, and DUPS_ALLOWED was not 
  3268.  specified when the index file was created, the insert fails (either a 
  3269.  STORE_KEY_XB, an INSERT_XB, or a REINDEX_XB operation), and error 
  3270.  EXB_KEY_EXISTS is returned. 
  3271.  
  3272.  Only data contained within a record should be used to build a key. The 
  3273.  physical record number is not part of the data of a record since it can change 
  3274.  at any time without you knowing about it (during a pack, for example).  Do not 
  3275.  use the record number in an attempt to generate unique keys.  Only use what is 
  3276.  available in the data record itself, so that the key can be built, or rebuilt, 
  3277.  at any time. 
  3278.  
  3279.  The intrinsic sort compare functions of BULLET are: 
  3280.  
  3281.  ASCII_SORT    1 - ASCII  (up to 16 key components) 
  3282.  NLS_SORT      2 - NLS   (up to 16 key components) 
  3283.  S16_SORT      3 - 16-bit signed integer (single component) 
  3284.  U16_SORT      4 - 16-bit unsigned integer (single component) 
  3285.  S32_SORT      5 - 32-bit signed integer (single component) 
  3286.  U32_SORT      6 - 32-bit unsigned integer (single component) 
  3287.  
  3288.  To expand on the basic functionality provided by BULLET, you can supply your 
  3289.  own parser, build, and sort compare routines, and have BULLET use them 
  3290.  instead.  With your own routines in place, you can have BULLET do just about 
  3291.  anything with regard to the index file, including evaluating the key 
  3292.  expression dynamically; using more components; allowing multi-part binary 
  3293.  keys; and more. 
  3294.  
  3295.  Generally, character data (type C) is left-justified, and unused space is 
  3296.  padded with the SPACE character (ASCII 32).  It is permissible to use C-type 
  3297.  strings, or to 0-fill unused space. 
  3298.  
  3299.  Numeric data (type N) is right-justified, with leading space to be padded with 
  3300.  the SPACE character.  It is not permissible to use 0-fill leading bytes 
  3301.  (literal '0' can used, however).  Since the field is right-justified, it is 
  3302.  not generally desirable to terminate the field with a 0 byte, either.  If a 
  3303.  decimal count is specified (not 0),the decimal point location is to be the 
  3304.  same for all entries in this field.  The field description must match the 
  3305.  actual data:  If the field length and field decimal count was specified as 
  3306.  10.2 (10 total bytes, 2 digits to the right of the decimal, then the data is 
  3307.  to be formatted so that '-234567.90' is the longest data that is to be entered 
  3308.  in that field.  All entries in all records for this field must be of the same 
  3309.  format.  For example, " 987654.21", or "   23.01", or "   -1.99" (note the 
  3310.  leading spaces).  Numeric data is indexed as ASCII values (i.e., the key 
  3311.  remains character digits) unless a binary sort function is specified. 
  3312.  
  3313.  Using one of the binary integer sort compare functions requires the following: 
  3314.  
  3315.  1.  Single component expression. 
  3316.  2.  Field type must be N if the field has ASCII digits, or if the data is 
  3317.      binary, then the field type must be Y (actually, anything but N). 
  3318.  3.  If ASCII digits, the value must fit into the function size (-32768 to 
  3319.      32767 or 0-65535 for signed/unsigned 16-bit; 2,147,483,647 to 
  3320.      -2,147,483,648 or 0-4,294,967,295 for 32-bit signed/unsigned values). 
  3321.  
  3322.  Although not dBASE compatible, you may use binary fields in your data records. 
  3323.  The Xbase standard always has ASCII data in the data fields, even if the field 
  3324.  is numeric.  For example, an 'N' type field of 8.2 (total 
  3325.  length.decimal-count) is stored as an ASCII text string in the data record, 
  3326.  say, a string like " 1100.55" (there is no \0 string terminator).  If you want 
  3327.  dBASE compatibility, your field data must be ASCII.  However, if you can forgo 
  3328.  this requirement, you can use binary values in the fields. 
  3329.  
  3330.  To do this you must specify a field type of 'Y' (actually, anything but an 
  3331.  'N') and, if it is to be used as a key field, also set the sort function to 
  3332.  the appropriate type (S16_SORT, etc.).  The field length 
  3333.  (fieldList[x].fieldLen) for a 'Y' field type is 2 if 16-bit, and 4 if 32-bit. 
  3334.  For 64-bit integers, a custom sort-copmare function is required since there is 
  3335.  no intrinsic 64-bit function available. 
  3336.  
  3337.  Note:  'B' should not be used as a binary field type marker since dBASE V uses 
  3338.  'B' to signify a binary-data memo file field.  Bullet makes no distinction in 
  3339.  its memo file data; anything can be place in them.  Typically, your memo 
  3340.  fields are marked as 'M' in Bullet, but could also be 'B' or 'G'. 
  3341.  
  3342.  The key expression string you specify may be up to 159 characters, and 
  3343.  evaluate out to 64 bytes (62 bytes if DUPS_ALLOWED is specified).  The 
  3344.  expression string must be 0-terminated, as are all strings used by BULLET 
  3345.  itself (filenames, etc.). 
  3346.  
  3347.  National Language Support (NLS) 
  3348.  
  3349.  National Language Support is available to properly sort most languages' 
  3350.  alphabets.  BULLET uses NLS to build the collate sequence table (sort table) 
  3351.  that it uses to ensure proper sorting of mixed-case keys as well as the 
  3352.  sorting of foreign language alphabets which use extended-ASCII.  In order for 
  3353.  BULLET to use the proper collate table, it must know what code page and 
  3354.  country code to use.  If not supplied, Bullet gets this information directly 
  3355.  from the OS, which provides the cc/cp for the current process.  If you supply 
  3356.  cc/cp, the code page must be loaded or an error is returned (see OS/2's CHCP 
  3357.  command).  The collate table generated is made part of the index file so that 
  3358.  all subsequent access to the index file maintains the original sort order, 
  3359.  even if, say, the MIS shop is moved to another location/computer system using 
  3360.  another country code/code page.  These three items are discussed below. 
  3361.  
  3362.  Code Page 
  3363.  
  3364.  To use the default code page of the current process, specify a code page of 0. 
  3365.  The OS is queried for the current code page and this code page is then used. 
  3366.  Any valid and available code page can be specified. This is used only if a 
  3367.  custom sort-compare or NLS sort is specified. 
  3368.  
  3369.  Country Code 
  3370.  
  3371.  To use the default country code of the current process, specify a country code 
  3372.  of 0.  The OS is queried for the current country code and this code is then 
  3373.  used.  Any valid country code can be specified.  This is used only if a custom 
  3374.  sort-compare or NLS sort is specified. 
  3375.  
  3376.  Custom Collate Table 
  3377.  
  3378.  If a null-pointer is specified, and a custom sort-compare or NLS sort is 
  3379.  specified, BULLET queries the OS for the collate sequence table to use based 
  3380.  on the code page and country code specified.  Otherwise, the supplied table is 
  3381.  used.  Intrinsic sorts other than NLS use no collate table, and the country 
  3382.  code or code page are not used, either. 
  3383.  
  3384.  To use a sort weight table of your own choosing, supply a non-NULL pointer to 
  3385.  this parameter.  If non-NULL, the passed table is used for sort compares.  The 
  3386.  table is composed of 256 weight values, one per character.  For example, table 
  3387.  position 65 ('A') and table position 97 ('a') could both be weighted 65, so 
  3388.  that that each are considered equal when sorted.  If a custom sort-compare 
  3389.  function was specified, this sort table may, or may not, be used -- it depends 
  3390.  on whether the sort compare function uses the table (it's all up to the custom 
  3391.  sort-compare function's logic). 
  3392.  
  3393.  Typically, you set both the code page and country code = 0, and the collate 
  3394.  table pointer to NULL. 
  3395.  
  3396.  Node Size 
  3397.  
  3398.  The index file is read and written in node-size chunks.  The larger the node 
  3399.  size, the more keys are read or written per chunk.  Generally, a smaller node 
  3400.  size offers better random key access, while a larger node size offers better 
  3401.  sequential key access. 
  3402.  
  3403.  Typically, an average node utilizes 66% of the node space for keys (a very 
  3404.  small number may contain only a few keys, while some may be filled 
  3405.  completely).  In a 512-byte node file, for a key length of 8, there is room 
  3406.  for (512-5)/(keylength+8) nodes, or 31 keys.  Since a typical node is filled 
  3407.  to 66%, that means about 20 keys per node.  For a 2048-byte node file, same 
  3408.  parameters, there is room for (2048-5)/(keylength+8), or 127 keys.  At the 
  3409.  standard 66% load, there are typically 83 keys per 2K node.  That's 3 more 
  3410.  keys per 2K of disk than the 512-byte node gives for 4 nodes (20 keys*4), The 
  3411.  trade-off is that each node is 4 times as large, and so requires 4 times more 
  3412.  searching.  Actual performance differences may be minimal, or may be great. 
  3413.  Run tests on expected data to determine the best for the data and access use. 
  3414.  
  3415.  
  3416. ΓòÉΓòÉΓòÉ 9.22. OPEN_INDEX_XB ΓòÉΓòÉΓòÉ
  3417.  
  3418. Pack: OPENPACK                 Source Example 
  3419.  
  3420.      IN               OUT
  3421.    OP.func          OP.stat
  3422.    OP.filenamePtr   OP.handle
  3423.    OP.asMode
  3424.    OP.xbLink
  3425.  
  3426.  Open an existing index file for use.  For index opens, three parameters are 
  3427.  specified:  the filename, the access-sharing mode, and the handle of the open 
  3428.  DBF file that this file indexes.  It is required to open the data file before 
  3429.  you can open its related index file. 
  3430.  
  3431.  Note:  Handles 0-2 are reserved handles and should never be used for any 
  3432.  BULLET routine.  Also, .xbLink of -1 is reserved by BULLET to indicate an 
  3433.  external data index for index create and open routines. 
  3434.  
  3435.  On a successful open, the file handle is returned.  Use this handle for all 
  3436.  further access to this file. 
  3437.  
  3438.  Once open, you can get information on the index file by using STAT_INDEX_XB. 
  3439.  
  3440.  Each index file that you open allocates and commits 4K bytes for internal use. 
  3441.  This memory is released when you close the file with CLOSE_INDEX_XB or issue 
  3442.  EXIT_XB, or you program terminates. 
  3443.  
  3444.  The OP.asMode has optional cache mode settings.  The caching modes cover 
  3445.  locality, write-through, and skip cache.  Locality is typically mostly random 
  3446.  (RND_LOCALITY), but may be mostly sequential if the data file has been sorted 
  3447.  and the index file recently reindexed and processing is mostly in-order (first 
  3448.  to last, rather than random).  Locality is used to tune the cache.  Also, 
  3449.  normally, data is written to the cache with control returning immediately to 
  3450.  the program before the disk is written (an asynchronous write).  To force the 
  3451.  write to take place before control is returned (a synchronous write), use the 
  3452.  WRITE_THROUGH mode.  To skip the cache completely, use the SKIP_CACHE mode. 
  3453.  This, as all OP.asMode settings, affects this file handle only. 
  3454.  
  3455.  BULLET has an optional external data mode where only indexing is done -- no 
  3456.  data file link is used.  In this mode, BULLET manages the index files of the 
  3457.  key and key data you provide (key data is any 32-bit item, e.g., a record 
  3458.  number, offset, etc.).  This would be useful for indexing non-DBF files, even 
  3459.  files with variable-length records.  Only those routines that do not access 
  3460.  the data file may be used (any routine using AP.recPtr, for example INSERT_XB, 
  3461.  could not be used, but NEXT_KEY_XB, STORE_KEY, etc., may). 
  3462.  
  3463.  
  3464. ΓòÉΓòÉΓòÉ 9.23. CLOSE_INDEX_XB ΓòÉΓòÉΓòÉ
  3465.  
  3466. Pack: HANDLEPACK               Source Example 
  3467.  
  3468.      IN               OUT
  3469.    HP.func          HP.stat
  3470.    HP.handle
  3471.  
  3472.  Close an open index file. 
  3473.  
  3474.  Closing the file updates the file header and releases the memory used by the 
  3475.  file.  Any outstanding locks should be unlocked before calling this routine. 
  3476.  
  3477.  Note:  Remaining locks belonging to this handle are released by the OS upon 
  3478.  the successful close. 
  3479.  
  3480.  
  3481. ΓòÉΓòÉΓòÉ 9.24. STAT_INDEX_XB ΓòÉΓòÉΓòÉ
  3482.  
  3483. Pack: STATINDEXPACK            Source Example 
  3484.  
  3485.      IN               OUT
  3486.    SIP.func         SIP.stat         SIP.keyLength
  3487.    SIP.handle       SIP.fileType     SIP.keyRecNo
  3488.                     SIP.flags        SIP.keyPtr
  3489.                     SIP.progress     SIP.herePtr
  3490.                     SIP.morePtr      SIP.codePage
  3491.                     SIP.xbLink       SIP.countryCode
  3492.                     SIP.asMode       SIP.CTptr
  3493.                     SIP.filenamePtr  SIP.nodeSize
  3494.                     SIP.fileID       SIP.sortFunction
  3495.                     SIP.keyExpPtr    SIP.lockCount
  3496.                     SIP.keys
  3497.  
  3498.  Return information BULLET has on the index file specified by SIP.handle. 
  3499.  
  3500.    Item             Description 
  3501.  stat               Return code of operation 
  3502.  fileType           0 for index, IX3 
  3503.  flags              Bit0=1 if file has changed since last flush (dirty) 
  3504.                     Bit1=1 if the file has its entire region locked (full lock) 
  3505.                     Bit2=1 if the file has a shared full-lock in use (cannot 
  3506.                     write to it if so) 
  3507.  progress           Percentage of reindex operation completed, 1-99, or 0 if 
  3508.                     done 
  3509.  morePtr            Always 0 
  3510.  xbLink             handle of the open DBF file this file indexes 
  3511.  asMode             Access-sharing-cache mode as specified at open 
  3512.  filenamePtr        Pointer to the filename as used in OPEN_INDEX_XB 
  3513.  fileID             '31ch' (the first four bytes of the file) 
  3514.  keyExpPtr          Pointer to the key expression used when the index was 
  3515.                     created 
  3516.  keys               Number of keys in the index file 
  3517.  keyLength          Length of the key, including 2-byte enumerator if 
  3518.                     DUPS_ALLOWED 
  3519.  keyRecNo           The DBF record number that the last accessed key indexes 
  3520.  keyPtr             Pointer to the last accessed key (valid for keyLength 
  3521.                     bytes) 
  3522.  herePtr            Pointer to the internal data control for this file 
  3523.  codePage           Code page used when the index file was created (the actual 
  3524.                     code page) 
  3525.  countryCode        Country code used when the index file was created (the 
  3526.                     actual country code) 
  3527.  CTptr              Pointer to the collate sequence table used for NLS sorting 
  3528.                     (each index file has its own sequence table) or NULL if not 
  3529.                     an NLS index 
  3530.  nodeSize           Size of an index node, 512, 1024, or 2048 bytes, as 
  3531.                     specified during create 
  3532.  sortFunction       The index sort-compare method (low word) and the sort flags 
  3533.                     (high word), with sort-compare values 1-9 being intrinsic, 
  3534.                     and 10-19 being custom functions; the DUPS_ALLOWED flag is 
  3535.                     bit0 of the high word (allowed if set) 
  3536.  lockCount          Number of full-locks in force (locked on first, unlocked on 
  3537.                     last) 
  3538.  
  3539.  Typically, your program tracks whether a particular handle belongs to an index 
  3540.  file or a data file.  In cases where this is not possible, call the 
  3541.  STAT_HANDLE_XB routine to determine what file type a handle is. 
  3542.  
  3543.  Note:  In network environments, you should have an exclusive lock on the index 
  3544.  file before using this routine to ensure that the information is current. 
  3545.  This routine is not mutex-protected.  During the call, the file handle must 
  3546.  not be closed by another thread. 
  3547.  
  3548.  
  3549. ΓòÉΓòÉΓòÉ 9.25. READ_INDEX_HEADER_XB ΓòÉΓòÉΓòÉ
  3550.  
  3551. Pack: HANDLEPACK               Source Example 
  3552.  
  3553.      IN               OUT
  3554.    HP.func          HP.stat
  3555.    HP.handle
  3556.  
  3557.  Reload the disk copy of the index header for the opened index file handle, 
  3558.  refreshing the in-memory copy. 
  3559.  
  3560.  Normally, this routine is not called directly but rather is done automatically 
  3561.  when you full-lock the file (LOCK_XB).  This routine does not refresh the 
  3562.  header if the current state is dirty (SIP.flags, bit0=1); it returns an error 
  3563.  if tried. Since it is recommended that a full-lock be in force before using 
  3564.  this routine (shared or exclusive), and since a full-lock always reloads the 
  3565.  header anyway, calling this routine should never be required.  If ever there 
  3566.  is a reason to use this routine without having a full-lock in force, then, of 
  3567.  course, you may need to.  However, it is not wise to reload the header without 
  3568.  a full-lock (which locks the header).  If you are using your own lock 
  3569.  routines, this call will be very useful. 
  3570.  
  3571.  In single-user, single-tasking systems this routine is not needed.  However, 
  3572.  in a multi-user or multi-tasking system it's possible, and desirable, for two 
  3573.  or more programs to use the same data file.  Consider this scenario: An index 
  3574.  file has 100 keys.  Two programs access this index file, both opening it. 
  3575.  Program 1 locks the file, adds a new key, then flushes and unlocks the file. 
  3576.  Program 1 knows that there are now 101 keys in the file.  However, Program 2 
  3577.  is not aware of the changes that Program 1 made--it thinks that there are 
  3578.  still 100 keys in the file.  This out-of-sync situation is easily remedied by 
  3579.  having Program 2 reload the index header from the file on disk. 
  3580.  
  3581.  How does Program 2 know that it needs to reload the header? It doesn't. 
  3582.  Instead, BULLET uses a simple, yet effective, approach when dealing with this. 
  3583.  When BULLET full-locks a file, it automatically reloads the header using this 
  3584.  routine.  When removing the full-lock, BULLET automatically flushes the header 
  3585.  using FLUSH_INDEX_HEADER_XB (unless the current lock is a shared lock 
  3586.  (SIP.flags bit2=1)). 
  3587.  
  3588.  
  3589. ΓòÉΓòÉΓòÉ 9.26. FLUSH_INDEX_HEADER_XB ΓòÉΓòÉΓòÉ
  3590.  
  3591. Pack: HANDLEPACK               Source Example 
  3592.  
  3593.      IN               OUT
  3594.    HP.func          HP.stat
  3595.    HP.handle
  3596.  
  3597.  Write the in-memory copy of the index header for the opened index file handle 
  3598.  to disk.  The actual write occurs only if the header has been changed. This 
  3599.  ensures that the index header on disk matches exactly the index header that is 
  3600.  being maintained by BULLET. 
  3601.  
  3602.  Normally, this routine is not called directly but rather is done automatically 
  3603.  when you unlock the file (UNLOCK_XB).  This routine does not write out the 
  3604.  header if the current lock state is shared (SIP.flags, bit2=1); it returns an 
  3605.  error if tried.  Unlocking a full-lock performs a flush automatically, and so 
  3606.  you may never need to explicitly call this routine.  Also, when relocking from 
  3607.  an exclusive full-lock to a shared full-lock, an automatic flush is performed. 
  3608.  
  3609.  Assume the following: An index file with 100 keys.  Your program opens the 
  3610.  index file and adds 1 key.  Physically, there are 101 keys on disk.  However, 
  3611.  the header image of the index file on disk still reads 100 keys.  This isn't a 
  3612.  problem; BULLET uses its in-memory copy of the index header and the in-memory 
  3613.  copy does read 101 keys.  But, if there were a system failure after the key 
  3614.  add, the disk image of the header would not get updated since the disk image 
  3615.  is written only on a CLOSE_ or FLUSH_INDEX_XB, or on EXIT_XB (and also prior 
  3616.  to REINDEX_XB).  After the system restarts, BULLET opens the file, reads the 
  3617.  header and thinks that there are 100 keys.  You lost a key.  Now, if after 
  3618.  that key was added, your program issues a FLUSH_INDEX_HEADER_XB, the header on 
  3619.  disk is refreshed with the in-memory copy, keeping the two in sync.  The 
  3620.  routine updates the directory entry, keeping things neat there as well (file 
  3621.  size).  Still, it doesn't come without cost: flushing will take additional 
  3622.  time, therefore, you may elect to flush periodically, or whenever the system 
  3623.  is idle. 
  3624.  
  3625.  Note:  You should have a full-lock on the file before using this routine. 
  3626.  
  3627.  
  3628. ΓòÉΓòÉΓòÉ 9.27. COPY_INDEX_HEADER_XB ΓòÉΓòÉΓòÉ
  3629.  
  3630. Pack: COPYPACK                 Source Example 
  3631.  
  3632.      IN               OUT
  3633.    CP.func          CP.stat
  3634.    CP.handle
  3635.    CP.filenamePtr
  3636.  
  3637.  Copy the index file structure of an open index file to another file. 
  3638.  
  3639.  This routine duplicates the structure of an existing index file without having 
  3640.  to re-specify the information needed by CREATE_INDEX_XB. The resultant index 
  3641.  file will be exactly like the source, including sort function and key 
  3642.  expression.  It contains 0 keys. 
  3643.  
  3644.  
  3645. ΓòÉΓòÉΓòÉ 9.28. ZAP_INDEX_HEADER_XB ΓòÉΓòÉΓòÉ
  3646.  
  3647. Pack: HANDLEPACK               Source Example 
  3648.  
  3649.      IN               OUT
  3650.    HP.func          HP.stat
  3651.    HP.handle
  3652.  
  3653.  Delete all keys from an index file. 
  3654.  
  3655.  This routine is similar to COPY_INDEX_HEADER_XB except for one major 
  3656.  difference: All keys in the source file are physically deleted. 
  3657.  
  3658.  If you have an index file with 100 keys and issue ZAP_INDEX_HEADER_XB, all 100 
  3659.  keys will be physically deleted and the file truncated to 0 keys. REINDEX_XB 
  3660.  can be used to rebuild the index file. 
  3661.  
  3662.  Note:  Since BULLET reindexes in place, the use of ZAP is not typically 
  3663.  needed. 
  3664.  
  3665.  
  3666. ΓòÉΓòÉΓòÉ 9.29. GET_DESCRIPTOR_XB ΓòÉΓòÉΓòÉ
  3667.  
  3668. Pack: DESCRIPTORPACK           Source Example 
  3669.  
  3670.      IN               OUT
  3671.    DP.func          DP.stat
  3672.    DP.handle        DP.fieldNumber
  3673.    DP.fieldNumber   DP.fieldOffset
  3674.         -or-        DP.FD.fieldName
  3675.    DP.FD.fieldName  DP.FD.fieldType
  3676.                     DP.FD.fieldLen
  3677.                     DP.FD.fieldDC
  3678.                     DP.FD.altFieldLength
  3679.  
  3680.  Get the field descriptor information for a field by fieldname or by field 
  3681.  position. 
  3682.  
  3683.  To get descriptor info by fieldname, set DP.fieldNumber=0 and set the 
  3684.  DP.FD.fieldname member to the fieldname string.  Fieldnames must be 
  3685.  0-terminated and 0-filled, and must be upper-case, with A-Z and _ valid 
  3686.  fieldname characters.  If the string matches a fieldname in the DBF descriptor 
  3687.  area, that field's descriptor info is returned in DP.FD, (FD is 
  3688.  FIELDDESCTYPE), and its position is returned in FD.fieldNumber. 
  3689.  
  3690.  To get descriptor info by field position (i.e., field number), set 
  3691.  DP.fieldNumber to the field's position.  The first is field #1. The "tag" 
  3692.  field is not considered a field.  If the position is valid (i.e., greater than 
  3693.  0 and not beyond the last field),that field's descriptor info is returned in 
  3694.  DP.FD. 
  3695.  
  3696.  This routine lets you work with unknown DBF files -- those created by another 
  3697.  program.  By reading each field descriptor, by number, from 1 to number of 
  3698.  fields (SDP.noFields), you can generate a run-time layout of the DBF file. 
  3699.  Alternatively, you can get input from your user for a fieldname, and locate 
  3700.  the descriptor by name. 
  3701.  
  3702.  Note:  If you need to add or delete a field, be sure to reindex all related 
  3703.  index files so that their key expressions can be re-evaluated. To do this, you 
  3704.  need to create a new data file and build it as you build any other new data 
  3705.  file.  Then, copy record-by-record from the old DBF to the new, using the old 
  3706.  record layout for reads, and the new record layout for writes.  After this, 
  3707.  reindex any index file related to the DBF file.  The old DBF file can then be 
  3708.  deleted. 
  3709.  
  3710.  If non-standard fields are used (i.e., non-char structure members to match 
  3711.  non-ASCII data fields in your non-standard DBF), then be aware that your 
  3712.  compiler more than likely will add padding to align on member-size boundaries. 
  3713.  This will result in a mis-match between your compiler structure and your DBF 
  3714.  structure (as described in fieldList[]).  To prevent this, place #pragma 
  3715.  pack(1) / #pragma pack() around your structures that BULLET uses.  Consult 
  3716.  your particular compiler for alternate methods if it does not support #pragma 
  3717.  pack. 
  3718.  
  3719.  
  3720. ΓòÉΓòÉΓòÉ 9.30. GET_RECORD_XB ΓòÉΓòÉΓòÉ
  3721.  
  3722. Pack: ACCESSPACK               Source Example 
  3723.  
  3724.      IN               OUT
  3725.    AP.func          AP.stat
  3726.    AP.handle        *AP.recPtr
  3727.    AP.recNo
  3728.    AP.recPtr
  3729.  
  3730.  Get the physical record from the data file into a data buffer. 
  3731.  
  3732.  The data buffer is typically a struct variable defined as the DBF record 
  3733.  itself is defined.  For example, if the DBF record has 2 fields, LNAME and 
  3734.  FNAME, each 25 characters, then then variable would be typed as: 
  3735.  
  3736.   struct rectype {
  3737.    CHAR  tag;             /* The Xbase DBF delete flag (must be included) */
  3738.    CHAR  lastName[25];    /* same length as first field's descriptor fieldLen */
  3739.    CHAR  firstName[25];   /* same length as second field's descriptor fieldLen */
  3740.   }; /* 51 */
  3741.   struct rectype recbuff;
  3742.  
  3743.  The first record is at AP.recNo=1.  The last is SDP.records, determined by 
  3744.  STAT_DATA_XB.  The buffer must be at least as large as the record length 
  3745.  (SDP.recordLength). 
  3746.  
  3747.  This method of accessing the data file does not use any indexing.  Generally, 
  3748.  this access method is not used except for special purposes (sequential 
  3749.  processing where order is not required).  The preferred method to access the 
  3750.  data is by one of the keyed GET_XB routines. 
  3751.  
  3752.  If non-standard fields are used (i.e., non-char structure members to match 
  3753.  non-ASCII data fields in your non-standard DBF), then be aware that your 
  3754.  compiler more than likely will add padding to align on member-size boundaries. 
  3755.  This will result in a mis-match between your compiler structure (rectype 
  3756.  above) and your DBF structure (as described in fieldList[]).  To prevent this, 
  3757.  place #pragma pack(1) / #pragma pack() around your structures that BULLET 
  3758.  uses.  Consult your particular compiler for alternate methods if it does not 
  3759.  support #pragma pack. 
  3760.  
  3761.  
  3762. ΓòÉΓòÉΓòÉ 9.31. ADD_RECORD_XB ΓòÉΓòÉΓòÉ
  3763.  
  3764. Pack: ACCESSPACK               Source Example 
  3765.  
  3766.      IN               OUT
  3767.    AP.func          AP.stat
  3768.    AP.handle        AP.recNo
  3769.    AP.recPtr
  3770.  
  3771.  Append the data record in the data buffer to the end of the DBF file. 
  3772.  
  3773.  This method of adding a record involves no indexing.  It is typically used to 
  3774.  build a data file en masse.  Indexing is deferred until all records have been 
  3775.  added, and then quickly indexed using REINDEX_XB. 
  3776.  
  3777.  Since ADD_RECORD_XB is extremely fast, if you have several thousand data 
  3778.  records to be added at once, appending records with this routine and 
  3779.  reindexing when all have been added using REINDEX_XB is often faster than 
  3780.  using INSERT_XB for each record to add. 
  3781.  
  3782.  The record number assigned to the record appended is determined by BULLET, and 
  3783.  that record number is returned in AP.recNo. 
  3784.  
  3785.  If non-standard fields are used (i.e., non-char structure members to match 
  3786.  non-ASCII data fields in your non-standard DBF), then be aware that your 
  3787.  compiler more than likely will adding padding to align on member-size 
  3788.  boundaries.  This will result in a mis-match between your compiler structure 
  3789.  and your DBF structure (as described in fieldList[]).  To prevent this, place 
  3790.  #pragma pack(1) / #pragma pack() around your structures that BULLET uses. 
  3791.  Consult your particular compiler for alternate methods if it does not support 
  3792.  #pragma pack. 
  3793.  
  3794.  
  3795. ΓòÉΓòÉΓòÉ 9.32. UPDATE_RECORD_XB ΓòÉΓòÉΓòÉ
  3796.  
  3797. Pack: ACCESSPACK               Source Example 
  3798.  
  3799.      IN               OUT
  3800.    AP.func          AP.stat
  3801.    AP.handle
  3802.    AP.recNo
  3803.    AP.recPtr
  3804.  
  3805.  Write the updated data record to the physical record number. 
  3806.  
  3807.  This method of updating a data record must not be used if any field being used 
  3808.  as a key field (i.e., part of the key expression) is changed. 
  3809.  
  3810.  This method of updating a record is very fast if you know that that update is 
  3811.  not going to alter any field used as a key in any index file that uses it. You 
  3812.  must, of course, first get the data record into the record buffer.  You can 
  3813.  then change it, and write the update out to disk using this routine. 
  3814.  
  3815.  If you need to change a field that is used as a key field, or part of one 
  3816.  (e.g., SUBSTR()), use the UPDATE_XB routine. 
  3817.  
  3818.  If you plan on reindexing with REINDEX_XB immediately after using this 
  3819.  routine, you may elect to update the data file using this method even if 
  3820.  changing any field used as a key, rather than UPDATE_XB.  This since UPDATE_XB 
  3821.  is very disk intensive.  However, if transaction support is needed (i.e., 
  3822.  updates are dependent on other updates), then UPDATE_XB should be used. 
  3823.  
  3824.  
  3825. ΓòÉΓòÉΓòÉ 9.33. DELETE_RECORD_XB ΓòÉΓòÉΓòÉ
  3826.  
  3827. Pack: ACCESSPACK               Source Example 
  3828.  
  3829.      IN               OUT
  3830.    AP.func          AP.stat
  3831.    AP.handle
  3832.    AP.recNo
  3833.  
  3834.  Tag the record at the physical record number as being deleted. 
  3835.  
  3836.  This does not tag any in-memory copies of the record so be sure to mark any 
  3837.  such copies as being deleted yourself. 
  3838.  
  3839.  The first byte of every DBF record is reserved for the tag field.  This tag is 
  3840.  a space (ASCII 32) if the record is normal, or a * (ASCII 42) if it's marked 
  3841.  as being deleted.  This delete tag is a reserved field in the DBF record and 
  3842.  as such is not defined as a formal field with a descriptor.  Make sure that 
  3843.  you define your in-memory buffers to reserve the first byte for the delete 
  3844.  tag. 
  3845.  
  3846.  The Xbase DBF standard doesn't physically remove records marked as deleted 
  3847.  from the data file.  It doesn't mark them as available/reusable either.  To 
  3848.  physically remove records marked as deleted use PACK_RECORDS_XB 
  3849.  
  3850.  Records can be temporarily marked as deleted during processing and then 
  3851.  recalled to normal status when completed, useful for flagging a record as 
  3852.  having been processed (for example, mass updating using UPDATE_XB).  The 
  3853.  GET_XB routines return the record number associated with a key (in AP.recNo), 
  3854.  and that record number can be used for this routine. 
  3855.  
  3856.  While the DELETE_RECORD_XB and UNDELETE_RECORD_XB routines provided in BULLET 
  3857.  use the * and SPACE characters only, you can use whatever character you want 
  3858.  in the tag field when you fill your record buffer structure's data.  Normally, 
  3859.  you set the tag field to SPACE (x.tag = ' ';), but, for example, if you want 
  3860.  to implement your own, program-level locking you can use the tag field as a 
  3861.  marker to indicate the record is locked (by using an 'L' character, or ID with 
  3862.  bit7=1, or whatever you can think of) and use the very fast UPDATE_RECORD_XB 
  3863.  to set it.  Another possibility is set to aside a field to be used as this, 
  3864.  say, along with the user ID of the lock owner. 
  3865.  
  3866.  The SKIP_TAG_SELECT item in SET_SYSVARS_XB can be set to have the REINDEX_XB 
  3867.  routine not place a key value into the index file if a record has a matching 
  3868.  tag field.  This may be useful if you want to, say, generate an ad hoc index 
  3869.  for only undeleted records. 
  3870.  
  3871.  
  3872. ΓòÉΓòÉΓòÉ 9.34. UNDELETE_RECORD_XB ΓòÉΓòÉΓòÉ
  3873.  
  3874. Pack: ACCESSPACK               Source Example 
  3875.  
  3876.      IN               OUT
  3877.    AP.func          AP.stat
  3878.    AP.handle
  3879.    AP.recNo
  3880.  
  3881.  Tag the record at the physical record number as being normal (not deleted). 
  3882.  
  3883.  This does not tag any in-memory copies of the record so be sure to mark any 
  3884.  such copies as being normal. 
  3885.  
  3886.  This routine removes the * character, as put there by DELETE_RECORD_XB, in the 
  3887.  tag field and replaces it with a SPACE.  The tag field is always overwritten 
  3888.  with a SPACE, regardless of what it was. 
  3889.  
  3890.  
  3891. ΓòÉΓòÉΓòÉ 9.35. DEBUMP_RECORD_XB ΓòÉΓòÉΓòÉ
  3892.  
  3893. Pack: ACCESSPACK               Source Example 
  3894.  
  3895.      IN               OUT
  3896.    AP.func          AP.stat
  3897.    AP.handle
  3898.    AP.recNo
  3899.  
  3900.  Remove the record identified by AP.recNo from the data file if and only if the 
  3901.  record is the last in the file.  The file is automatically flushed before 
  3902.  debumping. 
  3903.  
  3904.  Unlike DELETE_RECORD_XB, this routine physically removes a data record from 
  3905.  the DBF file, provided that the record to delete is the last. STAT_DATA_XB can 
  3906.  be used to identify the last record number (SDP.records is the last).  This, 
  3907.  when used after deleting any and all keys in all index files referencing this 
  3908.  record (see DELETE_KEY_XB), is useful if you are managing a transaction log 
  3909.  and need to back out changes made, beyond what BULLET performs. 
  3910.  
  3911.  If the record is not the last, alternate methods must be used. The simplest, 
  3912.  and often equally as good as physically deleting the record, is to just mark 
  3913.  the record as deleted using DELETE_RECORD_XB and let it remain in the file 
  3914.  until the next PACK_RECORDS_XB.  Another option is to overwrite the record's 
  3915.  data with SPACES, or other appropriate field data (such as HIGH-VALUES, and 
  3916.  use UPDATE_XB), if necessary.  This routine is the only method available to 
  3917.  physically remove a record from the file, short of using PACK_RECORDS_XB. 
  3918.  Removing a record with active keys referencing that record will result in an 
  3919.  access error (ERR_UNEXPECTED_EOF) when accessing that key with GET_XB 
  3920.  routines, or will generate stale results.  Remove any keys that reference this 
  3921.  record before deleting it. 
  3922.  
  3923.  
  3924. ΓòÉΓòÉΓòÉ 9.36. PACK_RECORDS_XB ΓòÉΓòÉΓòÉ
  3925.  
  3926. Pack: ACCESSPACK               Source Example 
  3927.  
  3928.      IN               OUT
  3929.    AP.func          AP.stat
  3930.    AP.handle
  3931.  
  3932.  Rebuild the open DBF file by physically removing all records marked as 
  3933.  deleted. 
  3934.  
  3935.  Packing occurs in place using the existing file.  It is recommended that you 
  3936.  use BACKUP_FILE_XB to copy the current DBF file before using this routine in 
  3937.  case of a failure during the pack process. 
  3938.  
  3939.  The newly packed file is truncated to reflect the current, actual size.  All 
  3940.  records with the tag field set to * are removed from the file. 
  3941.  
  3942.  If there are index files for this DBF file, they must be reindexed after the 
  3943.  pack process by using REINDEX_XB. 
  3944.  
  3945.  Memo files are not affected by this routine.  Before packing, it is 
  3946.  recommended that you traverse the data file to be packed, and for records that 
  3947.  are to be deleted, check to see if there is a memo record. If there is, delete 
  3948.  the memo.  Do this for each such occurrence.  This way, orphaned memo records 
  3949.  will not take up permanent space in the memo file. 
  3950.  
  3951.  
  3952. ΓòÉΓòÉΓòÉ 9.37. GET_MEMO_SIZE_XB ΓòÉΓòÉΓòÉ
  3953.  
  3954. Pack: MEMODATAPACK             Source Example 
  3955.  
  3956.      IN               OUT
  3957.    MDP.func         MDP.stat
  3958.    MDP.dbfHandle    MDP.memoBytes
  3959.    MDP.memoNo
  3960.  
  3961.  Get the number of bytes used by the memo at MDP.memoNo. 
  3962.  
  3963.  Memo file allocation is made in blocks, typically of 512 bytes each. 
  3964.  Therefore, a memo of 10 bytes uses 1 allocation block, as would a 500-byte 
  3965.  memo.  This size is stored with each memo record, and can be retrieved. 
  3966.  Before accessing a memo record, it's a good idea to retrieve the current size 
  3967.  of the memo so you know how large a buffer you may need if you intend to read 
  3968.  it all in, at one time, or even to just know how much to read, in total, 
  3969.  reading parts of it at a time. 
  3970.  
  3971.  The first memo is at MDP.memoNo=1.  The last memo number cannot be easily 
  3972.  determined, but generally this does not need to be known.  The memo number 
  3973.  identifying the memo's location is stored in the memo field area of the DBF 
  3974.  record.  It is stored as a text string (e.g., "0000000001") -- this is not a C 
  3975.  string; there is no zero terminator so sprintf() should be used.  This number 
  3976.  is the physical block number at which the memo starts.  Memos are always 
  3977.  stored in consecutive blocks, if more than a single block is needed.  For 
  3978.  example, a memo of 513 bytes uses two blocks, say, #1 and #2.  The next memo 
  3979.  added would use memo #3 (if #3 is available), rather than #2 since #2 was used 
  3980.  by the first memo.  Memo numbers may be reassigned (see UPDATE_MEMO_XB).  The 
  3981.  highest possible memo number is 589,822 (0x8FFFE).  With the standard 512-byte 
  3982.  block size, this allows a memo file to be up to 288MB.  If more memo data 
  3983.  space is needed, use a larger block size (e.g., 2KB block size allows over 1GB 
  3984.  per memo file). 
  3985.  
  3986.  Notice For All Memo Routines 
  3987.  
  3988.  In multitasking environments you should have a full-lock on the DBF file that 
  3989.  owns this memo file, or at least a record lock on the record that owns the 
  3990.  memo number.  In BULLET, locking is not performed on the memo file.  Instead, 
  3991.  the lock is implied when the lock is made on the DBF file.  This because a 
  3992.  memo file is for one DBF file alone, and so if you have a lock on the DBF 
  3993.  before accessing the memo file (for whatever reason), then no other process 
  3994.  may lock the DBF and also access the memo. 
  3995.  
  3996.  This works only if you restrict your access to the memo file if you have a 
  3997.  lock on the DBF master file (the DBF that this DBT memo file belongs to) or on 
  3998.  the DBF record.  For this routine, which only requires access to this memo 
  3999.  record, a record lock is sufficient since no writing is performed.  Further, a 
  4000.  shared lock is all that is required.  This because all that is required to 
  4001.  keep from stepping on other process's toes is that it be known that the 
  4002.  current memo header info (for this memo record), as known to this process, is 
  4003.  the current state of this memo.  In other words, it must be true that the memo 
  4004.  file state on disk exactly matches the memo file state in memory.  With a lock 
  4005.  in place, no other process may gain write access to change this memo, "out 
  4006.  from under you".  A shared lock does allow the other process to read this 
  4007.  memo, and that may be used if no writing is needed. 
  4008.  
  4009.  Each memo routine following states its lock requirements (exclusive full lock, 
  4010.  shared full lock, exclusive record lock, or shared record lock). 
  4011.  
  4012.  
  4013. ΓòÉΓòÉΓòÉ 9.38. GET_MEMO_XB ΓòÉΓòÉΓòÉ
  4014.  
  4015. Pack: MEMODATAPACK             Source Example 
  4016.  
  4017.      IN               OUT
  4018.    MDP.func         MDP.stat
  4019.    MDP.dbfHandle    *MDP.memoPtr
  4020.    MDP.memoNo       MDP.memoBytes
  4021.    MDP.memoPtr
  4022.    MDP.memoOffset
  4023.    MDP.memoBytes
  4024.  
  4025.  Read the specified number of bytes of the memo, starting at the offset, into 
  4026.  the buffer.  The actual number of bytes read is returned. 
  4027.  
  4028.  Use GET_MEMO_SIZE_XB to determine that total number of bytes you may need to 
  4029.  read.  With that, you can allocate a buffer of that size to read the entire 
  4030.  memo into.  Or, you can read chunks of the memo at a time, up to the number of 
  4031.  bytes in the memo. 
  4032.  
  4033.  The number of bytes actually read (and stored starting at MDP.memoPtr) is 
  4034.  returned in MDP.memoBytes (overwriting the value you placed there).  If the 
  4035.  number of bytes requested is not the same as the number of bytes returned, you 
  4036.  attempted to read beyond the end of the memo.  BULLET does not return an error 
  4037.  if you try this, which is SOP for file reads, so check the two if you need to 
  4038.  verify this.  An error is returned, however, if you attempt to read at a 
  4039.  starting offset beyond the end of the actual memo data (i.e., MDP.memoOffset > 
  4040.  memo's data size).  The first byte of the memo data is at .memoOffset=0. 
  4041.  
  4042.  It's recommended that a lock be in force on either the DBF (full-lock) or on 
  4043.  the record that this memo belongs to.  A shared lock is okay since no writing 
  4044.  is done. 
  4045.  
  4046.  
  4047. ΓòÉΓòÉΓòÉ 9.39. ADD_MEMO_XB ΓòÉΓòÉΓòÉ
  4048.  
  4049. Pack: MEMODATAPACK             Source Example 
  4050.  
  4051.      IN               OUT
  4052.    MDP.func         MDP.stat
  4053.    MDP.dbfHandle    MDP.memoNo
  4054.    MDP.memoPtr
  4055.    MDP.memoBytes
  4056.  
  4057.  Add the data from the buffer for the specified bytes to a new memo.  The memo 
  4058.  number used is returned. 
  4059.  
  4060.  Any data can be stored in a memo.  The memo number returned can be any value; 
  4061.  it can even be less than the previous add's memo number.  The reason for this 
  4062.  is that an avail-list is kept for the memo file, and any deleted or otherwise 
  4063.  freed blocks become available for re-use.  The memo is stored in the first 
  4064.  contiguous group of free blocks large enough to satisfy the request.  For 
  4065.  example, if MDP.memoBytes is from 1 to (blockSize-8) bytes, the first 
  4066.  available block is used.  If the size needed is greater than 1 block, then the 
  4067.  avail-list is walked and the first contiguous group large enough to satisfy 
  4068.  the request is used.  If none of the avail-list groups is large enough, 
  4069.  ultimately, the new memo data is appended to the end of the file.  This is 
  4070.  also done if there are no avail-list items at all, such as in a memo file that 
  4071.  has never had deletes or updates. 
  4072.  
  4073.  The returned memo is a binary block number (ULONG).  This value should be 
  4074.  converted into an ASCII string (sprintf can be used) and stored in the DBF 
  4075.  data record, in the memo field.  The string should be of the form, 
  4076.  "0000000001" (for MDP.memoNo=1), with leading zeros, but no zero terminator 
  4077.  (exactly 10 bytes in size).  This data record should then be written to disk 
  4078.  using UPDATE_RECORD_XB. Since BULLET can be used in non-standard Xbase mode, 
  4079.  where binary field values can be used, you can omit the conversion from binary 
  4080.  to ASCII if a standard DBF is not required.  Likewise, when accessing a memo, 
  4081.  the conversion from ASCII to binary would not be required. 
  4082.  
  4083.  It's recommended that a lock be in force on the DBF (full-lock).  A shared 
  4084.  lock may not be used since writing to the memo file, and the DBF record, is 
  4085.  required.  A full lock is required since the memo file header is read and 
  4086.  written. 
  4087.  
  4088.  
  4089. ΓòÉΓòÉΓòÉ 9.40. UPDATE_MEMO_XB ΓòÉΓòÉΓòÉ
  4090.  
  4091. Pack: MEMODATAPACK             Source Example 
  4092.  
  4093.      IN               OUT
  4094.    MDP.func         MDP.stat
  4095.    MDP.dbfHandle    MDP.memoNo
  4096.    MDP.memoNo
  4097.    MDP.memoPtr
  4098.    MDP.memoOffset
  4099.    MDP.memoBytes
  4100.  
  4101.  Update an existing memo.  The update can overwrite current data, append new 
  4102.  data extending the current size, or it can shrink the current size. 
  4103.  
  4104.  Appending data so that the memo is extended may result in a new memo number 
  4105.  returned.  The original memo blocks are made available for reuse (deleted). 
  4106.  Shrinking will not change the memo number, but unused blocks from the shrink 
  4107.  are made available for reuse. 
  4108.  
  4109.  If you want to change anything in the memo at MDP.memoNo, locate its position 
  4110.  within the memo with MDP.memoOffset and set the size in MDP.memoBytes. The 
  4111.  first data byte of a memo is located at MDP.offset=0.  There are 8 bytes of 
  4112.  overhead per memo record (any number of blocks still has only the 8 bytes of 
  4113.  overhead), but these are transparent to any memo access you do. The bytes at 
  4114.  MDP.memoPtr overwrite the current memo data at the position specified.  For 
  4115.  example, if you want to change the first 5 bytes of the first memo, set 
  4116.  MDP.memoNo=1, MDP.memoPtr=yourNewData, MDP.memoOffset=0, and MDP.memoBytes=5. 
  4117.  On return, MDP.memoNo is going to be the same as it was before the update, 
  4118.  since you are not extending the memo size in this example.  Nothing further 
  4119.  needs to be done; the memo is updated. 
  4120.  
  4121.  If you want to add new memo data to an existing memo at MDP.memoNo, such as 
  4122.  adding another line item, or problem report paragraph, etc., set 
  4123.  MDP.memoOffset=theCurrentMemoSize (this locates to the end of the current memo 
  4124.  data), MDP.memoBytes=bytesYouWantToAppend, and MDP.memoPtr=yourDataToAppend. 
  4125.  If the old data size plus your newly added data still fits inside the last 
  4126.  memo block previously used, MDP.memoNo is returned the same as it was on 
  4127.  entry.  However, if the new data requires that more blocks be allocated, the 
  4128.  entire memo is relocated to the next contiguous block group that is large 
  4129.  enough to store the data.  That new block number is returned in MDP.memoNo, 
  4130.  and the old block number and all its blocks are placed on the top of the 
  4131.  avail-list. 
  4132.  
  4133.  If you want to shrink the size as reported by GET_MEMO_SIZE_XB from an 
  4134.  existing memo at MDP.memoNo, set MDP.memoBytes=newSizeYouWant, and 
  4135.  MDP.memoPtr=NULL.  This means that you should have, before making this shrink 
  4136.  call, updated the memo data that occurs within this new size to be the data 
  4137.  size you want to be in the memo.  For example, if you have 10 line items, say, 
  4138.  each 60 bytes long, and want to remove line item #5, you could do it by 
  4139.  reading all 10 line items to memory, moving line items #6 to 10 down one (so 
  4140.  they are now line items #5 to 9, effectively removing old line item #5), and 
  4141.  update the memo (by using memoOffset=0 and memoBytes=9*60).  After this, 
  4142.  though, you still have 10*60 bytes as the memo size (old line item #10 is now 
  4143.  at #9 and still at #10).  Since you want the size to reflect the real data in 
  4144.  the memo, set MDP.memoBytes=90, MDP.memoPtr=NULL, and update this memo number. 
  4145.  Only the memo's size is affected by this particular update.  The size 
  4146.  specified must be smaller than the original size, or an error is returned. 
  4147.  
  4148.  It's recommended that a lock be in force on the DBF (full-lock).  A record 
  4149.  lock should not be used if the update may result in blocks being moved, or the 
  4150.  memo being shrunk by a full block or more.  A shared lock may not be used 
  4151.  since writing to the memo file, and to the DBF record if MDP.memoNo is new, is 
  4152.  required. 
  4153.  
  4154.  
  4155. ΓòÉΓòÉΓòÉ 9.41. DELETE_MEMO_XB ΓòÉΓòÉΓòÉ
  4156.  
  4157. Pack: MEMODATAPACK             Source Example 
  4158.  
  4159.      IN               OUT
  4160.    MDP.func         MDP.stat
  4161.    MDP.dbfHandle
  4162.    MDP.memoNo
  4163.  
  4164.  The memo and all its blocks are made available for reuse. 
  4165.  
  4166.  Before using PACK_RECORDS_XB, you should run through all DBF records and check 
  4167.  for those records that are deleted (record.tag='*') to be sure that any memo 
  4168.  belong to those records are deleted from the memo file.  If this is not done, 
  4169.  orphaned memo records -- those that do not have a DBF record memo field 
  4170.  pointing to it, may be left in the memo file (forever!). 
  4171.  
  4172.  After deleting a memo record, update the DBF record's memo field by writing 
  4173.  <SPACES> (ASCII 32) to the memo field member.  Update this to disk with 
  4174.  UPDATE_RECORD_XB as soon as possible (and before unlocking).  A memo field 
  4175.  with no current memo record is indicated by spaces ("0000000000" should not be 
  4176.  used). 
  4177.  
  4178.  It's recommended that a lock be in force on the DBF (full-lock).  Neither a 
  4179.  record lock nor a shared lock may be used since writing to the memo file 
  4180.  header and the DBF record is required. 
  4181.  
  4182.  
  4183. ΓòÉΓòÉΓòÉ 9.42. MEMO_BYPASS_XB ΓòÉΓòÉΓòÉ
  4184.  
  4185. Pack: MEMODATAPACK             Source Example 
  4186.  
  4187.      IN               OUT
  4188.    MDP.func         MDP.stat
  4189.    MDP.dbfHandle
  4190.    MDP.memoBypass
  4191.  
  4192.  Memo files are created, opened, closed, and flushed/reloaded by their 
  4193.  corresponding DBF data file action.  To perform these tasks asynchronously, 
  4194.  this routine is used.  Bypass routines are: 
  4195.  
  4196.      MDP.memoBypass      Value
  4197.    BYPASS_CREATE_MEMO        1
  4198.    BYPASS_OPEN_MEMO          2
  4199.    BYPASS_CLOSE_MEMO         3
  4200.    BYPASS_READ_MEMO_HEADER   4
  4201.    BYPASS_FLUSH_MEMO_HEADER  5
  4202.  
  4203.  All bypass routines require the handle of the DBF file that this memo is for. 
  4204.  Nothing is returned here, except the result code.  The memo handle from the 
  4205.  open is stored internally, but is available by using STAT_DATA_XB and checking 
  4206.  SDP.memoHandle.  However, none of the BULLET memo routines use the memo handle 
  4207.  directly; all access to the memo file is through the master DBF file handle. 
  4208.  
  4209.  No data is required for input other than the DBF handle and memo bypass 
  4210.  routine to perform (see table above).  All required info is obtained from the 
  4211.  DBF file's information.  You may use an alternate block size, as set via 
  4212.  SET_SYSVARS_XB. 
  4213.  
  4214.  Generally, there is no need to call these routines using this bypass. However, 
  4215.  if you need to create a memo file anew (say, after the initial DBF was 
  4216.  created), and then open it, using these routines is the easiest way to 
  4217.  proceed. 
  4218.  
  4219.  Note:  When creating a memo via the bypass method, the file ID is altered to 
  4220.  indicate that the DBF has a DBT memo file.  The file ID is the first byte of 
  4221.  the DBF file.  The ID is changed by OR'ing 0x88h with the current file ID 
  4222.  value.  The next flush or close updates the disk image of the DBF with the new 
  4223.  file ID.  The next DBF open, then, also opens the DBT memo file created here. 
  4224.  Be sure to always keep the DBT and DBF pairs in the same directory, if moved. 
  4225.  
  4226.  Since the DBF file is already open (and must be to use any of these routines), 
  4227.  you must use the open bypass routine to open the memo if you plan on using it. 
  4228.  Either that, or close the DBF after you've create the memo file, and simply 
  4229.  re-open the DBF, which also, now, opens the DBT memo file. 
  4230.  
  4231.  The other available bypass routines: close, read, and flush, typically will 
  4232.  not be used from this bypass routine.  These operations are done automatically 
  4233.  when their corresponding DBF action is performed, and have little 
  4234.  functionality used on their own. 
  4235.  
  4236.  Before using BYPASS_READ_MEMO_HEADER or BYPASS_FLUSH_MEMO_HEADER, it's 
  4237.  recommended that a lock be in force on the DBF (full-lock). A shared lock can 
  4238.  be used for BYPASS_READ_MEMO_HEADER, but it must be a full lock. 
  4239.  
  4240.  
  4241. ΓòÉΓòÉΓòÉ 9.43. FIRST_KEY_XB ΓòÉΓòÉΓòÉ
  4242.  
  4243. Pack: ACCESSPACK               Source Example 
  4244.  
  4245.      IN               OUT
  4246.    AP.func          AP.stat
  4247.    AP.handle        AP.recNo
  4248.    AP.keyPtr        *AP.keyPtr
  4249.  
  4250.  Retrieve the first key in index order from the index file. 
  4251.  
  4252.  This routine does not access the DBF file and so does not retrieve the data 
  4253.  record.  What it does do is locate the first logical key of the index file, 
  4254.  returning it, and also returning the record number within the DBF that the key 
  4255.  indexes. 
  4256.  
  4257.  To retrieve the data record you can use the GET_RECORD_XB routine.  The 
  4258.  preferred method, however, is to use GET_FIRST_XB, which combines these 
  4259.  operations. 
  4260.  
  4261.  The key returned includes an enumerator if the index file allows duplicate 
  4262.  keys. 
  4263.  
  4264.  This routine is typically used to position the index file to the first key so 
  4265.  as to allow forward in-order access to the keys by using NEXT_KEY_XB. 
  4266.  
  4267.  If an external data file was specified in CREATE_INDEX_XB, the record number 
  4268.  returned by this routine does not refer to a DBF record, but rather is the 
  4269.  value supplied when the key was stored.  This permits index access to your 
  4270.  data files (data files which are not maintained by BULLET, but by you). 
  4271.  
  4272.  
  4273. ΓòÉΓòÉΓòÉ 9.44. EQUAL_KEY_XB ΓòÉΓòÉΓòÉ
  4274.  
  4275. Pack: ACCESSPACK               Source Example 
  4276.  
  4277.      IN               OUT
  4278.    AP.func          AP.stat
  4279.    AP.handle        AP.recNo
  4280.    AP.keyPtr
  4281.  
  4282.  Search for the exact key in the index file. 
  4283.  
  4284.  This routine does not access the DBF file and so does not retrieve the data 
  4285.  record.  What it does do is search for the key in the index, and if found, 
  4286.  returns the record number within the DBF that the key indexes.  The key must 
  4287.  be an exact match, including the enumerator word if the index file is using 
  4288.  non-unique keys. 
  4289.  
  4290.  To retrieve the data record you can use the GET_RECORD_XB routine.  The 
  4291.  preferred method, however, is to use GET_EQUAL_XB, which combines these 
  4292.  operations. 
  4293.  
  4294.  This routine returns no key in *keyPtr since, by definition, you already have 
  4295.  the key in the key buffer if this routine succeeds. 
  4296.  
  4297.  This routine finds only an exact match to the specified key (including the 
  4298.  enumerator if applicable).  However, even if the exact key is not found, the 
  4299.  index file is positioned so that a NEXT_KEY_XB retrieves the key that would 
  4300.  have followed the unmatched specified key.  For example, if the key to match 
  4301.  were "KINGS" (a partial key, say, with \0\0 after the S), EQUAL_KEY_XB would 
  4302.  return a key not found error (since no exact match was found).  If you were to 
  4303.  now do a NEXT_KEY_XB, the next key logically ordered after "KINGS" would be 
  4304.  returned.  Let's say "KINGSTON" was the next.  That key value, including 
  4305.  enumerator if any, and the key's record number is returned from the 
  4306.  NEXT_KEY_XB call.  This technique lets you position anywhere in the index file 
  4307.  to narrow down any manual searches (for instance, if you're looking for a key 
  4308.  but aren't sure of the exact spelling). 
  4309.  
  4310.  Note:  When using the partial key technique shown above, be sure to set the 
  4311.  unspecified characters of the key to \0, or at least the two bytes immediately 
  4312.  following your search criterion.  This for both unique and non-unique index 
  4313.  files.  This is to ensure that the key located is the first key matching your 
  4314.  search criterion. 
  4315.  
  4316.  
  4317. ΓòÉΓòÉΓòÉ 9.45. NEXT_KEY_XB ΓòÉΓòÉΓòÉ
  4318.  
  4319. Pack: ACCESSPACK               Source Example 
  4320.  
  4321.      IN               OUT
  4322.    AP.func          AP.stat
  4323.    AP.handle        AP.recNo
  4324.    AP.keyPtr        *AP.keyPtr
  4325.  
  4326.  Retrieve the next key in index order from the index file. 
  4327.  
  4328.  This routine does not access the DBF file and so does not retrieve the data 
  4329.  record.  What it does do is retrieve the next key of the index, returning it, 
  4330.  and also returning the record number within the DBF that the key indexes. 
  4331.  
  4332.  To retrieve the data record you can use the GET_RECORD_XB routine.  The 
  4333.  preferred method, however, is to use GET_NEXT_XB, which combines these 
  4334.  operations. 
  4335.  
  4336.  The key returned includes an enumerator if the index file allows duplicates. 
  4337.  
  4338.  This routine is typically called after the index file has first been 
  4339.  positioned to a known key using either FIRST_KEY_XB or EQUAL_KEY_XB, or after 
  4340.  a previous NEXT_KEY_XB or even PREV_KEY_XB.  What it basically does is get the 
  4341.  key following the current key, and then make that key the new current key. ________________________________________________
  4342.  
  4343.  If bit0 of the atomic mode flag of SET_SYSVARS_XB is set to 1, key access is 
  4344.  based on a given starting point.  This simplifies index access in 
  4345.  multi-threaded code, where another thread may have altered the last key 
  4346.  accessed in the index file.  This mode lets you set a starting point for the 
  4347.  operation by supplying in AP.keyPtr the key value to start at. 
  4348.  
  4349.  For example, say you use GET_FIRST_XB.  On return, AP.keyPtr has the the very 
  4350.  first key.  Say elsewhere in your multi-threaded program, another operation 
  4351.  accesses that same index file handle, and performs some other access, where 
  4352.  the last accessed key is no longer the same (i.e., not the first key).  Your 
  4353.  first thread is expecting that a GET_NEXT_XB would get the second key, 
  4354.  however, it very likely won't since the second thread has altered the last 
  4355.  accessed key for that file handle.  By using the atomic mode for key access, 
  4356.  your first thread, which has the first key value in its AP.keyPtr, can do a 
  4357.  call to GET_NEXT_XB and get expected results, since the NEXT operation first 
  4358.  positions to the value in AP.keyPtr and then follows up with a GET_NEXT 
  4359.  operation.  This is performed within the Bullet kernel, and so won't be 
  4360.  interrupted by another thread (i.e., it is an atomic operation).  For this to 
  4361.  work, you must ensure that the AP.keyPtr value is set to the value of the last 
  4362.  accessed key.  This will always be the case unless uninitialized, or you are 
  4363.  using global variables for your threads' AP (AccessPack).  On return from the 
  4364.  operation, AP.keyPtr will once again be set up for another atomic operation. 
  4365.  
  4366.  Note:  You must supply a valid key value for this atomic access mode. 
  4367.  AP.keyPtr must be at least as large as the key length in all cases, and is to 
  4368.  have the starting point for the operation (i.e., the last accessed key).  You 
  4369.  may, alternatively, set the first byte of the key buffer to 0 (but not 
  4370.  AP.keyPtr itself to NULL).  This disables atomic mode for that access, and 
  4371.  reverts to the internally-stored last key accessed as the starting point. 
  4372.  
  4373.  
  4374. ΓòÉΓòÉΓòÉ 9.46. PREV_KEY_XB ΓòÉΓòÉΓòÉ
  4375.  
  4376. Pack: ACCESSPACK               Source Example 
  4377.  
  4378.      IN               OUT
  4379.    AP.func          AP.stat
  4380.    AP.handle        AP.recNo
  4381.    AP.keyPtr        *AP.keyPtr
  4382.  
  4383.  Retrieve the previous key in index order from the index file. 
  4384.  
  4385.  This routine does not access the DBF file and so does not retrieve the data 
  4386.  record.  What it does do is retrieve the previous key of the index, returning 
  4387.  it and also returning the record number within the DBF that the key indexes. 
  4388.  
  4389.  To retrieve the data record you can use the GET_RECORD_XB routine.  The 
  4390.  preferred method, however, is to use GET_PREV_XB, which combines these 
  4391.  operations. 
  4392.  
  4393.  The key returned includes an enumerator if the index file allows duplicates. 
  4394.  
  4395.  This routine is typically called after the index file has first been 
  4396.  positioned to a known key using either LAST_KEY_XB or EQUAL_KEY_XB, or after a 
  4397.  previous PREV_KEY_XB or even NEXT_KEY_XB.  What it basically does is to get 
  4398.  the key previous the current key, and then make that key the new current key. ________________________________________________
  4399.  
  4400.  If bit0 of the atomic mode flag of SET_SYSVARS_XB is set to 1, key access is 
  4401.  based on a given starting point.  This simplifies index access in 
  4402.  multi-threaded code, where another thread may have altered the last key 
  4403.  accessed in the index file.  This mode lets you set a starting point for the 
  4404.  operation by supplying in AP.keyPtr the key value to start at. 
  4405.  
  4406.  For example, say you use GET_FIRST_XB.  On return, AP.keyPtr has the the very 
  4407.  first key.  Say elsewhere in your multi-threaded program, another operation 
  4408.  accesses that same index file handle, and performs some other access, where 
  4409.  the last accessed key is no longer the same (i.e., not the first key).  Your 
  4410.  first thread is expecting that a GET_NEXT_XB would get the second key, 
  4411.  however, it very likely won't since the second thread has altered the last 
  4412.  accessed key for that file handle.  By using the atomic mode for key access, 
  4413.  your first thread, which has the first key value in its AP.keyPtr, can do a 
  4414.  call to GET_NEXT_XB and get expected results, since the NEXT operation first 
  4415.  positions to the value in AP.keyPtr and then follows up with a GET_NEXT 
  4416.  operation.  This is performed within the Bullet kernel, and so won't be 
  4417.  interrupted by another thread (i.e., it is an atomic operation).  For this to 
  4418.  work, you must ensure that the AP.keyPtr value is set to the value of the last 
  4419.  accessed key.  This will always be the case unless uninitialized, or you are 
  4420.  using global variables for your threads' AP (AccessPack).  On return from the 
  4421.  operation, AP.keyPtr will once again be set up for another atomic operation. 
  4422.  
  4423.  Note:  You must supply a valid key value for this atomic access mode. 
  4424.  AP.keyPtr must be at least as large as the key length in all cases, and is to 
  4425.  have the starting point for the operation (i.e., the last accessed key).  You 
  4426.  may, alternatively, set the first byte of the key buffer to 0 (but not 
  4427.  AP.keyPtr itself to NULL).  This disables atomic mode for that access, and 
  4428.  reverts to the internally-stored last key accessed as the starting point. 
  4429.  
  4430.  
  4431. ΓòÉΓòÉΓòÉ 9.47. LAST_KEY_XB ΓòÉΓòÉΓòÉ
  4432.  
  4433. Pack: ACCESSPACK               Source Example 
  4434.  
  4435.      IN               OUT
  4436.    AP.func          AP.stat
  4437.    AP.handle        AP.recNo
  4438.    AP.keyPtr        *AP.keyPtr
  4439.  
  4440.  Retrieve the last key in index order from the index file. 
  4441.  
  4442.  This routine does not access the DBF file and so does not retrieve the data 
  4443.  record.  What it does do is locate the last key of the index, returning it, 
  4444.  and also returning the record number within the DBF that the key indexes. 
  4445.  
  4446.  To retrieve the data record you can use the GET_RECORD_XB routine.  The 
  4447.  preferred method, however, is to use GET_LAST_XB, which combines these 
  4448.  operations. 
  4449.  
  4450.  The key returned includes an enumerator if the index file allows duplicates. 
  4451.  
  4452.  This routine is typically used to position the index file to the last key so 
  4453.  as to allow reverse in-order access to the keys by using PREV_KEY_XB. 
  4454.  
  4455.  
  4456. ΓòÉΓòÉΓòÉ 9.48. STORE_KEY_XB ΓòÉΓòÉΓòÉ
  4457.  
  4458. Pack: ACCESSPACK               Source Example 
  4459.  
  4460.      IN               OUT
  4461.    AP.func          AP.stat
  4462.    AP.handle
  4463.    AP.recNo
  4464.    AP.keyPtr
  4465.  
  4466.  Insert the key into the index file in proper key order. 
  4467.  
  4468.  This routine does not add the data record to the DBF file.  It only inserts 
  4469.  the key and record number into the index file.  Use INSERT_XB instead. 
  4470.  
  4471.  To do a complete data record and key insert, use ADD_RECORD_XB to add the data 
  4472.  record to the DBF, BUILD_KEY_XB to construct the key, then STORE_KEY_XB to 
  4473.  insert the key and record number information into the index file.  If that key 
  4474.  already exists and the file allows duplicate keys, attach the proper 
  4475.  enumerator word and retry STORE_KEY_XB.  INSERT_XB does this automatically. 
  4476.  
  4477.  
  4478. ΓòÉΓòÉΓòÉ 9.49. DELETE_KEY_XB ΓòÉΓòÉΓòÉ
  4479.  
  4480. Pack: ACCESSPACK               Source Example 
  4481.  
  4482.      IN               OUT
  4483.    AP.func          AP.stat
  4484.    AP.handle
  4485.    AP.keyPtr
  4486.  
  4487.  Physically remove the specified key from the index file. 
  4488.  
  4489.  This routine requires an exact key match for all bytes of the key, including 
  4490.  the enumerator word if duplicate keys are allowed. 
  4491.  
  4492.  Typically, this routine would seldom be used since deleted DBF data records 
  4493.  are only physically deleted during a PACK_RECORDS_XB operation, after which a 
  4494.  REINDEX_XB is done. It is useful if you are managing a transaction log and 
  4495.  need to back out changes made, beyond what BULLET performs.  Also see 
  4496.  DEBUMP_RECORD_XB. If you have non-unique keys (where DUPS_ALLOWED is true), 
  4497.  you may have several keys that match your criterion, and only differ in their 
  4498.  enumerator.  To identify which key, then, goes to a particular DBF record, 
  4499.  compare that key's AP.recNo with the number of your DBF record.  If they are 
  4500.  the same, then this key belongs to that record.  Use either the KEY_XB or the 
  4501.  GET_XB routines, then, before using this routine.  In other words, use this 
  4502.  routine only after you have identified exactly the key to delete, and for the 
  4503.  exact data record.  Once you have the record number, you can locate its key by 
  4504.  using GET_KEY_FOR_RECORD_XB. 
  4505.  
  4506.  
  4507. ΓòÉΓòÉΓòÉ 9.50. BUILD_KEY_XB ΓòÉΓòÉΓòÉ
  4508.  
  4509. Pack: ACCESSPACK               Source Example 
  4510.  
  4511.      IN               OUT
  4512.    AP.func          AP.stat
  4513.    AP.handle        *AP.keyPtr
  4514.    AP.recPtr
  4515.    AP.keyPtr
  4516.  
  4517.  Build the key for the specified data record based on the key expression for 
  4518.  the index file.  If the index file allows duplicate keys, a 0-value enumerator 
  4519.  is attached. 
  4520.  
  4521.  This routine, like most of the mid-level routines, typically would not be used 
  4522.  since the high-level access routines take care of this detail automatically. 
  4523.  If used, it normally would be used prior to STORE_KEY_XB. 
  4524.  
  4525.  This routine can be replaced.  See Custom Build-Key Routine. 
  4526.  
  4527.  Note:  If DUPS_ALLOWED, this routine always sets the enumerator to \0\0. 
  4528.  Enumerator management, which is used to guarantee a unique key, is performed 
  4529.  only when the INSERT_XB routine is used. 
  4530.  
  4531.  
  4532. ΓòÉΓòÉΓòÉ 9.51. GET_CURRENT_KEY_XB ΓòÉΓòÉΓòÉ
  4533.  
  4534. Pack: ACCESSPACK               Source Example 
  4535.  
  4536.      IN               OUT
  4537.    AP.func          AP.stat
  4538.    AP.handle        AP.recNo
  4539.    AP.keyPtr        *AP.keyPtr
  4540.  
  4541.  Retrieve the current key value for the specified index file handle and also 
  4542.  the data record number that it indexes. The key value includes the enumerator 
  4543.  if applicable. 
  4544.  
  4545.  This routine is useful in that it retrieves, on demand, the actual key value 
  4546.  of the last accessed key in the index file (and the data record number 
  4547.  associated with that key). STAT_INDEX_XB returns this information, too. 
  4548.  
  4549.  
  4550. ΓòÉΓòÉΓòÉ 9.52. GET_KEY_FOR_RECORD_XB ΓòÉΓòÉΓòÉ
  4551.  
  4552. Pack: ACCESSPACK               Source Example 
  4553.  
  4554.      IN               OUT
  4555.    AP.func          AP.stat
  4556.    AP.handle        *AP.keyPtr
  4557.    AP.recNo
  4558.    AP.recPtr
  4559.    AP.keyPtr
  4560.  
  4561.  Retrieve the key for the record/record number pair. 
  4562.  
  4563.  This routine would typically be used prior to using DELETE_KEY_XB and 
  4564.  DEBUMP_RECORD_XB.  The key returned includes the enumerator if applicable. 
  4565.  This routine sifts through any duplicate keys (if DUPS_ALLOWED) for the key 
  4566.  that matches the record/record number pair, and so requires both the actual 
  4567.  data record along with its physical record number (even if dups are not 
  4568.  allowed). 
  4569.  
  4570.  Typically this routine is extraneous; the key is available with a GET_XB 
  4571.  routine and so can be deleted from the information provided through normal 
  4572.  access. 
  4573.  
  4574.  This routine builds a key based on the supplied record at AP.recPtr and 
  4575.  searches the index for that key proper.  If found, and if DUPS_ALLOWED, each 
  4576.  key matching the key proper has its record number compared to the record 
  4577.  number in AP.recNo.  If that matches, too, then that is the exact key being 
  4578.  sought. 
  4579.  
  4580.  
  4581. ΓòÉΓòÉΓòÉ 9.53. GET_FIRST_XB ΓòÉΓòÉΓòÉ
  4582.  
  4583. Pack: ACCESSPACK               Source Example 
  4584.  
  4585.      IN               OUT
  4586.    AP.func          AP.stat
  4587.    AP.handle        AP.recNo
  4588.    AP.recPtr        *AP.recPtr
  4589.    AP.keyPtr        *AP.keyPtr
  4590.  
  4591.  Retrieve the first indexed key and its data record. 
  4592.  
  4593.  The key returned includes an enumerator if the index file uses non-unique keys 
  4594.  (DUPS_ALLOWED). 
  4595.  
  4596.  This routine is typically used to process a database in index order starting 
  4597.  at the first ordered key (and its data record).  After processing this first 
  4598.  entry, subsequent in-order access of the database is achieved by using 
  4599.  GET_NEXT_XB, until the end of the database is reached, at which point an error 
  4600.  is returned. 
  4601.  
  4602.  This routine, like all the high-level GET_XB routines, fills in the AP.recNo 
  4603.  of the record accessed.  In this case, it fills AP.recNo with the record 
  4604.  number pointed to by the first key. Since this is done upon each GET_XB 
  4605.  access, the AP pack is primed for an UPDATE_XB 
  4606.  
  4607.  
  4608. ΓòÉΓòÉΓòÉ 9.54. GET_EQUAL_XB ΓòÉΓòÉΓòÉ
  4609.  
  4610. Pack: ACCESSPACK               Source Example 
  4611.  
  4612.      IN               OUT
  4613.    AP.func          AP.stat
  4614.    AP.handle        AP.recNo
  4615.    AP.recPtr        *AP.recPtr
  4616.    AP.keyPtr
  4617.  
  4618.  Search for the exact key in the index file and return its data record. 
  4619.  
  4620.  This routine finds only an exact match to the specified key (including the 
  4621.  enumerator if applicable).  However, even if the exact key is not found in the 
  4622.  index file, the index file is positioned so that the next GET_NEXT_XB 
  4623.  retrieves the key that would have followed the unmatched specified key.  In 
  4624.  this manner, a GET_GREATER_THAN_OR_EQUAL is easily performed.  See also 
  4625.  EQUAL_KEY_XB. 
  4626.  
  4627.  This routine, like all the high-level GET_XB routines, fills in the AP.recNo 
  4628.  of the record accessed.  In this case, it fills AP.recNo with the record 
  4629.  number pointed to by the matching key. Since this is done upon each GET_XB 
  4630.  access, the AP pack is primed for an UPDATE_XB 
  4631.  
  4632.  Note:  When using the partial key technique as described in EQUAL_KEY_XB, be 
  4633.  sure to set the unspecified characters of the key to \0, or at least the two 
  4634.  bytes immediately following your search criterion.  This for both unique and 
  4635.  non-unique index files. 
  4636.  
  4637.  
  4638. ΓòÉΓòÉΓòÉ 9.55. GET_NEXT_XB ΓòÉΓòÉΓòÉ
  4639.  
  4640. Pack: ACCESSPACK               Source Example 
  4641.  
  4642.      IN               OUT
  4643.    AP.func          AP.stat
  4644.    AP.handle        AP.recNo
  4645.    AP.recPtr        *AP.recPtr
  4646.    AP.keyPtr        *AP.keyPtr
  4647.  
  4648.  Retrieve the next indexed key and its data record. 
  4649.  
  4650.  The key returned includes an enumerator if the index file uses non-unique keys 
  4651.  (DUPS_ALLOWED). 
  4652.  
  4653.  This routine is typically called after the index file has first been 
  4654.  positioned to a known key using either GET_FIRST_XB or GET_EQUAL_XB, or after 
  4655.  a previous GET_NEXT_XB or even GET_PREV_XB.  What it basically does is get the 
  4656.  key and data record following the current key, and then makes that key the new 
  4657.  current key. 
  4658.  
  4659.  This routine, like all the high-level GET_XB routines, fills in the AP.recNo 
  4660.  of the record accessed.  In this case, it fills AP.recNo with the record 
  4661.  number pointed to by the next key (now the current key). Since this is done 
  4662.  upon each GET_XB access, the AP pack is primed for an UPDATE_XB. ________________________________________________
  4663.  
  4664.  If bit0 of the atomic mode flag of SET_SYSVARS_XB is set to 1, key access is 
  4665.  based on a given starting point.  This simplifies index access in 
  4666.  multi-threaded code, where another thread may have altered the last key 
  4667.  accessed in the index file.  This mode lets you set a starting point for the 
  4668.  operation by supplying in AP.keyPtr the key value to start at. 
  4669.  
  4670.  For example, say you use GET_FIRST_XB.  On return, AP.keyPtr has the the very 
  4671.  first key.  Say elsewhere in your multi-threaded program, another operation 
  4672.  accesses that same index file handle, and performs some other access, where 
  4673.  the last accessed key is no longer the same (i.e., not the first key).  Your 
  4674.  first thread is expecting that a GET_NEXT_XB would get the second key, 
  4675.  however, it very likely won't since the second thread has altered the last 
  4676.  accessed key for that file handle.  By using the atomic mode for key access, 
  4677.  your first thread, which has the first key value in its AP.keyPtr, can do a 
  4678.  call to GET_NEXT_XB and get expected results, since the NEXT operation first 
  4679.  positions to the value in AP.keyPtr and then follows up with a GET_NEXT 
  4680.  operation.  This is performed within the Bullet kernel, and so won't be 
  4681.  interrupted by another thread (i.e., it is an atomic operation).  For this to 
  4682.  work, you must ensure that the AP.keyPtr value is set to the value of the last 
  4683.  accessed key.  This will always be the case unless uninitialized, or you are 
  4684.  using global variables for your threads' AP (AccessPack).  On return from the 
  4685.  operation, AP.keyPtr will once again be set up for another atomic operation. 
  4686.  
  4687.  Note:  You must supply a valid key value for this atomic access mode. 
  4688.  AP.keyPtr must be at least as large as the key length in all cases, and is to 
  4689.  have the starting point for the operation (i.e., the last accessed key).  You 
  4690.  may, alternatively, set the first byte of the key buffer to 0 (but not 
  4691.  AP.keyPtr itself to NULL).  This disables atomic mode for that access, and 
  4692.  reverts to the internally-stored last key accessed as the starting point. 
  4693.  
  4694.  
  4695. ΓòÉΓòÉΓòÉ 9.56. GET_PREV_XB ΓòÉΓòÉΓòÉ
  4696.  
  4697. Pack: ACCESSPACK               Source Example 
  4698.  
  4699.      IN               OUT
  4700.    AP.func          AP.stat
  4701.    AP.handle        AP.recNo
  4702.    AP.recPtr        *AP.recPtr
  4703.    AP.keyPtr        *AP.keyPtr
  4704.  
  4705.  Retrieve the previous indexed key and its data record. 
  4706.  
  4707.  The key returned includes an enumerator if the index file uses non-unique keys 
  4708.  (DUPS_ALLOWED). 
  4709.  
  4710.  This routine is typically called after the index file has first been 
  4711.  positioned to a known key using either GET_LAST_XB or GET_EQUAL_XB, or after a 
  4712.  previous GET_PREV_XB or even GET_NEXT_XB.  What it basically does is get the 
  4713.  key and data record preceding the current key, and then makes that key the new 
  4714.  current key. 
  4715.  
  4716.  This routine, like all the high-level GET_XB routines, fills in the AP.recNo 
  4717.  of the record accessed.  In this case, it fills AP.recNo with the record 
  4718.  number pointed to by the previous key (now the current key). Since this is 
  4719.  done upon each GET_XB access, the AP pack is primed for an UPDATE_XB. ________________________________________________
  4720.  
  4721.  If bit0 of the atomic mode flag of SET_SYSVARS_XB is set to 1, key access is 
  4722.  based on a given starting point.  This simplifies index access in 
  4723.  multi-threaded code, where another thread may have altered the last key 
  4724.  accessed in the index file.  This mode lets you set a starting point for the 
  4725.  operation by supplying in AP.keyPtr the key value to start at. 
  4726.  
  4727.  For example, say you use GET_FIRST_XB.  On return, AP.keyPtr has the the very 
  4728.  first key.  Say elsewhere in your multi-threaded program, another operation 
  4729.  accesses that same index file handle, and performs some other access, where 
  4730.  the last accessed key is no longer the same (i.e., not the first key).  Your 
  4731.  first thread is expecting that a GET_NEXT_XB would get the second key, 
  4732.  however, it very likely won't since the second thread has altered the last 
  4733.  accessed key for that file handle.  By using the atomic mode for key access, 
  4734.  your first thread, which has the first key value in its AP.keyPtr, can do a 
  4735.  call to GET_NEXT_XB and get expected results, since the NEXT operation first 
  4736.  positions to the value in AP.keyPtr and then follows up with a GET_NEXT 
  4737.  operation.  This is performed within the Bullet kernel, and so won't be 
  4738.  interrupted by another thread (i.e., it is an atomic operation).  For this to 
  4739.  work, you must ensure that the AP.keyPtr value is set to the value of the last 
  4740.  accessed key.  This will always be the case unless uninitialized, or you are 
  4741.  using global variables for your threads' AP (AccessPack).  On return from the 
  4742.  operation, AP.keyPtr will once again be set up for another atomic operation. 
  4743.  
  4744.  Note:  You must supply a valid key value for this atomic access mode. 
  4745.  AP.keyPtr must be at least as large as the key length in all cases, and is to 
  4746.  have the starting point for the operation (i.e., the last accessed key).  You 
  4747.  may, alternatively, set the first byte of the key buffer to 0 (but not 
  4748.  AP.keyPtr itself to NULL).  This disables atomic mode for that access, and 
  4749.  reverts to the internally-stored last key accessed as the starting point. 
  4750.  
  4751.  
  4752. ΓòÉΓòÉΓòÉ 9.57. GET_LAST_XB ΓòÉΓòÉΓòÉ
  4753.  
  4754. Pack: ACCESSPACK               Source Example 
  4755.  
  4756.      IN               OUT
  4757.    AP.func          AP.stat
  4758.    AP.handle        AP.recNo
  4759.    AP.recPtr        *AP.recPtr
  4760.    AP.keyPtr        *AP.keyPtr
  4761.  
  4762.  Retrieve the last indexed key and its data record. 
  4763.  
  4764.  The key returned includes an enumerator if the index file uses non-unique keys 
  4765.  (DUPS_ALLOWED). 
  4766.  
  4767.  This routine is typically used to process a database in reverse index order 
  4768.  starting at the last ordered key (and its data record).  After processing this 
  4769.  last entry, subsequent reverse-order access of the database is achieved by 
  4770.  using GET_PREV_XB, until the top of the database is reached, at which point an 
  4771.  error is returned. 
  4772.  
  4773.  This routine, like all the high-level GET_XB routines, fills in the AP.recNo 
  4774.  of the record accessed.  In this case, it fills AP.recNo with the record 
  4775.  number pointed to by the last key. Since this is done upon each GET_XB access, 
  4776.  the AP pack is primed for an UPDATE_XB 
  4777.  
  4778.  
  4779. ΓòÉΓòÉΓòÉ 9.58. INSERT_XB ΓòÉΓòÉΓòÉ
  4780.  
  4781. Pack: ACCESSPACK               Source Example 
  4782.  
  4783.      IN               OUT
  4784.    AP.func          AP.stat
  4785.    AP.handle        AP.recNo
  4786.    AP.recNo         *AP.keyPtr
  4787.    AP.recPtr
  4788.    AP.keyPtr
  4789.    AP.nextPtr
  4790.  
  4791.  Append the data records to data files and build and insert the related keys 
  4792.  into all linked index files.  (Alternate forms are possible.) 
  4793.  
  4794.  This routine is used to add new entries into a database.  Up to 256 index 
  4795.  files may be inserted into per call, with up to 256 data files being added, 
  4796.  too, for a total of 512 files managed per single INSERT_XB call. 
  4797.  
  4798.  Note:  Bullet comes in 100, 250, and 1024-file versions and so this routine is 
  4799.  able to use as many files as handles are still available. If non-standard 
  4800.  fields are used (i.e., non-char structure members to match non-ASCII data 
  4801.  fields in your non-standard DBF), then be aware that your compiler more than 
  4802.  likely will add padding to align on member-size boundaries.  This will result 
  4803.  in a mis-match between your compiler structure (rectype above) and your DBF 
  4804.  structure (as described in fieldList[]).  To prevent this, place #pragma 
  4805.  pack(1) / #pragma pack() around your structures that BULLET uses.  Consult 
  4806.  your particular compiler for alternate methods if it does not support #pragma 
  4807.  pack. 
  4808.  
  4809.  Only index handles are listed in AP.handle.  Each index file has associated 
  4810.  with it a data file, known internally to BULLET (the xbLink from OPEN_XB). 
  4811.  There may be more than one index file for a data file, but there is always one 
  4812.  data file per index handle specified in the list.  In other words, you can 
  4813.  list five index files, each indexing the same xbLink data file, and have 
  4814.  BULLET perform an atomic insert of that list.  Or, another possibility is that 
  4815.  you have a single index file, indexing a single data file.  Or, you can list 
  4816.  256 index files, each indexing a single data file (512 total files). 
  4817.  
  4818.  This, and several other routines, are transaction-list-based.  This means that 
  4819.  if a failure occurs prior to the routine's completion, all changes made to the 
  4820.  database by the routine will be backed-out, and the database (data and index 
  4821.  files) effectively restored to its original state. 
  4822.  
  4823.  If the routine failed to complete, the function return value is the number 
  4824.  (1-based) of the pack that caused the failure.  A positive number indicates 
  4825.  the failure was from an index operation; a negative number indicates the 
  4826.  failure was from a data operation.  In each case, the absolute value of the 
  4827.  return code is the list item that failed (the pack index).  For example, if 
  4828.  five index handles are in the list (AP[0] to AP[4]), and an error occurred on 
  4829.  the last pack's index file, the return code would be positive 5, indicating 
  4830.  the fifth pack (AP[4]) failed.  Since it was a positive 5, the index file was 
  4831.  being processed when the error occurred.  Being processed means not only 
  4832.  physical access, but verification, etc.  If the return code was -5, then 
  4833.  again, the error was in the fifth pack, but since it is negative, the error 
  4834.  occurred while processing the data file.  In either case, upon return, the 
  4835.  database is effectively restored to the way it was before the INSERT_XB call 
  4836.  was made.  Remedy the error, if possible, and INSERT_XB again. 
  4837.  
  4838.  Each pack must include a separate key buffer.  You must not share a common key 
  4839.  buffer.  Doing so disables any chance of recovering the index files in case of 
  4840.  error, since it is in these buffers that BULLET places the newly built keys, 
  4841.  and it is from these that BULLET, upon an error condition, deletes the keys 
  4842.  (required for roll-back). 
  4843.  
  4844.  The enumerator is automatically set up by this routine, if required 
  4845.  (DUPS_ALLOWED and the key already exists with enumerator 0).  It does this by 
  4846.  seeking the last possible enumerator value (0xFFFF) and then backing up to the 
  4847.  previous key.  That key's enumerator is evaluated and incremented, and used as 
  4848.  this key's. 
  4849.  
  4850.  Specifying Files 
  4851.  
  4852.  As mentioned, only the index file handles are specified in AP.handle. Data 
  4853.  files are implicitly specified by their links to the index files, as specified 
  4854.  when the index file was opened (OP.xbLink).  INSERT_XB can process up to 256 
  4855.  index files per call.  Since each index file requires a data file, this means 
  4856.  that up to 256 data files can be processed per call, as well.  Also possible 
  4857.  is that all 256 index handles refer to the same, single data file.  Yet 
  4858.  another possibility is that there is 1 index file, and so 1 data file.  The 
  4859.  possibilities can include those and anything in between. 
  4860.  
  4861.  Example: Specifying a single index file 
  4862.  
  4863.  The simplest form is where a single index handle is specified.  This implies a 
  4864.  single data file, too.  AccessPack setup for this is: 
  4865.  
  4866.   AP.func = INSERT_XB;
  4867.   AP.handle = indexHandle;
  4868.   AP.recNo = 0;
  4869.   AP.recPtr = &recordStruct; // contents referred to below as *recordStruct
  4870.   AP.keyPtr = keyBuffer;
  4871.   AP.nextPtr = NULL;
  4872.  
  4873.  A call to BULLET with the above does the following: 
  4874.  
  4875.    1. The data in *recordStruct is used as a new record that is appended to the 
  4876.       data file.  The data file was linked to this index during the index open, 
  4877.       in OP.xbLink. 
  4878.  
  4879.    2. A key is built by BULLET, based on the data in *recordStruct, and that 
  4880.       key is inserted into the index file (AP.handle).  Stored with the key is 
  4881.       the record number of the record added above. 
  4882.  
  4883.  Note:  AP.recNo must be set to 0 prior to the call.  Any positive number 
  4884.  results in an error (0x80000000, and negative numbers, may be used when more 
  4885.  than one AP pack is used - see below). 
  4886.  
  4887.  Upon return, if no error, the return code is 0.  AP.recNo is set to the 
  4888.  physical record number in the data file that *recordStruct was placed.  The 
  4889.  key that was stored, including any enumerator, is in *keyBuffer. 
  4890.  
  4891.  Upon return, and there was an error, the return code is either -1 or 1. If -1, 
  4892.  the error was caused during processing of the data file portion, and the error 
  4893.  code itself is in AP.stat.  If +1, the error was caused during processing of 
  4894.  the index file, and the error code itself is in AP.stat, as well.  The return 
  4895.  code is, as in all BULLET transaction-list routines, an index of the AP pack 
  4896.  that generated the error -- negative if a data file error, positive if an 
  4897.  index file error.  Since this example has only the single pack, only a -1 or 
  4898.  +1 could be returned, or 0. 
  4899.  
  4900.  Note:  If an error occurred after any part of the database had changed (during 
  4901.  this particular call), then any and all changes that were made are backed-out, 
  4902.  and the files restored to the same state as before the call. 
  4903.  
  4904.  Example: Specifying two index files for a single data file 
  4905.  
  4906.  Two index files, related to the same data file, would set AccessPack to: 
  4907.  
  4908.   AP[0].func = INSERT_XB;
  4909.   AP[0].handle = indexHandle_0;
  4910.   AP[0].recNo = 0;
  4911.   AP[0].recPtr = &recordStruct;
  4912.   AP[0].keyPtr = keyBuffer_0;
  4913.   AP[0].nextPtr = AP[1];
  4914.  
  4915.   AP[1].handle = indexHandle_1;
  4916.   AP[1].recNo = 0x80000000;
  4917.   AP[1].recPtr = &recordStruct;
  4918.   AP[1].keyPtr = keyBuffer_1;
  4919.   AP[1].nextPtr = NULL;
  4920.  
  4921.  A call to BULLET with the above does the following: 
  4922.  
  4923.    1. The data in *recordStruct is used as a new record that is appended 
  4924.       (added) to the data file. 
  4925.  
  4926.    2. A key is built by BULLET, based on the data in *recordStruct, and that 
  4927.       key is inserted into the index file (AP[0].handle).  Stored with the key 
  4928.       is the record number of the record added above. 
  4929.  
  4930.    3. A second key is built by BULLET, based on the data in *recordStruct, and 
  4931.       that key is inserted into the second index file (AP[1].handle).  Stored 
  4932.       with the key is the record number of the record added above. 
  4933.  
  4934.  Note:  The 0x80000000 in AP[1].recNo signifies that AP[1] is using the same 
  4935.  data record that was appended during processing of AP[0].  This results in 
  4936.  just the one data record being added.  AP[1].recPtr must still, however, point 
  4937.  to the same data as AP[0].recPtr does. 
  4938.  
  4939.  Upon return, if no error, the return code is 0.  AP[0].recNo is set to the 
  4940.  physical record number in the data file that *recordStruct was placed.  The 
  4941.  key that was stored for the first index, including any enumerator, is in the 
  4942.  buffer at AP[0].keyPtr.  AP[1].recNo is set to the same physical record number 
  4943.  as AP[0].recNo, except that the record number is negative: For example, if 
  4944.  AP[0].recNo is 22 on return, AP[1].recNo is -22 (the original 0x80000000 value 
  4945.  is overwritten).  The key that was stored for the second index, including any 
  4946.  enumerator, is in the buffer at AP[1].keyPtr. 
  4947.  
  4948.  Upon return, and there was an error, the return code can be -2, -1, 1, or 2. 
  4949.  If negative, the error was caused during processing of that AP pack's data 
  4950.  file portion, and the error code itself is in AP[abs(rez)-1].stat (where rez 
  4951.  is the return code, and -1 since C arrays start at 0).  If the return code was 
  4952.  positive, the error was caused during processing of that AP pack's index file, 
  4953.  and the error code itself is in AP[rez-1].stat, as well.  The return code is, 
  4954.  as in all BULLET transaction-list routines, an index of the AP pack that 
  4955.  generated the error -- negative if a data file error, positive if an index 
  4956.  file error. 
  4957.  
  4958.  Note:  If an error occurred after any part of the database had changed (during 
  4959.  this particular call), then any and all changes that were made are backed-out, 
  4960.  and the files restored to the same state as before the call. 
  4961.  
  4962.  Example: Specifying two index files for each of two different data files 
  4963.  
  4964.  Four total files: two index files related to one data file, and two other 
  4965.  index files related to another data file, would set AccessPack to: 
  4966.  
  4967.   AP[0].func = INSERT_XB;
  4968.   AP[0].handle = indexHandle_0;
  4969.   AP[0].recNo = 0;
  4970.   AP[0].recPtr = &recordStruct_0;
  4971.   AP[0].keyPtr = keyBuffer_0;
  4972.   AP[0].nextPtr = AP[1];
  4973.  
  4974.   AP[1].handle = indexHandle_1;
  4975.   AP[1].recNo = 0x80000000;
  4976.   AP[1].recPtr = &recordStruct_0;
  4977.   AP[1].keyPtr = keyBuffer_1;
  4978.   AP[1].nextPtr = AP[2];
  4979.  
  4980.   AP[2].handle = indexHandle_2;
  4981.   AP[2].recNo = 0;
  4982.   AP[2].recPtr = &recordStruct_1;
  4983.   AP[2].keyPtr = keyBuffer_2;
  4984.   AP[2].nextPtr = AP[3];
  4985.  
  4986.   AP[3].handle = indexHandle_3;
  4987.   AP[3].recNo = 0x80000000;
  4988.   AP[3].recPtr = &recordStruct_1;
  4989.   AP[3].keyPtr = keyBuffer_3;
  4990.   AP[3].nextPtr = NULL;
  4991.  
  4992.  A call to BULLET with the above does the following: 
  4993.  
  4994.    1. The data in *recordStruct_0 is used as a new record that is appended to 
  4995.       the data file linked to the index file in AP[0].handle. 
  4996.  
  4997.    2. A key is built by BULLET, based on the data in *recordStruct_0, and that 
  4998.       key is inserted into the index file (AP[0].handle).  Stored with the key 
  4999.       is the record number of the record added above, for _0. 
  5000.  
  5001.    3. A second key is built by BULLET, based on the data in *recordStruct_0, 
  5002.       and that key is inserted into the second index file (AP[1].handle). 
  5003.       Stored with the key is the record number of the record added above, using 
  5004.       *recordStruct_0. 
  5005.  
  5006.    4. The data in *recordStruct_1 is used as a new record that is appended to 
  5007.       the data file linked to the index file in AP[2].handle. 
  5008.  
  5009.    5. A third key is built by BULLET, based on the data in *recordStruct_1, and 
  5010.       that key is inserted into the index file (AP[2].handle).  Stored with the 
  5011.       key is the record number of the record added above, for _1. 
  5012.  
  5013.    6. A fourth key is built by BULLET, based on the data in *recordStruct_1, 
  5014.       and that key is inserted into the fourth index file (AP[3].handle). 
  5015.       Stored with the key is the record number of the record added above, using 
  5016.       *recordStruct_1. 
  5017.  
  5018.  Note:  The 0x80000000 in AP[1].recNo signifies that AP[1] is using the same 
  5019.  data record that was appended during processing of AP[0].  This results in 
  5020.  just the one data record being added.  AP[1].recPtr must still, however, point 
  5021.  to the same data as AP[0].recPtr does.  The same applies to AP[2] and AP[3] 
  5022.  (though different values, of course). 
  5023.  
  5024.  Upon return, if no error, the return code is 0.  AP[0].recNo is set to the 
  5025.  physical record number in the data file that *recordStruct_0 was placed. The 
  5026.  key that was stored for the first index, including any enumerator, is in the 
  5027.  buffer at AP[0].keyPtr.  AP[1].recNo is set to the same physical record number 
  5028.  as AP[0].recNo, except that the record number is negative: For example, if 
  5029.  AP[0].recNo is 22 on return, AP[1].recNo is -22 (the original 0x80000000 value 
  5030.  is overwritten).  The key that was stored for the second index, including any 
  5031.  enumerator, is in the buffer at AP[1].keyPtr.  AP[2].recNo is set to the 
  5032.  physical record number in the data file that *recordStruct_1 was placed.  The 
  5033.  key that was stored for the third index, including any enumerator, is in the 
  5034.  buffer at AP[2].keyPtr.  AP[3].recNo is set to the same physical record number 
  5035.  as AP[2].recNo, except that the record number is negative: For example, if 
  5036.  AP[2].recNo is 74 on return, AP[3].recNo is -74 (the original 0x80000000 value 
  5037.  is overwritten).  The key that was stored for the fourth index, including any 
  5038.  enumerator, is in the buffer at AP[3].keyPtr. 
  5039.  
  5040.  Upon return, and there was an error, the return code can be -4 to -1, or 1 to 
  5041.  4.  If negative, the error was caused during processing of that AP pack's data 
  5042.  file portion, and the error code itself is in AP[abs(rez)-1].stat (where rez 
  5043.  is the return code, and -1 since C arrays start at 0).  If the return code was 
  5044.  positive, the error was caused during processing of that AP pack's index file, 
  5045.  and the error code itself is in AP[rez-1].stat, as well.  The return code is, 
  5046.  as in all BULLET transaction-list routines, an index of the AP pack that 
  5047.  generated the error -- negative if a data file error, positive if an index 
  5048.  file error. 
  5049.  
  5050.  Note:  If an error occurred after any part of the database had changed (during 
  5051.  this particular call), then any and all changes that were made are backed-out, 
  5052.  and the files restored to the same state as before the call. 
  5053.  
  5054.  Example: Specifying two index files for two records in the same data file 
  5055.  
  5056.  Three files: two index files related to one data file, where two data records 
  5057.  are to be appended, would set AccessPack to: 
  5058.  
  5059.   AP[0].func = INSERT_XB;
  5060.   AP[0].handle = indexHandle_0;
  5061.   AP[0].recNo = 0;
  5062.   AP[0].recPtr = &recordStruct_0;
  5063.   AP[0].keyPtr = keyBuffer_0;
  5064.   AP[0].nextPtr = AP[1];
  5065.  
  5066.   AP[1].handle = indexHandle_1;
  5067.   AP[1].recNo = 0x80000000;
  5068.   AP[1].recPtr = &recordStruct_0;
  5069.   AP[1].keyPtr = keyBuffer_1;
  5070.   AP[1].nextPtr = AP[2];
  5071.  
  5072.   AP[2].handle = indexHandle_0;
  5073.   AP[2].recNo = 0;
  5074.   AP[2].recPtr = &recordStruct_1;
  5075.   AP[2].keyPtr = keyBuffer_2;
  5076.   AP[2].nextPtr = AP[3];
  5077.  
  5078.   AP[3].handle = indexHandle_1;
  5079.   AP[3].recNo = 0x80000000;
  5080.   AP[3].recPtr = &recordStruct_1;
  5081.   AP[3].keyPtr = keyBuffer_3;
  5082.   AP[3].nextPtr = NULL;
  5083.  
  5084.  A call to BULLET with the above does the following: 
  5085.  
  5086.    1. The data in *recordStruct_0 is used as a new record that is appended to 
  5087.       the data file linked to the index file in AP[0].handle. 
  5088.  
  5089.    2. A key is built by BULLET, based on the data in *recordStruct_0, and that 
  5090.       key is inserted into the index file (AP[0].handle).  Stored with the key 
  5091.       is the record number of the record added above, for _0. 
  5092.  
  5093.    3. A second key is built by BULLET, based on the data in *recordStruct_0, 
  5094.       and that key is inserted into the second index file (AP[1].handle). 
  5095.       Stored with the key is the record number of the record added above, using 
  5096.       *recordStruct_0. 
  5097.  
  5098.    4. The data in *recordStruct_1 is used as a new record that is appended to 
  5099.       the data file linked to the index file in AP[2].handle.  Since 
  5100.       AP[2].handle is the same index file as that of AP[0].handle, this means 
  5101.       it's also the same data file as was just operated on above -- a second 
  5102.       data record is appended to the data file.  The net effect of this 
  5103.       operation is to call INSERT_XB twice, once for one insert, then again for 
  5104.       the second.  The difference is that the operation is atomic -- if one 
  5105.       fails, the other is not committed; it's an "all or nothing" operation. 
  5106.  
  5107.    5. A third key is built by BULLET, based on the data in *recordStruct_1, and 
  5108.       that key is inserted into the index file (AP[2].handle).  Stored with the 
  5109.       key is the record number of the record added directly above, for _1. Note 
  5110.       that this index file is the same as specified in AP[0].handle. 
  5111.  
  5112.    6. A fourth key is built by BULLET, based on the data in *recordStruct_1, 
  5113.       and that key is inserted into the fourth index file (AP[3].handle). 
  5114.       Stored with the key is the record number of the record added above, using 
  5115.       *recordStruct_1. 
  5116.  The return ritual is as described above, for "Specifying two index files each 
  5117.  for two different data files". 
  5118.  
  5119.  Example: Specifying a single index file for a previously added data record 
  5120.  
  5121.  This form lets you insert a key without adding a data record.  This would be 
  5122.  required if you were, for example, creating a temporary index of select 
  5123.  records in a data file (i.e., the data records already exist, you just want to 
  5124.  index them).  AccessPack setup for this is: 
  5125.  
  5126.   AP.func = INSERT_XB;
  5127.   AP.handle = indexHandle;
  5128.   AP.recNo = -recordNumberOfExistingRecord;
  5129.   AP.recPtr = &recordStruct;
  5130.   AP.keyPtr = keyBuffer;
  5131.   AP.nextPtr = NULL;
  5132.  
  5133.  A call to BULLET with the above does the following: 
  5134.  
  5135.    1. A key is built by BULLET, based on the data in *recordStruct, and that 
  5136.       key is inserted into the index file (AP.handle).  Stored with the key is 
  5137.       the absolute value of the record number specified in AP.recNo (which is 
  5138.       set to negative record number). 
  5139.  
  5140.  Upon return, if no error, the return code is 0.  AP.recNo is changed to 
  5141.  abs(AP.recNo).  The key that was stored, including any enumerator, is in 
  5142.  *keyBuffer.  No data file access is made. 
  5143.  
  5144.  Upon return, and there was an error, the return code is either -1 or 1. If -1, 
  5145.  the error was caused during processing of the data file portion, and the error 
  5146.  code itself is in AP.stat.  If +1, the error was caused during processing of 
  5147.  the index file, and the error code itself is in AP.stat, as well.  The return 
  5148.  code is, as in all BULLET transaction-list routines, an index of the AP pack 
  5149.  that generated the error -- negative if a data file error, positive if an 
  5150.  index file error.  Since this example has only the single pack, only a -1 or 
  5151.  +1 could be returned. 
  5152.  
  5153.  Note:  If an error occurred after any part of the database had changed (during 
  5154.  this particular call), then any and all changes that were made are backed-out, 
  5155.  and the files restored to the same state as before the call. 
  5156.  
  5157.  An example use of this INSERT_XB feature is to create an ad hoc index of, say, 
  5158.  records marked as deleted.  To do this, create a new index file (say, with a 
  5159.  key of NAME).  Get each data record, by record number using GET_RECORD_XB (for 
  5160.  records 1 to number-of-records), and check the .tag byte.  If '*', call 
  5161.  INSERT_XB with the negative value of AP.recNo.  Do this for every such marked 
  5162.  record.  After all records are processed, you have an index of all deleted 
  5163.  records in the data file.  Delete the index when no longer needed.  That's 
  5164.  just one example. 
  5165.  
  5166.  
  5167. ΓòÉΓòÉΓòÉ 9.59. UPDATE_XB ΓòÉΓòÉΓòÉ
  5168.  
  5169. Pack: ACCESSPACK               Source Example 
  5170.  
  5171.      IN               OUT
  5172.    AP.func          AP.stat
  5173.    AP.handle        *AP.keyPtr
  5174.    AP.recNo
  5175.    AP.recPtr
  5176.    AP.keyPtr
  5177.    AP.nextPtr
  5178.  
  5179.  Update any and all files in the transaction list if necessary, including both 
  5180.  index and data files. 
  5181.  
  5182.  This routine is used to update data records while also updating the index 
  5183.  files if a key field has changed due to data record updates.  Up to 256 index 
  5184.  files may be updated per call, as well as 256 data files, too, for a total of 
  5185.  512 files managed per single UPDATE_XB call. 
  5186.  
  5187.  Only index handles are listed in AP.handle.  Each index file has associated 
  5188.  with it a data file, known internally to BULLET (the xbLink from OPEN_XB). 
  5189.  There may be more than one index file for a data file, but there is always one 
  5190.  data file per index handle specified in the list.  In other words, you can 
  5191.  list five index files, each indexing the same xbLink data file, and have 
  5192.  BULLET perform an atomic update of that list. Or, another possibility is that 
  5193.  you have a single index file, indexing a single data file.  Or, you can list 
  5194.  256 index files, each indexing a single data file (512 total files). 
  5195.  
  5196.  This, and several other routines, are transaction-list-based.  This means that 
  5197.  if a failure occurs prior to the routine's completion, all changes made to the 
  5198.  database by the routine will be backed-out, and the database (data and index 
  5199.  files) effectively restored to its original state. 
  5200.  
  5201.  If the routine failed to complete, the function return value is the number 
  5202.  (1-based) of the pack that caused the failure.  A positive number indicates 
  5203.  the failure was from an index operation; a negative number indicates the 
  5204.  failure was from a data operation.  In each case, the absolute value of the 
  5205.  return code is the list item that failed (the pack index).  For example, if 
  5206.  five index handles are in the list(AP[0] to AP[4]), and an error occurred on 
  5207.  the last pack's index file, the return code would be positive 5, indicating 
  5208.  the fifth pack (AP[4]) failed.  Since it was a positive 5, the index file was 
  5209.  being processed when the error occurred.  Being processed means not only 
  5210.  physical access, but verification, etc.  If the return code was -5, then 
  5211.  again, the error was in the fifth pack, but since it is negative, the error 
  5212.  occurred while processing the data file.  In either case, upon return, the 
  5213.  database is restored to the way it was before the UPDATE_XB call was made. 
  5214.  Remedy the error, if possible, and UPDATE_XB again. 
  5215.  
  5216.  Each pack must include a separate key buffer.  You must not share a common key 
  5217.  buffer.  Doing so disables any chance of recovering the index files in case of 
  5218.  error, since it is in these buffers that BULLET places any newly built keys, 
  5219.  and it is from these that BULLET, upon an error condition, deletes these keys 
  5220.  (required for roll-back). 
  5221.  
  5222.  The enumerator is automatically maintained by this routine, if required 
  5223.  (DUPS_ALLOWED and the key already exists with enumerator 0).  The process is 
  5224.  the same as INSERT_XB's. 
  5225.  
  5226.  How an update works 
  5227.  
  5228.  All data records specified in the list are read from disk into memory, except 
  5229.  those with AP.recNo=0.  Therefore, a memory allocation large enough to store 
  5230.  all unique data records is made upon entry to this routine (and released at 
  5231.  exit).  For example, if the list includes two implicit data files, and the 
  5232.  record lengths of those two data files are 2048 and 4096 bytes, an allocation 
  5233.  of 6K is made.  In addition, 40KB more is allocated for workspace.  So, for 
  5234.  this example, 46K is allocated (rounded up to 48KB, the next 4KB page 
  5235.  boundary).  Since up to 256 unique records are possible, where a unique record 
  5236.  is identified by handle/record number, be aware of the memory requirements if 
  5237.  you are updating very large databases (e.g., 256 unique records, each 4KB in 
  5238.  length, would have UPDATE_XB allocate a bit over 1MB of memory for this call). 
  5239.  
  5240.  After the data records have been read from disk, each list-item is processed, 
  5241.  in order.  The disk record image previously read is compared with the record 
  5242.  image at AP.recPtr.  If the same, that item is skipped, and the next item in 
  5243.  the list is processed.  If you know beforehand that that record is the same, 
  5244.  set that item's AP.recNo=0 so you can avoid having its disk image read and 
  5245.  stored (or do not include it in the list at all).  If the images differ, 
  5246.  BULLET creates a key for the index file being processed, for each record image 
  5247.  (the original and the one in AP.recPtr).  If the keys generated are the same, 
  5248.  no index file update is needed.  If different, the original key for that 
  5249.  record is deleted from that index file, and the new key inserted. Finally, the 
  5250.  new record replaces the old, the new directly overwriting the original.  Note 
  5251.  that the actual sequence of the update event differs somewhat from this 
  5252.  description in order to optimize the process. 
  5253.  
  5254.  Specifying Files 
  5255.  
  5256.  As mentioned, only the index file handles are specified in AP.handle. Data 
  5257.  files are implicitly specified by their links to the index files, as specified 
  5258.  when the index file was opened (OP.xbLink).  UPDATE_XB can process up to 256 
  5259.  index files per call.  Since each index file requires a data file, this means 
  5260.  that up to 256 data files can be processed per call as well.  Also possible is 
  5261.  that all 256 index handles refer to the same, single data file.  Yet another 
  5262.  possibility is that there is 1 index file, and so 1 data file.  The 
  5263.  possibilities can include those and anything in between. 
  5264.  
  5265.  Example: Specifying a single index file 
  5266.  
  5267.  The simplest form is where a single index handle is specified.  This implies a 
  5268.  single data file, too.  AccessPack setup for this is: 
  5269.  
  5270.   AP.func = UPDATE_XB;
  5271.   AP.handle = indexHandle;
  5272.   AP.recNo = recordToUpdate;
  5273.   AP.recPtr = &recordStruct;
  5274.   AP.keyPtr = keyBuffer;
  5275.   AP.nextPtr = NULL;
  5276.  
  5277.  A call to BULLET with the above does the following: 
  5278.  
  5279.    1. The data in *recordStruct is used as the new record that is to replace 
  5280.       the data record at AP.recNo.  The data file was linked to this index file 
  5281.       (AP.handle) during the index open, in OP.xbLink. 
  5282.  
  5283.    2. If the record data in *recordStruct is the same as the original disk 
  5284.       record, nothing is done.  If the data is new, the key fields are compared 
  5285.       to that belonging to the original disk record, and if the same, only the 
  5286.       record data is updated.  If the new record's key differs from the 
  5287.       original's, the original key for this record is removed from the index, 
  5288.       and the new key inserted. 
  5289.  
  5290.  AP.recNo must be set to the record number that you are updating. Any GET_XB 
  5291.  routine (GET_EQUAL_XB, etc.) may be used to identify the number of a data 
  5292.  record.  Key access has the obvious advantage of knowing the record number of 
  5293.  a specific key (for example, Betty Barbar's data). Any record number, from 1 
  5294.  to number of records in the data file, can be used.  In addition, a negative 
  5295.  record number can be used.  This is treated exactly the same as a positive 
  5296.  record number (the absolute value is used). The reason this is allowed is 
  5297.  because INSERT_XB replaces 0x80000000 record numbers with the negative value 
  5298.  of the previous insert. 
  5299.  
  5300.  Upon return, if no error, the return code is 0.  If the record data was new, 
  5301.  the key for that data record, including any enumerator, is in *keyBuffer. 
  5302.  This is so even if key fields had not changed. 
  5303.  
  5304.  Upon return, and there was an error, the return code is either -1 or 1. If -1, 
  5305.  the error was caused during processing of the data file portion, and the error 
  5306.  code itself is in AP.stat.  If +1, the error was caused during processing of 
  5307.  the index file, and the error code itself is in AP.stat, as well.  The return 
  5308.  code is, as in all BULLET transaction-list routines, an index of the AP pack 
  5309.  that generated the error -- negative if a data file error, positive if an 
  5310.  index file error.  Since this example has only the single pack, only a -1 or 
  5311.  +1 could be returned. 
  5312.  
  5313.  Note:  If an error occurred after any part of the database had changed (during 
  5314.  this particular call), then any and all changes that were made are backed-out, 
  5315.  and the files restored to the same state as before the call. 
  5316.  
  5317.  Example: Specifying two index files for a single data file 
  5318.  
  5319.  Two index files, related to the same data file, would set AccessPack to: 
  5320.  
  5321.   AP[0].func = UPDATE_XB;
  5322.   AP[0].handle = indexHandle_0;
  5323.   AP[0].recNo = recordToUpdate;
  5324.   AP[0].recPtr = &recordStruct;
  5325.   AP[0].keyPtr = keyBuffer_0;
  5326.   AP[0].nextPtr = AP[1];
  5327.  
  5328.   AP[1].handle = indexHandle_1;
  5329.   AP[1].recNo = recordToUpdate;
  5330.   AP[1].recPtr = &recordStruct;
  5331.   AP[1].keyPtr = keyBuffer_1;
  5332.   AP[1].nextPtr = NULL;
  5333.  
  5334.  A call to BULLET with the above does the following: 
  5335.  
  5336.    1. The data in *recordStruct is used as the new record that is to replace 
  5337.       the data record at AP.recNo.  The data file was linked to this index file 
  5338.       (AP.handle) during the index open, in OP.xbLink. 
  5339.  
  5340.    2. If the record data in *recordStruct is the same as the original disk 
  5341.       record, nothing is done.  If the data is new, the key fields are compared 
  5342.       to that belonging to the original disk record, and if the same, only the 
  5343.       record data is updated.  If the new record's key differs from the 
  5344.       original's, the original key for this record is removed from the index, 
  5345.       and the new key inserted. 
  5346.  
  5347.    3. The operation performed directly above is repeated, this time for the 
  5348.       second index file.  The new record data, and the record number to update 
  5349.       are, for this particular example, the same. 
  5350.  
  5351.  AP.recNo must be set to the record number that you are updating. Each 
  5352.  AP[].recNo must be set to a valid record number, even if the record number is 
  5353.  the same as the previous AP[] pack's (the case where you have more than one 
  5354.  index file for a data file).  BULLET knows if the record number duplicates a 
  5355.  number in a previous AP pack, and allocates resources for only the first 
  5356.  encounter of the data record.  Subsequent encounters refer to the first. 
  5357.  
  5358.  Upon return, if no error, the return code is 0.  If the new and original data 
  5359.  records differ, the key for the new data record, including any enumerator, is 
  5360.  in the buffer at AP[0].keyPtr.  This even if the key fields did not change. 
  5361.  The same applies to the second index, with the new data key in AP[1].keyPtr. 
  5362.  
  5363.  Upon return, and there was an error, the return code can be -2, -1, 1, or 2. 
  5364.  If negative, the error was caused during processing of that AP pack's data 
  5365.  file portion, and the error code itself is in AP[abs(rez)-1].stat (where rez 
  5366.  is the return code, and -1 since C arrays start at 0).  If the return code was 
  5367.  positive, the error was caused during processing of that AP pack's index file, 
  5368.  and the error code itself is in AP[rez-1].stat, as well.  The return code is, 
  5369.  as in all BULLET transaction-list routines, an index of the AP pack that 
  5370.  generated the error -- negative if a data file error, positive if an index 
  5371.  file error. 
  5372.  
  5373.  Note:  If an error occurred after any part of the database had changed (during 
  5374.  this particular call), then any and all changes that were made are backed-out, 
  5375.  and the files restored to the same state as before the call. 
  5376.  
  5377.  Example: Specifying two index files for each of two different data files 
  5378.  
  5379.  Four total files: two index files related to one data file, and two other 
  5380.  index files related to another data file, would set AccessPack to: 
  5381.  
  5382.   AP[0].func = UPDATE_XB;
  5383.   AP[0].handle = indexHandle_0;
  5384.   AP[0].recNo = recordToUpdate_0;
  5385.   AP[0].recPtr = &recordStruct_0;
  5386.   AP[0].keyPtr = keyBuffer_0;
  5387.   AP[0].nextPtr = AP[1];
  5388.  
  5389.   AP[1].handle = indexHandle_1;
  5390.   AP[1].recNo = recordToUpdate_0;
  5391.   AP[1].recPtr = &recordStruct_0;
  5392.   AP[1].keyPtr = keyBuffer_1;
  5393.   AP[1].nextPtr = AP[2];
  5394.  
  5395.   AP[2].handle = indexHandle_2;
  5396.   AP[2].recNo = recordToUpdate_1;
  5397.   AP[2].recPtr = &recordStruct_1;
  5398.   AP[2].keyPtr = keyBuffer_2;
  5399.   AP[2].nextPtr = AP[3];
  5400.  
  5401.   AP[3].handle = indexHandle_3;
  5402.   AP[3].recNo = recordToUpdate_1;
  5403.   AP[3].recPtr = &recordStruct_1;
  5404.   AP[3].keyPtr = keyBuffer_3;
  5405.   AP[3].nextPtr = NULL;
  5406.  
  5407.  A call to BULLET with the above does the following: 
  5408.  
  5409.    1. The data in *recordStruct_0 is used as the new record that is to replace 
  5410.       the data record at AP[0].recNo in the data file linked to the index file 
  5411.       in AP[0].handle. 
  5412.  
  5413.    2. If the record data in *recordStruct_0 is the same as the original disk 
  5414.       record, nothing is done.  If the data is new, the key fields are compared 
  5415.       to that belonging to the original disk record, and if the same, only the 
  5416.       record data is updated.  If the new record's key differs from the 
  5417.       original's, the original key for this record is removed from the index, 
  5418.       and the new key inserted. 
  5419.  
  5420.    3. The operation performed directly above is repeated, this time for the 
  5421.       second index file.  The new record data, and the record number to update, 
  5422.       are for this particular example, the same. 
  5423.  
  5424.    4. The data in *recordStruct_1 is used as the new record that is to replace 
  5425.       the data record at AP[2].recNo in the data file linked to the index file 
  5426.       in AP[2].handle. 
  5427.  
  5428.    5. If the record data in *recordStruct_1 is the same as the original disk 
  5429.       record, nothing is done.  If the data is new, the key fields are compared 
  5430.       to that belonging to the original disk record, and if the same, only the 
  5431.       record data is updated.  If the new record's key differs from the 
  5432.       original's, the original key for this record is removed from the index, 
  5433.       and the new key inserted. 
  5434.  
  5435.    6. The operation performed directly above is repeated, this time for the 
  5436.       fourth index file.  The new record data, and the record number to update 
  5437.       are, for this particular example, the same. 
  5438.  
  5439.  Upon return, if no error, the return code is 0.  If the new and original data 
  5440.  records differ, the keys for the new data records, including any enumerators, 
  5441.  are in the buffers at AP[0].keyPtr to AP[3].keyPtr.  This even if the key 
  5442.  fields did not change.  If one, or all, of the new data records matched the 
  5443.  original data record, nothing is placed in *keyBuffer for that index. 
  5444.  
  5445.  Upon return, and there was an error, the return code can be -4 to -1, or 1 to 
  5446.  4.  If negative, the error was caused during processing of that AP pack's data 
  5447.  file portion, and the error code itself is in AP[abs(rez)-1].stat (where rez 
  5448.  is the return code, and rez-1 since C arrays start at 0).  If the return code 
  5449.  was positive, the error was caused during processing of that AP pack's index 
  5450.  file, and the error code itself is in AP[rez-1].stat, as well.  The return 
  5451.  code is, as in all BULLET transaction-list routines, an index of the AP pack 
  5452.  that generated the error -- negative if a data file error, positive if an 
  5453.  index file error. 
  5454.  
  5455.  Note:  If an error occurred after any part of the database had changed (during 
  5456.  this particular call), then any and all changes that were made are backed-out, 
  5457.  and the files restored to the same state as before the call. 
  5458.  
  5459.  Example: Specifying two index files for two records in the same data file 
  5460.  
  5461.  Three files: two index files related to one data file, where two data records 
  5462.  are to be updated, would set AccessPack to: 
  5463.  
  5464.   AP[0].func = UPDATE_XB;
  5465.   AP[0].handle = indexHandle_0;
  5466.   AP[0].recNo = recordToUpdate_0;
  5467.   AP[0].recPtr = &recordStruct_0;
  5468.   AP[0].keyPtr = keyBuffer_0;
  5469.   AP[0].nextPtr = AP[1];
  5470.  
  5471.   AP[1].handle = indexHandle_1;
  5472.   AP[1].recNo = recordToUpdate_0;
  5473.   AP[1].recPtr = &recordStruct_0;
  5474.   AP[1].keyPtr = keyBuffer_1;
  5475.   AP[1].nextPtr = AP[2];
  5476.  
  5477.   AP[2].handle = indexHandle_0;
  5478.   AP[2].recNo = recordToUpdate_1;
  5479.   AP[2].recPtr = &recordStruct_1;
  5480.   AP[2].keyPtr = keyBuffer_2;
  5481.   AP[2].nextPtr = AP[3];
  5482.  
  5483.   AP[3].handle = indexHandle_1;
  5484.   AP[3].recNo = recordToUpdate_1;
  5485.   AP[3].recPtr = &recordStruct_1;
  5486.   AP[3].keyPtr = keyBuffer_3;
  5487.   AP[3].nextPtr = NULL;
  5488.  
  5489.  A call to BULLET with the above does the following: 
  5490.  
  5491.    1. The data in *recordStruct_0 is used as the new record that is to replace 
  5492.       the data record at AP[0].recNo in the data file linked to the index file 
  5493.       in AP[0].handle. 
  5494.  
  5495.    2. If the record data in *recordStruct_0 is the same as the original disk 
  5496.       record, nothing is done.  If the data is new, the key fields are compared 
  5497.       to that belonging to the original disk record, and if the same, only the 
  5498.       record data is updated.  If the new record's key differs from the 
  5499.       original's, the original key for this record is removed from the index, 
  5500.       and the new key inserted. 
  5501.  
  5502.    3. The operation performed directly above is repeated, this time for the 
  5503.       second index file.  The new record data, and the record number to update, 
  5504.       are for this particular example, the same. 
  5505.  
  5506.    4. The data in *recordStruct_1 is used as the new record that is to replace 
  5507.       the data record at AP[2].recNo in the data file linked to the index file 
  5508.       in AP[2].handle.  This is the same index file as the first AP pack, and 
  5509.       also the same data file.  However, this is a different record number. 
  5510.  
  5511.    5. If the record data in *recordStruct_1 is the same as the original disk 
  5512.       record, nothing is done.  If the data is new, the key fields are compared 
  5513.       to that belonging to the original disk record, and if the same, only the 
  5514.       record data is updated.  If the new record's key differs from the 
  5515.       original's, the original key for this record is removed from the index, 
  5516.       and the new key inserted. 
  5517.  
  5518.    6. The operation performed directly above is repeated, this time for the 
  5519.       fourth index file. The new record data, and the record number to update 
  5520.       are, for this particular example, the same. 
  5521.  The return ritual is as described above, for "Specifying two index files each 
  5522.  for two different data files". 
  5523.  
  5524.  
  5525. ΓòÉΓòÉΓòÉ 9.60. REINDEX_XB ΓòÉΓòÉΓòÉ
  5526.  
  5527. Pack: ACCESSPACK               Source Example 
  5528.  
  5529.      IN               OUT
  5530.    AP.func          AP.stat
  5531.    AP.handle        AP.recNo
  5532.    AP.keyPtr        *AP.keyPtr
  5533.    AP.nextPtr
  5534.  
  5535.  Reindex all files in the transaction list, re-evaluating the key expression in 
  5536.  the process. 
  5537.  
  5538.  This routine is used to reindex up to 256 index files per call. The index 
  5539.  files must already exist and be open.  Any existing key values are overwritten 
  5540.  by new key data.  In other words, if you have a 100MB index file, REINDEX_XB 
  5541.  uses the same file space, building new keys over old.  This results in a less 
  5542.  fragmented disk and also minimizes disk space needed.  You can also create a 
  5543.  new, empty index file and reindex to that.  This would be useful, for 
  5544.  instance, if you needed to create a temporary index file -- something that 
  5545.  you'd use for a report, say, then delete after the report.  Another use for 
  5546.  creating a new index file and reindexing to that is to, after creating it 
  5547.  (COPY_INDEX_HEADER_XB can be used), use EXPAND_FILE_DOS and expand it to the 
  5548.  expected size.  This has the benefit of ensuring that this file allocation is 
  5549.  as contiguous as the file system allows (without relying on OS/API-specific 
  5550.  calls). 
  5551.  
  5552.  If the routine failed to complete, the function return value is the number 
  5553.  (1-based) of the pack that caused the failure.  A positive number indicates 
  5554.  the failure was from an index operation; a negative number indicates the 
  5555.  failure was from a data operation (reading the data file).  In each case, the 
  5556.  absolute value of the return code is the list item that failed (the pack 
  5557.  index).  For example, if five index handles are in the list(AP[0] to AP[4]), 
  5558.  and an error occurred on the last pack's index file, the return code would be 
  5559.  positive 5, indicating the fifth pack (AP[4]) failed.  Since it was a positive 
  5560.  5, the index file was being processed when the error occurred.  Being 
  5561.  processed means not only physical access, but verification, etc.  If the 
  5562.  return code was -5, then again, the error was in the fifth pack, but since it 
  5563.  is negative, the error occurred while processing the data file. 
  5564.  
  5565.  Unlike INSERT_XB and UPDATE_XB, each pack need not include a separate key 
  5566.  buffer; you may share a common key buffer.  If duplicate keys are generated in 
  5567.  the reindex process and the sort function does not flag DUPS_ALLOWED, an error 
  5568.  is returned.  The duplicate key is in *AP.keyPtr and the record number it was 
  5569.  generated from in AP.recNo (both these are valid only on error).  Since no 
  5570.  roll-back is performed, there is only a real need for a single key buffer. 
  5571.  You may use separate ones, too. 
  5572.  
  5573.  This routine creates a temporary work file in either the current directory or, 
  5574.  if the environment variable TMP is defined, in the directory pointed to by 
  5575.  TMP=.  The path used for this temporary file may also be specified at run-time 
  5576.  by using the TMP_PATH_PTR item for SET_SYSVARS_XB.  If TMP_PATH_PTR is NULL 
  5577.  (default), then TMP= is used, or if that is not found, then the current 
  5578.  directory is used.  The size of this temporary file is, in bytes, 
  5579.  approximately (keylength+4) * number of records in the data file.  The 
  5580.  resultant index files are, by default, optimized for minimum size and maximum 
  5581.  retrieval speed.  This full-node packing leaves one empty key per node, which 
  5582.  means b-tree splitting will occur almost immediately upon inserting data (with 
  5583.  INSERT_XB or STORE_KEY_XB). 
  5584.  
  5585.  This behaviour can be modified with the REINDEX_PACK_PCT item for 
  5586.  SET_SYSVARS_XB so that less packing is done.  Less packing would improve 
  5587.  subsequent INSERT_XB performance since all nodes are not almost full as they 
  5588.  are with a full pack.  File size and retrieval times increase, though, but 
  5589.  perhaps not noticeably. 
  5590.  
  5591.  During the reindex process, each record is checked for a matching skip-tag 
  5592.  value, as set in SET_SYSVARS_XB.  The skip-tag is set to 0 by default, where 
  5593.  no check is done and keys for all records in the data file are inserted into 
  5594.  the index file. 
  5595.  
  5596.  
  5597. ΓòÉΓòÉΓòÉ 9.61. LOCK_XB ΓòÉΓòÉΓòÉ
  5598.  
  5599. Pack: LOCKPACK                 Source Example 
  5600.  
  5601.      IN               OUT
  5602.    LP.func          LP.stat
  5603.    LP.handle
  5604.    LP.xlMode
  5605.    LP.dlMode
  5606.    LP.recStart=0
  5607.    LP.nextPtr
  5608.  
  5609.  Lock all bytes of the files in the list for exclusive use by the current 
  5610.  process, and reload file headers from disk.  LP.recStart must be 0 for each 
  5611.  pack. 
  5612.  
  5613.  This routine is used to lock the database for either exclusive use by this 
  5614.  process, or shared access (allowing any process to read, but not write, to the 
  5615.  files).  Up to 256 index files may be locked per call, as well as 256 data 
  5616.  files, too, for a total of 512 files per single LOCK_XB call.  Shared-access 
  5617.  locking prevents all processes from writing to the file while a shared lock is 
  5618.  in force, including this process.  To relock in exclusive lock mode, without 
  5619.  unlocking first, use: RELOCK_XB. 
  5620.  
  5621.  Only index handles are listed in LP.handle.  Each index file has associated 
  5622.  with it a data file, known internally to BULLET (the xbLink from OPEN_XB). 
  5623.  There may be more than one index file for a data file, but there is always one 
  5624.  data file per index handle specified in the list.  For example, you can list 
  5625.  five index files, each indexing the same xbLink data file, and have BULLET 
  5626.  perform an atomic lock of that list. 
  5627.  
  5628.  LP.xlMode is set to 1 to perform a shared lock on the index file.  Set to 0 
  5629.  for an exclusive lock.  A shared lock allows only reading. 
  5630.  
  5631.  LP.dlMode is set to 1 to perform a shared lock on the data file.  Set to 0 for 
  5632.  an exclusive lock.  A shared lock allows only reading. 
  5633.  
  5634.  The lock mode (shared <-> exclusive) can be changed using RELOCK_XB. 
  5635.  
  5636.  Bullet maintains a per-handle lock count, and does a physical region lock only 
  5637.  upon the first lock request (or on a relock request).  It is only on this 
  5638.  first lock request that the header is reloaded.  When the lock count returns 
  5639.  to 0 (from UNLOCK_XB calls), it is at that time the header is flushed, if 
  5640.  required.  Only full-locks are maintained in this way.  The number of 
  5641.  outstanding locks can be determined from the SIP and SDP structures, from the 
  5642.  STAT_XB routines.  Note that individual LOCK_INDEX_XB and UNLOCK_INDEX_XB 
  5643.  routines, as well as the data ones, also act upon this lock count.  Therefore, 
  5644.  you can lock a file 100 times in a row, but only on the first lock are any 
  5645.  operations actually performed, and only on the last unlock are any performed. 
  5646.  Other lock/unlock calls (other than the first lock or last unlock) simply 
  5647.  increment or decrement the lock count for that handle. 
  5648.  
  5649.  This, and several other routines, are transaction-list-based.  This means that 
  5650.  if a failure occurs prior to the routine's completion, all locks made to the 
  5651.  database by this routine will be unlocked. 
  5652.  
  5653.  If the routine failed to complete, the function return value is the number 
  5654.  (1-based) of the pack that caused the failure.  A positive number indicates 
  5655.  the failure was from an index operation; a negative number indicates the 
  5656.  failure was from a data operation.  In each case, the absolute value of the 
  5657.  return code is the list item that failed (the pack index).  For example, if 
  5658.  five index handles are in the list(AP[0] to AP[4]), and an error occurred on 
  5659.  the last pack's index file, the return code would be positive 5, indicating 
  5660.  the fifth pack (AP[4]) failed.  Since it was a positive 5, the index file was 
  5661.  being processed when the error occurred.  Being processed means not only 
  5662.  physical access, but verification, etc.  If the return code was -5, then 
  5663.  again, the error was in the fifth pack, but since it is negative, the error 
  5664.  occurred while processing the data file.  In either case, upon return, any 
  5665.  files locked during this call are unlocked before returning. 
  5666.  
  5667.  The advantage of using region locks (LOCK_XB locks entire file regions) to 
  5668.  control file access is that the file does not need to be opened/closed using 
  5669.  the Deny Read/Write sharing attribute.  Opening the file for Deny None, and 
  5670.  controlling subsequent access with region locks, allows for faster processing 
  5671.  since files do not need to be constantly opened and closed, as they would if 
  5672.  access were controlled by opening with Deny Read/Write. 
  5673.  
  5674.  Using the operating system to control access also prevents other processes 
  5675.  from accessing the files.  Other methods, such as internal locking (such as 
  5676.  using 'L' in the tag field as a program-aware in-use flag), work fine so long 
  5677.  as each process accessing the files knows about this internal "locking". 
  5678.  However, since it's proprietary, other processes may not know about it.  Any 
  5679.  locking system that is not commonly shared throughout the system is not 
  5680.  effective when it comes to preventing other processes from corrupting files. 
  5681.  
  5682.  Note:  Region locking prevents other processes from both writing and reading 
  5683.  the locked file.  For operating systems that do not provide shared locks, and 
  5684.  read-access is required at all times, you may specify this type access with 
  5685.  the access-sharing mode when the BULLET file is opened.  Once opened for this 
  5686.  (R/W, DenyWrite) then only the current process can write to the file until it 
  5687.  is closed.  Other processes must open the file for Read-Only access.  For 
  5688.  small networks (two or three nodes), this may be suitable.  Otherwise, region 
  5689.  locking is much preferred, and very much faster, since files do not have to be 
  5690.  opened and closed every time the access state needs to change. 
  5691.  
  5692.  
  5693. ΓòÉΓòÉΓòÉ 9.62. UNLOCK_XB ΓòÉΓòÉΓòÉ
  5694.  
  5695. Pack: LOCKPACK                 Source Example 
  5696.  
  5697.      IN               OUT
  5698.    LP.func          LP.stat
  5699.    LP.handle
  5700.    LP.recStart=0
  5701.    LP.nextPtr
  5702.  
  5703.  Unlock all bytes in the specified files (previously locked) and flush the 
  5704.  files' headers to disk (the flush is done before the locks are released). Also 
  5705.  unlock all bytes in the related data file and flush the data file header to 
  5706.  disk.  LP.recStart must be 0 for each pack. 
  5707.  
  5708.  Note:  If a shared-lock is active for this handle (as set by this process), 
  5709.  the flush is not performed.  This because writing to the locked region is not 
  5710.  permitted (nor is the flush required since nothing could have been changed). 
  5711.  
  5712.  If the routine failed to complete, the function return value is the number 
  5713.  (1-based) of the pack that caused the failure.  A positive number indicates 
  5714.  the failure was from an index operation; a negative number indicates the 
  5715.  failure was from a data operation.  In each case, the absolute value of the 
  5716.  return code is the list item that failed (the pack index).  For example, if 
  5717.  five index handles are in the list(AP[0] to AP[4]), and an error occurred on 
  5718.  the last pack's index file, the return code would be positive 5, indicating 
  5719.  the fifth pack (AP[4]) failed.  Since it was a positive 5, the index file was 
  5720.  being processed when the error occurred.  Being processed means not only 
  5721.  physical access, but verification, etc.  If the return code was -5, then 
  5722.  again, the error was in the fifth pack, but since it is negative, the error 
  5723.  occurred while processing the data file. 
  5724.  
  5725.  This routine does not attempt to re-lock those files unlocked successfully if 
  5726.  an error occurs in the transaction.  If an error does occur (unlikely), the 
  5727.  remaining files must be manually unlocked with the UNLOCK_KEY_XB and 
  5728.  UNLOCK_DATA_XB routines. 
  5729.  
  5730.  Bullet maintains a per-handle lock count, and does a physical region lock only 
  5731.  upon the first lock request (or on a relock request).  It is only on this 
  5732.  first lock request that the header is reloaded.  When the lock count returns 
  5733.  to 0 (from UNLOCK_XB calls), it is at that time the header is flushed, if 
  5734.  required.  Only full-locks are maintained in this way.  The number of 
  5735.  outstanding locks can be determined from the SIP and SDP structures, from the 
  5736.  STAT_XB routines.  Note that individual LOCK_INDEX_XB and UNLOCK_INDEX_XB 
  5737.  routines, as well as the data ones, also act upon this lock count.  Therefore, 
  5738.  you can lock a file 100 times in a row, but only on the first lock are any 
  5739.  operations actually performed, and only on the last unlock are any performed. 
  5740.  Other lock/unlock calls (other than the first lock or last unlock) simply 
  5741.  increment or decrement the lock count for that handle. 
  5742.  
  5743.  
  5744. ΓòÉΓòÉΓòÉ 9.63. LOCK_INDEX_XB ΓòÉΓòÉΓòÉ
  5745.  
  5746. Pack: LOCKPACK                 Source Example 
  5747.  
  5748.      IN               OUT
  5749.    LP.func          LP.stat
  5750.    LP.handle
  5751.    LP.xlMode
  5752.  
  5753.  Lock all bytes of the index file for exclusive use by the current process and 
  5754.  reload the index file's header from disk. 
  5755.  
  5756.  LP.xlMode is set to 1 to perform a shared lock.  Set to 0 for an exclusive 
  5757.  lock.  A shared lock allows only reading.  The lock mode (shared <-> 
  5758.  exclusive) can be changed using RELOCK_INDEX_XB. 
  5759.  
  5760.  Bullet maintains a per-handle lock count, and does a physical region lock only 
  5761.  upon the first lock request (or on a relock request).  It is only on this 
  5762.  first lock request that the header is reloaded.  When the lock count returns 
  5763.  to 0 (from UNLOCK_XB calls), it is at that time the header is flushed, if 
  5764.  required.  Only full-locks are maintained in this way.  The number of 
  5765.  outstanding locks can be determined from the SIP and SDP structures, from the 
  5766.  STAT_XB routines.  Note that individual LOCK_INDEX_XB and UNLOCK_INDEX_XB 
  5767.  routines, as well as the data ones, also act upon this lock count.  Therefore, 
  5768.  you can lock a file 100 times in a row, but only on the first lock are any 
  5769.  operations actually performed, and only on the last unlock are any performed. 
  5770.  Other lock/unlock calls (other than the first lock or last unlock) simply 
  5771.  increment or decrement the lock count for that handle. 
  5772.  
  5773.  
  5774. ΓòÉΓòÉΓòÉ 9.64. UNLOCK_INDEX_XB ΓòÉΓòÉΓòÉ
  5775.  
  5776. Pack: LOCKPACK                 Source Example 
  5777.  
  5778.      IN               OUT
  5779.    LP.func          LP.stat
  5780.    LP.handle
  5781.  
  5782.  Unlock all bytes in the specified file (previously locked) and flush the 
  5783.  file's header to disk (the flush is done before the locks are released). 
  5784.  
  5785.  If the current lock state is shared, the flush is not performed. 
  5786.  
  5787.  Bullet maintains a per-handle lock count, and does a physical region lock only 
  5788.  upon the first lock request (or on a relock request).  It is only on this 
  5789.  first lock request that the header is reloaded.  When the lock count returns 
  5790.  to 0 (from UNLOCK_XB calls), it is at that time the header is flushed, if 
  5791.  required.  Only full-locks are maintained in this way.  The number of 
  5792.  outstanding locks can be determined from the SIP and SDP structures, from the 
  5793.  STAT_XB routines.  Note that individual LOCK_INDEX_XB and UNLOCK_INDEX_XB 
  5794.  routines, as well as the data ones, also act upon this lock count.  Therefore, 
  5795.  you can lock a file 100 times in a row, but only on the first lock are any 
  5796.  operations actually performed, and only on the last unlock are any performed. 
  5797.  Other lock/unlock calls (other than the first lock or last unlock) simply 
  5798.  increment or decrement the lock count for that handle. 
  5799.  
  5800.  
  5801. ΓòÉΓòÉΓòÉ 9.65. LOCK_DATA_XB ΓòÉΓòÉΓòÉ
  5802.  
  5803. Pack: LOCKPACK                 Source Example 
  5804.  
  5805.      IN               OUT
  5806.    LP.func          LP.stat
  5807.    LP.handle
  5808.    LP.dlMode
  5809.    LP.recStart
  5810.    LP.recCount
  5811.  
  5812.  Lock all bytes of the data file specified in LP.handle for exclusive use by 
  5813.  the current process.  It also reloads the data file header from disk. You must 
  5814.  set LP.recStart=0 to lock all bytes.  To lock a single record, or a set of 
  5815.  contiguous records, set LP.recStart to the first record to lock and 
  5816.  LP.recCount to the number of records to lock. 
  5817.  
  5818.  Header re-loading is performed only if locking all bytes. 
  5819.  
  5820.  If LP.recStart is not 0, be aware that the header is not locked, nor is it 
  5821.  re-loaded.  Also, maintaining a lock on the single record prevents any other 
  5822.  process from doing a full lock on that data file, thereby preventing write 
  5823.  access to the file from any other BULLET process using LOCK_XB, but not 
  5824.  necessarily preventing other applications from writing to that file.  That may 
  5825.  or may not be good.  It does not prevent other BULLET processes from reading 
  5826.  that file (except for that locked record). 
  5827.  
  5828.  Multiple single records are allowed, but each must then be unlocked 
  5829.  individually, in the same format (start, count) as the lock. 
  5830.  
  5831.  LP.dlMode is set to 1 to perform a shared lock.  Set to 0 for an exclusive 
  5832.  lock.  A shared lock allows only reading.  The lock mode (shared <-> 
  5833.  exclusive) can be changed using RELOCK_DATA_XB. 
  5834.  
  5835.  Bullet maintains a per-handle lock count, and does a physical region lock only 
  5836.  upon the first lock request (or on a relock request).  It is only on this 
  5837.  first lock request that the header is reloaded.  When the lock count returns 
  5838.  to 0 (from UNLOCK_XB calls), it is at that time the header is flushed, if 
  5839.  required.  Only full-locks are maintained in this way.  The number of 
  5840.  outstanding locks can be determined from the SIP and SDP structures, from the 
  5841.  STAT_XB routines.  Note that individual LOCK_INDEX_XB and UNLOCK_INDEX_XB 
  5842.  routines, as well as the data ones if a full lock, also act upon this lock 
  5843.  count.  Therefore, you can lock a file 100 times in a row, but only on the 
  5844.  first lock are any operations actually performed, and only on the last unlock 
  5845.  are any performed.  Other lock/unlock calls (other than the first lock or last 
  5846.  unlock) simply increment or decrement the lock count for that handle. 
  5847.  
  5848.  
  5849. ΓòÉΓòÉΓòÉ 9.66. UNLOCK_DATA_XB ΓòÉΓòÉΓòÉ
  5850.  
  5851. Pack: LOCKPACK                 Source Example 
  5852.  
  5853.      IN               OUT
  5854.    LP.func          LP.stat
  5855.    LP.handle
  5856.    LP.recStart
  5857.    LP.recCount
  5858.  
  5859.  Unlock all bytes in the specified file handle (previously locked) and flush 
  5860.  the data file header to disk (the flush is done before the lock is released). 
  5861.  You must set LP.recStart=0 to unlock all bytes.  To unlock a single record, or 
  5862.  a set of contiguous records, set LP.recStart to the first record to unlock and 
  5863.  LP.recCount to the number of records to unlock. 
  5864.  
  5865.  Header flushing is performed only if unlocking a full lock. 
  5866.  
  5867.  An unlock must exactly mimic its corresponding lock.  This means if you lock 
  5868.  several records singly, you must unlock each of those records -- you cannot 
  5869.  use LP.recStart=0 to unlock singly-locked records. 
  5870.  
  5871.  Bullet maintains a per-handle lock count, and does a physical region lock only 
  5872.  upon the first lock request (or on a relock request).  It is only on this 
  5873.  first lock request that the header is reloaded.  When the lock count returns 
  5874.  to 0 (from UNLOCK_XB calls), it is at that time the header is flushed, if 
  5875.  required.  Only full-locks are maintained in this way.  The number of 
  5876.  outstanding locks can be determined from the SIP and SDP structures, from the 
  5877.  STAT_XB routines.  Note that individual LOCK_INDEX_XB and UNLOCK_INDEX_XB 
  5878.  routines, as well as the data ones if a full lock, also act upon this lock 
  5879.  count.  Therefore, you can lock a file 100 times in a row, but only on the 
  5880.  first lock are any operations actually performed, and only on the last unlock 
  5881.  are any performed.  Other lock/unlock calls (other than the first lock or last 
  5882.  unlock) simply increment or decrement the lock count for that handle. 
  5883.  
  5884.  
  5885. ΓòÉΓòÉΓòÉ 9.67. CHECK_REMOTE_XB ΓòÉΓòÉΓòÉ
  5886.  
  5887. Pack: REMOTEPACK               Source Example 
  5888.  
  5889.      IN               OUT
  5890.    RP.func          RP.stat
  5891.    RP.handle        RP.isRemote
  5892.       -or-          RP.flags=0
  5893.    RP.drive         RP.isShare=1
  5894.  
  5895.  If RP.handle is non-zero, determine if the specified handle of a file or 
  5896.  device is remote.  If the handle is local (e.g., not a network file or 
  5897.  device), RP.isRemote returns 0, otherwise it is remote.  RP.flags=0 and 
  5898.  RP.isShare=1 on return for either a handle or drive check under OS/2. 
  5899.  
  5900.  If RP.handle is zero, determine if the drive specified in RP.drive is remote. 
  5901.  Drive A: is 1, B: is 2, C: is 3, and so on.  To check the default drive use 0 
  5902.  (the default drive is the current drive).  If the drive is local (e.g., not a 
  5903.  network drive), RP.isRemote returns 0, otherwise it is remote. 
  5904.  
  5905.  The significance of the remote-ness is less important in a multitasking 
  5906.  environment since sharing of resources (files, in particular) must always be 
  5907.  managed, compared to single-tasking environments where, typically, sharing 
  5908.  (locking mechanisms) need only be performed when the resource is able to be 
  5909.  accessed by another process (ie is a 'network' drive).  Note that the resource 
  5910.  need not be located elsewhere to be classified as remote: Drives or devices or 
  5911.  files on the same machine may be classified as remote if the network software 
  5912.  is redirecting local access (such as on a server). 
  5913.  
  5914.  Note:  This routine is not mutex-protected. 
  5915.  
  5916.  
  5917. ΓòÉΓòÉΓòÉ 9.68. RELOCK_XB ΓòÉΓòÉΓòÉ
  5918.  
  5919. Pack: LOCKPACK                 Source Example 
  5920.  
  5921.      IN               OUT
  5922.    LP.func          LP.stat
  5923.    LP.handle
  5924.    LP.xlMode
  5925.    LP.dlMode
  5926.    LP.recStart=0
  5927.    LP.nextPtr
  5928.  
  5929.  Relock all bytes of the index files for the mode specified in LP.xlMode (index 
  5930.  files) and LP.dlMode (data files).  Also relock all bytes in the related data 
  5931.  file.  LP.recStart must be 0 for each pack. 
  5932.  
  5933.  Set LP.xlMode=1 to select a shared lock for the index file; set to 0 for an 
  5934.  exclusive lock.  Set LP.dlMode=1 to select a shared lock for the data file; 
  5935.  set to 0 for an exclusive lock. 
  5936.  
  5937.  If the lock mode is from exclusive to shared, the file is flushed before the 
  5938.  shared state is set.  BULLET maintains the current lock state and knows which 
  5939.  direction the lock is going in.  The lock state (shared or exclusive) can be 
  5940.  determined by the SIP and SDP structures from the STAT_XB routines.  This 
  5941.  routine does not affect the lock count, nor are the headers reloaded (nor 
  5942.  should they be). 
  5943.  
  5944.  The lock state is on a file handle basis, not on an LP[] pack basis. This 
  5945.  means the file, as identified by the handle, is in the lock state last set. 
  5946.  
  5947.  Note:  The lock switch is made atomic:  Rather than unlocking, and then 
  5948.  locking again in the new state, this performs all operations without the 
  5949.  possibility that another process can grab the lock away. 
  5950.  
  5951.  
  5952. ΓòÉΓòÉΓòÉ 9.69. RELOCK_INDEX_XB ΓòÉΓòÉΓòÉ
  5953.  
  5954. Pack: LOCKPACK                 Source Example 
  5955.  
  5956.      IN               OUT
  5957.    LP.func          LP.stat
  5958.    LP.handle
  5959.    LP.xlMode
  5960.  
  5961.  Relock all bytes of the index file for the mode specified in LP.xlMode and 
  5962.  reload the header. 
  5963.  
  5964.  Set LP.xlMode=1 to select a shared lock; set to 0 for an exclusive lock. If 
  5965.  the lock mode is from exclusive to shared, the file is flushed before the 
  5966.  shared state is set.  BULLET maintains the current lock state and knows which 
  5967.  direction the lock is going in.  The lock state (shared or exclusive) can be 
  5968.  determined by the SIP structure from the STAT_INDEX_XB routine.  This routine 
  5969.  does not affect the lock count, nor is the header reloaded (nor should it be). 
  5970.  
  5971.  Note:  The lock switch is made atomic:  Rather than unlocking, and then 
  5972.  locking again in the new state, this performs all operations without the 
  5973.  possibility that another process can grab the lock away. 
  5974.  
  5975.  
  5976. ΓòÉΓòÉΓòÉ 9.70. RELOCK_DATA_XB ΓòÉΓòÉΓòÉ
  5977.  
  5978. Pack: LOCKPACK                 Source Example 
  5979.  
  5980.      IN               OUT
  5981.    LP.func          LP.stat
  5982.    LP.handle
  5983.    LP.dlMode
  5984.    LP.recStart
  5985.    LP.recCount
  5986.  
  5987.  Relock all bytes of the data file for the mode specified in LP.dlMode and 
  5988.  reload the header, unless LP.recStart is non-zero. 
  5989.  
  5990.  If the lock mode is from exclusive to shared, the file is flushed before the 
  5991.  shared state is set.  BULLET maintains the current lock state and knows which 
  5992.  direction the lock is going in.  The lock state (shared or exclusive) can be 
  5993.  determined by the SDP structure from the STAT_DATA_XB routine.  This routine 
  5994.  does not affect the lock count, nor is the header reloaded (nor should it be). 
  5995.  
  5996.  You must set LP.recStart=0 to relock all bytes.  To relock a single record, or 
  5997.  set of contiguous records, set LP.recStart=record# to relock and LP.recCount 
  5998.  to the number of records to relock. 
  5999.  
  6000.  Note:  The lock switch is made atomic:  Rather than unlocking, and then 
  6001.  locking again in the new state, this performs all operations without the 
  6002.  possibility that another process can grab the lock away. 
  6003.  
  6004.  
  6005. ΓòÉΓòÉΓòÉ 9.71. DELETE_FILE_DOS ΓòÉΓòÉΓòÉ
  6006.  
  6007. Pack: DOSFILEPACK              Source Example 
  6008.  
  6009.      IN               OUT
  6010.    DFP.func         DFP.stat
  6011.    DFP.filenamePtr
  6012.  
  6013.  Delete the specified file. 
  6014.  
  6015.  Note:  OS/2 DosForceDelete is used so the file is not recoverable with the 
  6016.  UNDELETE command. 
  6017.  
  6018.  
  6019. ΓòÉΓòÉΓòÉ 9.72. RENAME_FILE_DOS ΓòÉΓòÉΓòÉ
  6020.  
  6021. Pack: DOSFILEPACK              Source Example 
  6022.  
  6023.      IN               OUT
  6024.    DFP.func         DFP.stat
  6025.    DFP.filenamePtr
  6026.    DFP.newNamePtr
  6027.  
  6028.  Rename a file.  May also be used to move the file to a new directory within 
  6029.  the partition. 
  6030.  
  6031.  If the specified directory differs from the file's directory, the file's 
  6032.  directory entry is moved to the new directory. 
  6033.  
  6034.  For example, if the filenamePtr filename is /LP100/PROJ94A.INF and the 
  6035.  newFilenamePtr filename is /ARCH/PROJ93A.INA, the file is essentially renamed 
  6036.  and also moved to the /ARCH directory. 
  6037.  
  6038.  
  6039. ΓòÉΓòÉΓòÉ 9.73. CREATE_FILE_DOS ΓòÉΓòÉΓòÉ
  6040.  
  6041. Pack: DOSFILEPACK              Source Example 
  6042.  
  6043.      IN               OUT
  6044.    DFP.func         DFP.stat
  6045.    DFP.filenamePtr
  6046.    DFP.attr
  6047.  
  6048.  Create a new file. 
  6049.  
  6050.  The specified filename/pathname must not already exist. 
  6051.  
  6052.  The file created is not left open.  You must OPEN_FILE_DOS to use it. 
  6053.  
  6054.  The attribute used during the create can be: 
  6055.  
  6056.    Attribute  Value   Meaning
  6057.     Normal       0      normal access permitted to file
  6058.     Read-Only    1      read-only access permitted to file
  6059.     Hidden       2      file does not appear in directory listing
  6060.     System       4      file is a system file
  6061.     SubDir      10h     FILENAME is a subdirectory
  6062.     Archive     20h     file is marked for archiving
  6063.  
  6064.  Note:  Use MAKE_DIR_DOS to create a subdirectory. 
  6065.  
  6066.  
  6067. ΓòÉΓòÉΓòÉ 9.74. OPEN_FILE_DOS ΓòÉΓòÉΓòÉ
  6068.  
  6069. Pack: DOSFILEPACK              Source Example 
  6070.  
  6071.      IN               OUT
  6072.    DFP.func         DFP.stat
  6073.    DFP.filenamePtr  DFP.handle
  6074.    DFP.asMode
  6075.  
  6076.  Open the file with the access-sharing mode, returning the handle on success. 
  6077.  
  6078.  
  6079. ΓòÉΓòÉΓòÉ 9.75. SEEK_FILE_DOS ΓòÉΓòÉΓòÉ
  6080.  
  6081. Pack: DOSFILEPACK              Source Example 
  6082.  
  6083.      IN               OUT
  6084.    DFP.func         DFP.stat
  6085.    DFP.handle       DFP.seekTo
  6086.    DFP.seekTo
  6087.    DFP.method
  6088.  
  6089.  Position the file pointer of the file to the seekTo position based on the 
  6090.  method specified. 
  6091.  
  6092.  The position is a 32-bit value and is relative to either the start of the 
  6093.  file, the current file pointer position, or the end of the file. 
  6094.  
  6095.   Method   Meaning
  6096.     0      start move from the start of file (offset is a 32-bit unsigned value)
  6097.     1      start move at the current position (offset a signed value)
  6098.     2      start move at the end of file (offset a signed value)
  6099.  For example, to move to the last byte of a sector (512th byte, but offset 
  6100.  511), set the offset value to 511 and use Method 0.  On return, the absolute 
  6101.  offset value of the new position is returned.  This return value is useful 
  6102.  with Method 2 since you can specify an offset of 0 and have the file length 
  6103.  returned.  To move to the start of the file, use method 0, offset 0.  To move 
  6104.  to the first byte of the second sector, use offset 512. 
  6105.  
  6106.  Note:  Never position the file pointer to before the start of file. 
  6107.  
  6108.  
  6109. ΓòÉΓòÉΓòÉ 9.76. READ_FILE_DOS ΓòÉΓòÉΓòÉ
  6110.  
  6111. Pack: DOSFILEPACK              Source Example 
  6112.  
  6113.      IN               OUT
  6114.    DFP.func         DFP.stat
  6115.    DFP.handle       DFP.bytes
  6116.    DFP.bytes
  6117.    DFP.bufferPtr
  6118.  
  6119.  Read from the file or device the specified number of bytes into a buffer. 
  6120.  
  6121.  On block devices (such as disks) input starts at the current file position and 
  6122.  the file pointer is repositioned to the last byte read +1. 
  6123.  
  6124.  It is possible to read less than the bytes specified without an error being 
  6125.  generated.  Compare the bytes to read with the returned bytes read value.  If 
  6126.  less then end of file was reached during the read.  If 0 then file was already 
  6127.  at EOF. 
  6128.  
  6129.  
  6130. ΓòÉΓòÉΓòÉ 9.77. WRITE_FILE_DOS ΓòÉΓòÉΓòÉ
  6131.  
  6132. Pack: DOSFILEPACK              Source Example 
  6133.  
  6134.      IN               OUT
  6135.    DFP.func         DFP.stat
  6136.    DFP.handle       DFP.bytes
  6137.    DFP.bytes
  6138.    DFP.bufferPtr
  6139.  
  6140.  Write to the file or device the specified number of bytes from a buffer. 
  6141.  
  6142.  If the number of bytes written is less than the specified bytes, this routine 
  6143.  returns an error. 
  6144.  
  6145.  On block devices (such as disk) output starts at the current file position, 
  6146.  and the file pointer is repositioned to the last byte written +1. 
  6147.  
  6148.  Note:  If the specified bytes to write is 0, the file is truncated at the 
  6149.  current file pointer position. 
  6150.  
  6151.  
  6152. ΓòÉΓòÉΓòÉ 9.78. CLOSE_FILE_DOS ΓòÉΓòÉΓòÉ
  6153.  
  6154. Pack: DOSFILEPACK              Source Example 
  6155.  
  6156.      IN               OUT
  6157.    DFP.func         DFP.stat
  6158.    DFP.handle
  6159.  
  6160.  Close the file flushing any internal buffers, releasing any locked regions, 
  6161.  and updating the directory entry to the correct size, date, and time. 
  6162.  
  6163.  
  6164. ΓòÉΓòÉΓòÉ 9.79. ACCESS_FILE_DOS ΓòÉΓòÉΓòÉ
  6165.  
  6166. Pack: DOSFILEPACK              Source Example 
  6167.  
  6168.      IN               OUT
  6169.    DFP.func         DFP.stat
  6170.    DFP.filenamePtr
  6171.    DFP.asMode
  6172.  
  6173.  Determine if the specified file can be accessed with the specified 
  6174.  access-sharing mode. 
  6175.  
  6176.  Basically, a Does-File-Exist routine.  It uses the specified access-sharing 
  6177.  mode when trying to open the file.  For example, if you specify DFP.attr = 
  6178.  0x0042 (R/W access + Deny None sharing) and issue ACCESS_FILE_DOS on a 
  6179.  Read-Only file, an error is returned.  A sharing mode must be specified; it 
  6180.  cannot be left 0. 
  6181.  
  6182.  
  6183. ΓòÉΓòÉΓòÉ 9.80. EXPAND_FILE_DOS ΓòÉΓòÉΓòÉ
  6184.  
  6185. Pack: DOSFILEPACK              Source Example 
  6186.  
  6187.      IN               OUT
  6188.    DFP.func         DFP.stat
  6189.    DFP.handle
  6190.    DFP.bytes
  6191.  
  6192.  Expands the file by the number of bytes beyond its current size. 
  6193.  
  6194.  This routine is useful in pre-allocating disk space.  By reserving disk space 
  6195.  in advance you can guarantee that enough disk space will be available for a 
  6196.  future operation (especially if more than 1 process is running). You'll also 
  6197.  be able ensure that the disk space that a file does use is as contiguous as 
  6198.  possible. 
  6199.  
  6200.  Database systems are dynamic and their files typically allocate new space on 
  6201.  an as-needed basis.  This dynamic allocation can cause parts of a file to be 
  6202.  located throughout the disk system, possibly affecting performance 
  6203.  drastically.  By pre-allocating the disk space you can be assured of 
  6204.  consistent throughput performance since the file is contiguous. 
  6205.  
  6206.  Note:  The file space is not initialized. 
  6207.  
  6208.  * --------------------------------------------------------------------------- 
  6209.  
  6210.  
  6211. ΓòÉΓòÉΓòÉ 9.81. MAKE_DIR_DOS ΓòÉΓòÉΓòÉ
  6212.  
  6213. Pack: DOSFILEPACK              Source Example 
  6214.  
  6215.      IN               OUT
  6216.    DFP.func         DFP.stat
  6217.    DFP.filenamePtr
  6218.  
  6219.  Create a new subdirectory. 
  6220.  
  6221.  
  6222. ΓòÉΓòÉΓòÉ 9.82. COMMIT_FILE_DOS ΓòÉΓòÉΓòÉ
  6223.  
  6224. Pack: DOSFILEPACK              Source Example 
  6225.  
  6226.      IN               OUT
  6227.    DFP.func         DFP.stat
  6228.    DFP.handle
  6229.  
  6230.  Flushes the OS system buffers for the handle, and updates the directory entry 
  6231.  for size. 
  6232.  
  6233.  
  6234. ΓòÉΓòÉΓòÉ 10. Bullet Source Examples ΓòÉΓòÉΓòÉ
  6235.  
  6236. Bullet source example excerpts for the C language follow.  Complete program 
  6237. source examples are provide on the included disk. 
  6238.  
  6239. In the examples, consider that 
  6240.  
  6241.         CHAR keyBuffer[64];
  6242.         AP.keyPtr = keyBuffer;
  6243.  
  6244. provides the compiler with a pointer whenever 'keyBuffer' is referenced, hence 
  6245. no need to use &keyBuffer.  Contrast this with a structure definition 
  6246.  
  6247.         struct yourRecordLayout yourRecord;
  6248.         AP.recPtr = &yourRecord;
  6249.  
  6250. where &yourRecord is required. 
  6251.  
  6252. Be aware of how you use zero-terminated strings, especially for fields that are 
  6253. not to be 0T'ed (DATE and NUMERIC fields, for example).  Use sscanf() and 
  6254. sprintf(), as required. 
  6255.  
  6256.  
  6257. ΓòÉΓòÉΓòÉ 10.1. Bullet Initialization ΓòÉΓòÉΓòÉ
  6258.  
  6259. /* All example source uses minimal error checking/handling throughout */
  6260. // comment marks are used throughout
  6261.  
  6262. // To simplify the source examples, error handling is typically of the form:
  6263. //
  6264. //   if (rez) goto ErrorHandler;
  6265. //
  6266. // Use suitable coding as you would normally handle the error.
  6267.  
  6268. #include "bullet_2.h"
  6269.  
  6270. INITPACK IP;                    // packs used here
  6271.  
  6272. // INIT_XB must be the first Bullet routine used
  6273.  
  6274. IP.func = INIT_XB;              // start up Bullet
  6275. IP.JFTsize = 30;                // allow at least 30 handles to be open
  6276. rez = BULLET(&IP);
  6277. if (rez) return(rez);
  6278.  
  6279.  
  6280. ΓòÉΓòÉΓòÉ 10.2. Bullet Shutdown ΓòÉΓòÉΓòÉ
  6281.  
  6282. #include "bullet_2.h"
  6283.  
  6284. EXITPACK EP;                    // packs used here
  6285.  
  6286. EP.func = EXIT_XB;              // shutdown Bullet
  6287. rez = BULLET(&EP);
  6288. if (rez) return(rez);
  6289.  
  6290.  
  6291. ΓòÉΓòÉΓòÉ 10.3. Memory Available ΓòÉΓòÉΓòÉ
  6292.  
  6293. #include "bullet_2.h"
  6294.  
  6295. MEMORYPACK EP;                  // packs used here
  6296.  
  6297. MP.func = MEMORY_XB;
  6298. rez = BULLET(&MP);
  6299. if (rez==0) {
  6300.    printf("Private memory arena space right now is %d bytes\n",MP.memory);
  6301. }
  6302.  
  6303.  
  6304. ΓòÉΓòÉΓòÉ 10.4. File Backup Procedure ΓòÉΓòÉΓòÉ
  6305.  
  6306. #include "bullet_2.h"
  6307.  
  6308. // code determines file type of handle, and selects appropriate backup method
  6309. // this type of work (copy/backup) would be a prelude to reindexing an index
  6310. // file or performing a pack on a data file since both of those routines
  6311. // overwrite existing data
  6312.  
  6313. COPYPACK CP;
  6314. LOCKPACK LP;
  6315. STATHANDLEPACK SHP;
  6316. STATDATAPACK SDP;
  6317. STATINDEXPACK SIP;
  6318.  
  6319. CHAR CopyOfIndexHdrName[260];
  6320. CHAR BackupDataName[260];
  6321.  
  6322. // Given a handle, find out its type and, if index, generate a copy
  6323. // of the index file's header, or if data, backup the entire data file.
  6324. // Files are locked to ensure that access if permissible.
  6325.  
  6326. SHP.func = STAT_HANDLE_XB;
  6327. SHP.handle = passedHandle;
  6328. rez = BULLET(&SHP);
  6329. if (SHP.ID==-1)
  6330.    puts("Handle is not a Bullet data or index file.  Use DosCopy() API call.");
  6331. else {
  6332.    if (SHP.ID==0) {
  6333.  
  6334.       // Since the copy takes place on open files, ensure a full-lock is in place
  6335.       // A shared lock is okay since this file is only read
  6336.  
  6337.       // locking the entire file also RELOADS the index header
  6338.  
  6339.       LP.func = LOCK_INDEX_XB;
  6340.       LP.handle = passedHandle;
  6341.       LP.xlMode = LOCK_SHARED;          // in bullet_2.h
  6342.       rez = BULLET(&LP);
  6343.       if (rez) goto ErrorHandler;
  6344.  
  6345.       SIP.func = STAT_INDEX_XB;
  6346.       SIP.handle = passedHandle;
  6347.       rez = BULLET(&SIP);
  6348.       if (rez) goto ErrorHandler;       // must unlock file in handler
  6349.  
  6350.       // SIP.filenamePtr -> pathname of this handle, from which you can
  6351.       // derive a suitable name for the index header written next -- in
  6352.       // case it's not obvious, this function is not part of Bullet
  6353.  
  6354.       DeriveSuitableName(SIP.filenamePtr,CopyOfIndexHdrName);
  6355.  
  6356.       CP.func = COPY_INDEX_HEADER_XB;
  6357.       CP.handle = passedHandle;
  6358.       CP.filenamePtr = CopyOfIndexHdrName;
  6359.       rez = BULLET(&CP);
  6360.       if (rez) goto ErrorHandler;       // must unlock file in handler
  6361.  
  6362.       // unlocking also flushes the index header if not LOCK_SHARED (and if required)
  6363.  
  6364.       LP.func = UNLOCK_INDEX_XB;
  6365.       LP.handle = passedHandle;
  6366.       rez = BULLET(&LP);
  6367.       if (rez) goto ErrorHandler;
  6368.    }
  6369.    else {
  6370.  
  6371.       // locking the entire file also RELOADS the data header
  6372.  
  6373.       LP.func = LOCK_DATA_XB;
  6374.       LP.handle = passedHandle;
  6375.       LP.dlMode = LOCK_SHARED;
  6376.       LP.startRec = 0;                  // lock entire data file
  6377.       rez = BULLET(&LP);
  6378.       if (rez) goto ErrorHandler;
  6379.  
  6380.       SDP.func = STAT_DATA_XB;
  6381.       SDP.handle = passedHandle;
  6382.       rez = BULLET(&SDP);
  6383.       if (rez) goto ErrorHandler;       // must unlock file in handler
  6384.  
  6385.       DeriveSuitableName(SDP.filenamePtr,BackupDataName);
  6386.  
  6387.       CP.func = BACKUP_FILE_XB;
  6388.       CP.handle = passedHandle;         // set to -passedHandle to skip memo backup
  6389.       CP.filenamePtr = BackupDataName;
  6390.       rez = BULLET(&CP);
  6391.       if (rez) goto ErrorHandler;       // must unlock file in handler
  6392.  
  6393.       // unlocking also flushes the data header if not LOCK_SHARED (and if required)
  6394.  
  6395.       LP.func = UNLOCK_DATA_XB;
  6396.       LP.handle = passedHandle;
  6397.       rez = BULLET(&LP);
  6398.       if (rez) goto ErrorHandler;
  6399.    }
  6400. }
  6401.  
  6402.  
  6403. ΓòÉΓòÉΓòÉ 10.5. Get Error Class ΓòÉΓòÉΓòÉ
  6404.  
  6405. #include "bullet_2.h"
  6406.  
  6407. XERRORPACK XEP;                 // packs used here
  6408.  
  6409. // Bullet errors range from 8192 to 8999, any other return code
  6410. // indicates the error number was generated by OS/2 itself
  6411.  
  6412. if (rez < 8192) | (rez > 8999) {
  6413.    XEP.func = GET_ERROR_CLASS_XB;
  6414.    XEP.stat = rez;
  6415.    rez = BULLET(&XEP);
  6416.  
  6417.    // here XEP.errClass, .action, and .location are set
  6418.    // this call is the same as OS/2 API DosErrClass()
  6419.  
  6420.  
  6421. ΓòÉΓòÉΓòÉ 10.6. Query System Variables ΓòÉΓòÉΓòÉ
  6422.  
  6423. #include "bullet_2.h"
  6424.  
  6425. QUERYSETPACK  QSP;              // packs used here
  6426.  
  6427. // Query a Bullet system variable
  6428.  
  6429. QSP.func = QUERY_SYSVARS_XB;
  6430. QSP.item = MUTEX_SEM_HANDLE;    // in bullet_2.h
  6431. rez = BULLET(&QSP);
  6432. if (rez==0)
  6433.    printf("Bullet/2 mutex handle is %d\n",QSP.itemValue);
  6434.  
  6435.  
  6436. ΓòÉΓòÉΓòÉ 10.7. Set System Variables ΓòÉΓòÉΓòÉ
  6437.  
  6438. #include "bullet_2.h"
  6439.  
  6440. QUERYSETPACK  QSP;              // packs used here
  6441.  
  6442. // Set a Bullet system variable
  6443.  
  6444. QSP.func = SET_SYSVARS_XB;
  6445. QSP.item = REINDEX_BUFFER_SIZE; // in bullet_2.h
  6446. QSP.itemValue = 384*1024;       // set to 384KB
  6447. rez = BULLET(&QSP);
  6448. if (rez==0) {
  6449.    printf("Reindex buffer sized changed to 384K.\n");
  6450.    printf("Previous setting was %d.\n",QSP.itemValue);
  6451.  
  6452.    // For REINDEX_BUFFER_SIZE, a value of 0 represents 'autosize', for which
  6453.    // Bullet selects a minimum usuable size (often 144KB).  The minimum size
  6454.    // that you can use for REINDEX_BUFFER_SIZE is 48KB.
  6455.  
  6456.  
  6457. ΓòÉΓòÉΓòÉ 10.8. Set Dual-video Monitor ΓòÉΓòÉΓòÉ
  6458.  
  6459.  
  6460. // SET_DVMON_XB is not currently used
  6461.  
  6462.  
  6463. ΓòÉΓòÉΓòÉ 10.9. Query Vectors ΓòÉΓòÉΓòÉ
  6464.  
  6465. #include "bullet_2.h"
  6466.  
  6467. QUERYSETPACK  QSP;              // packs used here
  6468.  
  6469. // Query a Bullet vector
  6470.  
  6471. QSP.func = QUERY_VECTORS_XB;
  6472. QSP.item = VECTOR_GET_SORT_TABLE;  // in bullet_2.h
  6473. rez = BULLET(&QSP);
  6474. if (rez==0)
  6475.    printf("Bullet get-sort-table vector is %x\n",QSP.itemValue);
  6476.  
  6477.  
  6478. ΓòÉΓòÉΓòÉ 10.10. Set Vectors ΓòÉΓòÉΓòÉ
  6479.  
  6480. #include "bullet_2.h"
  6481.  
  6482. QUERYSETPACK  QSP;              // packs used here
  6483.  
  6484. // Set a Bullet vector
  6485.  
  6486. // external routine (in ccdosfn.c, for example)
  6487. LONG __cdecl BulletMalloc(ULONG bytes, VOID **basePtr);
  6488.  
  6489. QSP.func = SET_VECTORS_XB;
  6490. QSP.item = VECTOR_MALLOC;
  6491. QSP.itemValue = (ULONG) &BulletMalloc;
  6492. rez = BULLET(&QSP);
  6493. if (rez==0) {
  6494.    printf("Memory allocation changed to new routine.\n");
  6495.    printf("Previous routine's address was %x.\n",QSP.itemValue);
  6496.  
  6497.  
  6498. ΓòÉΓòÉΓòÉ 10.11. Create, Open, and Close Data and Index Files ΓòÉΓòÉΓòÉ
  6499.  
  6500. #include "bullet_2.h"
  6501.  
  6502. CREATEDATAPACK  CDP;
  6503. CREATEINDEXPACK CIP;
  6504. OPENPACK        OP;
  6505. HANDLEPACK      HP;             // packs used here
  6506.  
  6507. // create the data file
  6508.  
  6509. #pragma pack(1)         // ensure compiler does not pad Bullet-used structures
  6510.                         // (not needed here since all members are CHAR)
  6511.  
  6512. // generally, only left-justified strings should be 0-terminated, numbers or
  6513. // date fields should not be 0-terminated
  6514.  
  6515. typedef struct _RECTYPE {
  6516.  CHAR tag;              // record tag, init to SPACE, '*' means deleted
  6517.  CHAR userSSN[9];       // first field in DBF (not 0-terminated in this case)
  6518.  CHAR userScore[6];     // second field (also not 0T)
  6519. } RECTYPE;              // (total record length is 16 bytes)
  6520. RECTYPE ourRecord;
  6521.  
  6522. #pragma pack()
  6523.  
  6524. CHAR nameIX3[] = "INDEX.IX3";   // index pathname
  6525. CHAR keyExpression[] = "SSN";   // key is built from field named 'SSN'
  6526. ULONG indexID=0;                // handle of opened index file
  6527. CHAR keyBuffer[68];             // buffer to store/receive key values
  6528.  
  6529. CHAR nameData[] = "DATA.DBF";   // data pathname
  6530. ULONG dataID=0;                 // handle of opened data file
  6531. FIELDDESCTYPE fieldList[2];     // 2 fields used in data record (SSN and SCORE)
  6532.  
  6533. // the field descriptor info must have unused entries set to 0
  6534.  
  6535. memset(fieldList,0,sizeof(fieldList));  // init unused bytes to 0 (required)
  6536.  
  6537. // fill in the field descriptor info for the data file you want to create
  6538. // this descriptor must match the layout of ourRecord, above (ourRecord.tag
  6539. // is implicit and is not a formal field, and so is not in fieldList[])
  6540.  
  6541. strcpy(fieldList[0].fieldName, "SSN");  // field names must be upper-case
  6542. fieldList[0].fieldType = 'C';           // field types must be upper-case
  6543. fieldList[0].fieldLen = 9;              // * Note that the .fieldname here
  6544. fieldList[0].fieldDC = 0;               // * matches the keyExpression
  6545.  
  6546. strcpy(fieldList[1].fieldName, "SCORE");
  6547. fieldList[1].fieldType = 'C';
  6548. fieldList[1].fieldLen = 6;              // 6 is total size of field
  6549. fieldList[1].fieldDC = 0;
  6550.  
  6551. // Create the data file as defined in fieldList above
  6552. // To create only a DBF, set CDP.fileID=3
  6553. // To create both a DBF and a DBT memo file, set CDP.fileID=0x8B
  6554.  
  6555. CDP.func = CREATE_DATA_XB;
  6556. CDP.filenamePtr = nameData;
  6557. CDP.noFields = 2;
  6558. CDP.fieldListPtr = fieldList;
  6559. CDP.fileID = 3;
  6560. rez = BULLET(&CDP);
  6561. if (rez) {
  6562.    printf("Failed data file create.  Err: %d\n",rez);
  6563.    return(rez);
  6564. }
  6565.  
  6566. // Open the data file (required before creating an index file for it)
  6567.  
  6568. OP.func = OPEN_DATA_XB;
  6569. OP.filenamePtr = nameData;
  6570. OP.asMode = READWRITE | DENYNONE;
  6571. rez = BULLET(&OP);
  6572. if (rez) {
  6573.    printf("Failed data file open.  Err: %d\n",rez);
  6574.    return(rez);
  6575. }
  6576. dataID = OP.handle;
  6577.  
  6578. // Create an index file for the data file opened above.
  6579. // This example uses a simple primary key: the SSN field.
  6580. // Since it is assumed to be unique, DUPS_ALLOWED is not
  6581. // OR'ed with the .sortFunction.
  6582.  
  6583. CIP.func = CREATE_INDEX_XB;
  6584. CIP.filenamePtr = nameIX3;
  6585. CIP.keyExpPtr = keyExpression;
  6586. CIP.xbLink = dataID;            // the handle of the data file
  6587. CIP.sortFunction = ASCII_SORT;  // sort key by ASCII (fine for SSN ordering)
  6588. CIP.codePage = 0;               // use OS-default code page
  6589. CIP.countryCode = 0;            // use OS-default country code
  6590. CIP.collatePtr = NULL;          // no need for a special collate table
  6591. CIP.nodeSize = 512;             // 512-byte node size (or 1024, 2048 bytes)
  6592. rez = BULLET(&CIP);
  6593. if (rez) {
  6594.    printf("Failed index file create.  Err: %d\n",rez);
  6595.    return(rez);
  6596. }
  6597.  
  6598. // Open the index file (what we just created above).
  6599. // As with the index-create, the index-open requires the handle of the data
  6600. // file which this index file indexes.
  6601.  
  6602. OP.func = OPEN_INDEX_XB;
  6603. OP.filenamePtr = nameIX3;
  6604. OP.asMode = READWRITE | DENYNONE;
  6605. OP.xbLink = dataID;
  6606. rez = BULLET(&OP);
  6607. if (rez) {
  6608.    printf("Failed index file open.  Err: %d\n",rez);
  6609.    return(rez);
  6610. }
  6611. indexID = OP.handle;
  6612.  
  6613. // at this point, both the data and index files are open and accessible
  6614.  
  6615. // |
  6616. // | do work as required, then, when done, close them
  6617. // |
  6618.  
  6619. if (indexID) {
  6620.    HP.func = CLOSE_INDEX_XB;
  6621.    HP.handle = indexID;
  6622.    rez = BULLET(&HP);
  6623.    if (rez)
  6624.       printf("Failed index file close.  Err: %d\n",rez);
  6625. }
  6626.  
  6627. if (dataID) {
  6628.    HP.func = CLOSE_DATA_XB;
  6629.    HP.handle = dataID;
  6630.    rez = BULLET(&HP);
  6631.    if (rez)
  6632.       printf("Failed data file close.  Err: %d\n",rez);
  6633. }
  6634.  
  6635.  
  6636. ΓòÉΓòÉΓòÉ 10.12. Read Data and Index Header ΓòÉΓòÉΓòÉ
  6637.  
  6638. #include "bullet_2.h"
  6639.  
  6640. HANDLEPACK HP;                  // packs used here
  6641.  
  6642. // Since it is recommended that a full-lock be in force before reloading
  6643. // data or index headers, and since performing a full lock from BULLET does
  6644. // itself reload the header, this routine would not normally be used.
  6645. // However, if you are doing your own locking, then you need to call this.
  6646.  
  6647. rez = YourExternalControlLockRoutine;  // so you have your own locks...
  6648.  
  6649. if (rez==0) {
  6650.  
  6651.    if (youWantDataReload) {
  6652.       HP.func = READ_DATA_HEADER_XB;
  6653.       HP.func = dataID;
  6654.    }
  6655.    else {
  6656.       HP.func = READ_INDEX_HEADER_XB;
  6657.       HP.func = indexID;
  6658.    }
  6659.    rez = BULLET(&HP);
  6660.  
  6661.    // since locked, release lock regardless rez value
  6662.  
  6663.    rez2 = YourExternalControlUnlockRoutine;
  6664. }
  6665.  
  6666. // Be sure to read the explanation above
  6667.  
  6668.  
  6669. ΓòÉΓòÉΓòÉ 10.13. Flush Data and Index Header ΓòÉΓòÉΓòÉ
  6670.  
  6671. #include "bullet_2.h"
  6672.  
  6673. HANDLEPACK HP;                  // packs used here
  6674.  
  6675. // While BULLET automatically flushes data and index info whenever
  6676. // a BULLET file is unlocked from a full-lock (and if it
  6677. // is needed), you may to flush more frequently.
  6678.  
  6679. // It is recommended that you have a full-lock on the file before
  6680. // flushing.  In normal use, you would always have a full-lock when
  6681. // writing to a file (the only time you need to flush is if the file
  6682. // has been written to).  If you are, for whatever reason, keeping
  6683. // the file locked, and are updating it repeatedly, and have no
  6684. // intention of unlocking (and thereby flushing it) any time soon,
  6685. // you may do a manual flush to ensure that the disk image matches
  6686. // the memory image (in case the power goes out and you have no UPS)
  6687.  
  6688. if (youWantDataFlush) {
  6689.    HP.func = FLUSH_DATA_HEADER_XB;
  6690.    HP.func = dataID;
  6691. }
  6692. else {
  6693.    HP.func = FLUSH_INDEX_HEADER_XB;
  6694.    HP.func = indexID;
  6695. }
  6696. rez = BULLET(&HP);
  6697.  
  6698. // Only if the file has been changed does a flush actually write to disk.
  6699. // You should have an exclusive full-lock; a shared full-lock cannot be
  6700. // used since a shared lock does not allow writing to the file.
  6701.  
  6702.  
  6703. ΓòÉΓòÉΓòÉ 10.14. Copy (Add) a Subset of Records to a New File ΓòÉΓòÉΓòÉ
  6704.  
  6705. #include "bullet_2.h"
  6706.  
  6707. ACCESSPACK APo;                 // used when accessing original
  6708. ACCESSPACK APn;                 // used when accessing new
  6709. COPYPACK   CP;
  6710. HANDLEPACK HP;
  6711. OPENPACK   OP;                  // packs used here
  6712.  
  6713. RECTYPE ourRecord;              // as defined in Create example
  6714.  
  6715. // Assume an open, locked DBF data file, handle in dataID, and that you
  6716. // want to copy those records that are marked as deleted, one at a time, to a
  6717. // new file, prior to packing the database.  An extension to this procedure is
  6718. // to access each record in key order, and to copy each record to the new
  6719. // file, thereby giving a SORTED data file (also known as a clustered file).
  6720. // The lock must be a full-lock, but may be a shared full-lock.  A ZAP is done
  6721. // on the new file if the copy did not complete as expected.
  6722.  
  6723. // No indexed access is used in this example.
  6724.  
  6725. CP.func = COPY_DATA_HEADER_XB;
  6726. CP.handle = dataID;             // dataID is the original data file handle
  6727. CP.filenamePtr = "DELRECS.DBF"; // new file for deleted records
  6728. rez = BULLET(&CP);
  6729. if (rez) {
  6730.    printf("Failed header copy.  Err: %d\n",rez);
  6731.    return(rez);
  6732. }
  6733.  
  6734. // DELRECS.DBF now is exactly like the original, but has 0 records.  Since
  6735. // we're building this file, open it for exclusive use (DENYREADWRTE) --
  6736. // this is different from using the LOCK_XB routines since the lock is done
  6737. // at the file open level (no other process may even open it), whereas
  6738. // the LOCK_XB routines are at the access level (other processes may
  6739. // open the file, but may or may not access it).  You could instead use
  6740. // LOCK_DATA_XB for an exclusive full-lock, but this is simpler.
  6741.  
  6742. OP.func = OPEN_DATA_XB;
  6743. OP.filenamePtr = "DELRECS.DBF";         // open it
  6744. OP.asMode = READWRITE | DENYREADWRITE;  // for exclusive use
  6745. rez = BULLET(&OP);
  6746. if (rez) {
  6747.    printf("Failed new file open.  Err: %d\n",rez);
  6748.    return(rez);
  6749. }
  6750.  
  6751. // Now have two files open:  the original, with all the records, and
  6752. // the new, with no records.  The procedure here is to get all original
  6753. // records, check each for being deleted, if so, add that record (copy it)
  6754. // to the new file.  After copying, the original file is packed so that
  6755. // all deleted records are removed.  Then an index to it is reindexed.
  6756.  
  6757. // most BULLET pack members will be invariant within loops... (low overhead!)
  6758.  
  6759. APn.func = ADD_RECORD_XB;       // AccessPack for the new file
  6760. APn.handle = OP.handle;         // the handle just opened above
  6761. APn.recPtr = &ourRecord;
  6762.  
  6763. APo.func = GET_RECORD_XB;       // AccessPack for the original file
  6764. APo.handle = dataID;
  6765. APo.recNo = 1;                  // start at the first record
  6766. APo.recPtr = &ourRecord;        // read data into this
  6767. rez = BULLET(&APo);             // read the first data record
  6768.  
  6769. while (rez==0) {
  6770.  
  6771.    // check if this record is deleted, if so copy it else continue
  6772.  
  6773.    if (ourRecord.tag = '*') {
  6774.       rez = BULLET(&APn);       // add it to the new file
  6775.       if (rez) break;
  6776.       // here APn.recNo is the record number used for the just-added record
  6777.    }
  6778.  
  6779.    // This while() loop could have been a for() loop if we had used
  6780.    // STAT_DATA_XB to get the number of records, but in this example,
  6781.    // the original file is read until EXB_BAD_RECNO is returned,
  6782.    // indicating that the last record has been passed.
  6783.  
  6784.    APo.recNo++;                 // get next original record
  6785.    rez = BULLET(&APo);          // everything else is already setup
  6786. }
  6787.  
  6788. // the expected rez here is EXB_BAD_RECNO, any other then quit
  6789.  
  6790. if (rez != EXB_BAD_RECNO) {
  6791.     printf("Failed the while() loop, ZAPing new file.  Err: %d\n",rez);
  6792.  
  6793.     // As an example, if the copy failed to complete as expected, the
  6794.     // new file is ZAP'ed, removing any records that may have been copied
  6795.     // up to the point that the error occurred -- investigate failure and
  6796.     // restart process (you may want to just delete, rather than ZAP/CLOSE).
  6797.  
  6798.     HP.func = ZAP_DATA_HEADER_XB;
  6799.     HP.handle = APn.handle;     // the new file handle
  6800.     rez2 = BULLET(&HP);         // using 'rez2' to preserve initial error code
  6801.     if (rez2)
  6802.        printf("Failed ZAP!  Err: %d\n",rez2);
  6803.  
  6804.     HP.func = CLOSE_DATA_XB;    // close
  6805.     rez2 = BULLET(&HP);
  6806.     if (rez2)
  6807.        printf("Failed CLOSE!  Err: %d\n",rez2);
  6808.  
  6809.     return(rez);                // return initial error code
  6810. }
  6811.  
  6812. // done with the new file
  6813. // it contains all the records in the original marked as deleted
  6814.  
  6815. HP.func = CLOSE_DATA_XB;        // always use the correct pack for the routine
  6816. HP.handle = APn.handle;         // -- do not try to use AP when closing a file
  6817. rez = BULLET(&HP);
  6818. if (rez) return(rez);
  6819.  
  6820. // Pack the original data file, now that we've "saved" the delete-marked recs.
  6821. // Note: You may want to use BACKUP_XB before using this next routine
  6822. // in case a serious error occurs.  BULLET packs in place!  Also, before
  6823. // packing, memos belonging to records about to be deleted should have
  6824. // have been deleted before packing.  Neither is shown here.
  6825.  
  6826. APo.func = PACK_RECORDS_XB;
  6827. rez = BULLET(&APo);
  6828. if (rez==0) {
  6829.  
  6830.    // After a pack, you must reindex any related index files.
  6831.    // Assume here one index file, handle in indexID
  6832.  
  6833.    APo.func = REINDEX_XB;
  6834.    APo.handle = indexID;
  6835.    rez = BULLET(&APo);
  6836.    if (rez)
  6837.       printf("Failed reindex.  Err: %d\n",rez);
  6838. }
  6839. else {
  6840.    printf("Failed packed!  Recommend restore from backup.  Err: %d\n",rez);
  6841.    printf("Note: Unless error is known to not be severe.\n");
  6842. }
  6843.  
  6844. // Here and rez==0 then everything went as planned.
  6845.  
  6846. return(rez);
  6847.  
  6848.  
  6849. ΓòÉΓòÉΓòÉ 10.15. Zap Index File ΓòÉΓòÉΓòÉ
  6850.  
  6851. #include "bullet_2.h"
  6852.  
  6853. HANDLEPACK HP;                  // packs used here
  6854.  
  6855. // Since BULLET reindexes in place, there's typically no need to use
  6856. // ZAP to reduce disk requirements (there won't be two separate file
  6857. // spaces since the reindex copies right over the old key data).
  6858.  
  6859. HP.func = ZAP_INDEX_HEADER_XB;
  6860. HP.handle = indexToZap;
  6861. rez = BULLET(&HP);
  6862. if (rez) return(rez);
  6863.  
  6864.  
  6865. ΓòÉΓòÉΓòÉ 10.16. Get Descriptor, Using a DBF Not Created by Bullet ΓòÉΓòÉΓòÉ
  6866.  
  6867. #include <os2.h>
  6868. #include <stdio.h>
  6869. #include <stdlib.h>
  6870. #include <string.h>
  6871.  
  6872. #include "bullet_2.h"
  6873.  
  6874. int main(int argc,char *argv[]) {
  6875.  
  6876. INITPACK IP;
  6877. EXITPACK EP;
  6878. DESCRIPTORPACK DP;
  6879. OPENPACK OP;
  6880. HANDLEPACK HP;
  6881. STATDATAPACK SDP;
  6882. ACCESSPACK AP;          // packs used here
  6883.  
  6884. PFIELDDESCTYPE fieldDescPtr;    // pointer to field descriptor base allocation
  6885. PFIELDDESCTYPE fdPtr;           // roving pointer to any field's descriptor
  6886.  
  6887. CHAR dataRec[8192];     // 'unknown' record layout since reading "any" DBF
  6888. CHAR  fmt[32];          // printf() fmt string for on-the-fly formatting
  6889. ULONG dataID;           // handle of DBF
  6890. LONG  recNo;            // loop counter
  6891. BYTE  fldNo;            // loop counter2
  6892. int   rez;              // primary op return code
  6893. int   rez2;             // secondary op return code (so to perserve primary rc)
  6894.  
  6895. if (argc < 2) {
  6896.    puts("Use: C>progname anyfile.dbf");
  6897.    return(1);
  6898. }
  6899.  
  6900. // init Bullet
  6901.  
  6902. IP.func = INIT_XB;
  6903. IP.JFTsize = 20;                // 20 handles is all we need here
  6904. rez = BULLET(&IP);
  6905. if (rez!=0) {
  6906.    printf("INIT_XB failed: %d\n",rez);
  6907.    return(1);
  6908. }
  6909.  
  6910. // open existing DBF as named in command line
  6911.  
  6912. OP.func = OPEN_DATA_XB;
  6913. OP.filenamePtr = argv[1];
  6914. OP.asMode = READWRITE | DENYNONE;
  6915. rez = BULLET(&OP);
  6916. if (rez==0) {
  6917.  
  6918.    dataID = OP.handle;
  6919.  
  6920.    SDP.func = STAT_DATA_XB;
  6921.    SDP.handle = dataID;
  6922.    rez = BULLET(&SDP);
  6923.    if (rez==0) {
  6924.  
  6925.       // allocate field descriptors needed (SDP.fields is number needed)
  6926.       // calloc() used since 0-filled storage is required
  6927.  
  6928.       fieldDescPtr = calloc(SDP.fields,sizeof(FIELDDESCTYPE));
  6929.  
  6930.       if (fieldDescPtr != NULL) {
  6931.  
  6932.          fdPtr = fieldDescPtr;          // fdPtr->each descriptor
  6933.  
  6934.          // read each field descriptor from Bullet, storing to our program
  6935.          // show each for display
  6936.  
  6937.          //      1234567890-123456789-123456789-12345
  6938.          printf("FLD#   FIELDNAME  T  LEN.DEC  OFFSET\n");
  6939.  
  6940.          DP.func = GET_DESCRIPTOR_XB;
  6941.          DP.handle = dataID;
  6942.          for (fldNo=1;fldNo <= SDP.fields;fldNo++) {
  6943.  
  6944.             DP.fieldNumber = fldNo;
  6945.             rez = BULLET(&DP);
  6946.             if (rez==0) {
  6947.  
  6948.                strcpy(fdPtr->fieldName, DP.FD.fieldName);
  6949.                fdPtr->fieldType = DP.FD.fieldType;
  6950.                fdPtr->fieldLen = DP.FD.fieldLen;
  6951.                fdPtr->fieldDC = DP.FD.fieldDC;
  6952.                fdPtr->fieldDA = DP.fieldOffset;
  6953.                printf("%3u   %-10s  %c  %3u.%1u     %4u\n",
  6954.                   fldNo,
  6955.                   fdPtr->fieldName,
  6956.                   fdPtr->fieldType,
  6957.                   (ULONG) fdPtr->fieldLen,
  6958.                   (ULONG) fdPtr->fieldDC,
  6959.                   fdPtr->fieldDA);
  6960.                fdPtr++;                 // next field descriptor
  6961.             }
  6962.             else
  6963.                break;
  6964.          }
  6965.  
  6966.          // An interesting item above is where fdPtr->fieldDA is set to
  6967.          // DP.fieldOffset.  fieldDA is a run-time storage area that in
  6968.          // dBASE is used to directly access the field (DA="direct access").
  6969.          // It has no meaning except for that particular run (it is a memory
  6970.          // address). In this program example I use it to store the offset
  6971.          // of the field, relative the start of the record buffer (where the
  6972.          // tag byte = offset 0).  You could just as easily use some of the
  6973.          // 12 reserved bytes left over in the descriptor, as I do for the
  6974.          // alternate field length.  But, since fieldDA is already there, and
  6975.          // not used otherwise, it makes sense to use it.
  6976.  
  6977.          // Now have all we need to know about the DBF fields, having just
  6978.          // read and stored the field descriptors.  For this example, we
  6979.          // grab the first nine records and spit them out, by field, in record
  6980.          // number order (no indexing used).
  6981.  
  6982.          if (SDP.records != 0) {
  6983.  
  6984.             AP.func = GET_RECORD_XB;
  6985.             AP.handle = dataID;
  6986.             AP.recPtr = &dataRec;
  6987.  
  6988.             for (recNo=1;recNo <= 9; recNo++) {
  6989.  
  6990.                printf("\nrecNo %u: ",recNo);    // show line number
  6991.                AP.recNo = recNo;                // get this record #...
  6992.                rez = BULLET(&AP);               // ...to dataRec buffer
  6993.                if (rez==0) {
  6994.                   printf("%.1s ",(CHAR *) dataRec); // show if deleted or not
  6995.  
  6996.                   fdPtr = fieldDescPtr; // fdPtr->first field descriptor
  6997.  
  6998.                   for (fldNo=1;fldNo <= SDP.fields;fldNo++) {
  6999.  
  7000.                      // No special formatting is done on this output for this
  7001.                      // example -- since standard DBF data is always in pure
  7002.                      // ASCII form, all is printable.
  7003.  
  7004.                      switch (fdPtr->fieldType) {
  7005.                      case 'C':  // text
  7006.                      case 'D':  // date, show as-is
  7007.                      case 'L':  // logical, show as-is
  7008.                      case 'M':  // memo field (block number in ASCII)
  7009.                      case 'N':  // numeric (ASCII)
  7010.  
  7011.                         // make fmt[] string like this: "%xx.xxs"
  7012.                         // where xx is field length for this field
  7013.  
  7014.                         sprintf(fmt,"%%-%i.%is ",
  7015.                                 fdPtr->fieldLen,
  7016.                                 fdPtr->fieldLen);
  7017.  
  7018.                         // fdPtr->fieldDA=offset of the field within the record
  7019.                         // so it plus dataRec (buffer base) results in the
  7020.                         // offset of the current field we are processing
  7021.  
  7022.                         printf(fmt,dataRec+fdPtr->fieldDA);
  7023.                         break;
  7024.                      default:
  7025.                         printf("\nUnknown field type: %c\n",fdPtr->fieldType);
  7026.                      } // switch
  7027.  
  7028.                      fdPtr += 1;                  // next field's descriptor
  7029.  
  7030.                   } // for fields
  7031.                } // if record read
  7032.  
  7033.                else {
  7034.                   if (rez==EXB_BAD_RECNO)       // if < for-count records in DBF
  7035.                      rez=0;                     // then would get this error
  7036.                   else
  7037.                      printf("Failed GET_RECORD_XB, err: %d\n",rez);
  7038.                   break;                        // break for any ELSE case
  7039.                }
  7040.  
  7041.             } // for records
  7042.             if (rez==0) printf("\nDone.\n"); // all FOR recs done
  7043.          }
  7044.          else
  7045.             printf("No records in file\n");
  7046.  
  7047.          free(fieldDescPtr);
  7048.       }
  7049.       else
  7050.          printf("calloc failed!\n");
  7051.    }
  7052.    else
  7053.       printf("STAT_DATA_XB failed: %d\n",rez);
  7054.  
  7055.    HP.func = CLOSE_DATA_XB;
  7056.    HP.handle = dataID;
  7057.    rez2 = BULLET(&HP);
  7058. }
  7059. else
  7060.    printf("OPEN_DATA_XB failed: %d\n",rez);
  7061.  
  7062. EP.func = EXIT_XB;
  7063. rez2=BULLET(&EP);
  7064.  
  7065. printf("\nPress ENTER to exit");
  7066. getchar();
  7067. if (rez==0) rez=rez2;  // rez is more important, but if 0 use rez2 result
  7068. return(rez);
  7069. }
  7070.  
  7071. The above is a complete program.  Running it against a sample DBF results in 
  7072. the following output: 
  7073.  
  7074. FLD#   FIELDNAME  T  LEN.DEC  OFFSET
  7075.   1   SSN         C    9.0        1
  7076.   2   LNAME       C   16.0       10
  7077.   3   FNAME       C   16.0       26
  7078.   4   HIRED       D    8.0       42
  7079.   5   DEPT_ID     C    6.0       50
  7080.  
  7081. recNo 1:   465309999 Que              Barbie           19900131 BOSS
  7082. recNo 2:   445038888 Stewart          Jackie           19910228 ACC
  7083. recNo 3:   760443232 Whitman          Kelly            19920414 HUM
  7084. recNo 4:   845309944 Beatty           Leslie           19940122 PRG
  7085. recNo 5:   555033388 Jasper           Amy              19930230 PRG
  7086. recNo 6:   430443222 Hauntos          Poco             19920414 PRG
  7087. recNo 7:   365502949 Hopkins          Lisa             19910121 PRG
  7088. recNo 8:   685733868 Leonard          Rosina           19850218 PRG
  7089. recNo 9:   500945242 Morton           Holly            19950406 PHY
  7090. Done.
  7091.  
  7092. Press ENTER to exit
  7093.  
  7094.  
  7095. ΓòÉΓòÉΓòÉ 10.17. Update a Data Record ΓòÉΓòÉΓòÉ
  7096.  
  7097. #include "bullet_2.h"
  7098.  
  7099. ACCESSPACK AP;                  // packs used here
  7100.  
  7101. typedef struct _RECTYPE {
  7102.  CHAR tag;              // record tag, init to SPACE, '*' means deleted
  7103.  CHAR userSSN[9];       // first field in DBF (not 0-terminated in this case)
  7104.  CHAR userScore[6];     // second field (also not 0T)
  7105. } RECTYPE;              // (total record length is 16 bytes)
  7106. RECTYPE ourRecord;
  7107.  
  7108. // This excerpt demonstrates how to update (change) a record.
  7109. // The idea is to get the current contents of a record (by record
  7110. // number since no index is used for this update routine), change
  7111. // what needs changing, then write it back.  Under no circumstances
  7112. // should you change any field that is used as a key by an index, or
  7113. // as a foreign key, or in any other way removes the referential
  7114. // integrity of the database.  If you need to change a key field, then
  7115. // you must use UPDATE_XB.
  7116.  
  7117. AP.func = GET_RECORD_XB;
  7118. AP.handle = dataID;
  7119. AP.recNo = recordToUpdate;
  7120. AP.recPtr = &ourRecord;
  7121. rez = BULLET(&AP);
  7122. if (rez) return(rez);
  7123.  
  7124. // ourRecord has data stored at record number recordToUpdate -- since
  7125. // userScore is not used as a key field, this routine may be used to
  7126. // modify the contents of that field.  Since numbers are stored as ASCII
  7127. // text in compatible DBF files, must convert to binary, perform needed
  7128. // math, then convert back to text:
  7129.  
  7130. //t = atol(ourRecord.userScore);  // use scanf() since not 0T
  7131. sscanf(t,"%6u",&ourRecord.userScore);
  7132. t = t + ClassCurve;             // increase each score by curve value
  7133. sprintf(ourRecord.userScore,"%6.6u",t)
  7134.  
  7135. AP.func = UPDATE_RECORD_XB;     // other AP values already set up from GET
  7136. rez = BULLET(&AP);              // write out the record with the new score
  7137. if (rez) return(rez);
  7138.  
  7139.  
  7140. ΓòÉΓòÉΓòÉ 10.18. Delete, Undelete, 'Debump' a Data Record ΓòÉΓòÉΓòÉ
  7141.  
  7142. #include "bullet_2.h"
  7143.  
  7144. ACCESSPACK AP;                  // packs used here
  7145.  
  7146. // delete or undelete or remove (debump)
  7147.  
  7148. switch(*requestMsg) {
  7149. case 'delete':
  7150.    AP.func = DELETE_RECORD_XB;  // places a '*' in .tag byte
  7151.    break;
  7152. case 'undelete':
  7153.    AP.func = UNDELETE_RECORD_XB; // places a SPACE in .tag byte
  7154.    break;
  7155. case 'debump':
  7156.    AP.func = DEBUMP_RECORD_XB;  // physically removes record from file, but
  7157.    break;                       // fails if AP.recNo is not last record number
  7158. }
  7159.  
  7160. AP.handle = dataID;             // same for all three
  7161. AP.recNo = recordNumber;
  7162. rez = BULLET(&AP);
  7163. return(rez);
  7164.  
  7165.  
  7166. ΓòÉΓòÉΓòÉ 10.19. Reading Memo Records ΓòÉΓòÉΓòÉ
  7167.  
  7168. #include "bullet_2.h"
  7169.  
  7170. ACCESSPACK AP;
  7171. LOCKPACK LP;
  7172. MEMODATAPACK MDP;       // packs used here
  7173.  
  7174. typedef struct _RECTYPE {
  7175.  CHAR tag;              // record tag, init to SPACE, '*' means deleted
  7176.  CHAR userSSN[9];       // first field in DBF (not 0-terminated in this case)
  7177.  CHAR userMemo[10];     // second field (also not 0T), is memo field type
  7178. } RECTYPE;
  7179. RECTYPE someRecord;
  7180.  
  7181. // a minimum shared record lock is required on the DBF record that owns
  7182. // memoNumber in this example, since only reading of the single memo is done
  7183.  
  7184. LP.func = LOCK_DATA_XB;
  7185. LP.handle = dataID;
  7186. LP.dlMode = LOCK_SHARED;        // only reading here, shared record lock is okay
  7187. LP.recStart = recordToGet;      // lock this record
  7188. LP.recCount = 1;                // and only this record
  7189. rez = BULLET(&LP);
  7190. if (rez) return(rez);
  7191.  
  7192. // hereafter, must unlock before exiting
  7193.  
  7194. AP.func = GET_RECORD_XB;
  7195. AP.handle = dataID;
  7196. AP.recNo = recordToGet;
  7197. AP.recPtr = &someRecord;        // load someRecord with data on disk
  7198. rez = BULLET(&AP);
  7199. if (rez) return(rez);           // UNLOCK! before doing this exit
  7200.  
  7201. // memoNumber = atol(someRecord.userMemo); // the memo number (0 if none)
  7202. sscanf(memoNumber,"%10u",&someRecord.userMemo);
  7203.  
  7204. // this code reads the number of data bytes in the memo and allocates a
  7205. // run-time buffer to read that memo into
  7206.  
  7207. MDP.func = GET_MEMO_SIZE_XB;
  7208. MDP.dbfHandle = dataID;         // handle of the DBF this memo belongs to
  7209. MDP.memoNo = memoNumber;        // memo number to get size of (1=first)
  7210. rez = BULLET(&MDP);             // (returns an error if memoNumber is 0)
  7211. if (rez==0) {
  7212.  
  7213.    // BULLET does maintain 0-sized memo records, so you may want to check
  7214.    // if MDP.memoBytes from GET_MEMO_SIZE_XB is 0, and skip processing if so
  7215.  
  7216.    memoBytesToRead = MDP.memoBytes;         // since overwritten by next call
  7217.    memoBufferPtr = malloc(memoBytesToRead); // assuming you want it all at once
  7218.  
  7219.    if (memoBufferPtr) {
  7220.  
  7221.       MDP.func = GET_MEMO_XB;
  7222.       MDP.dbfHandle = dataID;      // same as before, as is .memoNo
  7223.       MDP.memoNo = memoNumber;
  7224.       MDP.memoPtr = memoBufferPtr; // memo disk data is loaded into this buffer
  7225.       MDP.memoOffset = 0;          // read from very first memo data byte
  7226.       MDP.memoBytes = memoBytesToRead;
  7227.  
  7228.       // MDP.memoBytes is already set to the total data size -- you may read
  7229.       // fewer bytes, and you may use .offset to move through the memo data
  7230.       // chunks at a time, rather than all at once -- the above simply reloads
  7231.       // it with the same count, since here memoBytesToRead==MDP.memoBytes
  7232.  
  7233.       rez = BULLET(&MDP);          // returns with MDP.memoBytes= bytes read
  7234.       if (rez==0) {
  7235.  
  7236.          // if (MDP.memoBytes != memoBytesToRead)
  7237.          //   printf("Could not read all bytes requested - probably at end of memo\n");
  7238.          // above would not happen in this case since the exact size was requested
  7239.  
  7240.          // process as required (here passes buffer ptr and bytes actually read)
  7241.  
  7242.          DoWhatYouWillWithThisMemoData(memoBufferPtr,MDP.memoBytes);
  7243.       }
  7244.       free(memoBufferPtr);
  7245.    }
  7246.    else rez=8;  // malloc failed, return 8=not enough memory
  7247. }
  7248.  
  7249. LP.func = UNLOCK_DATA_XB;
  7250. LP.handle = dataID;
  7251. LP.recStart = recordToGet;      // unlock this record
  7252. LP.recCount = 1;                // and only this record
  7253. rez2 = BULLET(&LP);
  7254.  
  7255. if (rez==0) rez=rez2;
  7256. return(rez);
  7257.  
  7258.  
  7259. ΓòÉΓòÉΓòÉ 10.20. Add, Update, Delete a Memo Record ΓòÉΓòÉΓòÉ
  7260.  
  7261. #include "bullet_2.h"
  7262.  
  7263. ACCESSPACK AP;
  7264. LOCKPACK LP;
  7265. MEMODATAPACK MDP;       // packs used here
  7266.  
  7267. typedef struct _RECTYPE {
  7268.  CHAR tag;
  7269.  CHAR userSSN[9];
  7270.  CHAR userMemo[10];
  7271. } RECTYPE;
  7272. RECTYPE someRecord;
  7273.  
  7274. // an exclusive lock is required on the DBF file that owns this memo file
  7275. // since writing is done to the memo file (memo file header, especially)
  7276.  
  7277. LP.func = LOCK_DATA_XB;
  7278. LP.handle = dataID;
  7279. LP.dlMode = LOCK_EXCLUSIVE;     // writing here, exclusive full lock required
  7280. LP.recStart = 0;                // lock all
  7281. rez = BULLET(&LP);
  7282. if (rez) return(rez);
  7283.  
  7284. // hereafter, must unlock before exiting
  7285.  
  7286. AP.func = GET_RECORD_XB;
  7287. AP.handle = dataID;
  7288. AP.recNo = recordToGet;
  7289. AP.recPtr = &someRecord;        // load someRecord with data on disk
  7290. rez = BULLET(&AP);
  7291. if (rez) return(rez);           // UNLOCK! before doing this exit
  7292.  
  7293. // memoNumber = atol(someRecord.userMemo); // the memo number (0 if none)
  7294. sscanf(memoNumber,"%10u",&someRecord.userMemo);
  7295.  
  7296. // if there is no current memo, this example adds one
  7297. // if there is, this example updates it by:
  7298. //   - changing the first 16 bytes to "Kilroy was here."
  7299. //   - adding the text "Was updated." to the end of the current memo data
  7300. // the example then deletes the memo
  7301.  
  7302. CHAR kilroyStr[] = "Kilroy was here.";
  7303. CHAR updateStr[] = "Was updated.";
  7304. CHAR newStr[] = "New.";
  7305.  
  7306. if (memoNumber) {
  7307.  
  7308.    // modify the current memo -- first, the text "Kilroy was here." is
  7309.    // placed at the start of the memo, then the memo size is gotten (in
  7310.    // case the original memo size were less than the size of "Kilroy...").
  7311.  
  7312.    MDP.func = UPDATE_MEMO_XB;
  7313.    MDP.dbfHandle = dataID;      // handle of the DBF this memo belongs to
  7314.    MDP.memoNo = memoNumber;     // memo number to update (1=first)
  7315.    MDP.memoPtr = kilroyStr;     // data to write
  7316.    MDP.memoOffset = 0;          // start write at first byte of memo
  7317.    MDP.memoBytes = strlen(kilroyStr); // bytes to write
  7318.    rez = BULLET(&MDP);
  7319.  
  7320.       // the first 16 bytes of the memo now say kilroyStr (overwrote what was there)
  7321.       // the memo size changes only if the original memo was < 16 bytes, in
  7322.       // which case the size is now 16
  7323.  
  7324.    if (rez==0) {
  7325.       printf("%s overwrote first 16 bytes\n",kilroyStr);
  7326.  
  7327.       // must check if the update resulted in a new memo block being
  7328.       // used (if the update required more allocation blocks), and if
  7329.       // so must update the DBF field storing the memo number
  7330.       // MDP.memoNo is the memo number returned, memoNumber the original number
  7331.  
  7332.       // IT CAN BE ASSUMED IN THIS PARTICULAR example that this will never
  7333.       // be needed since the update modified the first 16 bytes of the
  7334.       // memo only, and so would never have required any more blocks --
  7335.       // however, unless you know before-hand that the update will not need
  7336.       // more allocation blocks (not difficult, if you know the block size,
  7337.       // overhead bytes (8), and your offset and bytes to write), it should
  7338.       // be checked -- hint: as with all Bullet routines, the idea is to
  7339.       // wrap up these separate operations into nice, neat callable routines
  7340.       // that take care of your particular need; there are no doubt 1000s of
  7341.       // variations -- pick one you can deal with.
  7342.  
  7343.       if (MDP.memoNo != memoNumber) {
  7344.          sprintf(someRecord.userMemo,"%10.10u",MDP.memoNo)
  7345.          memoNumber = MDP.memoNo;       // set original to new for next update
  7346.  
  7347.          // rather than updating here, and possibly again below, you
  7348.          // may elect to set a flag and then do the DBF update at the end, once
  7349.          // again -- this updates the _data_ record, in the DBF file:
  7350.  
  7351.          AP.func = UPDATE_RECORD_XB;    // this updates the data record only
  7352.          AP.handle = dataID;
  7353.          AP.recNo = recordToGet;
  7354.          AP.recPtr = &someRecord;       // write the new data
  7355.          rez = BULLET(&AP);
  7356.          if (rez) return(rez);          // UNLOCK! before doing this exit
  7357.       }
  7358.  
  7359.       MDP.func = GET_MEMO_SIZE_XB;  // other MDP members already set above
  7360.       rez = BULLET(&MDP);
  7361.       if (rez=0) {              // size of memo is at least 16 (from kilroyStr)
  7362.                                 // but may be bigger if was bigger before
  7363.          MDP.func = UPDATE_MEMO_XB;
  7364.          MDP.memoPtr = updateStr;
  7365.  
  7366.          // the current memo size is used as the offset for the appending of
  7367.          // the updateStr bytes (offset is 0-based, so using MDP.memoBytes
  7368.          // results in the offset being the current size + 1)
  7369.  
  7370.          MDP.memoOffset = MDP.memoBytes;
  7371.          MDP.memoBytes = strlen(updateStr);
  7372.          rez = BULLET(&MDP);   // returns with MDP.memoNo
  7373.                                // bytes written==MDP.memoBytes always
  7374.          if (rez==0)
  7375.  
  7376.             printf("%s appended to memo\n",updateStr);
  7377.             // _minimum_ memo contents now is kilroyStr plus updateStr
  7378.             // more if original memo was > 16 bytes
  7379.  
  7380.             if (MDP.memoNo != memoNumber) {
  7381.                sprintf(someRecord.userMemo,"%10.10u",MDP.memoNo)
  7382.                AP.func = UPDATE_RECORD_XB;         //
  7383.                AP.handle = dataID;                 // as explained above
  7384.                AP.recNo = recordToGet;             //
  7385.                AP.recPtr = &someRecord;
  7386.                rez = BULLET(&AP);
  7387.                if (rez) return(rez);    // actually must unlock before exit!
  7388.             }
  7389.          } // memo update #2 failed
  7390.       } // memo size failed
  7391.    }
  7392.    else
  7393.       printf("update failed, err: %d\n",rez); // disk full probably
  7394. }
  7395. else {
  7396.  
  7397.    // no current memo, add one
  7398.  
  7399.    MDP.func = ADD_MEMO_XB;
  7400.    MDP.dbfHandle = dataID;      // handle of the DBF this memo belongs to
  7401.    MDP.memoPtr = newStr;        // data to write
  7402.    MDP.memoBytes = strlen(newStr); // bytes to write
  7403.    rez = BULLET(&MDP);
  7404.    if (rez==0) {
  7405.       sprintf(someRecord.userMemo,"%10.10u",MDP.memoNo)
  7406.       AP.func = UPDATE_RECORD_XB;         //
  7407.       AP.handle = dataID;                 // as explained above
  7408.       AP.recNo = recordToGet;             //
  7409.       AP.recPtr = &someRecord;
  7410.       rez = BULLET(&AP);
  7411.    }
  7412.    else
  7413.      printf("add failed, err: %d\n",rez);
  7414. }
  7415.  
  7416. // delete the memo just operated on
  7417.  
  7418. if (rez==0) {
  7419.  
  7420.    MDP.func = DELETE_MEMO_XB;
  7421.    // MDP.memoNo is already set
  7422.    rez = BULLET(&MDP);
  7423.    if (rez==0) {
  7424.       strcpy(someRecord.userMemo,"          ");// DBF memo field to all spaces
  7425.       AP.func = UPDATE_RECORD_XB;         //
  7426.       AP.handle = dataID;                 // as explained above
  7427.       AP.recNo = recordToGet;             //
  7428.       AP.recPtr = &someRecord;
  7429.       rez = BULLET(&AP);
  7430.    }
  7431.    else
  7432.      printf("delete failed, err: %d\n",rez);
  7433. }
  7434.  
  7435. LP.func = UNLOCK_DATA_XB;
  7436. LP.handle = dataID;
  7437. LP.recStart = 0;                // unlock all
  7438. rez2 = BULLET(&LP);
  7439.  
  7440. if (rez==0) rez=rez2;
  7441. return(rez);
  7442.  
  7443.  
  7444. ΓòÉΓòÉΓòÉ 10.21. Memo Bypass (Memo Create, Open, Close, Read/Flush Header) ΓòÉΓòÉΓòÉ
  7445.  
  7446. #include "bullet_2.h"
  7447.  
  7448. MEMODATAPACK MDP;               // packs used here
  7449.  
  7450.  
  7451. //  These five routines are normally performed automatically, as described
  7452. //  in the main documentation, and seldom would need to be called directly.
  7453.  
  7454.  
  7455. MDP.func = MEMO_BYPASS_XB;
  7456. MDP.dbfHandle = dataID;         // handle of DBF
  7457. MDP.memoBypass = BypassRoutineToDo;
  7458.  
  7459. // where BypassRoutineToDo is one of the following:
  7460. //
  7461. //   BYPASS_CREATE_MEMO
  7462. //   BYPASS_OPEN_MEMO
  7463. //   BYPASS_CLOSE_MEMO
  7464. //   BYPASS_READ_MEMO_HEADER
  7465. //   BYPASS_FLUSH_MEMO_HEADER
  7466.  
  7467. rez = BULLET(&MDP);
  7468. if (rez) return(rez);
  7469.  
  7470.  
  7471. ΓòÉΓòÉΓòÉ 10.22. Key Access Without Data Record Read ΓòÉΓòÉΓòÉ
  7472.  
  7473. #include "bullet_2.h"
  7474.  
  7475. CHAR keyBuffer[64];             // enough for the largest possible key
  7476.  
  7477. ACCESSPACK AP;                  // packs used here
  7478.  
  7479. // -----------------------------------------------------------
  7480. // this section starts at the first in-order key and reads all
  7481. // keys in the index file in order
  7482.  
  7483. AP.func = FIRST_KEY_XB;
  7484. AP.handle = indexID;
  7485. AP.keyPtr = keyBuffer;
  7486. rez = BULLET(&AP);
  7487. while (rez==0) {
  7488.  
  7489.    // show first 8 bytes of key, and the record number the key is for
  7490.    printf("%8.8s  %9.9lu\r", keyBuffer, AP.recNo);
  7491.  
  7492.    AP.func = NEXT_KEY_XB;       // and get the next key...
  7493.    rez = BULLET(&AP);           // until all keys accessed
  7494. };
  7495. if (rez!=EXB_END_OF_FILE) return(rez); // expected rez is EXB_END_OF_FILE
  7496.  
  7497.  
  7498. // ----------------------------------------------------------
  7499. // this section starts at the last in-order key and reads all
  7500. // keys in the index file in reverse order
  7501.  
  7502. AP.func = LAST_KEY_XB;
  7503. AP.handle = indexID;
  7504. AP.keyPtr = keyBuffer;
  7505. rez = BULLET(&AP);
  7506. while (rez==0) {
  7507.  
  7508.    // show first 8 bytes of key, and the record number the key is for
  7509.    printf("%8.8s  %9.9lu\r", keyBuffer, AP.recNo);
  7510.  
  7511.    AP.func = PREV_KEY_XB;       // and get the previous key...
  7512.    rez = BULLET(&AP);           // until all keys accessed
  7513. };
  7514. if (rez!=EXB_TOP_OF_FILE) return(rez); // expected rez is EXB_TOP_OF_FILE
  7515.  
  7516. // this section starts at the first key that starts with "SM", or if
  7517. // no keys do, the first key after "SM", and gets that key
  7518. // keys in the index file in reverse order
  7519.  
  7520. memset(keyBuffer,0,64);         // ensure remaining bytes are \0 (required)
  7521. strcpy(keyBuffer,"SM");         // get key of "SM", if present (not likely)
  7522. AP.func = EQUAL_KEY_XB;
  7523. AP.handle = indexID;
  7524. AP.keyPtr = keyBuffer;
  7525. rez = BULLET(&AP);
  7526.  
  7527. // since "SM" is only being used as a partial key search criterion,
  7528. // it won't be found (though, of course, it is a valid key) in this
  7529. // example -- however, by using NEXT_KEY_XB, the next key is accessed,
  7530. // say, for example, "SMITH"...  It could also be "TIMBU" if there were
  7531. // no keys with values greater than "SM" and less than "TIMBU".
  7532.  
  7533. // Be aware that if another thread in this process (repeat:
  7534. // this process!) is accessing this index file (it's not likely that
  7535. // you will write your could so that this would happen), then you
  7536. // can no longer rely on any multi-call key access to be an atomic
  7537. // operation.  If you need to have more than one thread access the
  7538. // same index (and you require NEXT_KEY_XB or PREV_KEY_XB), then you
  7539. // must semaphore protect your code so you don't try to access the same
  7540. // index file.
  7541.  
  7542. if (rez!=EXB_KEY_NOT_FOUND) {   // expected
  7543.    AP.func = NEXT_KEY_XB;       // so get the first key after "SM"
  7544.    AP.handle = indexID;
  7545.    AP.keyPtr = keyBuffer;
  7546.    rez = BULLET(&AP);
  7547.    if (rez==0)
  7548.       printf("The first key >= SM is %s\n",AP.keyBuffer);
  7549. }
  7550.  
  7551.  
  7552. ΓòÉΓòÉΓòÉ 10.23. Building and Storing Raw Key ΓòÉΓòÉΓòÉ
  7553.  
  7554. #include "bullet_2.h"
  7555.  
  7556. ACCESSPACK AP;                  // packs used here
  7557.  
  7558. // this example shows a simple database insert process
  7559. // INSERT_XB should be used instead since it does all this and then some
  7560. // files should be locked (not shown)
  7561.  
  7562. AP.func = ADD_RECORD_XB;
  7563. AP.handle = dataID;
  7564. AP.recPtr = &yourRecord;
  7565. rez = BULLET(&AP);
  7566. if (rez) return(rez);
  7567.  
  7568. // AP.recNo is returned by Bullet and will be used later
  7569.  
  7570. AP.func = BUILD_KEY_XB;
  7571. AP.handle = indexID;
  7572. AP.recPtr = &yourRecord;
  7573. AP.keyPtr = keyBuffer;          // CHAR keyBuffer[64];
  7574. rez = BULLET(&AP);
  7575. if (rez) return(rez);
  7576.  
  7577. // keyBuffer filled with key to store
  7578. // a \0\0 enumerator is attached if the index file was created with DUPS_ALLOWED
  7579.  
  7580. AP.func = STORE_KEY_XB;
  7581. AP.handle = indexID;
  7582. // AP.recNo is already set from the ADD_RECORD_XB call
  7583. AP.keyPtr = keyBuffer;
  7584. rez = BULLET(&AP);
  7585. if (rez) return(rez);
  7586.  
  7587. // if no error, the key was inserted in the index file and the record
  7588. // number was associated with that key -- next time you access that
  7589. // key, the record number is returned (along with the key itself) --
  7590. // and with that record number you access the data file
  7591.  
  7592. // when using this routine, you must check the error for a EXB_KEY_EXISTS
  7593. // error and if DUPS_ALLOWED, you must manage your own enumerator --
  7594. // INSERT_XB is the only routine that does this automatically so unless
  7595. // you have a real desire to manage this yourself (among other things)
  7596. // use INSERT_XB instead of all this.
  7597.  
  7598.  
  7599. ΓòÉΓòÉΓòÉ 10.24. Getting Current Key, Key for Rec/RecNo Pair, Deleting Key ΓòÉΓòÉΓòÉ
  7600.  
  7601. #include "bullet_2.h"
  7602.  
  7603. ACCESSPACK AP;
  7604. LOCKPACK LP;                    // packs used here
  7605.  
  7606. AP.func = GET_CURRENT_KEY_XB;
  7607. AP.handle = indexID;
  7608. AP.keyPtr = keyBuffer;          // current key placed here by Bullet
  7609. rez = BULLET(&AP);
  7610. if (rez) return(rez);
  7611. printf("The last accessed key for indexID is in keyBuffer, including any enumerator\n");
  7612.  
  7613. // This next example assumes that you are maintaining your own method of
  7614. // transaction rollback, and are about to delete the last item added to the
  7615. // database: in this case, the last data record is removed from the one
  7616. // DBF data file, and the key for that record is removed from the index file
  7617. // -- normally, you wouldn't do this, but if you have the need...
  7618.  
  7619. rez = InsertToDatabaseHoweverYouDoIt(yourPtr);
  7620.  
  7621. // Assume the above called succeeded, but you've decided, for whatever reason,
  7622. // that you want to backout the insert... normally, if you used INSERT_XB to
  7623. // insert a record/key into a database, you'd already have the record number
  7624. // used AND the key used for the record (for each if more than one) -- but for
  7625. // this example, assume that only the record number is known.  Steps done
  7626. // to remove the record and key for this would be:
  7627. //
  7628. //  1. Exclusive full-lock files
  7629. //  2. Get the record data at the record number (GET_RECORD_XB)
  7630. //  3. Get the key for this record/recNo pair (GET_KEY_FOR_RECORD_XB)
  7631. //  4. Delete the key (DELETE_KEY_XB) (delete the key before deleting the record)
  7632. //  5. Delete the record data (DEBUMP_RECORD_XB) (record must be last record in file)
  7633. //  6. Unlock files
  7634.  
  7635. // lock files being processed
  7636.  
  7637. LP.func = LOCK_XB;
  7638. LP.handle = indexID;            // also locks indexID's owner (its DBF)
  7639. LP.xlMode = LOCK_EXCLUSIVE;     // exclusive lock for index
  7640. LP.dlMode = LOCK_EXCLUSIVE;     // exclusive lock for data
  7641. LP.nextPtr = NULL;              // only one pack
  7642. rez = BULLET(&LP);
  7643. if (rez) return(LP.stat);       // rez for transaction-list is NOT the error
  7644.  
  7645. // get actual data record for record number
  7646.  
  7647. AP.func = GET_RECORD_XB;
  7648. AP.handle = dataID;
  7649. AP.recNo = recNoToDelete;       // get this record to...
  7650. AP.recPtr = &yourRecord;        // ...this data record buffer (a structure var)
  7651. rez = BULLET(&AP);
  7652. if (rez) goto MustAlwaysUnlock;
  7653.  
  7654. // now have the data record/data number pair --
  7655. // it must be the last physical record in the data file -- if this cannot
  7656. // be known, use STAT_DATA_XB to verify that recNoToDelete==SDP.records
  7657.  
  7658. AP.func = GET_KEY_FOR_RECORD_XB;
  7659. AP.handle = indexID;
  7660. AP.recNo = recNoToDelete;
  7661. AP.recPtr = &yourRecord;
  7662. AP.keyPtr = keyBuffer;          // CHAR keyBuffer[64]; key returned here
  7663. rez = BULLET(&AP);
  7664. if (rez) goto MustAlwaysUnlock;
  7665.  
  7666. // now have the key (with any attached enumerator) in keyBuffer, delete it
  7667.  
  7668. AP.func = DELETE_KEY_XB;
  7669. AP.handle = indexID;
  7670. AP.keyPtr = keyBuffer;          // was set with key by GET_KEY_FOR_RECORD_XB
  7671. rez = BULLET(&AP);
  7672. if (rez) goto MustAlwaysUnlock;
  7673.  
  7674. // and delete (physically remove) the data record
  7675.  
  7676. AP.func = DEBUMP_RECORD_XB;
  7677. AP.handle = dataID;
  7678. AP.recNo = recNoToDelete;
  7679. rez = BULLET(&AP);
  7680. // if (rez) goto MustAlwaysUnlock;
  7681.  
  7682. MustAlwaysUnlock:   // unlock ALWAYS required if lock succeeded
  7683.  
  7684. LP.func = UNLOCK_XB;
  7685. LP.handle = indexID;
  7686. LP.nextPtr = NULL;
  7687. rez2 = BULLET(&LP);
  7688. if (rez2) rez2=LP.stat; // rez for transaction-list is NOT the error
  7689.  
  7690. if (rez==0) rez=rez2;
  7691. return(rez);
  7692.  
  7693.  
  7694. ΓòÉΓòÉΓòÉ 10.25. Get Data by Key Order ΓòÉΓòÉΓòÉ
  7695.  
  7696. #include "bullet_2.h"
  7697.  
  7698. ACCESSPACK AP;                  // packs used here
  7699.  
  7700. // First example starts at first in-order data and moves through to last
  7701.  
  7702. AP.func = GET_FIRST_XB;
  7703. AP.handle = indexID;
  7704. AP.recPtr = &yourRecord;        // struct yourStructure yourRecord;
  7705. AP.keyPtr = keyBuffer;          // CHAR keyBuffer[64];
  7706. rez = BULLET(&AP);
  7707. if (rez) return(rez);
  7708. printf("The first in-order key is in keyBuffer and its record in yourRecord\n");
  7709.  
  7710. AP.func = GET_NEXT_XB;          // other parm same as set above
  7711. while (rez==0) {
  7712.    rez = BULLET(&AP);
  7713.    if (rez) break;
  7714.    printf("The next in-order key is in keyBuffer and its record in yourRecord\n");
  7715. }
  7716. if (rez==EXB_END_OF_FILE) rez==0; // expected rez after end of file
  7717. if (rez) return(rez);
  7718.  
  7719.  
  7720. // Second example starts at last in-order data and moves through to first
  7721. // note: since above already is past last, the call to GET_LAST_XB in
  7722. //       this example would not be necessary -- a call to GET_PREV_XB
  7723. //       could have been made directly -- however, it doesn't matter
  7724.  
  7725. AP.func = GET_LAST_XB;
  7726. AP.handle = indexID;
  7727. AP.recPtr = &yourRecord;
  7728. AP.keyPtr = keyBuffer;
  7729. rez = BULLET(&AP);
  7730. if (rez) return(rez);
  7731. printf("The last in-order key is in keyBuffer and its record in yourRecord\n");
  7732.  
  7733. AP.func = GET_PREV_XB;          // other parms same as set above
  7734. while (rez==0) {
  7735.    rez = BULLET(&AP);
  7736.    if (rez) break;
  7737.    printf("The previous in-order key is in keyBuffer and its record in yourRecord\n");
  7738. }
  7739. if (rez==EXB_TOP_OF_FILE) rez==0; // expected rez before at beginning of file
  7740. if (rez) return(rez);
  7741.  
  7742.  
  7743. // Third example performs a GET_EQUAL_OR_GREATER operation, typically
  7744. // used to locate to a key based on a partial search criterion
  7745.  
  7746. AP.func = GET_EQUAL_XB;
  7747. AP.handle = indexID;
  7748. AP.recPtr = &yourRecord;    // to be filled on return, if found
  7749.  
  7750. memset(keyBuffer,0,sizeof(keyBuffer);   // clear it out (required)
  7751. strcpy(keyBuffer,"KING");               // find first key starting with 'KING'
  7752. AP.keyPtr = keyBuffer;
  7753.  
  7754. rez = BULLET(&AP);
  7755. if (rez==0)
  7756.    printf("Matched search key in keyBuffer EXACTLY -- its record is in yourRecord\n");
  7757. else if (rez==EXB_KEY_NOT_FOUND) {
  7758.  
  7759.    // since not found, get the following in-order one (say, 'KINGSTON')
  7760.  
  7761.    AP.func = GET_NEXT_XB;
  7762.    rez = BULLET(&AP);
  7763.    if (rez) return(rez);
  7764.  
  7765.    printf("Not exact, but next greater key is in keyBuffer and its record is in yourRecord\n");
  7766. }
  7767. else
  7768.    return(rez);
  7769.  
  7770.  
  7771. ΓòÉΓòÉΓòÉ 10.26. Insert Data Record with Key Into Database ΓòÉΓòÉΓòÉ
  7772.  
  7773. #include "bullet_2.h"
  7774.  
  7775. ACCESSPACK AP;
  7776. LOCKPACK LP;                    // packs used here
  7777.  
  7778. LP.func = LOCK_XB;
  7779. LP.handle = indexID;            // also locks indexID's owner (its DBF)
  7780. LP.xlMode = LOCK_EXCLUSIVE;     // exclusive lock for index
  7781. LP.dlMode = LOCK_EXCLUSIVE;     // exclusive lock for data
  7782. LP.nextPtr = NULL;              // only one pack
  7783. rez = BULLET(&LP);
  7784. if (rez) return(LP.stat);       // rez for transaction-list is NOT the error
  7785.  
  7786. AP.func = INSERT_XB;
  7787. AP.handle = indexID;
  7788. AP.recNo = 0;                   // must be zero
  7789. AP.recPtr = &yourRecord;        // contains data record
  7790. AP.keyPtr = keyBuffer;          // empty, on return has key stored
  7791. AP.nextPtr = NULL;              // only the single pack
  7792. rez = BULLET(&AP);
  7793.  
  7794. // on return, as on all transaction-list routines, rez is not the return
  7795. // code but is the pack item that failed (neg if data, pos if index)
  7796.  
  7797. if (rez==0)
  7798.    printf("okay\n");
  7799. else if (rez < 0)
  7800.    printf("insert failed with data, err: %d\n",LP.stat);
  7801. else
  7802.    printf("insert failed with index, err: %d\n",LP.stat);
  7803.  
  7804.  
  7805. // if locked, MUST unlock!
  7806.  
  7807. LP.func = UNLOCK_XB;
  7808. LP.handle = indexID;
  7809. LP.nextPtr = NULL;
  7810. rez2 = BULLET(&LP);
  7811. if (rez2) rez2=LP.stat; // rez for transaction-list is NOT the error
  7812. if (rez==0) rez=rez2    // return the most interesting error, if any
  7813.  
  7814.  
  7815. ΓòÉΓòÉΓòÉ 10.27. Update Data Record with Key Update ΓòÉΓòÉΓòÉ
  7816.  
  7817. #include "bullet_2.h"
  7818.  
  7819. ACCESSPACK AP;
  7820. LOCKPACK LP;                    // packs used here
  7821.  
  7822. LP.func = LOCK_XB;
  7823. LP.handle = indexID;            // also locks indexID's owner (its DBF)
  7824. LP.xlMode = LOCK_SHARED;        // shared lock for index
  7825. LP.dlMode = LOCK_SHARED;        // shared lock for data
  7826. LP.nextPtr = NULL;              // only one pack
  7827. rez = BULLET(&LP);
  7828. if (rez) return(LP.stat);       // rez for transaction-list is NOT the error
  7829.  
  7830. AP.func = GET_FIRST_XB;         // get first key's data record (and its recNo)
  7831. AP.handle = indexID;
  7832. AP.recPtr = &yourRecord;
  7833. AP.keyPtr = keyBuffer;
  7834. rez = BULLET(&AP);
  7835. if (rez==0) {
  7836.  
  7837.    // assume that we want to change this entry now (as if we weren't sure
  7838.    // that we wanted to initially, hence the initial shared lock) --
  7839.    // this requires write access so relock to allow write access
  7840.  
  7841.    LP.func = RELOCK_XB;
  7842.    LP.handle = indexID;
  7843.    LP.xlMode = LOCK_EXCLUSIVE;  // exclusive lock for index
  7844.    LP.dlMode = LOCK_EXCLUSIVE;  // exclusive lock for data
  7845.    LP.recStart = 0;
  7846.    LP.nextPtr = NULL;
  7847.    rez = BULLET(&LP);
  7848.    if (rez) rez=LP.stat         // xaction-list routine so use LP.stat
  7849.    if (rez==0) {
  7850.  
  7851.       strcpy(yourRecord.someField,"new field data");
  7852.  
  7853.       // AP.recNo has been set by Bullet GET_XB call above
  7854.  
  7855.       AP.func = UPDATE_XB;
  7856.       AP.nextPtr = NULL;        // all other AP members set above
  7857.       rez = BULLET(&AP);
  7858.  
  7859.       // on return, as on all transaction-list routines, rez is not the return
  7860.       // code but is the pack item that failed (neg if data, pos if index)
  7861.  
  7862.       if (rez==0)
  7863.          printf("okay\n");
  7864.       else if (rez < 0)
  7865.          printf("update failed with data, err: %d\n",LP.stat);
  7866.       else
  7867.          printf("update failed with index, err: %d\n",LP.stat);
  7868.    }
  7869.    else
  7870.       printf("relock failed, rez: %d  err: %d\n",rez,LP.stat);
  7871. }
  7872.  
  7873. // if locked, MUST unlock!
  7874.  
  7875. LP.func = UNLOCK_XB;
  7876. LP.handle = indexID;
  7877. LP.nextPtr = NULL;
  7878. rez2 = BULLET(&LP);
  7879. if (rez2) rez2=LP.stat; // rez for transaction-list is NOT the error
  7880. if (rez==0) rez=rez2    // return the most interesting error, if any
  7881.  
  7882.  
  7883. ΓòÉΓòÉΓòÉ 10.28. Remote Drive, File/Device Check ΓòÉΓòÉΓòÉ
  7884.  
  7885. #include "bullet_2.h"
  7886.  
  7887. REMOTEPACK RP;                  // packs used here
  7888.  
  7889. // check if file in handle (or device handle) is on a 'network' drive
  7890.  
  7891. RP.func = CHECK_REMOTE_XB;
  7892. RP.handle = indexID;            // check if indexID handle is on a network
  7893. rez = BULLET(&RP);
  7894. if (rez) return(rez);
  7895. if (RP.isRemote)
  7896.    printf("handle is on a network drive\n");
  7897.  
  7898. // check if drive is a 'network' drive
  7899.  
  7900. RP.func = CHECK_REMOTE_XB;
  7901. RP.handle = 0;                  // set RP.handle to 0 to check drive
  7902. RP.drive = 0;                   // check if current drive is network drive
  7903. rez = BULLET(&RP);              // to check drive C:, set RP.drive=3
  7904. if (rez) return(rez);           // D: is RP.drive=4, and so on
  7905. if (RP.isRemote)
  7906.    printf("current drive is a network drive\n");
  7907.  
  7908.  
  7909. ΓòÉΓòÉΓòÉ 10.29. Relock Individual File ΓòÉΓòÉΓòÉ
  7910.  
  7911. #include "bullet_2.h"
  7912.  
  7913. LOCKPACK LP;
  7914. STATHANDLEPACK SHP;
  7915. STATDATAPACK SDP;
  7916. STATINDEXPACK SIP;              // packs used here
  7917.  
  7918. // given a handle, determine if it's DBF or index
  7919. // check if currently locked
  7920. // if locked, determine if shared or exclusive lock
  7921. // if exclusive lock, relock to shared
  7922. // if not locked, do nothing
  7923.  
  7924. SHP.func = STAT_HANDLE_XB;
  7925. SHP.handle = passedHandle;
  7926. rez = BULLET(&SHP);
  7927. if (SHP.ID==-1)
  7928.    puts("Handle is not a Bullet data or index file\n");
  7929. else {
  7930.    if (SHP.ID==0) {
  7931.  
  7932.       // normally, you lock before calling this routine but since
  7933.       // SIP.lockCount and SIP.flags are all that is being checked,
  7934.       // and since nothing is to be done if the handle is not locked,
  7935.       // it's okay in this instance to use this routine without
  7936.       // first explicitly locking the handle
  7937.  
  7938.       SIP.func = STAT_INDEX_XB;
  7939.       SIP.handle = passedHandle;
  7940.       rez = BULLET(&SIP);
  7941.       if (rez) goto ErrorHandler;
  7942.  
  7943.       // if locked, check if the lock is exclusive
  7944.  
  7945.       if (SIP.lockCount) {              // count of active full locks
  7946.  
  7947.          if ((SIP.flags & 4)==0) {      // bit2=0 means lock is not shared
  7948.  
  7949.             // currently exclusive, make it shared
  7950.  
  7951.             LP.func = RELOCK_INDEX_XB;
  7952.             LP.handle = passedHandle;
  7953.             LP.xlMode = LOCK_SHARED;
  7954.             rez = BULLET(&LP);
  7955.             if (rez) goto ErrorHandler;
  7956.          }
  7957.       }
  7958.    }
  7959.    else {
  7960.  
  7961.       SDP.func = STAT_DATA_XB;
  7962.       SDP.handle = passedHandle;
  7963.       rez = BULLET(&SDP);
  7964.       if (rez) goto ErrorHandler;
  7965.  
  7966.       if (SDP.lockCount) {              // count of active full locks
  7967.  
  7968.          if ((SDP.flags & 4)==0) {      // bit2=0 means lock is not shared
  7969.  
  7970.             // currently exclusive, make it shared
  7971.  
  7972.             LP.func = RELOCK_DATA_XB;
  7973.             LP.handle = passedHandle;
  7974.             LP.dlMode = LOCK_SHARED;
  7975.             LP.startRec = 0;            // entire file
  7976.             rez = BULLET(&LP);
  7977.             if (rez) goto ErrorHandler;
  7978.          }
  7979.       }
  7980.    }
  7981. }
  7982.  
  7983.  
  7984. ΓòÉΓòÉΓòÉ 10.30. DOS Disk Routines Through Bullet ΓòÉΓòÉΓòÉ
  7985.  
  7986. #include "bullet_2.h"
  7987.  
  7988. DOSFILEPACK DFP;                // packs used here
  7989.  
  7990. CHAR dataDirname[] = "under";
  7991. CHAR dataFilename[]= "under\\data.dbf";
  7992. CHAR newFilename[] = "under\\newdata.dbf";
  7993.  
  7994. // check if pathame can be access for read/write denynone (expected not here)
  7995.  
  7996. DFP.func = ACCESS_FILE_DOS;
  7997. DFP.filenamePtr = dataFilename;
  7998. DFP.asMode = 0x42;
  7999. rez = BULLET(&DFP);
  8000. if (rez==0) return(0);          // file already exists
  8001. if (rez==5) return(5);          // access denied (exists but in use)
  8002. // other errors possible, too, do the Make and Create and go by those results
  8003.  
  8004. // make directory for file
  8005.  
  8006. DFP.func = MAKE_DIR_DOS;
  8007. DFP.filenamePtr = dataDirname;
  8008. rez = BULLET(&DFP);
  8009. if (rez) rez=0;                 // can't create subdirectory (already exists?)
  8010.  
  8011. // create file
  8012.  
  8013. DFP.func = CREATE_FILE_DOS;
  8014. DFP.filenamePtr = dataFilename;
  8015. DFP.attr = 0;                   // 'normal' attributes
  8016. rez = BULLET(&DFP);
  8017. if (rez) return(rez);           // can't create file
  8018.  
  8019. // open file
  8020.  
  8021. DFP.func = OPEN_FILE_DOS;
  8022. DFP.filenamePtr = dataFilename;
  8023. DFP.asMode = 0x42;
  8024. rez = BULLET(&DFP);
  8025. if (rez) return(rez);           // can't open file
  8026.  
  8027. // DFP.handle is set by OPEN_FILE_DOS call above
  8028. // pre-allocate file space
  8029.  
  8030. DFP.func = EXPAND_FILE_DOS;
  8031. // DFP.handle already set
  8032. // DFP.asMode already set
  8033. DFP.bytes = 128*1024;           // set filesize to 128KB
  8034. rez = BULLET(&DFP);
  8035. if (rez) return(rez);           // can't do it (close file before return)
  8036.  
  8037. CHAR writeStuff[]="Write this string to offset 888";
  8038.  
  8039. DFP.func = SEEK_FILE_DOS;
  8040. // DFP.handle already set
  8041. DFP.seekTo = 888;
  8042. DFP.method = 0;                 // from start of file
  8043. rez = BULLET(&DFP);
  8044. if (rez) return(rez);           // can't do it (close...)
  8045.  
  8046. // write the string to disk
  8047.  
  8048. DFP.func = WRITE_FILE_DOS;
  8049. // DFP.handle already set
  8050. DFP.bytes = strlen(writeStuff);
  8051. DFP.bufferPtr = writeStuff;
  8052. rez = BULLET(&DFP);
  8053. if (rez) return(rez);
  8054.  
  8055. // commit to the deep
  8056.  
  8057. DFP.func = COMMIT_FILE_DOS;
  8058. // DFP.handle already set
  8059. rez = BULLET(&DFP);
  8060. if (rez) return(rez);
  8061.  
  8062. // reposition to where write started so can read what was written
  8063.  
  8064. DFP.func = SEEK_FILE_DOS;
  8065. // DFP.handle already set
  8066. DFP.seekTo = 888;
  8067. DFP.method = 0;
  8068. rez = BULLET(&DFP);
  8069. if (rez) return(rez);
  8070.  
  8071. CHAR readBuffer[128];
  8072.  
  8073. DFP.func = READ_FILE_DOS;
  8074. // DFP.handle already set
  8075. DFP.bytes = strlen(writeStuff); // read it back
  8076. DFP.bufferPtr = readBuffer;
  8077. rez = BULLET(&DFP);
  8078. if (rez) return(rez);
  8079. if (DFP.bytes != strlen(writeStuff))
  8080.    printf("read came up short!\n");
  8081.  
  8082. DFP.func = CLOSE_FILE_DOS;
  8083. // DFP.handle already set
  8084. rez = BULLET(&DFP);
  8085. if (rez) return(rez);
  8086. DFP.handle = 0;                 // it's gone (closed, anyway)
  8087.  
  8088. // rename the file
  8089.  
  8090. DFP.func = RENAME_FILE_DOS;
  8091. DFP.filenamePtr = dataFilename;
  8092. DFP.newFilenamePtr = newFilename;
  8093. rez = BULLET(&DFP);
  8094. if (rez) return(rez);
  8095.  
  8096. // and get rid of it (known now as newFilename)
  8097.  
  8098. DFP.func = DELETE_FILE_DOS;
  8099. DFP.filenamePtr = newFilename;
  8100. rez = BULLET(&DFP);
  8101. return(rez);
  8102.  
  8103. // Why the DosXXX routines when they're standard API?  Not all
  8104. // language tools are able to directly call the API, but can
  8105. // call them indirectly through the Bullet DLL.
  8106.  
  8107.  
  8108. ΓòÉΓòÉΓòÉ 11. Bullet Errors ΓòÉΓòÉΓòÉ
  8109.  
  8110. Bullet error codes are numbered so that they do not overlap OS error codes. 
  8111. The first general Bullet error number is 8193, but Bullet also returns select 
  8112. system error code numbers instead of duplicating system codes (those listed 
  8113. below less than 8192).  In addition, if the error is reported by the OS (for 
  8114. example, attempting to access a locked file), then the OS error in returned by 
  8115. Bullet.  For a list of OS errors, see OS/2 Dos API Errors. 
  8116.  
  8117. System Error Codes
  8118.  
  8119.    8    EXB_NOT_ENOUGH_MEMORY
  8120.         cannot get memory requested
  8121.  
  8122.   38    EXB_UNEXPECTED_EOF
  8123.         unexpected end-of-file where bytes requested for read exceeded EOF
  8124.  
  8125.   39    EXB_DISK_FULL
  8126.         disk full on WriteFile
  8127.  
  8128.   80    EXB_FILE_EXISTS
  8129.         cannot create file since it already exists
  8130.  
  8131.  
  8132. 8192+   EXB_OR_WITH_FAULTS
  8133.         1=flush failed on handle close
  8134.         2=free memory failed on handle close
  8135.         4=failed memo handle close (data handle only)
  8136.  
  8137.         During a CLOSE_XB routine, the close process continues
  8138.         regardless of errors, and so the errors are accumulated.
  8139.         For example, 8193 means the flush failed, and 8195 means
  8140.         both the flush and the free failed (8192+1+2=8195).
  8141.         If the error occurred in the actual DosClose() API call,
  8142.         only that error is returned (it will be an OS error code).
  8143.  
  8144.  
  8145. 8300    EXB_ILLEGAL_CMD
  8146.         function not allowed
  8147.  
  8148. 8301    EXB_OLD_DOS
  8149.         OS version < MIN_DOS_NEEDED
  8150.  
  8151. 8302    EXB_NOT_INITIALIZED
  8152.         init not active, must do INIT_XB before using Bullet
  8153.  
  8154. 8303    EXB_ALREADY_INITIALIZED
  8155.         init already active, must do EXIT_XB first
  8156.  
  8157. 8304    EXB_TOO_MANY_HANDLES
  8158.         more than 1024 opens requested,
  8159.         or more than license permits (100, 250, 1024)
  8160.  
  8161. 8305    EXB_SYSTEM_HANDLE
  8162.         Bullet won't use or close handles 0-2
  8163.  
  8164. 8306    EXB_FILE_NOT_OPEN
  8165.         the handle is not a Bullet handle, including the
  8166.         handle supplied in OP.xbLink
  8167.  
  8168. 8307    EXB_FILE_IS_DIRTY
  8169.         tried to reload header but current still dirty;
  8170.         flush the file before reloading the header
  8171.  
  8172. 8308    EXB_BAD_FILETYPE
  8173.         attempted to do a key file operation on non-key file,
  8174.         or a data operation on a non-data file
  8175.  
  8176. 8309    EXB_TOO_MANY_PACKS
  8177.         too many INSERT, UPDATE, REINDEX, LOCK_XB packs (more than 256)
  8178.  
  8179. 8310    EXB_NULL_RECPTR
  8180.         null record pointer passed to Bullet (.recPtr==NULL)
  8181.  
  8182. 8311    EXB_NULL_KEYPTR
  8183.         null key pointer passed to Bullet (.keyPtr==NULL)
  8184.  
  8185. 8312    EXB_NULL_MEMOPTR
  8186.         null memo pointer passed to Bullet (.memoPtr==NULL)
  8187.  
  8188. 8313    EXB_EXPIRED
  8189.         evaluation time period has expired, reinstall if time remaining
  8190.  
  8191. 8314    EXB_BAD_INDEX
  8192.         Query/SetSysVars index selection is beyond the last one
  8193.  
  8194. 8315    EXB_RO_INDEX
  8195.         SetSysVars index item is read-only
  8196.  
  8197. 8316    EXB_FILE_BOUNDS
  8198.         file size > 4GB, or greater than the SetSysVars value
  8199.  
  8200.  
  8201. 8397    EXB_FORCE_ROLLBACK
  8202.         rollback test requested (last AP[].nextPtr=-1 for Insert/Update) (test-use only)
  8203.  
  8204. 8398    EXB_INVALID_DLL
  8205.         DLL seems to be invalid (8399 similar)
  8206.  
  8207.  
  8208. Multi-access Error Codes
  8209.  
  8210. 8401    EXB_BAD_LOCK_MODE
  8211.         lock mode (LP) not valid, must be 0 or 1
  8212.  
  8213. 8402    EXB_NOTHING_TO_RELOCK
  8214.         cannot relock without existing full-lock
  8215.  
  8216. 8403    ERR_SHARED_LOCK_ON
  8217.         unlikely error, write access needed for flush, but lock is shared
  8218.  
  8219.  
  8220. Index Error Codes
  8221.  
  8222. 8501    EXB_KEY_NOT_FOUND
  8223.         exact match of key not found
  8224.  
  8225. 8502    EXB_KEY_EXISTS
  8226.         key exists already and dups not allowed
  8227.  
  8228. 8503    EXB_END_OF_FILE
  8229.         already at last index order
  8230.  
  8231. 8504    EXB_TOP_OF_FILE
  8232.         already at first index order
  8233.  
  8234. 8505    EXB_EMPTY_FILE
  8235.         nothing to do since no keys
  8236.  
  8237. 8506    EXB_CANNOT_GET_LAST
  8238.         cannot locate last key
  8239.  
  8240. 8507    EXB_BAD_INDEX_STACK
  8241.         index file is corrupt
  8242.  
  8243. 8508    EXB_BAD_INDEX_READ0
  8244.         index file is corrupt
  8245.  
  8246. 8509    EXB_BAD_INDEX_WRITE0
  8247.         index file is corrupt
  8248.  
  8249.  
  8250. 8521    EXB_OLD_INDEX
  8251.         incompatible Bullet index, use ReindexOld subroutine, if available
  8252.  
  8253. 8522    EXB_UNKNOWN_INDEX
  8254.         not a Bullet index file
  8255.  
  8256. 8523    EXB_KEY_TOO_LONG
  8257.         keylength > 62 (or 64 if unique), or is 0
  8258.  
  8259.  
  8260. 8531    EXB_PARSER_NULL
  8261.         parser function pointer is NULL
  8262.  
  8263. 8532    EXB_BUILDER_NULL
  8264.         build key function pointer is NULL
  8265.  
  8266. 8533    EXB_BAD_SORT_FUNC
  8267.         CIP.sortFunction not valid (not 1-6, or a custom sort-compare)
  8268.  
  8269. 8534    EXB_BAD_NODE_SIZE
  8270.         CIP.nodeSize is not 512, 1024, or 2048
  8271.  
  8272. 8535    EXB_FILENAME_TOO_LONG
  8273.         CIP.filenamePtr->pathname greater than file system allows
  8274.  
  8275.         This error is detected only for the file system installed,
  8276.         and does not detect using pathnames greater than 80 on a FAT
  8277.         system if HPFS is installed.  The OS returns its own error
  8278.         in this case, after the fact.
  8279.  
  8280.  
  8281. 8541    EXB_KEYX_NULL
  8282.         key expression is effectively NULL
  8283.  
  8284. 8542    EXB_KEYX_TOO_LONG
  8285.         CIP.keyExpPtr->expression is greater than 159 bytes
  8286.  
  8287. 8543    EXB_KEYX_SYM_TOO_LONG
  8288.         fieldname/funcname in expression is longer than 10 chars
  8289.  
  8290. 8544    EXB_KEYX_SYM_UNKNOWN
  8291.         fieldname/funcname in expression is unknown or misspelled
  8292.  
  8293. 8545    EXB_KEYX_TOO_MANY_SYMS
  8294.         too many symbols/fields used in expression (16 max)
  8295.  
  8296. 8546    EXB_KEYX_BAD_SUBSTR
  8297.         invalid SUBSTR() operand in expression
  8298.  
  8299. 8547    EXB_KEYX_BAD_SUBSTR_SZ
  8300.         SUBSTR() exceeds field's size
  8301.  
  8302. 8548    EXB_KEYX_BAD_FORM
  8303.         didn't match expected symbol in expression (missing paren, etc.)
  8304.  
  8305.  
  8306. 8551    EXB_NO_READS_FOR_RUN
  8307.         unlikely error, use different reindex buffer size to fix
  8308.  
  8309. 8552    EXB_TOO_MANY_RUNS
  8310.         unlikely error, too many runs (64K or more runs)
  8311.  
  8312. 8553    EXB_TOO_MANY_RUNS_FOR_BUFFER
  8313.         unlikely error, too many runs for run buffer
  8314.  
  8315. 8554    EXB_TOO_MANY_DUPLICATES
  8316.         more than 64K "identical" keys since the last enumerator used
  8317.         was 0xFFFF -- if ever you have this error, REINDEX_XB should
  8318.         be used to resequence the enumerators
  8319.  
  8320.  
  8321. 8561    EXB_INSERT_RECNO_BAD
  8322.         AP.recNo cannot be > 0 if inserting with INSERT_XB
  8323.  
  8324. 8562    EXB_PREV_APPEND_EMPTY
  8325.         no previous append for INSERT_XB yet AP.recNo==0x80000000
  8326.  
  8327. 8563    EXB_PREV_APPEND_MISMATCH
  8328.         previous append's xbLink does not match this
  8329.         -- if this pack's AP.recNo=0x80000000 then this pack's AP.handle
  8330.         must be the same handle as that of the last pack that added a record
  8331.  
  8332. 8564    EXB_INSERT_KBO_FAILED
  8333.         could not back out key at INSERT_XB
  8334.  
  8335. 8565    EXB_INSERT_DBO_FAILED
  8336.         could not back out data records at INSERT_XB
  8337.  
  8338.  
  8339. 8571    WRN_NOTHING_TO_UPDATE
  8340.         all AP.recNo=0 at UPDATE_XB so nothing to do
  8341.  
  8342. 8572    EXB_INTERNAL_UPDATE
  8343.         internal error UPDATE_XB, not in handle/record# list
  8344.  
  8345. 8573    EXB_FAILED_DATA_RESTORE
  8346.         could not restore original data record (*)
  8347.  
  8348. 8574    EXB_FAILED_KEY_DELETE
  8349.         could not remove new key (*)
  8350.  
  8351. 8575    EXB_FAILED_KEY_RESTORE
  8352.         could not restore original key(*)
  8353.  
  8354.         (*) original error, which forced a back-out, has been
  8355.         replaced by this error -- this error is always returned
  8356.         in the first AP.stat (-1 on data, 1 on index)
  8357.  
  8358.  
  8359. Data Error Codes
  8360.  
  8361. 8601    EXB_EXT_XBLINK
  8362.         xbLink handle is not an internal DBF, as was specified during the
  8363.         index file's creation -- the Bullet routine called requires a Bullet
  8364.         DBF data file (instead use index-only access methods like NEXT_KEY_XB).
  8365.  
  8366. 8602    EXB_FIELDNAME_TOO_LONG
  8367.         fieldname is > 10 characters
  8368.  
  8369. 8603    EXB_RECORD_TOO_LONG
  8370.         record length is > 64K
  8371.  
  8372. 8604    EXB_FIELD_NOT_FOUND
  8373.         fieldname not found in descriptor info
  8374.  
  8375. 8605    EXB_BAD_FIELD_COUNT
  8376.         fields <= 0 or >= MAX_FIELDS; also use of a field number which
  8377.         is beyond the last field
  8378.  
  8379. 8606    EXB_BAD_HEADER
  8380.         bad header (reclen=0, etc.)
  8381.  
  8382. 8607    EXB_BUFFER_TOO_SMALL
  8383.         buffer too small (pack buffer < record length)
  8384.  
  8385. 8608    EXB_INTERNAL_PACK
  8386.         internal error in PackRecords
  8387.  
  8388. 8609    EXB_BAD_RECNO
  8389.         record number=0 or > records in data file header, or
  8390.         pack attempt on empty data file
  8391.  
  8392. 8610    WRN_RECORD_TAGGED
  8393.         record's tag field matches skip tag
  8394.  
  8395.  
  8396. Memo Error Codes
  8397.  
  8398. 8701    WRN_CANNOT_OPEN_MEMO
  8399.         the DBF header has bits 3 & 7 set, which indicates that a memo
  8400.         file is attached to this DBF, but the DBT memo file failed to open
  8401.         -- the DBF open continues, with this warning code returned
  8402.  
  8403. 8702    EXB_MEMO_NOT_OPEN
  8404.         no open memo file for operation
  8405.  
  8406. 8703    EXB_BAD_BLOCKSIZE
  8407.         memo blocksize must be at least 24 bytes
  8408.  
  8409. 8704    EXB_MEMO_DELETED
  8410.         memo is deleted
  8411.  
  8412. 8705    EXB_MEMO_PAST_END
  8413.         memo data requested is past end of record
  8414.  
  8415. 8706    EXB_BAD_MEMONO
  8416.         memo number is not valid
  8417.  
  8418. 8707    EXB_MEMO_IN_USE
  8419.         memo add encountered likely corrupt memo file
  8420.         -- avail list indicates this memo record is deleted, but the memoAvail
  8421.         link for the memo indicates it is use (memoAvail link==0x8FFFF)
  8422.  
  8423. 8708    EXB_BAD_AVAIL_LINK
  8424.         memo avail link cannot be valid (e.g., memoAvail==0)
  8425.  
  8426. 8709    EXB_MEMO_ZERO_SIZE
  8427.         memo data has no size (size is 0)
  8428.  
  8429. 8710    EXB_MEMO_IS_SMALLER
  8430.         memo attempt to shrink but memo size is already <= size requested
  8431.  
  8432.  
  8433. ΓòÉΓòÉΓòÉ 12. OS/2 Dos API Errors ΓòÉΓòÉΓòÉ
  8434.  
  8435.  
  8436.   0   NO_ERROR
  8437.           No error occurred.
  8438.  
  8439.   1   ERROR_INVALID_FUNCTION
  8440.           Invalid function number.
  8441.  
  8442.   2   ERROR_FILE_NOT_FOUND
  8443.           File not found.
  8444.  
  8445.   3   ERROR_PATH_NOT_FOUND
  8446.           Path not found.
  8447.  
  8448.   4   ERROR_TOO_MANY_OPEN_FILES
  8449.           Too many open files (no handles left).
  8450.  
  8451.   5   ERROR_ACCESS_DENIED
  8452.           Access denied.
  8453.  
  8454.   6   ERROR_INVALID_HANDLE
  8455.           Invalid handle.
  8456.  
  8457.   7   ERROR_ARENA_TRASHED
  8458.           Memory control blocks destroyed.
  8459.  
  8460.   8   ERROR_NOT_ENOUGH_MEMORY
  8461.           Insufficient memory.
  8462.  
  8463.   9   ERROR_INVALID_BLOCK
  8464.           Invalid memory-block address.
  8465.  
  8466.   10   ERROR_BAD_ENVIRONMENT
  8467.           Invalid environment.
  8468.  
  8469.   11   ERROR_BAD_FORMAT
  8470.           Invalid format.
  8471.  
  8472.   12   ERROR_INVALID_ACCESS
  8473.           Invalid access code.
  8474.  
  8475.   13   ERROR_INVALID_DATA
  8476.           Invalid data.
  8477.  
  8478.   14   Reserved.
  8479.  
  8480.  
  8481.   15   ERROR_INVALID_DRIVE
  8482.           Invalid drive specified.
  8483.  
  8484.   16   ERROR_CURRENT_DIRECTORY
  8485.           Attempting to remove current directory.
  8486.  
  8487.   17   ERROR_NOT_SAME_DEVICE
  8488.           Not same device.
  8489.  
  8490.   18   ERROR_NO_MORE_FILES
  8491.           No more files.
  8492.  
  8493.   19   ERROR_WRITE_PROTECT
  8494.           Attempt to write on write-protected diskette.
  8495.  
  8496.   20   ERROR_BAD_UNIT
  8497.           Unknown unit.
  8498.  
  8499.   21   ERROR_NOT_READY
  8500.           Drive not ready.
  8501.  
  8502.   22   ERROR_BAD_COMMAND
  8503.           Unknown command.
  8504.  
  8505.   23   ERROR_CRC
  8506.           Data error - cyclic redundancy check.
  8507.  
  8508.   24   ERROR_BAD_LENGTH
  8509.           Invalid request structure length.
  8510.  
  8511.   25   ERROR_SEEK
  8512.           Seek error.
  8513.  
  8514.   26   ERROR_NOT_DOS_DISK
  8515.           Unknown media type.
  8516.  
  8517.   27   ERROR_SECTOR_NOT_FOUND
  8518.           Sector not found.
  8519.  
  8520.   28   ERROR_OUT_OF_PAPER
  8521.           Printer is out of paper.
  8522.  
  8523.   29   ERROR_WRITE FAULT
  8524.           Write fault.
  8525.  
  8526.   30   ERROR_READ_FAULT
  8527.           Read fault.
  8528.  
  8529.   31   ERROR_GEN_FAILURE
  8530.           General failure.
  8531.  
  8532.   32   ERROR_SHARING_VIOLATION
  8533.           Sharing violation.
  8534.  
  8535.   33   ERROR_LOCK_VIOLATION
  8536.           Lock violation.
  8537.  
  8538.   34   ERROR_WRONG_DISK
  8539.           Invalid disk change.
  8540.  
  8541.   35   ERROR_FCB_UNAVAILABLE
  8542.           FCB unavailable.
  8543.  
  8544.   36   ERROR_SHARING_BUFFER_EXCEEDED
  8545.           Sharing buffer overflow.
  8546.  
  8547.   37   ERROR_CODE_PAGE_MISMATCHED
  8548.           Code page does not match.
  8549.  
  8550.   38   ERROR_HANDLE_EOF
  8551.           End of file reached.
  8552.  
  8553.   39   ERROR_HANDLE_DISK_FULL
  8554.           Disk is full.
  8555.  
  8556.   40-49   Reserved.
  8557.  
  8558.  
  8559.   50   ERROR_NOT_SUPPORTED
  8560.           Network request not supported.
  8561.  
  8562.   51   ERROR_REM_NOT_LIST
  8563.           Remote network node is not online.
  8564.  
  8565.   52   ERROR_DUP_NAME
  8566.           Duplicate file name in network.
  8567.  
  8568.   53   ERROR_BAD_NETPATH
  8569.           Network path not found.
  8570.  
  8571.   54   ERROR_NETWORK_BUSY
  8572.           Network is busy.
  8573.  
  8574.   55   ERROR_DEV_NOT_EXIST
  8575.           Device is not installed in network.
  8576.  
  8577.   56   ERROR_TOO_MANY_CMDS
  8578.           Network command limit reached.
  8579.  
  8580.   57   ERROR_ADAP_HDW_ERR
  8581.           Network adapter hardware error.
  8582.  
  8583.   58   ERROR_BAD_NET_RESP
  8584.           Incorrect response in network.
  8585.  
  8586.   59   ERROR_UNEXP_NET_ERR
  8587.           Unexpected error in network.
  8588.  
  8589.   60   ERROR_BAD_REM_ADAP
  8590.           Remote network adapter error.
  8591.  
  8592.   61   ERROR_PRINTQ_FULL
  8593.           Network printer queue is full.
  8594.  
  8595.   62   ERROR_NO_SPOOL_SPACE
  8596.           No space in print spool file.
  8597.  
  8598.   63   ERROR_PRINT_CANCELLED
  8599.           Print spool file deleted.
  8600.  
  8601.   64   ERROR_NETNAME_DELETED
  8602.           Network name deleted.
  8603.  
  8604.   65   ERROR_NETWORK_ACCESS_DENIED
  8605.           Access to network denied.
  8606.  
  8607.   66   ERROR_BAD_DEV_TYPE
  8608.           Device type invalid for network.
  8609.  
  8610.   67   ERROR_BAD_NET_NAME
  8611.           Network name not found.
  8612.  
  8613.   68   ERROR_TOO_MANY_NAMES
  8614.           Network name limit exceeded.
  8615.  
  8616.   69   ERROR_TOO_MANY_SESS
  8617.           Network session limit exceeded.
  8618.  
  8619.   70   ERROR_SHARING_PAUSED
  8620.           Temporary pause in network.
  8621.  
  8622.   71   ERROR_REQ_NOT_ACCEP
  8623.           Network request denied.
  8624.  
  8625.   72   ERROR_REDIR_PAUSED
  8626.           Pause in network print disk redirection.
  8627.  
  8628.   73   ERROR_SBCS_ATT_WRITE_PROT
  8629.           Attempted write on protected disk.
  8630.  
  8631.   74   ERROR_SBCS_GENERAL_FAILURE
  8632.           General failure, single-byte character set.
  8633.  
  8634.   75-79   Reserved.
  8635.  
  8636.  
  8637.   80   ERROR_FILE_EXISTS
  8638.           File exists.
  8639.  
  8640.   81   ERROR_DUP_FCB
  8641.           Reserved.
  8642.  
  8643.   82   ERROR_CANNOT_MAKE
  8644.           Cannot make directory entry.
  8645.  
  8646.   83   ERROR_FAIL_I24
  8647.           Failure on INT 24.
  8648.  
  8649.   84   ERROR_OUT_OF_STRUCTURES
  8650.           Too many redirections.
  8651.  
  8652.   85   ERROR_ALREADY_ASSIGNED
  8653.           Duplicate redirection.
  8654.  
  8655.   86   ERROR_INVALID_PASSWORD
  8656.           Invalid password.
  8657.  
  8658.   87   ERROR_INVALID_PARAMETER
  8659.           Invalid parameter.
  8660.  
  8661.   88   ERROR_NET_WRITE_FAULT
  8662.           Network device fault.
  8663.  
  8664.   89   ERROR_NO_PROC_SLOTS
  8665.           No process slots available.
  8666.  
  8667.   90   ERROR_NOT_FROZEN
  8668.           System error.
  8669.  
  8670.   91   ERR_TSTOVFL
  8671.           Timer service table overflow.
  8672.  
  8673.   92   ERR_TSTDUP
  8674.           Timer service table duplicate.
  8675.  
  8676.   93   ERROR_NO_ITEMS
  8677.           No items to work on.
  8678.  
  8679.   95   ERROR_INTERRUPT
  8680.           Interrupted system call.
  8681.  
  8682.   99   ERROR_DEVICE_IN_USE
  8683.           Device in use.
  8684.  
  8685.   100   ERROR_TOO_MANY_SEMAPHORES
  8686.           User/system open semaphore limit reached.
  8687.  
  8688.   101   ERROR_EXCL_SEM_ALREADY_OWNED
  8689.           Exclusive semaphore already owned.
  8690.  
  8691.   102   ERROR_SEM_IS_SET
  8692.           DosCloseSem found semaphore set.
  8693.  
  8694.   103   ERROR_TOO_MANY_SEM_REQUESTS
  8695.           Too many exclusive semaphore requests.
  8696.  
  8697.   104   ERROR_INVALID_AT_INTERRUPT_TIME
  8698.           Operation invalid at interrupt time.
  8699.  
  8700.   105   ERROR_SEM_OWNER_DIED
  8701.           Previous semaphore owner terminated without freeing semaphore.
  8702.  
  8703.   106   ERROR_SEM_USER_LIMIT
  8704.           Semaphore limit exceeded.
  8705.  
  8706.   107   ERROR_DISK_CHANGE
  8707.           Insert drive B disk into drive A.
  8708.  
  8709.   108   ERROR_DRIVE_LOCKED
  8710.           Drive locked by another process.
  8711.  
  8712.   109   ERROR_BROKEN_PIPE
  8713.           Write on pipe with no reader.
  8714.  
  8715.   110   ERROR_OPEN_FAILED
  8716.           Open/create failed due to explicit fail command.
  8717.  
  8718.   111   ERROR_BUFFER_OVERFLOW
  8719.           Buffer passed to system call too small to hold return data.
  8720.  
  8721.   112   ERROR_DISK_FULL
  8722.           Not enough space on the disk.
  8723.  
  8724.   113   ERROR_NO_MORE_SEARCH_HANDLES
  8725.           Cannot allocate another search structure and handle.
  8726.  
  8727.   114   ERROR_INVALID_TARGET_HANDLE
  8728.           Target handle in DosDupHandle invalid.
  8729.  
  8730.   115   ERROR_PROTECTION_VIOLATION
  8731.           Invalid user virtual address.
  8732.  
  8733.   116   ERROR_VIOKBD_REQUEST
  8734.           Error on display write or keyboard read.
  8735.  
  8736.   117   ERROR_INVALID_CATEGORY
  8737.           Category for DevIOCtl not defined.
  8738.  
  8739.   118   ERROR_INVALID_VERIFY_SWITCH
  8740.           Invalid value passed for verify flag.
  8741.  
  8742.   119   ERROR_BAD_DRIVER_LEVEL
  8743.           Level four driver not found.
  8744.  
  8745.   120   ERROR_CALL_NOT_IMPLEMENTED
  8746.           Invalid function called.
  8747.  
  8748.   121   ERROR_SEM_TIMEOUT
  8749.           Time-out occurred from semaphore API function.
  8750.  
  8751.   122   ERROR_INSUFFICIENT_BUFFER
  8752.           Data buffer too small.
  8753.  
  8754.   123   ERROR_INVALID_NAME
  8755.           Illegal character or invalid file-system name.
  8756.  
  8757.   124   ERROR_INVALID_LEVEL
  8758.           Non-implemented level for information retrieval or setting.
  8759.  
  8760.   125   ERROR_NO_VOLUME_LABEL
  8761.           No volume label found with DosQueryFSInfo function.
  8762.  
  8763.   126   ERROR_MOD_NOT_FOUND
  8764.           Module handle not found with DosQueryProcAddr(),
  8765.           DosQueryModAddr().
  8766.  
  8767.   127   ERROR_PROC_NOT_FOUND
  8768.           Procedure address not found with DosQueryProcAddr().
  8769.  
  8770.   128   ERROR_WAIT_NO_CHILDREN
  8771.           DosWaitChild finds no children.
  8772.  
  8773.   129   ERROR_CHILD_NOT_COMPLETE
  8774.           DosWaitChild children not terminated.
  8775.  
  8776.   130   ERROR_DIRECT_ACCESS_HANDLE
  8777.           Handle operation invalid for direct disk-access handles.
  8778.  
  8779.   131   ERROR_NEGATIVE_SEEK
  8780.           Attempting seek to negative offset.
  8781.  
  8782.   132   ERROR_SEEK_ON_DEVICE
  8783.           Application trying to seek on device or pipe.
  8784.  
  8785.   133   ERROR_IS_JOIN_TARGET
  8786.           Drive has previously joined drives.
  8787.  
  8788.   134   ERROR_IS_JOINED
  8789.           Drive is already joined.
  8790.  
  8791.   135   ERROR_IS_SUBSTED
  8792.           Drive is already substituted.
  8793.  
  8794.   136   ERROR_NOT_JOINED
  8795.           Cannot delete drive that is not joined.
  8796.  
  8797.   137   ERROR_NOT_SUBSTED
  8798.           Cannot delete drive that is not substituted.
  8799.  
  8800.   138   ERROR_JOIN_TO_JOIN
  8801.           Cannot join to a joined drive.
  8802.  
  8803.   139   ERROR_SUBST_TO_SUBST
  8804.           Cannot substitute to a substituted drive.
  8805.  
  8806.   140   ERROR_JOIN_TO_SUBST
  8807.           Cannot join to a substituted drive.
  8808.  
  8809.   141   ERROR_SUBST_TO_JOIN
  8810.           Cannot substitute to a joined drive.
  8811.  
  8812.   142   ERROR_BUSY_DRIVE
  8813.           Specified drive is busy.
  8814.  
  8815.   143   ERROR_SAME_DRIVE
  8816.           Cannot join or substitute a drive to a directory on the same drive.
  8817.  
  8818.   144   ERROR_DIR_NOT_ROOT
  8819.           Directory must be a subdirectory of the root.
  8820.  
  8821.   145   ERROR_DIR_NOT_EMPTY
  8822.           Directory must be empty to use join command.
  8823.  
  8824.   146   ERROR_IS_SUBST_PATH
  8825.           Path specified is being used in a substitute.
  8826.  
  8827.   147   ERROR_IS_JOIN_PATH
  8828.           Path specified is being used in a join.
  8829.  
  8830.   148   ERROR_PATH_BUSY
  8831.           Path specified is being used by another process.
  8832.  
  8833.   149   ERROR_IS_SUBST_TARGET
  8834.           Cannot join or substitute a drive that has a directory that is the
  8835.           target of a previous substitute.
  8836.  
  8837.   150   ERROR_SYSTEM_TRACE
  8838.           System trace error.
  8839.  
  8840.   151   ERROR_INVALID_EVENT_COUNT
  8841.           DosWaitMuxWaitSem errors.
  8842.  
  8843.   152   ERROR_TOO_MANY_MUXWAITERS
  8844.           System limit of 100 entries reached.
  8845.  
  8846.   153   ERROR_INVALID_LIST_FORMAT
  8847.           Invalid list format.
  8848.  
  8849.   154   ERROR_LABEL_TOO_LONG
  8850.           Volume label too big.
  8851.  
  8852.   155   ERROR_TOO_MANY_TCBS
  8853.           Cannot create another TCB.
  8854.  
  8855.   156   ERROR_SIGNAL_REFUSED
  8856.           Signal refused.
  8857.  
  8858.   157   ERROR_DISCARDED
  8859.           Segment is discarded.
  8860.  
  8861.   158   ERROR_NOT_LOCKED
  8862.           Segment is not locked.
  8863.  
  8864.   159   ERROR_BAD_THREADID_ADDR
  8865.           Invalid thread-identity address.
  8866.  
  8867.   160   ERROR_BAD_ARGUMENTS
  8868.           Invalid environment pointer.
  8869.  
  8870.   161   ERROR_BAD_PATHNAME
  8871.           Invalid path name passed to exec.
  8872.  
  8873.   162   ERROR_SIGNAL_PENDING
  8874.           Signal already pending.
  8875.  
  8876.   163   ERROR_UNCERTAIN_MEDIA
  8877.           Error with INT 24 mapping.
  8878.  
  8879.   164   ERROR_MAX_THRDS_REACHED
  8880.           No more process slots.
  8881.  
  8882.   165   ERROR_MONITORS_NOT_SUPPORTED
  8883.           Error with INT 24 mapping.
  8884.  
  8885.   166   ERROR_UNC_DRIVER_NOT_INSTALLED
  8886.           Default redirection return code.
  8887.  
  8888.   167   ERROR_LOCK_FAILED
  8889.           Locking failed.
  8890.  
  8891.   168   ERROR_SWAPIO_FAILED
  8892.           Swap I/O failed.
  8893.  
  8894.   169   ERROR_SWAPIN_FAILED
  8895.           Swap in failed.
  8896.  
  8897.   170   ERROR_BUSY
  8898.           Segment is busy.
  8899.  
  8900.   171-172   Reserved.
  8901.  
  8902.  
  8903.   173   ERROR_CANCEL_VIOLATION
  8904.           A lock request is not outstanding for the specified file range, or the
  8905.           range length is zero.
  8906.  
  8907.   174   ERROR_ATOMIC_LOCK_NOT_SUPPORTED
  8908.           The file-system driver (FSD) does not support atomic lock operations.
  8909.           Versions of OS/2 prior to version 2.00 do not support atomic lock
  8910.           operations.
  8911.  
  8912.   175   ERROR_READ_LOCKS_NOT_SUPPORTED
  8913.           The file system driver (FSD) does not support shared read locks.
  8914.  
  8915.   176-179   Reserved.
  8916.  
  8917.  
  8918.   180   ERROR_INVALID_SEGMENT_NUMBER
  8919.           Invalid segment number.
  8920.  
  8921.   181   ERROR_INVALID_CALLGATE
  8922.           Invalid call gate.
  8923.  
  8924.   182   ERROR_INVALID_ORDINAL
  8925.           Invalid ordinal.
  8926.  
  8927.   183   ERROR_ALREADY_EXISTS
  8928.           Shared segment already exists.
  8929.  
  8930.   184   ERROR_NO_CHILD_PROCESS
  8931.           No child process to wait for.
  8932.  
  8933.   185   ERROR_CHILD_ALIVE_NOWAIT
  8934.           NoWait specified and child alive.
  8935.  
  8936.   186   ERROR_INVALID_FLAG_NUMBER
  8937.           Invalid flag number.
  8938.  
  8939.   187   ERROR_SEM_NOT_FOUND
  8940.           Semaphore does not exist.
  8941.  
  8942.   188   ERROR_INVALID_STARTING_CODESEG
  8943.           Invalid starting code segment, incorrect END (label) directive.
  8944.  
  8945.   189   ERROR_INVALID_STACKSEG
  8946.           Invalid stack segment.
  8947.  
  8948.   190   ERROR_INVALID_MODULETYPE
  8949.           Invalid module type - dynamic-link library file cannot be used as an
  8950.           application. Application cannot be used as a dynamic-link library.
  8951.  
  8952.   191   ERROR_INVALID_EXE_SIGNATURE
  8953.           Invalid EXE signature - file is a DOS mode program or an improper
  8954.           program.
  8955.  
  8956.   192   ERROR_EXE_MARKED_INVALID
  8957.           EXE marked invalid - link detected errors when the application was
  8958.           created.
  8959.  
  8960.   193   ERROR_BAD_EXE_FORMAT
  8961.           Invalid EXE format - file is a DOS mode program or an improper
  8962.           program.
  8963.  
  8964.   194   ERROR_ITERATED_DATA_EXCEEDS_64k
  8965.           Iterated data exceeds 64KB - there is more than 64KB of data in one
  8966.           of the segments of the file.
  8967.  
  8968.   195   ERROR_INVALID_MINALLOCSIZE
  8969.           Invalid minimum allocation size - the size is specified to be less than
  8970.           the size of the segment data in the file.
  8971.  
  8972.   196   ERROR_DYNLINK_FROM_INVALID_RING
  8973.           Dynamic link from invalid privilege level - privilege level 2 routine
  8974.           cannot link to dynamic-link libraries.
  8975.  
  8976.   197   ERROR_IOPL_NOT_ENABLED
  8977.           IOPL not enabled - IOPL set to NO in CONFIG.SYS.
  8978.  
  8979.   198   ERROR_INVALID_SEGDPL
  8980.           Invalid segment descriptor privilege level - can only have privilege
  8981.           levels of 2 and 3.
  8982.  
  8983.   199   ERROR_AUTODATASEG_EXCEEDS_64k
  8984.           Automatic data segment exceeds 64KB.
  8985.  
  8986.   200   ERROR_RING2SEG_MUST_BE_MOVABLE
  8987.           Privilege level 2 segment must be movable.
  8988.  
  8989.   201   ERROR_RELOC_CHAIN_XEEDS_SEGLIM
  8990.           Relocation chain exceeds segment limit.
  8991.  
  8992.   202   ERROR_INFLOOP_IN_RELOC_CHAIN
  8993.           Infinite loop in relocation chain segment.
  8994.  
  8995.   203   ERROR_ENVVAR_NOT_FOUND
  8996.           Environment variable not found.
  8997.  
  8998.   204   ERROR_NOT_CURRENT_CTRY
  8999.           Not current country.
  9000.  
  9001.   205   ERROR_NO_SIGNAL_SENT
  9002.           No signal sent - no process in the command subtree has a signal
  9003.           handler.
  9004.  
  9005.   206   ERROR_FILENAME_EXCED_RANGE
  9006.           File name or extension is greater than 8.3 characters.
  9007.  
  9008.   207   ERROR_RING2_STACK_IN_USE
  9009.           Privilege level 2 stack is in use.
  9010.  
  9011.   208   ERROR_META_EXPANSION_TOO_LONG
  9012.           Meta (global) expansion is too long.
  9013.  
  9014.   209   ERROR_INVALID_SIGNAL_NUMBER
  9015.           Invalid signal number.
  9016.  
  9017.   210   ERROR_THREAD_1_INACTIVE
  9018.           Inactive thread.
  9019.  
  9020.   211   ERROR_INFO_NOT_AVAIL
  9021.           File system information is not available for this file.
  9022.  
  9023.   212   ERROR_LOCKED
  9024.           Locked error.
  9025.  
  9026.   213   ERROR_BAD_DYNALINK
  9027.           Attempted to execute a non-family API in DOS mode.
  9028.  
  9029.   214   ERROR_TOO_MANY_MODULES
  9030.           Too many modules.
  9031.  
  9032.   215   ERROR_NESTING_NOT_ALLOWED
  9033.           Nesting is not allowed.
  9034.  
  9035.   217   ERROR_ZOMBIE_PROCESS
  9036.           Zombie process.
  9037.  
  9038.   218   ERROR_STACK_IN_HIGH_MEMORY
  9039.           Stack is in high memory.
  9040.  
  9041.   219   ERROR_INVALID_EXITROUTINE_RING
  9042.           Invalid exit routine ring.
  9043.  
  9044.   220   ERROR_GETBUF_FAILED
  9045.           Get buffer failed.
  9046.  
  9047.   221   ERROR_FLUSHBUF_FAILED
  9048.           Flush buffer failed.
  9049.  
  9050.   222   ERROR_TRANSFER_TOO_LONG
  9051.           Transfer is too long.
  9052.  
  9053.   224   ERROR_SMG_NO_TARGET_WINDOW
  9054.           The application window was created without the FCF_TASKLIST
  9055.           style, or the application window not yet been created or has already
  9056.           been destroyed.
  9057.  
  9058.   228   ERROR_NO_CHILDREN
  9059.           No child process.
  9060.  
  9061.   229   ERROR_INVALID_SCREEN_GROUP
  9062.           Invalid session.
  9063.  
  9064.   230   ERROR_BAD_PIPE
  9065.           Non-existent pipe or invalid operation.
  9066.  
  9067.   231   ERROR_PIPE_BUSY
  9068.           Pipe is busy.
  9069.  
  9070.   232   ERROR_NO_DATA
  9071.           No data available on non-blocking read.
  9072.  
  9073.   233   ERROR_PIPE_NOT_CONNECTED
  9074.           Pipe was disconnected by server.
  9075.  
  9076.   234   ERROR_MORE_DATA
  9077.           More data is available.
  9078.  
  9079.   240   ERROR_VC_DISCONNECTED
  9080.           Session was dropped due to errors.
  9081.  
  9082.   250   ERROR_CIRCULARITY_REQUESTED
  9083.           Renaming a directory that would cause a circularity problem.
  9084.  
  9085.   251   ERROR_DIRECTORY_IN_CDS
  9086.           Renaming a directory that is in use.
  9087.  
  9088.   252   ERROR_INVALID_FSD_NAME
  9089.           Trying to access nonexistent FSD.
  9090.  
  9091.   253   ERROR_INVALID_PATH
  9092.           Invalid pseudo device.
  9093.  
  9094.   254   ERROR_INVALID_EA_NAME
  9095.           Invalid character in name, or invalid cbName.
  9096.  
  9097.   255   ERROR_EA_LIST_INCONSISTENT
  9098.           List does not match its size, or there are invalid EAs in the list.
  9099.  
  9100.   256   ERROR_EA_LIST_TOO_LONG
  9101.           FEAList is longer than 64K-1 bytes.
  9102.  
  9103.   257   ERROR_NO_META_MATCH
  9104.           String does not match expression.
  9105.  
  9106.   259   ERROR_NO_MORE_ITEMS
  9107.           DosQueryFSAttach ordinal query.
  9108.  
  9109.   260   ERROR_SEARCH_STRUC_REUSED
  9110.           DOS mode findfirst/next search structure reused.
  9111.  
  9112.   261   ERROR_CHAR_NOT_FOUND
  9113.           Character not found.
  9114.  
  9115.   262   ERROR_TOO_MUCH_STACK
  9116.           Stack request exceeds system limit.
  9117.  
  9118.   263   ERROR_INVALID_ATTR
  9119.           Invalid attribute.
  9120.  
  9121.   264   ERROR_INVALID_STARTING_RING
  9122.           Invalid starting ring.
  9123.  
  9124.   265   ERROR_INVALID_DLL_INIT_RING
  9125.           Invalid DLL INIT ring.
  9126.  
  9127.   266   ERROR_CANNOT_COPY
  9128.           Cannot copy.
  9129.  
  9130.   267   ERROR_DIRECTORY
  9131.           Used by DOSCOPY in doscall1.
  9132.  
  9133.   268   ERROR_OPLOCKED_FILE
  9134.           Oplocked file.
  9135.  
  9136.   269   ERROR_OPLOCK_THREAD_EXISTS
  9137.           Oplock thread exists.
  9138.  
  9139.   270   ERROR_VOLUME_CHANGED
  9140.           Volume changed.
  9141.  
  9142.   271-273   Reserved.
  9143.  
  9144.  
  9145.   274   ERROR_ALREADY_SHUTDOWN
  9146.           System is already shut down.
  9147.  
  9148.   275   ERROR_EAS_DIDNT_FIT
  9149.           Buffer is not big enough to hold the EAs.
  9150.  
  9151.   276   ERROR_EA_FILE_CORRUPT
  9152.           EA file has been damaged.
  9153.  
  9154.   277   ERROR_EA_TABLE_FULL
  9155.           EA table is full.
  9156.  
  9157.   278   ERROR_INVALID_EA_HANDLE
  9158.           EA handle is invalid.
  9159.  
  9160.   279   ERROR_NO_CLUSTER
  9161.           No cluster.
  9162.  
  9163.   280   ERROR_CREATE_EA_FILE
  9164.           Cannot create the EA file.
  9165.  
  9166.   281   ERROR_CANNOT_OPEN_EA_FILE
  9167.           Cannot open the EA file.
  9168.  
  9169.   282   ERROR_EAS_NOT_SUPPORTED
  9170.           Destination file system does not support EAs.
  9171.  
  9172.   283   ERROR_NEED_EAS_FOUND
  9173.           Destination file system does not support EAs, and the source file's
  9174.           EAs contain a need EA.
  9175.  
  9176.   284   ERROR_DUPLICATE_HANDLE
  9177.           The handle already exists.
  9178.  
  9179.   285   ERROR_DUPLICATE_NAME
  9180.           The name already exists.
  9181.  
  9182.   286   ERROR_EMPTY_MUXWAIT
  9183.           The list of semaphores in a muxwait semaphore is empty.
  9184.  
  9185.   287   ERROR_MUTEX_OWNED
  9186.           The calling thread owns one or more of the mutex semaphores in the
  9187.           list.
  9188.  
  9189.   288   ERROR_NOT_OWNER
  9190.           Caller does not own the semaphore.
  9191.  
  9192.   289   ERROR_PARAM_TOO_SMALL
  9193.           Parameter is not large enough to contain all of the semaphore
  9194.           records in the muxwait semaphore.
  9195.  
  9196.   290   ERROR_TOO_MANY_HANDLES
  9197.           Limit reached for number of handles.
  9198.  
  9199.   291   ERROR_TOO_MANY_OPENS
  9200.           There are too many files or semaphores open.
  9201.  
  9202.   292   ERROR_WRONG_TYPE
  9203.           Attempted to create wrong type of semaphore.
  9204.  
  9205.   293   ERROR_UNUSED_CODE
  9206.           Code is not used.
  9207.  
  9208.   294   ERROR_THREAD_NOT_TERMINATED
  9209.           Thread has not terminated.
  9210.  
  9211.   295   ERROR_INIT_ROUTINE_FAILED
  9212.           Initialization routine failed.
  9213.  
  9214.   296   ERROR_MODULE_IN_USE
  9215.           Module is in use.
  9216.  
  9217.   297   ERROR_NOT_ENOUGH_WATCHPOINTS
  9218.           There are not enough watchpoints.
  9219.  
  9220.   298   ERROR_TOO_MANY_POSTS
  9221.           Post count limit was reached for an event semaphore.
  9222.  
  9223.   299   ERROR_ALREADY_POSTED
  9224.           Event semaphore is already posted.
  9225.  
  9226.   300   ERROR_ALREADY_RESET
  9227.           Event semaphore is already reset.
  9228.  
  9229.   301   ERROR_SEM_BUSY
  9230.           Semaphore is busy.
  9231.  
  9232.   302   Reserved
  9233.  
  9234.  
  9235.   303   ERROR_INVALID_PROCID
  9236.           Invalid process identity.
  9237.  
  9238.   304   ERROR_INVALID_PDELTA
  9239.           Invalid priority delta.
  9240.  
  9241.   305   ERROR_NOT_DESCENDANT
  9242.           Not descendant.
  9243.  
  9244.   306   ERROR_NOT_SESSION_MANAGER
  9245.           Requestor not session manager.
  9246.  
  9247.   307   ERROR_INVALID_PCLASS
  9248.           Invalid P class.
  9249.  
  9250.   308   ERROR_INVALID_SCOPE
  9251.           Invalid scope.
  9252.  
  9253.   309   ERROR_INVALID_THREADID
  9254.           Invalid thread identity.
  9255.  
  9256.   310   ERROR_DOSSUB_SHRINK
  9257.           Cannot shrink segment - DosSubSetMem.
  9258.  
  9259.   311   ERROR_DOSSUB_NOMEM
  9260.           No memory to satisfy request - DosSubAllocMem.
  9261.  
  9262.   312   ERROR_DOSSUB_OVERLAP
  9263.           Overlap of the specified block with a block of allocated memory -
  9264.           DosSubFreeMem.
  9265.  
  9266.   313   ERROR_DOSSUB_BADSIZE
  9267.           Invalid size parameter - DosSubAllocMem or DosSubFreeMem.
  9268.  
  9269.   314   ERROR_DOSSUB_BADFLAG
  9270.           Invalid flag parameter - DosSubSetMem.
  9271.  
  9272.   315   ERROR_DOSSUB_BADSELECTOR
  9273.           Invalid segment selector.
  9274.  
  9275.   316   ERROR_MR_MSG_TOO_LONG
  9276.           Message too long for buffer.
  9277.  
  9278.   317   ERROR_MR_MID_NOT_FOUND
  9279.           Message identity number not found.
  9280.  
  9281.   318   ERROR_MR_UN_ACC_MSGF
  9282.           Unable to access message file.
  9283.  
  9284.   319   ERROR_MR_INV_MSGF_FORMAT
  9285.           Invalid message file format.
  9286.  
  9287.   320   ERROR_MR_INV_IVCOUNT
  9288.           Invalid insertion variable count.
  9289.  
  9290.   321   ERROR_MR_UN_PERFORM
  9291.           Unable to perform function.
  9292.  
  9293.   322   ERROR_TS_WAKEUP
  9294.           Unable to wake up.
  9295.  
  9296.   323   ERROR_TS_SEMHANDLE
  9297.           Invalid system semaphore.
  9298.  
  9299.   324   ERROR_TS_NOTIMER
  9300.           No timers available.
  9301.  
  9302.   326   ERROR_TS_HANDLE
  9303.           Invalid timer handle.
  9304.  
  9305.   327   ERROR_TS_DATETIME
  9306.           Date or time invalid.
  9307.  
  9308.   328   ERROR_SYS_INTERNAL
  9309.           Internal system error.
  9310.  
  9311.   329   ERROR_QUE_CURRENT_NAME
  9312.           Current queue name does not exist.
  9313.  
  9314.   330   ERROR_QUE_PROC_NOT_OWNED
  9315.           Current process does not own queue.
  9316.  
  9317.   331   ERROR_QUE_PROC_OWNED
  9318.           Current process owns queue.
  9319.  
  9320.   332   ERROR_QUE_DUPLICATE
  9321.           Duplicate queue name.
  9322.  
  9323.   333   ERROR_QUE_ELEMENT_NOT_EXIST
  9324.           Queue element does not exist.
  9325.  
  9326.   334   ERROR_QUE_NO_MEMORY
  9327.           Inadequate queue memory.
  9328.  
  9329.   335   ERROR_QUE_INVALID_NAME
  9330.           Invalid queue name.
  9331.  
  9332.   336   ERROR_QUE_INVALID_PRIORITY
  9333.           Invalid queue priority parameter.
  9334.  
  9335.   337   ERROR_QUE_INVALID_HANDLE
  9336.           Invalid queue handle.
  9337.  
  9338.   338   ERROR_QUE_LINK_NOT_FOUND
  9339.           Queue link not found.
  9340.  
  9341.   339   ERROR_QUE_MEMORY_ERROR
  9342.           Queue memory error.
  9343.  
  9344.   340   ERROR_QUE_PREV_AT_END
  9345.           Previous queue element was at end of queue.
  9346.  
  9347.   341   ERROR_QUE_PROC_NO_ACCESS
  9348.           Process does not have access to queues.
  9349.  
  9350.   342   ERROR_QUE_EMPTY
  9351.           Queue is empty.
  9352.  
  9353.   343   ERROR_QUE_NAME_NOT_EXIST
  9354.           Queue name does not exist.
  9355.  
  9356.   344   ERROR_QUE_NOT_INITIALIZED
  9357.           Queues not initialized.
  9358.  
  9359.   345   ERROR_QUE_UNABLE_TO_ACCESS
  9360.           Unable to access queues.
  9361.  
  9362.   346   ERROR_QUE_UNABLE_TO_ADD
  9363.           Unable to add new queue.
  9364.  
  9365.   347   ERROR_QUE_UNABLE_TO_INIT
  9366.           Unable to initialize queues.
  9367.  
  9368.   349   ERROR_VIO_INVALID_MASK
  9369.           Invalid function replaced.
  9370.  
  9371.   350   ERROR_VIO_PTR
  9372.           Invalid pointer to parameter.
  9373.  
  9374.   351   ERROR_VIO_APTR
  9375.           Invalid pointer to attribute.
  9376.  
  9377.   352   ERROR_VIO_RPTR
  9378.           Invalid pointer to row.
  9379.  
  9380.   353   ERROR_VIO_CPTR
  9381.           Invalid pointer to column.
  9382.  
  9383.   354   ERROR_VIO_LPTR
  9384.           Invalid pointer to length.
  9385.  
  9386.   355   ERROR_VIO_MODE
  9387.           Unsupported screen mode.
  9388.  
  9389.   356   ERROR_VIO_WIDTH
  9390.           Invalid cursor width value.
  9391.  
  9392.   357   ERROR_VIO_ATTR
  9393.           Invalid cursor attribute value.
  9394.  
  9395.   358   ERROR_VIO_ROW
  9396.           Invalid row value.
  9397.  
  9398.   359   ERROR_VIO_COL
  9399.           Invalid column value.
  9400.  
  9401.   360   ERROR_VIO_TOPROW
  9402.           Invalid TopRow value.
  9403.  
  9404.   361   ERROR_VIO_BOTROW
  9405.           Invalid BotRow value.
  9406.  
  9407.   362   ERROR_VIO_RIGHTCOL
  9408.           Invalid right column value.
  9409.  
  9410.   363   ERROR_VIO_LEFTCOL
  9411.           Invalid left column value.
  9412.  
  9413.   364   ERROR_SCS_CALL
  9414.           Call issued by other than session manager.
  9415.  
  9416.   365   ERROR_SCS_VALUE
  9417.           Value is not for save or restore.
  9418.  
  9419.   366   ERROR_VIO_WAIT_FLAG
  9420.           Invalid wait flag setting.
  9421.  
  9422.   367   ERROR_VIO_UNLOCK
  9423.           Screen not previously locked.
  9424.  
  9425.   368   ERROR_SGS_NOT_SESSION_MGR
  9426.           Caller not session manager.
  9427.  
  9428.   369   ERROR_SMG_INVALID_SGID
  9429.           Invalid session identity.
  9430.  
  9431.   369   ERROR_SMG_INVALID_SESSION_ID
  9432.           Invalid session ID.
  9433.  
  9434.   370   ERROR_SMG_NOSG
  9435.           No sessions available.
  9436.  
  9437.   370   ERROR_SMG_NO_SESSIONS
  9438.           No sessions available.
  9439.  
  9440.   371   ERROR_SMG_GRP_NOT_FOUND
  9441.           Session not found.
  9442.  
  9443.   371   ERROR_SMG_SESSION_NOT_FOUND
  9444.           Session not found.
  9445.  
  9446.   372   ERROR_SMG_SET_TITLE
  9447.           Title sent by shell or parent cannot be changed.
  9448.  
  9449.   373   ERROR_KBD_PARAMETER
  9450.           Invalid parameter to keyboard.
  9451.  
  9452.   374   ERROR_KBD_NO_DEVICE
  9453.           No device.
  9454.  
  9455.   375   ERROR_KBD_INVALID_IOWAIT
  9456.           Invalid I/O wait specified.
  9457.  
  9458.   376   ERROR_KBD_INVALID_LENGTH
  9459.           Invalid length for keyboard.
  9460.  
  9461.   377   ERROR_KBD_INVALID_ECHO_MASK
  9462.           Invalid echo mode mask.
  9463.  
  9464.   378   ERROR_KBD_INVALID_INPUT_MASK
  9465.           Invalid input mode mask.
  9466.  
  9467.   379   ERROR_MON_INVALID_PARMS
  9468.           Invalid parameters to DosMon.
  9469.  
  9470.   380   ERROR_MON_INVALID_DEVNAME
  9471.           Invalid device name string.
  9472.  
  9473.   381   ERROR_MON_INVALID_HANDLE
  9474.           Invalid device handle.
  9475.  
  9476.   382   ERROR_MON_BUFFER_TOO_SMALL
  9477.           Buffer too small.
  9478.  
  9479.   383   ERROR_MON_BUFFER_EMPTY
  9480.           Buffer is empty.
  9481.  
  9482.   384   ERROR_MON_DATA_TOO_LARGE
  9483.           Data record is too large.
  9484.  
  9485.   385   ERROR_MOUSE_NO_DEVICE
  9486.           Mouse device closed (invalid device handle).
  9487.  
  9488.   386   ERROR_MOUSE_INV_HANDLE
  9489.           Mouse device closed (invalid device handle).
  9490.  
  9491.   387   ERROR_MOUSE_INV_PARMS
  9492.           Parameters invalid for display mode.
  9493.  
  9494.   388   ERROR_MOUSE_CANT_RESET
  9495.           Function assigned and cannot be reset.
  9496.  
  9497.   389   ERROR_MOUSE_DISPLAY_PARMS
  9498.           Parameters invalid for display mode.
  9499.  
  9500.   390   ERROR_MOUSE_INV_MODULE
  9501.           Module not valid.
  9502.  
  9503.   391   ERROR_MOUSE_INV_ENTRY_PT
  9504.           Entry point not valid.
  9505.  
  9506.   392   ERROR_MOUSE_INV_MASK
  9507.           Function mask invalid.
  9508.  
  9509.   393   NO_ERROR_MOUSE_NO_DATA
  9510.           No valid data.
  9511.  
  9512.   394   NO_ERROR_MOUSE_PTR_DRAWN
  9513.           Pointer drawn.
  9514.  
  9515.   395   ERROR_INVALID_FREQUENCY
  9516.           Invalid frequency for beep.
  9517.  
  9518.   396   ERROR_NLS_NO_COUNTRY_FILE
  9519.           Cannot find COUNTRY.SYS file.
  9520.  
  9521.   397   ERROR_NLS_OPEN_FAILED
  9522.           Cannot open COUNTRY.SYS file.
  9523.  
  9524.   398   ERROR_NLS_NO_CTRY_CODE
  9525.           Country code not found.
  9526.  
  9527.   398   ERROR_NO_COUNTRY_OR_CODEPAGE
  9528.           Country code not found.
  9529.  
  9530.   399   ERROR_NLS_TABLE_TRUNCATED
  9531.           Table returned information truncated, buffer is too small.
  9532.  
  9533.   400   ERROR_NLS_BAD_TYPE
  9534.           Selected type does not exist.
  9535.  
  9536.   401   ERROR_NLS_TYPE_NOT_FOUND
  9537.           Selected type is not in file.
  9538.  
  9539.   402   ERROR_VIO_SMG_ONLY
  9540.           Valid from session manager only.
  9541.  
  9542.   403   ERROR_VIO_INVALID_ASCIIZ
  9543.           Invalid ASCIIZ length.
  9544.  
  9545.   404   ERROR_VIO_DEREGISTER
  9546.           VioDeRegister not allowed.
  9547.  
  9548.   405   ERROR_VIO_NO_POPUP
  9549.           Pop-up window not allocated.
  9550.  
  9551.   406   ERROR_VIO_EXISTING_POPUP
  9552.           Pop-up window on screen (NoWait).
  9553.  
  9554.   407   ERROR_KBD_SMG_ONLY
  9555.           Valid from session manager only.
  9556.  
  9557.   408   ERROR_KBD_INVALID_ASCIIZ
  9558.           Invalid ASCIIZ length.
  9559.  
  9560.   409   ERROR_KBD_INVALID_MASK
  9561.           Invalid replacement mask.
  9562.  
  9563.   410   ERROR_KBD_REGISTER
  9564.           KbdRegister not allowed.
  9565.  
  9566.   411   ERROR_KBD_DEREGISTER
  9567.           KbdDeRegister not allowed.
  9568.  
  9569.   412   ERROR_MOUSE_SMG_ONLY
  9570.           Valid from session manager only.
  9571.  
  9572.   413   ERROR_MOUSE_INVALID_ASCIIZ
  9573.           Invalid ASCIIZ length.
  9574.  
  9575.   414   ERROR_MOUSE_INVALID_MASK
  9576.           Invalid replacement mask.
  9577.  
  9578.   415   ERROR_MOUSE_REGISTER
  9579.           Mouse register not allowed.
  9580.  
  9581.   416   ERROR_MOUSE_DEREGISTER
  9582.           Mouse deregister not allowed.
  9583.  
  9584.   417   ERROR_SMG_BAD_ACTION
  9585.           Invalid action specified.
  9586.  
  9587.   418   ERROR_SMG_INVALID_CALL
  9588.           INIT called more than once, or invalid session identity.
  9589.  
  9590.   419   ERROR_SCS_SG_NOTFOUND
  9591.           New session number.
  9592.  
  9593.   420   ERROR_SCS_NOT_SHELL
  9594.           Caller is not shell.
  9595.  
  9596.   421   ERROR_VIO_INVALID_PARMS
  9597.           Invalid parameters passed.
  9598.  
  9599.   422   ERROR_VIO_FUNCTION_OWNED
  9600.           Save/restore already owned.
  9601.  
  9602.   423   ERROR_VIO_RETURN
  9603.           Non-destruct return (undo).
  9604.  
  9605.   424   ERROR_SCS_INVALID_FUNCTION
  9606.           Caller invalid function.
  9607.  
  9608.   425   ERROR_SCS_NOT_SESSION_MGR
  9609.           Caller not session manager.
  9610.  
  9611.   426   ERROR_VIO_REGISTER
  9612.           Vio register not allowed.
  9613.  
  9614.   427   ERROR_VIO_NO_MODE_THREAD
  9615.           No mode restore thread in SG.
  9616.  
  9617.   428   ERROR_VIO_NO_SAVE_RESTORE_THD
  9618.           No save/restore thread in SG.
  9619.  
  9620.   429   ERROR_VIO_IN_BG
  9621.           Function invalid in background.
  9622.  
  9623.   430   ERROR_VIO_ILLEGAL_DURING_POPUP
  9624.           Function not allowed during pop-up window.
  9625.  
  9626.   431   ERROR_SMG_NOT_BASESHELL
  9627.           Caller is not the base shell.
  9628.  
  9629.   432   ERROR_SMG_BAD_STATUSREQ
  9630.           Invalid status requested.
  9631.  
  9632.   433   ERROR_QUE_INVALID_WAIT
  9633.           NoWait parameter out of bounds.
  9634.  
  9635.   434   ERROR_VIO_LOCK
  9636.           Error returned from Scroll Lock.
  9637.  
  9638.   435   ERROR_MOUSE_INVALID_IOWAIT
  9639.           Invalid parameters for IOWait.
  9640.  
  9641.   436   ERROR_VIO_INVALID_HANDLE
  9642.           Invalid VIO handle.
  9643.  
  9644.   437   ERROR_VIO_ILLEGAL_DURING_LOCK
  9645.           Function not allowed during screen lock.
  9646.  
  9647.   438   ERROR_VIO_INVALID_LENGTH
  9648.           Invalid VIO length.
  9649.  
  9650.   439   ERROR_KBD_INVALID_HANDLE
  9651.           Invalid KBD handle.
  9652.  
  9653.   440   ERROR_KBD_NO_MORE_HANDLE
  9654.           Ran out of handles.
  9655.  
  9656.   441   ERROR_KBD_CANNOT_CREATE_KCB
  9657.           Unable to create kcb.
  9658.  
  9659.   442   ERROR_KBD_CODEPAGE_LOAD_INCOMPL
  9660.           Unsuccessful code-page load.
  9661.  
  9662.   443   ERROR_KBD_INVALID_CODEPAGE_ID
  9663.           Invalid code-page identity.
  9664.  
  9665.   444   ERROR_KBD_NO_CODEPAGE_SUPPORT
  9666.           No code page support.
  9667.  
  9668.   445   ERROR_KBD_FOCUS_REQUIRED
  9669.           Keyboard focus required.
  9670.  
  9671.   446   ERROR_KBD_FOCUS_ALREADY_ACTIVE
  9672.           Calling thread has an outstanding focus.
  9673.  
  9674.   447   ERROR_KBD_KEYBOARD_BUSY
  9675.           Keyboard is busy.
  9676.  
  9677.   448   ERROR_KBD_INVALID_CODEPAGE
  9678.           Invalid code page.
  9679.  
  9680.   449   ERROR_KBD_UNABLE_TO_FOCUS
  9681.           Focus attempt failed.
  9682.  
  9683.   450   ERROR_SMG_SESSION_NON_SELECT
  9684.           Session is not selectable.
  9685.  
  9686.   451   ERROR_SMG_SESSION_NOT_FOREGRND
  9687.           Parent/child session is not foreground.
  9688.  
  9689.   452   ERROR_SMG_SESSION_NOT_PARENT
  9690.           Not parent of requested child.
  9691.  
  9692.   453   ERROR_SMG_INVALID_START_MODE
  9693.           Invalid session start mode.
  9694.  
  9695.   454   ERROR_SMG_INVALID_RELATED_OPT
  9696.           Invalid session start related option.
  9697.  
  9698.   455   ERROR_SMG_INVALID_BOND_OPTION
  9699.           Invalid session bond option.
  9700.  
  9701.   456   ERROR_SMG_INVALID_SELECT_OPT
  9702.           Invalid session select option.
  9703.  
  9704.   457   ERROR_SMG_START_IN_BACKGROUND
  9705.           Session started in background.
  9706.  
  9707.   458   ERROR_SMG_INVALID_STOP_OPTION
  9708.           Invalid session stop option.
  9709.  
  9710.   459   ERROR_SMG_BAD_RESERVE
  9711.           Reserved parameters are not zero.
  9712.  
  9713.   460   ERROR_SMG_PROCESS_NOT_PARENT
  9714.           Session parent process already exists.
  9715.  
  9716.   461   ERROR_SMG_INVALID_DATA_LENGTH
  9717.           Invalid data length.
  9718.  
  9719.   462   ERROR_SMG_NOT_BOUND
  9720.           Parent is not bound.
  9721.  
  9722.   463   ERROR_SMG_RETRY_SUB_ALLOC
  9723.           Retry request block allocation.
  9724.  
  9725.   464   ERROR_KBD_DETACHED
  9726.           This call is not allowed for a detached PID.
  9727.  
  9728.   465   ERROR_VIO_DETACHED
  9729.           This call is not allowed for a detached PID.
  9730.  
  9731.   466   ERROR_MOU_DETACHED
  9732.           This call is not allowed for a detached PID.
  9733.  
  9734.   467   ERROR_VIO_FONT
  9735.           No font is available to support the mode.
  9736.  
  9737.   468   ERROR_VIO_USER_FONT
  9738.           User font is active.
  9739.  
  9740.   469   ERROR_VIO_BAD_CP
  9741.           Invalid code page specified.
  9742.  
  9743.   470   ERROR_VIO_NO_CP
  9744.           System displays do not support code page.
  9745.  
  9746.   471   ERROR_VIO_NA_CP
  9747.           Current display does not support code page.
  9748.  
  9749.   472   ERROR_INVALID_CODE_PAGE
  9750.           Invalid code page.
  9751.  
  9752.   473   ERROR_CPLIST_TOO_SMALL
  9753.           Code page list is too small.
  9754.  
  9755.   474   ERROR_CP_NOT_MOVED
  9756.           Code page was not moved.
  9757.  
  9758.   475   ERROR_MODE_SWITCH_INIT
  9759.           Mode switch initialization error.
  9760.  
  9761.   476   ERROR_CODE_PAGE_NOT_FOUND
  9762.           Code page was not found.
  9763.  
  9764.   477   ERROR_UNEXPECTED_SLOT_RETURNED
  9765.           Internal error.
  9766.  
  9767.   478   ERROR_SMG_INVALID_TRACE_OPTION
  9768.           Invalid start session trace indicator.
  9769.  
  9770.   479   ERROR_VIO_INTERNAL_RESOURCE
  9771.           VIO internal resource error.
  9772.  
  9773.   480   ERROR_VIO_SHELL_INIT
  9774.           VIO shell initialization error.
  9775.  
  9776.   481   ERROR_SMG_NO_HARD_ERRORS
  9777.           No session manager hard errors.
  9778.  
  9779.   482   ERROR_CP_SWITCH_INCOMPLETE
  9780.           DosSetProcessCp is unable to set a KBD or VIO code page.
  9781.  
  9782.   483   ERROR_VIO_TRANSPARENT_POPUP
  9783.           Error during VIO pop-up window.
  9784.  
  9785.   484   ERROR_CRITSEC_OVERFLOW
  9786.           Critical section overflow.
  9787.  
  9788.   485   ERROR_CRITSEC_UNDERFLOW
  9789.           Critical section underflow.
  9790.  
  9791.   486   ERROR_VIO_BAD_RESERVE
  9792.           Reserved parameter is not zero.
  9793.  
  9794.   487   ERROR_INVALID_ADDRESS
  9795.           Invalid physical address.
  9796.  
  9797.   488   ERROR_ZERO_SELECTORS_REQUESTED
  9798.           At least one selector must be requested.
  9799.  
  9800.   489   ERROR_NOT_ENOUGH_SELECTORS_AVA
  9801.           Not enough GDT selectors to satisfy request.
  9802.  
  9803.   490   ERROR_INVALID_SELECTOR
  9804.           Not a GDT selector.
  9805.  
  9806.   491   ERROR_SMG_INVALID_PROGRAM_TYPE
  9807.           Invalid program type.
  9808.  
  9809.   492   ERROR_SMG_INVALID_PGM_CONTROL
  9810.           Invalid program control.
  9811.  
  9812.   493   ERROR_SMG_INVALID_INHERIT_OPT
  9813.           Invalid inherit option.
  9814.  
  9815.   494   ERROR_VIO_EXTENDED_SG
  9816.  
  9817.  
  9818.   495   ERROR_VIO_NOT_PRES_MGR_SG
  9819.  
  9820.  
  9821.   496   ERROR_VIO_SHIELD_OWNED
  9822.  
  9823.  
  9824.   497   ERROR_VIO_NO_MORE_HANDLES
  9825.  
  9826.  
  9827.   498   ERROR_VIO_SEE_ERROR_LOG
  9828.  
  9829.  
  9830.   499   ERROR_VIO_ASSOCIATED_DC
  9831.  
  9832.  
  9833.   500   ERROR_KBD_NO_CONSOLE
  9834.  
  9835.  
  9836.   501   ERROR_MOUSE_NO_CONSOLE
  9837.  
  9838.  
  9839.   502   ERROR_MOUSE_INVALID_HANDLE
  9840.  
  9841.  
  9842.   503   ERROR_SMG_INVALID_DEBUG_PARMS
  9843.  
  9844.  
  9845.   504   ERROR_KBD_EXTENDED_SG
  9846.  
  9847.  
  9848.   505   ERROR_MOU_EXTENDED_SG
  9849.  
  9850.  
  9851.   506   ERROR_SMG_INVALID_ICON_FILE
  9852.  
  9853.  
  9854.   507   ERROR_TRC_PID_NON_EXISTENT
  9855.  
  9856.  
  9857.   508   ERROR_TRC_COUNT_ACTIVE
  9858.  
  9859.  
  9860.   509   ERROR_TRC_SUSPENDED_BY_COUNT
  9861.  
  9862.  
  9863.   510   ERROR_TRC_COUNT_INACTIVE
  9864.  
  9865.  
  9866.   511   ERROR_TRC_COUNT_REACHED
  9867.  
  9868.  
  9869.   512   ERROR_NO_MC_TRACE
  9870.  
  9871.  
  9872.   513   ERROR_MC_TRACE
  9873.  
  9874.  
  9875.   514   ERROR_TRC_COUNT_ZERO
  9876.  
  9877.  
  9878.   515   ERROR_SMG_TOO_MANY_DDS
  9879.  
  9880.  
  9881.   516   ERROR_SMG_INVALID_NOTIFICATION
  9882.  
  9883.  
  9884.   517   ERROR_LF_INVALID_FUNCTION
  9885.  
  9886.  
  9887.   518   ERROR_LF_NOT_AVAIL
  9888.  
  9889.  
  9890.   519   ERROR_LF_SUSPENDED
  9891.  
  9892.  
  9893.   520   ERROR_LF_BUF_TOO_SMALL
  9894.  
  9895.  
  9896.   521   ERROR_LF_BUFFER_CORRUPTED
  9897.  
  9898.  
  9899.   521   ERROR_LF_BUFFER_FULL
  9900.  
  9901.  
  9902.   522   ERROR_LF_INVALID_DAEMON
  9903.  
  9904.  
  9905.   522   ERROR_LF_INVALID_RECORD
  9906.  
  9907.  
  9908.   523   ERROR_LF_INVALID_TEMPL
  9909.  
  9910.  
  9911.   523   ERROR_LF_INVALID_SERVICE
  9912.  
  9913.  
  9914.   524   ERROR_LF_GENERAL_FAILURE
  9915.  
  9916.  
  9917.   525   ERROR_LF_INVALID_ID
  9918.  
  9919.  
  9920.   526   ERROR_LF_INVALID_HANDLE
  9921.  
  9922.  
  9923.   527   ERROR_LF_NO_ID_AVAIL
  9924.  
  9925.  
  9926.   528   ERROR_LF_TEMPLATE_AREA_FULL
  9927.  
  9928.  
  9929.   529   ERROR_LF_ID_IN_USE
  9930.  
  9931.  
  9932.   530   ERROR_MOU_NOT_INITIALIZED
  9933.  
  9934.  
  9935.   531   ERROR_MOUINITREAL_DONE
  9936.  
  9937.  
  9938.   532   ERROR_DOSSUB_CORRUPTED
  9939.  
  9940.  
  9941.   533   ERROR_MOUSE_CALLER_NOT_SUBSYS
  9942.  
  9943.  
  9944.   534   ERROR_ARITHMETIC_OVERFLOW
  9945.  
  9946.  
  9947.   535   ERROR_TMR_NO_DEVICE
  9948.  
  9949.  
  9950.   536   ERROR_TMR_INVALID_TIME
  9951.  
  9952.  
  9953.   537   ERROR_PVW_INVALID_ENTITY
  9954.  
  9955.  
  9956.   538   ERROR_PVW_INVALID_ENTITY_TYPE
  9957.  
  9958.  
  9959.   539   ERROR_PVW_INVALID_SPEC
  9960.  
  9961.  
  9962.   540   ERROR_PVW_INVALID_RANGE_TYPE
  9963.  
  9964.  
  9965.   541   ERROR_PVW_INVALID_COUNTER_BLK
  9966.  
  9967.  
  9968.   542   ERROR_PVW_INVALID_TEXT_BLK
  9969.  
  9970.  
  9971.   543   ERROR_PRF_NOT_INITIALIZED
  9972.  
  9973.  
  9974.   544   ERROR_PRF_ALREADY_INITIALIZED
  9975.  
  9976.  
  9977.   545   ERROR_PRF_NOT_STARTED
  9978.  
  9979.  
  9980.   546   ERROR_PRF_ALREADY_STARTED
  9981.  
  9982.  
  9983.   547   ERROR_PRF_TIMER_OUT_OF_RANGE
  9984.  
  9985.  
  9986.   548   ERROR_PRF_TIMER_RESET
  9987.  
  9988.  
  9989.   639   ERROR_VDD_LOCK_USEAGE_DENIED
  9990.  
  9991.  
  9992.   640   ERROR_TIMEOUT
  9993.  
  9994.  
  9995.   641   ERROR_VDM_DOWN
  9996.  
  9997.  
  9998.   642   ERROR_VDM_LIMIT
  9999.  
  10000.  
  10001.   643   ERROR_VDD_NOT_FOUND
  10002.  
  10003.  
  10004.   644   ERROR_INVALID_CALLER
  10005.  
  10006.  
  10007.   645   ERROR_PID_MISMATCH
  10008.  
  10009.  
  10010.   646   ERROR_INVALID_VDD_HANDLE
  10011.  
  10012.  
  10013.   647   ERROR_VLPT_NO_SPOOLER
  10014.  
  10015.  
  10016.   648   ERROR_VCOM_DEVICE_BUSY
  10017.  
  10018.  
  10019.   649   ERROR_VLPT_DEVICE_BUSY
  10020.  
  10021.  
  10022.   650   ERROR_NESTING_TOO_DEEP
  10023.  
  10024.  
  10025.   651   ERROR_VDD_MISSING
  10026.  
  10027.  
  10028.   691   ERROR_IMP_INVALID_PARM
  10029.  
  10030.  
  10031.   692   ERROR_IMP_INVALID_LENGTH
  10032.  
  10033.  
  10034.   693   MSG_HPFS_DISK_ERROR_WARN
  10035.  
  10036.  
  10037.   730   ERROR_MON_BAD_BUFFER
  10038.  
  10039.  
  10040.   731   ERROR_MODULE_CORRUPTED
  10041.  
  10042.  
  10043.   2055   ERROR_LF_TIMEOUT
  10044.  
  10045.  
  10046.   2057   ERROR_LF_SUSPEND_SUCCESS
  10047.  
  10048.  
  10049.   2058   ERROR_LF_RESUME_SUCCESS
  10050.  
  10051.  
  10052.   2059   ERROR_LF_REDIRECT_SUCCESS
  10053.  
  10054.  
  10055.   2060   ERROR_LF_REDIRECT_FAILURE
  10056.  
  10057.  
  10058.   32768   ERROR_SWAPPER_NOT_ACTIVE
  10059.  
  10060.  
  10061.   32769   ERROR_INVALID_SWAPID
  10062.  
  10063.  
  10064.   32770   ERROR_IOERR_SWAP_FILE
  10065.  
  10066.  
  10067.   32771   ERROR_SWAP_TABLE_FULL
  10068.  
  10069.  
  10070.   32772   ERROR_SWAP_FILE_FULL
  10071.  
  10072.  
  10073.   32773   ERROR_CANT_INIT_SWAPPER
  10074.  
  10075.  
  10076.   32774   ERROR_SWAPPER_ALREADY_INIT
  10077.  
  10078.  
  10079.   32775   ERROR_PMM_INSUFFICIENT_MEMORY
  10080.  
  10081.  
  10082.   32776   ERROR_PMM_INVALID_FLAGS
  10083.  
  10084.  
  10085.   32777   ERROR_PMM_INVALID_ADDRESS
  10086.  
  10087.  
  10088.   32778   ERROR_PMM_LOCK_FAILED
  10089.  
  10090.  
  10091.   32779   ERROR_PMM_UNLOCK_FAILED
  10092.  
  10093.  
  10094.   32780   ERROR_PMM_MOVE_INCOMPLETE
  10095.  
  10096.  
  10097.   32781   ERROR_UCOM_DRIVE_RENAMED
  10098.  
  10099.  
  10100.   32782   ERROR_UCOM_FILENAME_TRUNCATED
  10101.  
  10102.  
  10103.   32783   ERROR_UCOM_BUFFER_LENGTH
  10104.  
  10105.  
  10106.   32784   ERROR_MON_CHAIN_HANDLE
  10107.  
  10108.  
  10109.   32785   ERROR_MON_NOT_REGISTERED
  10110.  
  10111.  
  10112.   32786   ERROR_SMG_ALREADY_TOP
  10113.  
  10114.  
  10115.   32787   ERROR_PMM_ARENA_MODIFIED
  10116.  
  10117.  
  10118.   32788   ERROR_SMG_PRINTER_OPEN
  10119.  
  10120.  
  10121.   32789   ERROR_PMM_SET_FLAGS_FAILED
  10122.  
  10123.  
  10124.   32790   ERROR_INVALID_DOS_DD
  10125.  
  10126.  
  10127.   32791   ERROR_BLOCKED
  10128.  
  10129.  
  10130.   32792   ERROR_NOBLOCK
  10131.  
  10132.  
  10133.   32793   ERROR_INSTANCE_SHARED
  10134.  
  10135.  
  10136.   32794   ERROR_NO_OBJECT
  10137.  
  10138.  
  10139.   32795   ERROR_PARTIAL_ATTACH
  10140.  
  10141.  
  10142.   32796   ERROR_INCACHE
  10143.  
  10144.  
  10145.   32797   ERROR_SWAP_IO_PROBLEMS
  10146.  
  10147.  
  10148.   32798   ERROR_CROSSES_OBJECT_BOUNDARY
  10149.  
  10150.  
  10151.   32799   ERROR_LONGLOCK
  10152.  
  10153.  
  10154.   32800   ERROR_SHORTLOCK
  10155.  
  10156.  
  10157.   32801   ERROR_UVIRTLOCK
  10158.  
  10159.  
  10160.   32802   ERROR_ALIASLOCK
  10161.  
  10162.  
  10163.   32803   ERROR_ALIAS
  10164.  
  10165.  
  10166.   32804   ERROR_NO_MORE_HANDLES
  10167.  
  10168.  
  10169.   32805   ERROR_SCAN_TERMINATED
  10170.  
  10171.  
  10172.   32806   ERROR_TERMINATOR_NOT_FOUND
  10173.  
  10174.  
  10175.   32807   ERROR_NOT_DIRECT_CHILD
  10176.  
  10177.  
  10178.   32808   ERROR_DELAY_FREE
  10179.  
  10180.  
  10181.   32809   ERROR_GUARDPAGE
  10182.  
  10183.  
  10184.   32900   ERROR_SWAPERROR
  10185.  
  10186.  
  10187.   32901   ERROR_LDRERROR
  10188.  
  10189.  
  10190.   32902   ERROR_NOMEMORY
  10191.  
  10192.  
  10193.   32903   ERROR_NOACCESS
  10194.  
  10195.  
  10196.   32904   ERROR_NO_DLL_TERM
  10197.  
  10198.  
  10199.   65026   ERROR_CPSIO_CODE_PAGE_INVALID
  10200.  
  10201.  
  10202.   65027   ERROR_CPSIO_NO_SPOOLER
  10203.  
  10204.  
  10205.   65028   ERROR_CPSIO_FONT_ID_INVALID
  10206.  
  10207.  
  10208.   65033   ERROR_CPSIO_INTERNAL_ERROR
  10209.  
  10210.  
  10211.   65034   ERROR_CPSIO_INVALID_PTR_NAME
  10212.  
  10213.  
  10214.   65037   ERROR_CPSIO_NOT_ACTIVE
  10215.  
  10216.  
  10217.   65039   ERROR_CPSIO_PID_FULL
  10218.  
  10219.  
  10220.   65040   ERROR_CPSIO_PID_NOT_FOUND
  10221.  
  10222.  
  10223.   65043   ERROR_CPSIO_READ_CTL_SEQ
  10224.  
  10225.  
  10226.   65045   ERROR_CPSIO_READ_FNT_DEF
  10227.  
  10228.  
  10229.   65047   ERROR_CPSIO_WRITE_ERROR
  10230.  
  10231.  
  10232.   65048   ERROR_CPSIO_WRITE_FULL_ERROR
  10233.  
  10234.  
  10235.   65049   ERROR_CPSIO_WRITE_HANDLE_BAD
  10236.  
  10237.  
  10238.   65074   ERROR_CPSIO_SWIT_LOAD
  10239.  
  10240.  
  10241.   65077   ERROR_CPSIO_INV_COMMAND
  10242.  
  10243.  
  10244.   65078   ERROR_CPSIO_NO_FONT_SWIT
  10245.  
  10246.  
  10247.   65079   ERROR_ENTRY_IS_CALLGATE
  10248.  
  10249.  
  10250. ΓòÉΓòÉΓòÉ 13. Specifications ΓòÉΓòÉΓòÉ
  10251.  
  10252. Specifications covered: 
  10253.  
  10254. Γûá API Calls Made 
  10255.  
  10256. Γûá Memory Usage 
  10257.  
  10258. Γûá IX3 File Format 
  10259.  
  10260. Γûá DBF File Format 
  10261.  
  10262. Γûá DBT File Format 
  10263.  
  10264. Γûá Custom Sort-Compare Function 
  10265.  
  10266. Γûá Custom Build-Key 
  10267.  
  10268. Γûá Custom Expression Parser 
  10269.  
  10270.  
  10271. ΓòÉΓòÉΓòÉ 13.1. OS/2 API Calls Made ΓòÉΓòÉΓòÉ
  10272.  
  10273. The following are the API calls made by Bullet. 
  10274.  
  10275.  DosAllocMem             DosClose                 DosCopy 
  10276.  DosCloseMutexSem        DosCreateDir             DosCreateMutexSem 
  10277.  DosDelete (*)           DosErrClass              DosExitList 
  10278.  DosForceDelete          DosFreeMem               DosGetDateTime 
  10279.  DosMapCase              DosOpen                  DosQueryCollate 
  10280.  DosQueryCp              DosQueryCtryInfo         DosQueryCurrentDisk 
  10281.  DosQueryFSAttach        DosQueryHType            DosQuerySysInfo 
  10282.  DosMove                 DosRead                  DosReleaseMutexSem 
  10283.  DosRequestMutexSem      DosResetBuffer           DosScanEnv 
  10284.  DosSetFileLocks         DosSetFilePtr            DosSetFileSize 
  10285.  DosSetMaxFH             DosSetRelMaxFH           DosWrite 
  10286.  
  10287.  (*) DosForceDelete is used in favor of DosDelete. 
  10288.  
  10289.  
  10290. ΓòÉΓòÉΓòÉ 13.2. Bullet Memory Usage ΓòÉΓòÉΓòÉ
  10291.  
  10292. Memory is committed when allocated, using the PAG_COMMIT and the PAG_WRITE 
  10293. flags.  This is memory allocated by Bullet itself.  Additional memory needs are 
  10294. made by your code, such as parameter pack data, key buffers, and data record 
  10295. buffers. 
  10296.  
  10297. Code 
  10298.  
  10299. Bullet uses 7 pages for code, or less than 28KB. 
  10300.  
  10301. Data 
  10302.  
  10303. Γûá  Shared Data 
  10304.  
  10305. A single page of shared memory is used by all Bullet processes. 
  10306.  
  10307. Γûá  Instance Data 
  10308.  
  10309. One page of private memory is used by each Bullet processes. 
  10310.  
  10311. Γûá  Handle Data 
  10312.  
  10313. One page of private memory is used by each open Bullet index file.  For open 
  10314. data files, one page of private memory is used for files with 121 or fewer 
  10315. fields.  Two pages are used for files with 249 or fewer fields. Three pages are 
  10316. used for files with 250 or more fields. 
  10317.  
  10318. For example, if one machine is running 2 Bullet processes, each with 10 open 
  10319. data files with 12 fields each, and 10 index files (one for each data file), 
  10320. its total memory usage is: 
  10321.  
  10322.      Total code is 28KB. 
  10323.      Shared data is 4KB. 
  10324.      Instance data is 2 processes * 4KB, or 8KB (plus INIT_XB use shown 
  10325.       below). 
  10326.      DBF file data is 2 * 10 files * 4KB, or 80KB. 
  10327.      Index file data is 2 * 10 files * 4KB, or 80KB. 
  10328.  
  10329.  Total memory committed by Bullet for the above is 200KB, plus code and data of 
  10330.  your two applications (or your single application, if the same application is 
  10331.  being run twice).  With no files open, for example when starting your program, 
  10332.  only 40KB is committed.  Thereafter, 4KB per open file.  The memory is freed 
  10333.  when the file is closed. 
  10334.  
  10335.  Γûá  Temporary Data 
  10336.  
  10337.  Additional memory is allocated on a temporary basis, where the allocation is 
  10338.  requested on entry to, and is freed upon exiting from, the routine called. 
  10339.  INIT_XB's allocation can be considered permanent since INIT_XB is usually not 
  10340.  exited until the program has ended.  The following are the routines and the 
  10341.  single requested amount: 
  10342.  
  10343.      Routine          Memory Allocated, in KB
  10344.  
  10345.   INIT_XB             8 for 1024 MAX_FILES version; 4KB for 100 and 250 MAX_FILES versions
  10346.   BACKUP_FILE_XB      8
  10347.   CREATE_DATA_XB      4 for 1-121 fields, 8 for 122-249 fields, 12 for 250+ fields
  10348.   CREATE_INDEX_XB     4
  10349.   PACK_RECORDS_XB     adjustable, 128 default (less if file is smaller)
  10350.   REINDEX_XB          adjustable, 144 default (minimum size is 48KB)
  10351.   UPDATE_XB           varies:      40 + sum of record lengths where AP[].recNo!=0
  10352.  
  10353.  Γûá  Stack Data 
  10354.  
  10355.  Stack requirements are 8KB minimum for Bullet.  No single stack allocation 
  10356.  requests more than 4KB at a time (ie all changes to ESP (the CPU stack 
  10357.  pointer) are less than 4KB at any one time), but some routines nest and 
  10358.  require up to the minimum 8KB in total.  The minimum recommended stack size 
  10359.  for your Bullet application is 16KB.  It's likely that you need to use a much 
  10360.  larger size for your main program's stack use.  If you have any doubt about 
  10361.  stack space, double it, twice even. 
  10362.  
  10363.  
  10364. ΓòÉΓòÉΓòÉ 13.3. IX3 File Format ΓòÉΓòÉΓòÉ
  10365.  
  10366. The IX3 index file is composed of a header followed by node data.  The header 
  10367. layout is detailed below, followed by the node format. 
  10368.  
  10369. Index Header 
  10370.  
  10371. // nnn, where nnn is the offset of that item relative to the start of the file
  10372.  
  10373. CHAR fileID[4];     // 000 file id = '31ch'
  10374. ULONG nodeSize;     // 004 size of a node, in bytes
  10375. ULONG rootNode;     // 008 root node (1-based)
  10376. ULONG noKeys;       // 012 total number of keys
  10377. ULONG availNode;    // 016 next available node (link to, 0 if none, 1-based)
  10378. ULONG freeNode;     // 020 next free node
  10379. ULONG keyLength;    // 024 length of key
  10380. ULONG maxKeys;      // 028 maximum number of keys on a node
  10381. ULONG codePage;     // 032 code page from CreateIndexFile
  10382. ULONG countryCode;  // 036 country code from CreateIndexFile
  10383. ULONG sortFunction; // 040 system (1-9) or custom (10-19)
  10384.                     //     high word has flags: bit0=1 dups allowed
  10385.                     //                          bit1-15 rez
  10386.  
  10387. // Translated key expression as done by Parser during CreateIndex and Reindex.
  10388. // More details on this is in the Custom Expression Parser Specifications.
  10389. // For each key part in KH.expression a 4-byte structure is used in XLATEX:
  10390.  
  10391. typedef struct _XLATEX {
  10392.  CHAR  ftype;   // field type (C,N,L, etc.),if bit7=1 and C then do UPPER key
  10393.  CHAR  length;  // bytes to use starting at offset (never > 64)
  10394.  SHORT offset;  // byte offset into data record that length bytes are to be used
  10395. } XLATEX;
  10396.  
  10397. ULONG xlateCount;         // 044 number of key fields (64/4=16 max fields)
  10398. XLATEX xlateExpression[16]; // 048 key construct info (16 dword's worth)
  10399. CHAR  miscWorkspace[236]; // 112-347 B-tree workspace
  10400. CHAR  expression[160];    // 348 key expression, user (0-Terminated)
  10401. ULONG CTsize;             // 508 size of collate table following
  10402. CHAR  collateTable[256];  // 512 collate table, fill at CreateIndexXB
  10403. CHAR  rez[256];           // 768 to 1023 reserved (header size=1024 bytes)
  10404.  
  10405. Node Data 
  10406.  
  10407. Directly after the header the node data starts.  Each node is either 512, 1024, 
  10408. or 2048 bytes long.  Each node contains a key count, indicating the number of 
  10409. active keys on the node, followed by key data. 
  10410.  
  10411. // nnn, where nnn is the offset of that item relative to the start of the node
  10412.  
  10413. CHAR  keyCount;         // 000 1 to maxKeys (in header above)
  10414. ULONG backNode;         // 001 previous node page, or 0 if this node is a leaf
  10415. XNODE node[maxKeys];    // 005...
  10416.  
  10417. For each key on the node: 
  10418.  
  10419. typedef struct _XNODE {
  10420. CHAR  keyValue[keyLength]; // 005   actual key   (keyLength from header)
  10421. ULONG recordNo;            // 005+keyLength   record number for key
  10422. ULONG fwdNode;             // 005+keyLength+4   next node page, or 0 if leaf
  10423. } XNODE;
  10424.  
  10425. backNode and fwdNode are node numbers.  The first node is 1, and is located 
  10426. directly after the header.  The last node used is at header:freeNode-1.  Each 
  10427. fwdNode of a key is also the next key's backNode.  If the node has had all keys 
  10428. removed, its node number is placed on the top of the header:availNode list, and 
  10429. the first 4 bytes of the node are used as a link to the previous list top. 
  10430.  
  10431.  
  10432. ΓòÉΓòÉΓòÉ 13.4. DBF File Format ΓòÉΓòÉΓòÉ
  10433.  
  10434. The DBF data file is composed of a header, field descriptors, one per field, 
  10435. and the actual record data.  The header layout is detailed below, followed by 
  10436. the field descriptor layout and then the description of the data record. The 
  10437. standard DBF file has a record length limit of 4000 bytes.  Creating record 
  10438. lengths greater than 4000 is allowed in Bullet, but these files may not be 
  10439. recognized by other applications if you do so. 
  10440.  
  10441. DBF Header 
  10442.  
  10443. // nnn, where nnn is the offset of that item relative to the start of the file
  10444.  
  10445. CHAR  fileID;           // 000 file id byte
  10446. CHAR  lastUpdateYR;     // 001 binary year-1900
  10447. CHAR  lastUpdateMO;     // 002 binary month (1-12)
  10448. CHAR  lastUpdateDA;     // 003 binary day (1-31)
  10449. ULONG noRecords;        // 004 total number of records
  10450. SHORT headerLength;     // 008 length of data header
  10451. SHORT recordLength;     // 010 record length
  10452. SHORT nada;             // 012 reserved
  10453. CHAR  xactionFlag;      // 014 flag indicating incomplete dBASE transaction (n/a)
  10454. CHAR  encryptFlag;      // 015 flag indicating encrypted (n/a)
  10455. CHAR  filler[16];       // 016 fill to 32 bytes
  10456.  
  10457. Field Descriptors 
  10458.  
  10459. For each field, a descriptor is stored in the DBF.  The first descriptor starts 
  10460. directly after the header, at file offset 32 (the 33rd byte).  Each descriptor 
  10461. is 32 bytes.  After the last descriptor, a byte with ASCII value 13 (0x0D) is 
  10462. stored.  Following this byte, the record data starts. 
  10463.  
  10464. // nnn, where nnn is offset of item relative to the start of the descriptor
  10465.  
  10466. CHAR  fieldName[11];    // 000 ASCII, UPPER, underscore, zero-filled, (0T)
  10467. CHAR  fieldType;        // 011 UPPER C,N,D,L,M
  10468. ULONG fieldDA;          // 012 not used
  10469. CHAR  fieldLength;      // 016 1-255 bytes, depending on fieldType
  10470. CHAR  fieldDC;          // 017 places right of decimal point
  10471. SHORT altFieldLength;   // 018 alternate field length when fieldLength==0
  10472. CHAR  filler[12];       // 020 not used
  10473.  
  10474. // altFieldLength is proprietary to Bullet, and can be used if Xbase
  10475. // compatibility is not required and fields need to be larger than 255 bytes.
  10476. // To use it, set fieldLength=0 and altFieldLength to > 255 bytes.
  10477.  
  10478. Record Data 
  10479.  
  10480. The DBF data are free-form, fixed-length records.  Each data record starts with 
  10481. a one-byte 'tag' field, which is implicitly defined for all records (hence, it 
  10482. is not a formal field and has no descriptor).  Following the tag field is the 
  10483. first field of the record, and following that field (whose length is described 
  10484. in the field's descriptor) is the next field, and so on.  No separators are 
  10485. used between fields.  After the very last data record in the file, DBF 
  10486. specification dictates that an end of file marker be placed, so at the end of 
  10487. the file is a byte of value ASCII 26 (0x1A). 
  10488.  
  10489. Record layout is as you define in your application.  It must match the layout
  10490. as described in the field descriptors, byte-for-byte.
  10491.  
  10492. Increasing DBF Performance 
  10493.  
  10494. Records are stored in the order they were written.  To improve performance, 
  10495. especially indexed-sequential access, the data file may be sorted, or 
  10496. clustered, by reading each record in primary key order, then writing that 
  10497. record to a new DBF data file.  Repeat for each record.  After all records have 
  10498. been written, reindex the newly created DBF data file (and all related index 
  10499. files).  After this, delete the old files (data and index), and rename the new 
  10500. ones to the filenames required.  This technique maximizes cache efficiency, and 
  10501. can easily offer 10x performance increase in access speed. 
  10502.  
  10503.  
  10504. ΓòÉΓòÉΓòÉ 13.5. DBT File Format ΓòÉΓòÉΓòÉ
  10505.  
  10506. The DBT memo file is composed of a header followed by memo data, stored in one 
  10507. or more blocks.  The header layout is detailed below, followed by the memo 
  10508. record. 
  10509.  
  10510. DBT Header 
  10511.  
  10512. // nnn, where nnn is the offset of that item relative to the start of the file
  10513.  
  10514. ULONG memoAvailBlock;   // 000 next available block (header is block 0)
  10515. ULONG memoRez;          // 004 not used
  10516. CHAR  memoFilename[8];  // 008 filename proper (first 8 of filename proper)
  10517. ULONG memoRez2;         // 016 not used (apparently)
  10518. ULONG memoBlockSize;    // 020 block size, must be at least 24
  10519.  
  10520. // the rest of the header block (to block size bytes) is unused
  10521.  
  10522. Memo Record 
  10523.  
  10524. // nnn, where nnn is offset of item relative to the start of the memo record
  10525.  
  10526. ULONG memoAvail;        // 000 next available link
  10527. ULONG memoSize;         // 004 size of data (including this and memoAvail)
  10528. CHAR  memoData;         // 008 for as many bytes as memoSize, less 8
  10529.  
  10530. A memo may use one or more blocks (each block is a fixed size), but allocations 
  10531. are always contiguous.  Unused bytes after the memo data (to the end of the 
  10532. last block allocated to that memo record) are undefined.  memoAvail is 0x8FFFF 
  10533. for all active memo records.  For deleted memo records, memoAvail is used as a 
  10534. link in the memoAvail list.  memoSize is the total bytes used by the memo, 
  10535. including the memoAvail and memoSize data, so it is the size of the real data + 
  10536. 8 bytes. 
  10537.  
  10538.  
  10539. ΓòÉΓòÉΓòÉ 13.6. Custom Sort-Compare Function ΓòÉΓòÉΓòÉ
  10540.  
  10541. Bullet provides 10 custom sort-compare functions, in addition to the 6 
  10542. intrinsic sort-compare functions (ASCII, NLS, and the four integer compares). 
  10543. The custom function you supply is not actually a sort function, as the name 
  10544. implies, but a compare function.  Basically, two strings are supplied and your 
  10545. function determines string1's relation to string2 (<, >, or ==). 
  10546.  
  10547. The strings supplied (via pointers) are not C strings, and they are not 
  10548. (necessarily) 0-terminated.  A count value is passed, indicating the number of 
  10549. bytes to compare.  The handle of the index file for which this compare is being 
  10550. done is also supplied, so that you can interrogate the index file state 
  10551. (STAT_INDEX_XB) for any additional information required. 
  10552.  
  10553. In addition to the compare function this routine performs, a special-case call 
  10554. is made to this routine requesting a pointer to a string of HIGH-VALUES for 
  10555. this sort compare.  The pointer must be to a static memory area that exists for 
  10556. as long as the index file is open, and must be at least as long as count.  This 
  10557. special-case call is indicated by both string pointers==NULL. 
  10558.  
  10559. To use a custom sort-compare function, first use SET_SYSVARS_XB to assign the 
  10560. custom sort ID (10 to 19) with the function's address pointer.  Once assigned, 
  10561. an index file may be created with its CIP.sortFunction set to the sort ID 
  10562. (10-19).  Also, any previously created index file with a custom sort ID may now 
  10563. be opened (but only after you used SET_SYSVARS_XB to assign the sort-compare 
  10564. function pointer).  During the index file create, the sort ID you specified for 
  10565. the create is stored in the index file.  When that index file is later opened, 
  10566. that same sort ID is used, and so requires that the custom sort-compare 
  10567. function already be assigned (with SET_SYSVARS_XB) before opening the index 
  10568. file.  This means that you need to be consistent in your custom sort ID 
  10569. numbering, since each index created forever uses that sort ID you specified. 
  10570.  
  10571. It's simple to create a custom sort-compare function.  The calling convention 
  10572. is APIENTRY (or _System, or __syscall for some compilers), and the parameters 
  10573. are passed to your function on the stack (by Bullet).  A sample prototype for a 
  10574. custom sort-compare function follows: 
  10575.  
  10576. LONG APIENTRY YourCustomSort10(PVOID str1,
  10577.                                PVOID str2,
  10578.                                ULONG count,
  10579.                                ULONG handle);
  10580.  
  10581. If the pointers are not NULL, your routine is to compare str1 to str2, for 
  10582. count bytes, and is to return: 
  10583.  
  10584.         -1 if str1 is less than str2
  10585.          0 if str1 is equal to str2
  10586.          1 if str1 is greater than str2
  10587.  
  10588. str is not a C string, but is of type void.  Cast as required,
  10589. depending on the data expected.
  10590.  
  10591. If str1 and str2 are both NULL, your routine must return a pointer to a static 
  10592. object that contains high-values for the object type.  For example, if the 
  10593. sort-compare is for IEEE floating-point, then the function is to return a 
  10594. pointer to a static data area filled with the highest floating-point value. 
  10595. Depending on your sort-compare routine's functionality, you may need just a 
  10596. single high-value, or multiple high-values, one after the other (e.g., if you 
  10597. are supporting compound key values for binary keys).  The count parameter 
  10598. indicates the total bytes needed, so divide by the object size to get the 
  10599. number of objects required.  Be aware that the object size (in count) is +2 
  10600. bytes for the enumerator if DUPS_ALLOWED was specified when the index file was 
  10601. created.  This high-values object is used in the REINDEX_XB routine, and also 
  10602. the LAST_KEY_XB and GET_LAST_XB routines. 
  10603.  
  10604.  
  10605. ΓòÉΓòÉΓòÉ 13.7. Custom Build-Key ΓòÉΓòÉΓòÉ
  10606.  
  10607. Bullet provides an internal build-key routine that constructs the key from the 
  10608. data record supplied.  The internal routine can be overloaded by your custom 
  10609. build-key routine if you need additional functionality.  It may be used in 
  10610. conjunction with a custom sort-compare function, or an intrinsic Bullet 
  10611. sort-compare. 
  10612.  
  10613. Developing a custom build-key routine requires delving into the internal Bullet 
  10614. data structures.  It is more complicated than a custom sort-compare function, 
  10615. but not really any more complex.  The handle of the index file is passed, and 
  10616. using this, STAT_INDEX_XB is called to get the SIP.herePtr pointer.  This is 
  10617. the pointer to the internal Bullet data structure for this index file.  What 
  10618. needs to be accessed in this structure is the translated key expression.  From 
  10619. this, you have the starting offset in the data record, and the byte count to 
  10620. use, for each key component (up to 16 components per key).  The offset value as 
  10621. stored in the XLATEX structure does not include the tag field byte.  Therefore, 
  10622. to locate to the correct offset, add 1 to the value in offset.  For example, 
  10623. XLATEX.offset=0 means to use the first field, which is the first byte after the 
  10624. tag field byte, but the physical offset, as referenced to recPtr, is not at 
  10625. offset=0, but is at offset=1. 
  10626.  
  10627. This translated key expression structure is: 
  10628.  
  10629. // (This is an excerpt from the IX3 header format)
  10630.  
  10631. // Translated key expression as done by Parser during CreateIndex and Reindex.
  10632. // More details on this is in the Custom Expression Parser Specifications.
  10633. // For each key part in KH.expression a 4-byte structure is used:
  10634.  
  10635. typedef struct _XLATEX {
  10636.  CHAR  ftype;   // field type (C,N,L, etc.),if bit7=1 and C then do UPPER key
  10637.  CHAR  length;  // bytes to use starting at offset (never > 64)
  10638.  SHORT offset;  // byte offset into data record that length bytes are to be used
  10639. } XLATEX;       // (note that offset does not count tag field byte)
  10640.  
  10641. ULONG xlateCount;           // 044 number of key fields (64/4=16 max fields)
  10642. XLATEX xlateExpression[16]; // 048 key construct info (16 dword's worth)
  10643.  
  10644. xlateExpression is at offset +48 relative the IX3 index header.  However, 
  10645. SIP.herePtr points to -384 relative the IX3 index header start.  Therefore, to 
  10646. locate to xlateExpression, you must add 384 to 48.  This means that 
  10647. xlateExpression[0].ftype is located at SIP.herePtr+432.  The number of valid 
  10648. key components in xlateExpression is stored in xlateCount (at SIP.herePtr+428). 
  10649.  
  10650. The calling convention for your custom build-key function is APIENTRY (or 
  10651. _System, or __syscall for some compilers), and the parameters are passed to 
  10652. your function on the stack (by Bullet).  A sample prototype for a build-key 
  10653. function follows: 
  10654.  
  10655. ULONG APIENTRY YourBuildKey(ULONG handle,
  10656.                             PVOID recordPtr,
  10657.                             PVOID keyPtr,
  10658.                             PULONG keyLenPtr
  10659.                             PULONG sortFuncPtr);
  10660.  
  10661. Using the data from xlateExpression, you are to build a key from the data 
  10662. record located at the passed pointer, recordPtr, and are store the built key in 
  10663. the buffer located at keyPtr.  For each key component, you copy from the data 
  10664. record xlateExpression[].length bytes starting at xlateExpression[].offset+1 
  10665. (given the 1-byte tag field which is not accounted for otherwise), and build 
  10666. other key components after previously build parts.  If the index file allows 
  10667. duplicate keys (DUPS_ALLOWED is flagged in SIP.sortFunction), then append an 
  10668. enumerator to the end of the key proper.  The handle of the index file is 
  10669. passed, which is used when calling STAT_INDEX_XB (to get SIP.herePtr).  The 
  10670. return is 0 if successful, or an appropriate Bullet error code (EXB_) should be 
  10671. used.  In addition, the key length is placed in the ULONG data pointed to by 
  10672. keyLenPtr (SIP.keyLength may be used), and the sort-compare function is placed 
  10673. in the ULONG data pointed to by sortFuncPtr (SIP.sortFunction may be used). 
  10674.  
  10675. The routine is also to check if the tag field of the data record matches the 
  10676. skip-tag value, as set by SET_SYSVARS_XB.  If the tag field matches, 
  10677. WRN_SKIP_KEY is to be returned as the 'error' code.  The key is built 
  10678. regardless of a match. 
  10679.  
  10680.  
  10681. ΓòÉΓòÉΓòÉ 13.8. Custom Expression Parser ΓòÉΓòÉΓòÉ
  10682.  
  10683. Bullet provides an internal key expression parser routine that constructs the 
  10684. translated key expression stored in the index file header.  The internal 
  10685. routine can be overloaded by your custom expression parser routine if you need 
  10686. additional functionality.  It may be used in conjunction with a custom 
  10687. sort-compare function, with a custom build-key routine, or with an intrinsic 
  10688. Bullet sort-compare. 
  10689.  
  10690. Developing a custom expression parser routine requires delving into the 
  10691. internal Bullet data structures.  It is more complicated than a custom 
  10692. sort-compare function, and it is also much more complex.  Unlike the custom 
  10693. sort-compare and build-key functions, no handle is passed to the parser.  This 
  10694. is because, rather than using the handle to get the SIP.herePtr, this pointer 
  10695. is passed directly to this routine.  This is the pointer to the internal Bullet 
  10696. data structure for this index file.  What needs to be accessed in this 
  10697. structure is the translated key expression location, as well as the text 
  10698. version of the key expression, as supplied by the programmer/user.  To the 
  10699. XLATEX data you place the starting offset in the data record, and the byte 
  10700. count to use, for each key component you parse from the key expression (up to 
  10701. 16 components per key).  The offset value as stored in the XLATEX structure 
  10702. does not include the tag field byte.  Therefore, the correct offset to store is 
  10703. the physical offset within the record, minus 1.  For example, XLATEX.offset=0 
  10704. should be used for the offset of the first field, which is the first byte after 
  10705. the tag field byte.  For each component parsed, an XLATEX data structure is 
  10706. added to the xlateExpression data area (up to 16).  Unused XLATEX components 
  10707. must be set to 0.  When all components have been stored, the xlateCount value 
  10708. is set to the number of key components stored. 
  10709.  
  10710. DHDptr is the data header pointer.  It is -352 bytes relative the DBF data 
  10711. header.  However, rather than using absolute addressing to locate field 
  10712. descriptor data (needed for parsing), it's recommended that the DBF handle be 
  10713. obtained from the KHptr structure.  Since no file handles are passed, you must 
  10714. read the xbLink handle value from the index file header.  The xbLink handle is 
  10715. stored at KHptr+12.  With this handle, you call the GET_DESCRIPTOR_XB routine 
  10716. to obtain field descriptor info for each field. 
  10717.  
  10718. This translated key expression structure, and text expression location, is at: 
  10719.  
  10720. // (This is an excerpt from the IX3 header format)
  10721.  
  10722. // Translated key expression as done by Parser during CreateIndex and Reindex.
  10723. // For each key part in KH.expression a 4-byte structure is used:
  10724.  
  10725. typedef struct _XLATEX {
  10726.  CHAR  ftype;   // field type (C,N,L, etc.),if bit7=1 and C then do UPPER key
  10727.  CHAR  length;  // bytes to use starting at offset (never > 64)
  10728.  SHORT offset;  // byte offset into data record that length bytes are to be used
  10729. } XLATEX;       // (note that offset does not count tag field byte)
  10730.  
  10731. ULONG xlateCount;           // 044 number of key fields (64/4=16 max fields)
  10732. XLATEX xlateExpression[16]; // 048 key construct info (16 dword's worth)
  10733.       :                     // 112-347   :
  10734. CHAR  expression[160];      // 348 key expression, user (0-Terminated)
  10735.  
  10736. xlateExpression is at offset +48 relative the IX3 index header.  However, 
  10737. KHptr, passed to this routine, points to -384 relative the IX3 index header 
  10738. start.  Therefore, to locate to xlateExpression, you must add 384 to 48.  This 
  10739. means that xlateExpression[0].ftype is located at KHptr+432.  The number of 
  10740. valid key components in xlateExpression is stored in xlateCount (at KHptr+428). 
  10741. To text key expression string, which you are to parse, is located at KHptr+732. 
  10742. This is identical to the expression passed during CREATE_INDEX_XB (and it is 
  10743. CREATE_INDEX_XB that calls this parser routine). 
  10744.  
  10745. The calling convention for your custom key expression parser function is 
  10746. APIENTRY (or _System, or __syscall for some compilers), and the parameters are 
  10747. passed to your function on the stack (by Bullet).  A sample prototype for a 
  10748. build-key function follows: 
  10749.  
  10750. ULONG APIENTRY YourKeyExpressionParser(PVOID DHDptr,
  10751.                                        PVOID KHptr,
  10752.                                        PULONG keyLenPtr);
  10753.  
  10754. You are to parse the text key expression at KHptr+732 and store the key 
  10755. component XLATEX structure values to the XLATEX structure, one for each key 
  10756. component parsed.  In addition, the key length (the sum of the XLATEX.length 
  10757. fields) is placed in the ULONG data pointed to by keyLenPtr.  The keylength may 
  10758. not exceed 64 bytes.  If DUPS_ALLOWED is flagged, add two to the sum of the 
  10759. XLATEX.length fields for the enumerator word. 
  10760.  
  10761. Note:  The key expression has been mapped to upper-case and 0-filled by the 
  10762. time this routine is called. 
  10763.  
  10764. This is probably the most difficult part of customizing Bullet.  However, the 
  10765. difficulty lies not with Bullet, but how you parse.  The idea is simple -- you 
  10766. are to generate a xlateCount value, and for each key component (ie 
  10767. non-contiguous, non-same-type run in the data record), an XLATEX variable 
  10768. describing the method to build that key component out of the data record (type, 
  10769. length, and starting offset) is stored.  The text key expression is available 
  10770. in the index header, and the destination to write to is there, also.  You do 
  10771. need to read the index header at KHptr+12 (ULONG) to obtain the DBF handle for 
  10772. this index file before you can parse the expression.  This because you need to 
  10773. know about the record field names, types, and lengths before you can parse the 
  10774. key expression.  The matter not covered here is that of parsing the expression, 
  10775. which is left to the programmer.  Any lexical parser algorithm may be used, or 
  10776. you may even do no parsing at all, and simply hard-code values into the XLATEX 
  10777. structures. 
  10778.  
  10779. If you've gotten this far, you may find the following data structures useful. 
  10780. The numbers at // nnn are offsets relative the SIP.herePtr and SDP.herePtr 
  10781. pointers.  For example, at SIP.herePtr+352 is a ULONG of the number of key 
  10782. searches requested.  These could be monitored in a separate thread. 
  10783.  
  10784. Relative SIP.herePtr: 
  10785.  
  10786. ULONG fType;            // 000 bit0=0 for index file, btree
  10787. ULONG flags;            // 004 bit0=1 is dirty
  10788.                         //     bit1=1 full lock (count stored in KH.lockCount)
  10789.                         //     bit2=1 shared lock (if bit1=1)
  10790.                         //     bit3-14 reserved (=0)
  10791.                         //     bit15=1 no coalesce on key delete
  10792.                         // 006 BYTE, progress of reindex (0,1-99)
  10793.                         // 007 BYTE
  10794. PVOID morePtr;          // 008 ptr to additional header info, if ever needed
  10795. ULONG xbLink;           // 012 related XB data file handle
  10796. ULONG asMode;           // 016 access-sharing-cache mode of open
  10797. CHAR  filename[260];    // 020 filename at open (0T)
  10798. ULONG currKeyRecNo;     // 280 current rec number assigned to KH.currKey
  10799. CHAR  currKey[64];      // 284 current key value
  10800. ULONG rez0;             // 348 allow for 0-terminated string
  10801. ULONG searches;         // 352 keys searched for
  10802. ULONG seeks;            // 356 nodes seeked
  10803. ULONG hits;             // 360 seeks satisfied without disk access
  10804. ULONG keysDeleted;      // 364 keys deleted since last zeroed
  10805. ULONG keysStored;       // 368 keys added since last zeroed
  10806. ULONG nodesSplit;       // 372 splits needed on insert since last zeroed
  10807. ULONG nodesMadeAvail;   // 376 nodes made available from deleting keys
  10808. ULONG lockCount;        // 380 active full-lock count
  10809.  
  10810. // the IX3 index header follows at 384+
  10811.  
  10812. Relative SDP.herePtr: 
  10813.  
  10814. ULONG fType;            // 000 bit0=1 for DBF data file, XB
  10815. ULONG flags;            // 004 bit0=1 is dirty
  10816.                         //     bit1=1 full lock
  10817.                         //     bit2=1 shared lock (if bit1=1)
  10818.                         //     bit3-15 reserved (=0)
  10819.                         // 006 BYTE, progress of pack (0,1-99)
  10820.                         // 007 BYTE, 0
  10821. PVOID morePtr;          // 008 ptr to additional header info, if ever needed
  10822. ULONG noFields;         // 012 number of fields in this data file
  10823. ULONG asMode;           // 016 access-sharing-cache mode of open
  10824. CHAR  filename[260];    // 020 filename at open (0T)
  10825. ULONG lockCount;        // 280 only when dec'ed to 0 do full unlock
  10826. ULONG memoAvailBlock;   // 284 next available block (header is block 0)
  10827. ULONG memoUnk1;         // 288 not used
  10828. CHAR  memoFilename[8];  // 292 filename proper (first 8 of filename proper)
  10829. ULONG memoUnk2;         // 300 not used (apparently)
  10830. ULONG memoBlockSize;    // 304 block size, must be at least 24 to cover header!
  10831. ULONG memoHandle;       // 308 handle of open memo file
  10832. ULONG memoFlags;        // 312 bit0=1 is dirty
  10833. ULONG memoLastNo;       // 316 last accessed memo number (if not 0)
  10834. ULONG memoLastLink;     // 320 link data for last accessed memo
  10835. ULONG memoLastSize;     // 324 size of last accessed memo (in bytes, w/OH)
  10836. ULONG align32[6];       // 328 (align to even32)
  10837.  
  10838. // the DBF data header follows at +352
  10839.  
  10840.  
  10841. ΓòÉΓòÉΓòÉ 14. Bullet Is... ΓòÉΓòÉΓòÉ
  10842.  
  10843. Bullet/2 is a thread-safe, multi-process capable database engine toolkit for 
  10844. OS/2.  It provides pre-built and tested access methods to data and index files 
  10845. for application programmers.  It is not an end-user Database Management System 
  10846. (DBMS), but it is a tool that could be used to develop one.  Bullet is compact, 
  10847. efficient, and very fast.  It can be configured to use custom key-build, 
  10848. sort-compare functions, and expression parser routines to extend the built-in 
  10849. functionality.  Rules are few; possibilities are great. 
  10850.  
  10851. The standard data format is DBF (dBASE 3+ and later).  The supported memo 
  10852. format is DBT (dBASE 4 and later).  Index-only support can be enabled and with 
  10853. this any data file format may be used (the data maintained by the programmer 
  10854. then).  Also, the DBF standard may be extended by using binary field values and 
  10855. fields larger than 255 bytes.  Index files are NLS-compatible and use an 
  10856. efficient b-tree structure.  Files may be any size supported by the OS, up to 
  10857. 4GB.  Up to 1024 files may be opened and in use by any one process, with any 
  10858. number of processes active. 
  10859.  
  10860. The Bullet API consists of a wide assortment of routines, from low-level OS 
  10861. calls to high-level transaction-list routines that can process hundreds of 
  10862. files per transaction, with roll-back on error.  Network and multi-user support 
  10863. is included, and makes use of operating system features such as atomic 
  10864. re-locking, and shared locks that allow other processes read-access to locked 
  10865. files. 
  10866.  
  10867. Bullet is simple to use, and may easily be modified by using function wrappers 
  10868. around groups of related Bullet routines.  If you don't like working with the 
  10869. parameter packs, use a wrapper and call as you like.  Bullet works the way you 
  10870. are used to working. 
  10871.  
  10872. This online manual is a complete introduction and programmer reference for 
  10873. Bullet/2.  Sample code is included, with more still on disk.  Use Bullet to 
  10874. make a mint, or at least that database program that OS/2 users are looking for. 
  10875. I'd like to, but then I wouldn't be selling Bullet to you if I were. 
  10876.  
  10877.  
  10878. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  10879.  
  10880. A foreign key is a column value in one table used as a primary key in a second 
  10881. table.  For example, if one table has two fields:  employee name (primary key) 
  10882. and department code, and a second table has two fields:  department code 
  10883. (primary key) and department name, then department code in the first table is 
  10884. considered a foreign key, since it may be used as the primary key value when 
  10885. searching the second table.  Joins and views make use of foreign keys. 
  10886.  
  10887.  
  10888. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  10889.  
  10890. Null pack
  10891.  
  10892.  
  10893. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  10894.  
  10895. typedef struct _ACCESSPACK {
  10896. ULONG func;
  10897. ULONG stat;
  10898. ULONG handle;         /* I, handle of Bullet file to access */
  10899. LONG  recNo;          /* IO, record number */
  10900. PVOID recPtr;         /* I, programmer's record buffer */
  10901. PVOID keyPtr;         /* I, programmer's key buffer */
  10902. PVOID nextPtr;        /* I, NULL if not xaction, else next AP in list */
  10903. } ACCESSPACK; /* AP */
  10904. typedef ACCESSPACK *PACCESSPACK;
  10905.  
  10906.  
  10907. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  10908.  
  10909. typedef struct _CALLBACKPACK {
  10910. ULONG sizeIs;         /* structure size (current 16 bytes) */
  10911. ULONG callMode;       /* 0=from reindex; 1=from DBF pack */
  10912. ULONG handle;         /* file handle */
  10913. ULONG data1;          /* for callMode=0/1: progress percent (1-99,0) */
  10914. } CALLBACKPACK; /* CBP */
  10915. typedef CALLBACKPACK *PCALLBACKPACK;
  10916.  
  10917.  
  10918. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  10919.  
  10920. typedef struct _COPYPACK {
  10921. ULONG func;
  10922. ULONG stat;
  10923. ULONG handle;         /* I, handle of Bullet file to copy */
  10924. PSZ   filenamePtr;    /* I, filename to use (drv:path must exist if used) */
  10925. } COPYPACK; /* CP */
  10926. typedef COPYPACK *PCOPYPACK;
  10927.  
  10928.  
  10929. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  10930.  
  10931. typedef struct _CREATEDATAPACK {
  10932. ULONG func;
  10933. ULONG stat;
  10934. PSZ   filenamePtr;    /* I, filename to use */
  10935. ULONG noFields;       /* I, 1 to 254 */
  10936. PFIELDDESCTYPE fieldListPtr;   /* I, descriptor list, 1 per field */
  10937. ULONG fileID;         /* I, 0x03 for std DBF, 0x8B for DBF+DBT */
  10938. } CREATEDATAPACK; /* CDP */
  10939. typedef CREATEDATAPACK *PCREATEDATAPACK;
  10940.  
  10941.  
  10942. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  10943.  
  10944. typedef struct _CREATEINDEXPACK {
  10945. ULONG func;
  10946. ULONG stat;
  10947. PSZ   filenamePtr;    /* I, filename to use */
  10948. PSZ   keyExpPtr;      /* I, e.g., "SUBSTR(LNAME,1,4)+SSN" */
  10949. LONG  xbLink;         /* I, opened data file handle this indexes */
  10950. ULONG sortFunction;   /* I, 1-9 system, 10-19 custom */
  10951. ULONG codePage;       /* I, 0=use process default */
  10952. ULONG countryCode;    /* I, 0=use process default */
  10953. PVOID collatePtr;     /* I, NULL=use cc/cp else use passed table for sort */
  10954. ULONG nodeSize;       /* I, 512, 1024, or 2048 */
  10955. } CREATEINDEXPACK; /* CIP */
  10956. typedef CREATEINDEXPACK *PCREATEINDEXPACK;
  10957.  
  10958.  
  10959. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  10960.  
  10961. typedef struct _FIELDDESCTYPE {
  10962. BYTE  fieldName[11];  /* IO, upper A-Z and _; 1-10 chars, 0-filled, 0-term */
  10963. BYTE  fieldType;      /* IO, C,D,L,N, or M */
  10964. LONG  fieldDA;        /* x, offset within record (run-time storage option) */
  10965. BYTE  fieldLen;       /* IO, C=1-255,D=8,L=1,N=1-19,M=10 */
  10966. BYTE  fieldDC;        /* IO, fieldType=N then 0-15 else 0 */
  10967. USHORT altFieldLength;/* IO, 0 */
  10968. BYTE  filler[12];     /* I, 0 */
  10969. } FIELDDESCTYPE; /* nested in DESCRIPTORPACK */
  10970. typedef FIELDDESCTYPE *PFIELDDESCTYPE;
  10971.  
  10972.  
  10973. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  10974.  
  10975. typedef struct _DESCRIPTORPACK {
  10976. ULONG func;
  10977. ULONG stat;
  10978. ULONG handle;         /* I, handle of DBF file */
  10979. ULONG fieldNumber;    /* IO, first field is 1 */
  10980. ULONG fieldOffset;    /* O, offset of field within record (delete tag=offset 0) */
  10981. FIELDDESCTYPE FD;  /* IO FD.fieldName, O rest of FD */
  10982. } DESCRIPTORPACK; /* DP */
  10983. typedef DESCRIPTORPACK *PDESCRIPTORPACK;
  10984. };
  10985.  
  10986.  
  10987. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  10988.  
  10989. typedef struct _DOSFILEPACK {
  10990. ULONG func;
  10991. ULONG stat;
  10992. PSZ   filenamePtr;    /* I, filename to use */
  10993. ULONG handle;         /* IO, handle of open file */
  10994. ULONG asMode;         /* I, access-sharing-cache mode */
  10995. ULONG bytes;          /* IO, bytes to read, write, length of */
  10996. LONG  seekTo;         /* IO, seek to offset, current offset */
  10997. ULONG method;         /* I, seek method (0=start of file, 1=current, 2=end) */
  10998. PVOID bufferPtr;      /* I, buffer to read into or write from */
  10999. ULONG attr;           /* I, attribute to create file with */
  11000. PSZ   newNamePtr;     /* I, name to use on rename */
  11001. } DOSFILEPACK; /* DFP */
  11002. typedef DOSFILEPACK *PDOSFILEPACK;
  11003.  
  11004.  
  11005. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  11006.  
  11007. typedef struct _EXITPACK {
  11008. ULONG func;
  11009. ULONG stat;
  11010. } EXITPACK; /* EP */
  11011. typedef EXITPACK *PEXITPACK;
  11012.  
  11013.  
  11014. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  11015.  
  11016. typedef struct _HANDLEPACK {
  11017. ULONG func;
  11018. ULONG stat;
  11019. ULONG handle;         /* I, handle of Bullet file */
  11020. } HANDLEPACK; /* HP */
  11021. typedef HANDLEPACK *PHANDLEPACK;
  11022.  
  11023.  
  11024. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  11025.  
  11026. typedef struct _INITPACK {
  11027. ULONG func;
  11028. ULONG stat;
  11029. ULONG JFTsize;        /* I, max opened files (20-1024+) */
  11030. ULONG versionDOS;     /* O, e.g., 230 for 2.30 */
  11031. ULONG versionBullet;  /* O, e.g., 2019 for 2.019 */
  11032. ULONG versionOS;      /* O, e.g., 4=OS/2 32-bit */
  11033. PVOID exitPtr;        /* O, function pointer to EXIT_XB routine */
  11034. } INITPACK; /* IP */
  11035. typedef INITPACK *PINITPACK;
  11036.  
  11037.  
  11038. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  11039.  
  11040. typedef struct _LOCKPACK {
  11041. ULONG func;
  11042. ULONG stat;
  11043. ULONG handle;         /* I, handle of Bullet file to lock */
  11044. ULONG xlMode;         /* I, index lock mode (0=exclusive, 1=shared) */
  11045. ULONG dlMode;         /* I, data lock mode (0=exclusive, 1=shared) */
  11046. LONG  recStart;       /* I, if data, first record # to lock, or 0 for all */
  11047. ULONG recCount;       /* I, if data and recStart!=0, # records to lock */
  11048. PVOID nextPtr;        /* I, NULL if not xaction, else next LP in list */
  11049. } LOCKPACK; /* LP */
  11050. typedef LOCKPACK *PLOCKPACK;
  11051.  
  11052.  
  11053. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  11054.  
  11055. typedef struct _MEMODATAPACK {
  11056. ULONG func;
  11057. ULONG stat;
  11058. ULONG dbfHandle;      /* I, handle of DBF file to which this memo file belongs */
  11059. ULONG memoBypass;     /* I, memo bypass function to do, if any */
  11060. PVOID memoPtr;        /* I, ptr to memo record buffer */
  11061. ULONG memoNo;         /* IO, memo record number (aka block number) */
  11062. ULONG memoOffset;     /* I, position within record to start read/update */
  11063. ULONG memoBytes;      /* IO, number of bytes to read/update */
  11064. } MEMODATAPACK; /* MDP */
  11065. typedef MEMODATAPACK *PMEMODATAPACK;
  11066.  
  11067.  
  11068. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  11069.  
  11070. typedef struct _MEMORYPACK {
  11071. ULONG func;
  11072. ULONG stat;
  11073. ULONG memory;         /* O, not used in OS/2 */
  11074. } MEMORYPACK; /* MP */
  11075. typedef MEMORYPACK *PMEMORYPACK;
  11076.  
  11077.  
  11078. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  11079.  
  11080. typedef struct _OPENPACK {
  11081. ULONG func;
  11082. ULONG stat;
  11083. ULONG handle;         /* O, handle of file opened */
  11084. PSZ   filenamePtr;    /* I, Bullet file to open */
  11085. ULONG asMode;         /* I, access-sharing-cache mode */
  11086. LONG  xbLink;         /* I, if index open, xbLink=handle of its opened DBF */
  11087. } OPENPACK; /* OP */
  11088. typedef OPENPACK *POPENPACK;
  11089.  
  11090.  
  11091. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  11092.  
  11093. typedef struct _QUERYSETPACK {
  11094. ULONG func;
  11095. ULONG stat;
  11096. ULONG item;           /* I, Bullet sysvar item to get/set */
  11097. ULONG itemValue;      /* IO, current/new value */
  11098. } QUERYSETPACK; /* QSP */
  11099. typedef QUERYSETPACK *PQUERYSETPACK;
  11100.  
  11101.  
  11102. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  11103.  
  11104. typedef struct _REMOTEPACK {
  11105. ULONG func;
  11106. ULONG stat;
  11107. ULONG handle;         /* I, handle of file, or if 0, use RP.drive */
  11108. ULONG drive;          /* I, drive (1=A,2=B,3=C,...0=current) to check */
  11109. ULONG isRemote;       /* O, =1 of handle/drive is remote, =0 if local */
  11110. ULONG flags;          /* O, 0 */
  11111. ULONG isShare;        /* O, 1 */
  11112. } REMOTEPACK; /* RP */
  11113. typedef REMOTEPACK *PREMOTEPACK;
  11114.  
  11115.  
  11116. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  11117.  
  11118. struct StatDataPack {
  11119. typedef struct _STATDATAPACK {
  11120. ULONG func;
  11121. ULONG stat;
  11122. ULONG handle;         /* I, handle to check */
  11123. ULONG fileType;       /* O, bit0=1 data file */
  11124. ULONG flags;          /* O, bit0=1 dirty, bit1=1 full-lock, bit2=1 shared */
  11125. ULONG progress;       /* O, 0,1-99% pack progress */
  11126. PVOID morePtr;        /* O, 0 */
  11127. ULONG fields;         /* O, fields per record */
  11128. ULONG asMode;         /* O, access-sharing-cache mode */
  11129. PSZ   filenamePtr;    /* O, filename used in open */
  11130. ULONG fileID;         /* O, first byte of DBF file */
  11131. ULONG lastUpdate;     /* O, high word=year,low byte=day, high byte=month */
  11132. ULONG records;        /* O, data records (including "deleted") */
  11133. ULONG recordLength;   /* O, record length */
  11134. ULONG xactionFlag;    /* O, 0 */
  11135. ULONG encryptFlag;    /* O, 0 */
  11136. PVOID herePtr;        /* O, this file's control address */
  11137. ULONG memoHandle;     /* O, handle of open memo file (0 if none) */
  11138. ULONG memoBlockSize;  /* O, memo file block size */
  11139. ULONG memoFlags;      /* O, bit0=1 dirty */
  11140. ULONG memoLastRecord; /* O, last accessed memo record (0 if none) */
  11141. ULONG memoLastSize;   /* O, size of last accessed memo record (in bytes, +8) */
  11142. ULONG lockCount;      /* O, number of full-locks in force */
  11143. } STATDATAPACK; /* SDP */
  11144. typedef STATDATAPACK *PSTATDATAPACK;
  11145.  
  11146.  
  11147. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  11148.  
  11149. typedef struct _STATHANDLEPACK {
  11150. ULONG func;
  11151. ULONG stat;
  11152. ULONG handle;         /* I, handle to check */
  11153. LONG  ID;             /* O, bit0=1 data file, bit0=1 index file */
  11154. } STATHANDLEPACK; /* SHP */
  11155. typedef STATHANDLEPACK *PSTATHANDLEPACK;
  11156.  
  11157.  
  11158. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  11159.  
  11160. typedef struct _STATINDEXPACK {
  11161. ULONG func;
  11162. ULONG stat;
  11163. ULONG handle;         /* I, handle to check */
  11164. ULONG fileType;       /* O, bit0=0 index file */
  11165. ULONG flags;          /* O, bit0=1 dirty, bit1=1 full-lock, bit2=1 shared */
  11166. ULONG progress;       /* O, 0,1-99% reindex progress */
  11167. PVOID morePtr;        /* O, 0 */
  11168. ULONG xbLink;         /* O, XB file link handle */
  11169. ULONG asMode;         /* O, access-sharing-cache mode */
  11170. PSZ   filenamePtr;    /* O, pointer to filename used in open */
  11171. ULONG fileID;         /* O, "31ch" */
  11172. PSZ   keyExpPtr;      /* O, pointer to key expression */
  11173. ULONG keys;           /* O, keys in file */
  11174. ULONG keyLength;      /* O, key length */
  11175. ULONG keyRecNo;       /* O, record number of current key */
  11176. PVOID keyPtr;         /* O, ptr to current key value (valid to keyLength) */
  11177. PVOID herePtr;        /* O, this file's control address */
  11178. ULONG codePage;       /* O, code page at create time */
  11179. ULONG countryCode;    /* O, country code at create time */
  11180. PVOID CTptr;          /* O, collate table ptr, NULL=no collate table present */
  11181. ULONG nodeSize;       /* O, node size */
  11182. ULONG sortFunction;   /* O, sort function ID */
  11183. ULONG lockCount;      /* O, number of full-locks in force */
  11184. } STATINDEXPACK; /* SIP */
  11185. typedef STATINDEXPACK *PSTATINDEXPACK;
  11186.  
  11187.  
  11188. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  11189.  
  11190. typedef struct _XERRORPACK {
  11191. ULONG func;
  11192. ULONG stat;           /* I, error to check */
  11193. ULONG errClass;       /* O, class of error */
  11194. ULONG action;         /* O, action recommended for error */
  11195. ULONG location;       /* O, location of error */
  11196. } XERRORPACK; /* XEP */
  11197. typedef XERRORPACK *PXERRORPACK;
  11198.  
  11199.  
  11200. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  11201.  
  11202.  Access-Mode (required)
  11203.   READONLY        0x00000000   read-only access open
  11204.   WRITEONLY       0x00000001   write-only access open
  11205.   READWRITE       0x00000002   read/write access open
  11206.  
  11207.  Share-Mode (required)
  11208.   DENYREADWRITE   0x00000010   no other process may share file
  11209.   DENYWRITE       0x00000020   no other process may share file for write
  11210.   DENYREAD        0x00000030   no other process may share file for read
  11211.   DENYNONE        0x00000040   any process may share file
  11212.  
  11213.  Inherit
  11214.   NOINHERIT       0x00000080   child process does not inherit file handles
  11215.  
  11216.  Cache
  11217.   NO_LOCALITY     0x00000000  locality is not known
  11218.   SEQ_LOCALITY    0x00010000  access will be mainly sequential
  11219.   RND_LOCALITY    0x00020000  access will be mainly random
  11220.   MIX_LOCALITY    0x00030000  access will be random with some sequential
  11221.   SKIP_CACHE      0x00100000  I/O is not to go through the cache
  11222.   WRITE_THROUGH   0x00400000  control returns only after disk is written to
  11223.  
  11224. Access- and Share-Mode values not explicitly listed are not valid.  The file 
  11225. access mode is a combination of ACCESS + SHARE + INHERIT + CACHE.  Typical data 
  11226. and index asMode is 0x00000042, though locality may be set accordingly (e.g., 
  11227. 0x00020042 for mostly random access to the file). 
  11228.  
  11229. The Cache mode options are valid for OPEN_DATA_XB and OPEN_INDEX_XB only; for 
  11230. DOS_FILE_OPEN, the Cache values must be right-shifted by 8.  The 'Skip Cache' 
  11231. and 'Write Through' options are not inherited. 
  11232.  
  11233.  
  11234. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  11235.  
  11236. The enumerator is a big-endian 16-bit value that serves to differentiate up to 
  11237. 65536 "identical", non- unique keys.  It is attached to all keys of 
  11238. DUPS_ALLOWED flagged index files (set at CREATE_INDEX_XB), and occupies the 
  11239. last two bytes of the key.  The first key of the type uses \0\0, the second 
  11240. uses \0\1, and so on.  This ordering of bytes is the reverse of x86 Intel 
  11241. words, which uses little-endian format. 
  11242.  
  11243.  
  11244. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  11245.  
  11246. HIGH-VALUES signify a sort order so that the value is the highest possible 
  11247. (sorts last).  HIGH-VALUES for a character key would be 0xFF for each byte, or 
  11248. the 256th byte of the collate-sequence table if an NLS sort (which is 0xFF 
  11249. also).  For 16-bit signed integer values, 0x7FFF is the highest.  And so on...