0day_dev/radare2-r2pipe/c
2020-08-07 13:48:00 -07:00
..
Makefile push 2020-08-07 13:48:00 -07:00
README.md push 2020-08-07 13:48:00 -07:00
test-pipe push 2020-08-07 13:48:00 -07:00
test-pipe.c push 2020-08-07 13:48:00 -07:00
test-pipe2 push 2020-08-07 13:48:00 -07:00
test-pipe2.c push 2020-08-07 13:48:00 -07:00
test-spawn push 2020-08-07 13:48:00 -07:00
test-spawn.c push 2020-08-07 13:48:00 -07:00

The C r2pipe API

It's implemented in libr_socket, so it depends on r2 libraries.

Here's a simple usage example:

#include <r_socket.h>

static void r2cmd(R2Pipe *r2, const char *cmd) {
	char *msg = r2pipe_cmd (r2, cmd);
	if (msg) {
		printf ("%s\n", msg);
		free (msg);
	}
}

int main() {
	R2Pipe *r2 = r2pipe_open ("radare2 -q0 /bin/ls");
	if (r2) {
		r2cmd (r2, "?e Hello World");
		r2cmd (r2, "x");
		r2cmd (r2, "?e Hello World");
		r2cmd (r2, "pd 20");
		r2pipe_close (r2);
		return 0;
	}
	return 1;
}