aboutsummaryrefslogtreecommitdiff
path: root/src_c/common.h
diff options
context:
space:
mode:
authorbozo.kopic <bozo@kopic.xyz>2021-12-21 02:50:05 +0100
committerbozo.kopic <bozo@kopic.xyz>2021-12-21 02:50:05 +0100
commit56b2ab072e099283d256c8346ae67f4dae77e260 (patch)
treecacbda0d76e1b0440aee524761ef2684b387efab /src_c/common.h
parent3aa527764f9198335e3748a023f9135faec3a619 (diff)
WIP c implementation
Diffstat (limited to 'src_c/common.h')
-rw-r--r--src_c/common.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/src_c/common.h b/src_c/common.h
new file mode 100644
index 0000000..e8eb9d1
--- /dev/null
+++ b/src_c/common.h
@@ -0,0 +1,77 @@
+#ifndef OPCUT_COMMON_H
+#define OPCUT_COMMON_H
+
+
+#import <stdbool.h>
+#import <stdio.h>
+
+#define OPCUT_SUCCESS 0
+#define OPCUT_ERROR -1
+#define OPCUT_UNSOLVABLE 1
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ char *data;
+ size_t len;
+} opcut_str_t;
+
+typedef struct {
+ opcut_str_t id;
+ double width;
+ double height;
+} opcut_panel_t;
+
+typedef struct {
+ opcut_str_t id;
+ double width;
+ double height;
+ bool can_rotate;
+} opcut_item_t;
+
+typedef struct {
+ double cut_width;
+ bool min_initial_usage;
+ opcut_panel_t *panels;
+ size_t panels_len;
+ opcut_item_t *items;
+ size_t items_len;
+} opcut_params_t;
+
+typedef struct {
+ opcut_panel_t *panel;
+ opcut_item_t *item;
+ double x;
+ double y;
+ bool rotate;
+} opcut_used_t;
+
+typedef struct {
+ opcut_panel_t *panel;
+ double width;
+ double height;
+ double x;
+ double y;
+} opcut_unused_t;
+
+typedef struct {
+ opcut_params_t *params;
+ opcut_used_t *used;
+ size_t used_len;
+ opcut_unused_t *unused;
+ size_t unused_len;
+} opcut_result_t;
+
+
+int opcut_params_init(opcut_params_t *params, opcut_str_t *json);
+void opcut_params_destroy(opcut_params_t *params);
+int opcut_result_write(opcut_result_t *result, FILE *stream);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif