Blame include/toksvc/toksvc.h

c0069e
#ifndef TOKSVC_H
c0069e
#define TOKSVC_H
c0069e
c0069e
#include <stdint.h>
c0069e
#include <stddef.h>
c0069e
c0069e
#include "toksvc_api.h"
c0069e
c0069e
#ifdef __cplusplus
c0069e
extern "C" {
c0069e
#endif
c0069e
c0069e
/* pre-alpha */
c0069e
#ifndef TOKS_APP
c0069e
#ifndef TOKS_PRE_ALPHA
c0069e
#error  libtoks: pre-alpha: ABI is not final!
c0069e
#error  to use the library, compile with -DTOKS_PRE_ALPHA.
c0069e
#endif
c0069e
#endif
c0069e
f9f1df
/* daemon */
f9f1df
#define TOKS_PORT_GUID_DAEMON		{0x7d36f145,  \
f9f1df
					  0xd8f0,     \
f9f1df
					  0x440f,     \
f9f1df
					 {0x92,0xbe,0xc3,0x53,0x61,0x7b,0xbc,0x96}}
f9f1df
00069c
#define TOKS_PORT_NAME_PREFIX		{'t','o','k','s','v','c'}
00069c
c0069e
/* status codes */
c0069e
#define TOKS_OK				0x00
c0069e
#define TOKS_USAGE			0x01
c0069e
#define TOKS_ERROR			0x02
c0069e
c0069e
/* driver flags */
c0069e
#define TOKS_DRIVER_VERBOSITY_NONE	0x0000
c0069e
#define TOKS_DRIVER_VERBOSITY_ERRORS	0x0001
c0069e
#define TOKS_DRIVER_VERBOSITY_STATUS	0x0002
c0069e
#define TOKS_DRIVER_VERBOSITY_USAGE	0x0004
c0069e
#define TOKS_DRIVER_CLONE_VECTOR	0x0008
c0069e
c0069e
#define TOKS_DRIVER_VERSION		0x0010
c0069e
#define TOKS_DRIVER_DRY_RUN		0x0020
c0069e
5e5175
#define TOKS_DRIVER_DAEMON_ALWAYS	0x0040
5e5175
#define TOKS_DRIVER_DAEMON_NEVER	0x0080
5e5175
c0069e
#define TOKS_DRIVER_ANNOTATE_ALWAYS	0x1000
c0069e
#define TOKS_DRIVER_ANNOTATE_NEVER	0x2000
c0069e
#define TOKS_DRIVER_ANNOTATE_FULL	0x4000
c0069e
618937
#define TOKS_DRIVER_MODE_SERVER		0X10000
618937
#define TOKS_DRIVER_MODE_CLIENT		0X20000
618937
02451d
#define TOKS_DRIVER_ACTION_ACQUIRE	0X100000
867b30
#define TOKS_DRIVER_ACTION_RELEASE	0X200000
520f51
#define TOKS_DRIVER_ACTION_ABORT	0X400000
02451d
c0069e
/* error flags */
c0069e
#define TOKS_ERROR_TOP_LEVEL		0x0001
c0069e
#define TOKS_ERROR_NESTED		0x0002
c0069e
#define TOKS_ERROR_CHILD		0x0004
c0069e
#define TOKS_ERROR_CUSTOM		0x0008
c0069e
c0069e
enum toks_custom_error {
c0069e
	TOKS_ERR_FLOW_ERROR,
c0069e
	TOKS_ERR_FLEE_ERROR,
c0069e
	TOKS_ERR_NULL_CONTEXT,
c0069e
	TOKS_ERR_BAD_DATA,
c0069e
	TOKS_ERR_CAP,
c0069e
};
c0069e
c0069e
enum toks_warning_level {
c0069e
	TOKS_WARNING_LEVEL_UNKNOWN,
c0069e
	TOKS_WARNING_LEVEL_ALL,
c0069e
	TOKS_WARNING_LEVEL_ERROR,
c0069e
	TOKS_WARNING_LEVEL_NONE,
c0069e
};
c0069e
c0069e
struct toks_source_version {
c0069e
	int		major;
c0069e
	int		minor;
c0069e
	int		revision;
c0069e
	const char *	commit;
c0069e
};
c0069e
abad9f
struct toks_token_string{
abad9f
	char            token[128];
abad9f
};
abad9f
c0069e
struct toks_error_info {
c0069e
	const struct toks_driver_ctx *	edctx;
c0069e
	const struct toks_unit_ctx *	euctx;
c0069e
	const char *			eunit;
c0069e
	int				esyscode;
c0069e
	int				elibcode;
c0069e
	const char *			efunction;
c0069e
	int				eline;
c0069e
	unsigned			eflags;
c0069e
	void *				eany;
c0069e
};
c0069e
c0069e
struct toks_common_ctx {
c0069e
	uint64_t			drvflags;
c0069e
	uint64_t			actflags;
c0069e
	uint64_t			fmtflags;
2f270e
	int32_t				loglevel;
618937
	const nt_guid *			uuid;
c0069e
	void *				hroot;
c0069e
	const char *			sysroot;
c0069e
	char **				eargv;
c0069e
};
c0069e
c0069e
struct toks_driver_ctx {
c0069e
	const char **                   units;
c0069e
	const char *			program;
c0069e
	const char *			module;
c0069e
	const struct toks_common_ctx *	cctx;
c0069e
	struct toks_error_info **	errv;
c0069e
	void *				any;
c0069e
};
c0069e
c0069e
/* driver api */
c0069e
toks_api int  toks_get_driver_ctx       (char ** argv, char ** envp, uint32_t flags,
c0069e
                                         struct toks_driver_ctx **);
c0069e
c0069e
toks_api void toks_free_driver_ctx      (struct toks_driver_ctx *);
c0069e
b27e56
toks_api void toks_driver_set_timeout   (struct toks_driver_ctx *, int64_t millisecs);
b27e56
toks_api void toks_driver_unset_timeout (struct toks_driver_ctx *);
b27e56
c0069e
/* core api */
520f51
toks_api int  toks_service_abort        (struct toks_driver_ctx *);
c0069e
486fcd
/* client api */
486fcd
toks_api int  toks_client_connect       (struct toks_driver_ctx *);
02451d
toks_api int  toks_client_acquire       (struct toks_driver_ctx *);
867b30
toks_api int  toks_client_release       (struct toks_driver_ctx *);
abad9f
toks_api int  toks_client_token_to_str  (struct toks_driver_ctx *, struct toks_token_string *);
abad9f
toks_api int  toks_client_str_to_token  (struct toks_driver_ctx *, const struct toks_token_string *);
c0069e
c0069e
/* utility api */
c0069e
toks_api int  toks_main                 (char **, char **);
c0069e
c0069e
/* error trace api */
c0069e
toks_api int  toks_output_error_record  (const struct toks_driver_ctx *, const struct toks_error_info *);
c0069e
toks_api int  toks_output_error_vector  (const struct toks_driver_ctx *);
c0069e
c0069e
/* package info */
c0069e
toks_api const struct toks_source_version * toks_source_version(void);
c0069e
c0069e
#ifdef __cplusplus
c0069e
}
c0069e
#endif
c0069e
c0069e
#endif