radare2/libr/core/yank.c
pancake c5303272d9 * Make r_cons independent from r_line
- r_cons_user_fgets() is a configurable function pointer
  - Simplify build
* Initial import of r_sysproxy
  - Directly copied from r1 (no api or anything working yet)
* R_APIze r_vm and r_print
* Make r_core_seek more consistent
* Move r_cons_progressbar() to r_print
* Rename visual 'x' -> 'w' (oops)
  - 'a' and 'w' are now compatible with cursor mode
* Implement r_sys_usleep() on w32 and fix r_sys_sleep()
2009-04-07 11:28:22 +00:00

33 lines
760 B
C

/* radare - LGPL - Copyright 2009 pancake<nopcode.org> */
#include "r_core.h"
int r_core_yank(struct r_core_t *core, u64 addr, int len)
{
u64 curseek = core->seek;
free(core->yank);
core->yank = (u8 *)malloc(len);
if (addr != core->seek)
r_core_seek(core, addr, 1);
if (len == 0)
len = core->blocksize;
if (len > core->blocksize)
r_core_block_size(core, len);
else memcpy(core->yank, core->block, len);
core->yank_off = addr;
core->yank_len = len;
if (curseek != addr)
r_core_seek(core, curseek, 1);
return R_TRUE;
}
int r_core_yank_paste(struct r_core_t *core, u64 addr, int len)
{
if (len == 0)
len = core->yank_len;
if (len > core->yank_len)
len = core->yank_len;
r_core_write_at(core, addr, core->yank, len);
return R_TRUE;
}