Lines Matching refs:rstrm

190 	RECSTREAM *rstrm = mem_alloc(sizeof(RECSTREAM));  in xdrrec_create()  local
192 if (rstrm == NULL) { in xdrrec_create()
201 rstrm->sendsize = sendsize = fix_buf_size(sendsize); in xdrrec_create()
202 rstrm->out_base = malloc(rstrm->sendsize); in xdrrec_create()
203 if (rstrm->out_base == NULL) { in xdrrec_create()
205 mem_free(rstrm, sizeof(RECSTREAM)); in xdrrec_create()
209 rstrm->recvsize = recvsize = fix_buf_size(recvsize); in xdrrec_create()
210 rstrm->in_base = malloc(recvsize); in xdrrec_create()
211 if (rstrm->in_base == NULL) { in xdrrec_create()
213 mem_free(rstrm->out_base, sendsize); in xdrrec_create()
214 mem_free(rstrm, sizeof(RECSTREAM)); in xdrrec_create()
221 xdrs->x_private = rstrm; in xdrrec_create()
222 rstrm->tcp_handle = tcp_handle; in xdrrec_create()
223 rstrm->readit = readit; in xdrrec_create()
224 rstrm->writeit = writeit; in xdrrec_create()
225 rstrm->out_finger = rstrm->out_boundry = rstrm->out_base; in xdrrec_create()
226 rstrm->frag_header = (uint32_t *)(void *)rstrm->out_base; in xdrrec_create()
227 rstrm->out_finger += sizeof(uint32_t); in xdrrec_create()
228 rstrm->out_boundry += sendsize; in xdrrec_create()
229 rstrm->frag_sent = FALSE; in xdrrec_create()
230 rstrm->in_size = recvsize; in xdrrec_create()
231 rstrm->in_boundry = rstrm->in_base; in xdrrec_create()
232 rstrm->in_finger = (rstrm->in_boundry += recvsize); in xdrrec_create()
233 rstrm->fbtbc = 0; in xdrrec_create()
234 rstrm->last_frag = TRUE; in xdrrec_create()
235 rstrm->in_haveheader = FALSE; in xdrrec_create()
236 rstrm->in_hdrlen = 0; in xdrrec_create()
237 rstrm->in_hdrp = (char *)(void *)&rstrm->in_header; in xdrrec_create()
238 rstrm->nonblock = FALSE; in xdrrec_create()
239 rstrm->in_reclen = 0; in xdrrec_create()
240 rstrm->in_received = 0; in xdrrec_create()
252 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); in xdrrec_getlong() local
253 int32_t *buflp = (int32_t *)(void *)(rstrm->in_finger); in xdrrec_getlong()
257 if ((rstrm->fbtbc >= (long)sizeof(int32_t)) && in xdrrec_getlong()
258 (((uintptr_t)rstrm->in_boundry - (uintptr_t)buflp) >= sizeof(int32_t))) { in xdrrec_getlong()
260 rstrm->fbtbc -= sizeof(int32_t); in xdrrec_getlong()
261 rstrm->in_finger += sizeof(int32_t); in xdrrec_getlong()
274 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); in xdrrec_putlong() local
275 int32_t *dest_lp = ((int32_t *)(void *)(rstrm->out_finger)); in xdrrec_putlong()
277 if ((rstrm->out_finger += sizeof(int32_t)) > rstrm->out_boundry) { in xdrrec_putlong()
282 rstrm->out_finger -= sizeof(int32_t); in xdrrec_putlong()
283 rstrm->frag_sent = TRUE; in xdrrec_putlong()
284 if (! flush_out(rstrm, FALSE)) in xdrrec_putlong()
286 dest_lp = ((int32_t *)(void *)(rstrm->out_finger)); in xdrrec_putlong()
287 rstrm->out_finger += sizeof(int32_t); in xdrrec_putlong()
296 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); in xdrrec_getbytes() local
300 current = (u_int)rstrm->fbtbc; in xdrrec_getbytes()
302 if (rstrm->last_frag) in xdrrec_getbytes()
304 if (! set_input_fragment(rstrm)) in xdrrec_getbytes()
309 if (! get_input_bytes(rstrm, addr, current)) in xdrrec_getbytes()
312 rstrm->fbtbc -= current; in xdrrec_getbytes()
321 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); in xdrrec_putbytes() local
325 current = (size_t)((u_long)rstrm->out_boundry - in xdrrec_putbytes()
326 (u_long)rstrm->out_finger); in xdrrec_putbytes()
328 memmove(rstrm->out_finger, addr, current); in xdrrec_putbytes()
329 rstrm->out_finger += current; in xdrrec_putbytes()
333 if (rstrm->out_finger == rstrm->out_boundry) { in xdrrec_putbytes()
334 rstrm->frag_sent = TRUE; in xdrrec_putbytes()
335 if (! flush_out(rstrm, FALSE)) in xdrrec_putbytes()
345 RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; in xdrrec_getpos() local
348 pos = lseek((int)(u_long)rstrm->tcp_handle, (off_t)0, 1); in xdrrec_getpos()
353 pos += rstrm->out_finger - rstrm->out_base; in xdrrec_getpos()
357 pos -= rstrm->in_boundry - rstrm->in_finger; in xdrrec_getpos()
370 RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; in xdrrec_setpos() local
379 newpos = rstrm->out_finger - delta; in xdrrec_setpos()
380 if ((newpos > (char *)(void *)(rstrm->frag_header)) && in xdrrec_setpos()
381 (newpos < rstrm->out_boundry)) { in xdrrec_setpos()
382 rstrm->out_finger = newpos; in xdrrec_setpos()
388 newpos = rstrm->in_finger - delta; in xdrrec_setpos()
389 if ((delta < (int)(rstrm->fbtbc)) && in xdrrec_setpos()
390 (newpos <= rstrm->in_boundry) && in xdrrec_setpos()
391 (newpos >= rstrm->in_base)) { in xdrrec_setpos()
392 rstrm->in_finger = newpos; in xdrrec_setpos()
393 rstrm->fbtbc -= delta; in xdrrec_setpos()
407 RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; in xdrrec_inline() local
413 if ((rstrm->out_finger + len) <= rstrm->out_boundry) { in xdrrec_inline()
414 buf = (int32_t *)(void *)rstrm->out_finger; in xdrrec_inline()
415 rstrm->out_finger += len; in xdrrec_inline()
420 if ((len <= (u_int)rstrm->fbtbc) && in xdrrec_inline()
421 ((rstrm->in_finger + len) <= rstrm->in_boundry)) { in xdrrec_inline()
422 buf = (int32_t *)(void *)rstrm->in_finger; in xdrrec_inline()
423 rstrm->fbtbc -= len; in xdrrec_inline()
424 rstrm->in_finger += len; in xdrrec_inline()
437 RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; in xdrrec_destroy() local
439 mem_free(rstrm->out_base, rstrm->sendsize); in xdrrec_destroy()
440 mem_free(rstrm->in_base, rstrm->recvsize); in xdrrec_destroy()
441 mem_free(rstrm, sizeof(RECSTREAM)); in xdrrec_destroy()
456 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); in xdrrec_skiprecord() local
459 if (rstrm->nonblock) { in xdrrec_skiprecord()
461 rstrm->fbtbc = 0; in xdrrec_skiprecord()
464 if (rstrm->in_finger == rstrm->in_boundry && in xdrrec_skiprecord()
466 rstrm->fbtbc = 0; in xdrrec_skiprecord()
471 while (rstrm->fbtbc > 0 || (! rstrm->last_frag)) { in xdrrec_skiprecord()
472 if (! skip_input_bytes(rstrm, rstrm->fbtbc)) in xdrrec_skiprecord()
474 rstrm->fbtbc = 0; in xdrrec_skiprecord()
475 if ((! rstrm->last_frag) && (! set_input_fragment(rstrm))) in xdrrec_skiprecord()
478 rstrm->last_frag = FALSE; in xdrrec_skiprecord()
490 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); in xdrrec_eof() local
492 while (rstrm->fbtbc > 0 || (! rstrm->last_frag)) { in xdrrec_eof()
493 if (!skip_input_bytes(rstrm, rstrm->fbtbc)) in xdrrec_eof()
495 rstrm->fbtbc = 0; in xdrrec_eof()
496 if ((!rstrm->last_frag) && (!set_input_fragment(rstrm))) in xdrrec_eof()
499 if (rstrm->in_finger == rstrm->in_boundry) in xdrrec_eof()
513 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); in xdrrec_endofrecord() local
516 if (sendnow || rstrm->frag_sent || in xdrrec_endofrecord()
517 ((u_long)rstrm->out_finger + sizeof(uint32_t) >= in xdrrec_endofrecord()
518 (u_long)rstrm->out_boundry)) { in xdrrec_endofrecord()
519 rstrm->frag_sent = FALSE; in xdrrec_endofrecord()
520 return (flush_out(rstrm, TRUE)); in xdrrec_endofrecord()
522 len = (u_long)(rstrm->out_finger) - (u_long)(rstrm->frag_header) - in xdrrec_endofrecord()
524 *(rstrm->frag_header) = htonl((uint32_t)len | LAST_FRAG); in xdrrec_endofrecord()
525 rstrm->frag_header = (uint32_t *)(void *)rstrm->out_finger; in xdrrec_endofrecord()
526 rstrm->out_finger += sizeof(uint32_t); in xdrrec_endofrecord()
537 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); in __xdrrec_getrec() local
541 if (!rstrm->in_haveheader) { in __xdrrec_getrec()
542 n = rstrm->readit(rstrm->tcp_handle, rstrm->in_hdrp, in __xdrrec_getrec()
543 (int)sizeof (rstrm->in_header) - rstrm->in_hdrlen); in __xdrrec_getrec()
552 rstrm->in_hdrp += n; in __xdrrec_getrec()
554 rstrm->in_hdrlen += (int)n; in __xdrrec_getrec()
555 if (rstrm->in_hdrlen < (int)sizeof(rstrm->in_header)) { in __xdrrec_getrec()
559 rstrm->in_header = ntohl(rstrm->in_header); in __xdrrec_getrec()
560 fraglen = (int)(rstrm->in_header & ~LAST_FRAG); in __xdrrec_getrec()
561 if (fraglen == 0 || fraglen > rstrm->in_maxrec || in __xdrrec_getrec()
562 (rstrm->in_reclen + fraglen) > rstrm->in_maxrec) { in __xdrrec_getrec()
566 rstrm->in_reclen += fraglen; in __xdrrec_getrec()
567 if ((u_int)rstrm->in_reclen > rstrm->recvsize) { in __xdrrec_getrec()
568 if (!realloc_stream(rstrm, rstrm->in_reclen)) { in __xdrrec_getrec()
573 if (rstrm->in_header & LAST_FRAG) { in __xdrrec_getrec()
574 rstrm->in_header &= ~LAST_FRAG; in __xdrrec_getrec()
575 rstrm->last_frag = TRUE; in __xdrrec_getrec()
579 n = rstrm->readit(rstrm->tcp_handle, in __xdrrec_getrec()
580 rstrm->in_base + rstrm->in_received, in __xdrrec_getrec()
581 (rstrm->in_reclen - rstrm->in_received)); in __xdrrec_getrec()
594 rstrm->in_received += (int)n; in __xdrrec_getrec()
596 if (rstrm->in_received == rstrm->in_reclen) { in __xdrrec_getrec()
597 rstrm->in_haveheader = FALSE; in __xdrrec_getrec()
598 rstrm->in_hdrp = (char *)(void *)&rstrm->in_header; in __xdrrec_getrec()
599 rstrm->in_hdrlen = 0; in __xdrrec_getrec()
600 if (rstrm->last_frag) { in __xdrrec_getrec()
601 rstrm->fbtbc = rstrm->in_reclen; in __xdrrec_getrec()
602 rstrm->in_boundry = rstrm->in_base + rstrm->in_reclen; in __xdrrec_getrec()
603 rstrm->in_finger = rstrm->in_base; in __xdrrec_getrec()
604 rstrm->in_reclen = rstrm->in_received = 0; in __xdrrec_getrec()
617 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); in __xdrrec_setnonblock() local
619 rstrm->nonblock = TRUE; in __xdrrec_setnonblock()
621 maxrec = rstrm->recvsize; in __xdrrec_setnonblock()
622 rstrm->in_maxrec = maxrec; in __xdrrec_setnonblock()
631 flush_out(RECSTREAM *rstrm, bool_t eor) in flush_out() argument
634 uint32_t len = (uint32_t)((u_long)(rstrm->out_finger) - in flush_out()
635 (u_long)(rstrm->frag_header) - sizeof(uint32_t)); in flush_out()
637 *(rstrm->frag_header) = htonl(len | eormask); in flush_out()
638 len = (uint32_t)((u_long)(rstrm->out_finger) - in flush_out()
639 (u_long)(rstrm->out_base)); in flush_out()
640 if ((*(rstrm->writeit))(rstrm->tcp_handle, rstrm->out_base, (int)len) in flush_out()
643 rstrm->frag_header = (uint32_t *)(void *)rstrm->out_base; in flush_out()
644 rstrm->out_finger = (char *)rstrm->out_base + sizeof(uint32_t); in flush_out()
649 fill_input_buf(RECSTREAM *rstrm) in fill_input_buf() argument
655 if (rstrm->nonblock) in fill_input_buf()
657 where = rstrm->in_base; in fill_input_buf()
658 i = (uint32_t)((u_long)rstrm->in_boundry % BYTES_PER_XDR_UNIT); in fill_input_buf()
660 len = (uint32_t)(rstrm->in_size - i); in fill_input_buf()
661 if ((len = (*(rstrm->readit))(rstrm->tcp_handle, where, len)) == -1) in fill_input_buf()
663 rstrm->in_finger = where; in fill_input_buf()
665 rstrm->in_boundry = where; in fill_input_buf()
670 get_input_bytes(RECSTREAM *rstrm, char *addr, u_int len) in get_input_bytes() argument
674 if (rstrm->nonblock) { in get_input_bytes()
675 if (len > ((uintptr_t)rstrm->in_boundry - (uintptr_t)rstrm->in_finger)) in get_input_bytes()
677 memcpy(addr, rstrm->in_finger, len); in get_input_bytes()
678 rstrm->in_finger += len; in get_input_bytes()
683 uintptr_t d = ((uintptr_t)rstrm->in_boundry - in get_input_bytes()
684 (uintptr_t)rstrm->in_finger); in get_input_bytes()
688 if (! fill_input_buf(rstrm)) in get_input_bytes()
693 memmove(addr, rstrm->in_finger, current); in get_input_bytes()
694 rstrm->in_finger += current; in get_input_bytes()
702 set_input_fragment(RECSTREAM *rstrm) in set_input_fragment() argument
706 if (rstrm->nonblock) in set_input_fragment()
708 if (! get_input_bytes(rstrm, (char *)(void *)&header, in set_input_fragment()
712 rstrm->last_frag = ((header & LAST_FRAG) == 0) ? FALSE : TRUE; in set_input_fragment()
723 rstrm->fbtbc = header & (~LAST_FRAG); in set_input_fragment()
728 skip_input_bytes(RECSTREAM *rstrm, long cnt) in skip_input_bytes() argument
733 current = (uint32_t)((long)rstrm->in_boundry - in skip_input_bytes()
734 (long)rstrm->in_finger); in skip_input_bytes()
736 if (! fill_input_buf(rstrm)) in skip_input_bytes()
741 rstrm->in_finger += current; in skip_input_bytes()
760 realloc_stream(RECSTREAM *rstrm, int size) in realloc_stream() argument
765 if ((u_int)size > rstrm->recvsize) { in realloc_stream()
766 buf = realloc(rstrm->in_base, (size_t)size); in realloc_stream()
769 diff = buf - rstrm->in_base; in realloc_stream()
770 rstrm->in_finger += diff; in realloc_stream()
771 rstrm->in_base = buf; in realloc_stream()
772 rstrm->in_boundry = buf + size; in realloc_stream()
773 rstrm->recvsize = size; in realloc_stream()
774 rstrm->in_size = size; in realloc_stream()