Lines Matching refs:rstrm

186   RECSTREAM *rstrm;  in xdrrec_create()  local
195 rstrm = (RECSTREAM *) mem_alloc (sizeof (RECSTREAM)); in xdrrec_create()
196 if (rstrm == NULL) in xdrrec_create()
209 rstrm->sendsize = sendsize = fix_buf_size (sendsize); in xdrrec_create()
210 rstrm->out_buffer = mem_alloc (rstrm->sendsize + BYTES_PER_XDR_UNIT); in xdrrec_create()
211 if (rstrm->out_buffer == NULL) in xdrrec_create()
214 mem_free (rstrm, sizeof (RECSTREAM)); in xdrrec_create()
218 for (rstrm->out_base = rstrm->out_buffer; in xdrrec_create()
219 (intptr_t) rstrm->out_base % BYTES_PER_XDR_UNIT != 0; rstrm->out_base++) in xdrrec_create()
223 rstrm->recvsize = recvsize = fix_buf_size (recvsize); in xdrrec_create()
224 rstrm->in_buffer = mem_alloc (recvsize + BYTES_PER_XDR_UNIT); in xdrrec_create()
225 if (rstrm->in_buffer == NULL) in xdrrec_create()
228 mem_free (rstrm->out_buffer, sendsize + BYTES_PER_XDR_UNIT); in xdrrec_create()
229 mem_free (rstrm, sizeof (RECSTREAM)); in xdrrec_create()
233 for (rstrm->in_base = rstrm->in_buffer; in xdrrec_create()
234 (intptr_t) rstrm->in_base % BYTES_PER_XDR_UNIT != 0; rstrm->in_base++) in xdrrec_create()
241 xdrs->x_private = rstrm; in xdrrec_create()
242 rstrm->tcp_handle = tcp_handle; in xdrrec_create()
243 rstrm->readit = readit; in xdrrec_create()
244 rstrm->writeit = writeit; in xdrrec_create()
245 rstrm->out_finger = rstrm->out_boundry = rstrm->out_base; in xdrrec_create()
246 rstrm->frag_header = (u_int32_t *) (void *) rstrm->out_base; in xdrrec_create()
247 rstrm->out_finger += sizeof (u_int32_t); in xdrrec_create()
248 rstrm->out_boundry += sendsize; in xdrrec_create()
249 rstrm->frag_sent = FALSE; in xdrrec_create()
250 rstrm->in_size = recvsize; in xdrrec_create()
251 rstrm->in_boundry = rstrm->in_base; in xdrrec_create()
252 rstrm->in_finger = (rstrm->in_boundry += recvsize); in xdrrec_create()
253 rstrm->fbtbc = 0; in xdrrec_create()
254 rstrm->last_frag = TRUE; in xdrrec_create()
255 rstrm->in_haveheader = FALSE; in xdrrec_create()
256 rstrm->in_hdrlen = 0; in xdrrec_create()
257 rstrm->in_hdrp = (char *) (void *) &rstrm->in_header; in xdrrec_create()
258 rstrm->nonblock = FALSE; in xdrrec_create()
259 rstrm->in_reclen = 0; in xdrrec_create()
260 rstrm->in_received = 0; in xdrrec_create()
273 RECSTREAM *rstrm = (RECSTREAM *) (xdrs->x_private); in xdrrec_getlong() local
274 int32_t *buflp = (int32_t *) (void *) (rstrm->in_finger); in xdrrec_getlong()
278 if ((rstrm->fbtbc >= (long) sizeof (int32_t)) && in xdrrec_getlong()
279 (((intptr_t) rstrm->in_boundry - (intptr_t) buflp) >= (long) sizeof (int32_t))) in xdrrec_getlong()
282 rstrm->fbtbc -= sizeof (int32_t); in xdrrec_getlong()
283 rstrm->in_finger += sizeof (int32_t); in xdrrec_getlong()
299 RECSTREAM *rstrm = (RECSTREAM *) (xdrs->x_private); in xdrrec_putlong() local
300 int32_t *dest_lp = ((int32_t *) (void *) (rstrm->out_finger)); in xdrrec_putlong()
302 if ((rstrm->out_finger += sizeof (int32_t)) > rstrm->out_boundry) in xdrrec_putlong()
308 rstrm->out_finger -= sizeof (int32_t); in xdrrec_putlong()
309 rstrm->frag_sent = TRUE; in xdrrec_putlong()
310 if (!flush_out (rstrm, FALSE)) in xdrrec_putlong()
312 dest_lp = ((int32_t *) (void *) (rstrm->out_finger)); in xdrrec_putlong()
313 rstrm->out_finger += sizeof (int32_t); in xdrrec_putlong()
324 RECSTREAM *rstrm = (RECSTREAM *) (xdrs->x_private); in xdrrec_getbytes() local
329 current = (int) rstrm->fbtbc; in xdrrec_getbytes()
332 if (rstrm->last_frag) in xdrrec_getbytes()
334 if (!set_input_fragment (rstrm)) in xdrrec_getbytes()
339 if (!get_input_bytes (rstrm, addr, current)) in xdrrec_getbytes()
342 rstrm->fbtbc -= current; in xdrrec_getbytes()
353 RECSTREAM *rstrm = (RECSTREAM *) (xdrs->x_private); in xdrrec_putbytes() local
358 current = (size_t) ((uintptr_t) rstrm->out_boundry - in xdrrec_putbytes()
359 (uintptr_t) rstrm->out_finger); in xdrrec_putbytes()
361 memmove (rstrm->out_finger, addr, current); in xdrrec_putbytes()
362 rstrm->out_finger += current; in xdrrec_putbytes()
365 if (rstrm->out_finger == rstrm->out_boundry) in xdrrec_putbytes()
367 rstrm->frag_sent = TRUE; in xdrrec_putbytes()
368 if (!flush_out (rstrm, FALSE)) in xdrrec_putbytes()
378 RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private; in xdrrec_getpos() local
381 pos = lseek ((int) (uintptr_t) rstrm->tcp_handle, (off_t) 0, 1); in xdrrec_getpos()
387 pos += rstrm->out_finger - rstrm->out_base; in xdrrec_getpos()
391 pos -= rstrm->in_boundry - rstrm->in_finger; in xdrrec_getpos()
405 RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private; in xdrrec_setpos() local
415 newpos = rstrm->out_finger - delta; in xdrrec_setpos()
416 if ((newpos > (char *) (void *) (rstrm->frag_header)) && in xdrrec_setpos()
417 (newpos < rstrm->out_boundry)) in xdrrec_setpos()
419 rstrm->out_finger = newpos; in xdrrec_setpos()
425 newpos = rstrm->in_finger - delta; in xdrrec_setpos()
426 if ((delta < (int) (rstrm->fbtbc)) && in xdrrec_setpos()
427 (newpos <= rstrm->in_boundry) && (newpos >= rstrm->in_base)) in xdrrec_setpos()
429 rstrm->in_finger = newpos; in xdrrec_setpos()
430 rstrm->fbtbc -= delta; in xdrrec_setpos()
445 RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private; in xdrrec_inline() local
460 if ((rstrm->out_finger + len) <= rstrm->out_boundry) in xdrrec_inline()
462 buf = (int32_t *) (void *) rstrm->out_finger; in xdrrec_inline()
463 rstrm->out_finger += len; in xdrrec_inline()
468 if (((long)len <= rstrm->fbtbc) && in xdrrec_inline()
469 ((rstrm->in_finger + len) <= rstrm->in_boundry)) in xdrrec_inline()
471 buf = (int32_t *) (void *) rstrm->in_finger; in xdrrec_inline()
472 rstrm->fbtbc -= len; in xdrrec_inline()
473 rstrm->in_finger += len; in xdrrec_inline()
486 RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private; in xdrrec_destroy() local
488 mem_free (rstrm->out_buffer, rstrm->sendsize + BYTES_PER_XDR_UNIT); in xdrrec_destroy()
489 mem_free (rstrm->in_buffer, rstrm->recvsize + BYTES_PER_XDR_UNIT); in xdrrec_destroy()
490 mem_free (rstrm, sizeof (RECSTREAM)); in xdrrec_destroy()
497 RECSTREAM *rstrm = (RECSTREAM *) (xdrs->x_private); in xdrrec_getint32() local
498 int32_t *bufip = (int32_t *) (void *) (rstrm->in_finger); in xdrrec_getint32()
502 if ((rstrm->fbtbc >= (long) sizeof (int32_t)) && in xdrrec_getint32()
503 (( rstrm->in_boundry - (char *) bufip) >= (ssize_t) sizeof (int32_t))) in xdrrec_getint32()
506 rstrm->fbtbc -= sizeof (int32_t); in xdrrec_getint32()
507 rstrm->in_finger += sizeof (int32_t); in xdrrec_getint32()
523 RECSTREAM *rstrm = (RECSTREAM *) (xdrs->x_private); in xdrrec_putint32() local
524 int32_t *dest_ip = ((int32_t *) (void *) (rstrm->out_finger)); in xdrrec_putint32()
526 if ((rstrm->out_finger += sizeof (int32_t)) > rstrm->out_boundry) in xdrrec_putint32()
532 rstrm->out_finger -= sizeof (int32_t); in xdrrec_putint32()
533 rstrm->frag_sent = TRUE; in xdrrec_putint32()
534 if (!flush_out (rstrm, FALSE)) in xdrrec_putint32()
536 dest_ip = ((int32_t *) (void *) (rstrm->out_finger)); in xdrrec_putint32()
537 rstrm->out_finger += sizeof (int32_t); in xdrrec_putint32()
554 RECSTREAM *rstrm = (RECSTREAM *) (xdrs->x_private); in xdrrec_skiprecord() local
557 if (rstrm->nonblock) in xdrrec_skiprecord()
561 rstrm->fbtbc = 0; in xdrrec_skiprecord()
564 if (rstrm->in_finger == rstrm->in_boundry && xstat == XPRT_MOREREQS) in xdrrec_skiprecord()
566 rstrm->fbtbc = 0; in xdrrec_skiprecord()
572 while (rstrm->fbtbc > 0 || (!rstrm->last_frag)) in xdrrec_skiprecord()
574 if (!skip_input_bytes (rstrm, rstrm->fbtbc)) in xdrrec_skiprecord()
576 rstrm->fbtbc = 0; in xdrrec_skiprecord()
577 if ((!rstrm->last_frag) && (!set_input_fragment (rstrm))) in xdrrec_skiprecord()
580 rstrm->last_frag = FALSE; in xdrrec_skiprecord()
592 RECSTREAM *rstrm = (RECSTREAM *) (xdrs->x_private); in xdrrec_eof() local
594 while (rstrm->fbtbc > 0 || (!rstrm->last_frag)) in xdrrec_eof()
596 if (!skip_input_bytes (rstrm, rstrm->fbtbc)) in xdrrec_eof()
598 rstrm->fbtbc = 0; in xdrrec_eof()
599 if ((!rstrm->last_frag) && (!set_input_fragment (rstrm))) in xdrrec_eof()
602 if (rstrm->in_finger == rstrm->in_boundry) in xdrrec_eof()
617 RECSTREAM *rstrm = (RECSTREAM *) (xdrs->x_private); in xdrrec_endofrecord() local
620 if (sendnow || rstrm->frag_sent || in xdrrec_endofrecord()
621 ((uintptr_t) rstrm->out_finger + sizeof (u_int32_t) >= in xdrrec_endofrecord()
622 (uintptr_t) rstrm->out_boundry)) in xdrrec_endofrecord()
624 rstrm->frag_sent = FALSE; in xdrrec_endofrecord()
625 return (flush_out (rstrm, TRUE)); in xdrrec_endofrecord()
627 len = (uintptr_t) (rstrm->out_finger) - (uintptr_t) (rstrm->frag_header) - in xdrrec_endofrecord()
629 *(rstrm->frag_header) = htonl ((u_int32_t) len | LAST_FRAG); in xdrrec_endofrecord()
630 rstrm->frag_header = (u_int32_t *) (void *) rstrm->out_finger; in xdrrec_endofrecord()
631 rstrm->out_finger += sizeof (u_int32_t); in xdrrec_endofrecord()
644 RECSTREAM *rstrm = (RECSTREAM *) (xdrs->x_private); in __xdrrec_getrec() local
648 if (!rstrm->in_haveheader) in __xdrrec_getrec()
650 n = rstrm->readit (rstrm->tcp_handle, rstrm->in_hdrp, in __xdrrec_getrec()
651 (int) sizeof (rstrm->in_header) - rstrm->in_hdrlen); in __xdrrec_getrec()
662 rstrm->in_hdrp += n; in __xdrrec_getrec()
663 rstrm->in_hdrlen += n; in __xdrrec_getrec()
664 if (rstrm->in_hdrlen < (int) sizeof (rstrm->in_header)) in __xdrrec_getrec()
669 rstrm->in_header = ntohl (rstrm->in_header); in __xdrrec_getrec()
670 fraglen = (int) (rstrm->in_header & ~LAST_FRAG); in __xdrrec_getrec()
671 if (fraglen == 0 || fraglen > rstrm->in_maxrec || in __xdrrec_getrec()
672 (rstrm->in_reclen + fraglen) > rstrm->in_maxrec) in __xdrrec_getrec()
677 rstrm->in_reclen += fraglen; in __xdrrec_getrec()
678 if (rstrm->in_reclen > (int)rstrm->recvsize) /* guaranteed recvsize < INT_MAX */ in __xdrrec_getrec()
679 if (!realloc_stream (rstrm, rstrm->in_reclen)) in __xdrrec_getrec()
684 if (rstrm->in_header & LAST_FRAG) in __xdrrec_getrec()
686 rstrm->in_header &= ~LAST_FRAG; in __xdrrec_getrec()
687 rstrm->last_frag = TRUE; in __xdrrec_getrec()
697 n = rstrm->readit (rstrm->tcp_handle, in __xdrrec_getrec()
698 rstrm->in_base + rstrm->in_received, in __xdrrec_getrec()
699 (rstrm->in_reclen - rstrm->in_received)); in __xdrrec_getrec()
713 rstrm->in_received += n; in __xdrrec_getrec()
715 if (rstrm->in_received == rstrm->in_reclen) in __xdrrec_getrec()
717 rstrm->in_haveheader = FALSE; in __xdrrec_getrec()
718 rstrm->in_hdrp = (char *) (void *) &rstrm->in_header; in __xdrrec_getrec()
719 rstrm->in_hdrlen = 0; in __xdrrec_getrec()
720 if (rstrm->last_frag) in __xdrrec_getrec()
722 rstrm->fbtbc = rstrm->in_reclen; in __xdrrec_getrec()
723 rstrm->in_boundry = rstrm->in_base + rstrm->in_reclen; in __xdrrec_getrec()
724 rstrm->in_finger = rstrm->in_base; in __xdrrec_getrec()
725 rstrm->in_reclen = rstrm->in_received = 0; in __xdrrec_getrec()
739 RECSTREAM *rstrm = (RECSTREAM *) (xdrs->x_private); in __xdrrec_setnonblock() local
741 rstrm->nonblock = TRUE; in __xdrrec_setnonblock()
743 maxrec = rstrm->recvsize; in __xdrrec_setnonblock()
744 rstrm->in_maxrec = maxrec; in __xdrrec_setnonblock()
752 flush_out (RECSTREAM * rstrm, in flush_out() argument
756 u_int32_t len = (u_int32_t) ((uintptr_t) (rstrm->out_finger) - in flush_out()
757 (uintptr_t) (rstrm->frag_header) - in flush_out()
760 *(rstrm->frag_header) = htonl (len | eormask); in flush_out()
761 len = (u_int32_t) ((uintptr_t) (rstrm->out_finger) - in flush_out()
762 (uintptr_t) (rstrm->out_base)); in flush_out()
763 if ((*(rstrm->writeit)) (rstrm->tcp_handle, rstrm->out_base, (int) len) in flush_out()
766 rstrm->frag_header = (u_int32_t *) (void *) rstrm->out_base; in flush_out()
767 rstrm->out_finger = (char *) rstrm->out_base + sizeof (u_int32_t); in flush_out()
772 fill_input_buf (RECSTREAM * rstrm) in fill_input_buf() argument
778 if (rstrm->nonblock) in fill_input_buf()
781 where = rstrm->in_base; in fill_input_buf()
782 i = (u_int32_t) ((uintptr_t) rstrm->in_boundry % BYTES_PER_XDR_UNIT); in fill_input_buf()
784 len = (u_int32_t) (rstrm->in_size - i); in fill_input_buf()
785 if ((len = (*(rstrm->readit)) (rstrm->tcp_handle, where, len)) == -1) in fill_input_buf()
787 rstrm->in_finger = where; in fill_input_buf()
789 rstrm->in_boundry = where; in fill_input_buf()
794 get_input_bytes (RECSTREAM * rstrm, in get_input_bytes() argument
800 if (rstrm->nonblock) in get_input_bytes()
802 …if ((rstrm->in_boundry < rstrm->in_finger) || /* <-- should never happen, but avoids… in get_input_bytes()
803 … (len > (size_t) (rstrm->in_boundry - rstrm->in_finger))) /* <-- signed/unsigned comparison */ in get_input_bytes()
805 memcpy (addr, rstrm->in_finger, (size_t) len); in get_input_bytes()
806 rstrm->in_finger += len; in get_input_bytes()
812 current = (size_t) ((intptr_t) rstrm->in_boundry - (intptr_t) rstrm->in_finger); in get_input_bytes()
815 if (!fill_input_buf (rstrm)) in get_input_bytes()
820 memmove (addr, rstrm->in_finger, current); in get_input_bytes()
821 rstrm->in_finger += current; in get_input_bytes()
829 set_input_fragment (RECSTREAM * rstrm) in set_input_fragment() argument
833 if (rstrm->nonblock) in set_input_fragment()
835 if (!get_input_bytes (rstrm, (char *) (void *) &header, sizeof (header))) in set_input_fragment()
838 rstrm->last_frag = ((header & LAST_FRAG) == 0) ? FALSE : TRUE; in set_input_fragment()
849 rstrm->fbtbc = header & (~LAST_FRAG); in set_input_fragment()
854 skip_input_bytes (RECSTREAM * rstrm, in skip_input_bytes() argument
861 current = (size_t) ((intptr_t) rstrm->in_boundry - (intptr_t) rstrm->in_finger); in skip_input_bytes()
864 if (!fill_input_buf (rstrm)) in skip_input_bytes()
870 rstrm->in_finger += current; in skip_input_bytes()
889 realloc_stream (RECSTREAM * rstrm, in realloc_stream() argument
896 if (size > (int)rstrm->recvsize) /* recvsize guaranteed < INT_MAX */ in realloc_stream()
898 buf = realloc (rstrm->in_buffer, (size_t) (size + BYTES_PER_XDR_UNIT)); in realloc_stream()
901 rstrm->in_buffer = buf; in realloc_stream()
904 rstrm->in_finger += diff; in realloc_stream()
905 rstrm->in_base = buf_algn; in realloc_stream()
906 rstrm->in_boundry = buf_algn + size; in realloc_stream()
907 rstrm->recvsize = size; in realloc_stream()
908 rstrm->in_size = size; in realloc_stream()