]> git.sur5r.net Git - c128-kasse/commitdiff
items und state laden geht, demodaten in dateien state und items
authormatze <matze@af93e077-1a23-4f1e-9cbe-9382a9d578f5>
Sat, 28 Jul 2007 22:50:47 +0000 (22:50 +0000)
committermatze <matze@af93e077-1a23-4f1e-9cbe-9382a9d578f5>
Sat, 28 Jul 2007 22:50:47 +0000 (22:50 +0000)
git-svn-id: https://shell.noname-ev.de/svn/kasse/c128@33 af93e077-1a23-4f1e-9cbe-9382a9d578f5

config.c
items [new file with mode: 0644]
state [new file with mode: 0644]
test.c [new file with mode: 0644]

index 19c375d0a63b67fdbeb496583e0396d7369792b4..2488bfd790a4df95b9a78080391ccc6d535d4017 100644 (file)
--- 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 (file)
index 0000000..ecbe32d
--- /dev/null
+++ b/items
@@ -0,0 +1,3 @@
+Mate=100\r
+Bier=120\r
+Cola=100
\ No newline at end of file
diff --git a/state b/state
new file mode 100644 (file)
index 0000000..a3a26f1
--- /dev/null
+++ b/state
@@ -0,0 +1,3 @@
+Mate=23\r
+Bier=42\r
+Cola=23
\ No newline at end of file
diff --git a/test.c b/test.c
new file mode 100644 (file)
index 0000000..f94b446
--- /dev/null
+++ b/test.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <conio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#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