summaryrefslogtreecommitdiffstats
path: root/main.c
blob: e1e22ec4e976011f08992c68fdf2e5856625a4cd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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;
}