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,
23 char *out, BYTE outlen) {
30 if (((terminators & INPUT_TERMINATOR_RETURN) == INPUT_TERMINATOR_RETURN) &&
32 return INPUT_TERMINATOR_RETURN;
33 } else if (((terminators & INPUT_TERMINATOR_SPACE) ==
34 INPUT_TERMINATOR_SPACE) &&
36 return INPUT_TERMINATOR_SPACE;
37 } else if (c == PETSCII_DEL) {
38 /* If you are at the left-most position, do nothing */
42 cputcxy(x + i, y, ' ');
46 if (i == (outlen - 1)) {
55 * Liest (maximal 31) Zeichen ein, bis Enter gedrückt wird.
56 * Vorsicht: Es wird ein statischer Buffer benutzt, sodass man
57 * das Ergebnis via strdup() retten muss, bevor man get_input()
61 char *get_input(void) {
62 static char output[32];
63 memset(output, '\0', sizeof(output));
64 get_input_terminated_by(INPUT_TERMINATOR_RETURN, output, sizeof(output));
68 char retry_or_quit(void) {
71 cprintf("\r\nr)etry or q)uit?\r\n");
73 } while ((*c != 'r') && (*c != 'q'));
77 char *format_euro(char *s, int maxlen, int cent) {
78 if(snprintf(s,maxlen,"%3d,%02dEUR", cent/100, cent%100) > maxlen)
83 void c128_perror(BYTE c, char *msg) {
84 cprintf("\r\nError (Code %d) while: %s\r\nOS Error = %d\r\n", c, msg,