diff options
author | midipix <writeonce@midipix.org> | 2016-03-04 13:32:05 -0500 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-03-08 14:21:05 -0500 |
commit | 9ca8c4c3c1b2cb1b22a3ff04c1c37b0863dd87f6 (patch) | |
tree | d1659a6814efef596730d6da5247b3fdd58d179b /include | |
parent | 0ff546cab29192407bf991bf915dce52c049c387 (diff) | |
download | slibtool-9ca8c4c3c1b2cb1b22a3ff04c1c37b0863dd87f6.tar.bz2 slibtool-9ca8c4c3c1b2cb1b22a3ff04c1c37b0863dd87f6.tar.xz |
created skeleton.
Diffstat (limited to 'include')
-rw-r--r-- | include/slibtool/slibtool.h | 88 | ||||
-rw-r--r-- | include/slibtool/slibtool_api.h | 35 |
2 files changed, 123 insertions, 0 deletions
diff --git a/include/slibtool/slibtool.h b/include/slibtool/slibtool.h new file mode 100644 index 0000000..4aec0cc --- /dev/null +++ b/include/slibtool/slibtool.h @@ -0,0 +1,88 @@ +#ifndef SOFORT_H +#define SOFORT_H + +#include <stdint.h> +#include <stdio.h> + +#include "slibtool_api.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* pre-alpha */ +#ifndef SLBT_APP +#ifndef SLBT_PRE_ALPHA +#error libslibtool: pre-alpha: ABI is not final! +#error to use the library, please pass -DSLBT_PRE_ALPHA to the compiler. +#endif +#endif + +/* status codes */ +#define SLBT_OK 0x00 +#define SLBT_USAGE 0x01 +#define SLBT_BAD_OPT 0x02 +#define SLBT_BAD_OPT_VAL 0x03 +#define SLBT_IO_ERROR 0xA0 +#define SLBT_MAP_ERROR 0xA1 + +/* driver flags */ +#define SLBT_DRIVER_VERBOSITY_NONE 0x0000 +#define SLBT_DRIVER_VERBOSITY_ERRORS 0x0001 +#define SLBT_DRIVER_VERBOSITY_STATUS 0x0002 +#define SLBT_DRIVER_VERBOSITY_USAGE 0x0004 +#define SLBT_DRIVER_CLONE_VECTOR 0x0008 + +#define SLBT_DRIVER_VERSION 0x0010 +#define SLBT_DRIVER_DRY_RUN 0x0020 + +/* unit action flags */ + +struct slbt_input { + void * addr; + size_t size; +}; + +struct slbt_common_ctx { + uint64_t drvflags; + uint64_t actflags; + uint64_t fmtflags; +}; + +struct slbt_driver_ctx { + const char ** units; + const char * program; + const char * module; + const struct slbt_common_ctx * cctx; + void * any; + int status; + int nerrors; +}; + +struct slbt_unit_ctx { + const char * const * path; + const struct slbt_input * map; + const struct slbt_common_ctx * cctx; + void * any; + int status; + int nerrors; +}; + +/* driver api */ +slbt_api int slbt_get_driver_ctx (char ** argv, char ** envp, uint32_t flags, struct slbt_driver_ctx **); +slbt_api int slbt_create_driver_ctx (const struct slbt_common_ctx *, struct slbt_driver_ctx **); +slbt_api void slbt_free_driver_ctx (struct slbt_driver_ctx *); + +slbt_api int slbt_get_unit_ctx (const struct slbt_driver_ctx *, const char * path, struct slbt_unit_ctx **); +slbt_api void slbt_free_unit_ctx (struct slbt_unit_ctx *); + +slbt_api int slbt_map_input (int fd, const char * path, int prot, struct slbt_input *); +slbt_api int slbt_unmap_input (struct slbt_input *); + +/* utility api */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/slibtool/slibtool_api.h b/include/slibtool/slibtool_api.h new file mode 100644 index 0000000..2be0a47 --- /dev/null +++ b/include/slibtool/slibtool_api.h @@ -0,0 +1,35 @@ +#ifndef SOFORT_API_H +#define SOFORT_API_H + +#include <limits.h> + +/* slbt_export */ +#if defined(__dllexport) +#define slbt_export __dllexport +#else +#define slbt_export +#endif + +/* slbt_import */ +#if defined(__dllimport) +#define slbt_import __dllimport +#else +#define slbt_import +#endif + +/* slbt_api */ +#ifndef SLBT_APP +#if defined (SLBT_BUILD) +#define slbt_api slbt_export +#elif defined (SLBT_SHARED) +#define slbt_api slbt_import +#elif defined (SLBT_STATIC) +#define slbt_api +#else +#define slbt_api +#endif +#else +#define slbt_api +#endif + +#endif |