]> git.sur5r.net Git - c128-kasse/commitdiff
forgot files
authorsECuRE <sECuRE@af93e077-1a23-4f1e-9cbe-9382a9d578f5>
Sat, 28 Jul 2007 19:30:21 +0000 (19:30 +0000)
committersECuRE <sECuRE@af93e077-1a23-4f1e-9cbe-9382a9d578f5>
Sat, 28 Jul 2007 19:30:21 +0000 (19:30 +0000)
git-svn-id: https://shell.noname-ev.de/svn/kasse/c128@17 af93e077-1a23-4f1e-9cbe-9382a9d578f5

credit_manager.c [new file with mode: 0644]
credit_manager.h [new file with mode: 0644]
general.c [new file with mode: 0644]

diff --git a/credit_manager.c b/credit_manager.c
new file mode 100644 (file)
index 0000000..bce1f35
--- /dev/null
@@ -0,0 +1,37 @@
+#include <conio.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "config.h"
+#include "general.h"
+
+char *filter = NULL;
+
+void print_credit_screen() {
+       uc i = 0;
+       clrscr();
+       printf("C128-Kassenprogramm: Guthabenverwaltung\n\n");
+       for (; i < num_credit_items; ++i)
+               printf("Guthaben für %s: %d Cents\n", credits[i].nickname, credits[i].credit);
+       printf("\nBefehle: f) Filtern q) Back to main screen\n");
+}
+
+/* Guthabenverwalter */
+void credit_manager() {
+       uc c;
+       while (1) {
+               print_credit_screen();
+               c = getchar();
+               if (c == 'f') {
+                       printf("Filter eingeben:\n");
+                       if (filter != NULL)
+                               free(filter);
+                       filter = get_input();
+                       if (filter[0] == '0') {
+                               free(filter);
+                               filter = NULL;
+                       }
+               } else if (c == 'q')
+                       break;
+       }
+}
diff --git a/credit_manager.h b/credit_manager.h
new file mode 100644 (file)
index 0000000..0e718e4
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef CREDIT_MANAGER_H_
+#define CREDIT_MANAGER_H_
+void credit_manager();
+#endif
diff --git a/general.c b/general.c
new file mode 100644 (file)
index 0000000..345a6a9
--- /dev/null
+++ b/general.c
@@ -0,0 +1,25 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "general.h"
+
+char *get_input() {
+       uc i = 0;
+       char *output = malloc(32 * sizeof(char));
+       uc c;
+       if (output == NULL) {
+               perror("malloc()");
+               exit(1);
+       }
+       memset(output, '\0', 32);
+       while (1) {
+               if (i == 31)
+                       break;
+               c = getchar();
+               if (c == 13)
+                       break;
+               else output[i++] = c;
+       }
+       return output;
+}