More R_LIB_VERSION and initial r_asm_set_cpu() dummy api

This commit is contained in:
pancake 2013-06-15 02:56:25 +02:00
parent d47a0176cf
commit d6de30eba4
16 changed files with 58 additions and 12 deletions

View File

@ -24,18 +24,30 @@ static int verify_version(int show) {
const char *name;
vc callback;
} vcs[] = {
{ "r_cmd", &r_cmd_version },
{ "r_anal", &r_anal_version },
{ "r_lib", &r_lib_version },
{ "r_egg", &r_egg_version },
{ "r_asm", &r_asm_version },
{ "r_bin", &r_bin_version },
{ "r_cons", &r_cons_version },
{ "r_flags", &r_flag_version }, // XXX inconsistency
{ "r_core", &r_core_version },
{ "r_util", &r_util_version },
{ "r_debug", &r_debug_version },
{ "r_io", &r_io_version },
{ "r_fs", &r_fs_version },
{ "r_crypto", &r_crypto_version },
{ "r_asm", &r_asm_version },
{ "r_db", &r_db_version },
{ "r_bp", &r_bp_version },
{ "r_debug", &r_debug_version },
{ "r_hash", &r_hash_version },
{ "r_diff", &r_diff_version },
{ "r_fs", &r_fs_version },
{ "r_io", &r_io_version },
{ "r_magic", &r_magic_version },
{ "r_parse", &r_parse_version },
{ "r_reg", &r_reg_version },
{ "r_sign", &r_sign_version },
{ "r_search", &r_search_version },
{ "r_syscall", &r_syscall_version },
{ "r_util", &r_util_version },
/* ... */
{NULL,NULL}
};

View File

@ -131,6 +131,7 @@ R_API RAsm *r_asm_new() {
a->cur = NULL;
a->binb.bin = NULL;
a->bits = 32;
a->cpu = NULL;
a->big_endian = 0;
a->pc = 0;
a->ifilter = NULL;
@ -181,6 +182,7 @@ R_API int r_asm_filter_output(RAsm *a, const char *f) {
R_API void r_asm_free(RAsm *a) {
if (!a) return;
free (a->cpu);
// TODO: any memory leak here?
r_pair_free (a->pair);
a->pair = NULL;
@ -255,6 +257,11 @@ static int has_bits(RAsmPlugin *h, int bits) {
return R_FALSE;
}
R_API void r_asm_set_cpu(RAsm *a, const char *cpu) {
free (a->cpu);
a->cpu = strdup (cpu);
}
R_API int r_asm_set_bits(RAsm *a, int bits) {
if (has_bits (a->cur, bits)) {
a->bits = bits;

View File

@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2009-2013 - pancake, nibble */
/* radare - LGPL - Copyright 2009-2013 - pancake */
#include <stdio.h>
#include <stdarg.h>
@ -69,6 +69,8 @@ static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
/* TODO: set arch */
obj.arch = UT32_MAX;
obj.mach = UT32_MAX;
obj.arch = 0;
obj.mach = 0;
obj.buffer = bytes;
obj.read_memory_func = &arm_buffer_read_memory;

View File

@ -1,8 +1,10 @@
/* radare2 - LGPL - Copyright 2009-2011 pancake<nopcode.org> */
/* radare2 - LGPL - Copyright 2009-2013 - pancake */
#include <r_bp.h>
#include "../config.h"
R_LIB_VERSION (r_bp);
static struct r_bp_plugin_t *bp_static_plugins[] =
{ R_BP_STATIC_PLUGINS };

View File

@ -3,6 +3,8 @@
#include <r_cmd.h>
#include <r_util.h>
R_LIB_VERSION (r_cmd);
R_API void r_cmd_alias_init(RCmd *cmd) {
cmd->aliases.count = 0;
cmd->aliases.keys = NULL;

View File

@ -1,7 +1,8 @@
/* radare - LGPL - Copyright 2009-2011 pancake<nopcode.org> */
/* radare - LGPL - Copyright 2009-2013 - pancake */
#include "r_db.h"
R_LIB_VERSION (r_db);
#if 0
Configurable options:
- allow dupped nodes? (two times the same pointer?)

View File

@ -1,7 +1,9 @@
/* radare - LGPL - Copyright 2009-2010 pancake<nopcode.org> */
/* radare - LGPL - Copyright 2009-2013 - pancake */
#include <r_diff.h>
R_LIB_VERSION (r_diff);
R_API RDiff *r_diff_new(ut64 off_a, ut64 off_b) {
RDiff *d = R_NEW (RDiff);
if (d) {

View File

@ -1,8 +1,10 @@
/* radare - LGPL - Copyright 2011-2012 - pancake */
/* radare - LGPL - Copyright 2011-2013 - pancake */
#include <r_egg.h>
#include "../config.h"
R_LIB_VERSION (r_egg);
// TODO: must be plugins
extern REggEmit emit_x86;
extern REggEmit emit_x64;

View File

@ -5,6 +5,8 @@
#include <r_cons.h>
#include <stdio.h>
R_LIB_VERSION(r_flag);
R_API RFlag * r_flag_new() {
int i;
RFlag *f = R_NEW (RFlag);

View File

@ -2,6 +2,8 @@
#include "r_hash.h"
R_LIB_VERSION(r_hash);
/* returns 0-100 */
R_API int r_hash_pcprint(const ut8 *buffer, ut64 len) {
const ut8 *end = buffer + len;

View File

@ -78,13 +78,15 @@ typedef struct {
char *value;
} RAsmEqu;
#define _RAsmPlugin struct r_asm_plugin_t
typedef struct r_asm_t {
const char *cpu;
int bits;
int big_endian;
int syntax;
ut64 pc;
void *user;
struct r_asm_plugin_t *cur;
_RAsmPlugin *cur;
RList *plugins;
RBinBind binb;
RParse *ifilter;

View File

@ -8,6 +8,7 @@
#include "r_io.h"
#include "r_fs.h"
#include "r_lib.h"
#include "r_diff.h"
#include "r_egg.h"
#include "r_lang.h"
#include "r_asm.h"

View File

@ -6,6 +6,8 @@
#include <stdio.h>
#include <dirent.h>
R_LIB_VERSION(r_lib);
/* TODO: support for nested plugins ?? here */
#if __UNIX__

View File

@ -29,6 +29,9 @@
*/
#include <r_userconf.h>
#include <r_types.h>
R_LIB_VERSION (r_magic);
#if USE_LIB_MAGIC
#include <magic.h>

View File

@ -4,6 +4,8 @@
#include <r_list.h>
#include <ctype.h>
R_LIB_VERSION (r_search);
R_API RSearch *r_search_new(int mode) {
RSearch *s = R_NEW0 (RSearch);
if (!s) return NULL;

View File

@ -1,8 +1,10 @@
/* radare - LGPL - Copyright 2009-2010 pancake<nopcode.org> */
/* radare - LGPL - Copyright 2009-2013 - pancake */
#include <r_sign.h>
#include <r_anal.h>
R_LIB_VERSION (r_sign);
R_API RSign *r_sign_new() {
RSign *sig = R_NEW (RSign);
if (sig) {