summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2015-12-14 01:58:21 -0500
committermidipix <writeonce@midipix.org>2015-12-14 01:58:21 -0500
commitf4603994a39431c8cee036216a6d15ab7281b0c6 (patch)
tree8fc779f0c3ec5e8f0041c89b1700ffd2120f6b42 /include
parent668af644e512cc911a32a955078866d9151bae80 (diff)
downloadsofort-f4603994a39431c8cee036216a6d15ab7281b0c6.tar.bz2
sofort-f4603994a39431c8cee036216a6d15ab7281b0c6.tar.xz
initial commit.
Diffstat (limited to 'include')
-rw-r--r--include/sofort/sofort.h93
-rw-r--r--include/sofort/sofort_api.h35
2 files changed, 128 insertions, 0 deletions
diff --git a/include/sofort/sofort.h b/include/sofort/sofort.h
new file mode 100644
index 0000000..ee5072f
--- /dev/null
+++ b/include/sofort/sofort.h
@@ -0,0 +1,93 @@
+#ifndef SFRT_H
+#define SFRT_H
+
+#include <stdint.h>
+#include <stdio.h>
+
+#include "sofort_api.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* pre-alpha */
+#ifndef SFRT_APP
+#ifndef SFRT_PRE_ALPHA
+#error libsofort: pre-alpha: ABI is not final!
+#error to use the library, please pass -DSFRT_PRE_ALPHA to the compiler.
+#endif
+#endif
+
+/* status codes */
+#define SFRT_OK 0x00
+#define SFRT_USAGE 0x01
+#define SFRT_BAD_OPT 0x02
+#define SFRT_BAD_OPT_VAL 0x03
+#define SFRT_IO_ERROR 0xA0
+#define SFRT_MAP_ERROR 0xA1
+
+/* driver flags */
+#define SFRT_DRIVER_VERBOSITY_NONE 0x0000
+#define SFRT_DRIVER_VERBOSITY_ERRORS 0x0001
+#define SFRT_DRIVER_VERBOSITY_STATUS 0x0002
+#define SFRT_DRIVER_VERBOSITY_USAGE 0x0004
+#define SFRT_DRIVER_CLONE_VECTOR 0x0008
+
+#define SFRT_DRIVER_VERSION 0x0010
+#define SFRT_DRIVER_DRY_RUN 0x0020
+
+/* unit action flags */
+#define SFRT_OUTPUT_NAME 0x0001
+#define SFRT_OUTPUT_ADDRESS 0x0002
+
+struct sfrt_input {
+ void * addr;
+ size_t size;
+};
+
+struct sfrt_common_ctx {
+ uint64_t drvflags;
+ uint64_t actflags;
+ uint64_t fmtflags;
+ const char * anystring;
+};
+
+struct sfrt_driver_ctx {
+ const char ** units;
+ const char * program;
+ const char * module;
+ const struct sfrt_common_ctx * cctx;
+ void * any;
+ int status;
+ int nerrors;
+};
+
+struct sfrt_unit_ctx {
+ const char * const * path;
+ const struct sfrt_input * map;
+ const struct sfrt_common_ctx * cctx;
+ void * any;
+ int status;
+ int nerrors;
+};
+
+/* driver api */
+sfrt_api int sfrt_get_driver_ctx (const char ** argv, const char ** envp, uint32_t flags, struct sfrt_driver_ctx **);
+sfrt_api void sfrt_free_driver_ctx (struct sfrt_driver_ctx *);
+
+sfrt_api int sfrt_get_unit_ctx (const struct sfrt_driver_ctx *, const char * path, struct sfrt_unit_ctx **);
+sfrt_api void sfrt_free_unit_ctx (struct sfrt_unit_ctx *);
+
+sfrt_api int sfrt_map_input (int fd, const char * path, int prot, struct sfrt_input *);
+sfrt_api int sfrt_unmap_input (struct sfrt_input *);
+
+/* utility api */
+sfrt_api int sfrt_output_dummy (const struct sfrt_common_ctx *, FILE *);
+sfrt_api int sfrt_output_name (const struct sfrt_unit_ctx *, FILE *);
+sfrt_api int sfrt_output_address (const struct sfrt_unit_ctx *, FILE *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/sofort/sofort_api.h b/include/sofort/sofort_api.h
new file mode 100644
index 0000000..5f0b2d9
--- /dev/null
+++ b/include/sofort/sofort_api.h
@@ -0,0 +1,35 @@
+#ifndef SFRT_API_H
+#define SFRT_API_H
+
+#include <limits.h>
+
+/* sfrt_export */
+#if defined(__dllexport)
+#define sfrt_export __dllexport
+#else
+#define sfrt_export
+#endif
+
+/* sfrt_import */
+#if defined(__dllimport)
+#define sfrt_import __dllimport
+#else
+#define sfrt_import
+#endif
+
+/* sfrt_api */
+#ifndef SFRT_APP
+#if defined (SFRT_BUILD)
+#define sfrt_api sfrt_export
+#elif defined (SFRT_SHARED)
+#define sfrt_api sfrt_import
+#elif defined (SFRT_STATIC)
+#define sfrt_api
+#else
+#define sfrt_api
+#endif
+#else
+#define sfrt_api
+#endif
+
+#endif