summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2015-12-29 04:48:00 -0500
committermidipix <writeonce@midipix.org>2016-01-01 22:50:23 -0500
commit383aa6559ee06236b7600df8df17d7f3ab254ca3 (patch)
tree1745e2888f440a7f56d54e29ce4a37a486d9d272 /include
parentd764f2cab0ed73a95f3574f7974ec53a516f3c0d (diff)
downloadapimagic-383aa6559ee06236b7600df8df17d7f3ab254ca3.tar.bz2
apimagic-383aa6559ee06236b7600df8df17d7f3ab254ca3.tar.xz
created skeleton.
Diffstat (limited to 'include')
-rw-r--r--include/apimagic/apimagic.h88
-rw-r--r--include/apimagic/apimagic_api.h35
2 files changed, 123 insertions, 0 deletions
diff --git a/include/apimagic/apimagic.h b/include/apimagic/apimagic.h
new file mode 100644
index 0000000..167c860
--- /dev/null
+++ b/include/apimagic/apimagic.h
@@ -0,0 +1,88 @@
+#ifndef APIMAGIC_H
+#define APIMAGIC_H
+
+#include <stdint.h>
+#include <stdio.h>
+
+#include "apimagic_api.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* pre-alpha */
+#ifndef AMGC_APP
+#ifndef AMGC_PRE_ALPHA
+#error libapimagic: pre-alpha: ABI is not final!
+#error to use the library, please pass -DAMGC_PRE_ALPHA to the compiler.
+#endif
+#endif
+
+/* status codes */
+#define AMGC_OK 0x00
+#define AMGC_USAGE 0x01
+#define AMGC_BAD_OPT 0x02
+#define AMGC_BAD_OPT_VAL 0x03
+#define AMGC_IO_ERROR 0xA0
+#define AMGC_MAP_ERROR 0xA1
+
+/* driver flags */
+#define AMGC_DRIVER_VERBOSITY_NONE 0x0000
+#define AMGC_DRIVER_VERBOSITY_ERRORS 0x0001
+#define AMGC_DRIVER_VERBOSITY_STATUS 0x0002
+#define AMGC_DRIVER_VERBOSITY_USAGE 0x0004
+#define AMGC_DRIVER_CLONE_VECTOR 0x0008
+
+#define AMGC_DRIVER_VERSION 0x0010
+#define AMGC_DRIVER_DRY_RUN 0x0020
+
+/* unit action flags */
+
+struct amgc_input {
+ void * addr;
+ size_t size;
+};
+
+struct amgc_common_ctx {
+ uint64_t drvflags;
+ uint64_t actflags;
+ uint64_t fmtflags;
+};
+
+struct amgc_driver_ctx {
+ const char ** units;
+ const char * program;
+ const char * module;
+ const struct amgc_common_ctx * cctx;
+ void * any;
+ int status;
+ int nerrors;
+};
+
+struct amgc_unit_ctx {
+ const char * const * path;
+ const struct amgc_input * map;
+ const struct amgc_common_ctx * cctx;
+ void * any;
+ int status;
+ int nerrors;
+};
+
+/* driver api */
+amgc_api int amgc_get_driver_ctx (const char ** argv, const char ** envp, uint32_t flags, struct amgc_driver_ctx **);
+amgc_api int amgc_create_driver_ctx (const struct amgc_common_ctx *, struct amgc_driver_ctx **);
+amgc_api void amgc_free_driver_ctx (struct amgc_driver_ctx *);
+
+amgc_api int amgc_get_unit_ctx (const struct amgc_driver_ctx *, const char * path, struct amgc_unit_ctx **);
+amgc_api void amgc_free_unit_ctx (struct amgc_unit_ctx *);
+
+amgc_api int amgc_map_input (int fd, const char * path, int prot, struct amgc_input *);
+amgc_api int amgc_unmap_input (struct amgc_input *);
+
+/* utility api */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/apimagic/apimagic_api.h b/include/apimagic/apimagic_api.h
new file mode 100644
index 0000000..263e2ee
--- /dev/null
+++ b/include/apimagic/apimagic_api.h
@@ -0,0 +1,35 @@
+#ifndef APIMAGIC_API_H
+#define APIMAGIC_API_H
+
+#include <limits.h>
+
+/* amgc_export */
+#if defined(__dllexport)
+#define amgc_export __dllexport
+#else
+#define amgc_export
+#endif
+
+/* amgc_import */
+#if defined(__dllimport)
+#define amgc_import __dllimport
+#else
+#define amgc_import
+#endif
+
+/* amgc_api */
+#ifndef AMGC_APP
+#if defined (AMGC_BUILD)
+#define amgc_api amgc_export
+#elif defined (AMGC_SHARED)
+#define amgc_api amgc_import
+#elif defined (AMGC_STATIC)
+#define amgc_api
+#else
+#define amgc_api
+#endif
+#else
+#define amgc_api
+#endif
+
+#endif