#pragma prototyped
#ifndef _CODEX_H
#define _CODEX_H 1
#include <ast.h>
#include <error.h>
#define CODEX_VERSION 20090704L
#define CODEX_PLUGIN_VERSION AST_PLUGIN_VERSION(CODEX_VERSION)
#define CODEX_DECODE 0x0001
#define CODEX_ENCODE 0x0002
#define CODEX_RETAIN 0x0010
#define CODEX_INVERT 0x0020
#define CODEX_TRACE 0x0040
#define CODEX_VERBOSE 0x0080
#define CODEX_COMPRESS 0x0100
#define CODEX_CRYPT 0x0200
#define CODEX_ICONV 0x0400
#define CODEX_SUM 0x0800
#define CODEX_UU 0x1000
#define CODEX_CACHED 0x10000000L
#define CODEX_SERIAL 0x20000000L
#define CODEX_FLUSH 0x40000000L
#define CODEX_ACTIVE 0x80000000L
#define CODEX_IDENT 1024
#define CODEX_NAME 256
#define CODEX_ARGS 32
#define CODEX(d) ((Codex_t*)(d))
typedef uint32_t Codexnum_t;
struct Codex_s; typedef struct Codex_s Codex_t;
struct Codexdata_s; typedef struct Codexdata_s Codexdata_t;
struct Codexdisc_s; typedef struct Codexdisc_s Codexdisc_t;
struct Codexmeth_s; typedef struct Codexmeth_s Codexmeth_t;
typedef Codexmeth_t* (*Codexlib_f)(const char*);
struct Codex_s
{
Sfdisc_t sfdisc;
Sfio_t* sp;
Sfio_t* dp;
Sfoff_t size;
Codexdisc_t* disc;
Codexmeth_t* meth;
Codexnum_t flags;
Codexnum_t index;
int serial;
void* data;
Sfio_t* op;
};
struct Codexdata_s
{
Codexnum_t size;
Codexnum_t num;
void* buf;
};
struct Codexdisc_s
{
Codexnum_t version;
Error_f errorf;
ssize_t (*passf)(void*, size_t, Codexdisc_t*, Codexmeth_t*);
const char* passphrase;
Sfio_t* identify;
};
struct Codexmeth_s
{
const char* name;
const char* description;
const char* options;
Codexnum_t flags;
int (*optionsf)(Codexmeth_t*, Sfio_t*);
int (*identf)(Codexmeth_t*, const void*, size_t, char*, size_t);
int (*openf)(Codex_t*, char* const[], Codexnum_t);
int (*closef)(Codex_t*);
int (*initf)(Codex_t*);
int (*donef)(Codex_t*);
ssize_t (*readf)(Sfio_t*, void*, size_t, Sfdisc_t*);
ssize_t (*writef)(Sfio_t*, const void*, size_t, Sfdisc_t*);
int (*syncf)(Codex_t*);
Sfoff_t (*seekf)(Codex_t*, Sfoff_t, int);
int (*dataf)(Codex_t*, Codexdata_t*);
void* vcmeth;
void* data;
Codexmeth_t* next;
};
#if _BLD_codex && !defined(main)
#include <codexlib.h>
#define CODEXLIB(m)
#define CODEXNEXT(m) codex_##m##_next
#else
#ifdef __STDC__
#define CODEXLIB(m) extern Codexmeth_t* codex_lib(const char* name) { return &codex_##m; } unsigned long plugin_version(void) { return CODEX_PLUGIN_VERSION; }
#else
#define CODEXLIB(m) extern Codexmeth_t* codex_lib(name) char* name; { return &codex_##m; } unsigned long plugin_version() { return CODEX_PLUGIN_VERSION; }
#endif
#define CODEXNEXT(m) 0
#if defined(__EXPORT__)
#define extern __EXPORT__
#endif
extern Codexmeth_t* codex_lib(const char*);
#undef extern
#endif
#define codexinit(d,e) (memset(d,0,sizeof(*(d))),(d)->version=CODEX_VERSION,(d)->errorf=(Error_f)(e))
#if _BLD_codex && defined(__EXPORT__)
#define extern __EXPORT__
#endif
extern int codex(Sfio_t*, Sfio_t*, const char*, Codexnum_t, Codexdisc_t*, Codexmeth_t*);
extern int codexpop(Sfio_t*, Sfio_t*, int);
extern int codexcmp(const char*, const char*);
extern int codexdata(Sfio_t*, Codexdata_t*);
extern ssize_t codexgetpass(const char*, void*, size_t);
extern Codexmeth_t* codexid(const void*, size_t, char*, size_t);
extern Codexmeth_t* codexlist(Codexmeth_t*);
extern Codexmeth_t* codexmeth(const char*);
extern int codexadd(const char*, Codexmeth_t*);
extern Sfio_t* codexnull(void);
extern ssize_t codexpass(void*, size_t, Codexdisc_t*, Codexmeth_t*);
extern int codexsize(Sfio_t*, Sfoff_t);
#undef extern
#endif