summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2020-01-27 08:36:51 -0500
committermidipix <writeonce@midipix.org>2020-05-23 05:59:01 +0000
commit88751e9e5ee3726b8a6987aeaae04e956c2234f5 (patch)
tree1ba3549be38e7a9348ad5b48bb35869e3e733daa /include
parentfa6b3e3522edcd8c202669c5587f2b5c77ac150d (diff)
downloadtpax-88751e9e5ee3726b8a6987aeaae04e956c2234f5.tar.bz2
tpax-88751e9e5ee3726b8a6987aeaae04e956c2234f5.tar.xz
created lib-app skeleton (foss21.org lib-app model).
Diffstat (limited to 'include')
-rw-r--r--include/empty.dir0
-rw-r--r--include/tpax/tpax.h142
-rw-r--r--include/tpax/tpax_api.h35
3 files changed, 177 insertions, 0 deletions
diff --git a/include/empty.dir b/include/empty.dir
deleted file mode 100644
index e69de29..0000000
--- a/include/empty.dir
+++ /dev/null
diff --git a/include/tpax/tpax.h b/include/tpax/tpax.h
new file mode 100644
index 0000000..e89076d
--- /dev/null
+++ b/include/tpax/tpax.h
@@ -0,0 +1,142 @@
+#ifndef TPAX_H
+#define TPAX_H
+
+#include <stdint.h>
+#include <stddef.h>
+
+#include "tpax_api.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* pre-alpha */
+#ifndef TPAX_APP
+#ifndef TPAX_PRE_ALPHA
+#error libtpax: pre-alpha: ABI is not final!
+#error to use the library, compile with -DTPAX_PRE_ALPHA.
+#endif
+#endif
+
+/* status codes */
+#define TPAX_OK 0x00
+#define TPAX_USAGE 0x01
+#define TPAX_ERROR 0x02
+
+/* driver flags */
+#define TPAX_DRIVER_VERBOSITY_NONE 0x0000
+#define TPAX_DRIVER_VERBOSITY_ERRORS 0x0001
+#define TPAX_DRIVER_VERBOSITY_STATUS 0x0002
+#define TPAX_DRIVER_VERBOSITY_USAGE 0x0004
+#define TPAX_DRIVER_CLONE_VECTOR 0x0008
+
+#define TPAX_DRIVER_VERSION 0x0010
+#define TPAX_DRIVER_DRY_RUN 0x0020
+
+#define TPAX_DRIVER_ANNOTATE_ALWAYS 0x1000
+#define TPAX_DRIVER_ANNOTATE_NEVER 0x2000
+#define TPAX_DRIVER_ANNOTATE_FULL 0x4000
+
+/* error flags */
+#define TPAX_ERROR_TOP_LEVEL 0x0001
+#define TPAX_ERROR_NESTED 0x0002
+#define TPAX_ERROR_CHILD 0x0004
+#define TPAX_ERROR_CUSTOM 0x0008
+
+enum tpax_custom_error {
+ TPAX_ERR_FLOW_ERROR,
+ TPAX_ERR_FLEE_ERROR,
+ TPAX_ERR_NULL_CONTEXT,
+ TPAX_ERR_BAD_DATA,
+ TPAX_ERR_CAP,
+};
+
+enum tpax_warning_level {
+ TPAX_WARNING_LEVEL_UNKNOWN,
+ TPAX_WARNING_LEVEL_ALL,
+ TPAX_WARNING_LEVEL_ERROR,
+ TPAX_WARNING_LEVEL_NONE,
+};
+
+struct tpax_source_version {
+ int major;
+ int minor;
+ int revision;
+ const char * commit;
+};
+
+struct tpax_fd_ctx {
+ int fdin;
+ int fdout;
+ int fderr;
+ int fdlog;
+ int fdcwd;
+ int fddst;
+};
+
+struct tpax_error_info {
+ const struct tpax_driver_ctx * edctx;
+ const struct tpax_unit_ctx * euctx;
+ const char * eunit;
+ int esyscode;
+ int elibcode;
+ const char * efunction;
+ int eline;
+ unsigned eflags;
+ void * eany;
+};
+
+struct tpax_common_ctx {
+ uint64_t drvflags;
+ uint64_t actflags;
+ uint64_t fmtflags;
+};
+
+struct tpax_driver_ctx {
+ const char ** units;
+ const char * program;
+ const char * module;
+ const struct tpax_common_ctx * cctx;
+ struct tpax_error_info ** errv;
+ void * any;
+};
+
+struct tpax_unit_ctx {
+ const char * const * path;
+ void * any;
+};
+
+/* driver api */
+tpax_api int tpax_get_driver_ctx (char ** argv, char ** envp, uint32_t flags,
+ const struct tpax_fd_ctx *,
+ struct tpax_driver_ctx **);
+
+tpax_api void tpax_free_driver_ctx (struct tpax_driver_ctx *);
+
+tpax_api int tpax_get_unit_ctx (const struct tpax_driver_ctx *, const char * path,
+ struct tpax_unit_ctx **);
+
+tpax_api void tpax_free_unit_ctx (struct tpax_unit_ctx *);
+
+tpax_api int tpax_get_driver_fdctx (const struct tpax_driver_ctx *, struct tpax_fd_ctx *);
+tpax_api int tpax_set_driver_fdctx (struct tpax_driver_ctx *, const struct tpax_fd_ctx *);
+
+/* core api */
+
+/* helper api */
+
+/* utility api */
+tpax_api int tpax_main (char **, char **,
+ const struct tpax_fd_ctx *);
+/* error trace api */
+tpax_api int tpax_output_error_record (const struct tpax_driver_ctx *, const struct tpax_error_info *);
+tpax_api int tpax_output_error_vector (const struct tpax_driver_ctx *);
+
+/* package info */
+tpax_api const struct tpax_source_version * tpax_source_version(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/tpax/tpax_api.h b/include/tpax/tpax_api.h
new file mode 100644
index 0000000..0e6db99
--- /dev/null
+++ b/include/tpax/tpax_api.h
@@ -0,0 +1,35 @@
+#ifndef TPAX_API_H
+#define TPAX_API_H
+
+#include <limits.h>
+
+/* tpax_export */
+#if defined(__dllexport)
+#define tpax_export __dllexport
+#else
+#define tpax_export
+#endif
+
+/* tpax_import */
+#if defined(__dllimport)
+#define tpax_import __dllimport
+#else
+#define tpax_import
+#endif
+
+/* tpax_api */
+#ifndef TPAX_APP
+#if defined (TPAX_EXPORT)
+#define tpax_api tpax_export
+#elif defined (TPAX_IMPORT)
+#define tpax_api tpax_import
+#elif defined (TPAX_STATIC)
+#define tpax_api
+#else
+#define tpax_api
+#endif
+#else
+#define tpax_api
+#endif
+
+#endif