xref: /illumos-gate/usr/src/cmd/sendmail/db/include/db_am.h (revision 88f8b78a88cbdc6d8c1af5c3e54bc49d25095c98)
1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 1996, 1997, 1998
5  *	Sleepycat Software.  All rights reserved.
6  *
7  *	@(#)db_am.h	10.15 (Sleepycat) 11/22/98
8  */
9 #ifndef _DB_AM_H
10 #define _DB_AM_H
11 
12 #define DB_ISBIG	0x01
13 #define	DB_ADD_DUP	0x10
14 #define	DB_REM_DUP	0x20
15 #define	DB_ADD_BIG	0x30
16 #define	DB_REM_BIG	0x40
17 #define	DB_SPLITOLD	0x50
18 #define	DB_SPLITNEW	0x60
19 #define	DB_ADD_PAGE	0x70
20 #define	DB_REM_PAGE	0x80
21 
22 /*
23  * Standard initialization and shutdown macros for all recovery functions.
24  *
25  * Requires the following local variables:
26  *
27  *	DB *file_dbp, *mdbp;
28  *	DB_MPOOLFILE *mpf;
29  *	int ret;
30  */
31 #define	REC_INTRO(func) {						\
32 	file_dbp = NULL;						\
33 	dbc = NULL;							\
34 	if ((ret = func(dbtp->data, &argp)) != 0)			\
35 		goto out;						\
36 	if ((ret =							\
37 	    __db_fileid_to_db(logp, &file_dbp, argp->fileid)) != 0) {	\
38 		if (ret	== DB_DELETED) {				\
39 			ret = 0;					\
40 			goto done;					\
41 		}							\
42 		goto out;						\
43 	}								\
44 	if (file_dbp == NULL)						\
45 		goto out;						\
46 	if ((ret = file_dbp->cursor(file_dbp, NULL, &dbc, 0)) != 0)	\
47 		goto out;						\
48 	F_SET(dbc, DBC_RECOVER);					\
49 	mpf = file_dbp->mpf;						\
50 }
51 
52 #define	REC_CLOSE {							\
53 	if (argp != NULL)						\
54 		__os_free(argp, sizeof(*argp));				\
55 	if (dbc != NULL)						\
56 		dbc->c_close(dbc);					\
57 	return (ret);							\
58 }
59 
60 /*
61  * No-op versions of the same macros.
62  */
63 #define	REC_NOOP_INTRO(func) {						\
64 	if ((ret = func(dbtp->data, &argp)) != 0)			\
65 		return (ret);						\
66 }
67 #define	REC_NOOP_CLOSE {						\
68 	if (argp != NULL)						\
69 		__os_free(argp, sizeof(*argp));				\
70 	return (ret);							\
71 }
72 
73 /*
74  * Standard debugging macro for all recovery functions.
75  */
76 #ifdef DEBUG_RECOVER
77 #define	REC_PRINT(func)							\
78 	(void)func(logp, dbtp, lsnp, redo, info);
79 #else
80 #define	REC_PRINT(func)							\
81 	COMPQUIET(info, NULL);
82 #endif
83 
84 #include "db_auto.h"
85 #include "db_ext.h"
86 #endif
87