Rizin
unix-like reverse engineering framework and cli tools
cmd_help.c File Reference
#include <stddef.h>
#include <math.h>
#include "rz_cons.h"
#include "rz_core.h"
#include "rz_util.h"

Go to the source code of this file.

Enumerations

enum  { RZ_AVATAR_ORANGG , RZ_AVATAR_CYBCAT , RZ_AVATAR_CLIPPY }
 

Functions

static ut32 vernum (const char *s)
 
static void cmd_help_exclamation (RzCore *core)
 
static void cmd_help_percent (RzCore *core)
 
static const char * findBreakChar (const char *s)
 
static char * filterFlags (RzCore *core, const char *msg)
 
RZ_API const char ** rz_core_help_vars_get (RzCore *core)
 Returns all the $ variable names in a NULL-terminated array. More...
 
RZ_API void rz_core_help_vars_print (RzCore *core)
 
RZ_API void rz_core_clippy (RzCore *core, const char *msg)
 
RZ_IPI int rz_cmd_help (void *data, const char *input)
 

Variables

static const char * help_msg_percent []
 
static const char * help_msg_env []
 
static const char * help_msg_exclamation []
 
static const char * help_msg_question_e []
 
static const char * help_msg_question []
 
static const char * help_msg_question_v []
 
static const char * help_msg_question_V []
 
static const char * help_msg_greater_sign []
 
static const char * avatar_orangg []
 
static const char * avatar_clippy []
 
static const char * avatar_clippy_utf8 []
 
static const char * avatar_cybcat []
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
RZ_AVATAR_ORANGG 
RZ_AVATAR_CYBCAT 
RZ_AVATAR_CLIPPY 

Definition at line 351 of file cmd_help.c.

351  {
355 };
@ RZ_AVATAR_ORANGG
Definition: cmd_help.c:352
@ RZ_AVATAR_CLIPPY
Definition: cmd_help.c:354
@ RZ_AVATAR_CYBCAT
Definition: cmd_help.c:353

Function Documentation

◆ cmd_help_exclamation()

static void cmd_help_exclamation ( RzCore core)
static

Definition at line 211 of file cmd_help.c.

211  {
214 }
RZ_API void rz_core_cmd_help(const RzCore *core, const char *help[])
Definition: cmd.c:163
static const char * help_msg_env[]
Definition: cmd_help.c:37
static const char * help_msg_exclamation[]
Definition: cmd_help.c:55

References help_msg_env, help_msg_exclamation, and rz_core_cmd_help().

Referenced by rz_cmd_help().

◆ cmd_help_percent()

static void cmd_help_percent ( RzCore core)
static

Definition at line 216 of file cmd_help.c.

216  {
219 }
static const char * help_msg_percent[]
Definition: cmd_help.c:25

References help_msg_env, help_msg_percent, and rz_core_cmd_help().

Referenced by rz_cmd_help().

◆ filterFlags()

static char* filterFlags ( RzCore core,
const char *  msg 
)
static

Definition at line 231 of file cmd_help.c.

231  {
232  const char *dollar, *end;
233  char *word, *buf = NULL;
234  for (;;) {
235  dollar = strchr(msg, '$');
236  if (!dollar) {
237  break;
238  }
239  buf = rz_str_appendlen(buf, msg, dollar - msg);
240  if (dollar[1] == '{') {
241  // find }
242  end = strchr(dollar + 2, '}');
243  if (end) {
244  word = rz_str_newlen(dollar + 2, end - dollar - 2);
245  end++;
246  } else {
247  msg = dollar + 1;
248  buf = rz_str_append(buf, "$");
249  continue;
250  }
251  } else {
252  end = findBreakChar(dollar + 1);
253  if (!end) {
254  end = dollar + strlen(dollar);
255  }
256  word = rz_str_newlen(dollar + 1, end - dollar - 1);
257  }
258  if (end && word) {
259  ut64 val = rz_num_math(core->num, word);
260  char num[32];
261  snprintf(num, sizeof(num), "0x%" PFMT64x, val);
262  buf = rz_str_append(buf, num);
263  msg = end;
264  } else {
265  break;
266  }
267  free(word);
268  }
269  buf = rz_str_append(buf, msg);
270  return buf;
271 }
ut16 val
Definition: armass64_const.h:6
static const char * findBreakChar(const char *s)
Definition: cmd_help.c:221
#define NULL
Definition: cris-opc.c:27
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
voidpf void * buf
Definition: ioapi.h:138
snprintf
Definition: kernel.h:364
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig const char static mode static oldfd struct tms static buf static getgid static geteuid const char static filename static arg static mask struct ustat static ubuf static getppid static setsid static egid sigset_t static set struct timeval struct timezone static tz fd_set fd_set fd_set struct timeval static timeout const char char static bufsiz const char static swapflags void static offset const char static length static mode static who const char struct statfs static buf unsigned unsigned num
Definition: sflib.h:126
RZ_API ut64 rz_num_math(RzNum *num, const char *str)
Definition: unum.c:456
RZ_API char * rz_str_append(char *ptr, const char *string)
Definition: str.c:1063
RZ_API char RZ_API char * rz_str_newlen(const char *str, int len)
Definition: str.c:871
RZ_API char * rz_str_appendlen(char *ptr, const char *string, int slen)
Definition: str.c:1043
#define PFMT64x
Definition: rz_types.h:393
static struct sockaddr static addrlen static backlog const void msg
Definition: sfsocketcall.h:119
RzNum * num
Definition: rz_core.h:316
ut64(WINAPI *w32_GetEnabledXStateFeatures)()

References test_evm::end, findBreakChar(), free(), msg, NULL, rz_core_t::num, num, PFMT64x, rz_num_math(), rz_str_append(), rz_str_appendlen(), rz_str_newlen(), snprintf, ut64(), and val.

Referenced by rz_cmd_help().

◆ findBreakChar()

static const char* findBreakChar ( const char *  s)
static

Definition at line 221 of file cmd_help.c.

221  {
222  while (*s) {
223  if (!rz_name_validate_char(*s, true)) {
224  break;
225  }
226  s++;
227  }
228  return s;
229 }
static RzSocket * s
Definition: rtr.c:28
RZ_API bool rz_name_validate_char(const char ch, bool strict)
Definition: name.c:6

References rz_name_validate_char(), and s.

Referenced by filterFlags().

◆ rz_cmd_help()

RZ_IPI int rz_cmd_help ( void *  data,
const char *  input 
)

Definition at line 419 of file cmd_help.c.

419  {
420  RzCore *core = (RzCore *)data;
421  RzIOMap *map;
422  const char *k;
423  RzListIter *iter;
424  char *p, out[128] = RZ_EMPTY;
425  ut64 n;
426  int i;
427  RzList *tmp;
428 
429  switch (input[0]) {
430  case '0': // "?0"
431  core->curtab = 0;
432  break;
433  case '1': // "?1"
434  if (core->curtab < 0) {
435  core->curtab = 0;
436  }
437  core->curtab++;
438  break;
439  case 'r': // "?r"
440  { // TODO : Add support for 64bit random numbers
441  ut64 b = 0;
442  ut32 r = UT32_MAX;
443  if (input[1]) {
444  strncpy(out, input + (input[1] == ' ' ? 2 : 1), sizeof(out) - 1);
445  p = strchr(out + 1, ' ');
446  if (p) {
447  *p = 0;
448  b = (ut32)rz_num_math(core->num, out);
449  r = (ut32)rz_num_math(core->num, p + 1) - b;
450  } else {
451  r = (ut32)rz_num_math(core->num, out);
452  }
453  } else {
454  r = 0LL;
455  }
456  if (!r) {
457  r = UT32_MAX >> 1;
458  }
459  core->num->value = (ut64)(b + rz_num_rand(r));
460  rz_cons_printf("0x%" PFMT64x "\n", core->num->value);
461  } break;
462  case 'a': // "?a"
464  break;
465  case 'b': // "?b"
466  if (input[1] == '6' && input[2] == '4') {
467  // b64 decoding takes at most strlen(str) * 4
468  const int buflen = (strlen(input + 3) * 4) + 1;
469  char *buf = calloc(buflen, sizeof(char));
470  if (!buf) {
471  return false;
472  }
473  if (input[3] == '-') {
474  rz_base64_decode((ut8 *)buf, input + 4, -1);
475  } else if (input[3] == ' ') {
476  const char *s = input + 4;
477  rz_base64_encode(buf, (const ut8 *)s, strlen(s));
478  }
480  free(buf);
481  } else if (input[1] == 't' && input[2] == 'w') { // "?btw"
482  if (rz_num_between(core->num, input + 3) == -1) {
483  eprintf("Usage: ?btw num|(expr) num|(expr) num|(expr)\n");
484  }
485  } else {
486  n = rz_num_math(core->num, input + 1);
487  rz_num_to_bits(out, n);
488  rz_cons_printf("%sb\n", out);
489  }
490  break;
491  case 'B': // "?B"
492  k = rz_str_trim_head_ro(input + 1);
493  tmp = rz_core_get_boundaries_prot(core, -1, k, "search");
494  if (!tmp) {
495  return false;
496  }
497  rz_list_foreach (tmp, iter, map) {
498  rz_cons_printf("0x%" PFMT64x " 0x%" PFMT64x "\n", map->itv.addr, rz_itv_end(map->itv));
499  }
500  rz_list_free(tmp);
501  break;
502  case 'h': // "?h"
503  if (input[1] == ' ') {
504  ut32 hash = (ut32)rz_str_djb2_hash(input + 2);
505  rz_cons_printf("0x%08x\n", hash);
506  } else {
507  eprintf("Usage: ?h [string-to-hash]\n");
508  }
509  break;
510  case 'F': // "?F"
511  rz_cons_flush();
512  break;
513  case 'f': // "?f"
514  if (input[1] == ' ') {
515  char *q, *p = strdup(input + 2);
516  if (!p) {
517  eprintf("Cannot strdup\n");
518  return 0;
519  }
520  q = strchr(p, ' ');
521  if (q) {
522  *q = 0;
523  n = rz_num_get(core->num, p);
524  rz_str_bits(out, (const ut8 *)&n, sizeof(n) * 8, q + 1);
526  } else {
527  eprintf("Usage: \"?b value bitstring\"\n");
528  }
529  free(p);
530  } else {
531  eprintf("Whitespace expected after '?f'\n");
532  }
533  break;
534  case 'o': // "?o"
535  n = rz_num_math(core->num, input + 1);
536  rz_cons_printf("0%" PFMT64o "\n", n);
537  break;
538  case 'T': // "?T"
539  rz_cons_printf("plug.init = %" PFMT64d "\n"
540  "plug.load = %" PFMT64d "\n"
541  "file.load = %" PFMT64d "\n",
542  core->times->loadlibs_init_time,
543  core->times->loadlibs_time,
544  core->times->file_open_time);
545  break;
546  case 'u': // "?u"
547  {
548  char unit[8];
549  n = rz_num_math(core->num, input + 1);
550  rz_num_units(unit, sizeof(unit), n);
551  rz_cons_println(unit);
552  } break;
553  case 'j': // "?j"
554  case ' ': // "? "
555  {
556  char *asnum, unit[8];
557  ut32 s, a;
558  double d;
559  float f;
560  char number[128];
561  char *const inputs = strdup(input + 1);
562  RzList *list = rz_num_str_split_list(inputs);
563  const int list_len = rz_list_length(list);
564  PJ *pj = NULL;
565  if (*input == 'j') {
566  pj = pj_new();
567  pj_o(pj);
568  }
569  for (i = 0; i < list_len; i++) {
570  const char *str = rz_list_pop_head(list);
571  if (!*str) {
572  continue;
573  }
574  n = rz_num_math(core->num, str);
575  if (core->num->dbz) {
576  eprintf("RzNum ERROR: Division by Zero\n");
577  }
578  asnum = rz_num_as_string(NULL, n, false);
579  /* decimal, hexa, octal */
580  s = n >> 16 << 12;
581  a = n & 0x0fff;
582  rz_num_units(unit, sizeof(unit), n);
583  if (*input == 'j') {
584  pj_ks(pj, "int32", rz_strf(number, "%d", (st32)(n & UT32_MAX)));
585  pj_ks(pj, "uint32", rz_strf(number, "%u", (ut32)n));
586  pj_ks(pj, "int64", rz_strf(number, "%" PFMT64d, (st64)n));
587  pj_ks(pj, "uint64", rz_strf(number, "%" PFMT64u, (ut64)n));
588  pj_ks(pj, "hex", rz_strf(number, "0x%08" PFMT64x, n));
589  pj_ks(pj, "octal", rz_strf(number, "0%" PFMT64o, n));
590  pj_ks(pj, "unit", unit);
591  pj_ks(pj, "segment", rz_strf(number, "%04x:%04x", s, a));
592 
593  } else {
594  if (n >> 32) {
595  rz_cons_printf("int64 %" PFMT64d "\n", (st64)n);
596  rz_cons_printf("uint64 %" PFMT64u "\n", (ut64)n);
597  } else {
598  rz_cons_printf("int32 %d\n", (st32)n);
599  rz_cons_printf("uint32 %u\n", (ut32)n);
600  }
601  rz_cons_printf("hex 0x%" PFMT64x "\n", n);
602  rz_cons_printf("octal 0%" PFMT64o "\n", n);
603  rz_cons_printf("unit %s\n", unit);
604  rz_cons_printf("segment %04x:%04x\n", s, a);
605 
606  if (asnum) {
607  rz_cons_printf("string \"%s\"\n", asnum);
608  free(asnum);
609  }
610  }
611  /* binary and floating point */
612  rz_str_bits64(out, n);
613  f = d = core->num->fvalue;
614  /* adjust sign for nan floats, different libcs are confused */
615  if (isnan(f) && signbit(f)) {
616  f = -f;
617  }
618  if (isnan(d) && signbit(d)) {
619  d = -d;
620  }
621  if (*input == 'j') {
622  pj_ks(pj, "fvalue", rz_strf(number, "%.1lf", core->num->fvalue));
623  pj_ks(pj, "float", rz_strf(number, "%ff", f));
624  pj_ks(pj, "double", rz_strf(number, "%lf", d));
625  pj_ks(pj, "binary", rz_strf(number, "0b%s", out));
627  pj_ks(pj, "trits", rz_strf(number, "0t%s", out));
628  } else {
629  rz_cons_printf("fvalue %.1lf\n", core->num->fvalue);
630  rz_cons_printf("float %ff\n", f);
631  rz_cons_printf("double %lf\n", d);
632  rz_cons_printf("binary 0b%s\n", out);
633 
634  /* ternary */
636  rz_cons_printf("trits 0t%s\n", out);
637  }
638  }
639  if (*input == 'j') {
640  pj_end(pj);
641  }
642  free(inputs);
644  if (pj) {
645  rz_cons_printf("%s\n", pj_string(pj));
646  pj_free(pj);
647  }
648  } break;
649  case 'q': // "?q"
650  if (core->num->dbz) {
651  eprintf("RzNum ERROR: Division by Zero\n");
652  }
653  if (input[1] == '?') {
654  rz_cons_printf("|Usage: ?q [num] # Update $? without printing anything\n"
655  "|?q 123; ?? x # hexdump if 123 != 0");
656  } else {
657  const char *space = strchr(input, ' ');
658  if (space) {
659  n = rz_num_math(core->num, space + 1);
660  } else {
661  n = rz_num_math(core->num, "$?");
662  }
663  core->num->value = n; // redundant
664  }
665  break;
666  case 'v': // "?v"
667  {
668  const char *space = strchr(input, ' ');
669  if (space) {
670  n = rz_num_math(core->num, space + 1);
671  } else {
672  n = rz_num_math(core->num, "$?");
673  }
674  }
675  if (core->num->dbz) {
676  eprintf("RzNum ERROR: Division by Zero\n");
677  }
678  switch (input[1]) {
679  case '?':
680  rz_cons_printf("|Usage: ?v[id][ num] # Show value\n"
681  "|?vx number -> show 8 digit padding in hex\n"
682  "|?vi1 200 -> 1 byte size value (char)\n"
683  "|?vi2 0xffff -> 2 byte size value (short)\n"
684  "|?vi4 0xffff -> 4 byte size value (int)\n"
685  "|?vi8 0xffff -> 8 byte size value (st64)\n"
686  "| No argument shows $? value\n"
687  "|?vi will show in decimal instead of hex\n");
688  break;
689  case '\0':
690  rz_cons_printf("%d\n", (st32)n);
691  break;
692  case 'x': // "?vx"
693  rz_cons_printf("0x%08" PFMT64x "\n", n);
694  break;
695  case 'i': // "?vi"
696  switch (input[2]) {
697  case '1': // byte
698  rz_cons_printf("%d\n", (st8)(n & UT8_MAX));
699  break;
700  case '2': // word
701  rz_cons_printf("%d\n", (st16)(n & UT16_MAX));
702  break;
703  case '4': // dword
704  rz_cons_printf("%d\n", (st32)(n & UT32_MAX));
705  break;
706  case '8': // qword
707  rz_cons_printf("%" PFMT64d "\n", (st64)(n & UT64_MAX));
708  break;
709  default:
710  rz_cons_printf("%" PFMT64d "\n", n);
711  break;
712  }
713  break;
714  case 'd':
715  rz_cons_printf("%" PFMT64d "\n", n);
716  break;
717  default:
718  rz_cons_printf("0x%" PFMT64x "\n", n);
719  }
720  core->num->value = n; // redundant
721  break;
722  case '=': // "?=" set num->value
723  if (input[1] == '=') { // ?==
724  if (input[2] == ' ') {
725  char *s = strdup(input + 3);
726  char *e = strchr(s, ' ');
727  if (e) {
728  *e++ = 0;
729  core->num->value = strcmp(s, e);
730  } else {
731  eprintf("Missing secondary word in expression to compare\n");
732  }
733  free(s);
734  } else {
735  eprintf("Usage: ?== str1 str2\n");
736  }
737  } else {
738  if (input[1]) { // ?=
739  rz_num_math(core->num, input + 1);
740  } else {
741  rz_cons_printf("0x%" PFMT64x "\n", core->num->value);
742  }
743  }
744  break;
745  case '+': // "?+"
746  if (input[1]) {
747  st64 n = (st64)core->num->value;
748  if (n > 0) {
749  rz_core_cmd(core, input + 1, 0);
750  }
751  } else {
752  rz_cons_printf("0x%" PFMT64x "\n", core->num->value);
753  }
754  break;
755  case '-': // "?-"
756  if (input[1]) {
757  st64 n = (st64)core->num->value;
758  if (n < 0) {
759  rz_core_cmd(core, input + 1, 0);
760  }
761  } else {
762  rz_cons_printf("0x%" PFMT64x "\n", core->num->value);
763  }
764  break;
765  case '!': // "?!"
766  if (input[1]) {
767  if (!core->num->value) {
768  if (input[1] == '?') {
769  cmd_help_exclamation(core);
770  return 0;
771  }
772  return core->num->value = rz_core_cmd(core, input + 1, 0);
773  }
774  } else {
775  rz_cons_printf("0x%" PFMT64x "\n", core->num->value);
776  }
777  break;
778  case '@': // "?@"
779  if (input[1] == '@') {
780  if (input[2] == '@') {
782  } else {
784  }
785  } else {
787  }
788  break;
789  case '&': // "?&"
790  helpCmdTasks(core);
791  break;
792  case '%': // "?%"
793  if (input[1] == '?') {
794  cmd_help_percent(core);
795  }
796  break;
797  case '$': // "?$"
798  if (input[1] == '?') {
800  } else {
802  }
803  return true;
804  case 'V': // "?V"
805  switch (input[1]) {
806  case '?': // "?V?"
808  break;
809  case 0: { // "?V"
810  char *v = rz_str_version(NULL);
811  rz_cons_printf("%s\n", v);
812  free(v);
813  break;
814  }
815  case 'c': // "?Vc"
816  rz_cons_printf("%d\n", vernum(RZ_VERSION));
817  break;
818  case 'j': // "?Vj"
819  {
820  PJ *pj = pj_new();
821  pj_o(pj);
822  pj_ks(pj, "arch", RZ_SYS_ARCH);
823  pj_ks(pj, "os", RZ_SYS_OS);
824  pj_ki(pj, "bits", RZ_SYS_BITS);
825  pj_ki(pj, "major", RZ_VERSION_MAJOR);
826  pj_ki(pj, "minor", RZ_VERSION_MINOR);
827  pj_ki(pj, "patch", RZ_VERSION_PATCH);
828  pj_ki(pj, "number", RZ_VERSION_NUMBER);
829  pj_ki(pj, "nversion", vernum(RZ_VERSION));
830  pj_ks(pj, "version", RZ_VERSION);
831  pj_end(pj);
832  rz_cons_printf("%s\n", pj_string(pj));
833  pj_free(pj);
834  } break;
835  case 'n': // "?Vn"
837  break;
838  case 'q': // "?Vq"
840  break;
841  case '0':
843  break;
844  case '1':
846  break;
847  case '2':
849  break;
850  }
851  break;
852  case 'l': // "?l"
853  if (input[1] == 'q') {
854  for (input += 2; input[0] == ' '; input++)
855  ;
856  core->num->value = strlen(input);
857  } else {
858  for (input++; input[0] == ' '; input++)
859  ;
860  core->num->value = strlen(input);
861  rz_cons_printf("%" PFMT64d "\n", core->num->value);
862  }
863  break;
864  case 'X': // "?X"
865  for (input++; input[0] == ' '; input++)
866  ;
867  n = rz_num_math(core->num, input);
868  rz_cons_printf("%" PFMT64x "\n", n);
869  break;
870  case 'x': // "?x"
871  for (input++; input[0] == ' '; input++)
872  ;
873  if (*input == '-') {
874  ut8 *out = malloc(strlen(input) + 1);
875  if (out) {
876  int len = rz_hex_str2bin(input + 1, out);
877  if (len >= 0) {
878  out[len] = 0;
879  rz_cons_println((const char *)out);
880  } else {
881  eprintf("Error parsing the hexpair string\n");
882  }
883  free(out);
884  }
885  } else if (*input == '+') {
886  ut64 n = rz_num_math(core->num, input);
887  int bits = rz_num_to_bits(NULL, n) / 8;
888  for (i = 0; i < bits; i++) {
889  rz_cons_printf("%02x", (ut8)((n >> (i * 8)) & 0xff));
890  }
891  rz_cons_newline();
892  } else {
893  if (*input == ' ') {
894  input++;
895  }
896  for (i = 0; input[i]; i++) {
897  rz_cons_printf("%02x", input[i]);
898  }
899  rz_cons_newline();
900  }
901  break;
902  case 'E': // "?E" clippy echo
904  break;
905  case 'e': // "?e" echo
906  switch (input[1]) {
907  case 't': // "?et newtitle"
909  break;
910  case '=': { // "?e="
911  ut64 pc = rz_num_math(core->num, input + 2);
912  rz_print_progressbar(core->print, pc, 80);
913  rz_cons_newline();
914  break;
915  }
916  case 'c': // "?ec" column
917  rz_cons_column(rz_num_math(core->num, input + 2));
918  break;
919  case 'g': { // "?eg" gotoxy
920  int x = atoi(input + 2);
921  char *arg = strchr(input + 2, ' ');
922  int y = arg ? atoi(arg + 1) : 0;
923  rz_cons_gotoxy(x, y);
924  } break;
925  case 'n': { // "?en" echo -n
926  const char *msg = rz_str_trim_head_ro(input + 2);
927  // TODO: replace all ${flagname} by its value in hexa
928  char *newmsg = filterFlags(core, msg);
929  rz_str_unescape(newmsg);
930  rz_cons_print(newmsg);
931  free(newmsg);
932  break;
933  }
934  case ' ': {
935  const char *msg = rz_str_trim_head_ro(input + 1);
936  // TODO: replace all ${flagname} by its value in hexa
937  char *newmsg = filterFlags(core, msg);
938  rz_str_unescape(newmsg);
939  rz_cons_println(newmsg);
940  free(newmsg);
941  } break;
942  case 0:
943  rz_cons_newline();
944  break;
945  default:
947  break;
948  }
949  break;
950  case 's': { // "?s" sequence from to step
951  ut64 from, to, step;
952  char *p, *p2;
953  for (input++; *input == ' '; input++)
954  ;
955  p = strchr(input, ' ');
956  if (p) {
957  *p = '\0';
958  from = rz_num_math(core->num, input);
959  p2 = strchr(p + 1, ' ');
960  if (p2) {
961  *p2 = '\0';
962  step = rz_num_math(core->num, p2 + 1);
963  } else {
964  step = 1;
965  }
966  to = rz_num_math(core->num, p + 1);
967  for (; from <= to; from += step)
968  rz_cons_printf("%" PFMT64d " ", from);
969  rz_cons_newline();
970  }
971  break;
972  }
973  case 'P': { // "?P" physical to virtual address conversion
974  ut64 n = (input[0] && input[1]) ? rz_num_math(core->num, input + 2) : core->offset;
975  ut64 vaddr = rz_io_p2v(core->io, n);
976  if (vaddr == UT64_MAX) {
977  rz_cons_printf("no map at 0x%08" PFMT64x "\n", n);
978  } else {
979  rz_cons_printf("0x%08" PFMT64x "\n", vaddr);
980  }
981  break;
982  }
983  case 'p': { // "?p" virtual to physical address conversion
984  ut64 n = (input[0] && input[1]) ? rz_num_math(core->num, input + 2) : core->offset;
985  ut64 paddr = rz_io_v2p(core->io, n);
986  if (paddr == UT64_MAX) {
987  rz_cons_printf("no map at 0x%08" PFMT64x "\n", n);
988  } else {
989  rz_cons_printf("0x%08" PFMT64x "\n", paddr);
990  }
991  break;
992  }
993  case '_': // "?_" hud input
994  rz_core_yank_hud_file(core, input + 1);
995  break;
996  case 'i': // "?i" input num
997  rz_cons_set_raw(0);
998  if (!rz_cons_is_interactive()) {
999  eprintf("Not running in interactive mode\n");
1000  } else {
1001  switch (input[1]) {
1002  case 'f': // "?if"
1003  core->num->value = !rz_num_conditional(core->num, input + 2);
1004  eprintf("%s\n", rz_str_bool(!core->num->value));
1005  break;
1006  case 'm': // "?im"
1007  rz_cons_message(input + 2);
1008  break;
1009  case 'p': // "?ip"
1010  core->num->value = rz_core_yank_hud_path(core, input + 2, 0) == true;
1011  break;
1012  case 'k': // "?ik"
1014  break;
1015  case 'y': // "?iy"
1016  for (input += 2; *input == ' '; input++)
1017  ;
1018  core->num->value = rz_cons_yesno(1, "%s? (Y/n)", input);
1019  break;
1020  case 'n': // "?in"
1021  for (input += 2; *input == ' '; input++)
1022  ;
1023  core->num->value = rz_cons_yesno(0, "%s? (y/N)", input);
1024  break;
1025  default: {
1026  char foo[1024];
1027  rz_cons_flush();
1028  for (input++; *input == ' '; input++)
1029  ;
1030  // TODO: rz_cons_input()
1031  snprintf(foo, sizeof(foo) - 1, "%s: ", input);
1033  rz_cons_fgets(foo, sizeof(foo), 0, NULL);
1034  foo[sizeof(foo) - 1] = 0;
1035  rz_core_yank_set_str(core, RZ_CORE_FOREIGN_ADDR, foo);
1036  core->num->value = rz_num_math(core->num, foo);
1037  } break;
1038  }
1039  }
1040  rz_cons_set_raw(0);
1041  break;
1042  case 'w': { // "?w"
1043  ut64 addr = rz_num_math(core->num, input + 1);
1044  char *rstr = core->print->hasrefs(core->print->user, addr, true);
1045  if (!rstr) {
1046  eprintf("Cannot get refs\n");
1047  break;
1048  }
1049  rz_cons_println(rstr);
1050  free(rstr);
1051  break;
1052  }
1053  case 't': { // "?t"
1055  rz_core_cmd(core, input + 1, 0);
1057  double seconds = (double)(end - start) / RZ_USEC_PER_SEC;
1058  core->num->value = (ut64)seconds;
1059  eprintf("%lf\n", seconds);
1060  break;
1061  }
1062  case '?': // "??"
1063  if (input[1] == '?') {
1064  if (input[2] == '?') { // "???"
1065  rz_core_clippy(core, "What are you doing?");
1066  return 0;
1067  }
1068  if (input[2]) {
1069  if (core->num->value) {
1070  rz_core_cmd(core, input + 1, 0);
1071  }
1072  break;
1073  }
1075  return 0;
1076  } else if (input[1]) {
1077  if (core->num->value) {
1078  core->num->value = rz_core_cmd(core, input + 1, 0);
1079  }
1080  } else {
1081  if (core->num->dbz) {
1082  eprintf("RzNum ERROR: Division by Zero\n");
1083  }
1084  rz_cons_printf("%" PFMT64d "\n", core->num->value);
1085  }
1086  break;
1087  case '\0': // "?"
1088  default:
1089  break;
1090  }
1091  return 0;
1092 }
size_t len
Definition: 6502dis.c:15
#define e(frag)
lzma_index ** i
Definition: index.h:629
int bits(struct state *s, int need)
Definition: blast.c:72
const lzma_allocator const uint8_t size_t uint8_t * out
Definition: block.h:528
RZ_API int rz_core_cmd(RzCore *core, const char *cstr, int log)
Definition: cmd.c:5328
static void cmd_help_exclamation(RzCore *core)
Definition: cmd_help.c:211
static const char * help_msg_question_v[]
Definition: cmd_help.c:132
RZ_API void rz_core_help_vars_print(RzCore *core)
Definition: cmd_help.c:370
static const char * help_msg_question_V[]
Definition: cmd_help.c:188
static char * filterFlags(RzCore *core, const char *msg)
Definition: cmd_help.c:231
RZ_API void rz_core_clippy(RzCore *core, const char *msg)
Definition: cmd_help.c:385
static ut32 vernum(const char *s)
Definition: cmd_help.c:10
static const char * help_msg_question_e[]
Definition: cmd_help.c:72
static void cmd_help_percent(RzCore *core)
Definition: cmd_help.c:216
static const char * help_msg_question[]
Definition: cmd_help.c:82
static const char * help_msg_at_at[]
Definition: cmd_print.c:154
static void helpCmdTasks(RzCore *core)
Definition: cmd_print.c:1085
static const char * help_msg_at_at_at[]
Definition: cmd_print.c:175
static const char * help_msg_at[]
Definition: cmd_print.c:102
RZ_API RZ_OWN RzList * rz_core_get_boundaries_prot(RzCore *core, int perm, const char *mode, const char *prefix)
Definition: cmd_search.c:577
RZ_API void rz_cons_set_raw(bool is_raw)
Definition: cons.c:1617
RZ_API void rz_cons_set_title(const char *str)
Definition: cons.c:1733
RZ_API void rz_cons_column(int c)
Definition: cons.c:1707
RZ_API void rz_cons_newline(void)
Definition: cons.c:1274
RZ_API int rz_cons_printf(const char *format,...)
Definition: cons.c:1202
RZ_API bool rz_cons_is_interactive(void)
Definition: cons.c:365
RZ_API void rz_cons_flush(void)
Definition: cons.c:959
RZ_API void rz_cons_println(const char *str)
Definition: cons.c:233
RZ_API void rz_cons_gotoxy(int x, int y)
Definition: cons.c:724
#define r
Definition: crypto_rc6.c:12
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 static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void start
Definition: sflib.h:133
uint32_t ut32
const char * k
Definition: dsignal.c:11
const char * v
Definition: dsignal.c:12
static states step(struct re_guts *, sopno, sopno, states, int, states)
Definition: engine.c:888
size_t map(int syms, int left, int len)
Definition: enough.c:237
RZ_API void rz_cons_message(RZ_NONNULL const char *msg)
Definition: hud.c:321
RZ_API int rz_cons_any_key(const char *msg)
Definition: input.c:393
RZ_API int rz_cons_fgets(char *buf, int len, int argc, const char **argv)
Definition: input.c:339
RZ_API bool rz_cons_yesno(int def, const char *fmt,...)
Definition: input.c:666
uint8_t ut8
Definition: lh5801.h:11
void * p
Definition: libc.cpp:67
static RzMain foo[]
Definition: main.c:11
static void list(RzEgg *egg)
Definition: rz-gg.c:52
RZ_API ut32 rz_list_length(RZ_NONNULL const RzList *list)
Returns the length of the list.
Definition: list.c:109
RZ_API RZ_OWN void * rz_list_pop_head(RZ_NONNULL RzList *list)
Removes and returns the first element of the list.
Definition: list.c:401
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
Definition: list.c:137
void * malloc(size_t size)
Definition: malloc.c:123
void * calloc(size_t number, size_t size)
Definition: malloc.c:102
RZ_API void rz_line_set_prompt(const char *prompt)
Definition: line.c:56
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")
int x
Definition: mipsasm.c:20
int n
Definition: mipsasm.c:19
RZ_API void rz_print_progressbar(RzPrint *p, int pc, int _cols)
Definition: print.c:1259
#define eprintf(x, y...)
Definition: rlcc.c:7
RZ_API const char * ret_ascii_table(void)
Definition: ascii_table.c:78
RZ_API size_t rz_base64_encode(char *bout, const ut8 *bin, size_t sz)
Definition: ubase64.c:81
RZ_API int rz_base64_decode(ut8 *bout, const char *bin, int len)
Definition: ubase64.c:48
RZ_API int rz_hex_str2bin(const char *in, ut8 *out)
Convert an input string in into the binary form in out.
Definition: hex.c:444
RZ_API ut64 rz_io_v2p(RzIO *io, ut64 va)
Definition: io.c:541
RZ_API ut64 rz_io_p2v(RzIO *io, ut64 pa)
Definition: io.c:533
static ut64 rz_itv_end(RzInterval itv)
Definition: rz_itv.h:42
RZ_API RzList * rz_num_str_split_list(char *str)
Definition: unum.c:905
RZ_API ut64 rz_num_get(RzNum *num, const char *str)
Definition: unum.c:172
RZ_API int rz_num_to_bits(char *out, ut64 num)
Definition: unum.c:542
RZ_API int rz_num_conditional(RzNum *num, const char *str)
Definition: unum.c:603
RZ_API int rz_num_to_trits(char *out, ut64 num)
Definition: unum.c:578
RZ_API char * rz_num_units(char *buf, size_t len, ut64 number)
Definition: unum.c:108
RZ_API int rz_num_between(RzNum *num, const char *input_value)
Definition: unum.c:826
RZ_API char * rz_num_as_string(RzNum *___, ut64 n, bool printable_only)
Definition: unum.c:705
RZ_API int rz_num_rand(int max)
Definition: unum.c:47
RZ_API PJ * pj_new(void)
Definition: pj.c:25
RZ_API PJ * pj_ki(PJ *j, const char *k, int d)
Definition: pj.c:149
RZ_API PJ * pj_end(PJ *j)
Definition: pj.c:87
RZ_API const char * pj_string(PJ *pj)
Definition: pj.c:57
RZ_API void pj_free(PJ *j)
Definition: pj.c:34
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
RZ_API ut64 rz_str_djb2_hash(const char *str)
Definition: str.c:383
RZ_API const char * rz_str_bool(int b)
Definition: str.c:3896
RZ_API int rz_str_bits64(char *strout, ut64 in)
Definition: str.c:244
RZ_API int rz_str_bits(char *strout, const ut8 *buf, int len, const char *bitz)
Definition: str.c:195
RZ_API const char * rz_str_trim_head_ro(const char *str)
Definition: str_trim.c:86
RZ_API char * rz_str_version(const char *program)
Definition: str.c:4051
RZ_API int rz_str_unescape(char *buf)
Definition: str.c:1300
#define rz_strf(buf,...)
Convenience macro for local temporary strings.
Definition: rz_str.h:59
#define RZ_USEC_PER_SEC
Definition: rz_time.h:9
RZ_API ut64 rz_time_now_mono(void)
Returns the current time in microseconds, using the monotonic clock.
Definition: time.c:102
#define PFMT64d
Definition: rz_types.h:394
#define RZ_SYS_BITS
Definition: rz_types.h:520
#define RZ_SYS_ARCH
Definition: rz_types.h:519
#define RZ_SYS_OS
Definition: rz_types.h:587
#define PFMT64u
Definition: rz_types.h:395
#define PFMT64o
Definition: rz_types.h:396
#define st8
Definition: rz_types_base.h:16
#define RZ_EMPTY
Definition: rz_types_base.h:68
#define st64
Definition: rz_types_base.h:10
#define UT32_MAX
Definition: rz_types_base.h:99
#define UT64_MAX
Definition: rz_types_base.h:86
#define UT8_MAX
#define st16
Definition: rz_types_base.h:14
#define st32
Definition: rz_types_base.h:12
#define UT16_MAX
#define RZ_VERSION_PATCH
Definition: rz_version.h:6
#define RZ_VERSION
Definition: rz_version.h:8
#define RZ_VERSION_MAJOR
Definition: rz_version.h:4
#define RZ_VERSION_NUMBER
Definition: rz_version.h:7
#define RZ_VERSION_MINOR
Definition: rz_version.h:5
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
#define d(i)
Definition: sha256.c:44
#define b(i)
Definition: sha256.c:42
#define f(i)
Definition: sha256.c:46
#define a(i)
Definition: sha256.c:41
Definition: rz_pj.h:12
ut64 offset
Definition: rz_core.h:301
RzIO * io
Definition: rz_core.h:313
int curtab
Definition: rz_core.h:367
RzPrint * print
Definition: rz_core.h:327
RzCoreTimes * times
Definition: rz_core.h:325
ut64 file_open_time
Definition: rz_core.h:180
ut64 loadlibs_init_time
Definition: rz_core.h:178
ut64 loadlibs_time
Definition: rz_core.h:179
double fvalue
Definition: rz_num.h:64
ut64 value
Definition: rz_num.h:63
int dbz
Definition: rz_num.h:66
void * user
Definition: rz_print.h:110
RzPrintHasRefs hasrefs
Definition: rz_print.h:150
ut64 buflen
Definition: core.c:76
if(dbg->bits==RZ_SYS_BITS_64)
Definition: windows-arm64.h:4
RZ_API bool rz_core_yank_hud_file(RzCore *core, const char *input)
Definition: yank.c:333
RZ_API bool rz_core_yank_set_str(RzCore *core, ut64 addr, RZ_NONNULL const char *str)
Definition: yank.c:101
RZ_API bool rz_core_yank_hud_path(RzCore *core, const char *input, int dir)
Definition: yank.c:346
static int addr
Definition: z80asm.c:58
static bool input(void *ud, zip_uint8_t *data, zip_uint64_t length)

References a, addr, b, bits(), buflen, calloc(), cmd_help_exclamation(), cmd_help_percent(), rz_core_t::curtab, d, rz_num_t::dbz, e, test_evm::end, eprintf, f, rz_core_times_t::file_open_time, filterFlags(), foo, free(), from, rz_num_t::fvalue, rz_print_t::hasrefs, help_msg_at, help_msg_at_at, help_msg_at_at_at, help_msg_question, help_msg_question_e, help_msg_question_v, help_msg_question_V, helpCmdTasks(), i, if(), input(), rz_core_t::io, k, len, list(), rz_core_times_t::loadlibs_init_time, rz_core_times_t::loadlibs_time, malloc(), map(), msg, n, NULL, rz_core_t::num, rz_core_t::offset, out, p, pc, PFMT64d, PFMT64o, PFMT64u, PFMT64x, pj_end(), pj_free(), pj_ki(), pj_ks(), pj_new(), pj_o(), pj_string(), rz_core_t::print, r, ret_ascii_table(), rz_base64_decode(), rz_base64_encode(), rz_cons_any_key(), rz_cons_column(), rz_cons_fgets(), rz_cons_flush(), rz_cons_gotoxy(), rz_cons_is_interactive(), rz_cons_message(), rz_cons_newline(), rz_cons_printf(), rz_cons_println(), rz_cons_set_raw(), rz_cons_set_title(), rz_cons_yesno(), rz_core_clippy(), rz_core_cmd(), rz_core_cmd_help(), rz_core_get_boundaries_prot(), rz_core_help_vars_print(), rz_core_yank_hud_file(), rz_core_yank_hud_path(), rz_core_yank_set_str(), RZ_EMPTY, rz_hex_str2bin(), rz_io_p2v(), rz_io_v2p(), rz_itv_end(), rz_line_set_prompt(), rz_list_free(), rz_list_length(), rz_list_pop_head(), rz_num_as_string(), rz_num_between(), rz_num_conditional(), rz_num_get(), rz_num_math(), rz_num_rand(), rz_num_str_split_list(), rz_num_to_bits(), rz_num_to_trits(), rz_num_units(), rz_print_progressbar(), rz_str_bits(), rz_str_bits64(), rz_str_bool(), rz_str_djb2_hash(), rz_str_trim_head_ro(), rz_str_unescape(), rz_str_version(), rz_strf, RZ_SYS_ARCH, RZ_SYS_BITS, RZ_SYS_OS, rz_time_now_mono(), RZ_USEC_PER_SEC, RZ_VERSION, RZ_VERSION_MAJOR, RZ_VERSION_MINOR, RZ_VERSION_NUMBER, RZ_VERSION_PATCH, s, snprintf, st16, st32, st64, st8, start, step(), cmd_descs_generate::str, strdup(), rz_core_t::times, autogen_x86imm::tmp, to, rz_print_t::user, UT16_MAX, UT32_MAX, ut64(), UT64_MAX, UT8_MAX, v, rz_num_t::value, vernum(), and x.

Referenced by rz_core_cmd_init(), and rzshell_cmddescs_init().

◆ rz_core_clippy()

RZ_API void rz_core_clippy ( RzCore core,
const char *  msg 
)

Definition at line 385 of file cmd_help.c.

385  {
386  int type = RZ_AVATAR_CLIPPY;
387  if (*msg == '+' || *msg == '3') {
388  char *space = strchr(msg, ' ');
389  if (!space) {
390  return;
391  }
392  type = (*msg == '+') ? RZ_AVATAR_ORANGG : RZ_AVATAR_CYBCAT;
393  msg = space + 1;
394  }
395  const char *f;
396  int msglen = rz_str_len_utf8(msg);
397  char *s = strdup(rz_str_pad(' ', msglen));
398  char *l;
399 
400  if (type == RZ_AVATAR_ORANGG) {
401  l = strdup(rz_str_pad('-', msglen));
402  f = avatar_orangg[0];
403  } else if (type == RZ_AVATAR_CYBCAT) {
404  l = strdup(rz_str_pad('-', msglen));
406  } else if (rz_config_get_i(core->config, "scr.utf8")) {
407  l = (char *)rz_str_repeat("─", msglen);
409  } else {
410  l = strdup(rz_str_pad('-', msglen));
412  }
413 
414  rz_cons_printf(f, l, s, msg, s, l);
415  free(l);
416  free(s);
417 }
static const char * avatar_clippy[]
Definition: cmd_help.c:285
static const char * avatar_orangg[]
Definition: cmd_help.c:273
static const char * avatar_cybcat[]
Definition: cmd_help.c:333
static const char * avatar_clippy_utf8[]
Definition: cmd_help.c:309
RZ_API ut64 rz_config_get_i(RzConfig *cfg, RZ_NONNULL const char *name)
Definition: config.c:119
int type
Definition: mipsasm.c:17
RZ_API char * rz_str_repeat(const char *ch, int sz)
Definition: str.c:3249
RZ_API size_t rz_str_len_utf8(const char *s)
Definition: str.c:2709
RZ_API const char * rz_str_pad(const char ch, int len)
Definition: str.c:3236
#define RZ_ARRAY_SIZE(x)
Definition: rz_types.h:300
RzConfig * config
Definition: rz_core.h:300

References avatar_clippy, avatar_clippy_utf8, avatar_cybcat, avatar_orangg, rz_core_t::config, f, free(), msg, RZ_ARRAY_SIZE, RZ_AVATAR_CLIPPY, RZ_AVATAR_CYBCAT, RZ_AVATAR_ORANGG, rz_config_get_i(), rz_cons_printf(), rz_num_rand(), rz_str_len_utf8(), rz_str_pad(), rz_str_repeat(), s, strdup(), and type.

Referenced by rz_cmd_help(), and rz_core_fortune_print_random().

◆ rz_core_help_vars_get()

RZ_API const char** rz_core_help_vars_get ( RzCore core)

Returns all the $ variable names in a NULL-terminated array.

Definition at line 360 of file cmd_help.c.

360  {
361  static const char *vars[] = {
362  "$$", "$$$", "$?", "$B", "$b", "$c", "$Cn", "$D", "$DB", "$DD", "$Dn",
363  "$e", "$f", "$F", "$Fb", "$FB", "$Fe", "$FE", "$Ff", "$Fi", "$FI", "$Fj",
364  "$fl", "$FS", "$Fs", "$FSS", "$j", "$Ja", "$l", "$M", "$m", "$MM", "$O",
365  "$o", "$p", "$P", "$r", "$s", "$S", "$SS", "$v", "$w", "$Xn", NULL
366  };
367  return vars;
368 }

References NULL.

Referenced by autocmplt_cmd_arg_help_var(), and rz_core_help_vars_print().

◆ rz_core_help_vars_print()

RZ_API void rz_core_help_vars_print ( RzCore core)

Definition at line 370 of file cmd_help.c.

370  {
371  int i = 0;
372  const char **vars = rz_core_help_vars_get(core);
373  const bool wideOffsets = rz_config_get_i(core->config, "scr.wideoff");
374  while (vars[i]) {
375  const char *pad = rz_str_pad(' ', 6 - strlen(vars[i]));
376  if (wideOffsets) {
377  eprintf("%s %s 0x%016" PFMT64x "\n", vars[i], pad, rz_num_math(core->num, vars[i]));
378  } else {
379  eprintf("%s %s 0x%08" PFMT64x "\n", vars[i], pad, rz_num_math(core->num, vars[i]));
380  }
381  i++;
382  }
383 }
RZ_API const char ** rz_core_help_vars_get(RzCore *core)
Returns all the $ variable names in a NULL-terminated array.
Definition: cmd_help.c:360
static void pad(RzStrBuf *sb, ut32 count)
Definition: protobuf.c:36

References rz_core_t::config, eprintf, i, rz_core_t::num, pad(), PFMT64x, rz_config_get_i(), rz_core_help_vars_get(), rz_num_math(), and rz_str_pad().

Referenced by rz_cmd_help(), and rz_core_visual_config().

◆ vernum()

static ut32 vernum ( const char *  s)
static

Definition at line 10 of file cmd_help.c.

10  {
11  // XXX this is known to be buggy, only works for strings like "x.x.x"
12  // XXX anything like "x.xx.x" will break the parsing
13  // XXX -git is ignored, maybe we should shift for it
14  char *a = strdup(s);
15  a = rz_str_replace(a, ".", "0", 1);
16  char *dash = strchr(a, '-');
17  if (dash) {
18  *dash = 0;
19  }
20  ut32 res = atoi(a);
21  free(a);
22  return res;
23 }
RZ_API char * rz_str_replace(char *str, const char *key, const char *val, int g)
Definition: str.c:1110

References a, free(), rz_str_replace(), s, and strdup().

Referenced by rz_cmd_help().

Variable Documentation

◆ avatar_clippy

const char* avatar_clippy[]
static
Initial value:
= {
" .--. .-%s-.\n"
" | _| | %s |\n"
" | O O < %s |\n"
" | | | | %s |\n"
" || | / `-%s-'\n"
" |`-'|\n"
" `---'\n",
" .--. .-%s-.\n"
" | \\ | %s |\n"
" | O o < %s |\n"
" | | / | %s |\n"
" | ( / `-%s-'\n"
" | / \n"
" `--'\n",
" .--. .-%s-.\n"
" | _|_ | %s |\n"
" | O O < %s |\n"
" | || | %s |\n"
" | _:| `-%s-'\n"
" | |\n"
" `---'\n",
}

Definition at line 285 of file cmd_help.c.

Referenced by rz_core_clippy().

◆ avatar_clippy_utf8

const char* avatar_clippy_utf8[]
static
Initial value:
= {
" ╭──╮ ╭─%s─╮\n"
" │ _│ │ %s │\n"
" │ O O < %s │\n"
" │ │╭ │ %s │\n"
" ││ ││ ╰─%s─╯\n"
" │└─┘│\n"
" ╰───╯\n",
" ╭──╮ ╭─%s─╮\n"
" │ ╶│╶ │ %s │\n"
" │ O o < %s │\n"
" │ │ ╱ │ %s │\n"
" │ ╭┘ ╱ ╰─%s─╯\n"
" │ ╰ ╱\n"
" ╰──'\n",
" ╭──╮ ╭─%s─╮\n"
" │ _│_ │ %s │\n"
" │ O O < %s │\n"
" │ │╷ │ %s │\n"
" │ ││ ╰─%s─╯\n"
" │ ─╯│\n"
" ╰───╯\n",
}

Definition at line 309 of file cmd_help.c.

Referenced by rz_core_clippy().

◆ avatar_cybcat

const char* avatar_cybcat[]
static
Initial value:
= {
" /\\.---./\\ .-%s-.\n"
" '-- --' | %s |\n"
"---- ^ ^ ---- < %s |\n"
" _.- Y -._ | %s |\n"
" `-%s-'\n",
" /\\.---./\\ .-%s-.\n"
" '-- @ @ --' | %s |\n"
"---- Y ---- < %s |\n"
" _.- O -._ | %s |\n"
" `-%s-'\n",
" /\\.---./\\ .-%s-.\n"
" '-- = = --' | %s |\n"
"---- Y ---- < %s |\n"
" _.- U -._ | %s |\n"
" `-%s-'\n",
}

Definition at line 333 of file cmd_help.c.

Referenced by rz_core_clippy().

◆ avatar_orangg

const char* avatar_orangg[]
static
Initial value:
= {
" _______\n"
" / \\ .-%s-.\n"
" _| ( o) (o)\\_ | %s |\n"
" / _ .\\. | \\ <| %s |\n"
" \\| \\ ____ / 7` | %s |\n"
" '|\\| `---'/ `-%s-'\n"
" | /----. \\\n"
" | \\___/ |___\n"
" `-----'`-----'\n"
}

Definition at line 273 of file cmd_help.c.

Referenced by rz_core_clippy().

◆ help_msg_env

const char* help_msg_env[]
static
Initial value:
= {
"\nEnvironment:", "", "",
"RZ_FILE", "", "file name",
"RZ_OFFSET", "", "10base offset 64bit value",
"RZ_XOFFSET", "", "same as above, but in 16 base",
"RZ_BSIZE", "", "block size",
"RZ_ENDIAN", "", "'big' or 'little'",
"RZ_IOVA", "", "is io.va true? virtual addressing (1,0)",
"RZ_DEBUG", "", "debug mode enabled? (1,0)",
"RZ_SIZE", "", "file size",
"RZ_ARCH", "", "value of asm.arch",
"RZ_BITS", "", "arch reg size (8, 16, 32, 64)",
"RZ_BIN_LANG", "", "assume this lang to demangle",
"RZ_BIN_DEMANGLE", "", "demangle or not",
"RZ_BIN_PDBSERVER", "", "e pdb.server",
}

Definition at line 37 of file cmd_help.c.

Referenced by cmd_help_exclamation(), and cmd_help_percent().

◆ help_msg_exclamation

const char* help_msg_exclamation[]
static
Initial value:
= {
"Usage:", "!<cmd>", " Run given command as in system(3)",
"!", "", "list all historic commands",
"!*", "rzp x", "run rizin command via rzpipe in current session",
"!!", "", "save command history to hist file",
"!!", "ls~txt", "print output of 'ls' and grep for 'txt'",
"!!!", "cmd [args|$type]", "adds the autocomplete value",
"!!!-", "cmd [args]", "removes the autocomplete value",
".!", "rz_bin -rpsei ${FILE}", "run each output line as a rizin cmd",
"!", "echo $RZ_SIZE", "display file size",
"!-", "", "clear history in current session",
"!-*", "", "clear and save empty history log",
"R=!", "", "enable remotecmd mode",
"R!=", "", "disable remotecmd mode",
}

Definition at line 55 of file cmd_help.c.

Referenced by cmd_help_exclamation().

◆ help_msg_greater_sign

const char* help_msg_greater_sign[]
static
Initial value:
= {
"Usage:", "[cmd]>[file]", "redirects console from 'cmd' output to 'file'",
"[cmd] > [file]", "", "redirect STDOUT of 'cmd' to 'file'",
"[cmd] > $alias", "", "save the output of the command as an alias (see $?)",
"[cmd] H> [file]", "", "redirect html output of 'cmd' to 'file'",
"[cmd] 2> [file]", "", "redirect STDERR of 'cmd' to 'file'",
"[cmd] 2> /dev/null", "", "omit the STDERR output of 'cmd'",
}

Definition at line 201 of file cmd_help.c.

Referenced by rz_core_cmd_subst_i().

◆ help_msg_percent

const char* help_msg_percent[]
static
Initial value:
= {
"Usage:", "%[name[=value]]", "Set each NAME to VALUE in the environment",
"%", "", "list all environment variables",
"%", "SHELL", "prints SHELL value",
"%", "TMPDIR=/tmp", "sets TMPDIR value to \"/tmp\"",
}

Definition at line 25 of file cmd_help.c.

Referenced by cmd_help_percent().

◆ help_msg_question

const char* help_msg_question[]
static

Definition at line 82 of file cmd_help.c.

Referenced by rz_cmd_help().

◆ help_msg_question_e

const char* help_msg_question_e[]
static
Initial value:
= {
"Usage: ?e[=bdgnpst] arg", "print/echo things", "",
"?e", "", "echo message with newline",
"?e=", " 32", "progress bar at 32 percentage",
"?eg", " 10 20", "move cursor to column 10, row 20",
"?en", " nonl", "echo message without ending newline",
"?et", " msg", "change terminal title",
}

Definition at line 72 of file cmd_help.c.

Referenced by rz_cmd_help().

◆ help_msg_question_v

const char* help_msg_question_v[]
static

Definition at line 132 of file cmd_help.c.

Referenced by rz_cmd_help().

◆ help_msg_question_V

const char* help_msg_question_V[]
static
Initial value:
= {
"Usage: ?V[jq]", "", "",
"?V", "", "show version information",
"?V0", "", "show major version",
"?V1", "", "show minor version",
"?V2", "", "show patch version",
"?Vn", "", "show numeric version (2)",
"?Vc", "", "show numeric version",
"?Vj", "", "same as above but in JSON",
"?Vq", "", "quiet mode, just show the version number",
}

Definition at line 188 of file cmd_help.c.

Referenced by rz_cmd_help().