Rizin
unix-like reverse engineering framework and cli tools
cmd_descs_util.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 # SPDX-FileCopyrightText: 2020-2021 ret2libc <sirmy15@gmail.com>
3 # SPDX-License-Identifier: LGPL-3.0-only
4 
5 CD_TYPE_OLDINPUT = "RZ_CMD_DESC_TYPE_OLDINPUT"
6 CD_TYPE_GROUP = "RZ_CMD_DESC_TYPE_GROUP"
7 CD_TYPE_ARGV = "RZ_CMD_DESC_TYPE_ARGV"
8 CD_TYPE_ARGV_MODES = "RZ_CMD_DESC_TYPE_ARGV_MODES"
9 CD_TYPE_ARGV_STATE = "RZ_CMD_DESC_TYPE_ARGV_STATE"
10 CD_TYPE_FAKE = "RZ_CMD_DESC_TYPE_FAKE"
11 CD_TYPE_INNER = "RZ_CMD_DESC_TYPE_INNER"
12 
13 CD_VALID_TYPES = [
14  CD_TYPE_OLDINPUT,
15  CD_TYPE_GROUP,
16  CD_TYPE_ARGV,
17  CD_TYPE_ARGV_MODES,
18  CD_TYPE_ARGV_STATE,
19  CD_TYPE_FAKE,
20  CD_TYPE_INNER,
21 ]
22 
23 CD_ARG_LAST_TYPES = [
24  "RZ_CMD_ARG_TYPE_RZNUM",
25  "RZ_CMD_ARG_TYPE_STRING",
26  "RZ_CMD_ARG_TYPE_CMD",
27 ]
28 
29 
30 def compute_cname(name):
31  if name == "":
32  return "empty"
33 
34  name = name.translate(
35  str.maketrans(
36  {
37  ".": "_dot_",
38  "*": "_star_",
39  ">": "_greater_",
40  "<": "_minor_",
41  "-": "_minus_",
42  "+": "_plus_",
43  "=": "_equal_",
44  "$": "_dollar_",
45  "?": "_question_",
46  "/": "_slash_",
47  "\\": "_backslash_",
48  "&": "_and_",
49  "!": "_escl_",
50  "#": "_hash_",
51  " ": "_space_",
52  "(": "_oparen_",
53  ")": "_cparen_",
54  }
55  )
56  )
57  if name.startswith("_"):
58  name = name[1:]
59 
60  return name
61 
62 
63 def get_handler_cname(ty, handler, cname):
64  if ty == CD_TYPE_OLDINPUT:
65  return "rz_" + (handler or cname)
66 
67  return "rz_" + (handler or cname) + "_handler"
def compute_cname(name)
def get_handler_cname(ty, handler, cname)