mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-24 13:49:50 +00:00
* Some work to standarize r_cmd (R_API and _new)
* Move empty strsub.c to util/ * r_flags depends on r_cons (yeah, it shouldnt..) - just for tmp fun * Fix some methods and declarations in r_bp and r_core vapis --HG-- rename : libr/cons/strsub.c => libr/util/strsub.c
This commit is contained in:
parent
54bdfb22bd
commit
368aeaf974
@ -3,13 +3,29 @@
|
||||
#include <r_cmd.h>
|
||||
#include <r_util.h>
|
||||
|
||||
int r_cmd_set_data(struct r_cmd_t *cmd, void *data)
|
||||
R_API RCommand *r_cmd_init(struct r_cmd_t *cmd)
|
||||
{
|
||||
int i;
|
||||
if (cmd) {
|
||||
INIT_LIST_HEAD(&cmd->lcmds);
|
||||
for(i=0;i<255;i++)
|
||||
cmd->cmds[i] = NULL;
|
||||
cmd->data = NULL;
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
|
||||
R_API RCommand *r_cmd_new () {
|
||||
return r_cmd_init (MALLOC_STRUCT (RCommand));
|
||||
}
|
||||
|
||||
R_API int r_cmd_set_data(struct r_cmd_t *cmd, void *data)
|
||||
{
|
||||
cmd->data = data;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int r_cmd_add_long(struct r_cmd_t *cmd, const char *longcmd, const char *shortcmd, const char *desc)
|
||||
R_API int r_cmd_add_long(struct r_cmd_t *cmd, const char *longcmd, const char *shortcmd, const char *desc)
|
||||
{
|
||||
struct r_cmd_long_item_t *item;
|
||||
item = MALLOC_STRUCT(struct r_cmd_long_item_t);
|
||||
@ -23,7 +39,7 @@ int r_cmd_add_long(struct r_cmd_t *cmd, const char *longcmd, const char *shortcm
|
||||
return 1;
|
||||
}
|
||||
|
||||
int r_cmd_add(struct r_cmd_t *cmd, const char *command, const char *description, r_cmd_callback(callback))
|
||||
R_API int r_cmd_add(struct r_cmd_t *cmd, const char *command, const char *description, r_cmd_callback(callback))
|
||||
{
|
||||
struct r_cmd_item_t *item;
|
||||
int idx = (ut8)command[0];
|
||||
@ -39,7 +55,7 @@ int r_cmd_add(struct r_cmd_t *cmd, const char *command, const char *description,
|
||||
return 1;
|
||||
}
|
||||
|
||||
int r_cmd_del(struct r_cmd_t *cmd, const char *command)
|
||||
R_API int r_cmd_del(struct r_cmd_t *cmd, const char *command)
|
||||
{
|
||||
int idx = (ut8)command[0];
|
||||
free(cmd->cmds[idx]);
|
||||
@ -47,7 +63,7 @@ int r_cmd_del(struct r_cmd_t *cmd, const char *command)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int r_cmd_call(struct r_cmd_t *cmd, const char *input)
|
||||
R_API int r_cmd_call(struct r_cmd_t *cmd, const char *input)
|
||||
{
|
||||
struct r_cmd_item_t *c;
|
||||
int ret = -1;
|
||||
@ -63,7 +79,7 @@ int r_cmd_call(struct r_cmd_t *cmd, const char *input)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int r_cmd_call_long(struct r_cmd_t *cmd, const char *input)
|
||||
R_API int r_cmd_call_long(struct r_cmd_t *cmd, const char *input)
|
||||
{
|
||||
char *inp;
|
||||
struct list_head *pos;
|
||||
@ -81,16 +97,7 @@ int r_cmd_call_long(struct r_cmd_t *cmd, const char *input)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int r_cmd_init(struct r_cmd_t *cmd)
|
||||
{
|
||||
int i;
|
||||
INIT_LIST_HEAD(&cmd->lcmds);
|
||||
for(i=0;i<255;i++)
|
||||
cmd->cmds[i] = NULL;
|
||||
cmd->data = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
// XXX: make it work :P
|
||||
static char *argv[]= { "foo", "bar", "cow", "muu" };
|
||||
char **r_cmd_args(struct r_cmd_t *cmd, int *argc)
|
||||
@ -99,3 +106,4 @@ char **r_cmd_args(struct r_cmd_t *cmd, int *argc)
|
||||
//argv = argv_test;
|
||||
return argv;
|
||||
}
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
NAME=r_cons
|
||||
OBJ=cons.o strsub.o pipe.o print.o input.o color.o
|
||||
OBJ=cons.o pipe.o print.o input.o color.o
|
||||
DEPS=r_util
|
||||
#r_line ??
|
||||
#LINK=../line/*.o ../util/*.a
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2008-2009 pancake<nopcode.org> */
|
||||
/* radare - LGPL - Copyright 2008-2010 pancake<nopcode.org> */
|
||||
|
||||
#include <r_cons.h>
|
||||
|
||||
@ -25,8 +25,8 @@
|
||||
|
||||
#define MOAR_VALUE 4096*4
|
||||
|
||||
// WTF //
|
||||
char *strsub (char *string, char *pat, char *rep, int global);
|
||||
RCons r_cons;
|
||||
|
||||
int r_cons_stdout_fd = 1;
|
||||
FILE *r_cons_stdin_fd = NULL; // TODO use int fd here too!
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
NAME=r_flags
|
||||
DEPS=r_util
|
||||
DEPS=r_util r_cons
|
||||
|
||||
OBJ=flags.o name.o spaces.o
|
||||
|
||||
|
@ -64,9 +64,9 @@ R_API struct r_flag_item_t *r_flag_list(struct r_flag_t *f, int rad)
|
||||
struct list_head *pos;
|
||||
list_for_each_prev(pos, &f->flags) {
|
||||
struct r_flag_item_t *flag = list_entry(pos, struct r_flag_item_t, list);
|
||||
if (rad) printf("f %s %lld @ 0x%08llx\n",
|
||||
if (rad) r_cons_printf("f %s %lld @ 0x%08llx\n",
|
||||
flag->name, flag->size, flag->offset);
|
||||
else printf("0x%08llx %lld %s\n",
|
||||
else r_cons_printf("0x%08llx %lld %s\n",
|
||||
flag->offset, flag->size, flag->name);
|
||||
}
|
||||
return NULL;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2008-2009 pancake<nopcode.org> */
|
||||
/* radare - LGPL - Copyright 2008-2010 pancake<nopcode.org> */
|
||||
|
||||
#include <r_flags.h>
|
||||
|
||||
|
@ -5,7 +5,7 @@ include ../../config.mk
|
||||
all: test${EXT_EXE}
|
||||
|
||||
test${EXT_EXE}:
|
||||
${CC} -g -I ../../include test.c ../*.o -lr_util -L../../util -o test${EXT_EXE}
|
||||
${CC} -g -I ../../include test.c ../*.o -lr_util -L../../util -L../../cons -lr_cons -o test${EXT_EXE}
|
||||
|
||||
clean:
|
||||
rm -f test
|
||||
|
@ -24,5 +24,7 @@ int main()
|
||||
printf("FLAG FOUND '%s'\n", fi->name);
|
||||
} else printf("FLAG NOT FOUND\n");
|
||||
|
||||
r_flag_list (&flags, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -29,7 +29,8 @@ typedef struct r_cmd_t {
|
||||
} RCommand;
|
||||
|
||||
#ifdef R_API
|
||||
R_API int r_cmd_init(struct r_cmd_t *cmd);
|
||||
R_API RCommand *r_cmd_new();
|
||||
R_API RCommand * r_cmd_init(struct r_cmd_t *cmd);
|
||||
R_API int r_cmd_set_data(struct r_cmd_t *cmd, void *data);
|
||||
R_API int r_cmd_add(struct r_cmd_t *cmd, const char *command, const char *desc, r_cmd_callback(callback));
|
||||
R_API int r_cmd_add_long(struct r_cmd_t *cmd, const char *longcmd, const char *shortcmd, const char *desc);
|
||||
|
@ -10,6 +10,15 @@
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
typedef struct r_cons_t {
|
||||
int r_cons_is_interactive;
|
||||
int r_cons_is_html;
|
||||
int r_cons_rows;
|
||||
int r_cons_columns;
|
||||
int r_cons_lines;
|
||||
int r_cons_noflush;
|
||||
} RCons;
|
||||
|
||||
#define CONS_MAX_USER 102400
|
||||
#define CONS_BUFSZ 0x4f00
|
||||
#define STR_IS_NULL(x) (!x || !x[0])
|
||||
@ -77,15 +86,15 @@ enum {
|
||||
#endif
|
||||
|
||||
/* XXX : global variables? or a struct with a singleton? */
|
||||
extern FILE *stdin_fd;
|
||||
//extern FILE *stdin_fd;
|
||||
extern FILE *r_cons_stdin_fd;
|
||||
extern int r_cons_stdout_fd;
|
||||
extern int r_cons_stdout_file;
|
||||
//extern int r_cons_stdout_file;
|
||||
extern int r_cons_breaked;
|
||||
extern const char *r_cons_palette_default;
|
||||
const char *r_cons_colors[CONS_COLORS_SIZE+1];
|
||||
extern char r_cons_palette[CONS_PALETTE_SIZE][8];
|
||||
extern const char *dl_prompt;
|
||||
//extern const char *dl_prompt;
|
||||
extern int r_cons_columns;
|
||||
extern int r_cons_rows;
|
||||
extern int r_cons_lines; // private or public?
|
||||
|
@ -12,7 +12,6 @@
|
||||
extern int r_line_echo;
|
||||
extern const char *r_line_prompt;
|
||||
extern const char *r_line_clipboard;
|
||||
extern void r_line_label_show();
|
||||
|
||||
extern char **r_line_history;
|
||||
extern int r_line_histsize;
|
||||
@ -32,6 +31,7 @@ R_API int r_line_init();
|
||||
R_API int r_line_hist_load(const char *file);
|
||||
R_API char *r_line_readline(int argc, const char **argv);
|
||||
R_API //extern int r_line_readchar();
|
||||
/* label ?! */
|
||||
R_API int r_line_hist_add(const char *line);
|
||||
R_API int r_line_hist_save(const char *file);
|
||||
R_API int r_line_hist_label(const char *label, void (*cb)(const char*));
|
||||
|
@ -2,6 +2,8 @@ r_asm
|
||||
r_hash
|
||||
r_config
|
||||
r_core
|
||||
r_line
|
||||
r_cons
|
||||
r_search
|
||||
r_diff
|
||||
r_io
|
||||
|
@ -6,9 +6,9 @@ public class Radare.RBreakpoint {
|
||||
public RBreakpoint ();
|
||||
public bool use (string arch);
|
||||
public void enable (uint64 addr, bool enabled);
|
||||
public bool at_addr (uint64 addr, int rwx);
|
||||
public Item add_sw (uint64 addr, int len, int rwx);
|
||||
public Item add_hw (uint64 addr, int len, int rwx);
|
||||
public unowned Item? at_addr (uint64 addr, int rwx);
|
||||
public unowned Item add_sw (uint64 addr, int len, int rwx);
|
||||
public unowned Item add_hw (uint64 addr, int len, int rwx);
|
||||
public bool add_fault (uint64 addr, int len, int rwx);
|
||||
public int add_cond (string cond);
|
||||
public bool del (uint64 addr);
|
||||
|
@ -23,7 +23,8 @@ namespace Radare {
|
||||
//public static int fgets(out string buf, int len, int argc, string argv[]);
|
||||
public static int readchar();
|
||||
public static void any_key();
|
||||
public static int get_columns();
|
||||
public static int get_real_columns();
|
||||
public static int get_size(out int rows);
|
||||
//public static int get_columns();
|
||||
//public static int get_real_columns();
|
||||
}
|
||||
}
|
||||
|
@ -1,42 +1,43 @@
|
||||
/* radare - LGPL - Copyright 2009 pancake<nopcode.org> */
|
||||
|
||||
namespace Radare {
|
||||
[Compact]
|
||||
[CCode (cheader_filename="r_core.h", cname="struct r_core_t", free_function="r_core_free", cprefix="r_core_")]
|
||||
public class Radare.RCore {
|
||||
/* lifecycle */
|
||||
public RCore();
|
||||
|
||||
public bool loadlibs();
|
||||
/* commands */
|
||||
public int prompt();
|
||||
public int cmd(string cmd, bool log);
|
||||
public int cmd0(string cmd);
|
||||
public int cmd_file(string file);
|
||||
public unowned string cmd_str(string cmd);
|
||||
|
||||
/* io */
|
||||
public int read_at(uint64 addr, out uint8 *buf, int size);
|
||||
public int write_at(uint64 addr, uint8 *buf, int size);
|
||||
public int block_read(bool next);
|
||||
public int seek(uint64 addr, bool rb);
|
||||
|
||||
/* files */
|
||||
public File file_open(string file, int mode);
|
||||
|
||||
// XXX mode = Radare.Io.Mode
|
||||
[Compact]
|
||||
[CCode (cheader_filename="r_core.h", cname="struct r_core_t", free_function="r_core_free", cprefix="r_core_")]
|
||||
public class RCore {
|
||||
/* lifecycle */
|
||||
public RCore();
|
||||
|
||||
/* commands */
|
||||
public int prompt();
|
||||
public int cmd(string cmd, bool log);
|
||||
public int cmd0(string cmd);
|
||||
public int cmd_file(string file);
|
||||
public unowned string cmd_str(string cmd);
|
||||
|
||||
/* io */
|
||||
public int read_at(uint64 addr, out uint8 *buf, int size);
|
||||
public int write_at(uint64 addr, uint8 *buf, int size);
|
||||
public int block_read(bool next);
|
||||
public int seek(uint64 addr, bool rb);
|
||||
|
||||
/* files */
|
||||
public RCore.File file_open(string file, int mode);
|
||||
|
||||
// XXX mode = Radare.Io.Mode
|
||||
[Compact]
|
||||
[CCode (cname="struct r_core_file_t", cprefix="r_core_")]
|
||||
public class File {
|
||||
//public static bool set(string file, Core.File file);
|
||||
//public static bool close(string file, Core.File file);
|
||||
public static bool close_fd(string file, int fd);
|
||||
/* attributes */
|
||||
public string uri;
|
||||
public string filename;
|
||||
public uint64 offset;
|
||||
public uint64 size;
|
||||
public int rwx;
|
||||
public int fd;
|
||||
}
|
||||
[CCode (cname="struct r_core_file_t", cprefix="r_core_file_")]
|
||||
public class File {
|
||||
//public static bool set(string file, Core.File file);
|
||||
//public static bool close(string file, Core.File file);
|
||||
public static bool close_fd(string file, int fd);
|
||||
/* attributes */
|
||||
public string uri;
|
||||
public string filename;
|
||||
public uint64 offset;
|
||||
public uint64 size;
|
||||
public int rwx;
|
||||
public int fd;
|
||||
}
|
||||
|
||||
public File file;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user