xref: /openbsd/usr.bin/vi/common/exf.h (revision 5f9c94e5)
1*5f9c94e5Stb /*	$OpenBSD: exf.h,v 1.6 2022/02/20 19:45:51 tb Exp $	*/
2d4e7c603Sniklas 
3df930be7Sderaadt /*-
4df930be7Sderaadt  * Copyright (c) 1992, 1993, 1994
5df930be7Sderaadt  *	The Regents of the University of California.  All rights reserved.
645f2ab88Sderaadt  * Copyright (c) 1992, 1993, 1994, 1995, 1996
745f2ab88Sderaadt  *	Keith Bostic.  All rights reserved.
8df930be7Sderaadt  *
945f2ab88Sderaadt  * See the LICENSE file for redistribution information.
10df930be7Sderaadt  *
11a513d41bSmichaels  *	@(#)exf.h	10.7 (Berkeley) 7/9/96
12df930be7Sderaadt  */
13df930be7Sderaadt 					/* Undo direction. */
14df930be7Sderaadt /*
15df930be7Sderaadt  * exf --
16df930be7Sderaadt  *	The file structure.
17df930be7Sderaadt  */
18df930be7Sderaadt struct _exf {
19df930be7Sderaadt 	int	 refcnt;		/* Reference count. */
20df930be7Sderaadt 
21df930be7Sderaadt 					/* Underlying database state. */
22df930be7Sderaadt 	DB	*db;			/* File db structure. */
23df930be7Sderaadt 	char	*c_lp;			/* Cached line. */
24df930be7Sderaadt 	size_t	 c_len;			/* Cached line length. */
25df930be7Sderaadt 	recno_t	 c_lno;			/* Cached line number. */
26df930be7Sderaadt 	recno_t	 c_nlines;		/* Cached lines in the file. */
27df930be7Sderaadt 
28df930be7Sderaadt 	DB	*log;			/* Log db structure. */
29df930be7Sderaadt 	char	*l_lp;			/* Log buffer. */
30df930be7Sderaadt 	size_t	 l_len;			/* Log buffer length. */
31df930be7Sderaadt 	recno_t	 l_high;		/* Log last + 1 record number. */
32df930be7Sderaadt 	recno_t	 l_cur;			/* Log current record number. */
33df930be7Sderaadt 	MARK	 l_cursor;		/* Log cursor position. */
3445f2ab88Sderaadt 	dir_t	 lundo;			/* Last undo direction. */
35df930be7Sderaadt 
36df930be7Sderaadt 	LIST_HEAD(_markh, _lmark) marks;/* Linked list of file MARK's. */
37df930be7Sderaadt 
3845f2ab88Sderaadt 	dev_t	 mdev;			/* Device. */
3945f2ab88Sderaadt 	ino_t	 minode;		/* Inode. */
40e5f69368Sbrynet 	struct timespec	mtim;		/* Last modification time. */
41df930be7Sderaadt 
42df930be7Sderaadt 	int	 fcntl_fd;		/* Fcntl locking fd; see exf.c. */
43df930be7Sderaadt 
44df930be7Sderaadt 	/*
45df930be7Sderaadt 	 * Recovery in general, and these fields specifically, are described
46df930be7Sderaadt 	 * in recover.c.
47df930be7Sderaadt 	 */
48df930be7Sderaadt #define	RCV_PERIOD	120		/* Sync every two minutes. */
49df930be7Sderaadt 	char	*rcv_path;		/* Recover file name. */
50df930be7Sderaadt 	char	*rcv_mpath;		/* Recover mail file name. */
51df930be7Sderaadt 	int	 rcv_fd;		/* Locked mail file descriptor. */
52df930be7Sderaadt 
53a513d41bSmichaels #define	F_DEVSET	0x001		/* mdev/minode fields initialized. */
54a513d41bSmichaels #define	F_FIRSTMODIFY	0x002		/* File not yet modified. */
55a513d41bSmichaels #define	F_MODIFIED	0x004		/* File is currently dirty. */
56a513d41bSmichaels #define	F_MULTILOCK	0x008		/* Multiple processes running, lock. */
57a513d41bSmichaels #define	F_NOLOG		0x010		/* Logging turned off. */
58a513d41bSmichaels #define	F_RCV_NORM	0x020		/* Don't delete recovery files. */
59a513d41bSmichaels #define	F_RCV_ON	0x040		/* Recovery is possible. */
60a513d41bSmichaels #define	F_UNDO		0x080		/* No change since last undo. */
61*5f9c94e5Stb #define	F_RCV_SYNC	0x100		/* Recovery file sync needed. */
62*5f9c94e5Stb 	u_int16_t flags;
63df930be7Sderaadt };
64df930be7Sderaadt 
6545f2ab88Sderaadt /* Flags to db_get(). */
6645f2ab88Sderaadt #define	DBG_FATAL	0x001	/* If DNE, error message. */
6745f2ab88Sderaadt #define	DBG_NOCACHE	0x002	/* Ignore the front-end cache. */
68df930be7Sderaadt 
6945f2ab88Sderaadt /* Flags to file_init() and file_write(). */
7045f2ab88Sderaadt #define	FS_ALL		0x001	/* Write the entire file. */
7145f2ab88Sderaadt #define	FS_APPEND	0x002	/* Append to the file. */
7245f2ab88Sderaadt #define	FS_FORCE	0x004	/* Force is set. */
7345f2ab88Sderaadt #define	FS_OPENERR	0x008	/* Open failed, try it again. */
7445f2ab88Sderaadt #define	FS_POSSIBLE	0x010	/* Force could have been set. */
7545f2ab88Sderaadt #define	FS_SETALT	0x020	/* Set alternate file name. */
76df930be7Sderaadt 
7745f2ab88Sderaadt /* Flags to rcv_sync(). */
78df930be7Sderaadt #define	RCV_EMAIL	0x01	/* Send the user email, IFF file modified. */
79df930be7Sderaadt #define	RCV_ENDSESSION	0x02	/* End the file session. */
80df930be7Sderaadt #define	RCV_PRESERVE	0x04	/* Preserve backup file, IFF file modified. */
81df930be7Sderaadt #define	RCV_SNAPSHOT	0x08	/* Snapshot the recovery, and send email. */
82