# 2.11BSD#431 - /usr/src/ucb/ex/ex_temp.h

##### Variables

    H                 X
    iblock            X
    iblock2           X
    ibuff             X
    ibuff2            X
    ninbuf            X
    nleft             X
    oblock            X
    obuff             X
    tline             X

##### Macros

    BLKMSK            X
    BNDRY             X
    INCRMT            X
    LBTMSK            X
    NMBLKS            X
    OFFBTS            X
    OFFMSK            X
    SHFT              X
    blocks            X
    flines            X
    savedfile         X
    uid               X

##### struct's

    header            X

       1: /*
       2:  * Copyright (c) 1980 Regents of the University of California.
       3:  * All rights reserved.  The Berkeley software License Agreement
       4:  * specifies the terms and conditions for redistribution.
       5:  *
       6:  *	@(#)ex_temp.h	7.4 (Berkeley) 5/31/85
       7:  */
       8:
       9: /*
      10:  * The editor uses a temporary file for files being edited, in a structure
      11:  * similar to that of ed.  The first block of the file is used for a header
      12:  * block which guides recovery after editor/system crashes.
      13:  * Lines are represented in core by a pointer into the temporary file which
      14:  * is packed into 16 bits (32 on VMUNIX).  All but the low bit index the temp
      15:  * file; the last is used by global commands.  The parameters below control
      16:  * how much the other bits are shifted left before they index the temp file.
      17:  * Larger shifts give more slop in the temp file but allow larger files
      18:  * to be edited.
      19:  *
      20:  * The editor does not garbage collect the temporary file.  When a new
      21:  * file is edited, the temporary file is rather discarded and a new one
      22:  * created for the new file.  Garbage collection would be rather complicated
      23:  * in ex because of the general undo, and in any case would require more
      24:  * work when throwing lines away because marks would have be carefully
      25:  * checked before reallocating temporary file space.  Said another way,
      26:  * each time you create a new line in the temporary file you get a unique
      27:  * number back, and this is a property used by marks.
      28:  *
      29:  * The following temp file parameters allow 256k bytes in the temporary
      30:  * file.  By changing to the numbers in comments you can get 512k.
      31:  * For VMUNIX you get more than you could ever want.
      32:  * VMUNIX uses long (32 bit) integers giving much more
      33:  * space in the temp file and no waste.  This doubles core
      34:  * requirements but allows files of essentially unlimited size to be edited.
      35:  */
      36: #ifndef VMUNIX
      37: #define BLKMSK  0777        /* 01777 */
      38: #define BNDRY   8       /* 16 */
      39: #define INCRMT  0200        /* 0100 */
      40: #define LBTMSK  0770        /* 0760 */
      41: #define NMBLKS  506     /* 1018 */
      42: #define OFFBTS  7       /* 6 */
      43: #define OFFMSK  0177        /* 077 */
      44: #define SHFT    2       /* 3 */
      45: #else
      46: #define BLKMSK  077777
      47: #define BNDRY   2
      48: #define INCRMT  02000
      49: #define LBTMSK  01776
      50: #define NMBLKS  077770
      51: #define OFFBTS  10
      52: #define OFFMSK  01777
      53: #define SHFT    0
      54: #endif
      55:
      56: /*
      57:  * The editor uses three buffers into the temporary file (ed uses two
      58:  * and is very similar).  These are two read buffers and one write buffer.
      59:  * Basically, the editor deals with the file as a sequence of BUFSIZ character
      60:  * blocks.  Each block contains some number of lines (and lines
      61:  * can run across block boundaries.
      62:  *
      63:  * New lines are written into the last block in the temporary file
      64:  * which is in core as obuf.  When a line is needed which isn't in obuf,
      65:  * then it is brought into an input buffer.  As there are two, the choice
      66:  * is to take the buffer into which the last read (of the two) didn't go.
      67:  * Thus this is a 2 buffer LRU replacement strategy.  Measurement
      68:  * shows that this saves roughly 25% of the buffer reads over a one
      69:  * input buffer strategy.  Since the editor (on our VAX over 1 week)
      70:  * spends (spent) roughly 30% of its time in the system read routine,
      71:  * this can be a big help.
      72:  */
      73: var bool    hitin2;     /* Last read hit was ibuff2 not ibuff */
      74: var bool    ichang2;    /* Have actually changed ibuff2 */
      75: var bool    ichanged;   /* Have actually changed ibuff */
      76: var short   iblock;     /* Temp file block number of ibuff (or -1) */
      77: var short   iblock2;    /* Temp file block number of ibuff2 (or -1) */
      78: var short   ninbuf;     /* Number useful chars left in input buffer */
      79: var short   nleft;      /* Number usable chars left in output buffer */
      80: var short   oblock;     /* Temp file block number of obuff (or -1) */
      81: #ifndef VMUNIX
      82: var short   tline;      /* Current temp file ptr */
      83: #else
      84: var int tline;
      85: #endif
      86:
      87: var char    ibuff[BUFSIZ];
      88: var char    ibuff2[BUFSIZ];
      89: var char    obuff[BUFSIZ];
      90:
      91: /*
      92:  * Structure of the descriptor block which resides
      93:  * in the first block of the temporary file and is
      94:  * the guiding light for crash recovery.
      95:  *
      96:  * As the Blocks field below implies, there are temporary file blocks
      97:  * devoted to (some) image of the incore array of pointers into the temp
      98:  * file.  Thus, to recover from a crash we use these indices to get the
      99:  * line pointers back, and then use the line pointers to get the text back.
     100:  * Except for possible lost lines due to sandbagged I/O, the entire
     101:  * file (at the time of the last editor "sync") can be recovered from
     102:  * the temp file.
     103:  */
     104:
     105: /* This definition also appears in expreserve.c... beware */
     106: struct  header {
     107:     time_t  Time;           /* Time temp file last updated */
     108:     int Uid;
     109: #ifndef VMUNIX
     110:     short   Flines;         /* Number of lines in file */
     111: #else
     112:     int Flines;
     113: #endif
     114:     char    Savedfile[FNSIZE];  /* The current file name */
     115:     short   Blocks[LBLKS];      /* Blocks where line pointers stashed */
     116: };
     117: var struct  header H;
     118:
     119: #define uid     H.Uid
     120: #define flines      H.Flines
     121: #define savedfile   H.Savedfile
     122: #define blocks      H.Blocks

#### Defined variables

H defined in line 117; used 32 times

- in line 119-122(4)
- in /usr/src/ucb/ex/ex_temp.c line 278-280(2), 304(3)
- in /usr/src/ucb/ex/exrecover.c line 103-112(3), 118, 127-130(3), 136, 261(3), 269, 342-343(2), 411(3), 457, 463, 489(3), 496

iblock defined in line 76; used 9 times

- in /usr/src/ucb/ex/ex_temp.c line 44, 163, 188-191(2), 271
- in /usr/src/ucb/ex/exrecover.c line 81, 726, 734-736(2)

iblock2 defined in line 77; used 5 times

- in /usr/src/ucb/ex/ex_temp.c line 45, 168, 178-181(2), 274

ibuff defined in line 87; used 9 times

- in /usr/src/ucb/ex/ex_temp.c line 166, 188-193(3), 271
- in /usr/src/ucb/ex/exrecover.c line 728, 734-738(3)

ibuff2 defined in line 88; used 5 times

- in /usr/src/ucb/ex/ex_temp.c line 171, 178-184(3), 274

ninbuf defined in line 78; used 6 times

- in /usr/src/ucb/ex/ex_io.c line 645-647(3), 656, 814
- in /usr/src/ucb/ex/exrecover.c line 684

nleft defined in line 79; used 11 times

- in /usr/src/ucb/ex/ex_io.c line 202, 254-258(2)
- in /usr/src/ucb/ex/ex_temp.c line 108-113(2), 128, 138, 162
- in /usr/src/ucb/ex/exrecover.c line 702-707(2), 725

oblock defined in line 80; used 13 times

- in /usr/src/ucb/ex/ex_temp.c line 46, 173, 195-198(3), 276-277(2), 288
- in /usr/src/ucb/ex/exrecover.c line 81, 730, 740-742(3)

obuff defined in line 89; used 7 times

- in /usr/src/ucb/ex/ex_temp.c line 174, 196-199(2), 277
- in /usr/src/ucb/ex/exrecover.c line 731, 741-743(2)

tline defined in line 84; used 9 times

- in /usr/src/ucb/ex/ex_temp.c line 35-39(2), 126, 141-142(2), 283-287(4)

#### Defined struct's

header defined in line 106; used 2 times

- in line 117(2)

#### Defined macros

BLKMSK defined in line 46; used 4 times

- in /usr/src/ucb/ex/ex_temp.c line 158, 284
- in /usr/src/ucb/ex/exrecover.c line 538, 721

BNDRY defined in line 47; used 2 times

- in /usr/src/ucb/ex/ex_temp.c line 142
- in /usr/src/ucb/ex/exrecover.c line 537

INCRMT defined in line 48; used 6 times

- in /usr/src/ucb/ex/ex_temp.c line 35-39(2), 112, 137, 287
- in /usr/src/ucb/ex/exrecover.c line 706

LBTMSK defined in line 49; used 2 times

- in /usr/src/ucb/ex/ex_temp.c line 159
- in /usr/src/ucb/ex/exrecover.c line 722

NMBLKS defined in line 50; used 3 times

- in /usr/src/ucb/ex/ex_temp.c line 160, 285
- in /usr/src/ucb/ex/exrecover.c line 723

OFFBTS defined in line 51; used 5 times

- in /usr/src/ucb/ex/ex_temp.c line 158, 284
- in /usr/src/ucb/ex/exrecover.c line 538, 562, 721

OFFMSK defined in line 52; used 5 times

- in /usr/src/ucb/ex/ex_temp.c line 109, 129, 283(2)
- in /usr/src/ucb/ex/exrecover.c line 703

SHFT defined in line 53; used 6 times

- in /usr/src/ucb/ex/ex_temp.c line 142, 159
- in /usr/src/ucb/ex/exrecover.c line 537, 562, 579, 722

blocks defined in line 122; used 5 times

- in /usr/src/ucb/ex/ex_temp.c line 40-42(3), 281
- in /usr/src/ucb/ex/exrecover.c line 128

flines defined in line 120; used 1 times

- in /usr/src/ucb/ex/ex_temp.c line 302

savedfile defined in line 121; used 23 times

- in /usr/src/ucb/ex/ex.c line 276
- in /usr/src/ucb/ex/ex_cmds.c line 206, 219, 534
- in /usr/src/ucb/ex/ex_cmds2.c line 249-251(3)
- in /usr/src/ucb/ex/ex_cmdsub.c line 626
- in /usr/src/ucb/ex/ex_io.c line 52-54(2), 66, 79-83(3), 174, 528, 534, 607, 627, 739
- in /usr/src/ucb/ex/ex_unix.c line 75
- in /usr/src/ucb/ex/exrecover.c line 344, 494

uid defined in line 119; used 1 times

- in /usr/src/ucb/ex/ex_temp.c line 279

#### Usage of this include

ex_temp.h used 10 times

- in /usr/src/ucb/ex/ex.c line 17
- in /usr/src/ucb/ex/ex_cmds.c line 13
- in /usr/src/ucb/ex/ex_cmds2.c line 13
- in /usr/src/ucb/ex/ex_cmdsub.c line 13
- in /usr/src/ucb/ex/ex_extern.c line 23
- in /usr/src/ucb/ex/ex_io.c line 13
- in /usr/src/ucb/ex/ex_set.c line 12
- in /usr/src/ucb/ex/ex_temp.c line 12
- in /usr/src/ucb/ex/ex_unix.c line 12
- in /usr/src/ucb/ex/exrecover.c line 21

Last modified: 1987-02-17 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1084 |