radare2/libr/bin/bin_meta.c
Nibble cec1f3fa73 * r_bin
- Refactor r_bin to work better with big fatbins
  - Don't load all sub-bins in memory
    Only load the fatbin and the selected sub-bin
  - Add r_bin_set_archidx() and r_bin_list_archs()
  - Update t/{rpathdel.c, test_meta.c}
* rabin2
  - Use '-f str' to select sub-bin by name
2010-10-04 03:46:58 +02:00

25 lines
792 B
C

/* radare - LGPL - Copyright 2009-2010 nibble<.ds@gmail.com> */
#include <r_types.h>
#include <r_bin.h>
R_API int r_bin_meta_get_line(RBin *bin, ut64 addr, char *file, int len, int *line) {
if (bin->curarch.curplugin && bin->curarch.curplugin->meta) {
// XXX quick hack to not show lines out of opened bin
if (addr >= bin->curarch.baddr && addr < (bin->curarch.baddr+bin->curarch.size))
if (bin->curarch.curplugin->meta->get_line)
return bin->curarch.curplugin->meta->get_line (&bin->curarch, addr,
file, len, line);
}
return R_FALSE;
}
R_API char *r_bin_meta_get_source_line(RBin *bin, ut64 addr) {
char file[4096];
int line;
char *out = NULL;
if (r_bin_meta_get_line (bin, addr, file, sizeof (file), &line))
out = r_file_slurp_line (file, line, 0);
return out;
}