Blame include/slibtool/slibtool.h

9ca8c4
#ifndef SOFORT_H
9ca8c4
#define SOFORT_H
9ca8c4
9ca8c4
#include <stdint.h>
528799
#include <stddef.h>
9ca8c4
#include <stdio.h>
528799
#include <unistd.h>
9ca8c4
9ca8c4
#include "slibtool_api.h"
9ca8c4
9ca8c4
#ifdef __cplusplus
9ca8c4
extern "C" {
9ca8c4
#endif
9ca8c4
9ca8c4
/* pre-alpha */
9ca8c4
#ifndef SLBT_APP
9ca8c4
#ifndef SLBT_PRE_ALPHA
9ca8c4
#error  libslibtool: pre-alpha: ABI is not final!
9ca8c4
#error  to use the library, please pass -DSLBT_PRE_ALPHA to the compiler.
9ca8c4
#endif
9ca8c4
#endif
9ca8c4
9ca8c4
/* status codes */
9ca8c4
#define SLBT_OK				0x00
9ca8c4
#define SLBT_USAGE			0x01
9ca8c4
#define SLBT_BAD_OPT			0x02
9ca8c4
#define SLBT_BAD_OPT_VAL		0x03
9ca8c4
#define SLBT_IO_ERROR			0xA0
9ca8c4
#define SLBT_MAP_ERROR			0xA1
9ca8c4
9ca8c4
/* driver flags */
9ca8c4
#define SLBT_DRIVER_VERBOSITY_NONE	0x0000
9ca8c4
#define SLBT_DRIVER_VERBOSITY_ERRORS	0x0001
9ca8c4
#define SLBT_DRIVER_VERBOSITY_STATUS	0x0002
9ca8c4
#define SLBT_DRIVER_VERBOSITY_USAGE	0x0004
9ca8c4
#define SLBT_DRIVER_CLONE_VECTOR	0x0008
9ca8c4
9ca8c4
#define SLBT_DRIVER_VERSION		0x0010
9ca8c4
#define SLBT_DRIVER_DRY_RUN		0x0020
173b54
#define SLBT_DRIVER_CONFIG		0x0040
fea1b8
#define SLBT_DRIVER_DEBUG		0x0080
d03fbc
#define SLBT_DRIVER_FEATURES		0x0100
40fabb
#define SLBT_DRIVER_DEPS		0x0200
398419
#define SLBT_DRIVER_SILENT		0x0400
25956b
#define SLBT_DRIVER_VERBOSE		0x0800
4f1b20
#define SLBT_DRIVER_PRO_PIC		0x1000
4f1b20
#define SLBT_DRIVER_ANTI_PIC		0x2000
9c25c7
#define SLBT_DRIVER_SHARED		0x4000
9c25c7
#define SLBT_DRIVER_STATIC		0x8000
9ca8c4
e4a8ce
#define SLBT_DRIVER_HEURISTICS		0x010000
e4a8ce
#define SLBT_DRIVER_STRICT		0x020000
93b62c
#define SLBT_DRIVER_NO_UNDEFINED	0x040000
a943fc
#define SLBT_DRIVER_MODULE		0x080000
68f313
#define SLBT_DRIVER_AVOID_VERSION	0x100000
bcd5af
#define SLBT_DRIVER_IMAGE_ELF		0x200000
bcd5af
#define SLBT_DRIVER_IMAGE_PE		0x400000
bcd5af
#define SLBT_DRIVER_IMAGE_MACHO		0x800000
e4a8ce
f7645c
#define SLBT_DRIVER_ALL_STATIC		0x01000000
0e609b
#define SLBT_DRIVER_DISABLE_STATIC	0x02000000
f5fa4c
#define SLBT_DRIVER_DISABLE_SHARED	0x04000000
0a9bff
#define SLBT_DRIVER_LEGABITS		0x08000000
f7645c
2bc175
#define SLBT_DRIVER_ANNOTATE_ALWAYS	0x10000000
2bc175
#define SLBT_DRIVER_ANNOTATE_NEVER	0x20000000
2bc175
#define SLBT_DRIVER_ANNOTATE_FULL	0x40000000
2bc175
6dc887
/* error flags */
6dc887
#define SLBT_ERROR_TOP_LEVEL		0x0001
6dc887
#define SLBT_ERROR_NESTED		0x0002
6dc887
#define SLBT_ERROR_CHILD		0x0004
6dc887
#define SLBT_ERROR_CUSTOM		0x0008
6dc887
ed069f
/* execution modes */
ed069f
enum slbt_mode {
ed069f
	SLBT_MODE_UNKNOWN,
ed069f
	SLBT_MODE_CLEAN,
ed069f
	SLBT_MODE_COMPILE,
ed069f
	SLBT_MODE_EXECUTE,
ed069f
	SLBT_MODE_FINISH,
ed069f
	SLBT_MODE_INSTALL,
ed069f
	SLBT_MODE_LINK,
ed069f
	SLBT_MODE_UNINSTALL,
ed069f
};
ed069f
53f4ec
enum slbt_tag {
53f4ec
	SLBT_TAG_UNKNOWN,
53f4ec
	SLBT_TAG_CC,
53f4ec
	SLBT_TAG_CXX,
62b4bb
	SLBT_TAG_NASM,
53f4ec
};
53f4ec
6376f0
enum slbt_warning_level {
6376f0
	SLBT_WARNING_LEVEL_UNKNOWN,
6376f0
	SLBT_WARNING_LEVEL_ALL,
6376f0
	SLBT_WARNING_LEVEL_ERROR,
6376f0
	SLBT_WARNING_LEVEL_NONE,
6376f0
};
6376f0
9f24d2
struct slbt_source_version {
9f24d2
	int		major;
9f24d2
	int		minor;
9f24d2
	int		revision;
9f24d2
	const char *	commit;
9f24d2
};
9f24d2
9ca8c4
struct slbt_input {
9ca8c4
	void *	addr;
9ca8c4
	size_t	size;
9ca8c4
};
9ca8c4
528799
struct slbt_exec_ctx {
528799
	char *	program;
27a8e1
	char *	compiler;
27a8e1
	char **	cargv;
528799
	char **	argv;
528799
	char **	envp;
6d0e8a
	char ** altv;
5aae4b
	char ** dpic;
5aae4b
	char ** fpic;
5aae4b
	char ** cass;
93b62c
	char ** noundef;
0f8591
	char ** soname;
0f8591
	char ** lsoname;
e15ee1
	char ** symdefs;
e15ee1
	char ** symfile;
5aae4b
	char ** lout[2];
df07fb
	char ** mout[2];
3e7d5b
	char ** rpath[2];
b1f977
	char ** sentinel;
5ee0d1
	FILE *	fwrapper;
0913c3
	FILE *	fdeps;
df088e
	char *	csrc;
7f35de
	int	ldirdepth;
df088e
	char *	ldirname;
df088e
	char *	lbasename;
df088e
	char *	lobjname;
e02305
	char *	aobjname;
e88a39
	char *	ltobjname;
680670
	char *	arfilename;
680670
	char *	lafilename;
26ea30
	char *	laifilename;
680670
	char *	dsofilename;
112a2b
	char *	relfilename;
b4491f
	char *	deffilename;
2330a5
	char *	rpathfilename;
1677f4
	char *	dimpfilename;
1677f4
	char *	pimpfilename;
1677f4
	char *	vimpfilename;
680670
	char *	exefilename;
2f9f52
	char *	sonameprefix;
528799
	pid_t	pid;
528799
	int	exitcode;
528799
};
528799
5a9161
struct slbt_version_info {
5a9161
	int				major;
5a9161
	int				minor;
5a9161
	int				revision;
5a9161
	const char *			verinfo;
cd3d41
	const char *			vernumber;
5a9161
};
5a9161
6dc887
struct slbt_error_info {
6dc887
	int				syserror;
6dc887
	int				liberror;
6dc887
	const char *			function;
6dc887
	int				line;
6dc887
	unsigned			flags;
6dc887
	void *				ctx;
6dc887
};
6dc887
a2fcc0
struct slbt_host_params {
a2fcc0
	const char *			host;
a2fcc0
	const char *			flavor;
a2fcc0
	const char *			ar;
a2fcc0
	const char *			ranlib;
a2fcc0
	const char *			dlltool;
af7db9
	const char *			ldrpath;
a2fcc0
};
a2fcc0
a66d34
struct slbt_flavor_settings {
bcd5af
	const char *			imagefmt;
a66d34
	const char *			arprefix;
a66d34
	const char *			arsuffix;
a66d34
	const char *			dsoprefix;
a66d34
	const char *			dsosuffix;
a66d34
	const char *			exeprefix;
a66d34
	const char *			exesuffix;
a66d34
	const char *			impprefix;
a66d34
	const char *			impsuffix;
41790b
	const char *			ldpathenv;
a66d34
};
a66d34
9ca8c4
struct slbt_common_ctx {
9ca8c4
	uint64_t			drvflags;
9ca8c4
	uint64_t			actflags;
9ca8c4
	uint64_t			fmtflags;
a2fcc0
	struct slbt_host_params		host;
a2fcc0
	struct slbt_host_params		cfgmeta;
a66d34
	struct slbt_flavor_settings	settings;
a313a4
	struct slbt_host_params		ahost;
a313a4
	struct slbt_host_params		acfgmeta;
a313a4
	struct slbt_flavor_settings	asettings;
5a9161
	struct slbt_version_info	verinfo;
667ce2
	enum slbt_mode			mode;
53f4ec
	enum slbt_tag			tag;
6376f0
	enum slbt_warning_level		warnings;
36a4c5
	char **				cargv;
36a4c5
	char **				targv;
36a4c5
	char *				libname;
4df790
	const char *			target;
b83b64
	const char *			output;
bfa8ca
	const char *			shrext;
9c664d
	const char *			rpath;
9aa1f4
	const char *			release;
873ecb
	const char *			symfile;
73ca78
	const char *			regex;
9b5eec
	const char *			user;
9ca8c4
};
9ca8c4
9ca8c4
struct slbt_driver_ctx {
9ca8c4
	const char **			units;
9ca8c4
	const char *			program;
9ca8c4
	const char *			module;
9ca8c4
	const struct slbt_common_ctx *	cctx;
6dc887
	struct slbt_error_info **	errv;
9ca8c4
	void *				any;
9ca8c4
};
9ca8c4
9ca8c4
struct slbt_unit_ctx {
9ca8c4
	const char * const *		path;
9ca8c4
	const struct slbt_input *	map;
9ca8c4
	const struct slbt_common_ctx *	cctx;
9ca8c4
	void *				any;
9ca8c4
	int				status;
9ca8c4
	int				nerrors;
9ca8c4
};
9ca8c4
9f24d2
/* package info */
9f24d2
slbt_api				const struct slbt_source_version * slbt_source_version(void);
9f24d2
9ca8c4
/* driver api */
9ca8c4
slbt_api int  slbt_get_driver_ctx	(char ** argv, char ** envp, uint32_t flags, struct slbt_driver_ctx **);
9ca8c4
slbt_api int  slbt_create_driver_ctx	(const struct slbt_common_ctx *, struct slbt_driver_ctx **);
9ca8c4
slbt_api void slbt_free_driver_ctx	(struct slbt_driver_ctx *);
9ca8c4
9ca8c4
slbt_api int  slbt_get_unit_ctx		(const struct slbt_driver_ctx *, const char * path, struct slbt_unit_ctx **);
9ca8c4
slbt_api void slbt_free_unit_ctx	(struct slbt_unit_ctx *);
9ca8c4
5e3f48
/* execution context api */
528799
slbt_api int  slbt_get_exec_ctx		(const struct slbt_driver_ctx *, struct slbt_exec_ctx **);
528799
slbt_api void slbt_free_exec_ctx	(struct slbt_exec_ctx *);
e7ddb2
slbt_api void slbt_reset_arguments	(struct slbt_exec_ctx *);
5aae4b
slbt_api void slbt_reset_placeholders	(struct slbt_exec_ctx *);
2a7f1c
slbt_api void slbt_disable_placeholders	(struct slbt_exec_ctx *);
528799
5e3f48
/* core api */
36de3e
slbt_api int  slbt_exec_compile		(const struct slbt_driver_ctx *, struct slbt_exec_ctx *);
e956c8
slbt_api int  slbt_exec_execute		(const struct slbt_driver_ctx *, struct slbt_exec_ctx *);
258073
slbt_api int  slbt_exec_install		(const struct slbt_driver_ctx *, struct slbt_exec_ctx *);
2bd749
slbt_api int  slbt_exec_link		(const struct slbt_driver_ctx *, struct slbt_exec_ctx *);
0fb20a
slbt_api int  slbt_exec_uninstall	(const struct slbt_driver_ctx *, struct slbt_exec_ctx *);
36de3e
a313a4
slbt_api int  slbt_set_alternate_host	(const struct slbt_driver_ctx *, const char * host, const char * flavor);
a313a4
slbt_api void slbt_reset_alternate_host	(const struct slbt_driver_ctx *);
a313a4
4a01cf
/* helper api */
9ca8c4
slbt_api int  slbt_map_input		(int fd, const char * path, int prot, struct slbt_input *);
9ca8c4
slbt_api int  slbt_unmap_input		(struct slbt_input *);
4a01cf
slbt_api int  slbt_archive_import	(const struct slbt_driver_ctx *, struct slbt_exec_ctx *,
4a01cf
					 char * dstarchive, char * srcarchive);
13b6d8
slbt_api int  slbt_copy_file		(const struct slbt_driver_ctx *, struct slbt_exec_ctx *,
13b6d8
					 char * src, char * dst);
575cdb
slbt_api int  slbt_dump_machine		(const char * compiler, char * machine, size_t bufsize);
9ca8c4
9ca8c4
/* utility api */
fffc91
slbt_api int  slbt_main			(int, char **, char **);
617bbc
slbt_api int  slbt_output_config	(const struct slbt_driver_ctx *);
fab986
slbt_api int  slbt_output_exec		(const struct slbt_driver_ctx *, const struct slbt_exec_ctx *, const char *);
6f991b
slbt_api int  slbt_output_compile	(const struct slbt_driver_ctx *, const struct slbt_exec_ctx *);
045b88
slbt_api int  slbt_output_execute	(const struct slbt_driver_ctx *, const struct slbt_exec_ctx *);
ca15b9
slbt_api int  slbt_output_install	(const struct slbt_driver_ctx *, const struct slbt_exec_ctx *);
ba3523
slbt_api int  slbt_output_link		(const struct slbt_driver_ctx *, const struct slbt_exec_ctx *);
0fb20a
slbt_api int  slbt_output_uninstall	(const struct slbt_driver_ctx *, const struct slbt_exec_ctx *);
d36645
slbt_api int  slbt_output_error_record	(const struct slbt_driver_ctx *, const struct slbt_error_info *);
d36645
slbt_api int  slbt_output_error_vector	(const struct slbt_driver_ctx *);
9ca8c4
9ca8c4
#ifdef __cplusplus
9ca8c4
}
9ca8c4
#endif
9ca8c4
9ca8c4
#endif