Skip to content

Commit

Permalink
radareorg#3052 all printf member functions changed to cb_printf
Browse files Browse the repository at this point in the history
  • Loading branch information
shua authored and radare committed Aug 9, 2015
1 parent de072e7 commit 0807686
Show file tree
Hide file tree
Showing 64 changed files with 628 additions and 628 deletions.
2 changes: 1 addition & 1 deletion binr/rabin2/rabin2.c
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ int main(int argc, char **argv) {
}
r_config_set_i (core.config, "bin.laddr", laddr);
core.bin = bin;
bin->printf = r_cons_printf;
bin->cb_printf = r_cons_printf;
filter.offset = at;
filter.name = name;
r_cons_new ()->is_interactive = R_FALSE;
Expand Down
4 changes: 2 additions & 2 deletions libr/anal/anal.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ R_API RAnal *r_anal_new() {
//anal->sdb_ret = sdb_ns (anal->sdb, "ret", 1);
//anal->sdb_locals = sdb_ns (anal->sdb, "locals", 1);
anal->sdb_types = sdb_ns (anal->sdb, "types", 1);
anal->printf = (PrintfCallback) printf;
anal->cb_printf = (PrintfCallback) printf;
r_anal_pin_init (anal);
r_anal_type_init (anal);
r_anal_xrefs_init (anal);
Expand Down Expand Up @@ -189,7 +189,7 @@ R_API int r_anal_list(RAnal *anal) {
RAnalPlugin *h;
RListIter *it;
r_list_foreach (anal->plugins, it, h) {
anal->printf ("anal %-10s %s\n", h->name, h->desc);
anal->cb_printf ("anal %-10s %s\n", h->name, h->desc);
}
return R_FALSE;
}
Expand Down
2 changes: 1 addition & 1 deletion libr/anal/esil.c
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ R_API int r_anal_esil_dumpstack (RAnalEsil *esil) {
return 0;
//eprintf ("StackDump:\n");
for (i=esil->stackptr-1; i>=0; i--) {
esil->anal->printf ("%s\n", esil->stack[i]);
esil->anal->cb_printf ("%s\n", esil->stack[i]);
}
return 1;
}
Expand Down
12 changes: 6 additions & 6 deletions libr/anal/esil2reil.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,26 +128,26 @@ void reil_print_inst(RAnalEsil *esil, RAnalReilInst *ins) {

if ((!ins) || (!esil)) return;

esil->anal->printf("%04"PFMT64x".%02"PFMT64x": %8s",
esil->anal->cb_printf("%04"PFMT64x".%02"PFMT64x": %8s",
esil->Reil->addr,
esil->Reil->seq_num++,
ops[ins->opcode]);
for (i = 0; i < 3; i++) {
if (i != 0)
esil->anal->printf (" ,");
esil->anal->cb_printf (" ,");
if (ins->arg[i]->type == ARG_NONE) {
esil->anal->printf ("%10s ", ins->arg[i]->name);
esil->anal->cb_printf ("%10s ", ins->arg[i]->name);
continue;
}
if (ins->arg[i]->type == ARG_REG) {
strncpy (tmp_buf, REIL_REG_PREFIX, sizeof(tmp_buf) - 1);
strncat (tmp_buf, ins->arg[i]->name, sizeof(tmp_buf) - strlen(tmp_buf) - 1);
esil->anal->printf ("%10s:%02d", tmp_buf, ins->arg[i]->size);
esil->anal->cb_printf ("%10s:%02d", tmp_buf, ins->arg[i]->size);
continue;
}
esil->anal->printf ("%10s:%02d", ins->arg[i]->name, ins->arg[i]->size);
esil->anal->cb_printf ("%10s:%02d", ins->arg[i]->name, ins->arg[i]->size);
}
esil->anal->printf("\n");
esil->anal->cb_printf("\n");
}

// Used to cast sizes during assignment. OR is used for casting.
Expand Down
2 changes: 1 addition & 1 deletion libr/anal/esil_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ R_API void r_anal_esil_trace_list (RAnalEsil *esil) {
}

R_API void r_anal_esil_trace_show(RAnalEsil *esil, int idx) {
PrintfCallback p = esil->anal->printf;
PrintfCallback p = esil->anal->cb_printf;
const char *str2;
const char *str;
int trace_idx = esil->trace_idx;
Expand Down
42 changes: 21 additions & 21 deletions libr/anal/flirt.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,31 +450,31 @@ static void print_module (const RAnal *anal, const RFlirtModule *module) {
RFlirtFunction *func, *ref_func;
RFlirtTailByte *tail_byte;

anal->printf ("%02X %04X %04X ", module->crc_length, module->crc16, module->length);
anal->cb_printf ("%02X %04X %04X ", module->crc_length, module->crc16, module->length);
r_list_foreach (module->public_functions, pub_func_it, func) {
if (func->is_local || func->is_collision) {
anal->printf ("(");
if (func->is_local) anal->printf ("l");
if (func->is_collision) anal->printf ("!");
anal->printf (")");
anal->cb_printf ("(");
if (func->is_local) anal->cb_printf ("l");
if (func->is_collision) anal->cb_printf ("!");
anal->cb_printf (")");
}
anal->printf ("%04X:%s", func->offset, func->name);
if (pub_func_it->n) anal->printf (" ");
anal->cb_printf ("%04X:%s", func->offset, func->name);
if (pub_func_it->n) anal->cb_printf (" ");
}
if (module->tail_bytes) {
r_list_foreach (module->tail_bytes, tail_byte_it, tail_byte) {
anal->printf(" (%04X: %02X)", tail_byte->offset, tail_byte->value);
anal->cb_printf(" (%04X: %02X)", tail_byte->offset, tail_byte->value);
}
}
if (module->referenced_functions) {
anal->printf (" (REF ");
anal->cb_printf (" (REF ");
r_list_foreach (module->referenced_functions, ref_func_it, ref_func) {
anal->printf ("%04X: %s", ref_func->offset, ref_func->name);
if (ref_func_it->n) anal->printf (" ");
anal->cb_printf ("%04X: %s", ref_func->offset, ref_func->name);
if (ref_func_it->n) anal->cb_printf (" ");
}
anal->printf (")");
anal->cb_printf (")");
}
anal->printf ("\n");
anal->cb_printf ("\n");
}


Expand All @@ -483,16 +483,16 @@ static void print_node_pattern (const RAnal *anal, const RFlirtNode *node) {

for (i = 0; i < node->length; i++) {
if (node->variant_bool_array[i])
anal->printf ("..");
anal->cb_printf ("..");
else
anal->printf ("%02X", node->pattern_bytes[i]);
anal->cb_printf ("%02X", node->pattern_bytes[i]);
}
anal->printf (":\n");
anal->cb_printf (":\n");
}

static void print_indentation (const RAnal *anal, int indent) {
int i;
for (i = 0 ; i<indent ; i++) anal->printf (" ");
for (i = 0 ; i<indent ; i++) anal->cb_printf (" ");
}

static void print_node (const RAnal *anal, const RFlirtNode *node, int indent) {
Expand All @@ -514,7 +514,7 @@ static void print_node (const RAnal *anal, const RFlirtNode *node, int indent) {
i = 0;
r_list_foreach (node->module_list, module_it, module) {
print_indentation (anal, indent + 1);
anal->printf ("%d. ", i);
anal->cb_printf ("%d. ", i);
print_module (anal, module);
i++;
}
Expand Down Expand Up @@ -557,7 +557,7 @@ static int module_match_buffer (const RAnal *anal, const RFlirtModule *module,
anal->flb.set (anal->flb.f, next_module_function->name,
next_module_function->addr, next_module_function->size, 0);

anal->printf ("Found %s\n", next_module_function->name);
anal->cb_printf ("Found %s\n", next_module_function->name);
}
}

Expand Down Expand Up @@ -615,7 +615,7 @@ static int node_match_functions (const RAnal *anal, const RFlirtNode *root_node)
int size, ret = R_TRUE;

if (r_list_length(anal->fcns) == 0) {
anal->printf("There is no analyzed functions. Have you run 'aa'?\n");
anal->cb_printf("There is no analyzed functions. Have you run 'aa'?\n");
return R_TRUE;
}

Expand Down Expand Up @@ -1194,7 +1194,7 @@ static RFlirtNode* flirt_parse (const RAnal *anal, RBuffer *flirt_buf) {

name[header->library_name_len] = '\0';

anal->printf ("Loading: %s\n", name);
anal->cb_printf ("Loading: %s\n", name);
#if DEBUG
print_header (header);
header_size = flirt_buf->cur;
Expand Down
4 changes: 2 additions & 2 deletions libr/anal/labels.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ R_API int r_anal_fcn_labels (RAnal *anal, RAnalFunction *fcn, int rad) {
switch (rad) {
case '*':
case 1:
anal->printf ("f.%s@0x%08"PFMT64x"\n",
anal->cb_printf ("f.%s@0x%08"PFMT64x"\n",
loc.name, loc.addr);
break;
case 'j':
eprintf ("TODO\n");
break;
default:
anal->printf ("0x%08"PFMT64x" %s [%s + %"PFMT64d"]\n",
anal->cb_printf ("0x%08"PFMT64x" %s [%s + %"PFMT64d"]\n",
loc.addr,
loc.name, fcn->name,
loc.addr - fcn->addr, loc.addr);
Expand Down
30 changes: 15 additions & 15 deletions libr/anal/meta.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ static void printmetaitem(RAnal *a, RAnalMetaItem *d, int rad) {
// r_str_sanitize (str);
switch (rad) {
case 'j':
a->printf ("{\"offset\":%"PFMT64d", \"type\":\"%s\", \"name\":\"%s\"}",
a->cb_printf ("{\"offset\":%"PFMT64d", \"type\":\"%s\", \"name\":\"%s\"}",
d->from, r_meta_type_to_string (d->type), str);
break;
case 0:
Expand All @@ -307,20 +307,20 @@ static void printmetaitem(RAnal *a, RAnalMetaItem *d, int rad) {
if (!s) s = strdup (pstr);
if (rad) {
if (!strcmp (type, "CCu")) {
a->printf ("%s base64:%s @ 0x%08"PFMT64x"\n",
a->cb_printf ("%s base64:%s @ 0x%08"PFMT64x"\n",
type, s, d->from);
} else {
a->printf ("%s %s @ 0x%08"PFMT64x"\n",
a->cb_printf ("%s %s @ 0x%08"PFMT64x"\n",
type, pstr, d->from);
}
} else {
if (!strcmp (type, "CCu")) {
char *mys = r_str_escape (pstr);
a->printf ("0x%08"PFMT64x" %s \"%s\"\n",
a->cb_printf ("0x%08"PFMT64x" %s \"%s\"\n",
d->from, type, mys);
free (mys);
} else {
a->printf ("0x%08"PFMT64x" %s \"%s\"\n",
a->cb_printf ("0x%08"PFMT64x" %s \"%s\"\n",
d->from, type, pstr);
}
}
Expand All @@ -330,46 +330,46 @@ static void printmetaitem(RAnal *a, RAnalMetaItem *d, int rad) {
case 'h': /* hidden */
case 's': /* string */
if (rad) {
a->printf ("%s %d @ 0x%08"PFMT64x" # %s\n",
a->cb_printf ("%s %d @ 0x%08"PFMT64x" # %s\n",
r_meta_type_to_string (d->type),
(int)d->size, d->from, pstr);
} else {
// TODO: use b64 here
a->printf ("0x%08"PFMT64x" string[%d] \"%s\"\n",
a->cb_printf ("0x%08"PFMT64x" string[%d] \"%s\"\n",
d->from, (int)d->size, pstr);
}
break;
case 'd': /* data */
if (rad) {
a->printf ("%s %d @ 0x%08"PFMT64x"\n",
a->cb_printf ("%s %d @ 0x%08"PFMT64x"\n",
r_meta_type_to_string (d->type),
(int)d->size, d->from);
} else {
a->printf ("0x%08"PFMT64x" data %s %d\n",
a->cb_printf ("0x%08"PFMT64x" data %s %d\n",
d->from, r_meta_type_to_string (d->type), (int)d->size);

}
break;
case 'm': /* magic */
case 'f': /* formatted */
if (rad) {
a->printf ("%s %d %s @ 0x%08"PFMT64x"\n",
a->cb_printf ("%s %d %s @ 0x%08"PFMT64x"\n",
r_meta_type_to_string (d->type),
(int)d->size, pstr, d->from);
} else {
const char *dtype = d->type=='m'?"magic":"format";
a->printf ("0x%08"PFMT64x" %s %d %s\n",
a->cb_printf ("0x%08"PFMT64x" %s %d %s\n",
d->from, dtype, (int)d->size, pstr);
}
break;
default:
if (rad) {
a->printf ("%s %d 0x%08"PFMT64x" # %s\n",
a->cb_printf ("%s %d 0x%08"PFMT64x" # %s\n",
r_meta_type_to_string (d->type),
(int)d->size, d->from, pstr);
} else {
// TODO: use b64 here
a->printf ("0x%08"PFMT64x" array[%d] %s %s\n",
a->cb_printf ("0x%08"PFMT64x" array[%d] %s %s\n",
d->from, (int)d->size,
r_meta_type_to_string (d->type), pstr);
}
Expand Down Expand Up @@ -413,13 +413,13 @@ static int meta_print_item(void *user, const char *k, const char *v) {

R_API int r_meta_list_cb(RAnal *a, int type, int rad, SdbForeachCallback cb, void *user) {
RAnalMetaUserItem ui = { a, type, rad, cb, user, 0 };
if (rad=='j') a->printf ("[");
if (rad=='j') a->cb_printf ("[");
if (cb) {
sdb_foreach (DB, cb, &ui);
} else {
sdb_foreach (DB, meta_print_item, &ui);
}
if (rad=='j') a->printf ("]\n");
if (rad=='j') a->cb_printf ("]\n");
return ui.count;
}

Expand Down
4 changes: 2 additions & 2 deletions libr/anal/pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ static int cb_list(void *user, const char *k, const char *v) {
RAnal *a = (RAnal*)user;
if (!strncmp (k, "0x", 2)) {
// bind
a->printf ("%s = %s\n", k, v);
a->cb_printf ("%s = %s\n", k, v);
} else {
// ptr
a->printf ("PIN %s\n", k);
a->cb_printf ("PIN %s\n", k);
}
return 1;
}
Expand Down
20 changes: 10 additions & 10 deletions libr/anal/sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ R_API RSign *r_sign_new() {
if (sig) {
sig->s_byte = sig->s_anal = 0;
sig->ns[0] = '\0';
sig->printf = (PrintfCallback) printf;
sig->cb_printf = (PrintfCallback) printf;
sig->items = r_list_new ();
if (!sig->items){
free (sig);
Expand Down Expand Up @@ -97,22 +97,22 @@ R_API void r_sign_list(RSign *sig, int rad) {
RListIter *iter;
RSignItem *si;
if (!r_list_empty (sig->items))
sig->printf ("zp-\n");
sig->cb_printf ("zp-\n");
r_list_foreach (sig->items, iter, si) {
sig->printf ("z%c %s ", si->type, si->name);
sig->cb_printf ("z%c %s ", si->type, si->name);
for (i=0; i<si->size; i++){
if (!si->mask[i]) // This is a mask
sig->printf ("..");
sig->cb_printf ("..");
else
sig->printf ("%02x", si->bytes[i]);
sig->cb_printf ("%02x", si->bytes[i]);
}
sig->printf ("\n");
sig->cb_printf ("\n");
}
} else {
sig->printf ("Loaded %d signatures\n", sig->s_byte + sig->s_anal + sig->s_func);
sig->printf (" %d byte signatures\n", sig->s_byte);
sig->printf (" %d head signatures\n", sig->s_head);
sig->printf (" %d func signatures\n", sig->s_func);
sig->cb_printf ("Loaded %d signatures\n", sig->s_byte + sig->s_anal + sig->s_func);
sig->cb_printf (" %d byte signatures\n", sig->s_byte);
sig->cb_printf (" %d head signatures\n", sig->s_head);
sig->cb_printf (" %d func signatures\n", sig->s_func);
}
}

Expand Down
12 changes: 6 additions & 6 deletions libr/anal/var.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,26 +309,26 @@ R_API void r_anal_var_list_show(RAnal *anal, RAnalFunction *fcn, int kind, int m
RAnalVar *var;
RListIter *iter;
if (mode=='j')
anal->printf ("[");
anal->cb_printf ("[");
r_list_foreach (list, iter, var) {
if (var->kind == kind) {
switch (mode) {
case '*':
// we cant express all type info here :(
anal->printf ("af%c %d %s %s @ 0x%"PFMT64x"\n",
anal->cb_printf ("af%c %d %s %s @ 0x%"PFMT64x"\n",
kind, var->delta,
var->name, var->type, fcn->addr);
break;
case 'j':
anal->printf ("{\"name\":\"%s\","
anal->cb_printf ("{\"name\":\"%s\","
"\"kind\":\"%s\",\"type\":\"%s\",\"ref\":\"%s%s0x%x\"}",
var->name, var->kind=='v'?"var":"arg", var->type,
anal->reg->name[R_REG_NAME_BP],
(var->kind=='v')?"-":"+", var->delta);
if (iter->n) anal->printf (",");
if (iter->n) anal->cb_printf (",");
break;
default:
anal->printf ("%s %s %s @ %s%s0x%x\n",
anal->cb_printf ("%s %s %s @ %s%s0x%x\n",
kind=='v'?"var":"arg",
var->type, var->name,
anal->reg->name[R_REG_NAME_BP],
Expand All @@ -338,6 +338,6 @@ R_API void r_anal_var_list_show(RAnal *anal, RAnalFunction *fcn, int kind, int m
}
}
if (mode=='j')
anal->printf ("]\n");
anal->cb_printf ("]\n");
r_list_free (list);
}
Loading

0 comments on commit 0807686

Please sign in to comment.