summaryrefslogtreecommitdiffstats
path: root/src/eval.c
diff options
context:
space:
mode:
authorAnastasios Grammenos <anastasios.grammenos@noris.gr>2022-10-23 19:20:39 +0300
committerAnastasios Grammenos <anastasios.grammenos@noris.gr>2022-10-23 19:20:39 +0300
commit7c5af1b2768247984a08569b35e47ff927e70389 (patch)
tree04ebe56d46bc4511a5549b0eda2a136d682185ea /src/eval.c
parent7b7240d50dd5e418bc17beff48aa5681b398b980 (diff)
downloadfoodtools-7c5af1b2768247984a08569b35e47ff927e70389.tar.gz
foodtools-7c5af1b2768247984a08569b35e47ff927e70389.tar.bz2
foodtools-7c5af1b2768247984a08569b35e47ff927e70389.zip
Start work for step evaluation
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c27
1 files changed, 27 insertions, 0 deletions
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;
}