// -*-c++-*-
/* This file was automatically generated by rpcc. */

#ifndef __RPCC_SFSAUTH_PROT_H_INCLUDED__
#define __RPCC_SFSAUTH_PROT_H_INCLUDED__ 1

#include "xdrmisc.h"
#include "sfs_prot.h"

typedef rpc_str<RPC_INFINITY> sfsauth_errmsg;
void *sfsauth_errmsg_alloc ();
bool_t xdr_sfsauth_errmsg (XDR *, void *);
RPC_TYPEDEF_DECL (sfsauth_errmsg)

enum { SPRIVK_HISTORY_LEN = 2 };


struct sfs_authreq2 {
  sfs_msgtype type;
  sfs_hash authid;
  sfs_seqno seqno;
  sfs_idname user;
};
void *sfs_authreq2_alloc ();
bool_t xdr_sfs_authreq2 (XDR *, void *);
RPC_STRUCT_DECL (sfs_authreq2)

template<class T> bool
rpc_traverse (T &t, sfs_authreq2 &obj)
{
  return rpc_traverse (t, obj.type)
    && rpc_traverse (t, obj.authid)
    && rpc_traverse (t, obj.seqno)
    && rpc_traverse (t, obj.user);
}



struct sfs_sigauth {
  sfs_authreq2 req;
  sfs_pubkey2 key;
  sfs_sig2 sig;
};
void *sfs_sigauth_alloc ();
bool_t xdr_sfs_sigauth (XDR *, void *);
RPC_STRUCT_DECL (sfs_sigauth)

template<class T> bool
rpc_traverse (T &t, sfs_sigauth &obj)
{
  return rpc_traverse (t, obj.req)
    && rpc_traverse (t, obj.key)
    && rpc_traverse (t, obj.sig);
}



struct sfs_unixpwauth {
  sfs_authreq2 req;
  rpc_str<RPC_INFINITY> password;
};
void *sfs_unixpwauth_alloc ();
bool_t xdr_sfs_unixpwauth (XDR *, void *);
RPC_STRUCT_DECL (sfs_unixpwauth)

template<class T> bool
rpc_traverse (T &t, sfs_unixpwauth &obj)
{
  return rpc_traverse (t, obj.req)
    && rpc_traverse (t, obj.password);
}



struct sfs_srpauth {
  sfs_authreq2 req;
  rpc_bytes<RPC_INFINITY> msg;
};
void *sfs_srpauth_alloc ();
bool_t xdr_sfs_srpauth (XDR *, void *);
RPC_STRUCT_DECL (sfs_srpauth)

template<class T> bool
rpc_traverse (T &t, sfs_srpauth &obj)
{
  return rpc_traverse (t, obj.req)
    && rpc_traverse (t, obj.msg);
}



struct sfs_autharg2 {
  const sfs_authtype type;
  union {
    union_entry_base _base;
    union_entry<sfs_authreq> authreq1;
    union_entry<sfs_sigauth> sigauth;
    union_entry<sfs_unixpwauth> pwauth;
    union_entry<sfs_srpauth> srpauth;
  };

#define rpcunion_tag_sfs_autharg2 type
#define rpcunion_switch_sfs_autharg2(swarg, action, voidaction, defaction) \
  switch (swarg) { \
  case SFS_AUTHREQ: \
    action (sfs_authreq, authreq1); \
    break; \
  case SFS_AUTHREQ2: \
    action (sfs_sigauth, sigauth); \
    break; \
  case SFS_UNIXPWAUTH: \
    action (sfs_unixpwauth, pwauth); \
    break; \
  case SFS_SRPAUTH: \
    action (sfs_srpauth, srpauth); \
    break; \
  default: \
    defaction; \
    break; \
  }

  sfs_autharg2 (sfs_authtype _tag = (sfs_authtype) 0) : type (_tag)
    { _base.init (); set_type (_tag); }
  sfs_autharg2 (const sfs_autharg2 &_s)
    : type (_s.type)
    { _base.init (_s._base); }
  ~sfs_autharg2 () { _base.destroy (); }
  sfs_autharg2 &operator= (const sfs_autharg2 &_s) {
    const_cast<sfs_authtype &> (type) = _s.type;
    _base.assign (_s._base);
    return *this;
  }

  void set_type (sfs_authtype _tag) {
    const_cast<sfs_authtype &> (type) = _tag;
    rpcunion_switch_sfs_autharg2
      (_tag, RPCUNION_SET, _base.destroy (), _base.destroy ());
  }
};

template<class T> bool
rpc_traverse (T &t, sfs_autharg2 &obj)
{
  sfs_authtype tag = obj.type;
  if (!rpc_traverse (t, tag))
    return false;
  if (tag != obj.type)
    obj.set_type (tag);

  rpcunion_switch_sfs_autharg2
    (obj.type, RPCUNION_TRAVERSE, return true, return false);
}
inline bool
rpc_traverse (const stompcast_t &s, sfs_autharg2 &obj)
{
  rpcunion_switch_sfs_autharg2
    (obj.type, RPCUNION_REC_STOMPCAST,
     obj._base.destroy (); return true, obj._base.destroy (); return true;);
}
void *sfs_autharg2_alloc ();
bool_t xdr_sfs_autharg2 (XDR *, void *);
RPC_UNION_DECL (sfs_autharg2)



struct sfsauth2_loginarg {
  sfs_loginarg arg;
  sfs_hash authid;
  rpc_str<RPC_INFINITY> source;
};
void *sfsauth2_loginarg_alloc ();
bool_t xdr_sfsauth2_loginarg (XDR *, void *);
RPC_STRUCT_DECL (sfsauth2_loginarg)

template<class T> bool
rpc_traverse (T &t, sfsauth2_loginarg &obj)
{
  return rpc_traverse (t, obj.arg)
    && rpc_traverse (t, obj.authid)
    && rpc_traverse (t, obj.source);
}



struct sfsauth2_loginokres {
  rpc_vec<sfsauth_cred, RPC_INFINITY> creds;
  rpc_bytes<RPC_INFINITY> resmore;
  rpc_str<RPC_INFINITY> hello;
};
void *sfsauth2_loginokres_alloc ();
bool_t xdr_sfsauth2_loginokres (XDR *, void *);
RPC_STRUCT_DECL (sfsauth2_loginokres)

template<class T> bool
rpc_traverse (T &t, sfsauth2_loginokres &obj)
{
  return rpc_traverse (t, obj.creds)
    && rpc_traverse (t, obj.resmore)
    && rpc_traverse (t, obj.hello);
}



struct sfsauth2_loginres {
  const sfs_loginstat status;
  union {
    union_entry_base _base;
    union_entry<sfsauth2_loginokres> resok;
    union_entry<rpc_bytes<RPC_INFINITY> > resmore;
    union_entry<sfsauth_errmsg> errmsg;
  };

#define rpcunion_tag_sfsauth2_loginres status
#define rpcunion_switch_sfsauth2_loginres(swarg, action, voidaction, defaction) \
  switch (swarg) { \
  case SFSLOGIN_OK: \
    action (sfsauth2_loginokres, resok); \
    break; \
  case SFSLOGIN_MORE: \
    action (opaque, resmore); \
    break; \
  case SFSLOGIN_BAD: \
    action (sfsauth_errmsg, errmsg); \
    break; \
  default: \
    voidaction; \
    break; \
  }

  sfsauth2_loginres (sfs_loginstat _tag = (sfs_loginstat) 0) : status (_tag)
    { _base.init (); set_status (_tag); }
  sfsauth2_loginres (const sfsauth2_loginres &_s)
    : status (_s.status)
    { _base.init (_s._base); }
  ~sfsauth2_loginres () { _base.destroy (); }
  sfsauth2_loginres &operator= (const sfsauth2_loginres &_s) {
    const_cast<sfs_loginstat &> (status) = _s.status;
    _base.assign (_s._base);
    return *this;
  }

  void set_status (sfs_loginstat _tag) {
    const_cast<sfs_loginstat &> (status) = _tag;
    rpcunion_switch_sfsauth2_loginres
      (_tag, RPCUNION_SET, _base.destroy (), _base.destroy ());
  }
};

template<class T> bool
rpc_traverse (T &t, sfsauth2_loginres &obj)
{
  sfs_loginstat tag = obj.status;
  if (!rpc_traverse (t, tag))
    return false;
  if (tag != obj.status)
    obj.set_status (tag);

  rpcunion_switch_sfsauth2_loginres
    (obj.status, RPCUNION_TRAVERSE, return true, return false);
}
inline bool
rpc_traverse (const stompcast_t &s, sfsauth2_loginres &obj)
{
  rpcunion_switch_sfsauth2_loginres
    (obj.status, RPCUNION_REC_STOMPCAST,
     obj._base.destroy (); return true, obj._base.destroy (); return true;);
}
void *sfsauth2_loginres_alloc ();
bool_t xdr_sfsauth2_loginres (XDR *, void *);
RPC_UNION_DECL (sfsauth2_loginres)


enum sfsauth_keyhalf_type {
  SFSAUTH_KEYHALF_NONE = 0,
  SFSAUTH_KEYHALF_PRIV = 1,
  SFSAUTH_KEYHALF_DELTA = 2,
  SFSAUTH_KEYHALF_FLAG = 3,
};
void *sfsauth_keyhalf_type_alloc ();
bool_t xdr_sfsauth_keyhalf_type (XDR *, void *);
RPC_ENUM_DECL (sfsauth_keyhalf_type)

template<class T> inline bool
rpc_traverse (T &t, sfsauth_keyhalf_type &obj)
{
  u_int32_t val = obj;
  if (!rpc_traverse (t, val))
    return false;
  obj = sfsauth_keyhalf_type (val);
  return true;
}


struct sfsauth_keyhalf {
  const sfsauth_keyhalf_type type;
  union {
    union_entry_base _base;
    union_entry<rpc_vec<sfs_2schnorr_priv_xdr, SPRIVK_HISTORY_LEN> > priv;
    union_entry<bigint> delta;
  };

#define rpcunion_tag_sfsauth_keyhalf type
#define rpcunion_switch_sfsauth_keyhalf(swarg, action, voidaction, defaction) \
  switch (swarg) { \
  case SFSAUTH_KEYHALF_NONE: \
    voidaction; \
    break; \
  case SFSAUTH_KEYHALF_PRIV: \
    action (sfs_2schnorr_priv_xdr, priv); \
    break; \
  case SFSAUTH_KEYHALF_DELTA: \
    action (bigint, delta); \
    break; \
  case SFSAUTH_KEYHALF_FLAG: \
    voidaction; \
    break; \
  default: \
    defaction; \
    break; \
  }

  sfsauth_keyhalf (sfsauth_keyhalf_type _tag = (sfsauth_keyhalf_type) 0) : type (_tag)
    { _base.init (); set_type (_tag); }
  sfsauth_keyhalf (const sfsauth_keyhalf &_s)
    : type (_s.type)
    { _base.init (_s._base); }
  ~sfsauth_keyhalf () { _base.destroy (); }
  sfsauth_keyhalf &operator= (const sfsauth_keyhalf &_s) {
    const_cast<sfsauth_keyhalf_type &> (type) = _s.type;
    _base.assign (_s._base);
    return *this;
  }

  void set_type (sfsauth_keyhalf_type _tag) {
    const_cast<sfsauth_keyhalf_type &> (type) = _tag;
    rpcunion_switch_sfsauth_keyhalf
      (_tag, RPCUNION_SET, _base.destroy (), _base.destroy ());
  }
};

template<class T> bool
rpc_traverse (T &t, sfsauth_keyhalf &obj)
{
  sfsauth_keyhalf_type tag = obj.type;
  if (!rpc_traverse (t, tag))
    return false;
  if (tag != obj.type)
    obj.set_type (tag);

  rpcunion_switch_sfsauth_keyhalf
    (obj.type, RPCUNION_TRAVERSE, return true, return false);
}
inline bool
rpc_traverse (const stompcast_t &s, sfsauth_keyhalf &obj)
{
  rpcunion_switch_sfsauth_keyhalf
    (obj.type, RPCUNION_REC_STOMPCAST,
     obj._base.destroy (); return true, obj._base.destroy (); return true;);
}
void *sfsauth_keyhalf_alloc ();
bool_t xdr_sfsauth_keyhalf (XDR *, void *);
RPC_UNION_DECL (sfsauth_keyhalf)


const u_int32_t sfsauth_noid = 0xffffffff;


struct sfsauth_userinfo {
  sfs_idname name;
  u_int32_t id;
  u_int32_t vers;
  u_int32_t gid;
  rpc_ptr<sfs_idname> owner;
  sfs_pubkey2 pubkey;
  rpc_str<RPC_INFINITY> privs;
  rpc_str<RPC_INFINITY> pwauth;
  sfs_privkey2 privkey;
  sfsauth_keyhalf srvprivkey;
  rpc_str<RPC_INFINITY> audit;
  u_int64_t mask;
};
void *sfsauth_userinfo_alloc ();
bool_t xdr_sfsauth_userinfo (XDR *, void *);
RPC_STRUCT_DECL (sfsauth_userinfo)

template<class T> bool
rpc_traverse (T &t, sfsauth_userinfo &obj)
{
  return rpc_traverse (t, obj.name)
    && rpc_traverse (t, obj.id)
    && rpc_traverse (t, obj.vers)
    && rpc_traverse (t, obj.gid)
    && rpc_traverse (t, obj.owner)
    && rpc_traverse (t, obj.pubkey)
    && rpc_traverse (t, obj.privs)
    && rpc_traverse (t, obj.pwauth)
    && rpc_traverse (t, obj.privkey)
    && rpc_traverse (t, obj.srvprivkey)
    && rpc_traverse (t, obj.audit)
    && rpc_traverse (t, obj.mask);
}



struct sfsauth_groupinfo {
  sfs_idname name;
  u_int32_t id;
  u_int32_t vers;
  rpc_vec<sfs_idname, RPC_INFINITY> owners;
  rpc_vec<sfs_idname, RPC_INFINITY> members;
  rpc_str<RPC_INFINITY> audit;
};
void *sfsauth_groupinfo_alloc ();
bool_t xdr_sfsauth_groupinfo (XDR *, void *);
RPC_STRUCT_DECL (sfsauth_groupinfo)

template<class T> bool
rpc_traverse (T &t, sfsauth_groupinfo &obj)
{
  return rpc_traverse (t, obj.name)
    && rpc_traverse (t, obj.id)
    && rpc_traverse (t, obj.vers)
    && rpc_traverse (t, obj.owners)
    && rpc_traverse (t, obj.members)
    && rpc_traverse (t, obj.audit);
}



struct sfsauth_ids {
  sfs_idname user;
  u_int32_t uid;
  u_int32_t gid;
  rpc_vec<u_int32_t, RPC_INFINITY> gidlist;
};
void *sfsauth_ids_alloc ();
bool_t xdr_sfsauth_ids (XDR *, void *);
RPC_STRUCT_DECL (sfsauth_ids)

template<class T> bool
rpc_traverse (T &t, sfsauth_ids &obj)
{
  return rpc_traverse (t, obj.user)
    && rpc_traverse (t, obj.uid)
    && rpc_traverse (t, obj.gid)
    && rpc_traverse (t, obj.gidlist);
}



struct sfsauth_srpparms {
  u_int32_t pwcost;
  rpc_str<RPC_INFINITY> parms;
};
void *sfsauth_srpparms_alloc ();
bool_t xdr_sfsauth_srpparms (XDR *, void *);
RPC_STRUCT_DECL (sfsauth_srpparms)

template<class T> bool
rpc_traverse (T &t, sfsauth_srpparms &obj)
{
  return rpc_traverse (t, obj.pwcost)
    && rpc_traverse (t, obj.parms);
}


enum sfsauth_dbtype {
  SFSAUTH_ERROR = 0,
  SFSAUTH_USER = 1,
  SFSAUTH_GROUP = 2,
  SFSAUTH_IDS = 3,
  SFSAUTH_SRPPARMS = 5,
  SFSAUTH_CERTINFO = 6,
};
void *sfsauth_dbtype_alloc ();
bool_t xdr_sfsauth_dbtype (XDR *, void *);
RPC_ENUM_DECL (sfsauth_dbtype)

template<class T> inline bool
rpc_traverse (T &t, sfsauth_dbtype &obj)
{
  u_int32_t val = obj;
  if (!rpc_traverse (t, val))
    return false;
  obj = sfsauth_dbtype (val);
  return true;
}


struct sfsauth_dbrec {
  const sfsauth_dbtype type;
  union {
    union_entry_base _base;
    union_entry<sfsauth_errmsg> errmsg;
    union_entry<sfsauth_userinfo> userinfo;
    union_entry<sfsauth_groupinfo> groupinfo;
    union_entry<sfsauth_ids> ids;
    union_entry<sfsauth_srpparms> srpparms;
    union_entry<sfsauth_certinfores> certinfo;
  };

#define rpcunion_tag_sfsauth_dbrec type
#define rpcunion_switch_sfsauth_dbrec(swarg, action, voidaction, defaction) \
  switch (swarg) { \
  case SFSAUTH_ERROR: \
    action (sfsauth_errmsg, errmsg); \
    break; \
  case SFSAUTH_USER: \
    action (sfsauth_userinfo, userinfo); \
    break; \
  case SFSAUTH_GROUP: \
    action (sfsauth_groupinfo, groupinfo); \
    break; \
  case SFSAUTH_IDS: \
    action (sfsauth_ids, ids); \
    break; \
  case SFSAUTH_SRPPARMS: \
    action (sfsauth_srpparms, srpparms); \
    break; \
  case SFSAUTH_CERTINFO: \
    action (sfsauth_certinfores, certinfo); \
    break; \
  default: \
    defaction; \
    break; \
  }

  sfsauth_dbrec (sfsauth_dbtype _tag = (sfsauth_dbtype) 0) : type (_tag)
    { _base.init (); set_type (_tag); }
  sfsauth_dbrec (const sfsauth_dbrec &_s)
    : type (_s.type)
    { _base.init (_s._base); }
  ~sfsauth_dbrec () { _base.destroy (); }
  sfsauth_dbrec &operator= (const sfsauth_dbrec &_s) {
    const_cast<sfsauth_dbtype &> (type) = _s.type;
    _base.assign (_s._base);
    return *this;
  }

  void set_type (sfsauth_dbtype _tag) {
    const_cast<sfsauth_dbtype &> (type) = _tag;
    rpcunion_switch_sfsauth_dbrec
      (_tag, RPCUNION_SET, _base.destroy (), _base.destroy ());
  }
};

template<class T> bool
rpc_traverse (T &t, sfsauth_dbrec &obj)
{
  sfsauth_dbtype tag = obj.type;
  if (!rpc_traverse (t, tag))
    return false;
  if (tag != obj.type)
    obj.set_type (tag);

  rpcunion_switch_sfsauth_dbrec
    (obj.type, RPCUNION_TRAVERSE, return true, return false);
}
inline bool
rpc_traverse (const stompcast_t &s, sfsauth_dbrec &obj)
{
  rpcunion_switch_sfsauth_dbrec
    (obj.type, RPCUNION_REC_STOMPCAST,
     obj._base.destroy (); return true, obj._base.destroy (); return true;);
}
void *sfsauth_dbrec_alloc ();
bool_t xdr_sfsauth_dbrec (XDR *, void *);
RPC_UNION_DECL (sfsauth_dbrec)


enum sfsauth_dbkeytype {
  SFSAUTH_DBKEY_NULL = 0,
  SFSAUTH_DBKEY_NAME = 1,
  SFSAUTH_DBKEY_ID = 2,
  SFSAUTH_DBKEY_PUBKEY = 3,
};
void *sfsauth_dbkeytype_alloc ();
bool_t xdr_sfsauth_dbkeytype (XDR *, void *);
RPC_ENUM_DECL (sfsauth_dbkeytype)

template<class T> inline bool
rpc_traverse (T &t, sfsauth_dbkeytype &obj)
{
  u_int32_t val = obj;
  if (!rpc_traverse (t, val))
    return false;
  obj = sfsauth_dbkeytype (val);
  return true;
}


struct sfsauth_dbkey {
  const sfsauth_dbkeytype type;
  union {
    union_entry_base _base;
    union_entry<sfs_idname> name;
    union_entry<u_int32_t> id;
    union_entry<sfs_pubkey2> key;
  };

#define rpcunion_tag_sfsauth_dbkey type
#define rpcunion_switch_sfsauth_dbkey(swarg, action, voidaction, defaction) \
  switch (swarg) { \
  case SFSAUTH_DBKEY_NULL: \
    voidaction; \
    break; \
  case SFSAUTH_DBKEY_NAME: \
    action (sfs_idname, name); \
    break; \
  case SFSAUTH_DBKEY_ID: \
    action (u_int32_t, id); \
    break; \
  case SFSAUTH_DBKEY_PUBKEY: \
    action (sfs_pubkey2, key); \
    break; \
  default: \
    defaction; \
    break; \
  }

  sfsauth_dbkey (sfsauth_dbkeytype _tag = (sfsauth_dbkeytype) 0) : type (_tag)
    { _base.init (); set_type (_tag); }
  sfsauth_dbkey (const sfsauth_dbkey &_s)
    : type (_s.type)
    { _base.init (_s._base); }
  ~sfsauth_dbkey () { _base.destroy (); }
  sfsauth_dbkey &operator= (const sfsauth_dbkey &_s) {
    const_cast<sfsauth_dbkeytype &> (type) = _s.type;
    _base.assign (_s._base);
    return *this;
  }

  void set_type (sfsauth_dbkeytype _tag) {
    const_cast<sfsauth_dbkeytype &> (type) = _tag;
    rpcunion_switch_sfsauth_dbkey
      (_tag, RPCUNION_SET, _base.destroy (), _base.destroy ());
  }
};

template<class T> bool
rpc_traverse (T &t, sfsauth_dbkey &obj)
{
  sfsauth_dbkeytype tag = obj.type;
  if (!rpc_traverse (t, tag))
    return false;
  if (tag != obj.type)
    obj.set_type (tag);

  rpcunion_switch_sfsauth_dbkey
    (obj.type, RPCUNION_TRAVERSE, return true, return false);
}
inline bool
rpc_traverse (const stompcast_t &s, sfsauth_dbkey &obj)
{
  rpcunion_switch_sfsauth_dbkey
    (obj.type, RPCUNION_REC_STOMPCAST,
     obj._base.destroy (); return true, obj._base.destroy (); return true;);
}
void *sfsauth_dbkey_alloc ();
bool_t xdr_sfsauth_dbkey (XDR *, void *);
RPC_UNION_DECL (sfsauth_dbkey)



struct sfsauth2_query_arg {
  sfsauth_dbtype type;
  sfsauth_dbkey key;
};
void *sfsauth2_query_arg_alloc ();
bool_t xdr_sfsauth2_query_arg (XDR *, void *);
RPC_STRUCT_DECL (sfsauth2_query_arg)

template<class T> bool
rpc_traverse (T &t, sfsauth2_query_arg &obj)
{
  return rpc_traverse (t, obj.type)
    && rpc_traverse (t, obj.key);
}


typedef sfsauth_dbrec sfsauth2_query_res;
void *sfsauth2_query_res_alloc ();
bool_t xdr_sfsauth2_query_res (XDR *, void *);
RPC_TYPEDEF_DECL (sfsauth2_query_res)

typedef u_int64_t sfs_update_opts;
void *sfs_update_opts_alloc ();
bool_t xdr_sfs_update_opts (XDR *, void *);
RPC_TYPEDEF_DECL (sfs_update_opts)


struct sfs_updatereq {
  sfs_msgtype type;
  sfs_hash authid;
  sfsauth_dbrec rec;
  sfs_update_opts opts;
};
void *sfs_updatereq_alloc ();
bool_t xdr_sfs_updatereq (XDR *, void *);
RPC_STRUCT_DECL (sfs_updatereq)

template<class T> bool
rpc_traverse (T &t, sfs_updatereq &obj)
{
  return rpc_traverse (t, obj.type)
    && rpc_traverse (t, obj.authid)
    && rpc_traverse (t, obj.rec)
    && rpc_traverse (t, obj.opts);
}



struct sfsauth2_update_arg {
  sfs_updatereq req;
  rpc_ptr<sfs_sig2> newsig;
  rpc_ptr<sfs_sig2> authsig;
};
void *sfsauth2_update_arg_alloc ();
bool_t xdr_sfsauth2_update_arg (XDR *, void *);
RPC_STRUCT_DECL (sfsauth2_update_arg)

template<class T> bool
rpc_traverse (T &t, sfsauth2_update_arg &obj)
{
  return rpc_traverse (t, obj.req)
    && rpc_traverse (t, obj.newsig)
    && rpc_traverse (t, obj.authsig);
}



struct sfsauth2_update_res {
  const bool ok;
  union {
    union_entry_base _base;
    union_entry<sfsauth_errmsg> errmsg;
  };

#define rpcunion_tag_sfsauth2_update_res ok
#define rpcunion_switch_sfsauth2_update_res(swarg, action, voidaction, defaction) \
  switch (swarg) { \
  case false: \
    action (sfsauth_errmsg, errmsg); \
    break; \
  case true: \
    voidaction; \
    break; \
  default: \
    defaction; \
    break; \
  }

  sfsauth2_update_res (bool _tag = (bool) 0) : ok (_tag)
    { _base.init (); set_ok (_tag); }
  sfsauth2_update_res (const sfsauth2_update_res &_s)
    : ok (_s.ok)
    { _base.init (_s._base); }
  ~sfsauth2_update_res () { _base.destroy (); }
  sfsauth2_update_res &operator= (const sfsauth2_update_res &_s) {
    const_cast<bool &> (ok) = _s.ok;
    _base.assign (_s._base);
    return *this;
  }

  void set_ok (bool _tag) {
    const_cast<bool &> (ok) = _tag;
    rpcunion_switch_sfsauth2_update_res
      (_tag, RPCUNION_SET, _base.destroy (), _base.destroy ());
  }
};

template<class T> bool
rpc_traverse (T &t, sfsauth2_update_res &obj)
{
  bool tag = obj.ok;
  if (!rpc_traverse (t, tag))
    return false;
  if (tag != obj.ok)
    obj.set_ok (tag);

  rpcunion_switch_sfsauth2_update_res
    (obj.ok, RPCUNION_TRAVERSE, return true, return false);
}
inline bool
rpc_traverse (const stompcast_t &s, sfsauth2_update_res &obj)
{
  rpcunion_switch_sfsauth2_update_res
    (obj.ok, RPCUNION_REC_STOMPCAST,
     obj._base.destroy (); return true, obj._base.destroy (); return true;);
}
void *sfsauth2_update_res_alloc ();
bool_t xdr_sfsauth2_update_res (XDR *, void *);
RPC_UNION_DECL (sfsauth2_update_res)



struct sfsauth2_presig {
  const sfs_keytype type;
  union {
    union_entry_base _base;
    union_entry<sfs_2schnorr_presig> schnorr;
  };

#define rpcunion_tag_sfsauth2_presig type
#define rpcunion_switch_sfsauth2_presig(swarg, action, voidaction, defaction) \
  switch (swarg) { \
  case SFS_2SCHNORR: \
    action (sfs_2schnorr_presig, schnorr); \
    break; \
  default: \
    voidaction; \
    break; \
  }

  sfsauth2_presig (sfs_keytype _tag = (sfs_keytype) 0) : type (_tag)
    { _base.init (); set_type (_tag); }
  sfsauth2_presig (const sfsauth2_presig &_s)
    : type (_s.type)
    { _base.init (_s._base); }
  ~sfsauth2_presig () { _base.destroy (); }
  sfsauth2_presig &operator= (const sfsauth2_presig &_s) {
    const_cast<sfs_keytype &> (type) = _s.type;
    _base.assign (_s._base);
    return *this;
  }

  void set_type (sfs_keytype _tag) {
    const_cast<sfs_keytype &> (type) = _tag;
    rpcunion_switch_sfsauth2_presig
      (_tag, RPCUNION_SET, _base.destroy (), _base.destroy ());
  }
};

template<class T> bool
rpc_traverse (T &t, sfsauth2_presig &obj)
{
  sfs_keytype tag = obj.type;
  if (!rpc_traverse (t, tag))
    return false;
  if (tag != obj.type)
    obj.set_type (tag);

  rpcunion_switch_sfsauth2_presig
    (obj.type, RPCUNION_TRAVERSE, return true, return false);
}
inline bool
rpc_traverse (const stompcast_t &s, sfsauth2_presig &obj)
{
  rpcunion_switch_sfsauth2_presig
    (obj.type, RPCUNION_REC_STOMPCAST,
     obj._base.destroy (); return true, obj._base.destroy (); return true;);
}
void *sfsauth2_presig_alloc ();
bool_t xdr_sfsauth2_presig (XDR *, void *);
RPC_UNION_DECL (sfsauth2_presig)



struct sfsauth2_sigreq {
  const sfs_msgtype type;
  union {
    union_entry_base _base;
    union_entry<sfs_hash> rnd;
    union_entry<sfs_authreq2> authreq;
    union_entry<sfs_updatereq> updatereq;
  };

#define rpcunion_tag_sfsauth2_sigreq type
#define rpcunion_switch_sfsauth2_sigreq(swarg, action, voidaction, defaction) \
  switch (swarg) { \
  case SFS_NULL: \
    action (sfs_hash, rnd); \
    break; \
  case SFS_SIGNED_AUTHREQ: \
    action (sfs_authreq2, authreq); \
    break; \
  case SFS_UPDATEREQ: \
    action (sfs_updatereq, updatereq); \
    break; \
  default: \
    defaction; \
    break; \
  }

  sfsauth2_sigreq (sfs_msgtype _tag = (sfs_msgtype) 0) : type (_tag)
    { _base.init (); set_type (_tag); }
  sfsauth2_sigreq (const sfsauth2_sigreq &_s)
    : type (_s.type)
    { _base.init (_s._base); }
  ~sfsauth2_sigreq () { _base.destroy (); }
  sfsauth2_sigreq &operator= (const sfsauth2_sigreq &_s) {
    const_cast<sfs_msgtype &> (type) = _s.type;
    _base.assign (_s._base);
    return *this;
  }

  void set_type (sfs_msgtype _tag) {
    const_cast<sfs_msgtype &> (type) = _tag;
    rpcunion_switch_sfsauth2_sigreq
      (_tag, RPCUNION_SET, _base.destroy (), _base.destroy ());
  }
};

template<class T> bool
rpc_traverse (T &t, sfsauth2_sigreq &obj)
{
  sfs_msgtype tag = obj.type;
  if (!rpc_traverse (t, tag))
    return false;
  if (tag != obj.type)
    obj.set_type (tag);

  rpcunion_switch_sfsauth2_sigreq
    (obj.type, RPCUNION_TRAVERSE, return true, return false);
}
inline bool
rpc_traverse (const stompcast_t &s, sfsauth2_sigreq &obj)
{
  rpcunion_switch_sfsauth2_sigreq
    (obj.type, RPCUNION_REC_STOMPCAST,
     obj._base.destroy (); return true, obj._base.destroy (); return true;);
}
void *sfsauth2_sigreq_alloc ();
bool_t xdr_sfsauth2_sigreq (XDR *, void *);
RPC_UNION_DECL (sfsauth2_sigreq)



struct sfsauth2_sign_arg {
  sfsauth2_sigreq req;
  sfs_authinfo authinfo;
  sfsauth2_presig presig;
  sfs_idname user;
  sfs_hash pubkeyhash;
};
void *sfsauth2_sign_arg_alloc ();
bool_t xdr_sfsauth2_sign_arg (XDR *, void *);
RPC_STRUCT_DECL (sfsauth2_sign_arg)

template<class T> bool
rpc_traverse (T &t, sfsauth2_sign_arg &obj)
{
  return rpc_traverse (t, obj.req)
    && rpc_traverse (t, obj.authinfo)
    && rpc_traverse (t, obj.presig)
    && rpc_traverse (t, obj.user)
    && rpc_traverse (t, obj.pubkeyhash);
}



struct sfsauth2_sign_res {
  const bool ok;
  union {
    union_entry_base _base;
    union_entry<sfsauth_errmsg> errmsg;
    union_entry<sfs_sig2> sig;
  };

#define rpcunion_tag_sfsauth2_sign_res ok
#define rpcunion_switch_sfsauth2_sign_res(swarg, action, voidaction, defaction) \
  switch (swarg) { \
  case false: \
    action (sfsauth_errmsg, errmsg); \
    break; \
  case true: \
    action (sfs_sig2, sig); \
    break; \
  default: \
    defaction; \
    break; \
  }

  sfsauth2_sign_res (bool _tag = (bool) 0) : ok (_tag)
    { _base.init (); set_ok (_tag); }
  sfsauth2_sign_res (const sfsauth2_sign_res &_s)
    : ok (_s.ok)
    { _base.init (_s._base); }
  ~sfsauth2_sign_res () { _base.destroy (); }
  sfsauth2_sign_res &operator= (const sfsauth2_sign_res &_s) {
    const_cast<bool &> (ok) = _s.ok;
    _base.assign (_s._base);
    return *this;
  }

  void set_ok (bool _tag) {
    const_cast<bool &> (ok) = _tag;
    rpcunion_switch_sfsauth2_sign_res
      (_tag, RPCUNION_SET, _base.destroy (), _base.destroy ());
  }
};

template<class T> bool
rpc_traverse (T &t, sfsauth2_sign_res &obj)
{
  bool tag = obj.ok;
  if (!rpc_traverse (t, tag))
    return false;
  if (tag != obj.ok)
    obj.set_ok (tag);

  rpcunion_switch_sfsauth2_sign_res
    (obj.ok, RPCUNION_TRAVERSE, return true, return false);
}
inline bool
rpc_traverse (const stompcast_t &s, sfsauth2_sign_res &obj)
{
  rpcunion_switch_sfsauth2_sign_res
    (obj.ok, RPCUNION_REC_STOMPCAST,
     obj._base.destroy (); return true, obj._base.destroy (); return true;);
}
void *sfsauth2_sign_res_alloc ();
bool_t xdr_sfsauth2_sign_res (XDR *, void *);
RPC_UNION_DECL (sfsauth2_sign_res)


#ifndef SFSAUTH_PROG
#define SFSAUTH_PROG 344442
#endif /* !SFSAUTH_PROG */
extern const rpc_program sfsauth_prog_2;
enum { SFSAUTH_V2 = 2 };
enum {
  SFSAUTH2_NULL = 0,
  SFSAUTH2_LOGIN = 1,
  SFSAUTH2_QUERY = 2,
  SFSAUTH2_UPDATE = 3,
  SFSAUTH2_SIGN = 4,
};
#define SFSAUTH_PROG_2_APPLY_NOVOID(macro, void) \
  macro (SFSAUTH2_NULL, void, void) \
  macro (SFSAUTH2_LOGIN, sfsauth2_loginarg, sfsauth2_loginres) \
  macro (SFSAUTH2_QUERY, sfsauth2_query_arg, sfsauth2_query_res) \
  macro (SFSAUTH2_UPDATE, sfsauth2_update_arg, sfsauth2_update_res) \
  macro (SFSAUTH2_SIGN, sfsauth2_sign_arg, sfsauth2_sign_res)
#define SFSAUTH_PROG_2_APPLY(macro) \
  SFSAUTH_PROG_2_APPLY_NOVOID(macro, void)

#endif /* !__RPCC_SFSAUTH_PROT_H_INCLUDED__ */
