1: # include "ctlmod.h" 2: # include "pipes.h" 3: # include <sccs.h> 4: 5: SCCSID(@(#)pb_prime.c 8.1 12/31/84) 6: 7: /* 8: ** PB_PRIME -- prime a pipe for reading or writing 9: ** 10: ** This clears out any nasty stuff in the pipe block. If 11: ** we are reading, it reads the first block so that we can 12: ** know what sort it is. 13: ** 14: ** Parameters: 15: ** ppb -- a pointer to the pipe block. 16: ** type -- if PB_NOTYPE, we are setting for reading. 17: ** Otherwise, we are setting to write a 18: ** message of the indicated type. 19: ** 20: ** Returns: 21: ** none 22: ** 23: ** Side Effects: 24: ** Changes *ppb. 25: ** 26: ** Trace Flags: 27: ** 12.0 28: */ 29: 30: pb_prime(ppb, type) 31: register pb_t *ppb; 32: int type; 33: { 34: # ifdef xCTR2 35: if (tTf(12, 0)) 36: lprintf("pb_prime: type %d\n", type); 37: # endif 38: if (type == PB_NOTYPE) 39: { 40: /* read pipe prime -- get the first block */ 41: pb_read(ppb); 42: } 43: else 44: { 45: /* write pipe prime -- set up initial pointers */ 46: ppb->pb_from = Cm.cm_myproc; 47: ppb->pb_type = type; 48: ppb->pb_stat = 0; 49: ppb->pb_nleft = PB_DBSIZE; 50: ppb->pb_nused = 0; 51: } 52: 53: /* do common initialization */ 54: ppb->pb_xptr = ppb->pb_data; 55: }