1/*-
2 * Copyright (c) 1992, 1993, 1994
3 *	The Regents of the University of California.  All rights reserved.
4 * Copyright (c) 1992, 1993, 1994, 1995, 1996
5 *	Keith Bostic.  All rights reserved.
6 *
7 * See the LICENSE file for redistribution information.
8 *
9 *	$Id: exf.h,v 10.10 2012/07/06 16:03:37 zy Exp $
10 */
11					/* Undo direction. */
12/*
13 * exf --
14 *	The file structure.
15 */
16struct _exf {
17	int	 refcnt;		/* Reference count. */
18
19					/* Underlying database state. */
20	DB	*db;			/* File db structure. */
21	CHAR_T	*c_lp;			/* Cached line. */
22	size_t	 c_len;			/* Cached line length. */
23	size_t	 c_blen;		/* Cached line buffer length. */
24	recno_t	 c_lno;			/* Cached line number. */
25	recno_t	 c_nlines;		/* Cached lines in the file. */
26
27	DB	*log;			/* Log db structure. */
28	char	*l_lp;			/* Log buffer. */
29	size_t	 l_len;			/* Log buffer length. */
30	recno_t	 l_high;		/* Log last + 1 record number. */
31	recno_t	 l_cur;			/* Log current record number. */
32	MARK	 l_cursor;		/* Log cursor position. */
33	dir_t	 lundo;			/* Last undo direction. */
34
35					/* Linked list of file MARK's. */
36	SLIST_HEAD(_markh, _lmark) marks[1];
37
38	dev_t		 mdev;		/* Device. */
39	ino_t		 minode;	/* Inode. */
40	struct timespec	 mtim;		/* Last modification time. */
41
42	/*
43	 * Recovery in general, and these fields specifically, are described
44	 * in recover.c.
45	 */
46#define	RCV_PERIOD	120		/* Sync every two minutes. */
47	char	*rcv_path;		/* Recover file name. */
48	char	*rcv_mpath;		/* Recover mail file name. */
49	int	 rcv_fd;		/* Locked mail file descriptor. */
50
51#define	F_DEVSET	0x001		/* mdev/minode fields initialized. */
52#define	F_FIRSTMODIFY	0x002		/* File not yet modified. */
53#define	F_MODIFIED	0x004		/* File is currently dirty. */
54#define	F_MULTILOCK	0x008		/* Multiple processes running, lock. */
55#define	F_NOLOG		0x010		/* Logging turned off. */
56#define	F_RCV_NORM	0x020		/* Don't delete recovery files. */
57#define	F_RCV_ON	0x040		/* Recovery is possible. */
58#define	F_UNDO		0x080		/* No change since last undo. */
59	u_int8_t flags;
60};
61
62/* Flags to db_get(). */
63#define	DBG_FATAL	0x001	/* If DNE, error message. */
64#define	DBG_NOCACHE	0x002	/* Ignore the front-end cache. */
65
66/* Flags to file_init() and file_write(). */
67#define	FS_ALL		0x001	/* Write the entire file. */
68#define	FS_APPEND	0x002	/* Append to the file. */
69#define	FS_FORCE	0x004	/* Force is set. */
70#define	FS_OPENERR	0x008	/* Open failed, try it again. */
71#define	FS_POSSIBLE	0x010	/* Force could have been set. */
72#define	FS_SETALT	0x020	/* Set alternate file name. */
73
74/* Flags to rcv_sync(). */
75#define	RCV_EMAIL	0x01	/* Send the user email, IFF file modified. */
76#define	RCV_ENDSESSION	0x02	/* End the file session. */
77#define	RCV_PRESERVE	0x04	/* Preserve backup file, IFF file modified. */
78#define	RCV_SNAPSHOT	0x08	/* Snapshot the recovery, and send email. */
79