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