OpenVAS Scanner  22.7.9
nasl_lex_ctxt.h File Reference
#include <glib.h>
#include "nasl_tree.h"
#include "nasl_var.h"
#include "nasl_func.h"
Include dependency graph for nasl_lex_ctxt.h:

Go to the source code of this file.

Data Structures

struct  struct_lex_ctxt
 

Macros

#define NASL_COMPAT_LEX_CTXT   "NASL compat lex context"
 

Typedefs

typedef struct struct_lex_ctxt lex_ctxt
 

Functions

lex_ctxtinit_empty_lex_ctxt (void)
 
void free_lex_ctxt (lex_ctxt *)
 
void dump_ctxt (lex_ctxt *)
 
nasl_funcget_func_ref_by_name (lex_ctxt *, const char *)
 
tree_celldecl_nasl_func (lex_ctxt *, tree_cell *, int)
 
nasl_funcinsert_nasl_func (lex_ctxt *, const char *, tree_cell *, int)
 
tree_cellnasl_func_call (lex_ctxt *, const nasl_func *, tree_cell *)
 
tree_cellget_variable_by_name (lex_ctxt *, const char *)
 
tree_cellget_array_elem (lex_ctxt *, const char *, tree_cell *)
 
anon_nasl_varadd_numbered_var_to_ctxt (lex_ctxt *, int, tree_cell *)
 
named_nasl_varadd_named_var_to_ctxt (lex_ctxt *, const char *, tree_cell *)
 
tree_cellnasl_read_var_ref (lex_ctxt *, tree_cell *)
 
tree_cellnasl_incr_variable (lex_ctxt *, tree_cell *, int, int)
 
tree_cellnasl_return (lex_ctxt *, tree_cell *)
 
tree_celldecl_local_variables (lex_ctxt *, tree_cell *)
 
tree_celldecl_global_variables (lex_ctxt *, tree_cell *)
 
tree_cellcell2atom (lex_ctxt *, tree_cell *)
 
long int get_int_var_by_num (lex_ctxt *, int, int)
 
char * get_str_var_by_num (lex_ctxt *, int)
 
long int get_int_var_by_name (lex_ctxt *, const char *, int)
 
char * get_str_var_by_name (lex_ctxt *, const char *)
 
int get_var_size_by_name (lex_ctxt *, const char *)
 
int get_var_type_by_name (lex_ctxt *, const char *)
 
int get_var_size_by_num (lex_ctxt *, int)
 
int get_var_type_by_num (lex_ctxt *, int)
 Returns NASL variable/cell type, VAR2_UNDEF if value is NULL. More...
 

Macro Definition Documentation

◆ NASL_COMPAT_LEX_CTXT

#define NASL_COMPAT_LEX_CTXT   "NASL compat lex context"

Definition at line 40 of file nasl_lex_ctxt.h.

Typedef Documentation

◆ lex_ctxt

typedef struct struct_lex_ctxt lex_ctxt

Function Documentation

◆ add_named_var_to_ctxt()

named_nasl_var* add_named_var_to_ctxt ( lex_ctxt ,
const char *  ,
tree_cell  
)

Definition at line 813 of file nasl_var.c.

814  {
815  int h = hash_str (name);
816  named_nasl_var *v;
817 
818  /* Duplicated code ? */
819  for (v = lexic->ctx_vars.hash_elt[h]; v != NULL; v = v->next_var)
820  if (v->var_name != NULL && strcmp (name, v->var_name) == 0)
821  {
822  if (val != NULL)
823  nasl_perror (lexic, "Cannot add existing variable %s\n", name);
824  return NULL;
825  }
826  v = create_named_var (name, val);
827  if (v == NULL)
828  return NULL;
829  v->next_var = lexic->ctx_vars.hash_elt[h];
830  lexic->ctx_vars.hash_elt[h] = v;
831  return v;
832  }

References create_named_var(), struct_lex_ctxt::ctx_vars, st_nasl_array::hash_elt, hash_str(), name, nasl_perror(), st_n_nasl_var::next_var, val, and st_n_nasl_var::var_name.

Referenced by decl_local_variables(), exec_nasl_script(), init_nasl_library(), and nasl_func_call().

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

◆ add_numbered_var_to_ctxt()

anon_nasl_var* add_numbered_var_to_ctxt ( lex_ctxt ,
int  ,
tree_cell  
)

Definition at line 784 of file nasl_var.c.

785  {
786  anon_nasl_var *v;
787  nasl_array *a = &lexic->ctx_vars;
788 
789  if (a->max_idx > num)
790  {
791  v = a->num_elt[num];
792  if (v != NULL && v->var_type != VAR2_UNDEF)
793  {
794  if (val != NULL)
795  nasl_perror (lexic, "Cannot add existing variable %d\n", num);
796  return NULL;
797  }
798  free_anon_var (a->num_elt[num]);
799  }
800  else
801  {
802  a->num_elt =
803  g_realloc (a->num_elt, (num + 1) * sizeof (anon_nasl_var *));
804  bzero (a->num_elt + a->max_idx,
805  sizeof (anon_nasl_var *) * (num + 1 - a->max_idx));
806  a->max_idx = num + 1;
807  }
808  a->num_elt[num] = v = create_anon_var (val);
809  return v;
810  }

References create_anon_var(), struct_lex_ctxt::ctx_vars, free_anon_var(), st_nasl_array::max_idx, nasl_perror(), st_nasl_array::num_elt, val, VAR2_UNDEF, and st_a_nasl_var::var_type.

Referenced by nasl_func_call().

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

◆ cell2atom()

tree_cell* cell2atom ( lex_ctxt lexic,
tree_cell c1 
)
Returns
A 'referenced' cell.

Definition at line 194 of file exec.c.

195 {
196  tree_cell *c2 = NULL, *ret = NULL;
197  if (c1 == NULL || c1 == FAKE_CELL)
198  return c1;
199 
200  switch (c1->type)
201  {
202  case CONST_INT:
203  case CONST_STR:
204  case CONST_DATA:
205  case REF_ARRAY:
206  case DYN_ARRAY:
207  ref_cell (c1);
208  return c1;
209  default:
210  c2 = nasl_exec (lexic, c1);
211  ret = cell2atom (lexic, c2);
212  deref_cell (c2);
213  return ret;
214  }
215 }

References cell2atom(), CONST_DATA, CONST_INT, CONST_STR, deref_cell(), DYN_ARRAY, FAKE_CELL, nasl_exec(), REF_ARRAY, ref_cell(), and TC::type.

Referenced by cell2atom(), cell_cmp(), nasl_exec(), nasl_func_call(), and nasl_return().

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

◆ decl_global_variables()

tree_cell* decl_global_variables ( lex_ctxt ,
tree_cell  
)

Definition at line 774 of file nasl_var.c.

775  {
776  lex_ctxt *c = lexic;
777 
778  while (c->up_ctxt != NULL)
779  c = c->up_ctxt;
780  return decl_local_variables (c, vars);
781  }

References decl_local_variables(), and struct_lex_ctxt::up_ctxt.

Referenced by nasl_exec().

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

◆ decl_local_variables()

tree_cell* decl_local_variables ( lex_ctxt ,
tree_cell  
)

Definition at line 761 of file nasl_var.c.

762  {
763  tree_cell *t;
764 
765  for (t = vars; t != NULL; t = t->link[0])
766  if (t->x.str_val == NULL)
767  nasl_perror (lexic, "decl_local_variables: null name!\n");
768  else
769  add_named_var_to_ctxt (lexic, t->x.str_val, NULL);
770  return FAKE_CELL;
771  }

References add_named_var_to_ctxt(), FAKE_CELL, TC::link, nasl_perror(), TC::str_val, and TC::x.

Referenced by decl_global_variables(), and nasl_exec().

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

◆ decl_nasl_func()

tree_cell* decl_nasl_func ( lex_ctxt ,
tree_cell ,
int   
)

Definition at line 66 of file nasl_func.c.

67 {
68  if (decl_node == NULL || decl_node == FAKE_CELL)
69  {
70  nasl_perror (lexic, "Cannot insert NULL or FAKE cell as function\n");
71  return NULL;
72  }
73 
74  if (insert_nasl_func (lexic, decl_node->x.str_val, decl_node, lint_mode)
75  == NULL)
76  return NULL;
77  else
78  return FAKE_CELL;
79 }

References FAKE_CELL, insert_nasl_func(), nasl_perror(), TC::str_val, and TC::x.

Referenced by nasl_exec(), nasl_lint_call(), and nasl_lint_def().

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

◆ dump_ctxt()

void dump_ctxt ( lex_ctxt )

Definition at line 52 of file nasl_lex_ctxt.c.

53 {
54  int i;
55  named_nasl_var *v;
56 
57  printf ("--------<CTXT>--------\n");
58  if (c->fct_ctxt)
59  printf ("Is a function context\n");
60  if (c->up_ctxt == NULL)
61  printf ("Is the top level context\n");
62  if (c->ret_val)
63  {
64  printf ("Return value\n");
65  nasl_dump_tree (c->ret_val);
66  }
67 
68  printf ("Variables:\n");
69  for (i = 0; i < VAR_NAME_HASH; i++)
70  for (v = c->ctx_vars.hash_elt[i]; v != NULL; v = v->next_var)
71  printf ("%s\t", v->var_name);
72  putchar ('\n');
73 
74  printf ("----------------------\n");
75 }

References struct_lex_ctxt::ctx_vars, struct_lex_ctxt::fct_ctxt, st_nasl_array::hash_elt, nasl_dump_tree(), st_n_nasl_var::next_var, struct_lex_ctxt::ret_val, struct_lex_ctxt::up_ctxt, st_n_nasl_var::var_name, and VAR_NAME_HASH.

Referenced by nasl_dump_ctxt().

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

◆ free_lex_ctxt()

void free_lex_ctxt ( lex_ctxt )

Definition at line 43 of file nasl_lex_ctxt.c.

44 {
45  deref_cell (c->ret_val);
46  free_array (&c->ctx_vars);
47  g_hash_table_destroy (c->functions);
48  g_free (c);
49 }

References struct_lex_ctxt::ctx_vars, deref_cell(), free_array(), struct_lex_ctxt::functions, and struct_lex_ctxt::ret_val.

Referenced by exec_nasl_script(), nasl_func_call(), and nasl_lint().

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

◆ get_array_elem()

tree_cell* get_array_elem ( lex_ctxt ,
const char *  ,
tree_cell  
)

Definition at line 211 of file nasl_var.c.

212  {
213  named_nasl_var *nv;
214  anon_nasl_var *u, *av, fake_var;
215  tree_cell *tc, idx0;
216 
217  /* Fake variable */
218  if (strcmp (name, "_FCT_ANON_ARGS") == 0)
219  {
220  lex_ctxt *c;
221  for (c = ctxt; c != NULL && !c->fct_ctxt; c = c->up_ctxt)
222  ;
223  if (c == NULL)
224  return NULL;
225  fake_var.var_type = VAR2_ARRAY;
226  fake_var.v.v_arr = c->ctx_vars;
227  fake_var.v.v_arr.hash_elt = NULL; /* mask named elements */
228  u = &fake_var;
229  }
230  else
231  {
232  named_nasl_var *v = get_var_ref_by_name (ctxt, name, 1);
233  u = &v->u;
234  }
235 
236  if (idx == NULL)
237  {
238  /* Treat it as zero */
239  memset (&idx0, '\0', sizeof (idx0));
240  idx = &idx0;
241  idx->type = CONST_INT;
242  }
243 
244  switch (u->var_type)
245  {
246  case VAR2_UNDEF:
247  /* We define the array here */
248  u->var_type = VAR2_ARRAY;
249  /* fallthrough */
250  case VAR2_ARRAY:
251  switch (idx->type)
252  {
253  case CONST_INT:
254  av = nasl_get_var_by_num (ctxt, &u->v.v_arr, idx->x.i_val,
255  /* avoid dangling pointers */
256  strcmp (name, "_FCT_ANON_ARGS"));
257  return var2cell (av);
258 
259  case CONST_STR:
260  case CONST_DATA:
261  nv = get_var_by_name (&u->v.v_arr, idx->x.str_val);
262  return var2cell (nv != NULL ? &nv->u : NULL);
263 
264  default:
265  nasl_perror (ctxt,
266  "get_array_elem: unhandled index type 0x%x for "
267  "variable %s\n",
268  idx->type, name);
269  return NULL;
270  }
271  /*NOTREACHED*/ break;
272 
273  case VAR2_INT:
274  nasl_perror (ctxt, "get_array_elem: variable %s is an integer\n", name);
275  return NULL;
276 
277  case VAR2_STRING:
278  case VAR2_DATA:
279  if (idx->type == CONST_INT)
280  {
281  int l = u->v.v_str.s_siz;
282 
283  if (idx->x.i_val >= l)
284  {
285  nasl_perror (ctxt,
286  "get_array_elem: requesting character after end "
287  "of string %s (%d >= %d)\n",
288  name, idx->x.i_val, l);
289  tc = alloc_expr_cell (idx->line_nb, CONST_DATA /*CONST_STR */,
290  NULL, NULL);
291  tc->x.str_val = g_strdup ("");
292  tc->size = 0;
293  return tc;
294  }
295  else
296  {
297  if (idx->x.i_val < 0)
298  {
299  nasl_perror (ctxt,
300  "get_array_elem: Negative index (%d) passed to "
301  "\"%s\"!\n",
302  idx->x.i_val, name);
303  return NULL;
304  }
305  tc = alloc_expr_cell (idx->line_nb, CONST_DATA /*CONST_STR */,
306  NULL, NULL);
307  tc->x.str_val = g_malloc0 (2);
308  tc->x.str_val[0] = u->v.v_str.s_val[idx->x.i_val];
309  tc->x.str_val[1] = '\0';
310  tc->size = 1;
311  return tc;
312  }
313  }
314  else
315  {
316  nasl_perror (ctxt,
317  "get_array_elem: Cannot use a non integer index"
318  " (type 0x%x) in string. Variable: %s\n",
319  idx->type, name);
320  return NULL;
321  }
322  /*NOTREACHED*/ break;
323 
324  default:
325  nasl_perror (ctxt, "Severe bug: unknown variable type 0x%x %s\n",
326  u->var_type, get_line_nb (idx));
327  return NULL;
328  }
329  /*NOTREACHED*/ return NULL;
330  }

References alloc_expr_cell(), CONST_DATA, CONST_INT, CONST_STR, struct_lex_ctxt::ctx_vars, struct_lex_ctxt::fct_ctxt, get_line_nb(), get_var_by_name(), get_var_ref_by_name(), st_nasl_array::hash_elt, TC::i_val, TC::line_nb, name, nasl_get_var_by_num(), nasl_perror(), st_nasl_string::s_siz, st_nasl_string::s_val, TC::size, TC::str_val, TC::type, st_n_nasl_var::u, struct_lex_ctxt::up_ctxt, st_a_nasl_var::v, st_a_nasl_var::v_arr, st_a_nasl_var::v_str, VAR2_ARRAY, VAR2_DATA, VAR2_INT, VAR2_STRING, VAR2_UNDEF, var2cell(), st_a_nasl_var::var_type, and TC::x.

Referenced by nasl_exec().

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

◆ get_func_ref_by_name()

nasl_func* get_func_ref_by_name ( lex_ctxt ,
const char *   
)

Definition at line 82 of file nasl_func.c.

83 {
84  nasl_func *f;
85 
86  if ((f = get_func (ctxt, name)))
87  return f;
88  else
89  return NULL;
90 }

References get_func(), and name.

Referenced by exec_nasl_script(), make_call_func_list(), nasl_defined_func(), nasl_exec(), nasl_lint_call(), and nasl_lint_def().

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

◆ get_int_var_by_name()

long int get_int_var_by_name ( lex_ctxt ,
const char *  ,
int   
)

Definition at line 1104 of file nasl_var.c.

1105  {
1106  named_nasl_var *v = get_var_ref_by_name (lexic, name, 0);
1107  return var2int (&v->u, defval);
1108  }

References get_var_ref_by_name(), name, st_n_nasl_var::u, and var2int().

Referenced by _http_req(), 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_port_transport(), get_tcp_option(), get_tcp_v6_option(), insert_ip_options(), insert_ip_v6_options(), nasl_bn_random(), nasl_close_stream_cipher(), nasl_crap(), nasl_dec2str(), nasl_egrep(), nasl_ereg(), nasl_ereg_replace(), nasl_eregmatch(), nasl_file_read(), nasl_file_seek(), nasl_file_write(), nasl_forge_frame(), nasl_ftp_get_pasv_address(), nasl_ftp_log_in(), nasl_get_sign(), nasl_get_sock_info(), nasl_isotime_add(), nasl_localtime(), nasl_match(), nasl_mktime(), nasl_ntlm_response(), nasl_ntlmv2_hash(), nasl_ntlmv2_response(), nasl_open_privileged_socket(), nasl_open_sock_tcp_bufsz(), nasl_pcap_next(), nasl_pread(), nasl_prf(), nasl_rc4_encrypt(), nasl_recv(), nasl_recv_line(), nasl_rsa_private_decrypt(), nasl_rsa_public_encrypt(), nasl_same_host(), nasl_scanner_add_port(), nasl_send(), nasl_send_arp_request(), nasl_send_capture(), nasl_send_frame(), nasl_send_packet(), nasl_send_v6packet(), nasl_smb3kdf(), nasl_smb_close(), nasl_smb_file_group_sid(), nasl_smb_file_owner_sid(), nasl_smb_file_SDDL(), nasl_smb_file_trustee_rights(), nasl_snmpv1v2c_get(), nasl_snmpv3_get_action(), nasl_socket_cert_verify(), nasl_socket_check_ssl_safe_renegotiation(), nasl_socket_get_cert(), 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_request_exec(), nasl_ssh_shell_open(), nasl_ssh_shell_read(), nasl_str_replace(), nasl_tcp_ping(), nasl_tcp_v6_ping(), nasl_wmi_close(), 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(), replace_kb_item(), script_add_preference(), script_get_preference(), security_something(), set_ip_elements(), set_ip_v6_elements(), set_kb_item(), set_kb_item_volatile(), set_tcp_elements(), set_tcp_v6_elements(), set_udp_elements(), and set_udp_v6_elements().

Here is the call graph for this function:

◆ get_int_var_by_num()

◆ get_str_var_by_name()

char* get_str_var_by_name ( lex_ctxt ,
const char *   
)

Definition at line 1118 of file nasl_var.c.

1119  {
1120  named_nasl_var *v = get_var_ref_by_name (lexic, name, 0);
1121  return (char *) var2str (&v->u);
1122  }

References get_var_ref_by_name(), name, st_n_nasl_var::u, and var2str().

Referenced by _http_req(), add_hostname(), 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_hostname_source(), get_icmp_element(), get_icmp_v6_element(), get_ip_element(), get_ip_v6_element(), get_tcp_element(), get_tcp_option(), get_tcp_v6_element(), get_tcp_v6_option(), get_udp_element(), get_udp_v6_element(), insert_ip_options(), insert_ip_v6_options(), insert_tcp_options(), insert_tcp_v6_options(), mpi_from_named_parameter(), nasl_bf_cbc(), nasl_crap(), nasl_dump_frame(), nasl_egrep(), nasl_ereg(), nasl_ereg_replace(), nasl_eregmatch(), nasl_file_open(), nasl_file_write(), nasl_forge_frame(), nasl_ftp_log_in(), nasl_fwrite(), nasl_get_sign(), nasl_gunzip(), nasl_gzip(), nasl_hmac(), nasl_hmac_sha256(), nasl_insert_hexzeros(), nasl_keyexchg(), nasl_load_privkey_param(), nasl_mac(), nasl_match(), nasl_ntlm2_response(), nasl_ntlm_response(), nasl_ntlmv1_hash(), nasl_ntlmv2_hash(), nasl_ntlmv2_response(), nasl_ntv2_owf_gen(), nasl_open_sock_tcp_bufsz(), nasl_open_stream_cipher(), nasl_pcap_next(), nasl_pread(), nasl_prf(), nasl_rsa_private_decrypt(), nasl_rsa_public_encrypt(), nasl_rsa_sign(), nasl_scanner_add_port(), nasl_send(), nasl_send_capture(), nasl_send_frame(), nasl_send_packet(), nasl_send_v6packet(), nasl_smb3kdf(), 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_snmpv1v2c_get(), nasl_snmpv3_get_action(), nasl_split(), nasl_ssh_connect(), nasl_ssh_login_interactive_pass(), nasl_ssh_request_exec(), nasl_ssh_set_login(), nasl_ssh_shell_write(), nasl_ssh_userauth(), nasl_str_replace(), 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(), replace_kb_item(), resolve_hostname(), resolve_hostname_to_multiple_ips(), script_add_preference(), script_mandatory_keys(), script_tag(), script_xref(), security_something(), set_ip_elements(), set_ip_v6_elements(), set_kb_item(), set_kb_item_volatile(), set_tcp_elements(), set_tcp_v6_elements(), set_udp_elements(), and set_udp_v6_elements().

Here is the call graph for this function:

◆ get_str_var_by_num()

◆ get_var_size_by_name()

int get_var_size_by_name ( lex_ctxt ,
const char *   
)

Definition at line 1138 of file nasl_var.c.

1139  {
1140  named_nasl_var *v = get_var_ref_by_name (lexic, name, 0);
1141  return get_var_size (&v->u);
1142  }

References get_var_ref_by_name(), get_var_size(), name, and st_n_nasl_var::u.

Referenced by 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_icmp_element(), get_icmp_v6_element(), get_tcp_element(), get_tcp_option(), get_tcp_v6_element(), get_tcp_v6_option(), get_udp_element(), get_udp_v6_element(), insert_ip_options(), insert_ip_v6_options(), insert_tcp_options(), insert_tcp_v6_options(), mpi_from_named_parameter(), nasl_bf_cbc(), nasl_crap(), nasl_dump_frame(), nasl_egrep(), nasl_ereg(), nasl_ereg_replace(), nasl_eregmatch(), nasl_file_write(), nasl_forge_frame(), nasl_fwrite(), nasl_gunzip(), nasl_gzip(), nasl_hmac(), nasl_hmac_sha256(), nasl_insert_hexzeros(), nasl_load_privkey_param(), nasl_mac(), nasl_ntlm2_response(), nasl_ntlm_response(), nasl_ntlmv1_hash(), nasl_ntlmv2_hash(), nasl_ntv2_owf_gen(), nasl_open_stream_cipher(), nasl_prf(), nasl_rsa_sign(), nasl_send(), nasl_send_frame(), nasl_smb3kdf(), nasl_smb_sign(), nasl_split(), nasl_str_replace(), replace_kb_item(), security_something(), set_ip_elements(), set_ip_v6_elements(), set_kb_item(), set_kb_item_volatile(), set_tcp_elements(), set_tcp_v6_elements(), set_udp_elements(), and set_udp_v6_elements().

Here is the call graph for this function:

◆ get_var_size_by_num()

◆ get_var_type_by_name()

int get_var_type_by_name ( lex_ctxt ,
const char *   
)

Definition at line 1162 of file nasl_var.c.

1163  {
1164  named_nasl_var *v = get_var_ref_by_name (lexic, name, 0);
1165  return v == NULL ? VAR2_UNDEF : v->u.var_type;
1166  }

References get_var_ref_by_name(), name, st_n_nasl_var::u, VAR2_UNDEF, and st_a_nasl_var::var_type.

Referenced by nasl_open_sock_tcp_bufsz(), nasl_rsa_private_decrypt(), nasl_rsa_public_encrypt(), replace_kb_item(), set_kb_item(), and set_kb_item_volatile().

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

◆ get_var_type_by_num()

int get_var_type_by_num ( lex_ctxt ,
int   
)

Returns NASL variable/cell type, VAR2_UNDEF if value is NULL.

Definition at line 1155 of file nasl_var.c.

1156  {
1157  anon_nasl_var *v = get_var_ref_by_num (lexic, num);
1158  return v == NULL ? VAR2_UNDEF : v->var_type;
1159  }

References get_var_ref_by_num(), VAR2_UNDEF, and st_a_nasl_var::var_type.

Referenced by nasl_get_sock_info(), nasl_isnull(), nasl_isotime_is_valid(), nasl_isotime_scan(), nasl_rawstring(), nasl_string(), and nasl_substr().

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

◆ get_variable_by_name()

tree_cell* get_variable_by_name ( lex_ctxt ,
const char *   
)

Definition at line 179 of file nasl_var.c.

180 {
181  if (name == NULL)
182  return NULL;
183  /* Broken: Need also code in get_array_elem */
184  if (strcmp (name, "_FCT_ANON_ARGS") == 0)
185  {
187  nasl_array *a = retc->x.ref_val = g_malloc0 (sizeof (nasl_array));
188  copy_array (a, &ctxt->ctx_vars, 0);
189  return retc;
190  }
191  else
192  {
193  named_nasl_var *v = get_var_ref_by_name (ctxt, name, 1);
194  return var2cell (&v->u);
195  }
196  /*NOTREACHED*/}

References alloc_typed_cell(), copy_array(), struct_lex_ctxt::ctx_vars, DYN_ARRAY, get_var_ref_by_name(), name, TC::ref_val, st_n_nasl_var::u, var2cell(), and TC::x.

Referenced by nasl_exec(), and nasl_pread().

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

◆ init_empty_lex_ctxt()

lex_ctxt* init_empty_lex_ctxt ( void  )
Todo:
Initialization of the library seems intuitively be necessary only once (involves "linking" the nasl functions to c code). Consider a "prototype" context that has to be created only once and of which copies are made when needed.

Definition at line 20 of file nasl_lex_ctxt.c.

21 {
22  lex_ctxt *c = g_malloc0 (sizeof (lex_ctxt));
23 
24  c->ctx_vars.hash_elt = g_malloc0 (sizeof (named_nasl_var *) * VAR_NAME_HASH);
25  c->ctx_vars.num_elt = NULL;
26  c->ctx_vars.max_idx = 0;
27  c->functions = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
28  (GDestroyNotify) free_func);
29  c->oid = NULL;
30  c->ret_val = NULL;
31  c->fct_ctxt = 0;
32 
38 
39  return c;
40 }

References struct_lex_ctxt::ctx_vars, struct_lex_ctxt::fct_ctxt, free_func(), struct_lex_ctxt::functions, st_nasl_array::hash_elt, init_nasl_library(), st_nasl_array::max_idx, st_nasl_array::num_elt, struct_lex_ctxt::oid, struct_lex_ctxt::ret_val, and VAR_NAME_HASH.

Referenced by exec_nasl_script(), nasl_func_call(), and nasl_lint().

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

◆ insert_nasl_func()

nasl_func* insert_nasl_func ( lex_ctxt ,
const char *  ,
tree_cell ,
int   
)

Definition at line 41 of file nasl_func.c.

43 {
44  nasl_func *pf;
45 
46  if (get_func (lexic, fname))
47  {
48  if (lint_mode == 0)
49  nasl_perror (
50  lexic, "insert_nasl_func: function '%s' is already defined\n", fname);
51  return NULL;
52  }
53  pf = g_malloc0 (sizeof (nasl_func));
54  pf->func_name = g_strdup (fname);
55 
56  if (decl_node != NULL && decl_node != FAKE_CELL)
57  {
58  pf->block = decl_node->link[1];
59  ref_cell (pf->block);
60  }
61  g_hash_table_insert (lexic->functions, pf->func_name, pf);
62  return pf;
63 }

References st_nasl_func::block, FAKE_CELL, st_nasl_func::func_name, struct_lex_ctxt::functions, get_func(), TC::link, nasl_perror(), and ref_cell().

Referenced by decl_nasl_func().

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

◆ nasl_func_call()

tree_cell* nasl_func_call ( lex_ctxt ,
const nasl_func ,
tree_cell  
)

Definition at line 95 of file nasl_func.c.

96 {
97  int nb_u = 0, nb_a = 0;
98  tree_cell *pc = NULL, *pc2 = NULL, *retc = NULL;
99  lex_ctxt *lexic2 = NULL;
100  char *trace_buf = NULL;
101  char *temp_funname = NULL, *tmp_filename = NULL;
102  int trace_buf_len = 0, tn;
103 #define TRACE_BUF_SZ 255
104 
105  /* 1. Create a new context */
106  lexic2 = init_empty_lex_ctxt ();
107  lexic2->script_infos = lexic->script_infos;
108  lexic2->oid = lexic->oid;
109  lexic2->recv_timeout = lexic->recv_timeout;
110  lexic2->fct_ctxt = 1;
111 
112  if (nasl_trace_fp != NULL)
113  {
114  trace_buf = g_malloc0 (TRACE_BUF_SZ);
115  tn = snprintf (trace_buf, TRACE_BUF_SZ, "Call %s(", f->func_name);
116  if (tn > 0)
117  trace_buf_len += tn;
118  }
119 
120  for (pc = arg_list; pc != NULL; pc = pc->link[1])
121  if (pc->x.str_val == NULL)
122  nb_u++;
123 
124  /*
125  * I should look exactly how unnamed arguments works...
126  * Or maybe I should remove this feature?
127  */
128 
129  for (nb_u = 0, pc = arg_list; pc != NULL; pc = pc->link[1])
130  {
131  pc2 = cell2atom (lexic, pc->link[0]);
132  if (pc->x.str_val == NULL)
133  {
134  /* 2. Add unnamed (numbered) variables for unnamed args */
135  if (add_numbered_var_to_ctxt (lexic2, nb_u, pc2) == NULL)
136  goto error;
137  nb_u++;
138  if (nasl_trace_fp != NULL && trace_buf_len < TRACE_BUF_SZ)
139  {
140  tn = snprintf (trace_buf + trace_buf_len,
141  TRACE_BUF_SZ - trace_buf_len, "%s%d: %s",
142  nb_a > 0 ? ", " : "", nb_u, dump_cell_val (pc2));
143  if (tn > 0)
144  trace_buf_len += tn;
145  }
146  nb_a++;
147  }
148  else
149  {
150  /* 3. and add named variables for named args */
151  if (add_named_var_to_ctxt (lexic2, pc->x.str_val, pc2) == NULL)
152  goto error;
153  if (nasl_trace_fp != NULL && trace_buf_len < TRACE_BUF_SZ)
154  {
155  tn = snprintf (trace_buf + trace_buf_len,
156  TRACE_BUF_SZ - trace_buf_len, "%s%s: %s",
157  nb_a > 0 ? ", " : "", pc->x.str_val,
158  dump_cell_val (pc2));
159  if (tn > 0)
160  trace_buf_len += tn;
161  }
162  nb_a++;
163  }
164  deref_cell (pc2);
165  }
166 
167  if (nasl_trace_fp != NULL)
168  {
169  if (trace_buf_len < TRACE_BUF_SZ)
170  nasl_trace (lexic, "NASL> %s)\n", trace_buf);
171  else
172  nasl_trace (lexic, "NASL> %s ...)\n", trace_buf);
173  }
174  /* trace_buf freed here because nasl_trace_fp might get set to NULL during the
175  * execution of nasl_func_call and therefore not get freed if we only free in
176  * the previous if block. This is done to make static analyzer happy. */
177  g_free (trace_buf);
178 
179  /* 4. Chain new context to old (lexic) */
180  lexic2->up_ctxt = lexic;
181  /* 5. Execute */
182  tmp_filename = g_strdup (nasl_get_filename (NULL));
183  nasl_set_filename (nasl_get_filename (f->func_name));
184  if (func_is_internal (f->func_name))
185  {
186 #pragma GCC diagnostic push
187 #pragma GCC diagnostic ignored "-Wpedantic"
188  // unless it is arcane system this void casting should work
189  // therefore ignoring pedantic here.
190  tree_cell *(*pf2) (lex_ctxt *) = f->block;
191 #pragma GCC diagnostic pop
192  retc = pf2 (lexic2);
193  }
194  else
195  {
196  temp_funname = g_strdup (nasl_get_function_name ());
197  nasl_set_function_name (f->func_name);
198  retc = nasl_exec (lexic2, f->block);
199  deref_cell (retc);
200  retc = FAKE_CELL;
201  nasl_set_function_name (temp_funname);
202  g_free (temp_funname);
203  }
204  nasl_set_filename (tmp_filename);
205  g_free (tmp_filename);
206 
207  if ((retc == NULL || retc == FAKE_CELL)
208  && (lexic2->ret_val != NULL && lexic2->ret_val != FAKE_CELL))
209  {
210  retc = lexic2->ret_val;
211  ref_cell (retc);
212  }
213 
214  if (nasl_trace_enabled ())
215  nasl_trace (lexic, "NASL> Return %s: %s\n", f->func_name,
216  dump_cell_val (retc));
217  if (!nasl_is_leaf (retc))
218  {
219  nasl_perror (lexic,
220  "nasl_func_call: return value from %s is not atomic!\n",
221  f->func_name);
222  nasl_dump_tree (retc);
223  }
224 
225  free_lex_ctxt (lexic2);
226  lexic2 = NULL;
227  return retc;
228 
229 error:
230  g_free (trace_buf);
231  free_lex_ctxt (lexic2);
232  return NULL;
233 }

References add_named_var_to_ctxt(), add_numbered_var_to_ctxt(), st_nasl_func::block, cell2atom(), deref_cell(), dump_cell_val(), FAKE_CELL, struct_lex_ctxt::fct_ctxt, free_lex_ctxt(), func_is_internal(), st_nasl_func::func_name, init_empty_lex_ctxt(), TC::link, nasl_dump_tree(), nasl_exec(), nasl_get_filename(), nasl_get_function_name(), nasl_is_leaf(), nasl_perror(), nasl_set_filename(), nasl_set_function_name(), nasl_trace(), nasl_trace_enabled(), nasl_trace_fp, struct_lex_ctxt::oid, struct_lex_ctxt::recv_timeout, ref_cell(), struct_lex_ctxt::ret_val, struct_lex_ctxt::script_infos, TC::str_val, TRACE_BUF_SZ, struct_lex_ctxt::up_ctxt, and TC::x.

Referenced by exec_nasl_script(), and nasl_exec().

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

◆ nasl_incr_variable()

tree_cell* nasl_incr_variable ( lex_ctxt ,
tree_cell ,
int  ,
int   
)

Definition at line 922 of file nasl_var.c.

923  {
924  anon_nasl_var *v;
925  int old_val = 0, new_val;
926  tree_cell *retc;
927 
928  if (tc->type != REF_VAR)
929  {
930  nasl_perror (
931  lexic, "nasl_incr_variable: argument (type=%d) is not REF_VAR %s\n",
932  tc->type, get_line_nb (tc));
933  return NULL;
934  }
935 
936  v = tc->x.ref_val;
937 
938  switch (v->var_type)
939  {
940  case VAR2_INT:
941  old_val = v->v.v_int;
942  break;
943  case VAR2_STRING:
944  case VAR2_DATA:
945  old_val =
946  v->v.v_str.s_val == NULL ? 0 : atoi ((char *) v->v.v_str.s_val);
947  break;
948  case VAR2_UNDEF:
949  old_val = 0;
950  break;
951 
952  default:
953  nasl_perror (lexic,
954  "nasl_incr_variable: variable %s has bad type %d %s\n",
955  /*get_var_name(v) */ "", get_line_nb (tc));
956  return NULL;
957  }
958  new_val = old_val + val;
959 
960  clear_anon_var (v);
961  v->var_type = VAR2_INT;
962  v->v.v_int = new_val;
963 
964  retc = alloc_typed_cell (CONST_INT);
965  retc->x.i_val = pre ? new_val : old_val;
966 
967  return retc;
968  }

References alloc_typed_cell(), clear_anon_var(), CONST_INT, get_line_nb(), TC::i_val, nasl_perror(), TC::ref_val, REF_VAR, st_nasl_string::s_val, TC::type, st_a_nasl_var::v, st_a_nasl_var::v_int, st_a_nasl_var::v_str, val, VAR2_DATA, VAR2_INT, VAR2_STRING, VAR2_UNDEF, st_a_nasl_var::var_type, and TC::x.

Referenced by nasl_exec().

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

◆ nasl_read_var_ref()

tree_cell* nasl_read_var_ref ( lex_ctxt ,
tree_cell  
)

Definition at line 835 of file nasl_var.c.

836  {
837  tree_cell *ret;
838  anon_nasl_var *v;
839 
840  if (tc == NULL || tc == FAKE_CELL)
841  {
842  nasl_perror (lexic,
843  "nasl_read_var_ref: cannot read NULL or FAKE cell\n");
844  return NULL;
845  }
846  if (tc->type != REF_VAR)
847  {
848  nasl_perror (lexic,
849  "nasl_read_var_ref: argument (type=%d) is not REF_VAR %s\n",
850  tc->type, get_line_nb (tc));
851  return NULL;
852  }
853 
854  v = tc->x.ref_val;
855  if (v == NULL)
856  return NULL;
857 
859  ret->line_nb = tc->line_nb;
860 
861  switch (v->var_type)
862  {
863  case VAR2_INT:
864  ret->type = CONST_INT;
865  ret->x.i_val = v->v.v_int;
866  if (nasl_trace_enabled ())
867  nasl_trace (lexic, "NASL> %s -> %lu\n", get_var_name (v),
868  ret->x.i_val);
869  return ret;
870 
871  case VAR2_STRING:
872  ret->type = CONST_STR;
873  /* Fix bad string length */
874  if (v->v.v_str.s_siz <= 0 && v->v.v_str.s_val[0] != '\0')
875  {
876  v->v.v_str.s_siz = strlen ((char *) v->v.v_str.s_val);
877  nasl_perror (lexic, "nasl_read_var_ref: Bad string length fixed\n");
878  }
879  /* fallthrough */
880  case VAR2_DATA:
881  ret->type = v->var_type == VAR2_STRING ? CONST_STR : CONST_DATA;
882  if (v->v.v_str.s_val == NULL)
883  {
884  ret->x.str_val = NULL;
885  ret->size = 0;
886  }
887  else
888  {
889  ret->x.str_val = g_malloc0 (v->v.v_str.s_siz + 1);
890  memcpy (ret->x.str_val, v->v.v_str.s_val, v->v.v_str.s_siz);
891  ret->size = v->v.v_str.s_siz;
892  }
893  if (nasl_trace_enabled ())
894  nasl_trace (lexic, "NASL> %s -> \"%s\"\n", get_var_name (v),
895  ret->x.str_val);
896  return ret;
897 
898  case VAR2_ARRAY:
899  ret->type = REF_ARRAY;
900  ret->x.ref_val = &v->v.v_arr;
901  return ret;
902 
903  case VAR2_UNDEF:
904  if (nasl_trace_enabled ())
905  nasl_trace (lexic, "NASL> %s -> undef\n", get_var_name (v),
906  v->var_type);
907  break;
908 
909  default:
910  nasl_perror (lexic, "nasl_read_var_ref: unhandled variable type %d\n",
911  v->var_type);
912  if (nasl_trace_enabled ())
913  nasl_trace (lexic, "NASL> %s -> ???? (Var type %d)\n",
914  get_var_name (v), v->var_type);
915  break;
916  }
917  deref_cell (ret);
918  return NULL;
919  }

References alloc_typed_cell(), CONST_DATA, CONST_INT, CONST_STR, deref_cell(), FAKE_CELL, get_line_nb(), get_var_name(), TC::i_val, TC::line_nb, nasl_perror(), nasl_trace(), nasl_trace_enabled(), NODE_EMPTY, REF_ARRAY, TC::ref_val, REF_VAR, st_nasl_string::s_siz, st_nasl_string::s_val, TC::size, TC::str_val, TC::type, st_a_nasl_var::v, st_a_nasl_var::v_arr, st_a_nasl_var::v_int, st_a_nasl_var::v_str, VAR2_ARRAY, VAR2_DATA, VAR2_INT, VAR2_STRING, VAR2_UNDEF, st_a_nasl_var::var_type, and TC::x.

Referenced by nasl_exec().

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

◆ nasl_return()

tree_cell* nasl_return ( lex_ctxt ,
tree_cell  
)

Definition at line 236 of file nasl_func.c.

237 {
238  tree_cell *c;
239 
240  retv = cell2atom (ctxt, retv);
241  if (retv == NULL)
242  retv = FAKE_CELL;
243 
244  if (retv != FAKE_CELL && retv->type == REF_ARRAY)
245  /* We have to "copy" it as the referenced array will be freed */
246  {
247  c = copy_ref_array (retv);
248  deref_cell (retv);
249  retv = c;
250  }
251 
252  while (ctxt != NULL)
253  {
254  ctxt->ret_val = retv;
255  ref_cell (retv);
256  if (ctxt->fct_ctxt)
257  break;
258  ctxt = ctxt->up_ctxt;
259  }
260  /* Bug? Do not return NULL, as we may test it to break the control flow */
261  deref_cell (retv);
262  return FAKE_CELL;
263 }

References cell2atom(), copy_ref_array(), deref_cell(), FAKE_CELL, struct_lex_ctxt::fct_ctxt, REF_ARRAY, ref_cell(), struct_lex_ctxt::ret_val, TC::type, and struct_lex_ctxt::up_ctxt.

Referenced by nasl_exec().

Here is the call graph for this function:
Here is the caller graph for this function:
st_a_nasl_var
Definition: nasl_var.h:40
get_var_name
static const char * get_var_name(anon_nasl_var *v)
Definition: nasl_var.c:199
free_array
void free_array(nasl_array *a)
Definition: nasl_var.c:342
struct_lex_ctxt::ctx_vars
nasl_array ctx_vars
Definition: nasl_lex_ctxt.h:35
CONST_DATA
@ CONST_DATA
Definition: nasl_tree.h:82
nasl_trace
void nasl_trace(lex_ctxt *lexic, char *msg,...)
Prints debug message in printf fashion to nasl_trace_fp if it exists.
Definition: nasl_debug.c:175
add_named_var_to_ctxt
named_nasl_var * add_named_var_to_ctxt(lex_ctxt *, const char *, tree_cell *)
Definition: nasl_var.c:813
get_func
static nasl_func * get_func(lex_ctxt *ctxt, const char *name)
This function climbs up in the context list and searches for a given.
Definition: nasl_func.c:25
add_numbered_var_to_ctxt
anon_nasl_var * add_numbered_var_to_ctxt(lex_ctxt *, int, tree_cell *)
Definition: nasl_var.c:784
VAR2_UNDEF
@ VAR2_UNDEF
Definition: nasl_var.h:15
TC::str_val
char * str_val
Definition: nasl_tree.h:103
create_named_var
static named_nasl_var * create_named_var(const char *name, tree_cell *val)
Definition: nasl_var.c:722
get_var_ref_by_num
static anon_nasl_var * get_var_ref_by_num(lex_ctxt *ctxt, int num)
Definition: nasl_var.c:141
nasl_get_function_name
const char * nasl_get_function_name()
Definition: nasl_debug.c:82
copy_array
static void copy_array(nasl_array *, const nasl_array *, int)
Definition: nasl_var.c:496
clear_anon_var
static void clear_anon_var(anon_nasl_var *v)
Definition: nasl_var.c:406
CONST_STR
@ CONST_STR
Definition: nasl_tree.h:80
st_n_nasl_var
Definition: nasl_var.h:55
var2str
const char * var2str(anon_nasl_var *v)
Definition: nasl_var.c:1065
nasl_dump_tree
void nasl_dump_tree(const tree_cell *c)
Definition: nasl_tree.c:366
st_nasl_array::max_idx
int max_idx
Definition: nasl_var.h:34
st_a_nasl_var::v_arr
nasl_array v_arr
Definition: nasl_var.h:49
TC::x
union TC::@5 x
st_nasl_array::hash_elt
struct st_n_nasl_var ** hash_elt
Definition: nasl_var.h:36
struct_lex_ctxt::functions
GHashTable * functions
Definition: nasl_lex_ctxt.h:37
DYN_ARRAY
@ DYN_ARRAY
Definition: nasl_tree.h:90
nasl_exec
tree_cell * nasl_exec(lex_ctxt *lexic, tree_cell *st)
Execute a parse tree.
Definition: exec.c:770
st_nasl_func
Definition: nasl_func.h:15
FAKE_CELL
#define FAKE_CELL
Definition: nasl_tree.h:110
st_n_nasl_var::var_name
char * var_name
Definition: nasl_var.h:58
create_anon_var
static anon_nasl_var * create_anon_var(tree_cell *val)
Definition: nasl_var.c:743
nasl_set_function_name
void nasl_set_function_name(const char *funname)
Definition: nasl_debug.c:73
st_a_nasl_var::v
union st_a_nasl_var::@7 v
st_a_nasl_var::v_str
nasl_string_t v_str
Definition: nasl_var.h:47
VAR2_STRING
@ VAR2_STRING
Definition: nasl_var.h:17
st_nasl_string::s_siz
int s_siz
Definition: nasl_var.h:27
name
const char * name
Definition: nasl_init.c:411
VAR2_DATA
@ VAR2_DATA
Definition: nasl_var.h:18
st_nasl_array
Definition: nasl_var.h:33
TRACE_BUF_SZ
#define TRACE_BUF_SZ
struct_lex_ctxt::up_ctxt
struct struct_lex_ctxt * up_ctxt
Definition: nasl_lex_ctxt.h:24
VAR2_INT
@ VAR2_INT
Definition: nasl_var.h:16
cell2atom
tree_cell * cell2atom(lex_ctxt *lexic, tree_cell *c1)
Definition: exec.c:194
get_var_by_name
static named_nasl_var * get_var_by_name(nasl_array *a, const char *s)
Definition: nasl_var.c:78
st_n_nasl_var::next_var
struct st_n_nasl_var * next_var
Definition: nasl_var.h:62
nasl_perror
void nasl_perror(lex_ctxt *lexic, char *msg,...)
Definition: nasl_debug.c:111
nasl_trace_enabled
int nasl_trace_enabled(void)
Checks if the nasl_trace_fp is set.
Definition: nasl_debug.c:161
insert_nasl_func
nasl_func * insert_nasl_func(lex_ctxt *lexic, const char *fname, tree_cell *decl_node, int lint_mode)
Definition: nasl_func.c:41
func_is_internal
nasl_func * func_is_internal(const char *)
Definition: nasl_init.c:526
dump_cell_val
char * dump_cell_val(const tree_cell *c)
Definition: nasl_tree.c:234
get_var_size
static int get_var_size(const anon_nasl_var *v)
Definition: nasl_var.c:1124
TC::size
int size
Definition: nasl_tree.h:99
var2cell
tree_cell * var2cell(anon_nasl_var *v)
Definition: nasl_var.c:171
TC::line_nb
short line_nb
Definition: nasl_tree.h:96
struct_lex_ctxt::oid
const char * oid
Definition: nasl_lex_ctxt.h:31
free_lex_ctxt
void free_lex_ctxt(lex_ctxt *c)
Definition: nasl_lex_ctxt.c:43
struct_lex_ctxt::fct_ctxt
unsigned fct_ctxt
Definition: nasl_lex_ctxt.h:26
VAR2_ARRAY
@ VAR2_ARRAY
Definition: nasl_var.h:19
TC::ref_val
void * ref_val
Definition: nasl_tree.h:105
st_a_nasl_var::var_type
int var_type
Definition: nasl_var.h:41
st_nasl_func::block
void * block
Definition: nasl_func.h:17
free_func
void free_func(nasl_func *f)
Definition: nasl_func.c:266
get_line_nb
char * get_line_nb(const tree_cell *c)
Definition: nasl_tree.c:379
init_nasl_library
void init_nasl_library(lex_ctxt *)
Adds "built-in" variable and function definitions to a context.
Definition: nasl_init.c:486
struct_lex_ctxt::script_infos
struct script_infos * script_infos
Definition: nasl_lex_ctxt.h:30
alloc_expr_cell
tree_cell * alloc_expr_cell(int lnb, int t, tree_cell *l, tree_cell *r)
Definition: nasl_tree.c:63
st_nasl_func::func_name
char * func_name
Definition: nasl_func.h:16
TC
Definition: nasl_tree.h:94
struct_lex_ctxt
Definition: nasl_lex_ctxt.h:23
TC::type
short type
Definition: nasl_tree.h:95
TC::link
struct TC * link[4]
Definition: nasl_tree.h:107
decl_local_variables
tree_cell * decl_local_variables(lex_ctxt *lexic, tree_cell *vars)
Definition: nasl_var.c:761
ref_cell
void ref_cell(tree_cell *c)
Definition: nasl_tree.c:167
REF_VAR
@ REF_VAR
Definition: nasl_tree.h:88
CONST_INT
@ CONST_INT
Definition: nasl_tree.h:79
nasl_is_leaf
int nasl_is_leaf(const tree_cell *pc)
Definition: nasl_tree.c:389
val
const char * val
Definition: nasl_init.c:412
var2int
static long int var2int(anon_nasl_var *v, int defval)
Definition: nasl_var.c:971
add_named_var_to_ctxt
named_nasl_var * add_named_var_to_ctxt(lex_ctxt *lexic, const char *name, tree_cell *val)
Definition: nasl_var.c:813
struct_lex_ctxt::recv_timeout
int recv_timeout
Definition: nasl_lex_ctxt.h:32
hash_str
static int hash_str(const char *s)
Definition: nasl_var.c:40
nasl_trace_fp
FILE * nasl_trace_fp
Definition: exec.c:357
copy_ref_array
tree_cell * copy_ref_array(const tree_cell *c1)
Definition: nasl_var.c:537
nasl_get_filename
const char * nasl_get_filename(const char *function)
Definition: nasl_debug.c:60
get_var_ref_by_name
static named_nasl_var * get_var_ref_by_name(lex_ctxt *ctxt, const char *name, int climb)
This function climbs up in the context list.
Definition: nasl_var.c:103
st_a_nasl_var::v_int
long int v_int
Definition: nasl_var.h:48
REF_ARRAY
@ REF_ARRAY
Definition: nasl_tree.h:89
nasl_set_filename
void nasl_set_filename(const char *filename)
Definition: nasl_debug.c:88
free_anon_var
static void free_anon_var(anon_nasl_var *)
Definition: nasl_var.c:387
deref_cell
void deref_cell(tree_cell *c)
Definition: nasl_tree.c:181
alloc_typed_cell
tree_cell * alloc_typed_cell(int typ)
Definition: nasl_tree.c:28
st_n_nasl_var::u
struct st_a_nasl_var u
Definition: nasl_var.h:56
init_empty_lex_ctxt
lex_ctxt * init_empty_lex_ctxt()
Definition: nasl_lex_ctxt.c:20
NODE_EMPTY
@ NODE_EMPTY
Definition: nasl_tree.h:13
VAR_NAME_HASH
#define VAR_NAME_HASH
Definition: nasl_var.h:22
nasl_get_var_by_num
anon_nasl_var * nasl_get_var_by_num(void *ctxt, nasl_array *a, int num, int create)
Definition: nasl_var.c:46
st_nasl_string::s_val
unsigned char * s_val
Definition: nasl_var.h:26
struct_lex_ctxt::ret_val
tree_cell * ret_val
Definition: nasl_lex_ctxt.h:25
TC::i_val
long int i_val
Definition: nasl_tree.h:104
st_nasl_array::num_elt
struct st_a_nasl_var ** num_elt
Definition: nasl_var.h:35