summary refs log tree commit diff
path: root/nss/nss_db/nss_db.h
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-05-08 04:50:45 +0000
committerUlrich Drepper <drepper@redhat.com>2000-05-08 04:50:45 +0000
commitd1c2a14cdfd71fea547c9ec0db7eff85991bdd11 (patch)
tree200fb3d55b6d160fec0cc21978851f589e48fc40 /nss/nss_db/nss_db.h
parent93414bb97c8d4af09fbc6ed493e5c904f27a5173 (diff)
downloadglibc-d1c2a14cdfd71fea547c9ec0db7eff85991bdd11.tar.gz
glibc-d1c2a14cdfd71fea547c9ec0db7eff85991bdd11.tar.xz
glibc-d1c2a14cdfd71fea547c9ec0db7eff85991bdd11.zip
Update.
2000-05-07  Mark Kettenis  <kettenis@gnu.org>

	* nss/nss_db/db-open.c: Cleanup and add comments.  Pretty print.
	Remove duplicate <errno.h> include.  Remove inclusion of
	<libintl.h> and "nsswitch.h".
	(set_cloexec_flag): New function, broken out of dbopen.
	(dbopen): Changed return type to `enum
	nss_status'.  Mostly rewritten to make sure that we do not report
	NSS_STATUS_SUCCESS if something went wrong.  Remove unnecessary casts.
	(internal_setent): Change return type to nss_status.
	Document, and make sure that the function
	behaves accordingly.  Make dynamically loading the database
	library really thread-safe and return NSS_STATUS_UNAVAIL if it
	failed.
	(db_cursor): Return ENOMEM is memory allocation failed.  Remove
	unecessary casts.
	* nss/nss_db/dummy-db.h: Add copyright notice.  Improve
	documentation.
	(struct dbc24, struct dbc27): Use DBT type in parameter lists for
	c_get function member.
	* nss/nss_db/nss_db.h: Add and tweak some comments.
	(DBT): Move typedef before NSS_DBC typedef.
	(NSS_DBC, NSS_DB): Use DBT in function member parameter lists.
Diffstat (limited to 'nss/nss_db/nss_db.h')
-rw-r--r--nss/nss_db/nss_db.h64
1 files changed, 37 insertions, 27 deletions
diff --git a/nss/nss_db/nss_db.h b/nss/nss_db/nss_db.h
index 8abec2d8de..4ace9ed846 100644
--- a/nss/nss_db/nss_db.h
+++ b/nss/nss_db/nss_db.h
@@ -20,32 +20,44 @@
 #ifndef _NSS_DB_H
 #define _NSS_DB_H	1
 
+#include <nss.h>
 #include <stdint.h>
 
 /* Variables which keep track of the error values.  */
 extern int db_keyexist;
 extern int db_notfound;
 
-/* Constants which vary from version to version are actually variables
-   here.  */
+/* 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.  */
 extern int db_first;
 extern int db_next;
 extern int db_nooverwrite;
 extern int db_truncate;
 extern int db_rdonly;
 
-/* Flags are also unchanged.  */
-#define DB_CREATE	0x000001
-
+/* 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;
 
-/* Similarly we have to handle the cursor object.  It is also very
-   different from version to version.  */
+/* But the cursor object is very different from version to version.  */
 typedef struct
 {
   void *cursor;
-  int (*c_get) (void *, void *, void *, uint32_t);
+  int (*c_get) (void *, DBT *, DBT *, uint32_t);
 } NSS_DBC;
 
+/* We need a helper function for it.  */
+extern int db_cursor (void *db, void *txn, NSS_DBC **dbcp);
 
 /* This is the wrapper we put around the `DB' structures to provide a
    uniform interface to the higher-level functions.  */
@@ -55,30 +67,28 @@ typedef struct
   int (*close) (void *, uint32_t);
   int (*cursor) (void *, void *, NSS_DBC **);
   int (*fd) (void *, int *);
-  int (*get) (void *, void *, void *, void *, uint32_t);
-  int (*put) (void *, void *, void *, void *, uint32_t);
+  int (*get) (void *, void *, DBT *, DBT *, uint32_t);
+  int (*put) (void *, void *, DBT *, DBT *, uint32_t);
 } NSS_DB;
 
+/* 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);
 
-/* 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;
-
+/* Close the database *DBP.  */
+extern void internal_endent (NSS_DB **dbp);
 
-/* Private routines to nss_db.
-   You must have included nsswitch.h and db.h before this file.  */
+/* 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);
 
-extern enum nss_status internal_setent (const char *file, NSS_DB **dbp);
-extern void internal_endent (NSS_DB **dbp);
-extern int db_cursor (void *db, void *txn, NSS_DBC **dbcp);
-extern int load_db (void);
+/* 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.  */
 extern int dbopen (const char *fname, int oper, int mode, NSS_DB **dbp);
 
-
 #endif	/* nss_db.h */