mirror of
https://github.com/radareorg/radare2.git
synced 2025-03-01 18:57:20 +00:00
Add print, println, and placeholder for printf and printfln ##cons (#18320)
This commit is contained in:
parent
80d81c553b
commit
35731c185c
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2009-2020 - pancake */
|
||||
/* radare - LGPL - Copyright 2009-2021 - pancake */
|
||||
|
||||
#include "r_asm.h"
|
||||
#include "r_core.h"
|
||||
@ -91,6 +91,7 @@ static const char* help_msg_pr[] = {
|
||||
"prc", "[=fep..]", "print bytes as colors in palette",
|
||||
"prg", "[?]", "print raw GUNZIPped block",
|
||||
"pri", "[aA2r]", "print raw image, honor hex.cols",
|
||||
"print", "[f][ln]", "print, println, printf, printfln",
|
||||
"prl", "", "print raw with lines offsets",
|
||||
"prx", "", "printable chars with real offset (hyew)",
|
||||
"prz", "", "print raw zero terminated string",
|
||||
@ -741,6 +742,22 @@ static void cmd_prc(RCore *core, const ut8* block, int len) {
|
||||
}
|
||||
}
|
||||
|
||||
static void cmd_printmsg(RCore *core, const char *input) {
|
||||
if (!strcmp (input, "ln")) {
|
||||
r_cons_newline ();
|
||||
} else if (!strncmp (input, "ln ", 3)) {
|
||||
r_cons_println (input + 3);
|
||||
} else if (!strncmp (input, " ", 1)) {
|
||||
r_cons_print (input + 1);
|
||||
} else if (!strncmp (input, "f ", 2)) {
|
||||
eprintf ("TODO: waiting for r2shell\n");
|
||||
} else if (!strncmp (input, "fln ", 2)) {
|
||||
eprintf ("TODO: waiting for r2shell\n");
|
||||
} else {
|
||||
eprintf ("Usage: print, println, printf, printfln");
|
||||
}
|
||||
}
|
||||
|
||||
static void cmd_prc_zoom(RCore *core, const char *input) {
|
||||
const char *chars = " .,:;!O@#";
|
||||
bool square = r_config_get_i (core->config, "scr.square");
|
||||
@ -5984,12 +6001,11 @@ l = use_blocksize;
|
||||
case 'r': // "pr"
|
||||
switch (input[1]) {
|
||||
case 'i': // "pri" // color raw image
|
||||
{
|
||||
if (input[2] == 'n') {
|
||||
cmd_printmsg (core, input + 4);
|
||||
} else {
|
||||
// TODO: do colormap and palette conversions here
|
||||
int mode = 0;
|
||||
if (r_config_get (core->config, "scr.color") == 0) {
|
||||
mode = 'a';
|
||||
}
|
||||
int mode = r_config_get_i (core->config, "scr.color")? 0: 'a';
|
||||
int cols = r_config_get_i (core->config, "hex.cols");
|
||||
r_cons_image (core->block, core->blocksize, cols, mode);
|
||||
}
|
||||
|
@ -234,4 +234,14 @@ EOF
|
||||
EXPECT=<<EOF
|
||||
2
|
||||
EOF
|
||||
RUN
|
||||
RUN
|
||||
|
||||
NAME="println"
|
||||
FILE=-
|
||||
CMDS=<<EOF
|
||||
print hello;print world;println
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
helloworld
|
||||
EOF
|
||||
RUN
|
||||
|
Loading…
x
Reference in New Issue
Block a user