Blame include/apimagic/apimagic.h

383aa6
#ifndef APIMAGIC_H
383aa6
#define APIMAGIC_H
383aa6
383aa6
#include <stdint.h>
383aa6
#include <stdio.h>
383aa6
43c8c9
#include <cparser/driver/driver_t.h>
43c8c9
383aa6
#include "apimagic_api.h"
383aa6
383aa6
#ifdef __cplusplus
383aa6
extern "C" {
383aa6
#endif
383aa6
383aa6
/* pre-alpha */
383aa6
#ifndef AMGC_APP
383aa6
#ifndef AMGC_PRE_ALPHA
383aa6
#error  libapimagic: pre-alpha: ABI is not final!
383aa6
#error  to use the library, please pass -DAMGC_PRE_ALPHA to the compiler.
383aa6
#endif
383aa6
#endif
383aa6
383aa6
/* status codes */
383aa6
#define AMGC_OK				0x00
383aa6
#define AMGC_USAGE			0x01
383aa6
#define AMGC_BAD_OPT			0x02
383aa6
#define AMGC_BAD_OPT_VAL		0x03
383aa6
#define AMGC_IO_ERROR			0xA0
383aa6
#define AMGC_MAP_ERROR			0xA1
1fd161
#define AMGC_INIT_ERROR			0xA2
383aa6
383aa6
/* driver flags */
383aa6
#define AMGC_DRIVER_VERBOSITY_NONE	0x0000
383aa6
#define AMGC_DRIVER_VERBOSITY_ERRORS	0x0001
383aa6
#define AMGC_DRIVER_VERBOSITY_STATUS	0x0002
383aa6
#define AMGC_DRIVER_VERBOSITY_USAGE	0x0004
383aa6
#define AMGC_DRIVER_CLONE_VECTOR	0x0008
383aa6
383aa6
#define AMGC_DRIVER_VERSION		0x0010
383aa6
#define AMGC_DRIVER_DRY_RUN		0x0020
383aa6
383aa6
/* unit action flags */
383aa6
383aa6
struct amgc_input {
383aa6
	void *	addr;
383aa6
	size_t	size;
383aa6
};
383aa6
383aa6
struct amgc_common_ctx {
383aa6
	uint64_t			drvflags;
383aa6
	uint64_t			actflags;
383aa6
	uint64_t			fmtflags;
43c8c9
	struct compilation_env_t *	ccenv;
383aa6
};
383aa6
383aa6
struct amgc_driver_ctx {
383aa6
	const char **			units;
383aa6
	const char *			program;
383aa6
	const char *			module;
383aa6
	const struct amgc_common_ctx *	cctx;
383aa6
	void *				any;
383aa6
	int				status;
383aa6
	int				nerrors;
383aa6
};
383aa6
383aa6
struct amgc_unit_ctx {
383aa6
	const char * const *		path;
383aa6
	const struct amgc_input *	map;
383aa6
	const struct amgc_common_ctx *	cctx;
43c8c9
	const struct compilation_unit_t*ccunit;
383aa6
	void *				any;
383aa6
	int				status;
383aa6
	int				nerrors;
383aa6
};
383aa6
383aa6
/* driver api */
383aa6
amgc_api int  amgc_get_driver_ctx	(const char ** argv, const char ** envp, uint32_t flags, struct amgc_driver_ctx **);
383aa6
amgc_api int  amgc_create_driver_ctx	(const struct amgc_common_ctx *, struct amgc_driver_ctx **);
383aa6
amgc_api void amgc_free_driver_ctx	(struct amgc_driver_ctx *);
383aa6
383aa6
amgc_api int  amgc_get_unit_ctx		(const struct amgc_driver_ctx *, const char * path, struct amgc_unit_ctx **);
383aa6
amgc_api void amgc_free_unit_ctx	(struct amgc_unit_ctx *);
383aa6
383aa6
amgc_api int  amgc_map_input		(int fd, const char * path, int prot, struct amgc_input *);
383aa6
amgc_api int  amgc_unmap_input		(struct amgc_input *);
383aa6
383aa6
/* utility api */
383aa6
383aa6
#ifdef __cplusplus
383aa6
}
383aa6
#endif
383aa6
383aa6
#endif