summaryrefslogblamecommitdiffstats
path: root/src/types.h
blob: d589c79a86a9b765f958bbd8054ba2cd2fe24468 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11










                       
        












                         
        



           

                      
                


                      
                                             






                             
                              
                                           




                        




                                    
                                                                   



                                    




                                               

                                            





                                                   
                                                   
   
                                             
 
                      
#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;
  char sha1[41];
} 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 listing(recipe * r, const char * fmt);
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_subrecipes(recipe * dst, recipe * src, int shallow_copy);

/**
 * 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);

/**
 * Merge all steps from `src` and add them to `dst`
 */
void merge_steps(recipe * dst, recipe * src);

#endif /* __TYPES_H */