/*
 * PersiFS
 *
 * Overall header file.  This should get included everywhere as it
 * defines PersiFS-global types.  This also includes header files that
 * are used everywhere.
 */

#ifndef PERSIFS_H
#define PERSIFS_H

// Enable debugging traces
#define ENABLE_TRACES 1

// Include common SFS headers
#include <callback.h>
#include <str.h>
#include <err.h>
#include <nfs3_prot.h>

struct nfstime3;
nfstime3 nfstime();

// Status indicators (typically error conditions)
typedef enum {
  POK = 0,
  PERR_IO=1,
  PERR_INVAL,                   // invalid arguments
  PERR_NOENT,                   // no such entry
  PERR_EXISTS,                  // entry already exists
  PERR_NOTDIR,                  // not a directory
  PERR_INTERNAL,                // internal error (catch all)
} pStat;

// Typical type for error callbacks
typedef callback<void, pStat>::ref cbe;

// A generic fatal error callback that will display a generic error
// message and terminate.
extern cbe fatalCB;

// Create a fatal error callback that will output msg before
// terminating.
cbe fatalCBMsg(str msg);

// Display a trace message with file and line number for debugging
// purposes.
#define TRACE() _trace(__FILE__, __LINE__)
void _trace(const char *file, int line);

// Replace all non-printable characters in in with escape codes
str debug_unparseStr(str in);

// Print a file handle
str debug_fh2hex(nfs_fh3 fh);

#endif // PERSIFS_H
