1 /* Common database open/close routines for nss_db.
2 Copyright (C) 1999, 2000 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
26 /* Variables which keep track of the error values. */
27 extern int db_keyexist
;
28 extern int db_notfound
;
30 /* This flag is the same for all versions of the Berkeley DB library. */
31 #define DB_CREATE 0x000001
33 /* But constants which vary from version to version are actually
37 extern int db_nooverwrite
;
38 extern int db_truncate
;
41 /* The `DBT' type is the same in all versions we support. */
52 /* But the cursor object is very different from version to version. */
56 int (*c_get
) (void *, DBT
*, DBT
*, uint32_t);
59 /* We need a helper function for it. */
60 extern int db_cursor (void *db
, void *txn
, NSS_DBC
**dbcp
);
62 /* This is the wrapper we put around the `DB' structures to provide a
63 uniform interface to the higher-level functions. */
67 int (*close
) (void *, uint32_t);
68 int (*cursor
) (void *, void *, NSS_DBC
**);
69 int (*fd
) (void *, int *);
70 int (*get
) (void *, void *, DBT
*, DBT
*, uint32_t);
71 int (*put
) (void *, void *, DBT
*, DBT
*, uint32_t);
74 /* Open the database stored in FILE. If succesful, store the database
75 handle in *DBP and return NSS_STATUS_SUCCESS. On failure, return
76 the appropriate lookup status. */
77 extern enum nss_status
internal_setent (const char *file
, NSS_DB
**dbp
);
79 /* Close the database *DBP. */
80 extern void internal_endent (NSS_DB
**dbp
);
82 /* Dynamically load the Berkeley DB library. Return zero if
83 successful, non-zero if no suitable version of the library could be
85 extern enum nss_status
load_db (void);
87 /* Open the database in FNAME, for access specified by FLAGS. If
88 opening the database causes the file FNAME to be created, it is
89 created with MODE. If succesful, store the database handle in *DBP
90 and return NSS_STATUS_SUCCESS. On failure, return the appropriate
92 extern int dbopen (const char *fname
, int oper
, int mode
, NSS_DB
**dbp
);