Debian Codegraph @

recover.h

raw
1 /**************************************************************************
2 * This program is Copyright (C) 1986-2002 by Jonathan Payne. JOVE is *
3 * provided by Jonathan and Jovehacks without charge and without *
4 * warranty. You may copy, modify, and/or distribute JOVE, provided that *
5 * this notice is included in all the source files and documentation. *
6 **************************************************************************/
7
8 #ifdef RECOVER /* the body is the rest of this file */
9 #include "temp.h"
10
11 #ifndef UNIX
12 # define getuid() 0
13 #endif
14
15 /* Format of records within the jrec file: information to allow
16 * recovery from a crash.
17 *
18 * Note: the recovery info is
19 * (1) architecture dependent -- it contains longs, among other things
20 * (2) version dependent -- format 1 started in 4.15.16, version 2 in 4.17.2.8
21 * (3) configuration dependent -- affected by any change to FILESIZE
22 * RECMAGIC tries to encode all those things so we can at least detect
23 * mismatches (and perhaps, down the road, at least recover different
24 * configurations.
25 * Even though this uses long, which might be 64bits, we keep RECMAGIC
26 * to fit in 32bits, so that it can fit on most machines. Similarly,
27 * we only use long as a field width, to make this more uniform;
28 * wastes bits on 64bit machines (which can afford it) but is nice
29 * for 32bit machines (or even 16bit, since their long is usually 32bits)
30 * The bulk of any jrec file is the daddr pointers anyway.
31 */
32
33 #define LG_JBUFSIZMIN 7
34 #if LG_JBUFSIZ < LG_JBUFSIZMIN || (LG_JBUFSIZ-LG_JBUFSIZMIN) > 15
35 Error will not be able to encode recovery header LG_JBUFSIZ safely
36 #endif
37
38 #define LG_FILESIZEMIN 6
39 #if LG_FILESIZE < LG_FILESIZEMIN || (LG_FILESIZE-LG_FILESIZEMIN) > 15
40 Error will not be able to encode recovery header LG_FILESIZE safely
41 #endif
42
43 #if LG_CHNK_CHARS > 15
44 Error will not be able to encode recovery header LG_CHNK_CHARS safely
45 #endif
46
47 # define RECVER 2 /* JOVE recovery file, version 2 */
48 # define RECMAGIC (((((((((((((long)'J' << 4) | \
49 RECVER) << 4) | \
50 (LG_JBUFSIZ-LG_JBUFSIZMIN)) << 4) | \
51 sizeof(long)) << 4) | \
52 sizeof(daddr)) << 4) | \
53 (LG_FILESIZE-LG_FILESIZEMIN)) << 4) | \
54 LG_CHNK_CHARS)
55
56 struct rec_head {
57 long RecMagic; /* (partial) compatibility check */
58 long Uid; /* uid of owner */
59 long Pid; /* pid of jove process */
60 long UpdTime; /* last time this was updated */
61 long Nbuffers; /* number of buffers */
62 daddr FreePtr; /* position of DFree */
63 char TmpFileName[FILESIZE]; /* name of corresponding tempfile */
64 };
65
66 struct rec_entry {
67 char r_bname[FILESIZE],
68 r_fname[FILESIZE];
69 long r_nlines,
70 r_dotline, /* so we can really save the context */
71 r_dotchar;
72 };
73
74 #endif /* RECOVER */