-/*
- * Deposits credit for a user. Called in the credit manager (with input ==
- * NULL) or interactively when the user does not have enough money for his
- * intended purchase (with input == nickname).
- *
- */
-void deposit_credit(char *input) {
- char *time = get_time();
- struct credits_t *credit;
- unsigned int deposit;
-
- if (input == NULL) {
- cprintf("\r\nName:\r\n");
- if ((input = get_input()) == NULL || *input == '\0')
- return; // no name given
- }
-
- if ((credit = find_credit(input)) == NULL)
- return; // cannot find named credit
-
- cprintf("\r\nEinzahlung in Cent:\r\n");
- if ((input = get_input()) == NULL || *input == '\0' || (deposit = atoi(input)) == 0)
- return;
-
- credit->credit += deposit;
-
- toggle_videomode();
- cprintf("%d Cent eingezahlt fuer %s.\r\nRestguthaben: %d\r\n", deposit, credit->nickname, credit->credit);
- sprintf(print_buffer, "%c%s - %d Cent eingezahlt fuer %s. Restguthaben: %d Cent\r", 17, time, deposit, credit->nickname, credit->credit);
- cprintf("%s", print_buffer);
- toggle_videomode();
- print_the_buffer();
- cprintf("\r\nEinzahlung durchgefuehrt, druecke RETURN...\r\n");
- input = get_input();
- toggle_videomode();
- clrscr();
- toggle_videomode();
+static int8_t find_credit_idx(char *name) {
+ int8_t i;
+ for (i = 0; i < credits.num_items; ++i) {
+ if (strncasecmp(name, credits.credits[i].nickname, NICKNAME_MAX_LEN + 1) ==
+ 0) {
+ return i;
+ }
+ }
+ return -1;