Blame include/ntux/ntux.h

26e14f
#ifndef NTUX_H
26e14f
#define NTUX_H
26e14f
26e14f
#include <stdint.h>
26e14f
26e14f
#include "ntux_api.h"
26e14f
26e14f
#ifdef __cplusplus
26e14f
extern "C" {
26e14f
#endif
26e14f
26e14f
/* pre-alpha */
26e14f
#ifndef NTUX_APP
26e14f
#ifndef NTUX_PRE_ALPHA
26e14f
#error  libntux: pre-alpha: ABI is not final!
26e14f
#error  to use the library, please pass -DNTUX_PRE_ALPHA to the compiler.
26e14f
#endif
26e14f
#endif
26e14f
26e14f
/* status codes */
26e14f
#define NTUX_OK				0x00
26e14f
#define NTUX_USAGE			0x01
26e14f
#define NTUX_ERROR			0x02
26e14f
26e14f
/* driver flags */
26e14f
#define NTUX_DRIVER_VERBOSITY_NONE	0x0000
26e14f
#define NTUX_DRIVER_VERBOSITY_ERRORS	0x0001
26e14f
#define NTUX_DRIVER_VERBOSITY_STATUS	0x0002
26e14f
#define NTUX_DRIVER_VERBOSITY_USAGE	0x0004
26e14f
#define NTUX_DRIVER_CLONE_VECTOR	0x0008
26e14f
26e14f
#define NTUX_DRIVER_VERSION		0x0010
26e14f
#define NTUX_DRIVER_DRY_RUN		0x0020
26e14f
da20d8
#define NTUX_DRIVER_ANNOTATE_ALWAYS	0x10000000
da20d8
#define NTUX_DRIVER_ANNOTATE_NEVER	0x20000000
da20d8
#define NTUX_DRIVER_ANNOTATE_FULL	0x40000000
da20d8
da20d8
/* error flags */
da20d8
#define NTUX_ERROR_TOP_LEVEL		0x0001
da20d8
#define NTUX_ERROR_NESTED		0x0002
da20d8
#define NTUX_ERROR_CHILD		0x0004
da20d8
#define NTUX_ERROR_CUSTOM		0x0008
da20d8
#define NTUX_ERROR_NATIVE		0x0010
da20d8
da20d8
enum ntux_custom_error {
da20d8
	NTUX_ERR_FLOW_ERROR,
da20d8
	NTUX_ERR_FLEE_ERROR,
da20d8
	NTUX_ERR_LDSO_INIT,
da20d8
};
da20d8
6a7c02
enum ntux_cmd {
6a7c02
	NTUX_CMD_DEFAULT,
6a7c02
	NTUX_CMD_STAT,
7deda5
	NTUX_CMD_SPAWN,
7deda5
	NTUX_CMD_STRACE,
c27a50
	NTUX_CMD_CAP,
6a7c02
};
6a7c02
26e14f
struct ntux_source_version {
26e14f
	int		major;
26e14f
	int		minor;
26e14f
	int		revision;
26e14f
	const char *	commit;
26e14f
};
26e14f
26e14f
struct ntux_error_info {
26e14f
	const struct ntux_driver_ctx *	edctx;
26e14f
	const struct ntux_unit_ctx *	euctx;
26e14f
	const char *			eunit;
26e14f
	int				esyscode;
26e14f
	int				elibcode;
26e14f
	const char *			efunction;
26e14f
	int				eline;
26e14f
	unsigned			eflags;
26e14f
	void *				eany;
26e14f
};
26e14f
26e14f
struct ntux_common_ctx {
26e14f
	uint64_t			drvflags;
26e14f
	uint64_t			actflags;
26e14f
	uint64_t			fmtflags;
6a7c02
	enum ntux_cmd			cmd;
7deda5
	uint32_t			state;
7deda5
	char **				sargv;
7deda5
	char **				senvp;
9682ca
	const char *			loader;
9682ca
	const char *			logfile;
9682ca
	uint32_t			sysmask[16];
9682ca
	uint32_t			dbgmask[16];
9682ca
	uint32_t			osmask [32];
26e14f
};
26e14f
26e14f
struct ntux_driver_ctx {
26e14f
	const char **			units;
26e14f
	const char *			program;
26e14f
	const char *			module;
26e14f
	const struct ntux_common_ctx *	cctx;
26e14f
	struct ntux_error_info **	errv;
26e14f
	void *				any;
26e14f
};
26e14f
da20d8
struct ntux_unit_ctx {
da20d8
	const char * const *		path;
da20d8
	void *				any;
da20d8
};
da20d8
26e14f
/* package info */
26e14f
ntux_api				const struct ntux_source_version * ntux_source_version(void);
26e14f
26e14f
/* driver api */
26e14f
ntux_api int  ntux_get_driver_ctx	(char ** argv, char ** envp, uint32_t flags, struct ntux_driver_ctx **);
26e14f
ntux_api int  ntux_create_driver_ctx	(const struct ntux_common_ctx *, struct ntux_driver_ctx **);
26e14f
ntux_api void ntux_free_driver_ctx	(struct ntux_driver_ctx *);
26e14f
f3d5e0
/* cmd api */
f3d5e0
ntux_api int  ntux_cmd_stat		(const struct ntux_driver_ctx *, const char *);
5ec9b6
ntux_api int  ntux_cmd_spawn		(const struct ntux_driver_ctx *);
8ce751
ntux_api int  ntux_cmd_strace		(const struct ntux_driver_ctx *);
f3d5e0
26e14f
/* utility api */
26e14f
ntux_api int  ntux_main			(int, char **, char **);
da20d8
ntux_api int  ntux_output_error_vector  (const struct ntux_driver_ctx *);
26e14f
26e14f
#ifdef __cplusplus
26e14f
}
26e14f
#endif
26e14f
26e14f
#endif