mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-31 10:22:37 +00:00
Rename prefix to namespace
This commit is contained in:
parent
73c1e4770e
commit
c8af9cb1cd
@ -9,7 +9,7 @@ R_API RSign *r_sign_new() {
|
||||
RSign *sig = R_NEW0 (RSign);
|
||||
if (sig) {
|
||||
sig->s_byte = sig->s_anal = 0;
|
||||
sig->prefix[0] = '\0';
|
||||
sig->ns[0] = '\0';
|
||||
sig->printf = (PrintfCallback) printf;
|
||||
sig->items = r_list_new ();
|
||||
sig->items->free = r_sign_item_free;
|
||||
@ -17,11 +17,12 @@ R_API RSign *r_sign_new() {
|
||||
return sig;
|
||||
}
|
||||
|
||||
R_API void r_sign_prefix(RSign *sig, const char *str) {
|
||||
R_API void r_sign_ns(RSign *sig, const char *str) {
|
||||
/*Set namespace*/
|
||||
if (str) {
|
||||
strncpy (sig->prefix, str, sizeof (sig->prefix)-1);
|
||||
sig->prefix[sizeof (sig->prefix)-1] = '\0';
|
||||
} else sig->prefix[0] = '\0';
|
||||
strncpy (sig->ns, str, sizeof (sig->ns)-1);
|
||||
sig->ns[sizeof (sig->ns)-1] = '\0';
|
||||
} else sig->ns[0] = '\0';
|
||||
}
|
||||
|
||||
R_API int r_sign_add(RSign *sig, RAnal *anal, int type, const char *name, const char *arg) {
|
||||
@ -36,7 +37,7 @@ R_API int r_sign_add(RSign *sig, RAnal *anal, int type, const char *name, const
|
||||
return R_FALSE;
|
||||
si->type = type;
|
||||
snprintf (si->name, sizeof (si->name), "%s.%c.%s",
|
||||
*sig->prefix? sig->prefix: "sign", type, name);
|
||||
*sig->ns? sig->ns: "sign", type, name);
|
||||
|
||||
switch (type) {
|
||||
case R_SIGN_FUNC: // function signature
|
||||
@ -117,17 +118,18 @@ R_API void r_sign_reset(RSign *sig) {
|
||||
sig->s_anal = sig->s_byte = sig->s_head = sig->s_func = 0;
|
||||
}
|
||||
|
||||
R_API int r_sign_remove_prefix(RSign* sig, const char* prefix) {
|
||||
R_API int r_sign_remove_ns(RSign* sig, const char* ns) {
|
||||
/*Remove namespace*/
|
||||
RListIter* iter, *iter2;
|
||||
RSignItem* si;
|
||||
int plen, i = 0;
|
||||
|
||||
if (!sig || !prefix)
|
||||
if (!sig || !ns)
|
||||
return -1;
|
||||
|
||||
plen = strlen (prefix);
|
||||
plen = strlen (ns);
|
||||
r_list_foreach_safe (sig->items, iter, iter2, si) {
|
||||
if (!strncmp (si->name, prefix, plen)) {
|
||||
if (!strncmp (si->name, ns, plen)) {
|
||||
if (si->type == R_SIGN_BYTE)
|
||||
sig->s_byte--;
|
||||
else if (si->type == R_SIGN_ANAL)
|
||||
|
@ -48,10 +48,10 @@ static int cmd_zign(void *data, const char *input) {
|
||||
break;
|
||||
case 'p':
|
||||
if (!input[1])
|
||||
r_cons_printf ("%s\n", core->sign->prefix);
|
||||
r_cons_printf ("%s\n", core->sign->ns);
|
||||
else if (!strcmp ("-", input+1))
|
||||
r_sign_prefix (core->sign, "");
|
||||
else r_sign_prefix (core->sign, input+2);
|
||||
r_sign_ns (core->sign, "");
|
||||
else r_sign_ns (core->sign, input+2);
|
||||
break;
|
||||
case 'a':
|
||||
case 'b':
|
||||
@ -72,7 +72,7 @@ static int cmd_zign(void *data, const char *input) {
|
||||
if (input[1] == '*')
|
||||
r_sign_reset (core->sign);
|
||||
else {
|
||||
int i = r_sign_remove_prefix(core->sign, input+1);
|
||||
int i = r_sign_remove_ns(core->sign, input+1);
|
||||
r_cons_printf ("%d zignatures removed\n", i);
|
||||
}
|
||||
break;
|
||||
@ -139,18 +139,18 @@ static int cmd_zign(void *data, const char *input) {
|
||||
"Usage:", "z[abcp/*-] [arg]", "Zignatures",
|
||||
"z", "", "show status of zignatures",
|
||||
"z*", "", "display all zignatures",
|
||||
"z-", "prefix", "unload zignatures with corresponding prefix",
|
||||
"z-", "namespace", "Unload zignatures in namespace",
|
||||
"z-*", "", "unload all zignatures",
|
||||
"z/", "[ini] [end]", "search zignatures between these regions",
|
||||
"za", " ...", "define new zignature for analysis",
|
||||
"zb", " name bytes", "define zignature for bytes",
|
||||
"zc", " @ fcn.foo", "flag signature if matching (.zc@@fcn)",
|
||||
"zf", " name fmt", "define function zignature (fast/slow, args, types)",
|
||||
"zg", " prefix [file]", "generate signature for current file",
|
||||
"zg", " namespace [file]", "Generate zignatures for current file",
|
||||
"zh", " name bytes", "define function header zignature",
|
||||
"zp", " prefix", "define prefix for following zignatures",
|
||||
"zp", "", "display current prefix",
|
||||
"zp-", "", "unset prefix",
|
||||
"zp", " namespace", "Define namespace for following zignatures (until zp-)",
|
||||
"zp", "", "Display current namespace",
|
||||
"zp-", "", "Unset namespace",
|
||||
"NOTE:", "", "bytes can contain '.' (dots) to specify a binary mask",
|
||||
NULL};
|
||||
r_core_cmd_help (core, help_msg);
|
||||
|
@ -34,7 +34,7 @@ typedef struct r_sign_t {
|
||||
int s_byte;
|
||||
int s_head;
|
||||
int s_func; // TODO: this must be an array count[N]
|
||||
char prefix[32];
|
||||
char ns[32]; // namespace
|
||||
PrintfCallback printf;
|
||||
RList *items;
|
||||
} RSign;
|
||||
@ -46,11 +46,11 @@ R_API RSign *r_sign_new();
|
||||
R_API int r_sign_add(RSign *sig, RAnal *anal, int type,
|
||||
const char *name, const char *arg);
|
||||
R_API RSign *r_sign_free(RSign *sig);
|
||||
R_API void r_sign_prefix(RSign *sig, const char *str);
|
||||
R_API void r_sign_ns(RSign *sig, const char *str);
|
||||
R_API void r_sign_list(RSign *sig, int rad);
|
||||
R_API void r_sign_reset(RSign *sig);
|
||||
R_API void r_sign_item_free(void *_item);
|
||||
R_API int r_sign_remove_prefix(RSign* sig, const char* prefix);
|
||||
R_API int r_sign_remove_ns(RSign* sig, const char* ns);
|
||||
|
||||
// old api
|
||||
R_API int r_sign_generate(RSign *sig, const char *file, FILE *fd);
|
||||
|
Loading…
x
Reference in New Issue
Block a user