2 #include <readline/readline.h>
3 #include <readline/history.h>
10 getline(char *buf,int *num,int max_num)
12 static int line_len = 0;
13 static char *line = NULL;
14 static char *line_pointer = NULL;
20 buff = readline(PROMPT);
23 if ((tmp_len = strlen(buff)) > line_len) {
25 line = malloc(tmp_len);
28 sprintf(line,"%s\n",buff);
34 *num = max_num > len? len : max_num;
35 strncpy(buf,line_pointer,*num);
36 line_pointer = line_pointer + *num;