From 382da0ada99a2874052f0e6ccb2c25e012d47fc9 Mon Sep 17 00:00:00 2001 From: gramanas Date: Sat, 13 Nov 2021 21:05:38 +0200 Subject: Update Makefile and add list ingredients draft --- src/types.h | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/types.h (limited to 'src/types.h') diff --git a/src/types.h b/src/types.h new file mode 100644 index 0000000..0d870cf --- /dev/null +++ b/src/types.h @@ -0,0 +1,73 @@ +#ifndef __TYPES_H +#define __TYPES_H + +typedef struct item_t { + char *name; + char *qty; +} item; + +enum step_type { + PREP = 0, + COOK, + SERVE, +}; + +typedef struct step_t { + char *inst; + char *duration; + char *result; + enum step_type type; +} step; + +typedef struct recipe_t { + char * filename; + char * path; + char * title; + int n; + item **i; + int in; + step **s; + int sn; + struct recipe_t **r; + int rn; +} recipe; + +recipe * new_recipe(); +void new_subrecipe(recipe * r, recipe * src); +void new_item(recipe * r); +void new_step(recipe * r); + +void free_recipe(recipe * r); +void free_item(item * i); +void free_step(step * s); + +void pprint_items(recipe * r); +void show(recipe * r); +void tojson(recipe * r); +void tohtml(recipe * r); +void torcp(recipe * r); + +/* Operations */ + +/** + * Copy metadata from `src` to `dst` + */ +void copy_metadata(recipe * dst, recipe * src); + +/** + * Copy top level items from `src` to `dst` + */ +void copy_items(recipe * dst, recipe * src); + +/** + * Merge all items from `src` and add them to `dst` + */ +void merge_items(recipe * dst, recipe * src); + +/** + * Sum all top level item qtys in `src` and add them to `dst` + * making sure each item name exists only once. + */ +void distinct_sum_items(recipe * dst, recipe * src); + +#endif /* __TYPES_H */ -- cgit v1.2.3