OpenVAS Scanner 23.32.3
nasl_tree.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  TC

Macros

#define FAKE_CELL   ((void *) 1)
#define EXIT_CELL   ((void *) 2)

Typedefs

typedef struct TC tree_cell

Enumerations

enum  node_type {
  NODE_EMPTY = 0 , NODE_IF_ELSE , NODE_INSTR_L , NODE_FOR ,
  NODE_WHILE , NODE_FOREACH , NODE_REPEAT_UNTIL , NODE_REPEATED ,
  NODE_FUN_DEF , NODE_FUN_CALL , NODE_DECL , NODE_ARG ,
  NODE_RETURN , NODE_BREAK , NODE_CONTINUE , NODE_ARRAY_EL ,
  NODE_AFF , NODE_VAR , NODE_LOCAL , NODE_GLOBAL ,
  NODE_PLUS_EQ , NODE_MINUS_EQ , NODE_MULT_EQ , NODE_DIV_EQ ,
  NODE_MODULO_EQ , NODE_L_SHIFT_EQ , NODE_R_SHIFT_EQ , NODE_R_USHIFT_EQ ,
  EXPR_AND , EXPR_OR , EXPR_NOT , EXPR_PLUS ,
  EXPR_MINUS , EXPR_U_MINUS , EXPR_MULT , EXPR_DIV ,
  EXPR_MODULO , EXPR_EXPO , EXPR_BIT_AND , EXPR_BIT_OR ,
  EXPR_BIT_XOR , EXPR_BIT_NOT , EXPR_INCR , EXPR_DECR ,
  EXPR_L_SHIFT , EXPR_R_SHIFT , EXPR_R_USHIFT , COMP_MATCH ,
  COMP_NOMATCH , COMP_RE_MATCH , COMP_RE_NOMATCH , COMP_LT ,
  COMP_LE , COMP_EQ , COMP_NE , COMP_GT ,
  COMP_GE , CONST_INT , CONST_STR , CONST_DATA ,
  CONST_REGEX , ARRAY_ELEM , REF_VAR , REF_ARRAY ,
  DYN_ARRAY
}

Functions

tree_cellalloc_expr_cell (int, int, tree_cell *, tree_cell *)
tree_cellalloc_RE_cell (int, int, tree_cell *, char *, int *)
tree_cellalloc_typed_cell (int)
int nasl_is_leaf (const tree_cell *)
char * get_line_nb (const tree_cell *)
tree_celldup_cell (const tree_cell *)
void nasl_dump_tree (const tree_cell *)
void ref_cell (tree_cell *)
void deref_cell (tree_cell *)
const char * nasl_type_name (int)
int cell_type (const tree_cell *)
char * dump_cell_val (const tree_cell *)

Macro Definition Documentation

◆ EXIT_CELL

#define EXIT_CELL   ((void *) 2)

Definition at line 111 of file nasl_tree.h.

◆ FAKE_CELL

#define FAKE_CELL   ((void *) 1)

Definition at line 110 of file nasl_tree.h.

Referenced by __attribute__(), affect_to_anon_var(), alloc_RE_cell(), cell2atom(), cell2bool(), cell2int3(), cell2str(), cell_cmp(), cell_type(), check_description_block(), check_description_block_xref(), copy_ref_array(), create_anon_var(), create_named_var(), decl_local_variables(), decl_nasl_func(), deref_cell(), dump_cell_val(), dump_ip_v6_packet(), dump_tree(), dup_cell(), exec_nasl_script(), find_description_block(), free_tree(), get_host_ip(), get_kb_list(), get_line_nb(), get_port_state(), get_udp_port_state(), host_reverse_lookup(), insert_nasl_func(), make_array_from_elems(), make_call_func_list(), nasl_array_iterator(), nasl_close_socket(), nasl_crap(), nasl_dump_ctxt(), nasl_dump_expr(), nasl_dump_tree(), nasl_egrep(), nasl_ereg_replace(), nasl_exec(), nasl_func_call(), nasl_get_sock_info(), nasl_is_leaf(), nasl_leave_multicast_group(), nasl_lint(), nasl_lint_call(), nasl_lint_def(), nasl_lint_defvar(), nasl_okrb5_find_kdc(), nasl_okrb5_gss_session_key_context(), nasl_okrb5_gss_update_context_out(), nasl_open_privileged_socket(), nasl_read_var_ref(), nasl_return(), nasl_scanner_add_port(), nasl_scanner_status(), nasl_send_packet(), nasl_send_v6packet(), nasl_short_dump(), nasl_sleep(), nasl_ssh_disconnect(), nasl_ssh_set_login(), nasl_start_denial(), nasl_strstr(), nasl_unlink(), nasl_usleep(), ref_cell(), replace_kb_item(), script_add_preference(), script_category(), script_copyright(), script_cve_id(), script_dependencies(), script_exclude_keys(), script_family(), script_get_preference(), script_get_preference_file_content(), script_mandatory_keys(), script_name(), script_oid(), script_require_keys(), script_require_ports(), script_require_udp_ports(), script_tag(), script_timeout(), script_version(), script_xref(), security_notus(), security_something(), set_kb_item(), set_kb_item_volatile(), validate_function(), and validate_script_xref().

Typedef Documentation

◆ tree_cell

typedef struct TC tree_cell

Enumeration Type Documentation

◆ node_type

enum node_type
Enumerator
NODE_EMPTY 
NODE_IF_ELSE 
NODE_INSTR_L 
NODE_FOR 
NODE_WHILE 
NODE_FOREACH 
NODE_REPEAT_UNTIL 
NODE_REPEATED 
NODE_FUN_DEF 
NODE_FUN_CALL 
NODE_DECL 
NODE_ARG 
NODE_RETURN 
NODE_BREAK 
NODE_CONTINUE 
NODE_ARRAY_EL 
NODE_AFF 
NODE_VAR 
NODE_LOCAL 
NODE_GLOBAL 
NODE_PLUS_EQ 
NODE_MINUS_EQ 
NODE_MULT_EQ 
NODE_DIV_EQ 
NODE_MODULO_EQ 
NODE_L_SHIFT_EQ 
NODE_R_SHIFT_EQ 
NODE_R_USHIFT_EQ 
EXPR_AND 
EXPR_OR 
EXPR_NOT 
EXPR_PLUS 
EXPR_MINUS 
EXPR_U_MINUS 
EXPR_MULT 
EXPR_DIV 
EXPR_MODULO 
EXPR_EXPO 
EXPR_BIT_AND 
EXPR_BIT_OR 
EXPR_BIT_XOR 
EXPR_BIT_NOT 
EXPR_INCR 
EXPR_DECR 
EXPR_L_SHIFT 
EXPR_R_SHIFT 
EXPR_R_USHIFT 
COMP_MATCH 
COMP_NOMATCH 
COMP_RE_MATCH 
COMP_RE_NOMATCH 
COMP_LT 
COMP_LE 
COMP_EQ 
COMP_NE 
COMP_GT 
COMP_GE 
CONST_INT 
CONST_STR 
CONST_DATA 
CONST_REGEX 
ARRAY_ELEM 
REF_VAR 
REF_ARRAY 
DYN_ARRAY 

Definition at line 11 of file nasl_tree.h.

12{
13 NODE_EMPTY = 0,
14 NODE_IF_ELSE, /* [0] = cond, [1] = if_block, [2] = else_block */
15 NODE_INSTR_L, /* Block. [0] = first instr, [1] = tail */
16 NODE_FOR, /* [0] = start expr, [1] = cond, [2] = end_expr, [3] = block */
17 NODE_WHILE, /* [0] = cond, [1] = block */
20 NODE_REPEATED, /* [0] = func call, [1] = repeat nb */
21 NODE_FUN_DEF, /* [0] = argdecl, [1] = block */
22 NODE_FUN_CALL, /* [0] = script_infos */
23 NODE_DECL, /* [0] = next arg in list */
24 NODE_ARG, /* val = name can be NULL, [0] = val, [1] = next arg */
25 NODE_RETURN, /* ret val */
28
29 NODE_ARRAY_EL, /* val = array name, [0] = index */
30 NODE_AFF, /* [0] = lvalue, [1] = rvalue */
31 NODE_VAR, /* val = variable name */
32 NODE_LOCAL, /* [0] = argdecl */
34
40
44
46 EXPR_OR,
48
56
66
71
72 COMP_LT,
73 COMP_LE,
74 COMP_EQ,
75 COMP_NE,
76 COMP_GT,
77 COMP_GE,
78
80 CONST_STR, /* "impure" string */
81
82 CONST_DATA, /* binary data / "pure" string */
83 CONST_REGEX, /* Compiled regex */
84
85 ARRAY_ELEM, /* val = char index or NULL if integer,
86 * [0] = value, [1] = next element */
87 /* For exec only */
88 REF_VAR,
91};
@ NODE_FOR
Definition nasl_tree.h:16
@ NODE_ARRAY_EL
Definition nasl_tree.h:29
@ NODE_L_SHIFT_EQ
Definition nasl_tree.h:41
@ NODE_PLUS_EQ
Definition nasl_tree.h:35
@ NODE_FUN_CALL
Definition nasl_tree.h:22
@ COMP_LE
Definition nasl_tree.h:73
@ NODE_R_SHIFT_EQ
Definition nasl_tree.h:42
@ COMP_GT
Definition nasl_tree.h:76
@ NODE_LOCAL
Definition nasl_tree.h:32
@ CONST_DATA
Definition nasl_tree.h:82
@ NODE_AFF
Definition nasl_tree.h:30
@ EXPR_MODULO
Definition nasl_tree.h:54
@ COMP_RE_MATCH
Definition nasl_tree.h:69
@ NODE_MULT_EQ
Definition nasl_tree.h:37
@ COMP_NE
Definition nasl_tree.h:75
@ NODE_VAR
Definition nasl_tree.h:31
@ NODE_R_USHIFT_EQ
Definition nasl_tree.h:43
@ NODE_ARG
Definition nasl_tree.h:24
@ NODE_CONTINUE
Definition nasl_tree.h:27
@ COMP_EQ
Definition nasl_tree.h:74
@ EXPR_MULT
Definition nasl_tree.h:52
@ NODE_FUN_DEF
Definition nasl_tree.h:21
@ COMP_GE
Definition nasl_tree.h:77
@ ARRAY_ELEM
Definition nasl_tree.h:85
@ NODE_REPEAT_UNTIL
Definition nasl_tree.h:19
@ NODE_REPEATED
Definition nasl_tree.h:20
@ REF_VAR
Definition nasl_tree.h:88
@ DYN_ARRAY
Definition nasl_tree.h:90
@ CONST_REGEX
Definition nasl_tree.h:83
@ EXPR_BIT_NOT
Definition nasl_tree.h:60
@ EXPR_R_SHIFT
Definition nasl_tree.h:64
@ EXPR_DIV
Definition nasl_tree.h:53
@ COMP_RE_NOMATCH
Definition nasl_tree.h:70
@ NODE_RETURN
Definition nasl_tree.h:25
@ NODE_EMPTY
Definition nasl_tree.h:13
@ EXPR_BIT_XOR
Definition nasl_tree.h:59
@ NODE_FOREACH
Definition nasl_tree.h:18
@ NODE_IF_ELSE
Definition nasl_tree.h:14
@ NODE_DIV_EQ
Definition nasl_tree.h:38
@ NODE_MINUS_EQ
Definition nasl_tree.h:36
@ COMP_NOMATCH
Definition nasl_tree.h:68
@ COMP_MATCH
Definition nasl_tree.h:67
@ EXPR_NOT
Definition nasl_tree.h:47
@ EXPR_PLUS
Definition nasl_tree.h:49
@ EXPR_L_SHIFT
Definition nasl_tree.h:63
@ NODE_DECL
Definition nasl_tree.h:23
@ CONST_STR
Definition nasl_tree.h:80
@ EXPR_BIT_AND
Definition nasl_tree.h:57
@ EXPR_EXPO
Definition nasl_tree.h:55
@ EXPR_INCR
Definition nasl_tree.h:61
@ NODE_INSTR_L
Definition nasl_tree.h:15
@ EXPR_BIT_OR
Definition nasl_tree.h:58
@ EXPR_U_MINUS
Definition nasl_tree.h:51
@ COMP_LT
Definition nasl_tree.h:72
@ EXPR_OR
Definition nasl_tree.h:46
@ NODE_BREAK
Definition nasl_tree.h:26
@ EXPR_DECR
Definition nasl_tree.h:62
@ EXPR_R_USHIFT
Definition nasl_tree.h:65
@ NODE_GLOBAL
Definition nasl_tree.h:33
@ CONST_INT
Definition nasl_tree.h:79
@ NODE_WHILE
Definition nasl_tree.h:17
@ REF_ARRAY
Definition nasl_tree.h:89
@ EXPR_MINUS
Definition nasl_tree.h:50
@ NODE_MODULO_EQ
Definition nasl_tree.h:39
@ EXPR_AND
Definition nasl_tree.h:45

Function Documentation

◆ alloc_expr_cell()

tree_cell * alloc_expr_cell ( int lnb,
int t,
tree_cell * l,
tree_cell * r )

Definition at line 60 of file nasl_tree.c.

61{
63 c->line_nb = lnb;
64 c->type = t;
65 c->link[0] = l;
66 c->link[1] = r;
67
68 return c;
69}
static tree_cell * alloc_tree_cell()
Definition nasl_tree.c:19
struct TC tree_cell
struct TC * link[4]
Definition nasl_tree.h:107
short line_nb
Definition nasl_tree.h:96
short type
Definition nasl_tree.h:95

References alloc_tree_cell(), TC::line_nb, TC::link, and TC::type.

Referenced by get_array_elem(), int2cell(), nasl_exec(), and yyparse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ alloc_RE_cell()

tree_cell * alloc_RE_cell ( int lnb,
int t,
tree_cell * l,
char * re_str,
int * err_c )

Definition at line 33 of file nasl_tree.c.

34{
35 regex_t *re = g_malloc0 (sizeof (regex_t));
36 int e;
37
39 c->line_nb = lnb;
40 c->type = t; /* We could check the type... */
41 c->link[0] = l;
42 c->link[1] = FAKE_CELL;
43 e = regcomp (re, re_str, REG_EXTENDED | REG_NOSUB | REG_ICASE);
44 if (!e)
45 c->x.ref_val = re;
46 else
47 {
48 char errbuf[100];
49 regerror (e, re, errbuf, sizeof (errbuf));
50 nasl_perror (NULL, "Line %d: Cannot compile regex: %s (error %d: %s)\n",
51 lnb, re_str, e, errbuf);
52 g_free (re);
53 *err_c = *err_c + 1;
54 }
55 g_free (re_str);
56 return c;
57}
void nasl_perror(lex_ctxt *lexic, char *msg,...)
Definition nasl_debug.c:105
#define FAKE_CELL
Definition nasl_tree.h:110
union TC::@332262321161220155002104006201360276211317150140 x
void * ref_val
Definition nasl_tree.h:105

References alloc_tree_cell(), FAKE_CELL, TC::line_nb, TC::link, nasl_perror(), TC::ref_val, TC::type, and TC::x.

Referenced by yyparse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ alloc_typed_cell()

tree_cell * alloc_typed_cell ( int typ)

Definition at line 25 of file nasl_tree.c.

26{
28 c->type = typ;
29 return c;
30}

References alloc_tree_cell(), and TC::type.

Referenced by __attribute__(), _http2_req(), _http_req(), array_from_snmp_error(), array_from_snmp_result(), cgibin(), copy_ref_array(), crypt_data(), encrypt_stream_data(), forge_icmp_packet(), forge_icmp_v6_packet(), forge_igmp_packet(), forge_igmp_v6_packet(), forge_ip_packet(), forge_ip_v6_packet(), forge_tcp_packet(), forge_tcp_v6_packet(), forge_udp_packet(), forge_udp_v6_packet(), get_host_ip(), get_host_kb_index(), get_host_open_port(), get_hostname(), get_hostname_source(), get_hostnames(), get_icmp_element(), get_icmp_v6_element(), get_ip_element(), get_ip_v6_element(), get_kb_item(), get_kb_list(), get_port_state(), get_port_transport(), get_script_oid(), get_tcp_element(), get_tcp_option(), get_tcp_v6_element(), get_tcp_v6_option(), get_udp_element(), get_udp_port_state(), get_udp_v6_element(), get_variable_by_name(), host_reverse_lookup(), insert_ip_options(), insert_tcp_options(), insert_tcp_v6_options(), make_array_from_elems(), nasl_bf_cbc(), nasl_bn_random(), nasl_chomp(), nasl_cipher(), nasl_close_stream_cipher(), nasl_crap(), nasl_dec2str(), nasl_defined_func(), nasl_dh_compute_key(), nasl_dh_generate_key(), nasl_display(), nasl_do_exit(), nasl_egrep(), nasl_end_denial(), nasl_ereg(), nasl_ereg_replace(), nasl_eregmatch(), nasl_exec(), nasl_file_close(), nasl_file_open(), nasl_file_read(), nasl_file_seek(), nasl_file_stat(), nasl_file_write(), nasl_find_in_path(), nasl_forge_frame(), nasl_fread(), nasl_ftp_get_pasv_address(), nasl_ftp_log_in(), nasl_fwrite(), nasl_gcrypt_hash(), nasl_get_byte_order(), nasl_get_local_mac_address_from_ip(), nasl_get_mtu(), nasl_get_preference(), nasl_get_sign(), nasl_get_sock_info(), nasl_get_source_port(), nasl_get_tmp_dir(), nasl_gettimeofday(), nasl_gunzip(), nasl_gzip(), nasl_hex(), nasl_hexstr(), nasl_hmac_sha256(), nasl_http2_close_handle(), nasl_http2_get_response_code(), nasl_http2_handle(), nasl_http2_set_custom_header(), nasl_incr_variable(), nasl_insert_hexzeros(), nasl_insstr(), nasl_int(), nasl_islocalhost(), nasl_islocalnet(), nasl_isnull(), nasl_isotime_add(), nasl_isotime_is_valid(), nasl_isotime_now(), nasl_isotime_print(), nasl_isotime_scan(), nasl_join_multicast_group(), nasl_keyexchg(), nasl_keys(), nasl_lint(), nasl_lm_owf_gen(), nasl_localtime(), nasl_mac(), nasl_make_array(), nasl_make_list(), nasl_match(), nasl_max_index(), nasl_mktime(), nasl_notus(), nasl_notus_error(), nasl_ntlm2_response(), nasl_ntlm_response(), nasl_ntlmv1_hash(), nasl_ntlmv2_hash(), nasl_ntlmv2_response(), nasl_ntv2_owf_gen(), nasl_okrb5_add_realm(), nasl_okrb5_error_code_to_string(), nasl_okrb5_find_kdc(), nasl_okrb5_gss_init(), nasl_okrb5_gss_prepare_context(), nasl_okrb5_gss_update_context(), nasl_okrb5_gss_update_context_needs_more(), nasl_okrb5_is_failure(), nasl_okrb5_is_success(), nasl_open_privileged_socket(), nasl_open_sock_kdc(), nasl_open_sock_tcp_bufsz(), nasl_open_sock_udp(), nasl_open_stream_cipher(), nasl_ord(), nasl_pcap_next(), nasl_pem_to(), nasl_pread(), nasl_prf(), nasl_rand(), nasl_rawstring(), nasl_read_var_ref(), nasl_recv(), nasl_recv_line(), nasl_rsa_private_decrypt(), nasl_rsa_public_decrypt(), nasl_rsa_public_encrypt(), nasl_rsa_sign(), nasl_same_host(), nasl_scanner_get_port(), nasl_send(), nasl_send_arp_request(), nasl_send_capture(), nasl_send_frame(), nasl_send_packet(), nasl_send_v6packet(), nasl_sftp_enabled_check(), nasl_smb3kdf(), nasl_smb_close(), nasl_smb_connect(), nasl_smb_file_group_sid(), nasl_smb_file_owner_sid(), nasl_smb_file_SDDL(), nasl_smb_file_trustee_rights(), nasl_smb_sign(), nasl_smb_versioninfo(), nasl_socket_cert_verify(), nasl_socket_check_ssl_safe_renegotiation(), nasl_socket_get_cert(), nasl_socket_get_error(), nasl_socket_get_ssl_ciphersuite(), nasl_socket_get_ssl_session_id(), nasl_socket_get_ssl_version(), nasl_socket_negotiate_ssl(), nasl_socket_ssl_do_handshake(), nasl_split(), nasl_ssh_connect(), nasl_ssh_execute_netconf_subsystem(), nasl_ssh_get_auth_methods(), nasl_ssh_get_host_key(), nasl_ssh_get_issue_banner(), nasl_ssh_get_server_banner(), nasl_ssh_get_sock(), nasl_ssh_login_interactive(), nasl_ssh_login_interactive_pass(), nasl_ssh_request_exec(), nasl_ssh_session_id_from_sock(), nasl_ssh_shell_open(), nasl_ssh_shell_read(), nasl_ssh_shell_write(), nasl_ssh_userauth(), nasl_str_replace(), nasl_strcat(), nasl_stridx(), nasl_string(), nasl_strlen(), nasl_strstr(), nasl_substr(), nasl_target_is_ipv6(), nasl_tcp_ping(), nasl_tcp_v6_ping(), nasl_telnet_init(), nasl_this_host(), nasl_this_host_name(), nasl_tolower(), nasl_toupper(), nasl_typeof(), nasl_unixtime(), nasl_vendor_version(), nasl_win_cmd_exec(), nasl_wmi_close(), nasl_wmi_connect(), nasl_wmi_connect_reg(), nasl_wmi_connect_rsop(), nasl_wmi_query(), nasl_wmi_query_rsop(), nasl_wmi_reg_create_key(), nasl_wmi_reg_delete_key(), nasl_wmi_reg_enum_key(), nasl_wmi_reg_enum_value(), nasl_wmi_reg_get_bin_val(), nasl_wmi_reg_get_dword_val(), nasl_wmi_reg_get_ex_string_val(), nasl_wmi_reg_get_mul_string_val(), nasl_wmi_reg_get_qword_val(), nasl_wmi_reg_get_sz(), nasl_wmi_reg_set_dword_val(), nasl_wmi_reg_set_ex_string_val(), nasl_wmi_reg_set_qword_val(), nasl_wmi_reg_set_string_val(), nasl_wmi_versioninfo(), okrb5_slice_to_tree_cell(), resolve_hostname(), resolve_hostname_to_multiple_ips(), safe_checks(), script_get_preference(), script_get_preference_file_content(), script_get_preference_file_location(), set_ip_elements(), set_ip_v6_elements(), set_tcp_elements(), set_tcp_v6_elements(), set_udp_elements(), set_udp_v6_elements(), var2cell(), and yyparse().

Here is the call graph for this function:

◆ cell_type()

int cell_type ( const tree_cell * c)

Definition at line 404 of file nasl_tree.c.

405 {
406 if (c == NULL || c == FAKE_CELL)
407 return 0;
408 else
409 return c->type;
410 }

References FAKE_CELL, and TC::type.

Referenced by cell_cmp().

Here is the caller graph for this function:

◆ deref_cell()

void deref_cell ( tree_cell * c)

Definition at line 178 of file nasl_tree.c.

179{
180 if (c == NULL || c == FAKE_CELL)
181 return;
182 if (--c->ref_count < 0)
183 free_tree (c);
184}
static void free_tree(tree_cell *c)
Definition nasl_tree.c:105
short ref_count
Definition nasl_tree.h:98

References FAKE_CELL, free_tree(), and TC::ref_count.

Referenced by cell2atom(), cell2bool(), cell2int3(), cell2str(), cell_cmp(), create_anon_var(), create_named_var(), exec_nasl_script(), free_lex_ctxt(), free_tree(), get_kb_list(), get_tcp_v6_element(), make_array_from_elems(), nasl_clean_ctx(), nasl_display(), nasl_exec(), nasl_func_call(), nasl_notus(), nasl_pread(), nasl_read_var_ref(), nasl_return(), nasl_start_denial(), var_cmp(), and yyparse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dump_cell_val()

char * dump_cell_val ( const tree_cell * c)

Definition at line 231 of file nasl_tree.c.

232{
233 static char txt[80];
234
235 if (c == NULL)
236 return "NULL";
237 else if (c == FAKE_CELL)
238 return "FAKE";
239 else
240 switch (c->type)
241 {
242 case CONST_INT:
243 snprintf (txt, sizeof (txt), "%ld", c->x.i_val);
244 break;
245 case CONST_STR:
246 case CONST_DATA: /* Beurk (English: Yuck) */
247 if ((unsigned int) c->size >= sizeof (txt) + 2)
248 {
249 snprintf (txt, sizeof (txt), "\"%s", c->x.str_val);
250 strcpy (txt + (sizeof (txt) - 5), "...\"");
251 }
252 else
253 snprintf (txt, sizeof (txt), "\"%s\"", c->x.str_val);
254 break;
255 default:
256 snprintf (txt, sizeof (txt), "???? (%s)", nasl_type_name (c->type));
257 break;
258 }
259 return txt;
260}
const char * nasl_type_name(int t)
Definition nasl_tree.c:343
int size
Definition nasl_tree.h:99
long int i_val
Definition nasl_tree.h:104
char * str_val
Definition nasl_tree.h:103

References CONST_DATA, CONST_INT, CONST_STR, FAKE_CELL, TC::i_val, nasl_type_name(), TC::size, TC::str_val, TC::type, and TC::x.

Referenced by nasl_func_call().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dup_cell()

tree_cell * dup_cell ( const tree_cell * tc)

Definition at line 72 of file nasl_tree.c.

73{
74 tree_cell *r;
75 int i;
76
77 if (tc == NULL)
78 return NULL;
79 else if (tc == FAKE_CELL)
80 return FAKE_CELL;
81
82 r = alloc_tree_cell ();
83 r->line_nb = tc->line_nb;
84 r->type = tc->type;
85 r->size = tc->size;
86
87 switch (tc->type)
88 {
89 case CONST_STR:
90 case CONST_DATA:
91 r->x.str_val = g_malloc0 (tc->size + 1);
92 memcpy (r->x.str_val, tc->x.str_val, tc->size);
93 break;
94 default:
95 r->x = tc->x;
96 break;
97 }
98
99 for (i = 0; i < 4; i++)
100 r->link[i] = dup_cell (tc->link[i]);
101 return r;
102}
tree_cell * dup_cell(const tree_cell *tc)
Definition nasl_tree.c:72

References alloc_tree_cell(), CONST_DATA, CONST_STR, dup_cell(), FAKE_CELL, TC::line_nb, TC::link, TC::size, TC::str_val, TC::type, and TC::x.

Referenced by dup_cell().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_line_nb()

char * get_line_nb ( const tree_cell * c)

Definition at line 376 of file nasl_tree.c.

377{
378 static char txt[32];
379 if (c == NULL || c == FAKE_CELL || c->line_nb <= 0)
380 return "";
381 snprintf (txt, sizeof (txt), " at or near line %d ", c->line_nb);
382 return txt;
383}

References FAKE_CELL, and TC::line_nb.

Referenced by get_array_elem(), nasl_incr_variable(), and nasl_read_var_ref().

Here is the caller graph for this function:

◆ nasl_dump_tree()

void nasl_dump_tree ( const tree_cell * c)

Definition at line 363 of file nasl_tree.c.

364{
365 printf ("^^^^ %p ^^^^^\n", (void *) c);
366 if (c == NULL)
367 puts ("NULL CELL");
368 else if (c == FAKE_CELL)
369 puts ("FAKE CELL");
370 else
371 dump_tree (c, 0, 0);
372 printf ("vvvvvvvvvvvvvvvvvv\n");
373}
static void dump_tree(const tree_cell *c, int n, int idx)
Definition nasl_tree.c:263

References dump_tree(), and FAKE_CELL.

Referenced by dump_ctxt(), nasl_func_call(), and ref_cell().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nasl_is_leaf()

int nasl_is_leaf ( const tree_cell * pc)

Definition at line 386 of file nasl_tree.c.

387{
388 if (pc == NULL || pc == FAKE_CELL)
389 return 1;
390 switch (pc->type)
391 {
392 case CONST_INT:
393 case CONST_STR:
394 case CONST_DATA:
395 case REF_ARRAY:
396 case DYN_ARRAY:
397 return 1;
398 default:
399 return 0;
400 }
401 /*NOTREACHED*/}

References CONST_DATA, CONST_INT, CONST_STR, DYN_ARRAY, FAKE_CELL, REF_ARRAY, and TC::type.

Referenced by nasl_func_call().

Here is the caller graph for this function:

◆ nasl_type_name()

const char * nasl_type_name ( int t)

Definition at line 343 of file nasl_tree.c.

344{
345 static char txt4[4][32]; /* This function may be called 4 times in the same
346 expression */
347 static int i = 0;
348 char *txt;
349
350 if (i >= 4)
351 i = 0;
352 txt = txt4[i];
353
354 if (t >= 0 && (unsigned int) t < sizeof (node_names) / sizeof (node_names[0]))
355 snprintf (txt, 32, "%s (%d)", node_names[t], t);
356 else
357 snprintf (txt, 32, "*UNKNOWN* (%d)", t);
358 i++;
359 return txt;
360}
static char * node_names[]
Definition nasl_tree.c:188

References node_names.

Referenced by cell_cmp(), dump_cell_val(), make_array_from_elems(), and nasl_affect().

Here is the caller graph for this function:

◆ ref_cell()

void ref_cell ( tree_cell * c)

Definition at line 164 of file nasl_tree.c.

165{
166 if (c == NULL || c == FAKE_CELL)
167 return;
168 c->ref_count++;
169 if (c->ref_count < 0)
170 {
171 nasl_perror (NULL, "ref_cell: ref count is negative!\n");
172 nasl_dump_tree (c);
173 abort ();
174 }
175}
void nasl_dump_tree(const tree_cell *c)
Definition nasl_tree.c:363

References FAKE_CELL, nasl_dump_tree(), nasl_perror(), and TC::ref_count.

Referenced by cell2atom(), insert_nasl_func(), nasl_do_exit(), nasl_exec(), nasl_func_call(), nasl_return(), and yyparse().

Here is the call graph for this function:
Here is the caller graph for this function: