xref: /freebsd/contrib/sendmail/include/libsmdb/smdb.h (revision d39bd2c1388b520fcba9abed1932acacead60fba)
106f25ae9SGregory Neil Shapiro /*
25b0945b5SGregory Neil Shapiro  * Copyright (c) 1999-2002, 2018 Proofpoint, Inc. and its suppliers.
340266059SGregory Neil Shapiro  *	All rights reserved.
440266059SGregory Neil Shapiro  *
540266059SGregory Neil Shapiro  * By using this file, you agree to the terms and conditions set
640266059SGregory Neil Shapiro  * forth in the LICENSE file which can be found at the top level of
740266059SGregory Neil Shapiro  * the sendmail distribution.
840266059SGregory Neil Shapiro  *
94313cc83SGregory Neil Shapiro  *	$Id: smdb.h,v 8.42 2013-11-22 20:51:28 ca Exp $
1040266059SGregory Neil Shapiro  *
1106f25ae9SGregory Neil Shapiro  */
1206f25ae9SGregory Neil Shapiro 
1306f25ae9SGregory Neil Shapiro #ifndef _SMDB_H_
1406f25ae9SGregory Neil Shapiro # define _SMDB_H_
1506f25ae9SGregory Neil Shapiro 
1606f25ae9SGregory Neil Shapiro # include <sys/types.h>
1706f25ae9SGregory Neil Shapiro # include <sys/stat.h>
1840266059SGregory Neil Shapiro # include <sm/gen.h>
1940266059SGregory Neil Shapiro # include <sm/errstring.h>
2006f25ae9SGregory Neil Shapiro 
215b0945b5SGregory Neil Shapiro # if NDBM
2206f25ae9SGregory Neil Shapiro #  include <ndbm.h>
235b0945b5SGregory Neil Shapiro # endif
2406f25ae9SGregory Neil Shapiro 
255b0945b5SGregory Neil Shapiro # if NEWDB
2613bd1963SGregory Neil Shapiro #  include "sm/bdb.h"
275b0945b5SGregory Neil Shapiro # endif
2806f25ae9SGregory Neil Shapiro 
2906f25ae9SGregory Neil Shapiro /*
3006f25ae9SGregory Neil Shapiro **  Some size constants
3106f25ae9SGregory Neil Shapiro */
3240266059SGregory Neil Shapiro 
3306f25ae9SGregory Neil Shapiro #define SMDB_MAX_USER_NAME_LEN	1024
3406f25ae9SGregory Neil Shapiro 
3506f25ae9SGregory Neil Shapiro /*
3606f25ae9SGregory Neil Shapiro **  This file defines the abstraction for database lookups. It is pretty
3706f25ae9SGregory Neil Shapiro **  much a copy of the db2 interface with the exception that every function
3806f25ae9SGregory Neil Shapiro **  returns 0 on success and non-zero on failure. The non-zero return code
3906f25ae9SGregory Neil Shapiro **  is meaningful.
4006f25ae9SGregory Neil Shapiro **
4106f25ae9SGregory Neil Shapiro **  I'm going to put the function comments in this file since the interface
4206f25ae9SGregory Neil Shapiro **  MUST be the same for all inheritors of this interface.
4306f25ae9SGregory Neil Shapiro */
4406f25ae9SGregory Neil Shapiro 
4506f25ae9SGregory Neil Shapiro typedef struct database_struct SMDB_DATABASE;
4606f25ae9SGregory Neil Shapiro typedef struct cursor_struct SMDB_CURSOR;
47193538b7SGregory Neil Shapiro typedef struct entry_struct SMDB_DBENT;
4806f25ae9SGregory Neil Shapiro 
4906f25ae9SGregory Neil Shapiro /*
5006f25ae9SGregory Neil Shapiro **  DB_CLOSE_FUNC -- close the database
5106f25ae9SGregory Neil Shapiro **
5206f25ae9SGregory Neil Shapiro **	Parameters:
5306f25ae9SGregory Neil Shapiro **		db -- The database to close.
5406f25ae9SGregory Neil Shapiro **
5506f25ae9SGregory Neil Shapiro **	Returns:
5606f25ae9SGregory Neil Shapiro **		0 - Success, otherwise errno.
5706f25ae9SGregory Neil Shapiro **
5806f25ae9SGregory Neil Shapiro */
5940266059SGregory Neil Shapiro 
6006f25ae9SGregory Neil Shapiro typedef int (*db_close_func) __P((SMDB_DATABASE *db));
6106f25ae9SGregory Neil Shapiro 
6206f25ae9SGregory Neil Shapiro /*
6306f25ae9SGregory Neil Shapiro **  DB_DEL_FUNC -- removes a key and data pair from the database
6406f25ae9SGregory Neil Shapiro **
6506f25ae9SGregory Neil Shapiro **	Parameters:
6606f25ae9SGregory Neil Shapiro **		db -- The database to close.
6706f25ae9SGregory Neil Shapiro **		key -- The key to remove.
6806f25ae9SGregory Neil Shapiro **		flags -- delete options. There are currently no defined
6906f25ae9SGregory Neil Shapiro **			 flags for delete.
7006f25ae9SGregory Neil Shapiro **
7106f25ae9SGregory Neil Shapiro **	Returns:
7206f25ae9SGregory Neil Shapiro **		0 - Success, otherwise errno.
7306f25ae9SGregory Neil Shapiro **
7406f25ae9SGregory Neil Shapiro */
7540266059SGregory Neil Shapiro 
7606f25ae9SGregory Neil Shapiro typedef int (*db_del_func) __P((SMDB_DATABASE *db,
7740266059SGregory Neil Shapiro 			   SMDB_DBENT *key, unsigned int flags));
7806f25ae9SGregory Neil Shapiro 
7906f25ae9SGregory Neil Shapiro /*
8006f25ae9SGregory Neil Shapiro **  DB_FD_FUNC -- Returns a pointer to a file used for the database.
8106f25ae9SGregory Neil Shapiro **
8206f25ae9SGregory Neil Shapiro **	Parameters:
8306f25ae9SGregory Neil Shapiro **		db -- The database to close.
8406f25ae9SGregory Neil Shapiro **		fd -- A pointer to store the returned fd in.
8506f25ae9SGregory Neil Shapiro **
8606f25ae9SGregory Neil Shapiro **	Returns:
8706f25ae9SGregory Neil Shapiro **		0 - Success, otherwise errno.
8806f25ae9SGregory Neil Shapiro **
8906f25ae9SGregory Neil Shapiro */
9040266059SGregory Neil Shapiro 
9106f25ae9SGregory Neil Shapiro typedef int (*db_fd_func) __P((SMDB_DATABASE *db, int* fd));
9206f25ae9SGregory Neil Shapiro 
9306f25ae9SGregory Neil Shapiro /*
9406f25ae9SGregory Neil Shapiro **  DB_GET_FUNC -- Gets the data associated with a key.
9506f25ae9SGregory Neil Shapiro **
9606f25ae9SGregory Neil Shapiro **	Parameters:
9706f25ae9SGregory Neil Shapiro **		db -- The database to close.
9806f25ae9SGregory Neil Shapiro **		key -- The key to access.
9906f25ae9SGregory Neil Shapiro **		data -- A place to store the returned data.
10006f25ae9SGregory Neil Shapiro **		flags -- get options. There are currently no defined
10106f25ae9SGregory Neil Shapiro **			 flags for get.
10206f25ae9SGregory Neil Shapiro **
10306f25ae9SGregory Neil Shapiro **	Returns:
10406f25ae9SGregory Neil Shapiro **		0 - Success, otherwise errno.
10506f25ae9SGregory Neil Shapiro **
10606f25ae9SGregory Neil Shapiro */
10740266059SGregory Neil Shapiro 
10806f25ae9SGregory Neil Shapiro typedef int (*db_get_func) __P((SMDB_DATABASE *db,
10906f25ae9SGregory Neil Shapiro 			   SMDB_DBENT *key,
11040266059SGregory Neil Shapiro 			   SMDB_DBENT *data, unsigned int flags));
11106f25ae9SGregory Neil Shapiro 
11206f25ae9SGregory Neil Shapiro /*
11306f25ae9SGregory Neil Shapiro **  DB_PUT_FUNC -- Sets some data according to the key.
11406f25ae9SGregory Neil Shapiro **
11506f25ae9SGregory Neil Shapiro **	Parameters:
11606f25ae9SGregory Neil Shapiro **		db -- The database to close.
11706f25ae9SGregory Neil Shapiro **		key -- The key to use.
11806f25ae9SGregory Neil Shapiro **		data -- The data to store.
11906f25ae9SGregory Neil Shapiro **		flags -- put options:
120*d39bd2c1SGregory Neil Shapiro **			SMDBF_NO_OVERWRITE - Return an error if key already
12106f25ae9SGregory Neil Shapiro **					     exists.
12206f25ae9SGregory Neil Shapiro **
12306f25ae9SGregory Neil Shapiro **	Returns:
12406f25ae9SGregory Neil Shapiro **		0 - Success, otherwise errno.
12506f25ae9SGregory Neil Shapiro **
12606f25ae9SGregory Neil Shapiro */
12740266059SGregory Neil Shapiro 
12806f25ae9SGregory Neil Shapiro typedef int (*db_put_func) __P((SMDB_DATABASE *db,
12906f25ae9SGregory Neil Shapiro 			   SMDB_DBENT *key,
13040266059SGregory Neil Shapiro 			   SMDB_DBENT *data, unsigned int flags));
13106f25ae9SGregory Neil Shapiro 
13206f25ae9SGregory Neil Shapiro /*
13306f25ae9SGregory Neil Shapiro **  DB_SYNC_FUNC -- Flush any cached information to disk.
13406f25ae9SGregory Neil Shapiro **
13506f25ae9SGregory Neil Shapiro **	Parameters:
13606f25ae9SGregory Neil Shapiro **		db -- The database to sync.
13706f25ae9SGregory Neil Shapiro **		flags -- sync options:
13806f25ae9SGregory Neil Shapiro **
13906f25ae9SGregory Neil Shapiro **	Returns:
14006f25ae9SGregory Neil Shapiro **		0 - Success, otherwise errno.
14106f25ae9SGregory Neil Shapiro **
14206f25ae9SGregory Neil Shapiro */
14306f25ae9SGregory Neil Shapiro 
14440266059SGregory Neil Shapiro typedef int (*db_sync_func) __P((SMDB_DATABASE *db, unsigned int flags));
14540266059SGregory Neil Shapiro 
14606f25ae9SGregory Neil Shapiro /*
14706f25ae9SGregory Neil Shapiro **  DB_SET_OWNER_FUNC -- Set the owner and group of the database files.
14806f25ae9SGregory Neil Shapiro **
14906f25ae9SGregory Neil Shapiro **	Parameters:
15006f25ae9SGregory Neil Shapiro **		db -- The database to set.
15106f25ae9SGregory Neil Shapiro **		uid -- The UID for the new owner (-1 for no change)
15206f25ae9SGregory Neil Shapiro **		gid -- The GID for the new owner (-1 for no change)
15306f25ae9SGregory Neil Shapiro **
15406f25ae9SGregory Neil Shapiro **	Returns:
15506f25ae9SGregory Neil Shapiro **		0 - Success, otherwise errno.
15606f25ae9SGregory Neil Shapiro **
15706f25ae9SGregory Neil Shapiro */
15806f25ae9SGregory Neil Shapiro 
15940266059SGregory Neil Shapiro typedef int (*db_set_owner_func) __P((SMDB_DATABASE *db, uid_t uid, gid_t gid));
16040266059SGregory Neil Shapiro 
16106f25ae9SGregory Neil Shapiro /*
16206f25ae9SGregory Neil Shapiro **  DB_CURSOR -- Obtain a cursor for sequential access
16306f25ae9SGregory Neil Shapiro **
16406f25ae9SGregory Neil Shapiro **	Parameters:
16506f25ae9SGregory Neil Shapiro **		db -- The database to use.
16606f25ae9SGregory Neil Shapiro **		cursor -- The address of a cursor pointer.
16706f25ae9SGregory Neil Shapiro **		flags -- sync options:
16806f25ae9SGregory Neil Shapiro **
16906f25ae9SGregory Neil Shapiro **	Returns:
17006f25ae9SGregory Neil Shapiro **		0 - Success, otherwise errno.
17106f25ae9SGregory Neil Shapiro **
17206f25ae9SGregory Neil Shapiro */
17340266059SGregory Neil Shapiro 
17406f25ae9SGregory Neil Shapiro typedef int (*db_cursor_func) __P((SMDB_DATABASE *db,
17540266059SGregory Neil Shapiro 			      SMDB_CURSOR **cursor, unsigned int flags));
17606f25ae9SGregory Neil Shapiro 
17742e5d165SGregory Neil Shapiro typedef int (*db_lockfd_func) __P((SMDB_DATABASE *db));
17806f25ae9SGregory Neil Shapiro 
17906f25ae9SGregory Neil Shapiro struct database_struct
18006f25ae9SGregory Neil Shapiro {
18106f25ae9SGregory Neil Shapiro 	db_close_func		smdb_close;
18206f25ae9SGregory Neil Shapiro 	db_del_func		smdb_del;
18306f25ae9SGregory Neil Shapiro 	db_fd_func		smdb_fd;
18406f25ae9SGregory Neil Shapiro 	db_get_func		smdb_get;
18506f25ae9SGregory Neil Shapiro 	db_put_func		smdb_put;
18606f25ae9SGregory Neil Shapiro 	db_sync_func		smdb_sync;
18706f25ae9SGregory Neil Shapiro 	db_set_owner_func	smdb_set_owner;
18806f25ae9SGregory Neil Shapiro 	db_cursor_func		smdb_cursor;
18942e5d165SGregory Neil Shapiro 	db_lockfd_func		smdb_lockfd;
19006f25ae9SGregory Neil Shapiro 	void			*smdb_impl;
19106f25ae9SGregory Neil Shapiro };
1925b0945b5SGregory Neil Shapiro 
19306f25ae9SGregory Neil Shapiro /*
19406f25ae9SGregory Neil Shapiro **  DB_CURSOR_CLOSE -- Close a cursor
19506f25ae9SGregory Neil Shapiro **
19606f25ae9SGregory Neil Shapiro **	Parameters:
19706f25ae9SGregory Neil Shapiro **		cursor -- The cursor to close.
19806f25ae9SGregory Neil Shapiro **
19906f25ae9SGregory Neil Shapiro **	Returns:
20006f25ae9SGregory Neil Shapiro **		0 - Success, otherwise errno.
20106f25ae9SGregory Neil Shapiro **
20206f25ae9SGregory Neil Shapiro */
20340266059SGregory Neil Shapiro 
20406f25ae9SGregory Neil Shapiro typedef int (*db_cursor_close_func) __P((SMDB_CURSOR *cursor));
20506f25ae9SGregory Neil Shapiro 
20606f25ae9SGregory Neil Shapiro /*
20706f25ae9SGregory Neil Shapiro **  DB_CURSOR_DEL -- Delete the key/value pair of this cursor
20806f25ae9SGregory Neil Shapiro **
20906f25ae9SGregory Neil Shapiro **	Parameters:
21006f25ae9SGregory Neil Shapiro **		cursor -- The cursor.
21106f25ae9SGregory Neil Shapiro **		flags -- flags
21206f25ae9SGregory Neil Shapiro **
21306f25ae9SGregory Neil Shapiro **	Returns:
21406f25ae9SGregory Neil Shapiro **		0 - Success, otherwise errno.
21506f25ae9SGregory Neil Shapiro **
21606f25ae9SGregory Neil Shapiro */
21706f25ae9SGregory Neil Shapiro 
21840266059SGregory Neil Shapiro typedef int (*db_cursor_del_func) __P((SMDB_CURSOR *cursor,
21940266059SGregory Neil Shapiro 					unsigned int flags));
22040266059SGregory Neil Shapiro 
22106f25ae9SGregory Neil Shapiro /*
22206f25ae9SGregory Neil Shapiro **  DB_CURSOR_GET -- Get the key/value of this cursor.
22306f25ae9SGregory Neil Shapiro **
22406f25ae9SGregory Neil Shapiro **	Parameters:
22506f25ae9SGregory Neil Shapiro **		cursor -- The cursor.
22606f25ae9SGregory Neil Shapiro **		key -- The current key.
22706f25ae9SGregory Neil Shapiro **		value -- The current value
22806f25ae9SGregory Neil Shapiro **		flags -- flags
22906f25ae9SGregory Neil Shapiro **
23006f25ae9SGregory Neil Shapiro **	Returns:
23106f25ae9SGregory Neil Shapiro **		0 - Success, otherwise errno.
23206f25ae9SGregory Neil Shapiro **		SMDBE_LAST_ENTRY - This is a success condition that
23306f25ae9SGregory Neil Shapiro **				   gets returned when the end of the
23406f25ae9SGregory Neil Shapiro **				   database is hit.
23506f25ae9SGregory Neil Shapiro **
23606f25ae9SGregory Neil Shapiro */
23740266059SGregory Neil Shapiro 
23806f25ae9SGregory Neil Shapiro typedef int (*db_cursor_get_func) __P((SMDB_CURSOR *cursor,
23906f25ae9SGregory Neil Shapiro 				  SMDB_DBENT *key,
24006f25ae9SGregory Neil Shapiro 				  SMDB_DBENT *data,
24140266059SGregory Neil Shapiro 				  unsigned int flags));
24206f25ae9SGregory Neil Shapiro 
24306f25ae9SGregory Neil Shapiro /*
24406f25ae9SGregory Neil Shapiro **  Flags for DB_CURSOR_GET
24506f25ae9SGregory Neil Shapiro */
24640266059SGregory Neil Shapiro 
2475b0945b5SGregory Neil Shapiro #define SMDB_CURSOR_GET_FIRST	0	/* NOT USED by any application */
2485b0945b5SGregory Neil Shapiro #define SMDB_CURSOR_GET_LAST	1	/* NOT USED by any application */
24906f25ae9SGregory Neil Shapiro #define SMDB_CURSOR_GET_NEXT	2
2505b0945b5SGregory Neil Shapiro #define SMDB_CURSOR_GET_RANGE	3	/* NOT USED by any application */
25106f25ae9SGregory Neil Shapiro 
25206f25ae9SGregory Neil Shapiro /*
25306f25ae9SGregory Neil Shapiro **  DB_CURSOR_PUT -- Put the key/value at this cursor.
25406f25ae9SGregory Neil Shapiro **
25506f25ae9SGregory Neil Shapiro **	Parameters:
25606f25ae9SGregory Neil Shapiro **		cursor -- The cursor.
25706f25ae9SGregory Neil Shapiro **		key -- The current key.
25806f25ae9SGregory Neil Shapiro **		value -- The current value
25906f25ae9SGregory Neil Shapiro **		flags -- flags
26006f25ae9SGregory Neil Shapiro **
26106f25ae9SGregory Neil Shapiro **	Returns:
26206f25ae9SGregory Neil Shapiro **		0 - Success, otherwise errno.
26306f25ae9SGregory Neil Shapiro **
26406f25ae9SGregory Neil Shapiro */
26540266059SGregory Neil Shapiro 
26606f25ae9SGregory Neil Shapiro typedef int (*db_cursor_put_func) __P((SMDB_CURSOR *cursor,
26706f25ae9SGregory Neil Shapiro 				  SMDB_DBENT *key,
26806f25ae9SGregory Neil Shapiro 				  SMDB_DBENT *data,
26940266059SGregory Neil Shapiro 				  unsigned int flags));
27006f25ae9SGregory Neil Shapiro 
27106f25ae9SGregory Neil Shapiro 
27206f25ae9SGregory Neil Shapiro 
27306f25ae9SGregory Neil Shapiro struct cursor_struct
27406f25ae9SGregory Neil Shapiro {
27506f25ae9SGregory Neil Shapiro 	db_cursor_close_func	smdbc_close;
27606f25ae9SGregory Neil Shapiro 	db_cursor_del_func	smdbc_del;
27706f25ae9SGregory Neil Shapiro 	db_cursor_get_func	smdbc_get;
27806f25ae9SGregory Neil Shapiro 	db_cursor_put_func	smdbc_put;
27906f25ae9SGregory Neil Shapiro 	void			*smdbc_impl;
28006f25ae9SGregory Neil Shapiro };
28106f25ae9SGregory Neil Shapiro 
28206f25ae9SGregory Neil Shapiro 
28306f25ae9SGregory Neil Shapiro struct database_params_struct
28406f25ae9SGregory Neil Shapiro {
28540266059SGregory Neil Shapiro 	unsigned int	smdbp_num_elements;
28640266059SGregory Neil Shapiro 	unsigned int	smdbp_cache_size;
28706f25ae9SGregory Neil Shapiro 	bool		smdbp_allow_dup;
28806f25ae9SGregory Neil Shapiro };
28906f25ae9SGregory Neil Shapiro 
29006f25ae9SGregory Neil Shapiro typedef struct database_params_struct SMDB_DBPARAMS;
29106f25ae9SGregory Neil Shapiro 
29206f25ae9SGregory Neil Shapiro struct database_user_struct
29306f25ae9SGregory Neil Shapiro {
29406f25ae9SGregory Neil Shapiro 	uid_t	smdbu_id;
29506f25ae9SGregory Neil Shapiro 	gid_t	smdbu_group_id;
29606f25ae9SGregory Neil Shapiro 	char	smdbu_name[SMDB_MAX_USER_NAME_LEN];
29706f25ae9SGregory Neil Shapiro };
29806f25ae9SGregory Neil Shapiro 
29906f25ae9SGregory Neil Shapiro typedef struct database_user_struct SMDB_USER_INFO;
30006f25ae9SGregory Neil Shapiro 
301193538b7SGregory Neil Shapiro struct entry_struct
30206f25ae9SGregory Neil Shapiro {
303193538b7SGregory Neil Shapiro 	void	*data;
30406f25ae9SGregory Neil Shapiro 	size_t	size;
30506f25ae9SGregory Neil Shapiro };
30606f25ae9SGregory Neil Shapiro 
30706f25ae9SGregory Neil Shapiro typedef char *SMDB_DBTYPE;
30840266059SGregory Neil Shapiro typedef unsigned int SMDB_FLAG;
30906f25ae9SGregory Neil Shapiro 
31006f25ae9SGregory Neil Shapiro /*
31106f25ae9SGregory Neil Shapiro **  These are types of databases.
31206f25ae9SGregory Neil Shapiro */
31306f25ae9SGregory Neil Shapiro 
31406f25ae9SGregory Neil Shapiro # define SMDB_TYPE_DEFAULT	NULL
31506f25ae9SGregory Neil Shapiro # define SMDB_TYPE_DEFAULT_LEN	0
3165b0945b5SGregory Neil Shapiro # define SMDB_TYPE_IMPL		"implicit"
3175b0945b5SGregory Neil Shapiro # define SMDB_TYPE_IMPL_LEN	9
31806f25ae9SGregory Neil Shapiro # define SMDB_TYPE_HASH		"hash"
31906f25ae9SGregory Neil Shapiro # define SMDB_TYPE_HASH_LEN	5
32006f25ae9SGregory Neil Shapiro # define SMDB_TYPE_BTREE	"btree"
32106f25ae9SGregory Neil Shapiro # define SMDB_TYPE_BTREE_LEN	6
32206f25ae9SGregory Neil Shapiro # define SMDB_TYPE_NDBM		"dbm"
32306f25ae9SGregory Neil Shapiro # define SMDB_TYPE_NDBM_LEN	4
3245b0945b5SGregory Neil Shapiro # define SMDB_TYPE_CDB		"cdb"
3255b0945b5SGregory Neil Shapiro # define SMDB_TYPE_CDB_LEN	4
3265b0945b5SGregory Neil Shapiro 
3275b0945b5SGregory Neil Shapiro # define SMDB_IS_TYPE_HASH(type)	(strncmp(type, SMDB_TYPE_HASH, SMDB_TYPE_HASH_LEN) == 0)
3285b0945b5SGregory Neil Shapiro # define SMDB_IS_TYPE_BTREE(type)	(strncmp(type, SMDB_TYPE_BTREE, SMDB_TYPE_BTREE_LEN) == 0)
3295b0945b5SGregory Neil Shapiro # define SMDB_IS_TYPE_NDBM(type)	(strncmp(type, SMDB_TYPE_NDBM, SMDB_TYPE_NDBM_LEN) == 0)
3305b0945b5SGregory Neil Shapiro # define SMDB_IS_TYPE_CDB(type)	(strncmp(type, SMDB_TYPE_CDB, SMDB_TYPE_CDB_LEN) == 0)
3315b0945b5SGregory Neil Shapiro 
3325b0945b5SGregory Neil Shapiro # define SMDB_IS_TYPE_DEFAULT(t) (((t) == SMDB_TYPE_DEFAULT) \
3335b0945b5SGregory Neil Shapiro 	|| (strncmp(type, SMDB_TYPE_IMPL, SMDB_TYPE_IMPL_LEN) == 0)	\
3345b0945b5SGregory Neil Shapiro 	)
3355b0945b5SGregory Neil Shapiro 
3365b0945b5SGregory Neil Shapiro # if CDB >= 2
3375b0945b5SGregory Neil Shapiro #  define SMCDB_FILE_EXTENSION "db"
3385b0945b5SGregory Neil Shapiro # else
3395b0945b5SGregory Neil Shapiro #  define SMCDB_FILE_EXTENSION "cdb"
3405b0945b5SGregory Neil Shapiro # endif
3415b0945b5SGregory Neil Shapiro # define SMDB1_FILE_EXTENSION "db"
3425b0945b5SGregory Neil Shapiro # define SMDB2_FILE_EXTENSION "db"
3435b0945b5SGregory Neil Shapiro # define SMNDB_DIR_FILE_EXTENSION "dir"
34406f25ae9SGregory Neil Shapiro 
34506f25ae9SGregory Neil Shapiro /*
34606f25ae9SGregory Neil Shapiro **  These are flags
34706f25ae9SGregory Neil Shapiro */
34840266059SGregory Neil Shapiro 
34906f25ae9SGregory Neil Shapiro /* Flags for put */
35006f25ae9SGregory Neil Shapiro # define SMDBF_NO_OVERWRITE	0x00000001
35106f25ae9SGregory Neil Shapiro 
3525b0945b5SGregory Neil Shapiro typedef int (smdb_open_func) __P((SMDB_DATABASE **, char *, int, int, long, SMDB_DBTYPE, SMDB_USER_INFO *, SMDB_DBPARAMS *));
35306f25ae9SGregory Neil Shapiro 
35406f25ae9SGregory Neil Shapiro extern SMDB_DATABASE	*smdb_malloc_database __P((void));
35506f25ae9SGregory Neil Shapiro extern void		smdb_free_database __P((SMDB_DATABASE *));
3565b0945b5SGregory Neil Shapiro extern smdb_open_func	smdb_open_database;
3575b0945b5SGregory Neil Shapiro # if NEWDB
3585b0945b5SGregory Neil Shapiro extern smdb_open_func	smdb_db_open;
3595b0945b5SGregory Neil Shapiro # else
3605b0945b5SGregory Neil Shapiro #  define smdb_db_open	NULL
3615b0945b5SGregory Neil Shapiro # endif
3625b0945b5SGregory Neil Shapiro # if NDBM
3635b0945b5SGregory Neil Shapiro extern smdb_open_func	smdb_ndbm_open;
3645b0945b5SGregory Neil Shapiro # else
3655b0945b5SGregory Neil Shapiro #  define smdb_ndbm_open	NULL
3665b0945b5SGregory Neil Shapiro # endif
36706f25ae9SGregory Neil Shapiro extern int		smdb_add_extension __P((char *, int, char *, char *));
36806f25ae9SGregory Neil Shapiro extern int		smdb_setup_file __P((char *, char *, int, long,
36906f25ae9SGregory Neil Shapiro 					     SMDB_USER_INFO *, struct stat *));
37006f25ae9SGregory Neil Shapiro extern int		smdb_lock_file __P((int *, char *, int, long, char *));
37106f25ae9SGregory Neil Shapiro extern int		smdb_unlock_file __P((int));
37206f25ae9SGregory Neil Shapiro extern int		smdb_filechanged __P((char *, char *, int,
37306f25ae9SGregory Neil Shapiro 					      struct stat *));
3745b0945b5SGregory Neil Shapiro extern void		smdb_print_available_types __P((bool));
3755b0945b5SGregory Neil Shapiro extern bool		smdb_is_db_type __P((const char *));
37606f25ae9SGregory Neil Shapiro extern char		*smdb_db_definition __P((SMDB_DBTYPE));
37742e5d165SGregory Neil Shapiro extern int		smdb_lock_map __P((SMDB_DATABASE *, int));
37842e5d165SGregory Neil Shapiro extern int		smdb_unlock_map __P((SMDB_DATABASE *));
3795b0945b5SGregory Neil Shapiro 
3805b0945b5SGregory Neil Shapiro # if CDB
3815b0945b5SGregory Neil Shapiro extern smdb_open_func	smdb_cdb_open;
3825b0945b5SGregory Neil Shapiro # else
3835b0945b5SGregory Neil Shapiro #  define smdb_cdb_open	NULL
3845b0945b5SGregory Neil Shapiro # endif
38506f25ae9SGregory Neil Shapiro #endif /* ! _SMDB_H_ */
386