diff --git a/build/logic.o b/build/logic.o index 0c36feb..93bc5bd 100644 Binary files a/build/logic.o and b/build/logic.o differ diff --git a/build/main.o b/build/main.o index bbe69c6..e6b6b9a 100644 Binary files a/build/main.o and b/build/main.o differ diff --git a/build/testLogic.d b/build/testLogic.d new file mode 100644 index 0000000..5a0fa52 --- /dev/null +++ b/build/testLogic.d @@ -0,0 +1,4 @@ +build/testLogic.o: src/testLogic.c src/../include/logic.h \ + src/../include/globals.h +src/../include/logic.h: +src/../include/globals.h: diff --git a/build/testLogic.o b/build/testLogic.o new file mode 100644 index 0000000..f6118ee Binary files /dev/null and b/build/testLogic.o differ diff --git a/build/windows.o b/build/windows.o index e4b04df..5558db7 100644 Binary files a/build/windows.o and b/build/windows.o differ diff --git a/git b/git new file mode 100644 index 0000000..b2cd66e --- /dev/null +++ b/git @@ -0,0 +1,7 @@ +-----BEGIN OPENSSH PRIVATE KEY----- +b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW +QyNTUxOQAAACDoGTp2mFxRu8ExX/qqNfnG0OUg147jqrAhjLkX0hKBxwAAAJhqlG87apRv +OwAAAAtzc2gtZWQyNTUxOQAAACDoGTp2mFxRu8ExX/qqNfnG0OUg147jqrAhjLkX0hKBxw +AAAEC0ZNFQCTPlQrSl0voBkhX5SA6ZjIOTQ1sUiWLOtBhnZugZOnaYXFG7wTFf+qo1+cbQ +5SDXjuOqsCGMuRfSEoHHAAAAFHJleGVyZWZAcG9ydGF0aWxlbnpvAQ== +-----END OPENSSH PRIVATE KEY----- diff --git a/git.pub b/git.pub new file mode 100644 index 0000000..576c8a4 --- /dev/null +++ b/git.pub @@ -0,0 +1 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOgZOnaYXFG7wTFf+qo1+cbQ5SDXjuOqsCGMuRfSEoHH rexeref@portatilenzo diff --git a/include/logic.h b/include/logic.h index 0e959a3..1e29679 100644 --- a/include/logic.h +++ b/include/logic.h @@ -7,10 +7,13 @@ #include struct product { - char + float cost; + int numberSold; + char name; }; int getCount(); -int exists(const char *fname); +int existsFile(const char *fname); +void createFile(const char *fname); #endif diff --git a/makefile b/makefile index f2dddec..d67b264 100644 --- a/makefile +++ b/makefile @@ -6,6 +6,7 @@ BUILD_DIR = build SOURCES = $(wildcard $(SRC_DIR)/*.c) OBJECTS = $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(SOURCES)) EXEC = productManager +EXECTEST = test DEPS = $(OBJECTS:.o=.d) @@ -20,6 +21,9 @@ $(BUILD_DIR)/%.o: $(SRC_DIR)/%.c -include $(DEPS) +test: + $(CC) $(CFLAGS) src/logic.c src/testLogic.c -o $(EXECTEST) + clean: rm -rf $(BUILD_DIR) $(EXEC) diff --git a/productManager b/productManager deleted file mode 100755 index 1702200..0000000 Binary files a/productManager and /dev/null differ diff --git a/productPricesSettings.fpm b/productPricesSettings.fpm deleted file mode 100644 index e69de29..0000000 diff --git a/productPricesSettings.txt b/productPricesSettings.txt deleted file mode 100644 index e69de29..0000000 diff --git a/src/logic.c b/src/logic.c index 888e26f..76f18f7 100644 --- a/src/logic.c +++ b/src/logic.c @@ -6,9 +6,18 @@ #include "../include/logic.h" #include "../include/globals.h" -FILE *products; +/* +* TODO: Listare prodotti con prezzo da file +* TODO: Aggiungere prodotto con prezzo a file +* TODO: Listare copie vendute di prodotto da file +* TODO: Aggiungere copie venduto di prodotto a file +* TODO: Cambiare nome dei file con interagisce +* TODO: Calcolare la somma delle entrate dati i file +*/ -int exists(const char *fname) { +char *products; + +int existsFile(const char *fname) { FILE *file; if ((file = fopen(fname, "r"))) { @@ -18,7 +27,36 @@ int exists(const char *fname) { return 0; } +void createFile(const char *fname) { + FILE *file; + file = fopen(fname, "w"); + fclose(file); +} + +char* getProducts(const char *fname) { + FILE *file; + + if((file=fopen(fname, "r"))==NULL) { + printf("Errore nell'apertura del file"); + exit(1); + } + +// TODO QUESTO CODICE NON E' MIO, RICONTROLLARE FUNZIONAMENTO fread() + + while(!feof(file)){ + n = fread(buffer, sizeof(char), sizeof(buffer), file); + for (i=0; i +#include +#include +#include + +#include "../include/logic.h" +#include "../include/globals.h" + +int main() { + printf("%d", exists("qwestoeuntest")); + createFile("qwestoeuntest"); + printf("%d", exists("qwestoeuntest")); + return 0; +}