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