From 7c5af1b2768247984a08569b35e47ff927e70389 Mon Sep 17 00:00:00 2001 From: Anastasios Grammenos Date: Sun, 23 Oct 2022 19:20:39 +0300 Subject: Start work for step evaluation --- src/eval.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/eval.c') diff --git a/src/eval.c b/src/eval.c index d6c8933..98ad3bf 100644 --- a/src/eval.c +++ b/src/eval.c @@ -21,6 +21,31 @@ create_hash(recipe * r) sha1digest(NULL, r->sha1, (uint8_t *)data, strlen(data)); } +int +eval_step(step * s) +{ + s->duration = strdup(s->inst); + s->result = strdup(s->inst); + return 0; +} + +int +resolve_steps(recipe * r) +{ + if (!r) return 1; + + int rc = 0; + for (int i=0; i < r->sn; i++) { + rc += eval_step(r->s[i]); + } + + if (rc > 0) { + return 1; + } + + return 0; +} + recipe * eval(recipe * r) { @@ -33,6 +58,8 @@ eval(recipe * r) copy_subrecipes(_r, r, 0 /* shallow copy off */); create_hash(_r); + + resolve_steps(_r); return _r; } -- cgit v1.2.3