2 * RGB2R-C128-Kassenprogramm
3 * © 2007-2009 phil_fry, sECuRE, sur5r
4 * See LICENSE for license information
15 * get_input_terminated_by() reads input (handling backspace correctly) until
16 * a terminator of |terminators| is encountered or |out| is full (outlen-1
17 * characters were read).
19 * get_input_terminated_by() returns the terminator it encountered.
22 input_terminator_t get_input_terminated_by(input_terminator_mask_t terminators, char *out, BYTE outlen) {
29 if (((terminators & INPUT_TERMINATOR_RETURN) == INPUT_TERMINATOR_RETURN) && (c == PETSCII_CR)) {
30 return INPUT_TERMINATOR_RETURN;
31 } else if (((terminators & INPUT_TERMINATOR_SPACE) == INPUT_TERMINATOR_SPACE) && (c == PETSCII_SP)) {
32 return INPUT_TERMINATOR_SPACE;
33 } else if (c == PETSCII_DEL) {
34 /* If you are at the left-most position, do nothing */
42 if (i == (outlen-1)) {
51 * Liest (maximal 31) Zeichen ein, bis Enter gedrückt wird.
52 * Vorsicht: Es wird ein statischer Buffer benutzt, sodass man
53 * das Ergebnis via strdup() retten muss, bevor man get_input()
57 char *get_input(void) {
58 static char output[32];
59 memset(output, '\0', sizeof(output));
60 get_input_terminated_by(INPUT_TERMINATOR_RETURN, output, sizeof(output));
64 char retry_or_quit(void) {
67 cprintf("\r\nr)etry or q)uit?\r\n");
69 } while ((*c != 'r') && (*c != 'q'));
73 char *format_euro(char *s, int maxlen, int cent){
75 int len = strlen(",EUR");
76 while ((tmp /= 10) > 0)
80 // workaround to produce a leading zero for cents.. %0.2d won't work
81 sprintf(s, "%3d,%s%dEUR", cent / 100, ((cent%100)<10?"0":""), cent % 100);
85 void c128_perror(BYTE c, char *msg) {
86 cprintf("\r\nError (Code %d) while: %s\r\nOS Error = %d\r\n", c, msg, _oserror);