From a74818918342a43dfa56d962c07196e0b32eb2ac Mon Sep 17 00:00:00 2001 From: matze Date: Sat, 28 Jul 2007 22:50:47 +0000 Subject: [PATCH] items und state laden geht, demodaten in dateien state und items git-svn-id: https://shell.noname-ev.de/svn/kasse/c128@33 af93e077-1a23-4f1e-9cbe-9382a9d578f5 --- config.c | 28 +++++++++++++++------------- items | 3 +++ state | 3 +++ test.c | 17 +++++++++++++++++ 4 files changed, 38 insertions(+), 13 deletions(-) create mode 100644 items create mode 100644 state create mode 100644 test.c diff --git a/config.c b/config.c index 19c375d..2488bfd 100644 --- a/config.c +++ b/config.c @@ -11,24 +11,26 @@ unsigned long int items_sold = 0; BYTE printer_port = 4; struct status_t status[MAX_ITEMS+1]; struct credits_t credits[MAX_CREDIT_ITEMS+1]; - +#define REAL_DATA #ifdef REAL_DATA void load_config(); void load_items(){ - FILE* f; - char line[80]; - char * sep; - f = fopen("items", "r"); - for (num_items=0; num_items < MAX_ITEMS && !feof(f); num_items++) { - fgets(line, 79, f); - sep = strchr(line, '='); - strncpy(status[num_items].item_name, line, sep-line); - status[num_items].price = atoi(sep+1); - status[num_items].times_sold = 0; - } - + FILE* f; + char line[80]; + char * sep; + BYTE lfn = 219; +// cbm_open(lfn, (BYTE)8, (BYTE)0, "items,r"); + f = fopen("items","r"); + for (num_items=0; num_items < MAX_ITEMS && !feof(f); num_items++) { + fgets(line, 79, f); + sep = strchr(line, '='); + strncpy(status[num_items].item_name, line, sep-line); + status[num_items].price = atoi(sep+1); + status[num_items].times_sold = 0; + } + fclose(f); } /** diff --git a/items b/items new file mode 100644 index 0000000..ecbe32d --- /dev/null +++ b/items @@ -0,0 +1,3 @@ +Mate=100 +Bier=120 +Cola=100 \ No newline at end of file diff --git a/state b/state new file mode 100644 index 0000000..a3a26f1 --- /dev/null +++ b/state @@ -0,0 +1,3 @@ +Mate=23 +Bier=42 +Cola=23 \ No newline at end of file diff --git a/test.c b/test.c new file mode 100644 index 0000000..f94b446 --- /dev/null +++ b/test.c @@ -0,0 +1,17 @@ +#include +#include +#include +#include + +#include "general.h" +#include "config.h" +#include "kasse.h" +#include "credit_manager.h" + +int main(){ + BYTE i=0; + load_items(); + load_state(); + for (; i < num_items; ++i) + printf("Eintrag %x: %s (%d Cents, %d mal verkauft)\n", i, status[i].item_name, status[i].price, status[i].times_sold); +} \ No newline at end of file -- 2.39.5