summaryrefslogtreecommitdiffstats
path: root/src/eval.c
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2022-01-28 13:45:30 +0200
committergramanas <anastasis.gramm2@gmail.com>2022-01-28 13:45:30 +0200
commit53ab9ae05a579a19c626e8be0c1e2cf9244bf863 (patch)
treee6ec5ce8920124e8f4dd59d2ca20f45f30b4640e /src/eval.c
parent98849f6afb8e216000f6c642d9c9ffa26a58bd4c (diff)
downloadfoodtools-53ab9ae05a579a19c626e8be0c1e2cf9244bf863.tar.gz
foodtools-53ab9ae05a579a19c626e8be0c1e2cf9244bf863.tar.bz2
foodtools-53ab9ae05a579a19c626e8be0c1e2cf9244bf863.zip
sha1 sum and others
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/eval.c b/src/eval.c
index 8bc886a..57bfbb0 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1,5 +1,25 @@
#include "eval.h"
#include "util.h"
+#include <stdint.h>
+
+extern int
+sha1digest(uint8_t *digest, char *hexdigest, const uint8_t *data, size_t databytes);
+
+void
+create_hash(recipe * r)
+{
+ char data[65536] = "\0";
+
+ for (int i = 0; i < r->in; i++) {
+ strcat(data, r->i[i]->name);
+ strcat(data, r->i[i]->qty);
+ }
+ if (r->sn) {
+ for (int i = 0; i < r->sn; i++)
+ strcat(data, r->s[i]->inst);
+ }
+ sha1digest(NULL, r->sha1, (uint8_t *)data, strlen(data));
+}
recipe *
eval(recipe * r)
@@ -10,7 +30,10 @@ eval(recipe * r)
merge_items(_r, r);
merge_steps(_r, r);
copy_metadata(_r, r);
+ copy_subrecipes(_r, r);
+ create_hash(_r);
+
return _r;
}