* sysdeps/unix/sysv/linux/configure.in: Bump minimal kernel
[glibc.git] / nss / nss_db / nss_db.h
blob0edc9b6bea2adc41b33a3459b6ddee06d1c9cced
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
18 02111-1307 USA. */
20 #ifndef _NSS_DB_H
21 #define _NSS_DB_H 1
23 #include <nss.h>
24 #include <stdint.h>
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
34 variables here. */
35 extern int db_first;
36 extern int db_next;
37 extern int db_nooverwrite;
38 extern int db_truncate;
39 extern int db_rdonly;
41 /* The `DBT' type is the same in all versions we support. */
42 typedef struct
44 void *data;
45 uint32_t size;
46 uint32_t ulen;
47 uint32_t dlen;
48 uint32_t doff;
49 uint32_t flags;
50 } DBT;
52 /* But the cursor object is very different from version to version. */
53 typedef struct
55 void *cursor;
56 int (*c_get) (void *, DBT *, DBT *, uint32_t);
57 } NSS_DBC;
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. */
64 typedef struct
66 void *db;
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);
72 } NSS_DB;
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
84 loaded. */
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
91 lookup status. */
92 extern int dbopen (const char *fname, int oper, int mode, NSS_DB **dbp);
94 #endif /* nss_db.h */