home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / rcs / sources / gdbm.h < prev    next >
C/C++ Source or Header  |  1991-05-23  |  3KB  |  97 lines

  1. /* gdbm.h  -  The include file for dbm users.  */
  2.  
  3. /*  This file is part of GDBM, the GNU data base manager, by Philip A. Nelson.
  4.     Copyright (C) 1990, 1991  Free Software Foundation, Inc.
  5.  
  6.     GDBM is free software; you can redistribute it and/or modify
  7.     it under the terms of the GNU General Public License as published by
  8.     the Free Software Foundation; either version 1, or (at your option)
  9.     any later version.
  10.  
  11.     GDBM is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.     GNU General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU General Public License
  17.     along with GDBM; see the file COPYING.  If not, write to
  18.     the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  
  20.     You may contact the author by:
  21.        e-mail:  phil@cs.wwu.edu
  22.       us-mail:  Philip A. Nelson
  23.                 Computer Science Department
  24.                 Western Washington University
  25.                 Bellingham, WA 98226
  26.         phone:  (206) 676-3035
  27.  
  28. *************************************************************************/
  29.  
  30. /* Parameters to gdbm_open for READERS, WRITERS, and WRITERS who
  31.    can create the database. */
  32. #define  GDBM_READER  0        /* A reader. */
  33. #define  GDBM_WRITER  1        /* A writer. */
  34. #define  GDBM_WRCREAT 2        /* A writer.  Create the db if needed. */
  35. #define  GDBM_NEWDB   3        /* A writer.  Always create a new db. */
  36.  
  37. /* Parameters to gdbm_store for simple insertion or replacement in the
  38.    case that the key is already in the database. */
  39. #define  GDBM_INSERT  0        /* Never replace old data with new. */
  40. #define  GDBM_REPLACE 1        /* Always replace old data with new. */
  41.  
  42.  
  43. /* The data and key structure.  This structure is defined for compatibility. */
  44. typedef struct {
  45.     char *dptr;
  46.     int   dsize;
  47.       } datum;
  48.  
  49.  
  50. /* The file information header. This is good enough for most applications. */
  51. typedef struct {int dummy[10];} *GDBM_FILE;
  52.  
  53.  
  54. /* These are the routines! */
  55.  
  56. #ifdef __STDC__
  57. extern GDBM_FILE gdbm_open (char *, int, int, int, void (*) ());
  58. extern void     gdbm_close (gdbm_file_info *);
  59. extern datum     gdbm_fetch (gdbm_file_info *, datum);
  60. extern int     gdbm_store (gdbm_file_info *, datum, datum, int);
  61. extern int     gdbm_delete (gdbm_file_info *, datum);
  62. extern datum     gdbm_firstkey (gdbm_file_info *);
  63. extern datum     gdbm_nextkey (gdbm_file_info *, datum);
  64. extern int     gdbm_reorganize (gdbm_file_info *);
  65. #else
  66. extern GDBM_FILE gdbm_open ();
  67. extern void     gdbm_close ();
  68. extern datum     gdbm_fetch ();
  69. extern int     gdbm_store ();
  70. extern int     gdbm_delete ();
  71. extern datum     gdbm_firstkey ();
  72. extern datum     gdbm_nextkey ();
  73. extern int     gdbm_reorganize ();
  74. #endif
  75.  
  76. /* gdbm sends back the following error codes in the variable gdbm_errno. */
  77. typedef enum {    GDBM_NO_ERROR,
  78.         GDBM_MALLOC_ERROR,
  79.         GDBM_BLOCK_SIZE_ERROR,
  80.         GDBM_FILE_OPEN_ERROR,
  81.         GDBM_FILE_WRITE_ERROR,
  82.         GDBM_FILE_SEEK_ERROR,
  83.         GDBM_FILE_READ_ERROR,
  84.         GDBM_BAD_MAGIC_NUMBER,
  85.         GDBM_EMPTY_DATABASE,
  86.         GDBM_CANT_BE_READER,
  87.             GDBM_CANT_BE_WRITER,
  88.         GDBM_READER_CANT_DELETE,
  89.         GDBM_READER_CANT_STORE,
  90.         GDBM_READER_CANT_REORGANIZE,
  91.         GDBM_UNKNOWN_UPDATE,
  92.         GDBM_ITEM_NOT_FOUND,
  93.         GDBM_REORGANIZE_FAILED,
  94.         GDBM_CANNOT_REPLACE,
  95.         GDBM_ILLEGAL_DATA}
  96.     gdbm_error;
  97.