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