XDR ライブラリは、次のサンプルプログラムのように、固定長配列用のプリミティブ xdr_vector() を提供します。
#define NLEN 255 /* マシン名は 255 文字以下 */
#define NGRPS 20 /* ユーザーは正確に 20 のグループに所属 */
struct netuser {
char *nu_machinename;
int nu_uid;
int nu_gids[NGRPS];
};
bool_t
xdr_netuser(xdrs, nup)
XDR *xdrs;
struct netuser *nup;
{
int i;
if (!xdr_string(xdrs, &nup->nu_machinename, NLEN))
return(FALSE);
if (!xdr_int(xdrs, &nup->nu_uid))
return(FALSE);
if (!xdr_vector(xdrs, nup->nu_gids, NGRPS, sizeof(int),
xdr_int))
return(FALSE);
return(TRUE);
}