summaryrefslogtreecommitdiffstats
path: root/include/libaccess/nsadb.h
blob: 07fb2ca21333031621a804bb26d99376462664f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/** BEGIN COPYRIGHT BLOCK
 * Copyright 2001 Sun Microsystems, Inc.
 * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
 * All rights reserved.
 * END COPYRIGHT BLOCK **/
#ifndef __nsadb_h
#define __nsadb_h

/*
 * Description (nsadb.h)
 *
 *	This file describes the interface for retrieving information
 *	from a Netscape authentication database.  This facility is
 *	built on top of the Netscape (server) database interface as
 *	defined in nsdb.h.  It represents a subclass of a more general
 *	authentication database interface defined in nsauth.h.
 */

#include "nserror.h"		/* error frame list support */
#include "nsautherr.h"		/* authentication error codes */
#include "nsauth.h"

/* Begin private definitions */
#ifdef __PRIVATE_NSADB

#include "nsdb.h"

#if defined(CLIENT_AUTH)
#define ADBDBNAMES	3		/* number of named files */
#else
#define ADBDBNAMES	2		/* number of named files */
#endif
#define ADBUSERDBNAME	"Users"		/* name of user database */
#define ADBGROUPDBNAME	"Groups"	/* name of group database */
#if defined(CLIENT_AUTH)
#define ADBCERTDBNAME	"Certs"		/* name of certificate mapping DB */
#define ADBUMAPDBNAME	"Certs.nm"	/* name of mapped user names DB */
#endif

typedef struct AuthDB_s AuthDB_t;
struct AuthDB_s {
    char * adb_dbname;			/* database name */
    void * adb_userdb;			/* handle for user database */
    void * adb_groupdb;			/* handle for group database */
#if defined(CLIENT_AUTH)
    void * adb_certdb;			/* handle for cert mapping database */
    void * adb_certlock;		/* lock for cert mapping database */
    void * adb_certnm;			/* handle for username-to-certid DB */
#endif
    int adb_flags;			/* flags */
};

/* Definitions for adb_flags (also used on nsadbOpenXxxx() calls) */
#define ADBF_NEW	0x1		/* newly created database */
#define ADBF_UREAD	0x10		/* user database open for read */
#define ADBF_UWRITE	0x20		/* user database open for write */
#define ADBF_GREAD	0x100		/* group database open for read */
#define ADBF_GWRITE	0x200		/* group database open for write */
#define ADBF_CREAD	0x1000		/* cert database open for read */
#define ADBF_CWRITE	0x2000		/* cert database open for write */
#endif /* __PRIVATE_NSADB */

NSPR_BEGIN_EXTERN_C

/* Functions in nsadb.c */
extern NSAPI_PUBLIC int nsadbOpen(NSErr_t * errp,
				  char * adbname, int flags, void **rptr);
extern NSAPI_PUBLIC void nsadbClose(void * authdb, int flags);
extern NSAPI_PUBLIC int nsadbOpenUsers(NSErr_t * errp,
				       void * authdb, int flags);
extern NSAPI_PUBLIC int nsadbOpenGroups(NSErr_t * errp,
					void * authdb, int flags);
extern NSAPI_PUBLIC int nsadbIdToName(NSErr_t * errp, void * authdb,
				      USI_t id, int flags, char **rptr);
extern NSAPI_PUBLIC int nsadbFindByName(NSErr_t * errp, void * authdb,
					char * name, int flags, void **rptr);

#if defined(CLIENT_AUTH)
#include "nscert.h"
#endif

/* Authentication database interface structure in nsadb.c */
extern AuthIF_t NSADB_AuthIF;

NSPR_END_EXTERN_C

#endif /* __nsadb_h */