/*
 * 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>

// Status indicators (typically error conditions)
typedef enum {
  POK = 0,
  PERR_IO=1,
  PERR_INVAL=2,                 // invalid arguments
  PERR_NOENT=3,                 // no such entry
  PERR_EXISTS=4,                // entry already exists
  PERR_INTERNAL=5,              // 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);

#endif // PERSIFS_H
