OpenVAS Libraries  9.0.3
lint.c
Go to the documentation of this file.
1 /* Nessus Attack Scripting Language "lint"
2  *
3  * Copyright (C) 2004 Michel Arboi
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2,
7  * as published by the Free Software Foundation
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  *
18  */
19 
20 #include "nasl.h"
21 #include "nasl_tree.h"
22 #include "nasl_global_ctxt.h"
23 #include "nasl_func.h"
24 #include "nasl_var.h"
25 #include "nasl_lex_ctxt.h"
26 #include "exec.h"
27 
28 #include "nasl_debug.h"
29 #include "nasl_init.h"
30 
31 #ifndef NASL_DEBUG
32 #define NASL_DEBUG 0
33 #endif
34 
35 tree_cell *
36 nasl_lint (lex_ctxt * lexic, tree_cell * st)
37 {
38  int i;
39  tree_cell *ret = FAKE_CELL;
40  nasl_func *pf;
41 
42  switch (st->type)
43  {
44  case NODE_FUN_DEF:
45  /* x.str_val = function name, [0] = argdecl, [1] = block */
46  ret = decl_nasl_func (lexic, st);
47  return ret;
48  case NODE_FUN_CALL:
49  pf = get_func_ref_by_name (lexic, st->x.str_val);
50  if (pf == NULL)
51  {
52  lexic->line_nb = st->line_nb;
53  nasl_perror (lexic, "Undefined function '%s'\n", st->x.str_val);
54  return NULL;
55  }
56  default:
57  for (i = 0; i < 4; i++)
58  if (st->link[i] != NULL && st->link[i] != FAKE_CELL)
59  if ((ret = nasl_lint (lexic, st->link[i])) == NULL)
60  return NULL;
61  return ret;
62  }
63 
64 }
#define FAKE_CELL
Definition: nasl_tree.h:120
struct TC * link[4]
Definition: nasl_tree.h:117
short type
Definition: nasl_tree.h:107
char * str_val
Definition: nasl_tree.h:113
short line_nb
Definition: nasl_tree.h:108
union TC::@7 x
Definition: nasl_tree.h:105
void nasl_perror(lex_ctxt *lexic, char *msg,...)
Definition: nasl_debug.c:94
tree_cell * nasl_lint(lex_ctxt *lexic, tree_cell *st)
Definition: lint.c:36
nasl_func * get_func_ref_by_name(lex_ctxt *ctxt, const char *name)
Definition: nasl_func.c:126
tree_cell * decl_nasl_func(lex_ctxt *lexic, tree_cell *decl_node)
Definition: nasl_func.c:111