2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
5 * %sccs.include.redist.c%
7 * $Id: exf.h,v 8.20 1993/12/28 16:39:54 bostic Exp $ (Berkeley) $Date: 1993/12/28 16:39:54 $
15 int refcnt
; /* Reference count. */
17 /* Underlying database state. */
18 DB
*db
; /* File db structure. */
19 char *c_lp
; /* Cached line. */
20 size_t c_len
; /* Cached line length. */
21 recno_t c_lno
; /* Cached line number. */
22 recno_t c_nlines
; /* Cached lines in the file. */
24 DB
*log
; /* Log db structure. */
25 char *l_lp
; /* Log buffer. */
26 size_t l_len
; /* Log buffer length. */
27 recno_t l_high
; /* Log last + 1 record number. */
28 recno_t l_cur
; /* Log current record number. */
29 MARK l_cursor
; /* Log cursor position. */
30 enum direction lundo
; /* Last undo direction. */
32 LIST_HEAD(_markh
, _mark
) marks
; /* Linked list of file MARK's. */
35 * Paths for the recovery mail file and the vi recovery file and
36 * a file descriptor for the former. We keep a file descriptor
37 * to the recovery file open and locked, while the file is in use.
38 * This allows the recovery option to distinguish between files
39 * that are live, and those that should be recovered.
41 * F_RCV_ON is set as long as we believe that the file is recoverable.
42 * This doesn't mean that any initialization has been done, however.
43 * If F_RCV_NORM is not set and rcv_path and rcv_mpath are not NULL,
44 * they are unlinked on file exit. If not NULL they are free'd on file
45 * exit. On file exit, if rcv_fd is not -1, it is closed.
47 #define RCV_PERIOD 120 /* Sync every two minutes. */
48 char *rcv_path
; /* Recover file name. */
49 char *rcv_mpath
; /* Recover mail file name. */
50 int rcv_fd
; /* Locked mail file descriptor. */
52 #define F_FIRSTMODIFY 0x001 /* File not yet modified. */
53 #define F_MODIFIED 0x002 /* File is currently dirty. */
54 #define F_MULTILOCK 0x004 /* Multiple processes running, lock. */
55 #define F_NOLOG 0x008 /* Logging turned off. */
56 #define F_RCV_ALRM 0x010 /* File needs to be synced. */
57 #define F_RCV_NORM 0x020 /* Don't delete recovery files. */
58 #define F_RCV_ON 0x040 /* Recovery is possible. */
59 #define F_UNDO 0x080 /* No change since last undo. */
63 /* Flags to file_write(). */
64 #define FS_ALL 0x01 /* Write the entire file. */
65 #define FS_APPEND 0x02 /* Append to the file. */
66 #define FS_FORCE 0x04 /* Force is set. */
67 #define FS_POSSIBLE 0x08 /* Force could be set. */
69 #define GETLINE_ERR(sp, lno) { \
71 "Error: %s/%d: unable to retrieve line %u.", \
72 tail(__FILE__), __LINE__, (lno)); \
76 FREF
*file_add
__P((SCR
*, FREF
*, CHAR_T
*, int));
77 FREF
*file_first
__P((SCR
*));
78 FREF
*file_next
__P((SCR
*, FREF
*));
79 FREF
*file_prev
__P((SCR
*, FREF
*));
80 FREF
*file_unedited
__P((SCR
*));
83 int file_end
__P((SCR
*, EXF
*, int));
84 int file_init
__P((SCR
*, FREF
*, char *, int));
85 int file_write
__P((SCR
*, EXF
*, MARK
*, MARK
*, char *, int));
87 /* Recovery routines. */
88 void rcv_hup
__P((void));
89 int rcv_init
__P((SCR
*, EXF
*));
90 int rcv_list
__P((SCR
*));
91 int rcv_read
__P((SCR
*, char *));
92 int rcv_sync
__P((SCR
*, EXF
*));
93 void rcv_term
__P((void));
94 int rcv_tmp
__P((SCR
*, EXF
*, char *));
96 /* DB interface routines */
97 int file_aline
__P((SCR
*, EXF
*, int, recno_t
, char *, size_t));
98 int file_dline
__P((SCR
*, EXF
*, recno_t
));
99 char *file_gline
__P((SCR
*, EXF
*, recno_t
, size_t *));
100 int file_iline
__P((SCR
*, EXF
*, recno_t
, char *, size_t));
101 int file_lline
__P((SCR
*, EXF
*, recno_t
*));
102 char *file_rline
__P((SCR
*, EXF
*, recno_t
, size_t *));
103 int file_sline
__P((SCR
*, EXF
*, recno_t
, char *, size_t));