1/*	$NetBSD: exf.h,v 1.1.1.2 2008/05/18 14:29:45 aymeric Exp $ */
2
3/*-
4 * Copyright (c) 1992, 1993, 1994
5 *	The Regents of the University of California.  All rights reserved.
6 * Copyright (c) 1992, 1993, 1994, 1995, 1996
7 *	Keith Bostic.  All rights reserved.
8 *
9 * See the LICENSE file for redistribution information.
10 *
11 *	Id: exf.h,v 10.19 2002/03/02 23:36:23 skimo Exp (Berkeley) Date: 2002/03/02 23:36:23
12 */
13					/* Undo direction. */
14/*
15 * exf --
16 *	The file structure.
17 */
18struct _exf {
19	CIRCLEQ_ENTRY(_exf) q;		/* Linked list of file structures. */
20	int	 refcnt;		/* Reference count. */
21
22	CIRCLEQ_HEAD(_escrh, _scr)   scrq;   /* Attached screens */
23					/* Underlying database state. */
24	DB_ENV	*env;			/* The DB environment. */
25	char	*env_path;		/* DB environment directory. */
26	DB	*db;			/* File db structure. */
27	db_recno_t	 c_nlines;	/* Cached lines in the file. */
28
29	DB	*log;			/* Log db structure. */
30	db_recno_t	 l_high;	/* Log last + 1 record number. */
31	db_recno_t	 l_cur;		/* Log current record number. */
32#ifdef USE_DB4_LOGGING
33	DB_LSN	lsn_first;
34	DB_LSN	lsn_high;		/* LSN of last record. */
35	DB_LSN	lsn_cur;		/* LSN of first record to undo. */
36#endif
37	MARK	 l_cursor;		/* Log cursor position. */
38	dir_t	 lundo;			/* Last undo direction. */
39	WIN	*l_win;			/* Window owning transaction. */
40
41	LIST_HEAD(_markh, _lmark) marks;/* Linked list of file MARK's. */
42
43	/*
44	 * XXX
45	 * Mtime should be a struct timespec, but time_t is more portable.
46	 */
47	dev_t	 mdev;			/* Device. */
48	ino_t	 minode;		/* Inode. */
49	time_t	 mtime;			/* Last modification time. */
50
51	int	 fcntl_fd;		/* Fcntl locking fd; see exf.c. */
52	int	 fd;			/* File descriptor */
53
54	/*
55	 * Recovery in general, and these fields specifically, are described
56	 * in recover.c.
57	 */
58#define	RCV_PERIOD	120		/* Sync every two minutes. */
59	char	*rcv_path;		/* Recover file name. */
60	char	*rcv_mpath;		/* Recover mail file name. */
61	int	 rcv_fd;		/* Locked mail file descriptor. */
62
63	void	*lock;			/* Lock for log. */
64
65#define	F_DEVSET	0x001		/* mdev/minode fields initialized. */
66#define	F_FIRSTMODIFY	0x002		/* File not yet modified. */
67#define	F_MODIFIED	0x004		/* File is currently dirty. */
68#define	F_MULTILOCK	0x008		/* Multiple processes running, lock. */
69#define	F_NOLOG		0x010		/* Logging turned off. */
70#define	F_RCV_NORM	0x020		/* Don't delete recovery files. */
71#define	F_RCV_ON	0x040		/* Recovery is possible. */
72#define	F_UNDO		0x080		/* No change since last undo. */
73	u_int8_t flags;
74};
75
76/* Flags to db_get(). */
77#define	DBG_FATAL	0x001	/* If DNE, error message. */
78#define	DBG_NOCACHE	0x002	/* Ignore the front-end cache. */
79
80/* Flags to file_init() and file_write(). */
81#define	FS_ALL		0x001	/* Write the entire file. */
82#define	FS_APPEND	0x002	/* Append to the file. */
83#define	FS_FORCE	0x004	/* Force is set. */
84#define	FS_OPENERR	0x008	/* Open failed, try it again. */
85#define	FS_POSSIBLE	0x010	/* Force could have been set. */
86#define	FS_SETALT	0x020	/* Set alternate file name. */
87
88/* Flags to rcv_sync(). */
89#define	RCV_EMAIL	0x01	/* Send the user email, IFF file modified. */
90#define	RCV_ENDSESSION	0x02	/* End the file session. */
91#define	RCV_PRESERVE	0x04	/* Preserve backup file, IFF file modified. */
92#define	RCV_SNAPSHOT	0x08	/* Snapshot the recovery, and send email. */
93