Created
April 15, 2013 16:28
-
-
Save Supermathie/5389349 to your computer and use it in GitHub Desktop.
xdr_opaque glibc source (RHEl6)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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 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 (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, (caddr_t)crud, rndup); | |
case XDR_ENCODE: | |
if (!XDR_PUTBYTES (xdrs, cp, cnt)) | |
{ | |
return FALSE; | |
} | |
if (rndup == 0) | |
return TRUE; | |
return XDR_PUTBYTES (xdrs, xdr_zero, rndup); | |
case XDR_FREE: | |
return TRUE; | |
} | |
return FALSE; | |
} | |
INTDEF(xdr_opaque) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment