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
486602
struct sfrt_input {
486602
	void *		addr;
486602
	size_t		size;
486602
};
486602
1f115d
struct sfrt_source_version {
1f115d
	int		major;
1f115d
	int		minor;
1f115d
	int		revision;
1f115d
	const char *	commit;
1f115d
};
1f115d
d4f88d
struct sfrt_fd_ctx {
d4f88d
	int		fdin;
d4f88d
	int		fdout;
d4f88d
	int		fderr;
d4f88d
	int		fdlog;
d4f88d
	int		fdcwd;
d4f88d
	int		fddst;
d4f88d
};
d4f88d
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
f46039
/* driver api */
e20359
sfrt_api int  sfrt_get_driver_ctx       (char **, char **, uint32_t,
d4f88d
                                         const struct sfrt_fd_ctx *,
486602
                                         struct sfrt_driver_ctx **);
486602
486602
sfrt_api void sfrt_free_driver_ctx      (struct sfrt_driver_ctx *);
f46039
e20359
sfrt_api int  sfrt_get_unit_ctx         (const struct sfrt_driver_ctx *, const char *,
486602
                                         struct sfrt_unit_ctx **);
f46039
486602
sfrt_api void sfrt_free_unit_ctx        (struct sfrt_unit_ctx *);
f46039
d4f88d
sfrt_api int  sfrt_get_driver_fdctx     (const struct sfrt_driver_ctx *, struct sfrt_fd_ctx *);
d4f88d
sfrt_api int  sfrt_set_driver_fdctx     (struct sfrt_driver_ctx *, const struct sfrt_fd_ctx *);
d4f88d
f46039
/* utility api */
69302d
sfrt_api int  sfrt_main                 (char **, char **, const struct sfrt_fd_ctx *);
2dfa01
2dfa01
sfrt_api int  sfrt_output_dummy         (const struct sfrt_driver_ctx *);					/* dummy */
2dfa01
sfrt_api int  sfrt_output_name          (const struct sfrt_driver_ctx *, const struct sfrt_unit_ctx *);		/* dummy */
2dfa01
sfrt_api int  sfrt_output_address       (const struct sfrt_driver_ctx *, const struct sfrt_unit_ctx *);		/* dummy */
2dfa01
2dfa01
/* error trace api */
486602
sfrt_api int  sfrt_output_error_record  (const struct sfrt_driver_ctx *, const struct sfrt_error_info *);
486602
sfrt_api int  sfrt_output_error_vector  (const struct sfrt_driver_ctx *);
486602
486602
/* raw input api */
486602
sfrt_api int  sfrt_map_input            (const struct sfrt_driver_ctx *,
486602
                                         int, const char *, int,
486602
                                         struct sfrt_input *);
486602
486602
sfrt_api int  sfrt_unmap_input          (struct sfrt_input *);
486602
486602
/* package info */
486602
sfrt_api const struct sfrt_source_version * sfrt_source_version(void);
f46039
f46039
#ifdef __cplusplus
f46039
}
f46039
#endif
f46039
f46039
#endif