Lines Matching refs:rstrm
153 RECSTREAM *rstrm = malloc(sizeof (RECSTREAM)); in xdrrec_create() local
159 if (rstrm == NULL) { in xdrrec_create()
171 rstrm->sendsize = fix_buf_size(sendsize); in xdrrec_create()
172 rstrm->recvsize = fix_buf_size(recvsize); in xdrrec_create()
173 rstrm->out_base = malloc(rstrm->sendsize); in xdrrec_create()
174 if (rstrm->out_base == NULL) { in xdrrec_create()
176 free(rstrm); in xdrrec_create()
179 rstrm->in_base = malloc(rstrm->recvsize); in xdrrec_create()
180 if (rstrm->in_base == NULL) { in xdrrec_create()
182 free(rstrm->out_base); in xdrrec_create()
183 free(rstrm); in xdrrec_create()
192 xdrs->x_private = (caddr_t)rstrm; in xdrrec_create()
193 rstrm->tcp_handle = tcp_handle; in xdrrec_create()
194 rstrm->readit = readit; in xdrrec_create()
195 rstrm->writeit = writeit; in xdrrec_create()
196 rstrm->out_finger = rstrm->out_boundry = rstrm->out_base; in xdrrec_create()
198 rstrm->frag_header = (uint32_t *)rstrm->out_base; in xdrrec_create()
199 rstrm->out_finger += sizeof (uint_t); in xdrrec_create()
200 rstrm->out_boundry += rstrm->sendsize; in xdrrec_create()
201 rstrm->frag_sent = FALSE; in xdrrec_create()
202 rstrm->in_boundry = rstrm->in_base; in xdrrec_create()
203 rstrm->in_finger = (rstrm->in_boundry += rstrm->recvsize); in xdrrec_create()
204 rstrm->fbtbc = 0; in xdrrec_create()
205 rstrm->last_frag = TRUE; in xdrrec_create()
206 rstrm->firsttime = 0; in xdrrec_create()
207 rstrm->in_nonblock = 0; in xdrrec_create()
208 rstrm->in_needpoll = 1; in xdrrec_create()
209 rstrm->in_maxrecsz = 0; in xdrrec_create()
210 rstrm->in_nextrec = rstrm->in_base; in xdrrec_create()
211 rstrm->in_nextrecsz = 0; in xdrrec_create()
220 align_instream(RECSTREAM *rstrm) in align_instream() argument
222 int current = rstrm->in_boundry - rstrm->in_finger; in align_instream()
224 (void) memcpy(rstrm->in_base, rstrm->in_finger, current); in align_instream()
225 rstrm->in_finger = rstrm->in_base; in align_instream()
226 rstrm->in_boundry = rstrm->in_finger + current; in align_instream()
237 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); in xdrrec_getint32() local
239 int32_t *buflp = (int32_t *)(rstrm->in_finger); in xdrrec_getint32()
243 if ((rstrm->fbtbc >= (int)sizeof (int32_t)) && in xdrrec_getint32()
244 ((uint_t)(rstrm->in_boundry - (caddr_t)buflp) >= in xdrrec_getint32()
250 align_instream(rstrm); in xdrrec_getint32()
252 buflp = (int32_t *)(rstrm->in_finger); in xdrrec_getint32()
255 rstrm->fbtbc -= (int)sizeof (int32_t); in xdrrec_getint32()
256 rstrm->in_finger += sizeof (int32_t); in xdrrec_getint32()
269 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); in xdrrec_putint32() local
271 int32_t *dest_lp = ((int32_t *)(rstrm->out_finger)); in xdrrec_putint32()
273 if ((rstrm->out_finger += sizeof (int32_t)) > rstrm->out_boundry) { in xdrrec_putint32()
278 rstrm->out_finger -= sizeof (int32_t); in xdrrec_putint32()
279 rstrm->frag_sent = TRUE; in xdrrec_putint32()
280 if (!flush_out(rstrm, FALSE)) in xdrrec_putint32()
283 dest_lp = ((int32_t *)(rstrm->out_finger)); in xdrrec_putint32()
284 rstrm->out_finger += sizeof (int32_t); in xdrrec_putint32()
320 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); in xdrrec_getbytes() local
324 current = rstrm->fbtbc; in xdrrec_getbytes()
326 if (rstrm->last_frag) in xdrrec_getbytes()
328 if (!set_input_fragment(rstrm)) in xdrrec_getbytes()
333 if (!get_input_bytes(rstrm, addr, current, FALSE)) in xdrrec_getbytes()
336 rstrm->fbtbc -= current; in xdrrec_getbytes()
346 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); in xdrrec_putbytes() local
351 current = (uintptr_t)rstrm->out_boundry - in xdrrec_putbytes()
352 (uintptr_t)rstrm->out_finger; in xdrrec_putbytes()
354 (void) memcpy(rstrm->out_finger, addr, current); in xdrrec_putbytes()
355 rstrm->out_finger += current; in xdrrec_putbytes()
358 if (rstrm->out_finger == rstrm->out_boundry) { in xdrrec_putbytes()
359 rstrm->frag_sent = TRUE; in xdrrec_putbytes()
360 if (!flush_out(rstrm, FALSE)) in xdrrec_putbytes()
377 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); in xdrrec_readbytes() local
382 current = rstrm->fbtbc; in xdrrec_readbytes()
384 if (rstrm->last_frag) in xdrrec_readbytes()
386 if (!set_input_fragment(rstrm)) in xdrrec_readbytes()
391 if (!get_input_bytes(rstrm, addr, current, FALSE)) in xdrrec_readbytes()
394 rstrm->fbtbc -= current; in xdrrec_readbytes()
404 RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; in xdrrec_getpos() local
407 pos = lseek((intptr_t)rstrm->tcp_handle, 0, 1); in xdrrec_getpos()
412 pos += rstrm->out_finger - rstrm->out_base; in xdrrec_getpos()
416 pos -= rstrm->in_boundry - rstrm->in_finger; in xdrrec_getpos()
430 RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; in xdrrec_setpos() local
439 newpos = rstrm->out_finger - delta; in xdrrec_setpos()
440 if ((newpos > (caddr_t)(rstrm->frag_header)) && in xdrrec_setpos()
441 (newpos < rstrm->out_boundry)) { in xdrrec_setpos()
442 rstrm->out_finger = newpos; in xdrrec_setpos()
448 newpos = rstrm->in_finger - delta; in xdrrec_setpos()
449 if ((delta < (int)(rstrm->fbtbc)) && in xdrrec_setpos()
450 (newpos <= rstrm->in_boundry) && in xdrrec_setpos()
451 (newpos >= rstrm->in_base)) { in xdrrec_setpos()
452 rstrm->in_finger = newpos; in xdrrec_setpos()
453 rstrm->fbtbc -= delta; in xdrrec_setpos()
465 RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; in xdrrec_inline() local
471 if ((rstrm->out_finger + len) <= rstrm->out_boundry) { in xdrrec_inline()
473 buf = (rpc_inline_t *)rstrm->out_finger; in xdrrec_inline()
474 rstrm->out_finger += len; in xdrrec_inline()
479 if ((len <= rstrm->fbtbc) && in xdrrec_inline()
480 ((rstrm->in_finger + len) <= rstrm->in_boundry)) { in xdrrec_inline()
485 if (((intptr_t)rstrm->in_finger) & in xdrrec_inline()
487 align_instream(rstrm); in xdrrec_inline()
489 buf = (rpc_inline_t *)rstrm->in_finger; in xdrrec_inline()
490 rstrm->fbtbc -= len; in xdrrec_inline()
491 rstrm->in_finger += len; in xdrrec_inline()
502 RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; in xdrrec_destroy() local
504 free(rstrm->out_base); in xdrrec_destroy()
505 free(rstrm->in_base); in xdrrec_destroy()
506 free(rstrm); in xdrrec_destroy()
522 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); in xdrrec_skiprecord() local
524 if (rstrm->in_nonblock) { in xdrrec_skiprecord()
534 rstrm->in_finger == rstrm->in_boundry)) { in xdrrec_skiprecord()
535 rstrm->fbtbc = 0; in xdrrec_skiprecord()
540 while (rstrm->fbtbc > 0 || (!rstrm->last_frag)) { in xdrrec_skiprecord()
541 if (!skip_input_bytes(rstrm, rstrm->fbtbc)) in xdrrec_skiprecord()
543 rstrm->fbtbc = 0; in xdrrec_skiprecord()
544 if ((!rstrm->last_frag) && (!set_input_fragment(rstrm))) in xdrrec_skiprecord()
547 rstrm->last_frag = FALSE; in xdrrec_skiprecord()
560 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); in xdrrec_eof() local
562 if (rstrm->in_nonblock) { in xdrrec_eof()
567 return (rstrm->in_needpoll); in xdrrec_eof()
569 while (rstrm->fbtbc > 0 || (!rstrm->last_frag)) { in xdrrec_eof()
570 if (!skip_input_bytes(rstrm, rstrm->fbtbc)) in xdrrec_eof()
572 rstrm->fbtbc = 0; in xdrrec_eof()
573 if ((!rstrm->last_frag) && (!set_input_fragment(rstrm))) in xdrrec_eof()
576 if (rstrm->in_finger == rstrm->in_boundry) in xdrrec_eof()
591 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); in xdrrec_endofrecord() local
594 if (sendnow || rstrm->frag_sent || in xdrrec_endofrecord()
595 ((uintptr_t)rstrm->out_finger + sizeof (uint32_t) >= in xdrrec_endofrecord()
596 (uintptr_t)rstrm->out_boundry)) { in xdrrec_endofrecord()
597 rstrm->frag_sent = FALSE; in xdrrec_endofrecord()
598 return (flush_out(rstrm, TRUE)); in xdrrec_endofrecord()
600 len = (uintptr_t)(rstrm->out_finger) - (uintptr_t)(rstrm->frag_header) - in xdrrec_endofrecord()
602 *(rstrm->frag_header) = htonl((uint32_t)len | LAST_FRAG); in xdrrec_endofrecord()
604 rstrm->frag_header = (uint32_t *)rstrm->out_finger; in xdrrec_endofrecord()
605 rstrm->out_finger += sizeof (uint32_t); in xdrrec_endofrecord()
614 flush_out(RECSTREAM *rstrm, bool_t eor) in flush_out() argument
617 uint32_t len = (uintptr_t)(rstrm->out_finger) - in flush_out()
618 (uintptr_t)(rstrm->frag_header) - sizeof (uint32_t); in flush_out()
621 *(rstrm->frag_header) = htonl(len | eormask); in flush_out()
622 len = (uintptr_t)(rstrm->out_finger) - (uintptr_t)(rstrm->out_base); in flush_out()
624 written = (*(rstrm->writeit)) in flush_out()
625 (rstrm->tcp_handle, rstrm->out_base, (int)len); in flush_out()
633 rstrm->frag_header = (uint32_t *)rstrm->out_base; in flush_out()
634 rstrm->out_finger = (caddr_t)rstrm->out_base + sizeof (uint32_t); in flush_out()
641 fill_input_buf(RECSTREAM *rstrm, bool_t do_align) in fill_input_buf() argument
646 if (rstrm->in_nonblock) { in fill_input_buf()
650 where = rstrm->in_base; in fill_input_buf()
652 len = rstrm->recvsize; in fill_input_buf()
654 uint_t i = (uintptr_t)rstrm->in_boundry % BYTES_PER_XDR_UNIT; in fill_input_buf()
657 len = rstrm->recvsize - i; in fill_input_buf()
659 if ((len = (*(rstrm->readit))(rstrm->tcp_handle, where, len)) == -1) in fill_input_buf()
661 rstrm->in_finger = where; in fill_input_buf()
663 rstrm->in_boundry = where; in fill_input_buf()
669 get_input_bytes(RECSTREAM *rstrm, caddr_t addr, in get_input_bytes() argument
674 if (rstrm->in_nonblock) { in get_input_bytes()
679 current = (int)(rstrm->in_boundry - rstrm->in_finger); in get_input_bytes()
682 (void) memcpy(addr, rstrm->in_finger, len); in get_input_bytes()
683 rstrm->in_finger += len; in get_input_bytes()
689 current = (intptr_t)rstrm->in_boundry - in get_input_bytes()
690 (intptr_t)rstrm->in_finger; in get_input_bytes()
692 if (!fill_input_buf(rstrm, do_align)) in get_input_bytes()
697 (void) memcpy(addr, rstrm->in_finger, current); in get_input_bytes()
698 rstrm->in_finger += current; in get_input_bytes()
708 set_input_fragment(RECSTREAM *rstrm) in set_input_fragment() argument
712 if (rstrm->in_nonblock) { in set_input_fragment()
720 if (!get_input_bytes(rstrm, (caddr_t)&header, (int)sizeof (header), in set_input_fragment()
721 rstrm->last_frag)) in set_input_fragment()
724 rstrm->last_frag = ((header & LAST_FRAG) == 0) ? FALSE : TRUE; in set_input_fragment()
725 rstrm->fbtbc = header & (~LAST_FRAG); in set_input_fragment()
731 skip_input_bytes(RECSTREAM *rstrm, int32_t cnt) in skip_input_bytes() argument
736 current = (intptr_t)rstrm->in_boundry - in skip_input_bytes()
737 (intptr_t)rstrm->in_finger; in skip_input_bytes()
739 if (!fill_input_buf(rstrm, FALSE)) in skip_input_bytes()
744 rstrm->in_finger += current; in skip_input_bytes()
752 __xdrrec_nonblock_realloc(RECSTREAM *rstrm, uint32_t newsize) in __xdrrec_nonblock_realloc() argument
754 caddr_t newbuf = rstrm->in_base; in __xdrrec_nonblock_realloc()
758 if (newsize > rstrm->recvsize) { in __xdrrec_nonblock_realloc()
764 offset = newbuf - rstrm->in_base; in __xdrrec_nonblock_realloc()
765 rstrm->in_finger += offset; in __xdrrec_nonblock_realloc()
766 rstrm->in_boundry += offset; in __xdrrec_nonblock_realloc()
767 rstrm->in_nextrec += offset; in __xdrrec_nonblock_realloc()
768 rstrm->in_base = newbuf; in __xdrrec_nonblock_realloc()
769 rstrm->recvsize = newsize; in __xdrrec_nonblock_realloc()
783 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); in __xdrrec_set_conn_nonblock() local
786 rstrm->in_nonblock = TRUE; in __xdrrec_set_conn_nonblock()
793 rstrm->in_maxrecsz = rstrm->recvsize; in __xdrrec_set_conn_nonblock()
796 rstrm->in_maxrecsz = tcp_maxrecsz; in __xdrrec_set_conn_nonblock()
797 if (tcp_maxrecsz <= rstrm->recvsize) in __xdrrec_set_conn_nonblock()
812 if (!__xdrrec_nonblock_realloc(rstrm, newsize)) { in __xdrrec_set_conn_nonblock()
814 free(rstrm->out_base); in __xdrrec_set_conn_nonblock()
815 free(rstrm->in_base); in __xdrrec_set_conn_nonblock()
816 free(rstrm); in __xdrrec_set_conn_nonblock()
832 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); in __xdrrec_getbytes_nonblock() local
848 if (rstrm->in_nextrecsz > 0) { in __xdrrec_getbytes_nonblock()
850 (void) memmove(rstrm->in_base, rstrm->in_nextrec, in __xdrrec_getbytes_nonblock()
851 rstrm->in_nextrecsz); in __xdrrec_getbytes_nonblock()
852 rstrm->in_nextrec = rstrm->in_finger = rstrm->in_base; in __xdrrec_getbytes_nonblock()
853 rstrm->in_boundry = rstrm->in_nextrec + rstrm->in_nextrecsz; in __xdrrec_getbytes_nonblock()
854 unprocessed = rstrm->in_nextrecsz; in __xdrrec_getbytes_nonblock()
855 rstrm->in_nextrecsz = 0; in __xdrrec_getbytes_nonblock()
856 } else if (rstrm->in_nextrec == rstrm->in_base) { in __xdrrec_getbytes_nonblock()
858 rstrm->in_boundry = rstrm->in_finger = rstrm->in_base; in __xdrrec_getbytes_nonblock()
859 rstrm->last_frag = FALSE; in __xdrrec_getbytes_nonblock()
860 rstrm->in_needpoll = TRUE; in __xdrrec_getbytes_nonblock()
863 prevbytes_thisrec = (uint32_t)(rstrm->in_boundry - rstrm->in_base); in __xdrrec_getbytes_nonblock()
866 if (rstrm->in_needpoll) { in __xdrrec_getbytes_nonblock()
869 rstrm->in_needpoll = FALSE; in __xdrrec_getbytes_nonblock()
871 (int)(rstrm->in_boundry - rstrm->in_base); in __xdrrec_getbytes_nonblock()
872 len_requested = rstrm->recvsize - len_total_received; in __xdrrec_getbytes_nonblock()
885 minreqrecsize = rstrm->recvsize + in __xdrrec_getbytes_nonblock()
886 rstrm->fbtbc + in __xdrrec_getbytes_nonblock()
887 (rstrm->last_frag ? 0 : sizeof (*header)); in __xdrrec_getbytes_nonblock()
889 if (minreqrecsize == rstrm->recvsize) { in __xdrrec_getbytes_nonblock()
899 if (minreqrecsize > rstrm->in_maxrecsz) in __xdrrec_getbytes_nonblock()
904 if ((len_received = (*(rstrm->readit))(rstrm->tcp_handle, in __xdrrec_getbytes_nonblock()
905 rstrm->in_boundry, len_requested)) == -1) { in __xdrrec_getbytes_nonblock()
909 rstrm->in_boundry += len_received; in __xdrrec_getbytes_nonblock()
910 rstrm->in_nextrec = rstrm->in_boundry; in __xdrrec_getbytes_nonblock()
917 minreqrecsize = prevbytes_thisrec + rstrm->fbtbc; in __xdrrec_getbytes_nonblock()
927 if (rstrm->fbtbc == 0) { in __xdrrec_getbytes_nonblock()
932 len_recvd_thisfrag = (uint32_t)(rstrm->in_boundry - in __xdrrec_getbytes_nonblock()
933 rstrm->in_finger); in __xdrrec_getbytes_nonblock()
935 header = (uint32_t *)rstrm->in_finger; in __xdrrec_getbytes_nonblock()
961 (minreqrecsize > rstrm->in_maxrecsz)) { in __xdrrec_getbytes_nonblock()
972 rstrm->last_frag = last_frag; in __xdrrec_getbytes_nonblock()
973 rstrm->fbtbc = minfraglen; in __xdrrec_getbytes_nonblock()
990 if ((minreqrecsize > rstrm->in_maxrecsz) || in __xdrrec_getbytes_nonblock()
991 (rstrm->last_frag && minreqrecsize < MIN_FRAG) || in __xdrrec_getbytes_nonblock()
992 (!rstrm->last_frag && minfraglen == 0)) { in __xdrrec_getbytes_nonblock()
994 rstrm->fbtbc = 0; in __xdrrec_getbytes_nonblock()
995 rstrm->last_frag = 1; in __xdrrec_getbytes_nonblock()
1005 if (rstrm->in_finger == rstrm->in_base) { in __xdrrec_getbytes_nonblock()
1006 rstrm->in_finger += sizeof (*header); in __xdrrec_getbytes_nonblock()
1008 rstrm->in_boundry -= sizeof (*header); in __xdrrec_getbytes_nonblock()
1009 (void) memmove(rstrm->in_finger, in __xdrrec_getbytes_nonblock()
1010 rstrm->in_finger + sizeof (*header), in __xdrrec_getbytes_nonblock()
1011 rstrm->in_boundry - rstrm->in_finger); in __xdrrec_getbytes_nonblock()
1028 if (len_received >= rstrm->fbtbc) { in __xdrrec_getbytes_nonblock()
1029 len_received -= rstrm->fbtbc; in __xdrrec_getbytes_nonblock()
1030 rstrm->in_finger += rstrm->fbtbc; in __xdrrec_getbytes_nonblock()
1031 rstrm->fbtbc = 0; in __xdrrec_getbytes_nonblock()
1033 rstrm->fbtbc -= len_received; in __xdrrec_getbytes_nonblock()
1034 rstrm->in_finger += len_received; in __xdrrec_getbytes_nonblock()
1047 if (len_received > 0 && rstrm->last_frag) { in __xdrrec_getbytes_nonblock()
1048 rstrm->in_nextrec = rstrm->in_finger; in __xdrrec_getbytes_nonblock()
1049 rstrm->in_nextrecsz = (uint32_t)(rstrm->in_boundry - in __xdrrec_getbytes_nonblock()
1050 rstrm->in_nextrec); in __xdrrec_getbytes_nonblock()
1056 if (rstrm->last_frag && rstrm->fbtbc == 0) { in __xdrrec_getbytes_nonblock()
1065 rstrm->fbtbc = (int)(rstrm->in_finger - in __xdrrec_getbytes_nonblock()
1066 rstrm->in_base - sizeof (*header)); in __xdrrec_getbytes_nonblock()
1067 rstrm->in_finger = rstrm->in_base + sizeof (*header); in __xdrrec_getbytes_nonblock()
1068 if (rstrm->in_nextrecsz == 0) in __xdrrec_getbytes_nonblock()
1069 rstrm->in_nextrec = rstrm->in_base; in __xdrrec_getbytes_nonblock()
1078 if (minreqrecsize > rstrm->recvsize) { in __xdrrec_getbytes_nonblock()
1079 if (!__xdrrec_nonblock_realloc(rstrm, minreqrecsize)) { in __xdrrec_getbytes_nonblock()
1080 rstrm->fbtbc = 0; in __xdrrec_getbytes_nonblock()
1081 rstrm->last_frag = 1; in __xdrrec_getbytes_nonblock()
1087 rstrm->in_needpoll = TRUE; in __xdrrec_getbytes_nonblock()
1096 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); in __is_xdrrec_first() local
1097 return ((rstrm->firsttime == TRUE) ? 1 : 0); in __is_xdrrec_first()
1104 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); in __xdrrec_setfirst() local
1111 if (rstrm->in_finger == rstrm->in_boundry) in __xdrrec_setfirst()
1112 rstrm->firsttime = TRUE; in __xdrrec_setfirst()
1114 rstrm->firsttime = FALSE; in __xdrrec_setfirst()
1122 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); in __xdrrec_resetfirst() local
1124 rstrm->firsttime = FALSE; in __xdrrec_resetfirst()
1143 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); in xdrrec_control() local
1150 if ((rstrm->fbtbc == 0) && (!rstrm->last_frag)) in xdrrec_control()
1151 if (!set_input_fragment(rstrm)) { in xdrrec_control()
1156 xptr->xc_is_last_record = rstrm->last_frag; in xdrrec_control()
1157 xptr->xc_num_avail = rstrm->fbtbc; in xdrrec_control()