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
7ed7e6
#define SFRT_ERROR			0x02
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
f0da18
#define SFRT_DRIVER_ANNOTATE_ALWAYS	0x1000
f0da18
#define SFRT_DRIVER_ANNOTATE_NEVER	0x2000
f0da18
#define SFRT_DRIVER_ANNOTATE_FULL	0x4000
f0da18
f46039
/* unit action flags */
bbc20f
#define SFRT_OUTPUT_NAME		0x0001 /* dummy */
bbc20f
#define SFRT_OUTPUT_ADDRESS		0x0002 /* dummy */
f46039
b03974
/* error flags */
b03974
#define SFRT_ERROR_TOP_LEVEL		0x0001
b03974
#define SFRT_ERROR_NESTED		0x0002
b03974
#define SFRT_ERROR_CHILD		0x0004
b03974
#define SFRT_ERROR_CUSTOM		0x0008
b03974
b03974
enum sfrt_custom_error {
b03974
	SFRT_ERR_FLOW_ERROR,
b03974
	SFRT_ERR_FLEE_ERROR,
b03974
	SFRT_ERR_NULL_CONTEXT,
b03974
	SFRT_ERR_NULL_SOURCE,
b03974
	SFRT_ERR_INVALID_CONTEXT,
b03974
	SFRT_ERR_INVALID_SOURCE,
b03974
	SFRT_ERR_SOURCE_SIZE_ZERO,
b03974
	SFRT_ERR_CAP,
b03974
};
b03974
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
b03974
struct sfrt_error_info {
b03974
	const struct sfrt_driver_ctx *	edctx;
b03974
	const struct sfrt_unit_ctx *	euctx;
b03974
	const char *			eunit;
b03974
	int				esyscode;
b03974
	int				elibcode;
b03974
	const char *			efunction;
b03974
	int				eline;
b03974
	unsigned			eflags;
b03974
	void *				eany;
b03974
};
b03974
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;
b03974
	struct sfrt_error_info **	errv;
f46039
	void *				any;
f46039
};
f46039
f46039
struct sfrt_unit_ctx {
f46039
	const char * const *		path;
f46039
	const struct sfrt_input *	map;
f46039
	void *				any;
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
47a21b
sfrt_api int  sfrt_map_input		(const struct sfrt_driver_ctx *, 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 */
f0da18
sfrt_api int  sfrt_output_error_record	(const struct sfrt_driver_ctx *, const struct sfrt_error_info *);
f0da18
sfrt_api int  sfrt_output_error_vector	(const struct sfrt_driver_ctx *);
f46039
f46039
#ifdef __cplusplus
f46039
}
f46039
#endif
f46039
f46039
#endif