logo

Grimgrains

Unnamed repository; edit this file 'description' to name the repository.
commit: 852be7b8dd7c4132f68116d1ef042bd7fab9687d
parent 35cb9b234adb1b9dd6f71cdb229a6f0df01e2ce0
Author: neauoire <aliceffekt@gmail.com>
Date:   Fri, 20 Dec 2019 15:34:34 -0500

Started site builder

Diffstat:

Msrc/builder.c16++++++++++++----
Asrc/helpers.c16++++++++++++++++
Msrc/ingredient.c10++++++++++
Msrc/main.c6+++---
4 files changed, 41 insertions(+), 7 deletions(-)

diff --git a/src/builder.c b/src/builder.c @@ -1,4 +1,15 @@ +int ingredients_len = sizeof ingredients / sizeof ingredients[0]; +int recipes_len = sizeof recipes / sizeof recipes[0]; + +printf("Found Ingredients: %d, Recipes: %d\n",ingredients_len,recipes_len); + + + +for(int i = 0; i < ingredients_len; ++i) { + build_ingredient_page(ingredients[i]); +} + /* FILE *myfile = fopen("../site/somefile.txt", "w"); @@ -8,7 +19,5 @@ fclose(myfile); */ -int ingredients_len = sizeof ingredients / sizeof ingredients[0]; -int recipes_len = sizeof recipes / sizeof recipes[0]; -printf("Ingredients: %d Recipes: %d\n",ingredients_len,recipes_len);- \ No newline at end of file + diff --git a/src/helpers.c b/src/helpers.c @@ -0,0 +1,15 @@ + +void to_lowercase(char *str, char *modified) { + for (int i = 0; ; i++) { + modified[i] = str[i]; + if (modified[i] == '\0') { + break; + } + if (modified[i] == ' ') { + modified[i] = '_'; + } + else { + modified[i] = tolower(modified[i]); + } + } +}+ \ No newline at end of file diff --git a/src/ingredient.c b/src/ingredient.c @@ -31,4 +31,14 @@ Serving create_serving(Ingredient *ingredient, char *quantity) { a.ingredient = ingredient; a.quantity = quantity; return a; +} + +void print_ingredient(Ingredient *ingredient){ + printf("%s\n", ingredient->name); +} + +void build_ingredient_page(Ingredient *ingredient){ + char ingredient_path[1024]; + to_lowercase(ingredient->name, ingredient_path); + printf("%s -> %s\n", ingredient->name, ingredient_path); } \ No newline at end of file diff --git a/src/main.c b/src/main.c @@ -1,5 +1,7 @@ -#include "stdio.h" +#include <stdio.h> +#include <ctype.h> +#include "helpers.c" #include "ingredient.c" #include "recipe.c" @@ -10,7 +12,5 @@ int main(void) { #include "builder.c" - // print_recipe(&sweet_sour_lentils); - return (0); } \ No newline at end of file