Handle ^C in /p

This commit is contained in:
pancake 2014-05-14 23:24:46 +02:00
parent 03e1407dd9
commit 583be01f32
5 changed files with 22 additions and 1 deletions

View file

@ -16,6 +16,7 @@ static RCons r_cons_instance;
static void break_signal(int sig) {
I.breaked = R_TRUE;
r_print_set_interrupted (I.breaked);
if (I.event_interrupt)
I.event_interrupt (I.data);
}
@ -116,6 +117,7 @@ R_API void r_cons_break(void (*cb)(void *u), void *user) {
R_API void r_cons_break_end() {
I.breaked = R_FALSE;
r_print_set_interrupted (I.breaked);
#if __UNIX__
signal (SIGINT, SIG_IGN);
#endif

View file

@ -476,8 +476,10 @@ static int cmd_search(void *data, const char *input) {
{
int ps = atoi (input+1);
if (ps>1) {
r_cons_break (NULL, NULL);
r_search_pattern_size (core->search, ps);
r_search_pattern (core->search, from, to);
r_cons_break_end ();
} else eprintf ("Invalid pattern size (must be >0)\n");
}
break;

View file

@ -59,6 +59,11 @@ typedef struct r_print_t {
} RPrint;
#ifdef R_API
/* RConsBreak handlers */
R_API int r_print_is_interrupted();
R_API void r_print_set_interrupt(int i);
/* ... */
R_API char *r_print_hexpair(RPrint *p, const char *str, int idx);
R_API RPrint *r_print_new();
R_API RPrint *r_print_free(RPrint *p);

View file

@ -58,7 +58,7 @@ R_API int r_search_pattern(RSearch *s, ut64 from, ut64 to) {
int patlen = s->pattern_size;
fnditem* root;
eprintf ("Searching patterns between 0x%llx and 0x%llx\n", from, to);
eprintf ("Searching patterns between 0x%llx and 0x%llx\n", from, to);
if (patlen < 1 || patlen > MAX_PATLEN) {
eprintf ("Invalid pattern length (must be > 1 and < %d)\n", MAX_PATLEN);
return R_FALSE;
@ -74,6 +74,9 @@ eprintf ("Searching patterns between 0x%llx and 0x%llx\n", from, to);
// bproc = from2
while (bact < bytes) {
addr = bact;
if (r_print_is_interrupted ()) {
break;
}
bproc = bact + patlen ;
// read ( fd, sblk, patlen );

View file

@ -6,6 +6,15 @@
#include "r_util.h"
static int nullprinter(const char* a, ...) { return 0; }
static int IsInterrupted = 0;
R_API int r_print_is_interrupted() {
return IsInterrupted;
}
R_API void r_print_set_interrupted(int i) {
IsInterrupted = i;
}
R_API int r_print_mute(RPrint *p, int x) {
if (x) {