xdr_vector() ライブラリでは、例 A-11サンプルプログラムで示すように、固定長配列に対するプリミティブ 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);
}
|