home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume33 / problem / part02 / gdbm.h-proto next >
Encoding:
Text File  |  1992-10-19  |  3.2 KB  |  96 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. #ifndef __GDBM_H
  31. #define __GDBM_H
  32.  
  33. /* Parameters to gdbm_open for READERS, WRITERS, and WRITERS who
  34.    can create the database. */
  35. #define  GDBM_READER  0        /* A reader. */
  36. #define  GDBM_WRITER  1        /* A writer. */
  37. #define  GDBM_WRCREAT 2        /* A writer.  Create the db if needed. */
  38. #define  GDBM_NEWDB   3        /* A writer.  Always create a new db. */
  39.  
  40. /* Parameters to gdbm_store for simple insertion or replacement in the
  41.    case that the key is already in the database. */
  42. #define  GDBM_INSERT  0        /* Never replace old data with new. */
  43. #define  GDBM_REPLACE 1        /* Always replace old data with new. */
  44.  
  45.  
  46. /* The data and key structure.  This structure is defined for compatibility. */
  47. typedef struct {
  48.     char *dptr;
  49.     int   dsize;
  50. } datum;
  51.  
  52. /* The file information header. This is good enough for most applications. */
  53. typedef struct {int dummy[10];} *GDBM_FILE;
  54.  
  55. #if __STDC__ == 1 || __cplusplus
  56. #define proto(x)  x
  57. #else
  58. #define proto(x) ()
  59. #endif
  60.  
  61. /* These are the routines! */
  62. extern GDBM_FILE gdbm_open proto((const char *, int, int, int, void (*)()));
  63. extern void     gdbm_close proto((GDBM_FILE));
  64. extern datum     gdbm_fetch proto((GDBM_FILE, datum));
  65. extern int     gdbm_store proto((GDBM_FILE, datum, datum, int));
  66. extern int     gdbm_delete proto((GDBM_FILE, datum));
  67. extern datum     gdbm_firstkey proto((GDBM_FILE));
  68. extern datum     gdbm_nextkey proto((GDBM_FILE, datum));
  69. extern int     gdbm_reorganize proto((GDBM_FILE));
  70.  
  71. #undef proto
  72.  
  73. /* gdbm sends back the following error codes in the variable gdbm_errno. */
  74. typedef enum {    GDBM_NO_ERROR,
  75.         GDBM_MALLOC_ERROR,
  76.         GDBM_BLOCK_SIZE_ERROR,
  77.         GDBM_FILE_OPEN_ERROR,
  78.         GDBM_FILE_WRITE_ERROR,
  79.         GDBM_FILE_SEEK_ERROR,
  80.         GDBM_FILE_READ_ERROR,
  81.         GDBM_BAD_MAGIC_NUMBER,
  82.         GDBM_EMPTY_DATABASE,
  83.         GDBM_CANT_BE_READER,
  84.             GDBM_CANT_BE_WRITER,
  85.         GDBM_READER_CANT_DELETE,
  86.         GDBM_READER_CANT_STORE,
  87.         GDBM_READER_CANT_REORGANIZE,
  88.         GDBM_UNKNOWN_UPDATE,
  89.         GDBM_ITEM_NOT_FOUND,
  90.         GDBM_REORGANIZE_FAILED,
  91.         GDBM_CANNOT_REPLACE,
  92.         GDBM_ILLEGAL_DATA}
  93.     gdbm_error;
  94.  
  95. #endif /*__GDBM_H*/
  96.