1: # include   <useful.h>
   2: # include   <pipes.h>
   3: # include   <sccs.h>
   4: 
   5: SCCSID(@(#)IIpb_get.c	8.1	12/31/84)
   6: 
   7: 
   8: /*
   9: **  IIPB_GET -- buffered get from pipe
  10: **
  11: **	This routine just gets a record from the pipe block, reading
  12: **	if necessary.  It tries to do things in big chunks to keep
  13: **	the overhead down.
  14: **
  15: **	Parameters:
  16: **		ppb -- a pointer to the pipe block to unbuffer.
  17: **		dp -- a pointer to the data area.
  18: **		len -- the number of bytes to read.
  19: **
  20: **	Returns:
  21: **		The number of bytes actually read.
  22: **		Zero on end of file.
  23: **
  24: **	Side Effects:
  25: **		none.
  26: **
  27: **	Trace Flags:
  28: **		18.1 - 18.7
  29: */
  30: 
  31: IIpb_get(ppb, dp, len)
  32: register pb_t   *ppb;
  33: char        *dp;
  34: register int    len;
  35: {
  36:     int     rct;
  37:     register int    i;
  38: 
  39:     rct = 0;
  40: 
  41:     /*
  42: 	**  Top Loop.
  43: 	**	As long as we still want more, keep buffering out.
  44: 	*/
  45: 
  46:     while (len > 0)
  47:     {
  48:         /* if we have no data, read another block */
  49:         while (ppb->pb_nleft <= 0)
  50:         {
  51:             if (bitset(PB_EOF, ppb->pb_stat))
  52:                 return (rct);
  53:             IIpb_read(ppb);
  54:         }
  55: 
  56:         /*
  57: 		**  Compute the length to move.
  58: 		**	This is the min of the amount we want and the
  59: 		**	amount we have available to us in the buffer.
  60: 		*/
  61: 
  62:         i = min(ppb->pb_nleft, len);
  63:         IIbmove(ppb->pb_xptr, dp, i);
  64:         ppb->pb_xptr += i;
  65:         ppb->pb_nleft -= i;
  66:         dp += i;
  67:         len -= i;
  68:         rct += i;
  69:     }
  70: 
  71:     return (rct);
  72: }
Last modified: 1986-04-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 858
Valid CSS Valid XHTML 1.0 Strict