static void printmetaitem(RAnal *a, RAnalMetaItem *d, int rad) { char *pstr, *str = r_str_escape (d->str); if (str) { if (d->type=='s' && !*str) { free (str); return; } if (d->type != 'C') { r_name_filter (str, 0); pstr = str; } else pstr = d->str; // r_str_sanitize (str); switch (rad) { case 'j': a->printf ("{\"offset\":%"PFMT64d", \"type\":\"%s\", \"name\":\"%s\"}", d->from, r_meta_type_to_string (d->type), str); break; case 0: a->printf ("0x%08"PFMT64x" %s\n", d->from, str); case 1: case '*': default: if (d->type == 'C') { a->printf ("\"%s %s\" @ 0x%08"PFMT64x"\n", r_meta_type_to_string (d->type), pstr, d->from); } else { a->printf ("%s %d 0x%08"PFMT64x" # %s\n", r_meta_type_to_string (d->type), d->size, d->from, pstr); } break; } free (str); } }
static void printmetaitem(RAnal *a, RAnalMetaItem *d, int rad) { char *pstr, *str; //eprintf ("%d %d\n", d->space, a->meta_spaces.space_idx); if (a->meta_spaces.space_idx != -1) { if (a->meta_spaces.space_idx != d->space) { return; } } str = r_str_escape (d->str); if (str || d->type == 'd') { if (d->type=='s' && !*str) { free (str); return; } if (!str) { pstr = ""; } else if (d->type != 'C') { r_name_filter (str, 0); pstr = str; } else pstr = d->str; // r_str_sanitize (str); switch (rad) { case 'j': a->cb_printf ("{\"offset\":%"PFMT64d", \"type\":\"%s\", \"name\":\"%s\"}", d->from, r_meta_type_to_string (d->type), str); break; case 0: case 1: case '*': default: switch (d->type) { case 'C': { const char *type = r_meta_type_to_string (d->type); char *s = sdb_encode ((const ut8*)pstr, -1); if (!s) s = strdup (pstr); if (rad) { if (!strcmp (type, "CCu")) { a->cb_printf ("%s base64:%s @ 0x%08"PFMT64x"\n", type, s, d->from); } else { a->cb_printf ("%s %s @ 0x%08"PFMT64x"\n", type, pstr, d->from); } } else { if (!strcmp (type, "CCu")) { char *mys = r_str_escape (pstr); a->cb_printf ("0x%08"PFMT64x" %s \"%s\"\n", d->from, type, mys); free (mys); } else { a->cb_printf ("0x%08"PFMT64x" %s \"%s\"\n", d->from, type, pstr); } } free (s); } break; case 'h': /* hidden */ case 's': /* string */ if (rad) { a->cb_printf ("%s %d @ 0x%08"PFMT64x" # %s\n", r_meta_type_to_string (d->type), (int)d->size, d->from, pstr); } else { // TODO: use b64 here a->cb_printf ("0x%08"PFMT64x" string[%d] \"%s\"\n", d->from, (int)d->size, pstr); } break; case 'd': /* data */ if (rad) { a->cb_printf ("%s %d @ 0x%08"PFMT64x"\n", r_meta_type_to_string (d->type), (int)d->size, d->from); } else { a->cb_printf ("0x%08"PFMT64x" data %s %d\n", d->from, r_meta_type_to_string (d->type), (int)d->size); } break; case 'm': /* magic */ case 'f': /* formatted */ if (rad) { a->cb_printf ("%s %d %s @ 0x%08"PFMT64x"\n", r_meta_type_to_string (d->type), (int)d->size, pstr, d->from); } else { const char *dtype = d->type=='m'?"magic":"format"; a->cb_printf ("0x%08"PFMT64x" %s %d %s\n", d->from, dtype, (int)d->size, pstr); } break; default: if (rad) { a->cb_printf ("%s %d 0x%08"PFMT64x" # %s\n", r_meta_type_to_string (d->type), (int)d->size, d->from, pstr); } else { // TODO: use b64 here a->cb_printf ("0x%08"PFMT64x" array[%d] %s %s\n", d->from, (int)d->size, r_meta_type_to_string (d->type), pstr); } break; } break; } if (str) free (str); } }