- char *input, *name;
- int price;
-
- if (status.num_items == MAX_ITEMS) {
- cprintf("\rEs ist bereits die maximale Anzahl an Eintraegen erreicht, druecke RETURN...\r\n");
- input = get_input();
- return;
- }
-
- cprintf("\rName des Eintrags:\r\n");
- if ((input = get_input()) == NULL || *input == '\0')
- return;
- name = strdup(input);
- cprintf("\r\nPreis in Cents:\r\n");
- if ((input = get_input()) == NULL || *input == '\0' || (price = atoi(input)) == 0)
- return;
- cprintf("\r\nWie oft schon verkauft? [0] \r\n");
- if ((input = get_input()) == NULL)
- return;
- memset(status.status[status.num_items].item_name, '\0', MAX_ITEM_NAME_LENGTH+1);
- strncpy(status.status[status.num_items].item_name, name, MAX_ITEM_NAME_LENGTH);
- status.status[status.num_items].price = price;
- status.status[status.num_items].times_sold = atoi(input);
- status.num_items++;
- free(name);
+ char name[MAX_ITEM_NAME_LENGTH + 1];
+ int price, times_sold;
+
+ if (status.num_items == MAX_ITEMS) {
+ cprintf("\rEs ist bereits die maximale Anzahl an Eintr" aUML
+ "gen erreicht, dr" uUML "cke RETURN...\r\n");
+ cget_return();
+ return;
+ }
+
+ cprintf("\rName des Eintrags:\r\n");
+ if (cgetn_input(name, sizeof(name)) == 0)
+ return;
+ cprintf("\r\nPreis in Cents:\r\n");
+ if ((price = cget_number(0)) <= 0)
+ return;
+ cprintf("\r\nWie oft schon verkauft? [0] \r\n");
+ if ((times_sold = cget_number(0)) < 0)
+ return;
+ memset(status.status[status.num_items].item_name, '\0',
+ MAX_ITEM_NAME_LENGTH + 1);
+ strncpy(status.status[status.num_items].item_name, name,
+ MAX_ITEM_NAME_LENGTH);
+ status.status[status.num_items].price = price;
+ status.status[status.num_items].times_sold = times_sold;
+ status.num_items++;