]> git.ipfire.org Git - people/ms/u-boot.git/blob - board/MAI/bios_emulator/scitech/src/v86bios/command.c
* Code cleanup:
[people/ms/u-boot.git] / board / MAI / bios_emulator / scitech / src / v86bios / command.c
1 #include <stdio.h>
2 #include <readline/readline.h>
3 #include <readline/history.h>
4 #include <malloc.h>
5
6 #define PROMPT ">"
7
8
9 void
10 getline(char *buf,int *num,int max_num)
11 {
12 static int line_len = 0;
13 static char *line = NULL;
14 static char *line_pointer = NULL;
15 static int len = 0;
16 int tmp_len;
17 char *buff;
18
19 if (len <= 0) {
20 buff = readline(PROMPT);
21 add_history(buff);
22
23 if ((tmp_len = strlen(buff)) > line_len) {
24 free(line);
25 line = malloc(tmp_len);
26 line_len = tmp_len;
27 }
28 sprintf(line,"%s\n",buff);
29 free(buff);
30 line_pointer = line;
31 len = strlen(line);
32 }
33
34 *num = max_num > len? len : max_num;
35 strncpy(buf,line_pointer,*num);
36 line_pointer = line_pointer + *num;
37 len = len - *num;
38 }