Rizin
unix-like reverse engineering framework and cli tools
cmd_flag.c File Reference
#include <stddef.h>
#include <rz_cons.h>
#include <rz_core.h>
#include "../core_private.h"

Go to the source code of this file.

Classes

struct  PrintFcnLabelsCtx
 
struct  flagbar_t
 
struct  flag_to_flag_t
 
struct  rename_flag_t
 

Functions

static bool listFlag (RzFlagItem *flag, void *user)
 
static size_t countMatching (const char *a, const char *b)
 
static const char * __isOnlySon (RzCore *core, RzList *flags, const char *kw)
 
static RzList__childrenFlagsOf (RzCore *core, RzList *flags, const char *prefix)
 
static void __printRecursive (RzCore *core, RzList *list, const char *name, RzOutputMode mode, int depth)
 
static bool print_function_labels_cb (void *user, const ut64 addr, const void *v)
 
static bool flag_set_comment (RzFlagItem *item, const char *comment)
 
RZ_IPI RzCmdStatus rz_flag_add_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_append_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_local_add_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_local_remove_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_local_list_handler (RzCore *core, int argc, const char **argv, RzCmdStateOutput *state)
 
RZ_IPI RzCmdStatus rz_flag_local_list_all_handler (RzCore *core, int argc, const char **argv, RzCmdStateOutput *state)
 
RZ_IPI RzCmdStatus rz_flag_graph_handler (RzCore *core, int argc, const char **argv, RzCmdStateOutput *state)
 
RZ_IPI RzCmdStatus rz_flag_relocate_handler (RzCore *core, int argc, const char **argv)
 
static int cmpflag (const void *_a, const void *_b)
 
RZ_IPI void rz_core_flag_describe (RzCore *core, ut64 addr, bool strict_offset, RzCmdStateOutput *state)
 
RZ_IPI RzCmdStatus rz_flag_describe_handler (RzCore *core, int argc, const char **argv, RzCmdStateOutput *state)
 
RZ_IPI RzCmdStatus rz_flag_describe_at_handler (RzCore *core, int argc, const char **argv, RzCmdStateOutput *state)
 
RZ_IPI RzCmdStatus rz_flag_describe_closest_handler (RzCore *core, int argc, const char **argv)
 
static void flag_zone_list (RzFlag *f, RzCmdStateOutput *state)
 
RZ_IPI RzCmdStatus rz_flag_zone_add_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_zone_remove_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_zone_remove_all_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_zone_around_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_zone_list_handler (RzCore *core, int argc, const char **argv, RzCmdStateOutput *state)
 
static bool flagbar_foreach (RzFlagItem *fi, void *user)
 
static void flagbars (RzCore *core, const char *glob)
 
static bool flag_to_flag_foreach (RzFlagItem *fi, void *user)
 
static int flag_to_flag (RzCore *core, const char *glob)
 
RZ_IPI RzCmdStatus rz_flag_tag_add_handler (RzCore *core, int argc, const char **argv)
 
static void flag_tag_print (RzCore *core, const char *tag, RzCmdStateOutput *state)
 
RZ_IPI RzCmdStatus rz_flag_tag_list_handler (RzCore *core, int argc, const char **argv, RzCmdStateOutput *state)
 
RZ_IPI RzCmdStatus rz_flag_tag_search_handler (RzCore *core, int argc, const char **argv)
 
static bool rename_flag_ordinal (RzFlagItem *fi, void *user)
 
static void flag_ordinals (RzCore *core, const char *glob)
 
static bool adjust_offset (RzFlagItem *flag, void *user)
 
static void print_space_stack (RzFlag *f, int ordinal, const char *name, bool selected, RzCmdStateOutput *state)
 
RZ_IPI RzCmdStatus rz_flag_space_add_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_space_list_handler (RzCore *core, int argc, const char **argv, RzCmdStateOutput *state)
 
RZ_IPI RzCmdStatus rz_flag_space_move_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_space_remove_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_space_remove_all_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_space_rename_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_space_stack_push_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_space_stack_pop_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_space_stack_list_handler (RzCore *core, int argc, const char **argv, RzCmdStateOutput *state)
 
RZ_IPI RzCmdStatus rz_flag_remove_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_remove_all_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_alias_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_base_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_exists_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_distance_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_move_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_length_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_realname_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_list_ascii_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_color_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_comment_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_ordinals_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_rename_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_hexdump_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_flag_range_handler (RzCore *core, int argc, const char **argv, RzCmdStateOutput *state)
 
RZ_IPI RzCmdStatus rz_flag_list_at_handler (RzCore *core, int argc, const char **argv, RzCmdStateOutput *state)
 
RZ_IPI RzCmdStatus rz_flag_list_handler (RzCore *core, int argc, const char **argv, RzCmdStateOutput *state)
 

Function Documentation

◆ __childrenFlagsOf()

static RzList* __childrenFlagsOf ( RzCore core,
RzList flags,
const char *  prefix 
)
static

Definition at line 43 of file cmd_flag.c.

43  {
45  RzListIter *iter, *iter2;
46  RzFlagItem *f, *f2;
47  char *fn;
48 
49  const size_t prefix_len = strlen(prefix);
50  rz_list_foreach (flags, iter, f) {
51  if (prefix_len > 0 && strncmp(f->name, prefix, prefix_len)) {
52  continue;
53  }
54  if (prefix_len > strlen(f->name)) {
55  continue;
56  }
57  if (rz_cons_is_breaked()) {
58  break;
59  }
60  const char *name = f->name;
61  int name_len = strlen(name);
62  rz_list_foreach (flags, iter2, f2) {
63  if (prefix_len > strlen(f2->name)) {
64  continue;
65  }
66  if (prefix_len > 0 && strncmp(f2->name, prefix, prefix_len)) {
67  continue;
68  }
69  int matching = countMatching(name, f2->name);
70  if (matching < prefix_len || matching == name_len) {
71  continue;
72  }
73  if (matching > name_len) {
74  break;
75  }
76  if (matching < name_len) {
77  name_len = matching;
78  }
79  }
80  char *kw = rz_str_ndup(name, name_len + 1);
81  const int kw_len = strlen(kw);
82  const char *only = __isOnlySon(core, flags, kw);
83  if (only) {
84  free(kw);
85  kw = strdup(only);
86  } else {
87  const char *fname = NULL;
88  size_t fname_len = 0;
89  rz_list_foreach (flags, iter2, f2) {
90  if (strncmp(f2->name, kw, kw_len)) {
91  continue;
92  }
93  if (fname) {
94  int matching = countMatching(fname, f2->name);
95  if (fname_len) {
96  if (matching < fname_len) {
97  fname_len = matching;
98  }
99  } else {
100  fname_len = matching;
101  }
102  } else {
103  fname = f2->name;
104  }
105  }
106  if (fname_len > 0) {
107  free(kw);
108  kw = rz_str_ndup(fname, fname_len);
109  }
110  }
111 
112  bool found = false;
113  rz_list_foreach (list, iter2, fn) {
114  if (!strcmp(fn, kw)) {
115  found = true;
116  break;
117  }
118  }
119  if (found) {
120  free(kw);
121  } else {
122  if (strcmp(prefix, kw)) {
123  rz_list_append(list, kw);
124  } else {
125  free(kw);
126  }
127  }
128  }
129  return list;
130 }
static const char * __isOnlySon(RzCore *core, RzList *flags, const char *kw)
Definition: cmd_flag.c:25
static size_t countMatching(const char *a, const char *b)
Definition: cmd_flag.c:14
RZ_API bool rz_cons_is_breaked(void)
Definition: cons.c:373
#define NULL
Definition: cris-opc.c:27
unsigned short prefix[65536]
Definition: gun.c:163
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
RZ_API const KEY_TYPE bool * found
Definition: ht_inc.h:130
static void list(RzEgg *egg)
Definition: rz-gg.c:52
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
Definition: list.c:248
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
Definition: list.c:288
static const char struct stat static buf struct stat static buf static idle const char static path static fd const char static len const void static prot const char struct module static image struct kernel_sym static table unsigned char static buf static fsuid unsigned struct dirent unsigned static count const struct iovec static count static pid const void static len static flags const struct sched_param static p static pid static policy struct timespec static tp static suid unsigned fn
Definition: sflib.h:186
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
RZ_API char * rz_str_ndup(RZ_NULLABLE const char *ptr, int len)
Create new copy of string ptr limited to size len.
Definition: str.c:1006
static struct sockaddr static addrlen static backlog const void static flags void flags
Definition: sfsocketcall.h:123
#define f(i)
Definition: sha256.c:46
Definition: z80asm.h:102

References __isOnlySon(), countMatching(), f, autogen_x86imm::f2, flags, fn, create_tags_rz::fname, found, free(), list(), NULL, prefix, rz_cons_is_breaked(), rz_list_append(), rz_list_newf(), rz_str_ndup(), and strdup().

Referenced by __printRecursive().

◆ __isOnlySon()

static const char* __isOnlySon ( RzCore core,
RzList flags,
const char *  kw 
)
static

Definition at line 25 of file cmd_flag.c.

25  {
27  RzFlagItem *f;
28 
29  size_t count = 0;
30  char *fname = NULL;
31  rz_list_foreach (flags, iter, f) {
32  if (!strncmp(f->name, kw, strlen(kw))) {
33  count++;
34  if (count > 1) {
35  return NULL;
36  }
37  fname = f->name;
38  }
39  }
40  return fname;
41 }
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
Definition: sflib.h:98

References count, f, flags, create_tags_rz::fname, and NULL.

Referenced by __childrenFlagsOf().

◆ __printRecursive()

static void __printRecursive ( RzCore core,
RzList list,
const char *  name,
RzOutputMode  mode,
int  depth 
)
static

Definition at line 134 of file cmd_flag.c.

134  {
135  char *fn;
136  RzListIter *iter;
138  rz_cons_printf("agn root\n");
139  }
140  if (rz_flag_get(core->flags, name)) {
141  return;
142  }
143  RzList *children = __childrenFlagsOf(core, flags, name);
144  const int name_len = strlen(name);
145  rz_list_foreach (children, iter, fn) {
146  if (!strcmp(fn, name)) {
147  continue;
148  }
149  if (mode == RZ_OUTPUT_MODE_RIZIN) {
150  rz_cons_printf("agn %s %s\n", fn, fn + name_len);
151  rz_cons_printf("age %s %s\n", RZ_STR_ISNOTEMPTY(name) ? name : "root", fn);
152  } else {
153  rz_cons_printf("%s %s\n", rz_str_pad(' ', name_len), fn + name_len);
154  }
155  // rz_cons_printf (".fg %s\n", fn);
156  __printRecursive(core, flags, fn, mode, depth + 1);
157  }
158  rz_list_free(children);
159 }
static void __printRecursive(RzCore *core, RzList *list, const char *name, RzOutputMode mode, int depth)
Definition: cmd_flag.c:134
static RzList * __childrenFlagsOf(RzCore *core, RzList *flags, const char *prefix)
Definition: cmd_flag.c:43
RZ_API int rz_cons_printf(const char *format,...)
Definition: cons.c:1202
RZ_API RzFlagItem * rz_flag_get(RzFlag *f, const char *name)
Definition: flag.c:310
const char int mode
Definition: ioapi.h:137
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
Definition: list.c:137
#define RZ_STR_ISNOTEMPTY(x)
Definition: rz_str.h:68
#define RZ_STR_ISEMPTY(x)
Definition: rz_str.h:67
RZ_API const char * rz_str_pad(const char ch, int len)
Definition: str.c:3236
@ RZ_OUTPUT_MODE_RIZIN
Definition: rz_types.h:41
RzFlag * flags
Definition: rz_core.h:330

References __childrenFlagsOf(), rz_core_t::flags, flags, fn, rz_cons_printf(), rz_flag_get(), rz_list_free(), RZ_OUTPUT_MODE_RIZIN, RZ_STR_ISEMPTY, RZ_STR_ISNOTEMPTY, and rz_str_pad().

Referenced by rz_flag_graph_handler().

◆ adjust_offset()

static bool adjust_offset ( RzFlagItem flag,
void *  user 
)
static

Definition at line 654 of file cmd_flag.c.

654  {
655  st64 base = *(st64 *)user;
656  flag->offset += base;
657  return true;
658 }
#define st64
Definition: rz_types_base.h:10
ut64 offset
Definition: rz_flag.h:38

References rz_flag_item_t::offset, and st64.

Referenced by rz_flag_base_handler().

◆ cmpflag()

static int cmpflag ( const void *  _a,
const void *  _b 
)
static

Definition at line 322 of file cmd_flag.c.

322  {
323  const RzFlagItem *flag1 = _a, *flag2 = _b;
324  return (flag1->offset - flag2->offset);
325 }

References rz_flag_item_t::offset.

Referenced by rz_flag_describe_closest_handler().

◆ countMatching()

static size_t countMatching ( const char *  a,
const char *  b 
)
static

Definition at line 14 of file cmd_flag.c.

14  {
15  size_t matches = 0;
16  for (; *a && *b; a++, b++) {
17  if (*a != *b) {
18  break;
19  }
20  matches++;
21  }
22  return matches;
23 }
#define b(i)
Definition: sha256.c:42
#define a(i)
Definition: sha256.c:41

References a, and b.

Referenced by __childrenFlagsOf().

◆ flag_ordinals()

static void flag_ordinals ( RzCore core,
const char *  glob 
)
static

Definition at line 643 of file cmd_flag.c.

643  {
644  char *pfx = strdup(glob);
645  char *p = strchr(pfx, '*');
646  if (p) {
647  *p = 0;
648  }
649  struct rename_flag_t u = { .core = core, .pfx = pfx, .count = 0 };
651  free(pfx);
652 }
static bool rename_flag_ordinal(RzFlagItem *fi, void *user)
Definition: cmd_flag.c:632
RZ_API void rz_flag_foreach_glob(RzFlag *f, const char *glob, RzFlagItemCb cb, void *user)
Definition: flag.c:818
void * p
Definition: libc.cpp:67
RzCore * core
Definition: cmd_flag.c:627
const char * pfx
Definition: cmd_flag.c:628

References rename_flag_t::core, rz_core_t::flags, free(), p, rename_flag_t::pfx, rename_flag_ordinal(), rz_flag_foreach_glob(), and strdup().

Referenced by rz_flag_ordinals_handler().

◆ flag_set_comment()

static bool flag_set_comment ( RzFlagItem item,
const char *  comment 
)
static

Definition at line 191 of file cmd_flag.c.

191  {
192  if (!strncmp(comment, "base64:", 7)) {
193  const char *b64str = comment + 7;
194  char *dec = (char *)rz_base64_decode_dyn(b64str, -1);
195  if (!dec) {
196  RZ_LOG_ERROR("Failed to decode base64-encoded string: \"%s\"\n", b64str);
197  return false;
198  }
199  rz_flag_item_set_comment(item, dec);
200  free(dec);
201  } else {
202  rz_flag_item_set_comment(item, comment);
203  }
204  return true;
205 }
RZ_API void rz_flag_item_set_comment(RzFlagItem *item, const char *comment)
Definition: flag.c:564
RZ_API ut8 * rz_base64_decode_dyn(const char *in, int len)
Definition: ubase64.c:65
#define RZ_LOG_ERROR(fmtstr,...)
Definition: rz_log.h:58

References free(), rz_base64_decode_dyn(), rz_flag_item_set_comment(), and RZ_LOG_ERROR.

Referenced by rz_flag_add_handler(), rz_flag_append_handler(), and rz_flag_comment_handler().

◆ flag_tag_print()

static void flag_tag_print ( RzCore core,
const char *  tag,
RzCmdStateOutput state 
)
static

Definition at line 554 of file cmd_flag.c.

554  {
555  PJ *pj = state->d.pj;
556  switch (state->mode) {
557  case RZ_OUTPUT_MODE_JSON: {
558  pj_k(pj, tag);
559  pj_a(pj);
561  if (!flags) {
562  pj_end(pj);
563  break;
564  }
565  RzListIter *iter;
566  RzFlagItem *flag;
567  rz_list_foreach (flags, iter, flag) {
568  pj_s(pj, flag->name);
569  }
570  pj_end(pj);
572  break;
573  }
574  case RZ_OUTPUT_MODE_LONG: {
575  rz_cons_printf("%s:\n", tag);
577  if (!flags) {
578  break;
579  }
580  RzListIter *iter;
581  RzFlagItem *flag;
582  rz_list_foreach (flags, iter, flag) {
583  rz_cons_printf("0x%08" PFMT64x " %s\n", flag->offset, flag->name);
584  }
586  break;
587  }
589  rz_cons_printf("%s\n", tag);
590  break;
591  default:
593  break;
594  }
595 }
#define rz_warn_if_reached()
Definition: rz_assert.h:29
RZ_API PJ * pj_k(PJ *j, const char *k)
Definition: pj.c:104
RZ_API PJ * pj_end(PJ *j)
Definition: pj.c:87
RZ_API PJ * pj_s(PJ *j, const char *k)
Definition: pj.c:197
RZ_API PJ * pj_a(PJ *j)
Definition: pj.c:81
@ RZ_OUTPUT_MODE_LONG
Definition: rz_types.h:44
@ RZ_OUTPUT_MODE_JSON
Definition: rz_types.h:40
@ RZ_OUTPUT_MODE_STANDARD
Definition: rz_types.h:39
#define PFMT64x
Definition: rz_types.h:393
Definition: rz_pj.h:12
char * name
Definition: rz_flag.h:35
Definition: dis.h:43
RZ_API RzList * rz_flag_tags_get(RzFlag *f, const char *name)
Definition: tags.c:53

References rz_core_t::flags, flags, rz_flag_item_t::name, rz_flag_item_t::offset, PFMT64x, pj_a(), pj_end(), pj_k(), pj_s(), rz_cons_printf(), rz_flag_tags_get(), rz_list_free(), RZ_OUTPUT_MODE_JSON, RZ_OUTPUT_MODE_LONG, RZ_OUTPUT_MODE_STANDARD, rz_warn_if_reached, and test-lz4-versions::tag.

Referenced by rz_flag_tag_list_handler().

◆ flag_to_flag()

static int flag_to_flag ( RzCore core,
const char *  glob 
)
static

Definition at line 538 of file cmd_flag.c.

538  {
539  rz_return_val_if_fail(glob, 0);
540  glob = rz_str_trim_head_ro(glob);
541  struct flag_to_flag_t u = { .next = UT64_MAX, .offset = core->offset };
543  if (u.next != UT64_MAX && u.next > core->offset) {
544  return u.next - core->offset;
545  }
546  return 0;
547 }
static bool flag_to_flag_foreach(RzFlagItem *fi, void *user)
Definition: cmd_flag.c:530
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
RZ_API const char * rz_str_trim_head_ro(const char *str)
Definition: str_trim.c:86
#define UT64_MAX
Definition: rz_types_base.h:86
ut64 offset
Definition: rz_core.h:301

References flag_to_flag_foreach(), rz_core_t::flags, flag_to_flag_t::next, rz_core_t::offset, rz_flag_foreach_glob(), rz_return_val_if_fail, rz_str_trim_head_ro(), and UT64_MAX.

Referenced by rz_flag_distance_handler().

◆ flag_to_flag_foreach()

static bool flag_to_flag_foreach ( RzFlagItem fi,
void *  user 
)
static

Definition at line 530 of file cmd_flag.c.

530  {
531  struct flag_to_flag_t *u = (struct flag_to_flag_t *)user;
532  if (fi->offset < u->next && fi->offset > u->offset) {
533  u->next = fi->offset;
534  }
535  return true;
536 }

References flag_to_flag_t::next, flag_to_flag_t::offset, and rz_flag_item_t::offset.

Referenced by flag_to_flag().

◆ flag_zone_list()

static void flag_zone_list ( RzFlag f,
RzCmdStateOutput state 
)
static

Definition at line 439 of file cmd_flag.c.

439  {
440  if (!f->zones) {
441  return;
442  }
443  RzListIter *iter;
444  RzFlagZoneItem *zi;
445  PJ *pj = state->d.pj;
447  rz_list_foreach (f->zones, iter, zi) {
448  switch (state->mode) {
449  case RZ_OUTPUT_MODE_JSON:
450  pj_o(pj);
451  pj_ks(pj, "name", zi->name);
452  pj_ki(pj, "from", zi->from);
453  pj_ki(pj, "to", zi->to);
454  pj_end(pj);
455  break;
457  rz_cons_printf("0x08%" PFMT64x " 0x%08" PFMT64x " %s\n",
458  zi->from, zi->to, zi->name);
459  break;
460  default:
462  break;
463  }
464  }
466 }
RZ_API void rz_cmd_state_output_array_start(RzCmdStateOutput *state)
Mark the start of an array of elements in the output.
Definition: cmd_api.c:2558
RZ_API void rz_cmd_state_output_array_end(RzCmdStateOutput *state)
Mark the end of an array of elements in the output.
Definition: cmd_api.c:2572
RZ_API PJ * pj_ki(PJ *j, const char *k, int d)
Definition: pj.c:149
RZ_API PJ * pj_o(PJ *j)
Definition: pj.c:75
RZ_API PJ * pj_ks(PJ *j, const char *k, const char *v)
Definition: pj.c:170

References f, rz_flag_zone_item_t::from, rz_flag_zone_item_t::name, PFMT64x, pj_end(), pj_ki(), pj_ks(), pj_o(), rz_cmd_state_output_array_end(), rz_cmd_state_output_array_start(), rz_cons_printf(), RZ_OUTPUT_MODE_JSON, RZ_OUTPUT_MODE_STANDARD, rz_warn_if_reached, and rz_flag_zone_item_t::to.

Referenced by rz_flag_zone_list_handler().

◆ flagbar_foreach()

static bool flagbar_foreach ( RzFlagItem fi,
void *  user 
)
static

Definition at line 500 of file cmd_flag.c.

500  {
501  struct flagbar_t *u = (struct flagbar_t *)user;
502  ut64 min = 0, max = rz_io_size(u->core->io);
503  RzIOMap *m = rz_io_map_get(u->core->io, fi->offset);
504  if (m) {
505  min = m->itv.addr;
506  max = m->itv.addr + m->itv.size;
507  }
508  rz_cons_printf("0x%08" PFMT64x " ", fi->offset);
509  rz_print_rangebar(u->core->print, fi->offset, fi->offset + fi->size, min, max, u->cols);
510  rz_cons_printf(" %s\n", fi->name);
511  return true;
512 }
int max
Definition: enough.c:225
RZ_API void rz_print_rangebar(RzPrint *p, ut64 startA, ut64 endA, ut64 min, ut64 max, int cols)
Definition: print.c:1283
#define min(a, b)
Definition: qsort.h:83
RZ_API ut64 rz_io_size(RzIO *io)
Definition: io.c:399
RZ_API RzIOMap * rz_io_map_get(RzIO *io, ut64 addr)
Definition: io_map.c:176
RzCore * core
Definition: cmd_flag.c:496
int cols
Definition: cmd_flag.c:497
RzIO * io
Definition: rz_core.h:313
RzPrint * print
Definition: rz_core.h:327
ut64(WINAPI *w32_GetEnabledXStateFeatures)()

References flagbar_t::cols, flagbar_t::core, rz_core_t::io, regress::m, max, min, rz_flag_item_t::name, rz_flag_item_t::offset, PFMT64x, rz_core_t::print, rz_cons_printf(), rz_io_map_get(), rz_io_size(), rz_print_rangebar(), rz_flag_item_t::size, and ut64().

Referenced by flagbars().

◆ flagbars()

static void flagbars ( RzCore core,
const char *  glob 
)
static

Definition at line 514 of file cmd_flag.c.

514  {
515  int cols = rz_cons_get_size(NULL);
516  cols -= 80;
517  if (cols < 0) {
518  cols += 80;
519  }
520 
521  struct flagbar_t u = { .core = core, .cols = cols };
522  rz_flag_foreach_space_glob(core->flags, glob, rz_flag_space_cur(core->flags), flagbar_foreach, &u);
523 }
static bool flagbar_foreach(RzFlagItem *fi, void *user)
Definition: cmd_flag.c:500
RZ_API int rz_cons_get_size(int *rows)
Definition: cons.c:1446
RZ_API void rz_flag_foreach_space_glob(RzFlag *f, const char *glob, const RzSpace *space, RzFlagItemCb cb, void *user)
Definition: flag.c:822

References flagbar_t::cols, flagbar_t::core, flagbar_foreach(), rz_core_t::flags, NULL, rz_cons_get_size(), and rz_flag_foreach_space_glob().

Referenced by rz_flag_list_ascii_handler().

◆ listFlag()

static bool listFlag ( RzFlagItem flag,
void *  user 
)
static

Definition at line 9 of file cmd_flag.c.

9  {
10  rz_list_append(user, flag);
11  return true;
12 }

References rz_list_append().

Referenced by rz_flag_graph_handler().

◆ print_function_labels_cb()

static bool print_function_labels_cb ( void *  user,
const ut64  addr,
const void *  v 
)
static

Definition at line 166 of file cmd_flag.c.

166  {
167  const PrintFcnLabelsCtx *ctx = user;
168  const char *name = v;
169  switch (ctx->state->mode) {
170  case RZ_OUTPUT_MODE_JSON:
171  pj_o(ctx->state->d.pj);
172  pj_kn(ctx->state->d.pj, name, addr);
173  pj_end(ctx->state->d.pj);
174  break;
176  rz_cons_printf("%s\n", name);
177  break;
179  rz_cons_printf("0x%08" PFMT64x " %s [%s + %" PFMT64d "]\n",
180  addr,
181  name, ctx->fcn->name,
182  addr - ctx->fcn->addr);
183  break;
184  default:
186  break;
187  }
188  return true;
189 }
const char * v
Definition: dsignal.c:12
RZ_API PJ * pj_kn(PJ *j, const char *k, ut64 n)
Definition: pj.c:121
#define PFMT64d
Definition: rz_types.h:394
@ RZ_OUTPUT_MODE_QUIET
Definition: rz_types.h:42
static int addr
Definition: z80asm.c:58

References addr, PFMT64d, PFMT64x, pj_end(), pj_kn(), pj_o(), rz_cons_printf(), RZ_OUTPUT_MODE_JSON, RZ_OUTPUT_MODE_QUIET, RZ_OUTPUT_MODE_STANDARD, rz_warn_if_reached, and v.

Referenced by rz_flag_local_list_all_handler(), and rz_flag_local_list_handler().

◆ print_space_stack()

static void print_space_stack ( RzFlag f,
int  ordinal,
const char *  name,
bool  selected,
RzCmdStateOutput state 
)
static

Definition at line 660 of file cmd_flag.c.

660  {
661  switch (state->mode) {
662  case RZ_OUTPUT_MODE_JSON: {
663  char *ename = rz_str_escape(name);
664  if (!ename) {
665  return;
666  }
667  pj_o(state->d.pj);
668  pj_ki(state->d.pj, "ordinal", ordinal);
669  pj_ks(state->d.pj, "name", ename);
670  pj_kb(state->d.pj, "selected", selected);
671  pj_end(state->d.pj);
672  free(ename);
673  break;
674  }
675  default:
676  rz_cons_printf("%-2d %s%s\n", ordinal, name, selected ? " (selected)" : "");
677  break;
678  }
679 }
RZ_API PJ * pj_kb(PJ *j, const char *k, bool v)
Definition: pj.c:177
RZ_API RZ_OWN char * rz_str_escape(RZ_NONNULL const char *buf)
Definition: str.c:1550

References free(), pj_end(), pj_kb(), pj_ki(), pj_ks(), pj_o(), rz_cons_printf(), RZ_OUTPUT_MODE_JSON, and rz_str_escape().

Referenced by rz_flag_space_stack_list_handler().

◆ rename_flag_ordinal()

static bool rename_flag_ordinal ( RzFlagItem fi,
void *  user 
)
static

Definition at line 632 of file cmd_flag.c.

632  {
633  struct rename_flag_t *u = (struct rename_flag_t *)user;
634  char *newName = rz_str_newf("%s%d", u->pfx, u->count++);
635  if (!newName) {
636  return false;
637  }
638  rz_flag_rename(u->core->flags, fi, newName);
639  free(newName);
640  return true;
641 }
RZ_API int rz_flag_rename(RzFlag *f, RzFlagItem *item, const char *name)
Definition: flag.c:587
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1

References rename_flag_t::core, rename_flag_t::count, rz_core_t::flags, free(), rename_flag_t::pfx, rz_flag_rename(), and rz_str_newf().

Referenced by flag_ordinals().

◆ rz_core_flag_describe()

RZ_IPI void rz_core_flag_describe ( RzCore core,
ut64  addr,
bool  strict_offset,
RzCmdStateOutput state 
)

Definition at line 327 of file cmd_flag.c.

327  {
328  RzFlagItem *f = rz_flag_get_at(core->flags, addr, !strict_offset);
329  if (!f) {
330  return;
331  }
332  PJ *pj = state->d.pj;
333  switch (state->mode) {
334  case RZ_OUTPUT_MODE_JSON:
335  pj_o(pj);
336  pj_kn(pj, "offset", f->offset);
337  pj_ks(pj, "name", f->name);
338  // Print flag's real name if defined
339  if (f->realname) {
340  pj_ks(pj, "realname", f->realname);
341  }
342  pj_end(pj);
343  break;
345  // Print realname if exists and asm.flags.real is enabled
346  const char *name = core->flags->realnames && f->realname ? f->realname : f->name;
347  if (f->offset != addr) {
348  rz_cons_printf("%s + %d\n", name, (int)(addr - f->offset));
349  } else {
351  }
352  break;
353  }
354  default:
356  break;
357  }
358 }
RZ_API void rz_cons_println(const char *str)
Definition: cons.c:233
RZ_API RzFlagItem * rz_flag_get_at(RzFlag *f, ut64 off, bool closest)
Definition: flag.c:404
bool realnames
Definition: rz_flag.h:49

References addr, f, rz_core_t::flags, pj_end(), pj_kn(), pj_ks(), pj_o(), rz_flag_t::realnames, rz_cons_printf(), rz_cons_println(), rz_flag_get_at(), RZ_OUTPUT_MODE_JSON, RZ_OUTPUT_MODE_STANDARD, and rz_warn_if_reached.

Referenced by rz_core_visual_xrefs(), and rz_flag_describe_handler().

◆ rz_flag_add_handler()

RZ_IPI RzCmdStatus rz_flag_add_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 207 of file cmd_flag.c.

207  {
208  RzFlagItem *item;
209  bool addFlag = true;
210  ut64 size = argc > 2 ? rz_num_math(core->num, argv[2]) : 1;
211  if ((item = rz_flag_get_at(core->flags, core->offset, false))) {
212  RZ_LOG_ERROR("Cannot create flag \"%s\" at 0x%" PFMT64x
213  " because there is already \"%s\" flag\n",
214  argv[1],
215  core->offset, item->name);
216  addFlag = false;
217  }
218  if (addFlag) {
219  item = rz_flag_set(core->flags, argv[1], core->offset, size);
220  }
221  if (!item) {
222  RZ_LOG_ERROR("Cannot create flag \"%s\" at 0x%" PFMT64x "\n", argv[1], core->offset);
223  return RZ_CMD_STATUS_ERROR;
224  }
225  if (argc > 3) {
226  return bool2status(flag_set_comment(item, argv[3]));
227  }
228  return RZ_CMD_STATUS_OK;
229 }
static bool flag_set_comment(RzFlagItem *item, const char *comment)
Definition: cmd_flag.c:191
static RzCmdStatus bool2status(bool val)
Definition: core_private.h:208
RZ_API RzFlagItem * rz_flag_set(RzFlag *f, const char *name, ut64 off, ut32 size)
Definition: flag.c:521
voidpf void uLong size
Definition: ioapi.h:138
static static fork const void static count static fd const char const char static newpath char char argv
Definition: sflib.h:40
@ RZ_CMD_STATUS_OK
command handler exited in the right way
Definition: rz_cmd.h:24
@ RZ_CMD_STATUS_ERROR
command handler had issues while running (e.g. allocation error, etc.)
Definition: rz_cmd.h:26
RZ_API ut64 rz_num_math(RzNum *num, const char *str)
Definition: unum.c:456
RzNum * num
Definition: rz_core.h:316

References argv, bool2status(), flag_set_comment(), rz_core_t::flags, rz_flag_item_t::name, rz_core_t::num, rz_core_t::offset, PFMT64x, RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_flag_get_at(), rz_flag_set(), RZ_LOG_ERROR, rz_num_math(), and ut64().

Referenced by rzshell_cmddescs_init().

◆ rz_flag_alias_handler()

RZ_IPI RzCmdStatus rz_flag_alias_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 752 of file cmd_flag.c.

752  {
753  RzFlagItem *fi = rz_flag_get(core->flags, argv[1]);
754  if (!fi) {
755  fi = rz_flag_set(core->flags, argv[1], core->offset, 1);
756  }
757  if (!fi) {
758  RZ_LOG_ERROR("Cannot find flag '%s'\n", argv[1]);
759  return RZ_CMD_STATUS_ERROR;
760  }
762  return RZ_CMD_STATUS_OK;
763 }
RZ_API void rz_flag_item_set_alias(RzFlagItem *item, const char *alias)
Definition: flag.c:557

References argv, rename_flag_t::core, rz_core_t::flags, rz_core_t::offset, RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_flag_get(), rz_flag_item_set_alias(), rz_flag_set(), and RZ_LOG_ERROR.

Referenced by rzshell_cmddescs_init().

◆ rz_flag_append_handler()

RZ_IPI RzCmdStatus rz_flag_append_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 231 of file cmd_flag.c.

231  {
232  ut64 size = argc > 2 ? rz_num_math(core->num, argv[2]) : 1;
233  RzFlagItem *item = rz_flag_set(core->flags, argv[1], core->offset, size);
234  if (!item) {
235  RZ_LOG_ERROR("Cannot create flag \"%s\" at 0x%" PFMT64x "\n", argv[1], core->offset);
236  return RZ_CMD_STATUS_ERROR;
237  }
238  if (argc > 3) {
239  return bool2status(flag_set_comment(item, argv[3]));
240  }
241  return RZ_CMD_STATUS_OK;
242 }

References argv, bool2status(), flag_set_comment(), rz_core_t::flags, rz_core_t::num, rz_core_t::offset, PFMT64x, RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_flag_set(), RZ_LOG_ERROR, rz_num_math(), and ut64().

Referenced by rzshell_cmddescs_init().

◆ rz_flag_base_handler()

RZ_IPI RzCmdStatus rz_flag_base_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 765 of file cmd_flag.c.

765  {
766  if (argc > 2) {
767  RzFlag *f = core->flags;
768  ut64 base = rz_num_math(core->num, argv[1]);
770  } else {
771  core->flags->base = rz_num_math(core->num, argv[1]);
772  }
773  return RZ_CMD_STATUS_OK;
774 }
static bool adjust_offset(RzFlagItem *flag, void *user)
Definition: cmd_flag.c:654
st64 base
Definition: rz_flag.h:48

References adjust_offset(), argv, rz_flag_t::base, rename_flag_t::core, f, rz_core_t::flags, rz_core_t::num, RZ_CMD_STATUS_OK, rz_flag_foreach_glob(), rz_num_math(), and ut64().

Referenced by rzshell_cmddescs_init().

◆ rz_flag_color_handler()

RZ_IPI RzCmdStatus rz_flag_color_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 834 of file cmd_flag.c.

834  {
835  RzFlagItem *fi = rz_flag_get(core->flags, argv[1]);
836  if (!fi) {
837  RZ_LOG_ERROR("Cannot find the flag '%s'\n", argv[1]);
838  return RZ_CMD_STATUS_ERROR;
839  }
840  const char *ret = rz_flag_item_set_color(fi, argv[2]);
841  if (ret) {
842  rz_cons_println(ret);
843  }
844  return RZ_CMD_STATUS_OK;
845 }
RZ_API const char * rz_flag_item_set_color(RzFlagItem *item, const char *color)
Definition: flag.c:578

References argv, rename_flag_t::core, rz_core_t::flags, RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_cons_println(), rz_flag_get(), rz_flag_item_set_color(), and RZ_LOG_ERROR.

Referenced by rzshell_cmddescs_init().

◆ rz_flag_comment_handler()

RZ_IPI RzCmdStatus rz_flag_comment_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 847 of file cmd_flag.c.

847  {
848  RzFlagItem *item;
849  if (argc > 2) {
850  item = rz_flag_get(core->flags, argv[1]);
851  if (!item) {
852  RZ_LOG_ERROR("Cannot find flag with name '%s'\n", argv[1]);
853  return RZ_CMD_STATUS_ERROR;
854  }
855  return bool2status(flag_set_comment(item, argv[2]));
856  } else {
857  item = rz_flag_get_i(core->flags, rz_num_math(core->num, argv[1]));
858  if (item && item->comment) {
859  rz_cons_println(item->comment);
860  } else {
861  RZ_LOG_ERROR("Cannot find the flag\n");
862  return RZ_CMD_STATUS_ERROR;
863  }
864  }
865  return RZ_CMD_STATUS_OK;
866 }
RZ_API RzFlagItem * rz_flag_get_i(RzFlag *f, ut64 off)
Definition: flag.c:317
char * comment
Definition: rz_flag.h:42

References argv, bool2status(), rz_flag_item_t::comment, rename_flag_t::core, flag_set_comment(), rz_core_t::flags, rz_core_t::num, RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_cons_println(), rz_flag_get(), rz_flag_get_i(), RZ_LOG_ERROR, and rz_num_math().

Referenced by rzshell_cmddescs_init().

◆ rz_flag_describe_at_handler()

RZ_IPI RzCmdStatus rz_flag_describe_at_handler ( RzCore core,
int  argc,
const char **  argv,
RzCmdStateOutput state 
)

Definition at line 365 of file cmd_flag.c.

365  {
366  const RzList *flags = rz_flag_get_list(core->flags, core->offset);
367  if (!flags) {
368  return RZ_CMD_STATUS_OK;
369  }
370  PJ *pj = state->d.pj;
372  RzFlagItem *flag;
373  RzListIter *iter;
374  // Sometimes an address has multiple flags assigned to, show them all
375  rz_list_foreach (flags, iter, flag) {
376  if (!flag) {
377  continue;
378  }
379  switch (state->mode) {
380  case RZ_OUTPUT_MODE_JSON:
381  pj_o(pj);
382  pj_ks(pj, "name", flag->name);
383  if (flag->realname) {
384  pj_ks(pj, "realname", flag->realname);
385  }
386  pj_end(pj);
387  break;
389  // Print realname if exists and asm.flags.real is enabled
390  if (core->flags->realnames && flag->realname) {
391  rz_cons_println(flag->realname);
392  } else {
393  rz_cons_println(flag->name);
394  }
395  break;
396  default:
398  break;
399  }
400  }
402  return RZ_CMD_STATUS_OK;
403 }
RZ_API const RzList * rz_flag_get_list(RzFlag *f, ut64 off)
Definition: flag.c:475
char * realname
Definition: rz_flag.h:36

References rz_core_t::flags, flags, rz_flag_item_t::name, rz_core_t::offset, pj_end(), pj_ks(), pj_o(), rz_flag_item_t::realname, rz_flag_t::realnames, rz_cmd_state_output_array_end(), rz_cmd_state_output_array_start(), RZ_CMD_STATUS_OK, rz_cons_println(), rz_flag_get_list(), RZ_OUTPUT_MODE_JSON, RZ_OUTPUT_MODE_STANDARD, and rz_warn_if_reached.

Referenced by rzshell_cmddescs_init().

◆ rz_flag_describe_closest_handler()

RZ_IPI RzCmdStatus rz_flag_describe_closest_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 405 of file cmd_flag.c.

405  {
406  RzList *temp = rz_flag_all_list(core->flags, true);
407  if (!temp) {
408  return RZ_CMD_STATUS_OK;
409  }
410  ut64 loff = 0;
411  ut64 uoff = 0;
412  ut64 curseek = core->offset;
413  char *lmatch = NULL, *umatch = NULL;
414  RzFlagItem *flag;
415  RzListIter *iter;
416  rz_list_sort(temp, &cmpflag);
417  rz_list_foreach (temp, iter, flag) {
418  if (strstr(flag->name, argv[1]) != NULL) {
419  if (flag->offset < core->offset) {
420  loff = flag->offset;
421  lmatch = flag->name;
422  continue;
423  }
424  uoff = flag->offset;
425  umatch = flag->name;
426  break;
427  }
428  }
429  char *match = (curseek - loff) < (uoff - curseek) ? lmatch : umatch;
430  if (match) {
431  if (*match) {
433  }
434  }
435  rz_list_free(temp);
436  return RZ_CMD_STATUS_OK;
437 }
static int cmpflag(const void *_a, const void *_b)
Definition: cmd_flag.c:322
RZ_API RzList * rz_flag_all_list(RzFlag *f, bool by_space)
Definition: flag.c:463
RZ_API void rz_list_sort(RZ_NONNULL RzList *list, RZ_NONNULL RzListComparator cmp)
Sorts via merge sort or via insertion sort a list.
Definition: list.c:743
Definition: engine.c:71

References argv, cmpflag(), rz_core_t::flags, rz_flag_item_t::name, NULL, rz_core_t::offset, rz_flag_item_t::offset, RZ_CMD_STATUS_OK, rz_cons_println(), rz_flag_all_list(), rz_list_free(), rz_list_sort(), and ut64().

Referenced by rzshell_cmddescs_init().

◆ rz_flag_describe_handler()

RZ_IPI RzCmdStatus rz_flag_describe_handler ( RzCore core,
int  argc,
const char **  argv,
RzCmdStateOutput state 
)

Definition at line 360 of file cmd_flag.c.

360  {
361  rz_core_flag_describe(core, core->offset, false, state);
362  return RZ_CMD_STATUS_OK;
363 }
RZ_IPI void rz_core_flag_describe(RzCore *core, ut64 addr, bool strict_offset, RzCmdStateOutput *state)
Definition: cmd_flag.c:327

References rz_core_t::offset, RZ_CMD_STATUS_OK, and rz_core_flag_describe().

Referenced by rzshell_cmddescs_init().

◆ rz_flag_distance_handler()

RZ_IPI RzCmdStatus rz_flag_distance_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 786 of file cmd_flag.c.

786  {
787  rz_cons_printf("%d\n", flag_to_flag(core, argv[1]));
788  return RZ_CMD_STATUS_OK;
789 }
static int flag_to_flag(RzCore *core, const char *glob)
Definition: cmd_flag.c:538

References argv, rename_flag_t::core, flag_to_flag(), RZ_CMD_STATUS_OK, and rz_cons_printf().

Referenced by rzshell_cmddescs_init().

◆ rz_flag_exists_handler()

RZ_IPI RzCmdStatus rz_flag_exists_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 776 of file cmd_flag.c.

776  {
777  RzFlagItem *item = rz_flag_get(core->flags, argv[1]);
778  if (!item) {
779  RZ_LOG_ERROR("Cannot find flag '%s'\n", argv[1]);
780  return RZ_CMD_STATUS_ERROR;
781  }
782  RZ_LOG_DEBUG("Find flag '%s' at 0x%" PFMT64x "\n", argv[1], item->offset);
783  return RZ_CMD_STATUS_OK;
784 }
#define RZ_LOG_DEBUG(fmtstr,...)
Definition: rz_log.h:49

References argv, rename_flag_t::core, rz_core_t::flags, rz_flag_item_t::offset, PFMT64x, RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_flag_get(), RZ_LOG_DEBUG, and RZ_LOG_ERROR.

Referenced by rzshell_cmddescs_init().

◆ rz_flag_graph_handler()

RZ_IPI RzCmdStatus rz_flag_graph_handler ( RzCore core,
int  argc,
const char **  argv,
RzCmdStateOutput state 
)

Definition at line 298 of file cmd_flag.c.

298  {
300  rz_flag_foreach_space(core->flags, rz_flag_space_cur(core->flags), listFlag, flags);
301  if (!argv[1]) {
302  __printRecursive(core, flags, "", state->mode, 0);
303  } else {
304  __printRecursive(core, flags, argv[1], state->mode, 0);
305  }
307  return RZ_CMD_STATUS_OK;
308 }
static bool listFlag(RzFlagItem *flag, void *user)
Definition: cmd_flag.c:9
RZ_API void rz_flag_foreach_space(RzFlag *f, const RzSpace *space, RzFlagItemCb cb, void *user)
Definition: flag.c:826

References __printRecursive(), argv, rz_core_t::flags, flags, listFlag(), NULL, RZ_CMD_STATUS_OK, rz_flag_foreach_space(), rz_list_free(), and rz_list_newf().

Referenced by rzshell_cmddescs_init().

◆ rz_flag_hexdump_handler()

RZ_IPI RzCmdStatus rz_flag_hexdump_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 889 of file cmd_flag.c.

889  {
890  char cmd[128];
891  ut64 address = rz_num_math(core->num, argv[1]);
892  RzFlagItem *item = rz_flag_get_i(core->flags, address);
893  if (!item) {
894  RZ_LOG_ERROR("Cannot find flag '%s'\n", argv[1]);
895  return RZ_CMD_STATUS_ERROR;
896  }
897  rz_cons_printf("0x%08" PFMT64x "\n", item->offset);
898  // FIXME: Use the API directly instead of calling the command
899  snprintf(cmd, sizeof(cmd), "px@%" PFMT64d ":%" PFMT64d, item->offset, item->size);
900  rz_core_cmd0(core, cmd);
901  return RZ_CMD_STATUS_OK;
902 }
RZ_API int rz_core_cmd0(RzCore *core, const char *cmd)
Definition: cmd.c:5428
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags cmd
Definition: sflib.h:79
snprintf
Definition: kernel.h:364

References argv, cmd, rename_flag_t::core, rz_core_t::flags, rz_core_t::num, rz_flag_item_t::offset, PFMT64d, PFMT64x, RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_cons_printf(), rz_core_cmd0(), rz_flag_get_i(), RZ_LOG_ERROR, rz_num_math(), rz_flag_item_t::size, snprintf, and ut64().

Referenced by rzshell_cmddescs_init().

◆ rz_flag_length_handler()

RZ_IPI RzCmdStatus rz_flag_length_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 796 of file cmd_flag.c.

796  {
797  RzFlagItem *item = rz_flag_get_i(core->flags, core->offset);
798  if (!item) {
799  RZ_LOG_ERROR("Cannot find flag at 0x%" PFMT64x " offset\n", core->offset);
800  return RZ_CMD_STATUS_ERROR;
801  }
802  if (argc < 2) {
803  rz_cons_printf("0x%08" PFMT64x "\n", item->size);
804  } else {
805  item->size = rz_num_math(core->num, argv[1]);
806  }
807  return RZ_CMD_STATUS_OK;
808 }

References argv, rename_flag_t::core, rz_core_t::flags, rz_core_t::num, rz_core_t::offset, PFMT64x, RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_cons_printf(), rz_flag_get_i(), RZ_LOG_ERROR, rz_num_math(), and rz_flag_item_t::size.

Referenced by rzshell_cmddescs_init().

◆ rz_flag_list_ascii_handler()

RZ_IPI RzCmdStatus rz_flag_list_ascii_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 825 of file cmd_flag.c.

825  {
826  if (argc > 1) {
827  flagbars(core, argv[1]);
828  } else {
829  flagbars(core, NULL);
830  }
831  return RZ_CMD_STATUS_OK;
832 }
static void flagbars(RzCore *core, const char *glob)
Definition: cmd_flag.c:514

References argv, rename_flag_t::core, flagbars(), NULL, and RZ_CMD_STATUS_OK.

Referenced by rzshell_cmddescs_init().

◆ rz_flag_list_at_handler()

RZ_IPI RzCmdStatus rz_flag_list_at_handler ( RzCore core,
int  argc,
const char **  argv,
RzCmdStateOutput state 
)

Definition at line 914 of file cmd_flag.c.

914  {
915  rz_core_flag_range_print(core->flags, state, core->offset, core->offset + 1);
916  return RZ_CMD_STATUS_OK;
917 }
RZ_IPI void rz_core_flag_range_print(RzFlag *f, RzCmdStateOutput *state, ut64 range_from, ut64 range_to)
Definition: cflag.c:184

References rename_flag_t::core, rz_core_t::flags, rz_core_t::offset, RZ_CMD_STATUS_OK, and rz_core_flag_range_print().

Referenced by rzshell_cmddescs_init().

◆ rz_flag_list_handler()

RZ_IPI RzCmdStatus rz_flag_list_handler ( RzCore core,
int  argc,
const char **  argv,
RzCmdStateOutput state 
)

Definition at line 919 of file cmd_flag.c.

919  {
921  return RZ_CMD_STATUS_OK;
922 }
RZ_IPI void rz_core_flag_print(RzFlag *f, RzCmdStateOutput *state)
Definition: cflag.c:169

References rename_flag_t::core, rz_core_t::flags, RZ_CMD_STATUS_OK, and rz_core_flag_print().

Referenced by rzshell_cmddescs_init().

◆ rz_flag_local_add_handler()

RZ_IPI RzCmdStatus rz_flag_local_add_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 244 of file cmd_flag.c.

244  {
246  if (!fcn) {
247  RZ_LOG_ERROR("Cannot find function at 0x%" PFMT64x " offset\n", core->offset);
248  return RZ_CMD_STATUS_ERROR;
249  }
251  return RZ_CMD_STATUS_OK;
252 }
RZ_DEPRECATE RZ_API RzAnalysisFunction * rz_analysis_get_fcn_in(RzAnalysis *analysis, ut64 addr, int type)
Definition: fcn.c:1687
RZ_API bool rz_analysis_function_set_label(RzAnalysisFunction *fcn, const char *name, ut64 addr)
Definition: labels.c:20
RzAnalysis * analysis
Definition: rz_core.h:322

References rz_core_t::analysis, argv, rz_core_t::offset, PFMT64x, rz_analysis_function_set_label(), rz_analysis_get_fcn_in(), RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, and RZ_LOG_ERROR.

Referenced by rzshell_cmddescs_init().

◆ rz_flag_local_list_all_handler()

RZ_IPI RzCmdStatus rz_flag_local_list_all_handler ( RzCore core,
int  argc,
const char **  argv,
RzCmdStateOutput state 
)

Definition at line 277 of file cmd_flag.c.

277  {
278  RzAnalysisFunction *fcn;
279  RzListIter *it;
281  rz_list_foreach (core->analysis->fcns, it, fcn) {
282  if (!fcn->labels->count) {
283  continue;
284  }
285  if (state->mode == RZ_OUTPUT_MODE_JSON) {
286  pj_k(state->d.pj, fcn->name);
287  }
288  PrintFcnLabelsCtx ctx = { fcn, state };
289  ht_up_foreach(fcn->labels, print_function_labels_cb, &ctx);
290  if (state->mode == RZ_OUTPUT_MODE_JSON) {
291  pj_end(state->d.pj);
292  }
293  }
295  return RZ_CMD_STATUS_OK;
296 }
static bool print_function_labels_cb(void *user, const ut64 addr, const void *v)
Definition: cmd_flag.c:166
RzList * fcns
Definition: rz_analysis.h:565

References rz_core_t::analysis, rz_analysis_t::fcns, rz_analysis_function_t::labels, rz_analysis_function_t::name, pj_end(), pj_k(), print_function_labels_cb(), rz_cmd_state_output_array_end(), rz_cmd_state_output_array_start(), RZ_CMD_STATUS_OK, and RZ_OUTPUT_MODE_JSON.

Referenced by rzshell_cmddescs_init().

◆ rz_flag_local_list_handler()

RZ_IPI RzCmdStatus rz_flag_local_list_handler ( RzCore core,
int  argc,
const char **  argv,
RzCmdStateOutput state 
)

◆ rz_flag_local_remove_handler()

RZ_IPI RzCmdStatus rz_flag_local_remove_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 254 of file cmd_flag.c.

254  {
256  if (!fcn) {
257  RZ_LOG_ERROR("Cannot find function at 0x%" PFMT64x " offset\n", core->offset);
258  return RZ_CMD_STATUS_ERROR;
259  }
261  return RZ_CMD_STATUS_OK;
262 }
RZ_API bool rz_analysis_function_delete_label(RzAnalysisFunction *fcn, const char *name)
Definition: labels.c:34

References rz_core_t::analysis, argv, rz_core_t::offset, PFMT64x, rz_analysis_function_delete_label(), rz_analysis_get_fcn_in(), RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, and RZ_LOG_ERROR.

Referenced by rzshell_cmddescs_init().

◆ rz_flag_move_handler()

RZ_IPI RzCmdStatus rz_flag_move_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 791 of file cmd_flag.c.

791  {
792  ut64 address = rz_num_math(core->num, argv[1]);
793  return bool2status(rz_flag_move(core->flags, core->offset, address));
794 }
RZ_API bool rz_flag_move(RzFlag *f, ut64 at, ut64 to)
Definition: flag.c:741

References argv, bool2status(), rename_flag_t::core, rz_core_t::flags, rz_core_t::num, rz_core_t::offset, rz_flag_move(), rz_num_math(), and ut64().

Referenced by rzshell_cmddescs_init().

◆ rz_flag_ordinals_handler()

RZ_IPI RzCmdStatus rz_flag_ordinals_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 868 of file cmd_flag.c.

868  {
869  flag_ordinals(core, argv[1]);
870  return RZ_CMD_STATUS_OK;
871 }
static void flag_ordinals(RzCore *core, const char *glob)
Definition: cmd_flag.c:643

References argv, rename_flag_t::core, flag_ordinals(), and RZ_CMD_STATUS_OK.

Referenced by rzshell_cmddescs_init().

◆ rz_flag_range_handler()

RZ_IPI RzCmdStatus rz_flag_range_handler ( RzCore core,
int  argc,
const char **  argv,
RzCmdStateOutput state 
)

Definition at line 904 of file cmd_flag.c.

904  {
905  if (argc > 1) {
906  ut64 size = rz_num_math(core->num, argv[1]);
907  rz_core_flag_range_print(core->flags, state, core->offset, core->offset + size);
908  } else {
909  rz_core_flag_range_print(core->flags, state, core->offset, core->offset + core->blocksize);
910  }
911  return RZ_CMD_STATUS_OK;
912 }
ut32 blocksize
Definition: rz_core.h:303

References argv, rz_core_t::blocksize, rename_flag_t::core, rz_core_t::flags, rz_core_t::num, rz_core_t::offset, RZ_CMD_STATUS_OK, rz_core_flag_range_print(), rz_num_math(), and ut64().

Referenced by rzshell_cmddescs_init().

◆ rz_flag_realname_handler()

RZ_IPI RzCmdStatus rz_flag_realname_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 810 of file cmd_flag.c.

810  {
811  RzFlagItem *item = argc > 1 ? rz_flag_get(core->flags, argv[1])
812  : rz_flag_get_i(core->flags, core->offset);
813  if (!item) {
814  RZ_LOG_ERROR("Cannot find flag\n");
815  return RZ_CMD_STATUS_ERROR;
816  }
817  if (argc < 3) {
818  rz_cons_printf("%s\n", item->realname);
819  } else {
821  }
822  return RZ_CMD_STATUS_OK;
823 }
RZ_API void rz_flag_item_set_realname(RzFlagItem *item, const char *realname)
Definition: flag.c:571
voidpf uLong offset
Definition: ioapi.h:144

References argv, rename_flag_t::core, rz_core_t::flags, rz_core_t::offset, rz_flag_item_t::realname, RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_cons_printf(), rz_flag_get(), rz_flag_get_i(), rz_flag_item_set_realname(), and RZ_LOG_ERROR.

Referenced by rzshell_cmddescs_init().

◆ rz_flag_relocate_handler()

RZ_IPI RzCmdStatus rz_flag_relocate_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 310 of file cmd_flag.c.

310  {
311  ut64 mask = 0xffff;
312  if (argc > 3) {
313  mask = rz_num_math(core->num, argv[3]);
314  }
315  ut64 from = rz_num_math(core->num, argv[1]);
316  ut64 to = rz_num_math(core->num, argv[2]);
317  int ret = rz_flag_relocate(core->flags, from, mask, to);
318  RZ_LOG_INFO("Relocated %d flags\n", ret);
319  return RZ_CMD_STATUS_OK;
320 }
#define mask()
RZ_API int rz_flag_relocate(RzFlag *f, ut64 off, ut64 off_mask, ut64 to)
Definition: flag.c:726
#define RZ_LOG_INFO(fmtstr,...)
Definition: rz_log.h:54
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr from
Definition: sfsocketcall.h:123
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr socklen_t static fromlen const void const struct sockaddr to
Definition: sfsocketcall.h:125

References argv, rz_core_t::flags, from, mask, rz_core_t::num, RZ_CMD_STATUS_OK, rz_flag_relocate(), RZ_LOG_INFO, rz_num_math(), to, and ut64().

Referenced by rzshell_cmddescs_init().

◆ rz_flag_remove_all_handler()

RZ_IPI RzCmdStatus rz_flag_remove_all_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 747 of file cmd_flag.c.

747  {
748  rz_flag_unset_all(core->flags);
749  return RZ_CMD_STATUS_OK;
750 }
RZ_API void rz_flag_unset_all(RzFlag *f)
Definition: flag.c:677

References rename_flag_t::core, rz_core_t::flags, RZ_CMD_STATUS_OK, and rz_flag_unset_all().

Referenced by rzshell_cmddescs_init().

◆ rz_flag_remove_handler()

RZ_IPI RzCmdStatus rz_flag_remove_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 737 of file cmd_flag.c.

737  {
738  if (argc < 2) {
739  return bool2status(rz_flag_unset_all_off(core->flags, core->offset));
740  }
741  if (rz_flag_unset_glob(core->flags, argv[1]) < 0) {
742  return RZ_CMD_STATUS_ERROR;
743  }
744  return RZ_CMD_STATUS_OK;
745 }
RZ_API bool rz_flag_unset_all_off(RzFlag *f, ut64 off)
Definition: flag.c:635
RZ_API int rz_flag_unset_glob(RzFlag *f, const char *glob)
Definition: flag.c:660

References argv, bool2status(), rename_flag_t::core, rz_core_t::flags, rz_core_t::offset, RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_flag_unset_all_off(), and rz_flag_unset_glob().

Referenced by rzshell_cmddescs_init().

◆ rz_flag_rename_handler()

RZ_IPI RzCmdStatus rz_flag_rename_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 873 of file cmd_flag.c.

873  {
874  RzFlagItem *item = rz_flag_get(core->flags, argv[1]);
875  if (!item && !strncmp(argv[1], "fcn.", 4)) {
876  item = rz_flag_get(core->flags, argv[1] + 4);
877  }
878  if (!item) {
879  RZ_LOG_ERROR("Cannot find matching flag\n");
880  return RZ_CMD_STATUS_ERROR;
881  }
882  if (!rz_flag_rename(core->flags, item, argv[2])) {
883  RZ_LOG_ERROR("Invalid new flag name\n");
884  return RZ_CMD_STATUS_ERROR;
885  }
886  return RZ_CMD_STATUS_OK;
887 }

References argv, rename_flag_t::core, rz_core_t::flags, RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_flag_get(), rz_flag_rename(), and RZ_LOG_ERROR.

Referenced by rzshell_cmddescs_init().

◆ rz_flag_space_add_handler()

RZ_IPI RzCmdStatus rz_flag_space_add_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 681 of file cmd_flag.c.

681  {
682  return bool2status(rz_flag_space_set(core->flags, argv[1]));
683 }

References argv, bool2status(), rename_flag_t::core, and rz_core_t::flags.

Referenced by rzshell_cmddescs_init().

◆ rz_flag_space_list_handler()

RZ_IPI RzCmdStatus rz_flag_space_list_handler ( RzCore core,
int  argc,
const char **  argv,
RzCmdStateOutput state 
)

Definition at line 685 of file cmd_flag.c.

685  {
686  rz_core_spaces_print(core, &core->flags->spaces, state);
687  return RZ_CMD_STATUS_OK;
688 }
RZ_IPI void rz_core_spaces_print(RzCore *core, RzSpaces *spaces, RzCmdStateOutput *state)
Definition: cmeta.c:9
RzSpaces spaces
Definition: rz_flag.h:47

References rename_flag_t::core, rz_core_t::flags, RZ_CMD_STATUS_OK, rz_core_spaces_print(), and rz_flag_t::spaces.

Referenced by rzshell_cmddescs_init().

◆ rz_flag_space_move_handler()

RZ_IPI RzCmdStatus rz_flag_space_move_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 690 of file cmd_flag.c.

690  {
691  RzFlagItem *f = rz_flag_get_i(core->flags, core->offset);
692  if (!f) {
693  RZ_LOG_ERROR("Cannot find any flag at 0x%" PFMT64x ".\n", core->offset);
694  return RZ_CMD_STATUS_ERROR;
695  }
696  f->space = rz_flag_space_cur(core->flags);
697  return RZ_CMD_STATUS_OK;
698 }

References rename_flag_t::core, f, rz_core_t::flags, rz_core_t::offset, PFMT64x, RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_flag_get_i(), and RZ_LOG_ERROR.

Referenced by rzshell_cmddescs_init().

◆ rz_flag_space_remove_all_handler()

RZ_IPI RzCmdStatus rz_flag_space_remove_all_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 709 of file cmd_flag.c.

709  {
710  return bool2status(rz_flag_space_unset(core->flags, NULL));
711 }

References bool2status(), rename_flag_t::core, rz_core_t::flags, and NULL.

Referenced by rzshell_cmddescs_init().

◆ rz_flag_space_remove_handler()

RZ_IPI RzCmdStatus rz_flag_space_remove_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 700 of file cmd_flag.c.

700  {
701  const RzSpace *sp = rz_flag_space_cur(core->flags);
702  if (!sp) {
703  RZ_LOG_ERROR("No flag space currently selected.\n");
704  return RZ_CMD_STATUS_ERROR;
705  }
706  return bool2status(rz_flag_space_unset(core->flags, sp->name));
707 }
static int sp
Definition: z80asm.c:91

References bool2status(), rename_flag_t::core, rz_core_t::flags, RZ_CMD_STATUS_ERROR, RZ_LOG_ERROR, and sp.

Referenced by rzshell_cmddescs_init().

◆ rz_flag_space_rename_handler()

RZ_IPI RzCmdStatus rz_flag_space_rename_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 713 of file cmd_flag.c.

713  {
714  return bool2status(rz_flag_space_rename(core->flags, NULL, argv[1]));
715 }

References argv, bool2status(), rename_flag_t::core, rz_core_t::flags, and NULL.

Referenced by rzshell_cmddescs_init().

◆ rz_flag_space_stack_list_handler()

RZ_IPI RzCmdStatus rz_flag_space_stack_list_handler ( RzCore core,
int  argc,
const char **  argv,
RzCmdStateOutput state 
)

Definition at line 725 of file cmd_flag.c.

725  {
726  RzListIter *iter;
727  char *space;
728  int i = 0;
729  rz_list_foreach (core->flags->spaces.spacestack, iter, space) {
730  print_space_stack(core->flags, i++, space, false, state);
731  }
732  const char *cur_name = rz_flag_space_cur_name(core->flags);
733  print_space_stack(core->flags, i++, cur_name, true, state);
734  return RZ_CMD_STATUS_OK;
735 }
lzma_index ** i
Definition: index.h:629
static void print_space_stack(RzFlag *f, int ordinal, const char *name, bool selected, RzCmdStateOutput *state)
Definition: cmd_flag.c:660
RzList * spacestack
Definition: rz_spaces.h:60

References rename_flag_t::core, rz_core_t::flags, i, print_space_stack(), RZ_CMD_STATUS_OK, rz_flag_t::spaces, and rz_spaces_t::spacestack.

Referenced by rzshell_cmddescs_init().

◆ rz_flag_space_stack_pop_handler()

RZ_IPI RzCmdStatus rz_flag_space_stack_pop_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 721 of file cmd_flag.c.

721  {
722  return bool2status(rz_flag_space_pop(core->flags));
723 }

References bool2status(), rename_flag_t::core, and rz_core_t::flags.

Referenced by rzshell_cmddescs_init().

◆ rz_flag_space_stack_push_handler()

RZ_IPI RzCmdStatus rz_flag_space_stack_push_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 717 of file cmd_flag.c.

717  {
718  return bool2status(rz_flag_space_push(core->flags, argv[1]));
719 }

References argv, bool2status(), rename_flag_t::core, and rz_core_t::flags.

Referenced by rzshell_cmddescs_init().

◆ rz_flag_tag_add_handler()

RZ_IPI RzCmdStatus rz_flag_tag_add_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 549 of file cmd_flag.c.

549  {
550  rz_flag_tags_set(core->flags, argv[1], argv[2]);
551  return RZ_CMD_STATUS_OK;
552 }
RZ_API void rz_flag_tags_set(RzFlag *f, const char *name, const char *words)
Definition: tags.c:6

References argv, rz_core_t::flags, RZ_CMD_STATUS_OK, and rz_flag_tags_set().

Referenced by rzshell_cmddescs_init().

◆ rz_flag_tag_list_handler()

RZ_IPI RzCmdStatus rz_flag_tag_list_handler ( RzCore core,
int  argc,
const char **  argv,
RzCmdStateOutput state 
)

Definition at line 597 of file cmd_flag.c.

597  {
599  if (!list) {
600  return RZ_CMD_STATUS_ERROR;
601  }
602  RzListIter *iter;
603  const char *tag;
605  rz_list_foreach (list, iter, tag) {
606  flag_tag_print(core, tag, state);
607  }
610  return RZ_CMD_STATUS_OK;
611 }
static void flag_tag_print(RzCore *core, const char *tag, RzCmdStateOutput *state)
Definition: cmd_flag.c:554
RZ_API RZ_OWN RzList * rz_flag_tags_list(RzFlag *f)
Definition: tags.c:12

References flag_tag_print(), rz_core_t::flags, list(), rz_cmd_state_output_array_end(), rz_cmd_state_output_array_start(), RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_flag_tags_list(), rz_list_free(), and test-lz4-versions::tag.

Referenced by rzshell_cmddescs_init().

◆ rz_flag_tag_search_handler()

RZ_IPI RzCmdStatus rz_flag_tag_search_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 613 of file cmd_flag.c.

613  {
614  RzList *flags = rz_flag_tags_get(core->flags, argv[1]);
615  if (!flags) {
616  return RZ_CMD_STATUS_ERROR;
617  }
618  RzListIter *iter;
619  RzFlagItem *flag;
620  rz_list_foreach (flags, iter, flag) {
621  rz_cons_printf("0x%08" PFMT64x " %s\n", flag->offset, flag->name);
622  }
623  return RZ_CMD_STATUS_OK;
624 }

References argv, rz_core_t::flags, flags, rz_flag_item_t::name, rz_flag_item_t::offset, PFMT64x, RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_cons_printf(), and rz_flag_tags_get().

Referenced by rzshell_cmddescs_init().

◆ rz_flag_zone_add_handler()

RZ_IPI RzCmdStatus rz_flag_zone_add_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 468 of file cmd_flag.c.

468  {
469  rz_flag_zone_add(core->flags, argv[1], core->offset);
470  return RZ_CMD_STATUS_OK;
471 }
RZ_API bool rz_flag_zone_add(RzFlag *f, const char *name, ut64 addr)
Definition: zones.c:29

References argv, rz_core_t::flags, rz_core_t::offset, RZ_CMD_STATUS_OK, and rz_flag_zone_add().

Referenced by rzshell_cmddescs_init().

◆ rz_flag_zone_around_handler()

RZ_IPI RzCmdStatus rz_flag_zone_around_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 483 of file cmd_flag.c.

483  {
484  const char *a = NULL, *b = NULL;
485  rz_flag_zone_around(core->flags, core->offset, &a, &b);
486  rz_cons_printf("%s %s\n", a ? a : "~", b ? b : "~");
487  return RZ_CMD_STATUS_OK;
488 }
RZ_API bool rz_flag_zone_around(RzFlag *f, ut64 addr, const char **prev, const char **next)
Definition: zones.c:75

References a, b, rz_core_t::flags, NULL, rz_core_t::offset, RZ_CMD_STATUS_OK, rz_cons_printf(), and rz_flag_zone_around().

Referenced by rzshell_cmddescs_init().

◆ rz_flag_zone_list_handler()

RZ_IPI RzCmdStatus rz_flag_zone_list_handler ( RzCore core,
int  argc,
const char **  argv,
RzCmdStateOutput state 
)

Definition at line 490 of file cmd_flag.c.

490  {
491  flag_zone_list(core->flags, state);
492  return RZ_CMD_STATUS_OK;
493 }
static void flag_zone_list(RzFlag *f, RzCmdStateOutput *state)
Definition: cmd_flag.c:439

References flag_zone_list(), rz_core_t::flags, and RZ_CMD_STATUS_OK.

Referenced by rzshell_cmddescs_init().

◆ rz_flag_zone_remove_all_handler()

RZ_IPI RzCmdStatus rz_flag_zone_remove_all_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 478 of file cmd_flag.c.

478  {
479  rz_flag_zone_reset(core->flags);
480  return RZ_CMD_STATUS_OK;
481 }
RZ_API bool rz_flag_zone_reset(RzFlag *f)
Definition: zones.c:51

References rz_core_t::flags, RZ_CMD_STATUS_OK, and rz_flag_zone_reset().

Referenced by rzshell_cmddescs_init().

◆ rz_flag_zone_remove_handler()

RZ_IPI RzCmdStatus rz_flag_zone_remove_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 473 of file cmd_flag.c.

473  {
474  rz_flag_zone_del(core->flags, argv[1]);
475  return RZ_CMD_STATUS_OK;
476 }
RZ_API bool rz_flag_zone_del(RzFlag *f, const char *name)
Definition: zones.c:57

References argv, rz_core_t::flags, RZ_CMD_STATUS_OK, and rz_flag_zone_del().

Referenced by rzshell_cmddescs_init().