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

#ifndef __RPCC_SFSRO_PROT_H_INCLUDED__
#define __RPCC_SFSRO_PROT_H_INCLUDED__ 1

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

enum { SFSRO_FHSIZE = 20 };
enum { SFSRO_BLKSIZE = 8192 };
enum { SFSRO_NFH = 256 };
enum { SFSRO_NDIR = 7 };
enum { SFSRO_FHDB_KEYS = 255 };
enum { SFSRO_FHDB_CHILDREN = 256 };
enum { SFSRO_FHDB_NFH = 256 };

enum sfsrostat {
  SFSRO_OK = 0,
  SFSRO_ERRNOENT = 1,
};
void *sfsrostat_alloc ();
bool_t xdr_sfsrostat (XDR *, void *);
RPC_ENUM_DECL (sfsrostat)

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


struct sfsro_dataresok {
  rpc_bytes<RPC_INFINITY> data;
};
void *sfsro_dataresok_alloc ();
bool_t xdr_sfsro_dataresok (XDR *, void *);
RPC_STRUCT_DECL (sfsro_dataresok)

template<class T> inline bool
rpc_traverse (T &t, sfsro_dataresok &obj)
{
  return rpc_traverse (t, obj.data);
}



struct sfsro_datares {
  const sfsrostat status;
  union {
    union_entry_base _base;
    union_entry<sfsro_dataresok> resok;
  };

#define rpcunion_tag_sfsro_datares status
#define rpcunion_switch_sfsro_datares(swarg, action, voidaction, defaction) \
  switch (swarg) { \
  case SFSRO_OK: \
    action (sfsro_dataresok, resok); \
    break; \
  case SFSRO_ERRNOENT: \
    voidaction; \
    break; \
  default: \
    defaction; \
    break; \
  }

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

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

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

  rpcunion_switch_sfsro_datares
    (obj.status, RPCUNION_TRAVERSE, return true, return false);
}
inline bool
rpc_traverse (const stompcast_t &s, sfsro_datares &obj)
{
  rpcunion_switch_sfsro_datares
    (obj.status, RPCUNION_REC_STOMPCAST,
     obj._base.destroy (); return true, obj._base.destroy (); return true;);
}
void *sfsro_datares_alloc ();
bool_t xdr_sfsro_datares (XDR *, void *);
RPC_UNION_DECL (sfsro_datares)


enum ftypero {
  SFSROREG = 1,
  SFSROREG_EXEC = 2,
  SFSRODIR = 3,
  SFSRODIR_OPAQ = 4,
  SFSROLNK = 5,
};
void *ftypero_alloc ();
bool_t xdr_ftypero (XDR *, void *);
RPC_ENUM_DECL (ftypero)

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

enum { SFSRO_IVSIZE = 20 };


struct sfsro2_signed_fsinfo {
  sfs_msgtype type;
  sfs_time start;
  u_int32_t duration;
  rpc_opaque<SFSRO_IVSIZE> iv;
  sfs_hash rootfh;
  sfs_hash fhdb;
  int32_t blocksize;
};
void *sfsro2_signed_fsinfo_alloc ();
bool_t xdr_sfsro2_signed_fsinfo (XDR *, void *);
RPC_STRUCT_DECL (sfsro2_signed_fsinfo)

template<class T> bool
rpc_traverse (T &t, sfsro2_signed_fsinfo &obj)
{
  return rpc_traverse (t, obj.type)
    && rpc_traverse (t, obj.start)
    && rpc_traverse (t, obj.duration)
    && rpc_traverse (t, obj.iv)
    && rpc_traverse (t, obj.rootfh)
    && rpc_traverse (t, obj.fhdb)
    && rpc_traverse (t, obj.blocksize);
}



struct sfsro2_fsinfo {
  sfsro2_signed_fsinfo info;
  sfs_sig2 sig;
};
void *sfsro2_fsinfo_alloc ();
bool_t xdr_sfsro2_fsinfo (XDR *, void *);
RPC_STRUCT_DECL (sfsro2_fsinfo)

template<class T> bool
rpc_traverse (T &t, sfsro2_fsinfo &obj)
{
  return rpc_traverse (t, obj.info)
    && rpc_traverse (t, obj.sig);
}



struct sfsro_fsinfo {
  const sfsrostat stat;
  union {
    union_entry_base _base;
    union_entry<sfsro2_fsinfo> v2;
  };

#define rpcunion_tag_sfsro_fsinfo stat
#define rpcunion_switch_sfsro_fsinfo(swarg, action, voidaction, defaction) \
  switch (swarg) { \
  case SFSRO_OK: \
    action (sfsro2_fsinfo, v2); \
    break; \
  case SFSRO_ERRNOENT: \
    voidaction; \
    break; \
  default: \
    defaction; \
    break; \
  }

  sfsro_fsinfo (sfsrostat _tag = (sfsrostat) 0) : stat (_tag)
    { _base.init (); set_stat (_tag); }
  sfsro_fsinfo (const sfsro_fsinfo &_s)
    : stat (_s.stat)
    { _base.init (_s._base); }
  ~sfsro_fsinfo () { _base.destroy (); }
  sfsro_fsinfo &operator= (const sfsro_fsinfo &_s) {
    const_cast<sfsrostat &> (stat) = _s.stat;
    _base.assign (_s._base);
    return *this;
  }

  void set_stat (sfsrostat _tag) {
    const_cast<sfsrostat &> (stat) = _tag;
    rpcunion_switch_sfsro_fsinfo
      (_tag, RPCUNION_SET, _base.destroy (), _base.destroy ());
  }
};

template<class T> bool
rpc_traverse (T &t, sfsro_fsinfo &obj)
{
  sfsrostat tag = obj.stat;
  if (!rpc_traverse (t, tag))
    return false;
  if (tag != obj.stat)
    obj.set_stat (tag);

  rpcunion_switch_sfsro_fsinfo
    (obj.stat, RPCUNION_TRAVERSE, return true, return false);
}
inline bool
rpc_traverse (const stompcast_t &s, sfsro_fsinfo &obj)
{
  rpcunion_switch_sfsro_fsinfo
    (obj.stat, RPCUNION_REC_STOMPCAST,
     obj._base.destroy (); return true, obj._base.destroy (); return true;);
}
void *sfsro_fsinfo_alloc ();
bool_t xdr_sfsro_fsinfo (XDR *, void *);
RPC_UNION_DECL (sfsro_fsinfo)



struct sfsro_inode_lnk {
  uint32 nlink;
  nfstime3 mtime;
  nfstime3 ctime;
  nfspath3 dest;
};
void *sfsro_inode_lnk_alloc ();
bool_t xdr_sfsro_inode_lnk (XDR *, void *);
RPC_STRUCT_DECL (sfsro_inode_lnk)

template<class T> bool
rpc_traverse (T &t, sfsro_inode_lnk &obj)
{
  return rpc_traverse (t, obj.nlink)
    && rpc_traverse (t, obj.mtime)
    && rpc_traverse (t, obj.ctime)
    && rpc_traverse (t, obj.dest);
}



struct sfsro_inode_reg {
  uint32 nlink;
  uint64 size;
  uint64 used;
  nfstime3 mtime;
  nfstime3 ctime;
  rpc_vec<sfs_hash, SFSRO_NDIR> direct;
  sfs_hash indirect;
  sfs_hash double_indirect;
  sfs_hash triple_indirect;
};
void *sfsro_inode_reg_alloc ();
bool_t xdr_sfsro_inode_reg (XDR *, void *);
RPC_STRUCT_DECL (sfsro_inode_reg)

template<class T> bool
rpc_traverse (T &t, sfsro_inode_reg &obj)
{
  return rpc_traverse (t, obj.nlink)
    && rpc_traverse (t, obj.size)
    && rpc_traverse (t, obj.used)
    && rpc_traverse (t, obj.mtime)
    && rpc_traverse (t, obj.ctime)
    && rpc_traverse (t, obj.direct)
    && rpc_traverse (t, obj.indirect)
    && rpc_traverse (t, obj.double_indirect)
    && rpc_traverse (t, obj.triple_indirect);
}



struct sfsro_inode {
  const ftypero type;
  union {
    union_entry_base _base;
    union_entry<sfsro_inode_lnk> lnk;
    union_entry<sfsro_inode_reg> reg;
  };

#define rpcunion_tag_sfsro_inode type
#define rpcunion_switch_sfsro_inode(swarg, action, voidaction, defaction) \
  switch (swarg) { \
  case SFSROLNK: \
    action (sfsro_inode_lnk, lnk); \
    break; \
  default: \
    action (sfsro_inode_reg, reg); \
    break; \
  }

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

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

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

  rpcunion_switch_sfsro_inode
    (obj.type, RPCUNION_TRAVERSE, return true, return false);
}
inline bool
rpc_traverse (const stompcast_t &s, sfsro_inode &obj)
{
  rpcunion_switch_sfsro_inode
    (obj.type, RPCUNION_REC_STOMPCAST,
     obj._base.destroy (); return true, obj._base.destroy (); return true;);
}
void *sfsro_inode_alloc ();
bool_t xdr_sfsro_inode (XDR *, void *);
RPC_UNION_DECL (sfsro_inode)



struct sfsro_indirect {
  rpc_vec<sfs_hash, SFSRO_NFH> handles;
};
void *sfsro_indirect_alloc ();
bool_t xdr_sfsro_indirect (XDR *, void *);
RPC_STRUCT_DECL (sfsro_indirect)

template<class T> inline bool
rpc_traverse (T &t, sfsro_indirect &obj)
{
  return rpc_traverse (t, obj.handles);
}



struct sfsro_dirent {
  sfs_hash fh;
  rpc_str<RPC_INFINITY> name;
  rpc_ptr<sfsro_dirent> nextentry;
};
void *sfsro_dirent_alloc ();
bool_t xdr_sfsro_dirent (XDR *, void *);
RPC_STRUCT_DECL (sfsro_dirent)

template<class T> bool
rpc_traverse (T &t, sfsro_dirent &obj)
{
  return rpc_traverse (t, obj.fh)
    && rpc_traverse (t, obj.name)
    && rpc_traverse (t, obj.nextentry);
}



struct sfsro_directory {
  rpc_ptr<sfsro_dirent> entries;
  bool eof;
};
void *sfsro_directory_alloc ();
bool_t xdr_sfsro_directory (XDR *, void *);
RPC_STRUCT_DECL (sfsro_directory)

template<class T> bool
rpc_traverse (T &t, sfsro_directory &obj)
{
  return rpc_traverse (t, obj.entries)
    && rpc_traverse (t, obj.eof);
}



struct sfsro_fhdb_indir {
  rpc_vec<sfs_hash, SFSRO_FHDB_KEYS> key;
  rpc_vec<sfs_hash, SFSRO_FHDB_CHILDREN> child;
};
void *sfsro_fhdb_indir_alloc ();
bool_t xdr_sfsro_fhdb_indir (XDR *, void *);
RPC_STRUCT_DECL (sfsro_fhdb_indir)

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


typedef rpc_vec<sfs_hash, SFSRO_FHDB_NFH> sfsro_fhdb_dir;
void *sfsro_fhdb_dir_alloc ();
bool_t xdr_sfsro_fhdb_dir (XDR *, void *);
RPC_TYPEDEF_DECL (sfsro_fhdb_dir)

enum dtype {
  SFSRO_INODE = 0,
  SFSRO_FILEBLK = 1,
  SFSRO_DIRBLK = 2,
  SFSRO_INDIR = 3,
  SFSRO_FHDB_DIR = 4,
  SFSRO_FHDB_INDIR = 5,
};
void *dtype_alloc ();
bool_t xdr_dtype (XDR *, void *);
RPC_ENUM_DECL (dtype)

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


struct sfsro_data {
  const dtype type;
  union {
    union_entry_base _base;
    union_entry<sfsro_inode> inode;
    union_entry<rpc_bytes<RPC_INFINITY> > data;
    union_entry<sfsro_directory> dir;
    union_entry<sfsro_indirect> indir;
    union_entry<sfsro_fhdb_dir> fhdb_dir;
    union_entry<sfsro_fhdb_indir> fhdb_indir;
  };

#define rpcunion_tag_sfsro_data type
#define rpcunion_switch_sfsro_data(swarg, action, voidaction, defaction) \
  switch (swarg) { \
  case SFSRO_INODE: \
    action (sfsro_inode, inode); \
    break; \
  case SFSRO_FILEBLK: \
    action (opaque, data); \
    break; \
  case SFSRO_DIRBLK: \
    action (sfsro_directory, dir); \
    break; \
  case SFSRO_INDIR: \
    action (sfsro_indirect, indir); \
    break; \
  case SFSRO_FHDB_DIR: \
    action (sfsro_fhdb_dir, fhdb_dir); \
    break; \
  case SFSRO_FHDB_INDIR: \
    action (sfsro_fhdb_indir, fhdb_indir); \
    break; \
  default: \
    voidaction; \
    break; \
  }

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

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

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

  rpcunion_switch_sfsro_data
    (obj.type, RPCUNION_TRAVERSE, return true, return false);
}
inline bool
rpc_traverse (const stompcast_t &s, sfsro_data &obj)
{
  rpcunion_switch_sfsro_data
    (obj.type, RPCUNION_REC_STOMPCAST,
     obj._base.destroy (); return true, obj._base.destroy (); return true;);
}
void *sfsro_data_alloc ();
bool_t xdr_sfsro_data (XDR *, void *);
RPC_UNION_DECL (sfsro_data)



struct sfsro_getdataargs {
  filename3 sname;
  sfs_hash fh;
};
void *sfsro_getdataargs_alloc ();
bool_t xdr_sfsro_getdataargs (XDR *, void *);
RPC_STRUCT_DECL (sfsro_getdataargs)

template<class T> bool
rpc_traverse (T &t, sfsro_getdataargs &obj)
{
  return rpc_traverse (t, obj.sname)
    && rpc_traverse (t, obj.fh);
}


#ifndef SFSRO_PROGRAM
#define SFSRO_PROGRAM 344446
#endif /* !SFSRO_PROGRAM */
extern const rpc_program sfsro_program_2;
enum { SFSRO_VERSION_V2 = 2 };
enum {
  SFSROPROC2_NULL = 0,
  SFSROPROC2_GETDATA = 1,
  SFSROPROC2_GETFSINFO = 2,
};
#define SFSRO_PROGRAM_2_APPLY_NOVOID(macro, void) \
  macro (SFSROPROC2_NULL, void, void) \
  macro (SFSROPROC2_GETDATA, sfsro_getdataargs, sfsro_datares) \
  macro (SFSROPROC2_GETFSINFO, filename3, sfsro_fsinfo)
#define SFSRO_PROGRAM_2_APPLY(macro) \
  SFSRO_PROGRAM_2_APPLY_NOVOID(macro, void)

#endif /* !__RPCC_SFSRO_PROT_H_INCLUDED__ */
