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