diff --git a/mfhdf/xdr/xdr.c b/mfhdf/xdr/xdr.c index 616d5920..19bec832 100644 --- a/mfhdf/xdr/xdr.c +++ b/mfhdf/xdr/xdr.c @@ -549,3 +549,34 @@ xdr_wrapstring(xdrs, cpp) } return (FALSE); } + +bool_t +xdr_hyper (XDR *xdrs, quad_t *llp) +{ + long int t1, t2; + + printf("xdr_hyper...\n"); + if (xdrs->x_op == XDR_ENCODE) + { + t1 = (long) ((*llp) >> 32); + t2 = (long) (*llp); + return (XDR_PUTLONG(xdrs, &t1) && XDR_PUTLONG(xdrs, &t2)); + } + + if (xdrs->x_op == XDR_DECODE) + { + if (!XDR_GETLONG(xdrs, &t1) || !XDR_GETLONG(xdrs, &t2)) + return FALSE; + printf("t1 = %ld, t2 = %ld\n", t1, t2); + *llp = ((quad_t) t1) << 32; + *llp |= (uint32_t) t2; + return TRUE; + } + + if (xdrs->x_op == XDR_FREE) + return TRUE; + + return FALSE; +} + + diff --git a/mfhdf/xdr/xdr.h b/mfhdf/xdr/xdr.h index 2ee293dc..08c54b24 100644 --- a/mfhdf/xdr/xdr.h +++ b/mfhdf/xdr/xdr.h @@ -50,6 +50,7 @@ enum xdr_op { XDR_FREE=2 }; +typedef long long quad_t; /* * This is the number of bytes per unit of external data. */ @@ -202,6 +203,7 @@ XDRLIBAPI bool_t xdr_int(XDR *, int *); XDRLIBAPI bool_t xdr_u_int(XDR *, u_int *); XDRLIBAPI bool_t xdr_long(XDR *, long *); XDRLIBAPI bool_t xdr_u_long(XDR *, u_long *); +XDRLIBAPI bool_t xdr_hyper(XDR *, quad_t *); XDRLIBAPI bool_t xdr_short(XDR *, short *); XDRLIBAPI bool_t xdr_u_short(XDR *, u_short *); XDRLIBAPI bool_t xdr_bool(XDR *, bool_t *); diff --git a/mfhdf/xdr/xdrtest.c b/mfhdf/xdr/xdrtest.c index 1a393cfc..07323195 100644 --- a/mfhdf/xdr/xdrtest.c +++ b/mfhdf/xdr/xdrtest.c @@ -105,8 +105,8 @@ char *av[] ; long lnum = 82555 ; - static long longs[5] = { -4, -3, -2, -1, 0} ; - long *lp , got_al[5] ; + static long long longs[5] = { -4, -3, -2, -1, 0} ; + quad_t *lp , got_al[5] ; static unsigned long u_longs[5] = { ((unsigned)65535), @@ -187,7 +187,7 @@ char *av[] ; assert( xdr_setpos(xdrs, seeks[jj])) ; szof = sizeof(long) ; count = sizeof(longs)/sizeof(long) ; - assert( xdr_vector(xdrs, (char *)longs, count, szof, xdr_long)) ; + assert( xdr_vector(xdrs, (char *)longs, count, szof, xdr_hyper)) ; poses[jj++] = xdr_getpos(xdrs) ; assert( xdr_setpos(xdrs, seeks[jj])) ; @@ -296,7 +296,8 @@ char *av[] ; assert( xdr_setpos(xdrs, seeks[jj])) ; szof = sizeof(long) ; count = sizeof(longs)/sizeof(long) ; - assert( xdr_vector(xdrs, (char *)got_al, count, szof, xdr_long)) ; + + assert( xdr_vector(xdrs, (char *)got_al, count, szof, xdr_hyper)) ; assert( poses[jj++] = xdr_getpos(xdrs) ) ; printf("longs: "); for(ii = 0, lp = got_al ;