1: /* $Header$ */
   2: 
   3: /*
   4:  * Author: Peter J. Nicklin
   5:  */
   6: 
   7: /*
   8:  * pbstretch() stretches the buffer by n characters just before the point
   9:  * marked by buffer pointer bp. Negative n shrinks the buffer by n
  10:  * characters. Returns integer NO if buffer space exceeded, otherwise YES.
  11:  */
  12: #include <stdio.h>
  13: #include "path.h"
  14: #include "pdb.h"
  15: #include "yesno.h"
  16: 
  17: extern char *CURPBUF;           /* current database buffer */
  18: extern PDB *CURPDB;         /* current database stream */
  19: 
  20: pbstretch(bp, n)
  21:     register char *bp;      /* buffer pointer */
  22:     int n;              /* stretch amount */
  23: {
  24:     register char *lowerbp;     /* lower roving buffer pointer */
  25:     register char *upperbp;     /* upper roving buffer pointer */
  26:     char *sprintf();        /* print output to string */
  27: 
  28:     if (n > 0)
  29:         {
  30:         for (lowerbp = bp; *lowerbp != '\0'; lowerbp++)
  31:             continue;
  32:         upperbp = lowerbp + n;
  33:         if (upperbp >= CURPBUF + PBUFSIZE)
  34:             {
  35:             sprintf(CURPDB->perr, "%s database buffer exceeded",
  36:                 CURPDB->path);
  37:             CURPDB->flag |= _PERR;
  38:             return(NO);
  39:             }
  40:         while (lowerbp >= bp)
  41:             *upperbp-- = *lowerbp--;
  42:         }
  43:     else if (n < 0)
  44:         {
  45:         for (upperbp = bp; *upperbp != '\0'; upperbp++)
  46:             continue;
  47:         lowerbp = bp - n;
  48:         if (lowerbp >= upperbp)
  49:             *bp = '\0';
  50:         while (lowerbp <= upperbp)
  51:             *bp++ = *lowerbp++;
  52:         }
  53:     return(YES);
  54: }
Last modified: 1985-07-03
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 554
Valid CSS Valid XHTML 1.0 Strict