mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-21 14:50:49 +00:00
Minor indentation fixes coming from the fix-pipes pr
This commit is contained in:
parent
06d7b89d18
commit
0612ab7275
@ -2026,9 +2026,10 @@ static int r_core_cmd_subst_i(RCore *core, char *cmd, char *colon) {
|
||||
eprintf (" pd|H - enable scr.html, respect scr.color\n");
|
||||
eprintf (" pi 1|T - use scr.tts to speak out the stdout\n");
|
||||
return ret;
|
||||
} else if (!strcmp (ptr + 1, "H")) { // "|H"
|
||||
} else if (!strncmp (ptr + 1, "H", 1)) { // "|H"
|
||||
scr_html = r_config_get_i (core->config, "scr.html");
|
||||
r_config_set_i (core->config, "scr.html", true);
|
||||
//r_config_set_i (core->config, "scr.pipecolor", true);
|
||||
} else if (!strcmp (ptr + 1, "T")) { // "|T"
|
||||
scr_color = r_config_get_i (core->config, "scr.color");
|
||||
r_config_set_i (core->config, "scr.color", COLOR_MODE_DISABLED);
|
||||
|
@ -489,24 +489,29 @@ static void handle_crc64_iso (const ut8 * block, int len) {
|
||||
|
||||
static int cmd_hash_bang (RCore *core, const char *input) {
|
||||
char *p;
|
||||
const char *lang = input+1;
|
||||
const char *lang = input + 1;
|
||||
if (r_sandbox_enable (0)) {
|
||||
eprintf ("hashbang disabled in sandbox mode\n");
|
||||
return false;
|
||||
}
|
||||
if (*lang=='/') {
|
||||
const char *ptr = lang+1;
|
||||
const char *ptr = lang + 1;
|
||||
while (*lang) {
|
||||
if (*lang=='/')
|
||||
ptr = lang+1;
|
||||
if (*lang=='/') {
|
||||
ptr = lang + 1;
|
||||
}
|
||||
lang++;
|
||||
}
|
||||
RLangPlugin *p = r_lang_get_by_extension (core->lang, ptr);
|
||||
if (p && p->name) lang = p->name;
|
||||
if (p && p->name) {
|
||||
lang = p->name;
|
||||
}
|
||||
}
|
||||
if (*lang==' ') {
|
||||
RLangPlugin *p = r_lang_get_by_extension (core->lang, input+2);
|
||||
if (p && p->name) lang = p->name;
|
||||
if (*lang == ' ') {
|
||||
RLangPlugin *p = r_lang_get_by_extension (core->lang, input + 2);
|
||||
if (p && p->name) {
|
||||
lang = p->name;
|
||||
}
|
||||
} else if (input[1]=='?' || input[1]=='*' || input[1]=='\0') {
|
||||
r_lang_list (core->lang);
|
||||
return true;
|
||||
@ -534,7 +539,9 @@ static int cmd_hash_bang (RCore *core, const char *input) {
|
||||
} else {
|
||||
if (r_config_get_i (core->config, "scr.interactive")) {
|
||||
r_lang_prompt (core->lang);
|
||||
} else eprintf ("Error: scr.interactive required to run the rlang prompt\n");
|
||||
} else {
|
||||
eprintf ("Error: scr.interactive required to run the rlang prompt\n");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
eprintf ("Invalid hashbang. See '#!' for help.\n");
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* radare2 - LGPL - Copyright 2015 pancake */
|
||||
/* radare2 - LGPL - Copyright 2015-2018 pancake */
|
||||
|
||||
#include "r_lib.h"
|
||||
#include "r_core.h"
|
||||
@ -29,10 +29,12 @@ static HANDLE myCreateChildProcess(const char * szCmdline) {
|
||||
//CloseHandle (piProcInfo.hThread);
|
||||
return bSuccess? piProcInfo.hProcess: NULL;
|
||||
}
|
||||
|
||||
static BOOL bStopPipeLoop = FALSE;
|
||||
static HANDLE hPipeInOut = NULL;
|
||||
static HANDLE hproc = NULL;
|
||||
#define PIPE_BUF_SIZE 4096
|
||||
|
||||
static DWORD WINAPI WaitForProcThread(LPVOID lParam) {
|
||||
WaitForSingleObject(hproc, INFINITE);
|
||||
bStopPipeLoop = TRUE;
|
||||
@ -56,9 +58,10 @@ static void lang_pipe_run_win(RLang *lang) {
|
||||
}
|
||||
memset (buf, 0, PIPE_BUF_SIZE);
|
||||
bSuccess = ReadFile (hPipeInOut, buf, PIPE_BUF_SIZE, &dwRead, NULL);
|
||||
if (bStopPipeLoop)
|
||||
if (bStopPipeLoop) {
|
||||
break;
|
||||
if (bSuccess && dwRead>0) {
|
||||
}
|
||||
if (bSuccess && dwRead > 0) {
|
||||
buf[sizeof (buf)-1] = 0;
|
||||
char *res = lang->cmd_str ((RCore*)lang->user, buf);
|
||||
if (res) {
|
||||
@ -89,7 +92,7 @@ static void lang_pipe_run_win(RLang *lang) {
|
||||
WriteFile (hPipeInOut, "", 1, &dwWritten, NULL);
|
||||
}
|
||||
}
|
||||
} while(!bStopPipeLoop);
|
||||
} while (!bStopPipeLoop);
|
||||
r_cons_break_pop ();
|
||||
}
|
||||
#else
|
||||
@ -139,7 +142,7 @@ static int lang_pipe_run(RLang *lang, const char *code, int len) {
|
||||
break;
|
||||
}
|
||||
memset (buf, 0, sizeof (buf));
|
||||
ret = read (output[0], buf, sizeof (buf)-1);
|
||||
ret = read (output[0], buf, sizeof (buf) - 1);
|
||||
if (ret < 1 || !buf[0]) {
|
||||
break;
|
||||
}
|
||||
@ -147,7 +150,7 @@ static int lang_pipe_run(RLang *lang, const char *code, int len) {
|
||||
res = lang->cmd_str ((RCore*)lang->user, buf);
|
||||
//eprintf ("%d %s\n", ret, buf);
|
||||
if (res) {
|
||||
write (input[1], res, strlen (res)+1);
|
||||
write (input[1], res, strlen (res) + 1);
|
||||
free (res);
|
||||
} else {
|
||||
eprintf ("r_lang_pipe: NULL reply for (%s)\n", buf);
|
||||
@ -209,7 +212,7 @@ static int lang_pipe_run(RLang *lang, const char *code, int len) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static struct r_lang_plugin_t r_lang_plugin_pipe = {
|
||||
static RLangPlugin r_lang_plugin_pipe = {
|
||||
.name = "pipe",
|
||||
.ext = "pipe",
|
||||
.license = "LGPL",
|
||||
|
Loading…
x
Reference in New Issue
Block a user