gdbm.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* gdbm.h - The include file for dbm users. */
  2. /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson.
  3. Copyright (C) 1990, 1991, 1993 Free Software Foundation, Inc.
  4. GDBM is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GDBM is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GDBM; see the file COPYING. If not, write to
  14. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  15. You may contact the author by:
  16. e-mail: phil@cs.wwu.edu
  17. us-mail: Philip A. Nelson
  18. Computer Science Department
  19. Western Washington University
  20. Bellingham, WA 98226
  21. *************************************************************************/
  22. /* Protection for multiple includes. */
  23. #ifndef _GDBM_H_
  24. #define _GDBM_H_
  25. /* Parameters to gdbm_open for READERS, WRITERS, and WRITERS who
  26. can create the database. */
  27. #define GDBM_READER 0 /* A reader. */
  28. #define GDBM_WRITER 1 /* A writer. */
  29. #define GDBM_WRCREAT 2 /* A writer. Create the db if needed. */
  30. #define GDBM_NEWDB 3 /* A writer. Always create a new db. */
  31. #define GDBM_FAST 0x10 /* Write fast! => No fsyncs. OBSOLETE. */
  32. #define GDBM_SYNC 0x20 /* Sync operations to the disk. */
  33. #define GDBM_NOLOCK 0x40 /* Don't do file locking operations. */
  34. /* Parameters to gdbm_store for simple insertion or replacement in the
  35. case that the key is already in the database. */
  36. #define GDBM_INSERT 0 /* Never replace old data with new. */
  37. #define GDBM_REPLACE 1 /* Always replace old data with new. */
  38. /* Parameters to gdbm_setopt, specifing the type of operation to perform. */
  39. #define GDBM_CACHESIZE 1 /* Set the cache size. */
  40. #define GDBM_FASTMODE 2 /* Toggle fast mode. OBSOLETE. */
  41. #define GDBM_SYNCMODE 3 /* Turn on or off sync operations. */
  42. #define GDBM_CENTFREE 4 /* Keep all free blocks in the header. */
  43. #define GDBM_COALESCEBLKS 5 /* Attempt to coalesce free blocks. */
  44. /* The data and key structure. This structure is defined for compatibility. */
  45. typedef struct {
  46. char *dptr;
  47. int dsize;
  48. } datum;
  49. /* The file information header. This is good enough for most applications. */
  50. typedef struct {int dummy[10];} *GDBM_FILE;
  51. /* Determine if the C(++) compiler requires complete function prototype */
  52. #ifndef __P
  53. #if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
  54. #define __P(x) x
  55. #else
  56. #define __P(x) ()
  57. #endif
  58. #endif
  59. /* External variable, the gdbm build release string. */
  60. extern char *gdbm_version;
  61. /* GDBM C++ support */
  62. #if defined(__cplusplus) || defined(c_plusplus)
  63. extern "C" {
  64. #endif
  65. /* These are the routines! */
  66. extern GDBM_FILE gdbm_open __P((char *, int, int, int, void (*)()));
  67. extern void gdbm_close __P((GDBM_FILE));
  68. extern int gdbm_store __P((GDBM_FILE, datum, datum, int));
  69. extern datum gdbm_fetch __P((GDBM_FILE, datum));
  70. extern int gdbm_delete __P((GDBM_FILE, datum));
  71. extern datum gdbm_firstkey __P((GDBM_FILE));
  72. extern datum gdbm_nextkey __P((GDBM_FILE, datum));
  73. extern int gdbm_reorganize __P((GDBM_FILE));
  74. extern void gdbm_sync __P((GDBM_FILE));
  75. extern int gdbm_exists __P((GDBM_FILE, datum));
  76. extern int gdbm_setopt __P((GDBM_FILE, int, int *, int));
  77. extern int gdbm_fdesc __P((GDBM_FILE));
  78. #if defined(__cplusplus) || defined(c_plusplus)
  79. }
  80. #endif
  81. #define GDBM_NO_ERROR 0
  82. #define GDBM_MALLOC_ERROR 1
  83. #define GDBM_BLOCK_SIZE_ERROR 2
  84. #define GDBM_FILE_OPEN_ERROR 3
  85. #define GDBM_FILE_WRITE_ERROR 4
  86. #define GDBM_FILE_SEEK_ERROR 5
  87. #define GDBM_FILE_READ_ERROR 6
  88. #define GDBM_BAD_MAGIC_NUMBER 7
  89. #define GDBM_EMPTY_DATABASE 8
  90. #define GDBM_CANT_BE_READER 9
  91. #define GDBM_CANT_BE_WRITER 10
  92. #define GDBM_READER_CANT_DELETE 11
  93. #define GDBM_READER_CANT_STORE 12
  94. #define GDBM_READER_CANT_REORGANIZE 13
  95. #define GDBM_UNKNOWN_UPDATE 14
  96. #define GDBM_ITEM_NOT_FOUND 15
  97. #define GDBM_REORGANIZE_FAILED 16
  98. #define GDBM_CANNOT_REPLACE 17
  99. #define GDBM_ILLEGAL_DATA 18
  100. #define GDBM_OPT_ALREADY_SET 19
  101. #define GDBM_OPT_ILLEGAL 20
  102. typedef int gdbm_error; /* For compatibilities sake. */
  103. extern gdbm_error gdbm_errno;
  104. /* extra prototypes */
  105. /* GDBM C++ support */
  106. #if defined(__cplusplus) || defined(c_plusplus)
  107. extern "C" {
  108. #endif
  109. extern char *gdbm_strerror __P((gdbm_error));
  110. #if defined(__cplusplus) || defined(c_plusplus)
  111. }
  112. #endif
  113. #endif