1: # include <useful.h> 2: # include <pipes.h> 3: # include <sccs.h> 4: 5: SCCSID(@(#)IIpb_put.c 8.1 12/31/84) 6: 7: 8: /* 9: ** IIPB_PUT -- buffered put on pipe 10: ** 11: ** This routine puts the named data out onto the pipe 12: ** determined by ppb->pb_proc. 13: ** 14: ** Parameters: 15: ** dp -- a pointer to the data to write. 16: ** len -- the length of the data to write. 17: ** ppb -- a pointer to the pipe block. 18: ** 19: ** Returns: 20: ** none 21: ** 22: ** Side Effects: 23: ** none 24: ** 25: ** Trace Flags: 26: ** 18.8 - 18.15 27: */ 28: 29: IIpb_put(dp, len, ppb) 30: register char *dp; 31: register int len; 32: register pb_t *ppb; 33: { 34: register int i; 35: 36: 37: /* 38: ** Top loop. 39: ** Loop until we have run out of things to write. 40: */ 41: 42: while (len > 0) 43: { 44: /* compute the length to move */ 45: i = min(ppb->pb_nleft, len); 46: 47: /* move data into buffer and adjust ptrs & counts */ 48: IIbmove(dp, ppb->pb_xptr, i); 49: dp += i; 50: len -= i; 51: ppb->pb_xptr += i; 52: ppb->pb_nleft -= i; 53: ppb->pb_nused += i; 54: 55: /* flush block if full */ 56: if (ppb->pb_nleft <= 0) 57: IIpb_write(ppb); 58: } 59: }