forked from radareorg/radare2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathline.c
44 lines (35 loc) · 878 Bytes
/
line.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* radare - LGPL - Copyright 2007-2013 - pancake */
#include <r_cons.h>
static RLine r_line_instance;
#define I r_line_instance
/* definitions to be removed */
int r_line_dietline_init();
void r_line_hist_free();
R_API RLine *r_line_singleton () {
return &r_line_instance;
}
R_API RLine *r_line_new () {
I.hist_up = NULL;
I.hist_down = NULL;
I.prompt = strdup ("> ");
I.contents = NULL;
if (!r_line_dietline_init ())
eprintf ("error: r_line_dietline_init\n");
return &I;
}
R_API void r_line_free () {
// XXX: prompt out of the heap?
free ((void*)I.prompt);
I.prompt = NULL;
r_line_hist_free ();
}
// handle const or dynamic prompts?
R_API void r_line_set_prompt (const char *prompt) {
free (I.prompt);
I.prompt = strdup (prompt);
}
// handle const or dynamic prompts?
R_API char *r_line_get_prompt () {
return strdup (I.prompt);
}
#include "dietline.c"