diff options
author | Anastasios Grammenos <anastasios.grammenos@noris.gr> | 2022-10-23 19:20:39 +0300 |
---|---|---|
committer | Anastasios Grammenos <anastasios.grammenos@noris.gr> | 2022-10-23 19:20:39 +0300 |
commit | 7c5af1b2768247984a08569b35e47ff927e70389 (patch) | |
tree | 04ebe56d46bc4511a5549b0eda2a136d682185ea /src/types.c | |
parent | 7b7240d50dd5e418bc17beff48aa5681b398b980 (diff) | |
download | foodtools-7c5af1b2768247984a08569b35e47ff927e70389.tar.gz foodtools-7c5af1b2768247984a08569b35e47ff927e70389.tar.bz2 foodtools-7c5af1b2768247984a08569b35e47ff927e70389.zip |
Start work for step evaluation
Diffstat (limited to 'src/types.c')
-rw-r--r-- | src/types.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/types.c b/src/types.c index 9314f8d..68c402c 100644 --- a/src/types.c +++ b/src/types.c @@ -72,7 +72,7 @@ new_step(recipe * r) r->s[r->sn] = (step *)malloc(sizeof(step)); if (!r->s[r->sn]) - die("Couldn't allocate memory for item"); + die("Couldn't allocate memory for step"); r->s[r->sn]->inst = NULL; r->s[r->sn]->duration = NULL; r->s[r->sn]->result = NULL; @@ -220,8 +220,8 @@ tojson(recipe * r) printf(",\"steps\":["); int i = 0; for (; i < r->sn - 1; i++) - printf("\"%s\",", r->s[i]->inst); - printf("\"%s\"]", r->s[i]->inst); + printf("{\"inst\":\"%s\",\"duration\":\"%s\",\"result\":\"%s\",\"type\":\"%s\"},", r->s[i]->inst, r->s[i]->duration, r->s[i]->result, r->s[i]->type == 0 ? "prep" : (r->s[i]->type == 1 ? "cook" : "serve") ); + printf("{\"inst\":\"%s\",\"duration\":\"%s\",\"result\":\"%s\",\"type\":\"%s\"}]", r->s[i]->inst, r->s[i]->duration, r->s[i]->result, r->s[i]->type == 0 ? "prep" : (r->s[i]->type == 1 ? "cook" : "serve") ); } printf("}"); } @@ -421,7 +421,8 @@ distinct_sum_items(recipe * dst, recipe * src) if (!strcmp(dst->i[n]->qty, "") && !strcmp(src->i[i]->qty, "")) { // noop - } else if (strlen(dst->i[n]->qty) + strlen(src->i[i]->qty) != 0) { + } else if (!strcmp(dst->i[n]->qty, "") + || !strcmp(src->i[i]->qty, "")) { char tmp[FOOD_MAX_ARRAY] = ""; strcat(tmp, dst->i[n]->qty); strcat(tmp, src->i[i]->qty); |