Blame include/sofort/sofort.h

8805b2
#ifndef SOFORT_H
8805b2
#define SOFORT_H
f46039
f46039
#include <stdint.h>
f46039
#include <stdio.h>
f46039
f46039
#include "sofort_api.h"
f46039
f46039
#ifdef __cplusplus
f46039
extern "C" {
f46039
#endif
f46039
f46039
/* pre-alpha */
f46039
#ifndef SFRT_APP
f46039
#ifndef SFRT_PRE_ALPHA
f46039
#error  libsofort: pre-alpha: ABI is not final!
f46039
#error  to use the library, please pass -DSFRT_PRE_ALPHA to the compiler.
f46039
#endif
f46039
#endif
f46039
f46039
/* status codes */
f46039
#define SFRT_OK				0x00
f46039
#define SFRT_USAGE			0x01
f46039
#define SFRT_BAD_OPT			0x02
f46039
#define SFRT_BAD_OPT_VAL		0x03
f46039
#define SFRT_IO_ERROR			0xA0
f46039
#define SFRT_MAP_ERROR			0xA1
f46039
f46039
/* driver flags */
f46039
#define SFRT_DRIVER_VERBOSITY_NONE	0x0000
f46039
#define SFRT_DRIVER_VERBOSITY_ERRORS	0x0001
f46039
#define SFRT_DRIVER_VERBOSITY_STATUS	0x0002
f46039
#define SFRT_DRIVER_VERBOSITY_USAGE	0x0004
f46039
#define SFRT_DRIVER_CLONE_VECTOR	0x0008
f46039
f46039
#define SFRT_DRIVER_VERSION		0x0010
f46039
#define SFRT_DRIVER_DRY_RUN		0x0020
f46039
f46039
/* unit action flags */
bbc20f
#define SFRT_OUTPUT_NAME		0x0001 /* dummy */
bbc20f
#define SFRT_OUTPUT_ADDRESS		0x0002 /* dummy */
f46039
1f115d
struct sfrt_source_version {
1f115d
	int		major;
1f115d
	int		minor;
1f115d
	int		revision;
1f115d
	const char *	commit;
1f115d
};
1f115d
f46039
struct sfrt_input {
f46039
	void *	addr;
f46039
	size_t	size;
f46039
};
f46039
f46039
struct sfrt_common_ctx {
f46039
	uint64_t			drvflags;
f46039
	uint64_t			actflags;
f46039
	uint64_t			fmtflags;
bbc20f
	const char *			anystring; /* dummy */
f46039
};
f46039
f46039
struct sfrt_driver_ctx {
f46039
	const char **			units;
f46039
	const char *			program;
f46039
	const char *			module;
f46039
	const struct sfrt_common_ctx *	cctx;
f46039
	void *				any;
f46039
	int				status;
f46039
	int				nerrors;
f46039
};
f46039
f46039
struct sfrt_unit_ctx {
f46039
	const char * const *		path;
f46039
	const struct sfrt_input *	map;
f46039
	const struct sfrt_common_ctx *	cctx;
f46039
	void *				any;
f46039
	int				status;
f46039
	int				nerrors;
f46039
};
f46039
1f115d
/* package info */
1f115d
sfrt_api				const struct sfrt_source_version * sfrt_source_version(void);
1f115d
f46039
/* driver api */
4a749a
sfrt_api int  sfrt_get_driver_ctx	(char ** argv, char ** envp, uint32_t flags, struct sfrt_driver_ctx **);
333bf0
sfrt_api int  sfrt_create_driver_ctx	(const struct sfrt_common_ctx *, struct sfrt_driver_ctx **);
f46039
sfrt_api void sfrt_free_driver_ctx	(struct sfrt_driver_ctx *);
f46039
f46039
sfrt_api int  sfrt_get_unit_ctx		(const struct sfrt_driver_ctx *, const char * path, struct sfrt_unit_ctx **);
f46039
sfrt_api void sfrt_free_unit_ctx	(struct sfrt_unit_ctx *);
f46039
f46039
sfrt_api int  sfrt_map_input		(int fd, const char * path, int prot, struct sfrt_input *);
f46039
sfrt_api int  sfrt_unmap_input		(struct sfrt_input *);
f46039
f46039
/* utility api */
c5881d
sfrt_api int  sfrt_main			(int, char **, char **);
bbc20f
sfrt_api int  sfrt_output_dummy		(const struct sfrt_common_ctx *, FILE *);	/* dummy */
bbc20f
sfrt_api int  sfrt_output_name		(const struct sfrt_unit_ctx *, FILE *);		/* dummy */
bbc20f
sfrt_api int  sfrt_output_address	(const struct sfrt_unit_ctx *, FILE *);		/* dummy */
f46039
f46039
#ifdef __cplusplus
f46039
}
f46039
#endif
f46039
f46039
#endif