blob: 57bfbb024a9617542f0d12d4e7a8f31a47bb13a2 (
plain) (
tree)
|
|
#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)
{
if (!r) return NULL;
recipe * _r = new_recipe();
merge_items(_r, r);
merge_steps(_r, r);
copy_metadata(_r, r);
copy_subrecipes(_r, r);
create_hash(_r);
return _r;
}
|