-: 0:Source:xdr_rec.c -: 0:Graph:/var/tsitkova/Sources/v10/trunk/src/lib/rpc/xdr_rec.so.gcno -: 0:Data:/var/tsitkova/Sources/v10/trunk/src/lib/rpc/xdr_rec.so.gcda -: 0:Runs:959 -: 0:Programs:1 -: 1:/* @(#)xdr_rec.c 2.2 88/08/01 4.0 RPCSRC */ -: 2:/* -: 3: * Copyright (c) 2010, Oracle America, Inc. -: 4: * -: 5: * All rights reserved. -: 6: * -: 7: * Redistribution and use in source and binary forms, with or without -: 8: * modification, are permitted provided that the following conditions are met: -: 9: * -: 10: * * Redistributions of source code must retain the above copyright -: 11: * notice, this list of conditions and the following disclaimer. -: 12: * -: 13: * * Redistributions in binary form must reproduce the above copyright -: 14: * notice, this list of conditions and the following disclaimer in -: 15: * the documentation and/or other materials provided with the -: 16: * distribution. -: 17: * -: 18: * * Neither the name of the "Oracle America, Inc." nor the names of -: 19: * its contributors may be used to endorse or promote products -: 20: * derived from this software without specific prior written permission. -: 21: * -: 22: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -: 23: * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -: 24: * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -: 25: * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -: 26: * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -: 27: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -: 28: * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -: 29: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -: 30: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -: 31: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -: 32: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -: 33: */ -: 34:#if !defined(lint) && defined(SCCSIDS) -: 35:static char sccsid[] = "@(#)xdr_rec.c 1.21 87/08/11 Copyr 1984 Sun Micro"; -: 36:#endif -: 37: -: 38:/* -: 39: * xdr_rec.c, Implements TCP/IP based XDR streams with a "record marking" -: 40: * layer above tcp (for rpc's use). -: 41: * -: 42: * These routines interface XDRSTREAMS to a tcp/ip connection. -: 43: * There is a record marking layer between the xdr stream -: 44: * and the tcp transport level. A record is composed on one or more -: 45: * record fragments. A record fragment is a thirty-two bit header followed -: 46: * by n bytes of data, where n is contained in the header. The header -: 47: * is represented as a htonl(uint32_t). Thegh order bit encodes -: 48: * whether or not the fragment is the last fragment of the record -: 49: * (1 => fragment is last, 0 => more fragments to follow. -: 50: * The other 31 bits encode the byte length of the fragment. -: 51: */ -: 52: -: 53:#include -: 54:#include -: 55:#include -: 56:#include -: 57: -: 58:#include -: 59:#include -: 60: -: 61:static bool_t xdrrec_getlong(XDR *, long *); -: 62:static bool_t xdrrec_putlong(XDR *, long *); -: 63:static bool_t xdrrec_getbytes(XDR *, caddr_t, u_int); -: 64:static bool_t xdrrec_putbytes(XDR *, caddr_t, u_int); -: 65:static u_int xdrrec_getpos(XDR *); -: 66:static bool_t xdrrec_setpos(XDR *, u_int); -: 67:static rpc_inline_t * xdrrec_inline(XDR *, int); -: 68:static void xdrrec_destroy(XDR *); -: 69: -: 70:static struct xdr_ops xdrrec_ops = { -: 71: xdrrec_getlong, -: 72: xdrrec_putlong, -: 73: xdrrec_getbytes, -: 74: xdrrec_putbytes, -: 75: xdrrec_getpos, -: 76: xdrrec_setpos, -: 77: xdrrec_inline, -: 78: xdrrec_destroy -: 79:}; -: 80: -: 81:/* -: 82: * A record is composed of one or more record fragments. -: 83: * A record fragment is a four-byte header followed by zero to -: 84: * 2**31-1 bytes. The header is treated as an unsigned 32 bit integer and is -: 85: * encode/decoded to the network via htonl/ntohl. The low order 31 bits -: 86: * are a byte count of the fragment. The highest order bit is a boolean: -: 87: * 1 => this fragment is the last fragment of the record, -: 88: * 0 => this fragment is followed by more fragment(s). -: 89: * -: 90: * The fragment/record machinery is not general; it is constructed to -: 91: * meet the needs of xdr and rpc based on tcp. -: 92: */ -: 93: -: 94:#define LAST_FRAG ((uint32_t)(1UL << 31)) -: 95: -: 96:typedef struct rec_strm { -: 97: caddr_t tcp_handle; -: 98: caddr_t the_buffer; -: 99: /* -: 100: * out-goung bits -: 101: */ -: 102: int (*writeit)(); -: 103: caddr_t out_base; /* output buffer (points to frag header) */ -: 104: caddr_t out_finger; /* next output position */ -: 105: caddr_t out_boundry; /* data cannot up to this address */ -: 106: uint32_t *frag_header; /* beginning of curren fragment */ -: 107: bool_t frag_sent; /* true if buffer sent in middle of record */ -: 108: /* -: 109: * in-coming bits -: 110: */ -: 111: int (*readit)(); -: 112: uint32_t in_size; /* fixed size of the input buffer */ -: 113: caddr_t in_base; -: 114: caddr_t in_finger; /* location of next byte to be had */ -: 115: caddr_t in_boundry; /* can read up to this location */ -: 116: int32_t fbtbc; /* fragment bytes to be consumed */ -: 117: bool_t last_frag; -: 118: u_int sendsize; -: 119: u_int recvsize; -: 120:} RECSTREAM; -: 121: -: 122:static u_int fix_buf_size(u_int); -: 123:static bool_t flush_out(RECSTREAM *, bool_t); -: 124:static bool_t get_input_bytes(RECSTREAM *, caddr_t, int); -: 125:static bool_t set_input_fragment(RECSTREAM *); -: 126:static bool_t skip_input_bytes(RECSTREAM *, int32_t); -: 127: -: 128:/* -: 129: * Create an xdr handle for xdrrec -: 130: * xdrrec_create fills in xdrs. Sendsize and recvsize are -: 131: * send and recv buffer sizes (0 => use default). -: 132: * tcp_handle is an opaque handle that is passed as the first parameter to -: 133: * the procedures readit and writeit. Readit and writeit are read and -: 134: * write respectively. They are like the system -: 135: * calls expect that they take an opaque handle rather than an fd. -: 136: */ -: 137:void 12: 138:xdrrec_create( -: 139: XDR *xdrs, -: 140: u_int sendsize, -: 141: u_int recvsize, -: 142: caddr_t tcp_handle, -: 143: int (*readit)(), /* like read, but pass it a tcp_handle, not sock */ -: 144: int (*writeit)() /* like write, but pass it a tcp_handle, not sock */ -: 145: ) -: 146:{ -: 147: register RECSTREAM *rstrm = 12: 148: (RECSTREAM *)mem_alloc(sizeof(RECSTREAM)); -: 149: 12: 150: if (rstrm == NULL) { #####: 151: (void)fprintf(stderr, "xdrrec_create: out of memory\n"); -: 152: /* -: 153: * This is bad. Should rework xdrrec_create to -: 154: * return a handle, and in this case return NULL -: 155: */ #####: 156: return; -: 157: } -: 158: /* -: 159: * adjust sizes and allocate buffer quad byte aligned -: 160: */ 12: 161: rstrm->sendsize = sendsize = fix_buf_size(sendsize); 12: 162: rstrm->recvsize = recvsize = fix_buf_size(recvsize); 12: 163: rstrm->the_buffer = mem_alloc(sendsize + recvsize + BYTES_PER_XDR_UNIT); 12: 164: if (rstrm->the_buffer == NULL) { #####: 165: (void)fprintf(stderr, "xdrrec_create: out of memory\n"); #####: 166: return; -: 167: } 24: 168: for (rstrm->out_base = rstrm->the_buffer; -: 169: /* Pointer arithmetic - long cast allowed... */ 12: 170: (u_long)rstrm->out_base % BYTES_PER_XDR_UNIT != 0; #####: 171: rstrm->out_base++); 12: 172: rstrm->in_base = rstrm->out_base + sendsize; -: 173: /* -: 174: * now the rest ... -: 175: */ 12: 176: xdrs->x_ops = &xdrrec_ops; 12: 177: xdrs->x_private = (caddr_t)rstrm; 12: 178: rstrm->tcp_handle = tcp_handle; 12: 179: rstrm->readit = readit; 12: 180: rstrm->writeit = writeit; 12: 181: rstrm->out_finger = rstrm->out_boundry = rstrm->out_base; 12: 182: rstrm->frag_header = (uint32_t *)(void *)rstrm->out_base; 12: 183: rstrm->out_finger += BYTES_PER_XDR_UNIT; 12: 184: rstrm->out_boundry += sendsize; 12: 185: rstrm->frag_sent = FALSE; 12: 186: rstrm->in_size = recvsize; 12: 187: rstrm->in_boundry = rstrm->in_base; 12: 188: rstrm->in_finger = (rstrm->in_boundry += recvsize); 12: 189: rstrm->fbtbc = 0; 12: 190: rstrm->last_frag = TRUE; -: 191:} -: 192: -: 193: -: 194:/* -: 195: * The reoutines defined below are the xdr ops which will go into the -: 196: * xdr handle filled in by xdrrec_create. -: 197: */ -: 198: -: 199:static bool_t 450: 200:xdrrec_getlong(XDR *xdrs, long *lp) -: 201:{ 450: 202: register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); 450: 203: register int32_t *buflp = (int32_t *)(void *)(rstrm->in_finger); -: 204: uint32_t mylong; -: 205: -: 206: /* first try the inline, fast case */ 1242: 207: if ((rstrm->fbtbc >= BYTES_PER_XDR_UNIT) && 396: 208: (((long)rstrm->in_boundry - (long)buflp) >= -: 209: BYTES_PER_XDR_UNIT)) { 396: 210: *lp = (long)ntohl((uint32_t)(*buflp)); 396: 211: rstrm->fbtbc -= BYTES_PER_XDR_UNIT; 396: 212: rstrm->in_finger += BYTES_PER_XDR_UNIT; -: 213: } else { 54: 214: if (! xdrrec_getbytes(xdrs, (caddr_t)&mylong, -: 215: BYTES_PER_XDR_UNIT)) 6: 216: return (FALSE); 48: 217: *lp = (long)(int32_t)ntohl(mylong); -: 218: } 444: 219: return (TRUE); -: 220:} -: 221: -: 222:static bool_t 336: 223:xdrrec_putlong(XDR *xdrs, long *lp) -: 224:{ 336: 225: register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); 336: 226: register int32_t *dest_lp = ((int32_t *)(void *)(rstrm->out_finger)); -: 227: 336: 228: if (rstrm->out_boundry - rstrm->out_finger < BYTES_PER_XDR_UNIT) { -: 229: /* -: 230: * this case should almost never happen so the code is -: 231: * inefficient -: 232: */ #####: 233: rstrm->frag_sent = TRUE; #####: 234: if (! flush_out(rstrm, FALSE)) #####: 235: return (FALSE); #####: 236: dest_lp = ((int32_t *)(void *)(rstrm->out_finger)); -: 237: } 336: 238: rstrm->out_finger += BYTES_PER_XDR_UNIT; 336: 239: *dest_lp = (int32_t)htonl((uint32_t)(*lp)); 336: 240: return (TRUE); -: 241:} -: 242: -: 243:static bool_t /* must manage buffers, fragments, and records */ 168: 244:xdrrec_getbytes(XDR *xdrs, caddr_t addr, u_int len) -: 245:{ 168: 246: register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); -: 247: register int current; -: 248: 546: 249: while (len > 0) { 216: 250: current = rstrm->fbtbc; 216: 251: if (current == 0) { 54: 252: if (rstrm->last_frag) #####: 253: return (FALSE); 54: 254: if (! set_input_fragment(rstrm)) 6: 255: return (FALSE); 48: 256: continue; -: 257: } 162: 258: current = (len < current) ? len : current; 162: 259: if (! get_input_bytes(rstrm, addr, current)) #####: 260: return (FALSE); 162: 261: addr += current; 162: 262: rstrm->fbtbc -= current; 162: 263: len -= current; -: 264: } 162: 265: return (TRUE); -: 266:} -: 267: -: 268:static bool_t 150: 269:xdrrec_putbytes(XDR *xdrs, caddr_t addr, u_int len) -: 270:{ 150: 271: register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); -: 272: register size_t current; -: 273: 450: 274: while (len > 0) { 150: 275: current = (size_t) ((long)rstrm->out_boundry - -: 276: (long)rstrm->out_finger); 150: 277: current = (len < current) ? len : current; 150: 278: memmove(rstrm->out_finger, addr, current); 150: 279: rstrm->out_finger += current; 150: 280: addr += current; 150: 281: len -= current; 150: 282: if (rstrm->out_finger == rstrm->out_boundry) { #####: 283: rstrm->frag_sent = TRUE; #####: 284: if (! flush_out(rstrm, FALSE)) #####: 285: return (FALSE); -: 286: } -: 287: } 150: 288: return (TRUE); -: 289:} -: 290: -: 291:static u_int 36: 292:xdrrec_getpos(XDR *xdrs) -: 293:{ 36: 294: register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; -: 295: register int pos; -: 296: 36: 297: switch (xdrs->x_op) { -: 298: -: 299: case XDR_ENCODE: 36: 300: pos = rstrm->out_finger - rstrm->out_base 36: 301: - BYTES_PER_XDR_UNIT; 36: 302: break; -: 303: -: 304: case XDR_DECODE: #####: 305: pos = rstrm->in_boundry - rstrm->in_finger #####: 306: - BYTES_PER_XDR_UNIT; #####: 307: break; -: 308: -: 309: default: #####: 310: pos = -1; -: 311: break; -: 312: } 36: 313: return ((u_int) pos); -: 314:} -: 315: -: 316:static bool_t 18: 317:xdrrec_setpos(XDR *xdrs, u_int pos) -: 318:{ 18: 319: register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; 18: 320: u_int currpos = xdrrec_getpos(xdrs); 18: 321: int delta = currpos - pos; -: 322: caddr_t newpos; -: 323: 18: 324: if ((int)currpos != -1) 18: 325: switch (xdrs->x_op) { -: 326: -: 327: case XDR_ENCODE: 18: 328: newpos = rstrm->out_finger - delta; 36: 329: if ((newpos > (caddr_t)(rstrm->frag_header)) && 18: 330: (newpos < rstrm->out_boundry)) { 18: 331: rstrm->out_finger = newpos; 18: 332: return (TRUE); -: 333: } #####: 334: break; -: 335: -: 336: case XDR_DECODE: #####: 337: newpos = rstrm->in_finger - delta; #####: 338: if ((delta < (int)(rstrm->fbtbc)) && #####: 339: (newpos <= rstrm->in_boundry) && #####: 340: (newpos >= rstrm->in_base)) { #####: 341: rstrm->in_finger = newpos; #####: 342: rstrm->fbtbc -= delta; #####: 343: return (TRUE); -: 344: } -: 345: break; -: 346: -: 347: case XDR_FREE: -: 348: break; -: 349: } #####: 350: return (FALSE); -: 351:} -: 352: -: 353:static rpc_inline_t * 48: 354:xdrrec_inline(XDR *xdrs, int len) -: 355:{ 48: 356: register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; 48: 357: rpc_inline_t * buf = NULL; -: 358: 48: 359: if (len < 0) #####: 360: return (FALSE); -: 361: 48: 362: switch (xdrs->x_op) { -: 363: -: 364: case XDR_ENCODE: 18: 365: if (len <= (rstrm->out_boundry - rstrm->out_finger)) { 18: 366: buf = (rpc_inline_t *)(void *) rstrm->out_finger; 18: 367: rstrm->out_finger += len; -: 368: } 18: 369: break; -: 370: -: 371: case XDR_DECODE: 30: 372: if ((len <= rstrm->fbtbc) && #####: 373: (len <= (rstrm->in_boundry - rstrm->in_finger))) { #####: 374: buf = (rpc_inline_t *)(void *) rstrm->in_finger; #####: 375: rstrm->fbtbc -= len; #####: 376: rstrm->in_finger += len; -: 377: } -: 378: break; -: 379: -: 380: case XDR_FREE: -: 381: break; -: 382: } 48: 383: return (buf); -: 384:} -: 385: -: 386:static void 12: 387:xdrrec_destroy(XDR *xdrs) -: 388:{ 12: 389: register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; -: 390: 12: 391: mem_free(rstrm->the_buffer, -: 392: rstrm->sendsize + rstrm->recvsize + BYTES_PER_XDR_UNIT); 12: 393: mem_free((caddr_t)rstrm, sizeof(RECSTREAM)); 12: 394:} -: 395: -: 396: -: 397:/* -: 398: * Exported routines to manage xdr records -: 399: */ -: 400: -: 401:/* -: 402: * Before reading (deserializing from the stream, one should always call -: 403: * this procedure to guarantee proper record alignment. -: 404: */ -: 405:bool_t 54: 406:xdrrec_skiprecord(XDR *xdrs) -: 407:{ 54: 408: register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); -: 409: 108: 410: while (rstrm->fbtbc > 0 || (! rstrm->last_frag)) { #####: 411: if (! skip_input_bytes(rstrm, rstrm->fbtbc)) #####: 412: return (FALSE); #####: 413: rstrm->fbtbc = 0; #####: 414: if ((! rstrm->last_frag) && (! set_input_fragment(rstrm))) #####: 415: return (FALSE); -: 416: } 54: 417: rstrm->last_frag = FALSE; 54: 418: return (TRUE); -: 419:} -: 420: -: 421:/* -: 422: * Look ahead fuction. -: 423: * Returns TRUE iff there is no more input in the buffer -: 424: * after consuming the rest of the current record. -: 425: */ -: 426:bool_t 24: 427:xdrrec_eof(XDR *xdrs) -: 428:{ 24: 429: register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); -: 430: 54: 431: while (rstrm->fbtbc > 0 || (! rstrm->last_frag)) { 6: 432: if (! skip_input_bytes(rstrm, rstrm->fbtbc)) #####: 433: return (TRUE); 6: 434: rstrm->fbtbc = 0; 6: 435: if ((! rstrm->last_frag) && (! set_input_fragment(rstrm))) #####: 436: return (TRUE); -: 437: } 24: 438: if (rstrm->in_finger == rstrm->in_boundry) 24: 439: return (TRUE); #####: 440: return (FALSE); -: 441:} -: 442: -: 443:/* -: 444: * The client must tell the package when an end-of-record has occurred. -: 445: * The second paraemters tells whether the record should be flushed to the -: 446: * (output) tcp stream. (This let's the package support batched or -: 447: * pipelined procedure calls.) TRUE => immmediate flush to tcp connection. -: 448: */ -: 449:bool_t 48: 450:xdrrec_endofrecord(XDR *xdrs, bool_t sendnow) -: 451:{ 48: 452: register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); -: 453: register uint32_t len; /* fragment length */ -: 454: 48: 455: if (sendnow || rstrm->frag_sent || #####: 456: ((long)rstrm->out_finger + BYTES_PER_XDR_UNIT >= -: 457: (long)rstrm->out_boundry)) { 48: 458: rstrm->frag_sent = FALSE; 48: 459: return (flush_out(rstrm, TRUE)); -: 460: } #####: 461: len = (long)(rstrm->out_finger) - (long)(rstrm->frag_header) - -: 462: BYTES_PER_XDR_UNIT; #####: 463: *(rstrm->frag_header) = htonl((uint32_t)len | LAST_FRAG); #####: 464: rstrm->frag_header = (uint32_t *)(void *)rstrm->out_finger; #####: 465: rstrm->out_finger += BYTES_PER_XDR_UNIT; #####: 466: return (TRUE); -: 467:} -: 468: -: 469: -: 470:/* -: 471: * Internal useful routines -: 472: */ -: 473:static bool_t 48: 474:flush_out(RECSTREAM *rstrm, bool_t eor) -: 475:{ 48: 476: register uint32_t eormask = (eor == TRUE) ? LAST_FRAG : 0; 48: 477: register uint32_t len = (u_long)(rstrm->out_finger) - 48: 478: (u_long)(rstrm->frag_header) - BYTES_PER_XDR_UNIT; -: 479: 48: 480: *(rstrm->frag_header) = htonl(len | eormask); 48: 481: len = (u_long)(rstrm->out_finger) - (u_long)(rstrm->out_base); 48: 482: if ((*(rstrm->writeit))(rstrm->tcp_handle, rstrm->out_base, (int)len) -: 483: != (int)len) #####: 484: return (FALSE); 48: 485: rstrm->frag_header = (uint32_t *)(void *)rstrm->out_base; 48: 486: rstrm->out_finger = (caddr_t)rstrm->out_base + BYTES_PER_XDR_UNIT; 48: 487: return (TRUE); -: 488:} -: 489: -: 490:static bool_t /* knows nothing about records! Only about input buffers */ 54: 491:fill_input_buf(RECSTREAM *rstrm) -: 492:{ -: 493: register caddr_t where; -: 494: u_int i; -: 495: register int len; -: 496: 54: 497: where = rstrm->in_base; 54: 498: i = (u_int)((u_long)rstrm->in_boundry % BYTES_PER_XDR_UNIT); 54: 499: where += i; 54: 500: len = rstrm->in_size - i; 54: 501: if ((len = (*(rstrm->readit))(rstrm->tcp_handle, where, len)) == -1) 6: 502: return (FALSE); 48: 503: rstrm->in_finger = where; 48: 504: where += len; 48: 505: rstrm->in_boundry = where; 48: 506: return (TRUE); -: 507:} -: 508: -: 509:static bool_t /* knows nothing about records! Only about input buffers */ 216: 510:get_input_bytes(RECSTREAM *rstrm, caddr_t addr, int len) -: 511:{ -: 512: register size_t current; -: 513: 690: 514: while (len > 0) { 264: 515: current = (size_t)((long)rstrm->in_boundry - -: 516: (long)rstrm->in_finger); 264: 517: if (current == 0) { 54: 518: if (! fill_input_buf(rstrm)) 6: 519: return (FALSE); 48: 520: continue; -: 521: } 210: 522: current = (len < current) ? len : current; 210: 523: memmove(addr, rstrm->in_finger, current); 210: 524: rstrm->in_finger += current; 210: 525: addr += current; 210: 526: len -= current; -: 527: } 210: 528: return (TRUE); -: 529:} -: 530: -: 531:static bool_t /* next four bytes of input stream are treated as a header */ 54: 532:set_input_fragment(rstrm) -: 533: register RECSTREAM *rstrm; -: 534:{ -: 535: uint32_t header; -: 536: 54: 537: if (! get_input_bytes(rstrm, (caddr_t)&header, sizeof(header))) 6: 538: return (FALSE); 48: 539: header = ntohl(header); 48: 540: rstrm->last_frag = ((header & LAST_FRAG) == 0) ? FALSE : TRUE; 48: 541: rstrm->fbtbc = header & (~LAST_FRAG); 48: 542: return (TRUE); -: 543:} -: 544: -: 545:static bool_t /* consumes input bytes; knows nothing about records! */ 6: 546:skip_input_bytes(RECSTREAM *rstrm, int32_t cnt) -: 547:{ -: 548: register int current; -: 549: 18: 550: while (cnt > 0) { 6: 551: current = (int)((long)rstrm->in_boundry - -: 552: (long)rstrm->in_finger); 6: 553: if (current == 0) { #####: 554: if (! fill_input_buf(rstrm)) #####: 555: return (FALSE); #####: 556: continue; -: 557: } 6: 558: current = (cnt < current) ? cnt : current; 6: 559: rstrm->in_finger += current; 6: 560: cnt -= current; -: 561: } 6: 562: return (TRUE); -: 563:} -: 564: -: 565:static u_int 24: 566:fix_buf_size(u_int s) -: 567:{ -: 568: 24: 569: if (s < 100) 24: 570: s = 4000; 24: 571: return (RNDUP(s)); -: 572:}