Extend the manpage reader to support more attributes ##doc

* r2 -c 'man rasign2' --
This commit is contained in:
pancake 2024-03-17 19:29:07 +01:00 committed by pancake
parent c555f744f7
commit 70cfb7f2e4
2 changed files with 31 additions and 24 deletions

View File

@ -60,14 +60,34 @@ static char *readman(const char *page) {
p++;
}
break;
case 'F': // ".Fl"
case 'T': // ".Tn"
if (p[2] == 'P') {
memset (p, ' ', 3);
break;
}
if (p[2] == 'H') {
memcpy (p, "\n#", 2);
break;
}
// fallthrough
case 'B': // ".Bl"
if (p[2] == ' ') {
char *nl = strchr (p, '\n');
if (nl) {
memmove (p, p + 1, nl - p - 1);
memcpy (p, " '", 2);
nl[-1] = '\'';
p = nl;
}
break;
}
case 'F': // ".Fl"
while (*p && *p != '\n') {
*p = ' ';
p++;
}
break;
case 'R': // ".RS" ".RE"
case 'E': // ".El"
case 'N': // ".Nm"
case 'X': // ".Xr"
@ -90,6 +110,7 @@ static char *readman(const char *page) {
p = strstr (p, "\n.");
}
// replace \n.XX with stuff
res = r_str_replace_all (res, "\\-", "-");
res = r_str_replace_all (res, " Ar ", " ");
}
free (p);
@ -249,16 +270,16 @@ static int cmd_mount(void *data, const char *_input) {
RFSPartition *part;
RCore *core = (RCore *)data;
if (r_str_startswith (_input, "an")) {
if (r_str_startswith (_input, "an")) { // "ma" "man"
return cmd_man (data, _input);
}
if (r_str_startswith (_input, "ktemp")) {
if (r_str_startswith (_input, "ktemp")) { // "mktemp"
return cmd_mktemp (data, _input);
}
if (r_str_startswith (_input, "kdir")) {
if (r_str_startswith (_input, "kdir")) { // "mkdir"
return cmd_mkdir (data, _input);
}
if (r_str_startswith (_input, "v")) {
if (r_str_startswith (_input, "v")) { // "mv"
return cmd_mv (data, _input);
}
input = oinput = strdup (_input);

View File

@ -7,9 +7,7 @@ rasign2 \- a tool for generating and managing binary file signatures
[options] [file]
.SH DESCRIPTION
The
.B rasign2
tool is designed for creating, dumping, and managing signature files for binary analysis. It facilitates the generation of signature databases (SDB) from binary files, making it easier to identify and catalog functions and other symbols. The tool can interpret FLIRT 'I.sig' files, execute custom Radare2 scripts, and output signatures in multiple formats.
The rasign2 tool is designed for creating, dumping, and managing signature files for binary analysis. It facilitates the generation of signature databases (SDB) from binary files, making it easier to identify and catalog functions and other symbols. The tool can interpret FLIRT 'I.sig' files, execute custom Radare2 scripts, and output signatures in multiple formats.
.SH OPTIONS
.TP
@ -100,7 +98,7 @@ Merging signatures:
.RS
.B rasign2 -m -o existing_sigs.sdb new_sigs.sdb
.RE
Merges or overwrites signatures in Iexisting_sigs.sdb P with those from Inew_sigs.sdb P.
Merges or overwrites signatures in 'existing_sigs.sdb' with those from 'new_sigs.sdb'.
.SH "THE Z COMMAND IN RADARE2"
@ -109,9 +107,7 @@ The
command in radare2 is dedicated to the management of binary signatures, known as zignatures. Zignatures are used for identifying and cataloging functions across different binaries by their unique characteristics, such as bytes patterns, graph metrics, and other attributes.
.SH "CONFIGURATION OPTIONS"
The behavior of zignature processing can be fine-tuned through a variety of configuration options, accessible via
.B e??zign.
in radare2. Some key configuration options include:
The behavior of zignature processing can be fine-tuned through a variety of configuration options, accessible via 'e??zign.' in radare2. Some key configuration options include:
.TP
.B zign.autoload
@ -138,15 +134,7 @@ Minimum similarity required for inclusion in zb output.
Use types for matching.
.SH "ADDING ZIGNATURES"
Zignatures can be added with the
.B za
command, supporting a variety of types such as bytes patterns (
.B a
and
.B b
), graph metrics (
.B g
), and more. Examples include:
Zignatures can be added with the 'za' command, supporting a variety of types such as bytes patterns, graph metrics, and more.
.TP
.B za foo b 558bec..e8........
@ -255,9 +243,7 @@ Each metric allows for a nuanced approach to identifying and comparing functions
.SH "USAGE EXAMPLES FOR THE Z COMMAND"
The
.B z
command in radare2 is versatile, offering various functionalities through its subcommands. Here are five usage examples:
The z command in radare2 is versatile, offering various functionalities through its subcommands. Here are five usage examples:
.TP
.B Show all zignatures