From 51d16373fbaa027e91f230a7423ebb1b2d339042 Mon Sep 17 00:00:00 2001 From: Anastasios Grammenos Date: Sun, 23 Oct 2022 21:05:57 +0300 Subject: More --- src/eval.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) (limited to 'src/eval.c') diff --git a/src/eval.c b/src/eval.c index 98ad3bf..aa9a236 100644 --- a/src/eval.c +++ b/src/eval.c @@ -21,11 +21,64 @@ create_hash(recipe * r) sha1digest(NULL, r->sha1, (uint8_t *)data, strlen(data)); } +/* TODO: Needs work to actually remove the extra characters only when they + define a variable/time schedule */ +char * +inst2txt(char * s) +{ + char txt[FOOD_MAX_ARRAY] = "\0"; + int l = 0; + for (int i=0; i 0) { + duration[l] = s[i]; + duration[l+1] = '\0'; + l = strlen(duration); + } + if (s[i] == '[') + flag = flag + 1; + } + + if (strlen(duration)) { + return strdup(duration); + } + + return NULL; +} + int eval_step(step * s) { - s->duration = strdup(s->inst); - s->result = strdup(s->inst); + s->txt = inst2txt(s->inst); + s->duration = inst2duration(s->inst); + // s->result = strdup(s->inst); return 0; } -- cgit v1.2.3