From 6a58176b306f633c4c37a5897670247ca1533865 Mon Sep 17 00:00:00 2001 From: sECuRE Date: Sat, 28 Jul 2007 19:30:21 +0000 Subject: [PATCH] forgot files git-svn-id: https://shell.noname-ev.de/svn/kasse/c128@17 af93e077-1a23-4f1e-9cbe-9382a9d578f5 --- credit_manager.c | 37 +++++++++++++++++++++++++++++++++++++ credit_manager.h | 4 ++++ general.c | 25 +++++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 credit_manager.c create mode 100644 credit_manager.h create mode 100644 general.c diff --git a/credit_manager.c b/credit_manager.c new file mode 100644 index 0000000..bce1f35 --- /dev/null +++ b/credit_manager.c @@ -0,0 +1,37 @@ +#include +#include +#include + +#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 index 0000000..0e718e4 --- /dev/null +++ b/credit_manager.h @@ -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 index 0000000..345a6a9 --- /dev/null +++ b/general.c @@ -0,0 +1,25 @@ +#include +#include +#include + +#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; +} -- 2.39.5