From: matze Date: Fri, 26 Oct 2007 23:15:02 +0000 (+0000) Subject: allow the user to retry or quit, when printing fails X-Git-Tag: rgb2rv6~38 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a0b9ff6838cd92fdfb551ef3a09fcbada5eafbf0;p=c128-kasse allow the user to retry or quit, when printing fails git-svn-id: https://shell.noname-ev.de/svn/kasse/c128@71 af93e077-1a23-4f1e-9cbe-9382a9d578f5 --- diff --git a/src/kasse.c b/src/kasse.c index ba28886..8c02cef 100644 --- a/src/kasse.c +++ b/src/kasse.c @@ -60,6 +60,15 @@ static void log_file(const char *s) { cbm_close((BYTE)8); } +static char retry_or_quit() { + char *c; + do { + cprintf("\r\nr)etry or q)uit?\r\n"); + c = get_input(); + } while ((*c != 'r') && (*c != 'q')); + return *c; +} + /* Druckt eine entsprechende Zeile aus */ static void print_log(BYTE n, int einheiten, char *nickname) { BYTE c; @@ -78,22 +87,29 @@ static void print_log(BYTE n, int einheiten, char *nickname) { exit(1); } + RETRY:; sprintf(print_buffer, "[%lu] %s - %s - %s - %d - an %s\r\n", - items_sold, time, status.status[n].item_name, price, - einheiten, (nickname != NULL ? nickname : "Unbekannt")); + items_sold, time, status.status[n].item_name, price, + einheiten, (nickname != NULL ? nickname : "Unbekannt")); c = cbm_open((BYTE)4, (BYTE)4, (BYTE)0, NULL); if (c != 0) { c128_perror(c, "cbm_open(printer)"); - save_items(); - save_credits(); - exit(1); + if (retry_or_quit() == 'q') { + save_items(); + save_credits(); + exit(1); + } + goto RETRY; } c = cbm_write((BYTE)4, print_buffer, strlen(print_buffer)); if (c != strlen(print_buffer)) { c128_perror(c, "write(printer)"); - save_items(); - save_credits(); - exit(1); + if (retry_or_quit() == 'q') { + save_items(); + save_credits(); + exit(1); + } + goto RETRY; } cbm_close((BYTE)4); log_file(print_buffer);