From 4c9ae396d13939b8f20025bc91e538ecd3ff1906 Mon Sep 17 00:00:00 2001 From: matze Date: Thu, 25 Oct 2007 15:11:41 +0000 Subject: [PATCH] put filter back in again. implemented a deposit function which crashes the program... git-svn-id: https://shell.noname-ev.de/svn/kasse/c128@62 af93e077-1a23-4f1e-9cbe-9382a9d578f5 --- src/credit_manager.c | 64 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 58 insertions(+), 6 deletions(-) diff --git a/src/credit_manager.c b/src/credit_manager.c index 6fa39d5..35ea372 100644 --- a/src/credit_manager.c +++ b/src/credit_manager.c @@ -29,16 +29,60 @@ static void credit_print_screen() { current_credits_page = pages; cprintf("Datei: CREDITS (Seite %d von %d)\r\n\r\n", current_credits_page, pages); for (i = (current_credits_page * 16); i < credits.num_items && i < ((current_credits_page+1) * 16); i++) { - if (format_euro(buffer, 10, credits.credits[i].credit) != buffer) { - cprintf("Error: Could not format credit %d\r\n", credits.credits[i].credit); - exit(1); + if (filter == NULL || strncmp(credits.credits[i].nickname, filter, filter_len) == 0) { + if (format_euro(buffer, 10, credits.credits[i].credit) != buffer) { + cprintf("Error: Could not format credit %d\r\n", credits.credits[i].credit); + exit(1); + } + + cprintf("%d: %s: %s\r\n", i, credits.credits[i].nickname, buffer); } - - cprintf("%d: %s: %s\r\n", i, credits.credits[i].nickname, buffer); } - cprintf("\r\nn) Neu d) Loeschen b) Seite hoch f) Seite runter\r\ne) Aendern s) Speichern z) Zurueck\r\n"); + cprintf("\r\nn) Neu d) Loeschen p) Einzahlen b) Seite hoch f) Seite runter\r\ng) Filtern e) Aendern s) Speichern z) Zurueck\r\n"); } +static struct credits_t * find_credit(char * name){ + int i; + for (i=0;icredit += deposit; + + toggle_videomode(); + cprintf("%d Cent eingezahlt fuer %s. Restguthaben: %d\r\n", deposit, credit->nickname, credit->credit); + sleep(1); + clrscr(); + toggle_videomode(); +} static void new_credit() { char *input, *name; @@ -109,6 +153,14 @@ void credit_manager(){ if (current_credits_page > 0) current_credits_page--; break; + case 'p': + deposit_credit(); break; + case 'g': + cprintf("Filter eingeben:\r\n"); + filter = get_input(); + if (filter == NULL || *filter == 32 || (filter_len = strlen(filter)) == 0) + filter = NULL; + break; case 'z': return; default: -- 2.39.5