home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / DBMANP.ZIP / DBMANIP.TXT < prev   
Text File  |  1992-07-13  |  8KB  |  257 lines

  1. DBMANIP Dbase3 functions brought to you by WalkerWerks, Memphis, Tn.
  2.  
  3. Files
  4.     DBMANIP.C        functions for manipulating DB3 files
  5.     DBMANIP.H        function declerations and global variables
  6.     DBERR.H         The defines for the database errors
  7.     DBINC.H         The header file for use by programs using the DLL.
  8.     DBMANIP.DEF     Definition file for OS/2
  9.     DBMANIP.MAK     Microsoft C 6.0 make file
  10.     DBMANIP.LIB     Import library for DLL to link with programs using DLL
  11.     DBMANIP.DLL     DLL library containing DBMANIP functions
  12.  
  13. DBMANIP is a set of basic functions for manipulating DBase3 or 3+ files.
  14. No index functions are included.  The code is released to the Public
  15. Domain as is.  The Author takes no responsibility for its use or any
  16. damages resulting from the original or altered copies of the routines.
  17. I only ask that if you add functions you provide a copy to me and the
  18. public domain to provide access to DB3 files from OS/2.  Please message
  19. Compuserve 70304,2705 with suggestions or changes that might help us
  20. all.
  21.  
  22. All functions use OS/2 2.x procedures.  All OS/2
  23. specific functions are isolated in subroutines at the end of the file
  24. for ease in porting.
  25.  
  26. The functions are basic.  Several improvements could be used such as
  27. handling the various date types.  Currently only MM/DD/YYYY format is
  28. supported.  In addition numeric fields could be improved to convert from
  29. Numerics to text data and the reverse when retrieving fields.  The functions
  30. could also use better error trapping when manipulating the passed data
  31. strings.
  32.  
  33.  
  34. LINKING Note
  35.     The DLL has several global variables for managing the databases.
  36.     Because of this the DLL is initialized instanced.  Everything is
  37.     included except the project file for compiling and linking with
  38.     C set/2.
  39.  
  40.  
  41. FUNCTIONS
  42.  
  43. SHORT EXPENTRY DbCreate(CHAR *file, SHORT fldcount, FLDDATA *info)
  44.  
  45. Creates an empty DBase 3 database, even if one of the same name currently
  46. exists.
  47.  
  48. file    A NULL terminated string of the database name.    If no extension
  49.         is given .DBF is appended.
  50.  
  51. fldcount    The number of fields for the database.
  52.  
  53. info    A pointer to an array of fldcount structures of type FLDDATA.
  54.         These must contain the information about the field.
  55.  
  56. Returns 0 if successful or an errorcode if not.
  57.  
  58. This function does not open the created database.
  59.  
  60.  
  61.  
  62. SHORT EXPENTRY DbOpen(CHAR *file, SHORT readwrite)
  63.  
  64. Opens the requested database.
  65.  
  66. file    A null terminated string of the database name.    If no extension
  67.         is given .DBF is appended.
  68.  
  69. readwrite    SHORT value of access authority 0 is readonly, nonzero is
  70.             readwrite priveledges.
  71.  
  72. Returns Non negative value is the handle for the selected database.
  73.         Negative value is an error code.
  74.  
  75.  
  76. SHORT EXPENTRY DbClose(SHORT dbhndl)
  77.  
  78. Closes the indicated database.
  79.  
  80. dbhndl    The handle returned by DbOpen
  81.  
  82. Returns 0 = Success  Non Zero is an error code.
  83.  
  84.  
  85.  
  86. SHORT EXPENTRY DbInfo(SHORT hndl, DBREPORT *info)
  87.  
  88. Provides header information about the indicated database.
  89.  
  90. hndl    The handle returned by DbOpen
  91.  
  92. info    A pointer to a structure of the type DBREPORT
  93.  
  94. Returns 0 = SUCCESS  Nonzero error code
  95.  
  96.  
  97. SHORT EXPENTRY FldInfo(SHORT hndl, SHORT fldnum, FLDDATA FAR *fldinfo)
  98.  
  99. Returns information about the selected field within the indicated
  100. database.
  101.  
  102. hndl    The database handle
  103. fldnum    The field to report about.    Fields are zero based.
  104. fldinfo A pointer to a structure of type FLDDATA for returning the
  105.         information.
  106.  
  107. Returns 0 for Success or an Error code.
  108.  
  109.  
  110. SHORT EXPENTRY AddRec(SHORT dbhndl, CHAR *recdata,
  111.                       LONG *recnum, SHORT lockstatus)
  112.  
  113. Adds a new record to the database.    Additionally can lock the new record
  114. upon return.  The number of the new record is returned in recnum.
  115.  
  116. dbhndl    The database handle
  117.  
  118. recdata A pointer to the new record.  This must be properly formatted in
  119.         Dbase3's record layout.  If this is set to NULL a new blank record
  120.         will be appended to the file.
  121.  
  122. recnum    Pointer to a LONG for returning the record number of the new record
  123.  
  124. lockstatus    0 do not lock the record on return, 1 lock the record on return.
  125.             If you lock the record you must unlock it before other processes
  126.             can access the record.
  127.  
  128. Returns     0 for success or an error code
  129.  
  130.  
  131. SHORT EXPENTRY PutRec(SHORT dbhndl, CHAR *recdata, LONG recnum)
  132.  
  133. Replaces an existing record with the record data pointed to by recdata.
  134.  
  135. dbhndl        the handle of the database
  136.  
  137. recdata     A pointer to the Dbase3 record.
  138.  
  139. recnum        The record number to update.
  140.  
  141. Returns     0 for success or an error code
  142.  
  143.  
  144. SHORT EXPENTRY GetRec(SHORT dbhndl, CHAR *recdata, LONG recnum)
  145.  
  146. Retrieves the requested record and copies it into the buffer pointed
  147. to by recdata.
  148.  
  149. dbhndl        The handle of the database.
  150.  
  151. recdata     The buffer for the record.    You must insure that it is
  152.             sufficiently large, no overflow checking is done by the
  153.             routine.
  154.  
  155. recnum        The record to retrieve
  156.  
  157. Returns     0 for success or an error code
  158.  
  159.  
  160. SHORT EXPENTRY DeleteRec(SHORT dbhndl, LONG recnum)
  161.  
  162. Deletes the selected record.  Records are not actually deleted in DBase
  163. files, the first byte is set to an asterisk (*).
  164.  
  165. dbhndl    The database handle
  166.  
  167. recnum    The record number to delete
  168.  
  169. Returns     0 for success or an error code
  170.  
  171.  
  172. SHORT EXPENTRY RecoverRec(SHORT dbhndl, LONG recnum)
  173.  
  174. Unmarks the selected record as deleted.
  175.  
  176. dbhndl    The database handle
  177.  
  178. recnum    The record number to activate
  179.  
  180. Returns     0 for success or an error code
  181.  
  182.  
  183. SHORT EXPENTRY CheckRec(SHORT dbhndl, LONG recnum)
  184.  
  185. Checks the selected record to see if it is marked as active or
  186. deleted.
  187.  
  188. dbhndl    The database handle
  189.  
  190. recnum    The record number to activate
  191.  
  192. Returns     0 if the record is inactive, 1 if active, or a negative
  193.             value error code.
  194.  
  195.  
  196. SHORT EXPENTRY LockRec(SHORT dbhndl, LONG recnum)
  197.  
  198. Locks the selected record so that other processes cannot read or write
  199. to the record.    This is commonly used when updating a record so that
  200. multiple processes will not alter the data and get the changes out of
  201. sinc.
  202.  
  203. dbhndl    the database handle
  204.  
  205. recnum    The record number
  206.  
  207. Returns     0 for success or an error code
  208.  
  209.  
  210. SHORT EXPENTRY UnLockRec(SHORT dbhndl, LONG recnum)
  211.  
  212. Unlocks a record so that other processes can read and write to the
  213. record.
  214.  
  215. dbhndl    The database handle
  216.  
  217. recnum    The record number
  218.  
  219. Returns     0 for success or an error code
  220.  
  221.  
  222. SHORT EXPENTRY GetField(SHORT dbhndl, LONG recnum, CHAR *buff, SHORT fldnm)
  223.  
  224. Retrieves the specified field from the selected record.  Returns the
  225. field in the buffer pointed to by buff.  You must ensure that the
  226. buffer is sufficient to contain the record.  All data is left justified
  227. and any trailing spaces are removed.  All dates are returned in the
  228. format MM/DD/YYYY.
  229.  
  230. dbhndl    The database handle
  231.  
  232. recnum    The record number
  233.  
  234. buff    The buffer for the field contents
  235.  
  236. fldnum    The field number, Fields are zero based
  237.  
  238. Returns     0 for success or an error code.
  239.  
  240.  
  241. SHORT EXPENTRY PutField(SHORT dbhndl, LONG recnum, CHAR *buff, SHORT fldnm)
  242.  
  243. Puts the data in buff into the proper format and writes it into the
  244. field specified.  All numbers are right justified and space padded.
  245. Dates MUST be in the format MM/DD/YY or MM/DD/YYYY.  If the former date
  246. format is used the century will be set to 1900.  All data is text data.
  247.  
  248. dbhndl    The database handle
  249.  
  250. recnum    The record number
  251.  
  252. buff    A null terminated string of the data to place in the selected field.
  253.  
  254. fldnm    The field number to update.
  255.  
  256. Returns     0 for success or an error code.
  257.