1: /* $Header: backpage.c,v 4.3 85/05/01 11:36:03 lwall Exp $
   2:  *
   3:  * $Log:	backpage.c,v $
   4:  * Revision 4.3  85/05/01  11:36:03  lwall
   5:  * Baseline for release with 4.3bsd.
   6:  *
   7:  */
   8: 
   9: #include "EXTERN.h"
  10: #include "common.h"
  11: #include "intrp.h"
  12: #include "final.h"
  13: #include "INTERN.h"
  14: #include "backpage.h"
  15: 
  16: ART_LINE maxindx = -1;
  17: long lseek();
  18: 
  19: void
  20: backpage_init()
  21: {
  22:     char *varyname;
  23: 
  24:     varyname = filexp(VARYNAME);
  25:     close(creat(varyname,0600));
  26:     varyfd = open(varyname,2);
  27:     UNLINK(varyname);
  28:     if (varyfd < 0) {
  29:     printf(cantopen,varyname) FLUSH;
  30:     sig_catcher(0);
  31:     }
  32: 
  33: }
  34: 
  35: /* virtual array read */
  36: 
  37: ART_POS
  38: vrdary(indx)
  39: ART_LINE indx;
  40: {
  41:     int subindx;
  42:     long offset;
  43: 
  44: #ifdef DEBUGGING
  45:     if (indx > maxindx) {
  46:     printf("vrdary(%ld) > %ld\n",(long)indx, (long)maxindx) FLUSH;
  47:     return 0;
  48:     }
  49: #endif
  50:     if (indx < 0)
  51:     return 0;
  52:     subindx = indx % VARYSIZE;
  53:     offset = (indx - subindx) * sizeof(varybuf[0]);
  54:     if (offset != oldoffset) {
  55:     if (oldoffset >= 0) {
  56: #ifndef lint
  57:         (void)lseek(varyfd,oldoffset,0);
  58:         write(varyfd, (char *)varybuf,sizeof(varybuf));
  59: #endif lint
  60:     }
  61: #ifndef lint
  62:     (void)lseek(varyfd,offset,0);
  63:     read(varyfd,(char *)varybuf,sizeof(varybuf));
  64: #endif lint
  65:     oldoffset = offset;
  66:     }
  67:     return varybuf[subindx];
  68: }
  69: 
  70: /* write to virtual array */
  71: 
  72: void
  73: vwtary(indx,newvalue)
  74: ART_LINE indx;
  75: ART_POS newvalue;
  76: {
  77:     int subindx;
  78:     long offset;
  79: 
  80: #ifdef DEBUGGING
  81:     if (indx < 0)
  82:     printf("vwtary(%ld)\n",(long)indx) FLUSH;
  83:     if (!indx)
  84:     maxindx = 0;
  85:     if (indx > maxindx) {
  86:     if (indx != maxindx + 1)
  87:         printf("indx skipped %d-%d\n",maxindx+1,indx-1) FLUSH;
  88:     maxindx = indx;
  89:     }
  90: #endif
  91:     subindx = indx % VARYSIZE;
  92:     offset = (indx - subindx) * sizeof(varybuf[0]);
  93:     if (offset != oldoffset) {
  94:     if (oldoffset >= 0) {
  95: #ifndef lint
  96:         (void)lseek(varyfd,oldoffset,0);
  97:         write(varyfd,(char *)varybuf,sizeof(varybuf));
  98: #endif lint
  99:     }
 100: #ifndef lint
 101:     (void)lseek(varyfd,offset,0);
 102:     read(varyfd,(char *)varybuf,sizeof(varybuf));
 103: #endif lint
 104:     oldoffset = offset;
 105:     }
 106:     varybuf[subindx] = newvalue;
 107: }

Defined functions

backpage_init defined in line 19; used 2 times
vrdary defined in line 37; used 8 times
vwtary defined in line 72; used 5 times

Defined variables

maxindx defined in line 16; used 7 times
Last modified: 1987-03-16
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2658
Valid CSS Valid XHTML 1.0 Strict