/* * XDR opaque data * Allows the specification of a fixed size sequence of opaque bytes. * cp points to the opaque object and cnt gives the byte length. */ bool_t xdr_opaque( XDR *xdrs, caddr_t cp, u_int cnt) { u_int rndup; static int crud[BYTES_PER_XDR_UNIT]; /* * if no data we are done */ if (cnt == 0) return (TRUE); /* * round byte count to full xdr units */ rndup = cnt % BYTES_PER_XDR_UNIT; if (rndup > 0) rndup = BYTES_PER_XDR_UNIT - rndup; if (xdrs->x_op == XDR_DECODE) { if (!XDR_GETBYTES(xdrs, cp, cnt)) { return (FALSE); } if (rndup == 0) return (TRUE); return (XDR_GETBYTES(xdrs, (caddr_t)crud, rndup)); } if (xdrs->x_op == XDR_ENCODE) { if (!XDR_PUTBYTES(xdrs, cp, cnt)) { return (FALSE); } if (rndup == 0) return (TRUE); return (XDR_PUTBYTES(xdrs, xdr_zero, rndup)); } if (xdrs->x_op == XDR_FREE) { return (TRUE); } return (FALSE); }
/* * XDR opaque data * Allows the specification of a fixed size sequence of opaque bytes. * cp points to the opaque object and cnt gives the byte length. */ bool_t xdr_opaque(XDR *xdrs, caddr_t cp, const uint_t cnt) { uint_t rndup; char crud[BYTES_PER_XDR_UNIT]; /* * if no data we are done */ if (cnt == 0) return (TRUE); /* * round byte count to full xdr units */ rndup = cnt % BYTES_PER_XDR_UNIT; if ((int)rndup > 0) rndup = BYTES_PER_XDR_UNIT - rndup; switch (xdrs->x_op) { case XDR_DECODE: if (!XDR_GETBYTES(xdrs, cp, cnt)) return (FALSE); if (rndup == 0) return (TRUE); return (XDR_GETBYTES(xdrs, crud, rndup)); case XDR_ENCODE: if (!XDR_PUTBYTES(xdrs, cp, cnt)) return (FALSE); if (rndup == 0) return (TRUE); return (XDR_PUTBYTES(xdrs, (caddr_t)&xdr_zero[0], rndup)); case XDR_FREE: return (TRUE); } return (FALSE); }