aboutsummaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/main.c b/main.c
new file mode 100644
index 0000000..e1e22ec
--- /dev/null
+++ b/main.c
@@ -0,0 +1,57 @@
+#include "pipeline.h"
+
+#define UNUSED(_v) ((void)(_v))
+
+PIPELINE_STAGE int stage(struct pipeline_ctx_t *ctx, void *data, size_t len)
+{
+ UNUSED(ctx);
+ UNUSED(data);
+ UNUSED(len);
+ return 1;
+}
+
+PIPELINE_STAGE int identity_stage(struct pipeline_ctx_t *ctx, void *data, size_t len) {
+ return pipeline_next(ctx, data, len);
+}
+
+/* mockup:
+ * Pipeline signature: D -> D*1
+ * int simple_1to1_stage(struct pipeline_ctx *ctx, void *data, size_t len) {
+ * void *out = ... transform data ...;
+ * size_t out_len = ^^^;
+ * return pipeline_next(ctx, out, out_len);
+ * }
+ *
+ * Pipeline signature: D -> D*(0,n)
+ * int complex_1tomany_stage(struct pipeline_ctx *ctx, void *data, size_t len) {
+ * int err;
+ * for (void *out; has_data(data, len); out = next_data(data, &len)) {
+ * if (!out) {
+ * return -1; ... next_data failed somehow ...
+ * }
+ *
+ * if ((err = pipeline_next(ctx, out, out_len)) < 0) {
+ * return err;
+ * }
+ * }
+ * return 0;
+ * }
+ *
+ * Pipeline signature: D -> D*1
+ * int stateful_stage(struct pipeline_ctx *ctx, void *data, size_t len) {
+ * my_stage_t *stg = ctx->me;
+ * stg->stat_in += len;
+ * return pipeline_next(ctx, data, len);
+ * }
+ *
+ * Pipeline signature: D -> void (i.e., never calls next)
+ * int terminal_stage(struct pipeline_ctx *ctx, void *data, size_t len) {
+ * my_handler_t *handler = ctx->me;
+ * handler->do_handle(data, len);
+ * return 0; ... return values should indicate pipeline (i.e., parsing) errors, not application errors ...
+ * }
+ */
+
+int main(void) {
+ return 0;
+}