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