/* radare - LGPL - Copyright 2013-2018 - pancake, sghctoma, xarkes */ #include <r_cons.h> #define RCOLOR_AT(i) (RColor *) (((ut8 *) &(r_cons_singleton ()->cpal)) + keys[i].coff) #define COLOR_AT(i) (char **) (((ut8 *) &(r_cons_singleton ()->pal)) + keys[i].off) static struct { const char *name; int off; // RConsPrintablePalette offset int coff; // RConsPalette offset } keys[] = { { "comment", r_offsetof (RConsPrintablePalette, comment), r_offsetof (RConsPalette, comment) }, { "usrcmt", r_offsetof (RConsPrintablePalette, usercomment), r_offsetof (RConsPalette, usercomment) }, { "args", r_offsetof (RConsPrintablePalette, args), r_offsetof (RConsPalette, args) }, { "fname", r_offsetof (RConsPrintablePalette, fname), r_offsetof (RConsPalette, fname) }, { "floc", r_offsetof (RConsPrintablePalette, floc), r_offsetof (RConsPalette, floc) }, { "fline", r_offsetof (RConsPrintablePalette, fline), r_offsetof (RConsPalette, fline) }, { "flag", r_offsetof (RConsPrintablePalette, flag), r_offsetof (RConsPalette, flag) }, { "label", r_offsetof (RConsPrintablePalette, label), r_offsetof (RConsPalette, label) }, { "help", r_offsetof (RConsPrintablePalette, help), r_offsetof (RConsPalette, help) }, { "flow", r_offsetof (RConsPrintablePalette, flow), r_offsetof (RConsPalette, flow) }, { "flow2", r_offsetof (RConsPrintablePalette, flow2), r_offsetof (RConsPalette, flow2) }, { "prompt", r_offsetof (RConsPrintablePalette, prompt), r_offsetof (RConsPalette, prompt) }, { "offset", r_offsetof (RConsPrintablePalette, offset), r_offsetof (RConsPalette, offset) }, { "input", r_offsetof (RConsPrintablePalette, input), r_offsetof (RConsPalette, input) }, { "invalid", r_offsetof (RConsPrintablePalette, invalid), r_offsetof (RConsPalette, invalid) }, { "other", r_offsetof (RConsPrintablePalette, other), r_offsetof (RConsPalette, other) }, { "b0x00", r_offsetof (RConsPrintablePalette, b0x00), r_offsetof (RConsPalette, b0x00) }, { "b0x7f", r_offsetof (RConsPrintablePalette, b0x7f), r_offsetof (RConsPalette, b0x7f) }, { "b0xff", r_offsetof (RConsPrintablePalette, b0xff), r_offsetof (RConsPalette, b0xff) },
} for (i=0; colors[i].name; i++) { if (!strcmp (s, colors[i].name)) strcat (out, colors[i].code); if (p && !strcmp (p, colors[i].name)) strcat (out, colors[i].bgcode); } free (s); return *out? strdup (out): NULL; } static struct { const char *name; int off; } keys[] = { { "comment", r_offsetof (RConsPalette, comment) }, { "args", r_offsetof (RConsPalette, args) }, { "fname", r_offsetof (RConsPalette, fname) }, { "fline", r_offsetof (RConsPalette, fline) }, { "flag", r_offsetof (RConsPalette, flag) }, { "label", r_offsetof (RConsPalette, label) }, { "help", r_offsetof (RConsPalette, help) }, { "flow", r_offsetof (RConsPalette, flow) }, { "prompt", r_offsetof (RConsPalette, prompt) }, { "offset", r_offsetof (RConsPalette, offset) }, { "input", r_offsetof (RConsPalette, input) }, { "invalid", r_offsetof (RConsPalette, invalid) }, { "other", r_offsetof (RConsPalette, other) }, { "b0x00", r_offsetof (RConsPalette, b0x00) }, { "b0x7f", r_offsetof (RConsPalette, b0x7f) }, { "b0xff", r_offsetof (RConsPalette, b0xff) },
} for (i=0; colors[i].name; i++) { if (!strcmp (s, colors[i].name)) strcat (out, colors[i].code); if (p && !strcmp (p, colors[i].name)) strcat (out, colors[i].bgcode); } free (s); return *out? strdup (out): NULL; } struct { const char *name; int off; } keys[] = { { "comment", r_offsetof (RConsPalette, comment) }, { "prompt", r_offsetof (RConsPalette, prompt) }, { "offset", r_offsetof (RConsPalette, offset) }, { "input", r_offsetof (RConsPalette, input) }, { "other", r_offsetof (RConsPalette, other) }, { "b0x00", r_offsetof (RConsPalette, b0x00) }, { "b0x7f", r_offsetof (RConsPalette, b0x7f) }, { "b0xff", r_offsetof (RConsPalette, b0xff) }, { "btext", r_offsetof (RConsPalette, btext) }, { "math", r_offsetof (RConsPalette, math) }, { "bin", r_offsetof (RConsPalette, bin) }, { "push", r_offsetof (RConsPalette, push) }, { "pop", r_offsetof (RConsPalette, pop) }, { "jmp", r_offsetof (RConsPalette, jmp) }, { "call", r_offsetof (RConsPalette, call) }, { "nop", r_offsetof (RConsPalette, nop) },
} for (i=0; colors[i].name; i++) { if (!strcmp (s, colors[i].name)) strncat (out, colors[i].code, sizeof(out)-strlen(out)-1); if (p && !strcmp (p, colors[i].name)) strncat (out, colors[i].bgcode, sizeof(out)-strlen(out)-1); } free (s); return *out? strdup (out): NULL; } static struct { const char *name; int off; } keys[] = { { "comment", r_offsetof (RConsPalette, comment) }, { "args", r_offsetof (RConsPalette, args) }, { "fname", r_offsetof (RConsPalette, fname) }, { "fline", r_offsetof (RConsPalette, fline) }, { "flag", r_offsetof (RConsPalette, flag) }, { "label", r_offsetof (RConsPalette, label) }, { "help", r_offsetof (RConsPalette, help) }, { "flow", r_offsetof (RConsPalette, flow) }, { "prompt", r_offsetof (RConsPalette, prompt) }, { "offset", r_offsetof (RConsPalette, offset) }, { "input", r_offsetof (RConsPalette, input) }, { "invalid", r_offsetof (RConsPalette, invalid) }, { "other", r_offsetof (RConsPalette, other) }, { "b0x00", r_offsetof (RConsPalette, b0x00) }, { "b0x7f", r_offsetof (RConsPalette, b0x7f) }, { "b0xff", r_offsetof (RConsPalette, b0xff) },
} for (i=0; colors[i].name; i++) { if (!strcmp (s, colors[i].name)) strcat (out, colors[i].code); if (p && !strcmp (p, colors[i].name)) strcat (out, colors[i].bgcode); } free (s); return *out? strdup (out): NULL; } static struct { const char *name; int off; } keys[] = { { "comment", r_offsetof (RConsPalette, comment) }, { "fname", r_offsetof (RConsPalette, fname) }, { "fline", r_offsetof (RConsPalette, fline) }, { "flag", r_offsetof (RConsPalette, flag) }, { "label", r_offsetof (RConsPalette, label) }, { "flow", r_offsetof (RConsPalette, flow) }, { "prompt", r_offsetof (RConsPalette, prompt) }, { "offset", r_offsetof (RConsPalette, offset) }, { "input", r_offsetof (RConsPalette, input) }, { "other", r_offsetof (RConsPalette, other) }, { "b0x00", r_offsetof (RConsPalette, b0x00) }, { "b0x7f", r_offsetof (RConsPalette, b0x7f) }, { "b0xff", r_offsetof (RConsPalette, b0xff) }, { "math", r_offsetof (RConsPalette, math) }, { "bin", r_offsetof (RConsPalette, bin) }, { "btext", r_offsetof (RConsPalette, btext) },