radare2/libr/io/t/read4.c
pancake 16cf12c8d6 * Fixtures for the r_io API (breaking ABI and so :)
- Standalone test program is now able to debug a process and read mapped memory
  - Fixes in the r_io and ptrace plugin sides
* Added 'make vdoc' target
2009-09-07 20:01:34 +00:00

29 lines
507 B
C

#include <r_io.h>
int main(int argc, char **argv)
{
char buf[1024];
int fd;
struct r_io_t io;
char *file;
r_io_init(&io);
file = argc>1?argv[1]:"/bin/ls";
fd = r_io_open(&io, file, R_IO_READ, 0);
if (fd == -1) {
printf("Cannot open file '%s'\n", file);
return 1;
}
printf("FD = %d\n", fd);
r_io_seek(&io, 1, R_IO_SEEK_SET);
memset(buf, '\0', sizeof(buf));
r_io_read(&io, buf, 4);
buf[4]='\0';
printf("%llx\n", r_io_read_i(&io, 0LL, 4, 0));
puts(buf);
return r_io_close(&io, fd);
}