2000-01-02 12:20:21 +08:00
|
|
|
/* Common database open/close routines for nss_db.
|
|
|
|
Copyright (C) 1999, 2000 Free Software Foundation, Inc.
|
|
|
|
This file is part of the GNU C Library.
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
2001-07-06 12:58:11 +08:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
2000-01-02 12:20:21 +08:00
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2001-07-06 12:58:11 +08:00
|
|
|
Lesser General Public License for more details.
|
2000-01-02 12:20:21 +08:00
|
|
|
|
2001-07-06 12:58:11 +08:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with the GNU C Library; if not, write to the Free
|
|
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
|
|
02111-1307 USA. */
|
2000-01-02 12:20:21 +08:00
|
|
|
|
|
|
|
#ifndef _NSS_DB_H
|
|
|
|
#define _NSS_DB_H 1
|
|
|
|
|
2000-05-08 12:50:45 +08:00
|
|
|
#include <nss.h>
|
2000-01-02 12:20:21 +08:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2000-01-08 13:28:22 +08:00
|
|
|
/* Variables which keep track of the error values. */
|
|
|
|
extern int db_keyexist;
|
|
|
|
extern int db_notfound;
|
|
|
|
|
2000-05-08 12:50:45 +08:00
|
|
|
/* This flag is the same for all versions of the Berkeley DB library. */
|
|
|
|
#define DB_CREATE 0x000001
|
|
|
|
|
|
|
|
/* But constants which vary from version to version are actually
|
|
|
|
variables here. */
|
2000-01-08 13:28:22 +08:00
|
|
|
extern int db_first;
|
|
|
|
extern int db_next;
|
|
|
|
extern int db_nooverwrite;
|
|
|
|
extern int db_truncate;
|
|
|
|
extern int db_rdonly;
|
2000-01-02 12:20:21 +08:00
|
|
|
|
2000-05-08 12:50:45 +08:00
|
|
|
/* The `DBT' type is the same in all versions we support. */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
void *data;
|
|
|
|
uint32_t size;
|
|
|
|
uint32_t ulen;
|
|
|
|
uint32_t dlen;
|
|
|
|
uint32_t doff;
|
|
|
|
uint32_t flags;
|
|
|
|
} DBT;
|
2000-01-02 16:45:58 +08:00
|
|
|
|
2000-05-08 12:50:45 +08:00
|
|
|
/* But the cursor object is very different from version to version. */
|
2000-01-02 16:45:58 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
void *cursor;
|
2000-05-08 12:50:45 +08:00
|
|
|
int (*c_get) (void *, DBT *, DBT *, uint32_t);
|
2000-01-02 16:45:58 +08:00
|
|
|
} NSS_DBC;
|
|
|
|
|
2000-05-08 12:50:45 +08:00
|
|
|
/* We need a helper function for it. */
|
|
|
|
extern int db_cursor (void *db, void *txn, NSS_DBC **dbcp);
|
2000-01-02 16:45:58 +08:00
|
|
|
|
2000-01-02 12:20:21 +08:00
|
|
|
/* This is the wrapper we put around the `DB' structures to provide a
|
|
|
|
uniform interface to the higher-level functions. */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
void *db;
|
|
|
|
int (*close) (void *, uint32_t);
|
2000-01-02 16:45:58 +08:00
|
|
|
int (*cursor) (void *, void *, NSS_DBC **);
|
2000-01-02 12:20:21 +08:00
|
|
|
int (*fd) (void *, int *);
|
2000-05-08 12:50:45 +08:00
|
|
|
int (*get) (void *, void *, DBT *, DBT *, uint32_t);
|
|
|
|
int (*put) (void *, void *, DBT *, DBT *, uint32_t);
|
2000-01-02 12:20:21 +08:00
|
|
|
} NSS_DB;
|
|
|
|
|
2000-05-08 12:50:45 +08:00
|
|
|
/* Open the database stored in FILE. If succesful, store the database
|
|
|
|
handle in *DBP and return NSS_STATUS_SUCCESS. On failure, return
|
|
|
|
the appropriate lookup status. */
|
|
|
|
extern enum nss_status internal_setent (const char *file, NSS_DB **dbp);
|
2000-01-02 12:20:21 +08:00
|
|
|
|
2000-05-08 12:50:45 +08:00
|
|
|
/* Close the database *DBP. */
|
|
|
|
extern void internal_endent (NSS_DB **dbp);
|
2000-01-02 12:20:21 +08:00
|
|
|
|
2000-05-08 12:50:45 +08:00
|
|
|
/* Dynamically load the Berkeley DB library. Return zero if
|
|
|
|
successful, non-zero if no suitable version of the library could be
|
|
|
|
loaded. */
|
|
|
|
extern enum nss_status load_db (void);
|
2000-01-02 12:20:21 +08:00
|
|
|
|
2000-05-08 12:50:45 +08:00
|
|
|
/* Open the database in FNAME, for access specified by FLAGS. If
|
|
|
|
opening the database causes the file FNAME to be created, it is
|
|
|
|
created with MODE. If succesful, store the database handle in *DBP
|
|
|
|
and return NSS_STATUS_SUCCESS. On failure, return the appropriate
|
|
|
|
lookup status. */
|
2000-01-08 13:28:22 +08:00
|
|
|
extern int dbopen (const char *fname, int oper, int mode, NSS_DB **dbp);
|
|
|
|
|
2000-01-02 12:20:21 +08:00
|
|
|
#endif /* nss_db.h */
|