OpenVAS Libraries  9.0.3
arglists.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  arglist
 

Macros

#define ARG_STRING   1
 
#define ARG_PTR   2
 
#define ARG_INT   3
 
#define ARG_ARGLIST   4
 

Functions

void arg_add_value (struct arglist *, const char *, int, void *)
 
void arg_prepend_value (struct arglist **, const char *, int, void *)
 
int arg_set_value (struct arglist *, const char *, void *)
 
void * arg_get_value (struct arglist *, const char *)
 
int arg_get_value_int (struct arglist *, const char *)
 
int arg_get_type (struct arglist *, const char *)
 
void arg_dump (struct arglist *, int)
 
void arg_free (struct arglist *)
 
void arg_free_all (struct arglist *)
 
void arg_del_value (struct arglist *, const char *name)
 

Macro Definition Documentation

◆ ARG_ARGLIST

#define ARG_ARGLIST   4

Definition at line 41 of file arglists.h.

◆ ARG_INT

#define ARG_INT   3

Definition at line 40 of file arglists.h.

◆ ARG_PTR

#define ARG_PTR   2

Definition at line 39 of file arglists.h.

◆ ARG_STRING

#define ARG_STRING   1

Definition at line 38 of file arglists.h.

Function Documentation

◆ arg_add_value()

void arg_add_value ( struct arglist ,
const char *  ,
int  ,
void *   
)

Definition at line 170 of file arglists.c.

175 {
176  if (!arglst)
177  return;
178  while (arglst->next)
179  arglst = arglst->next;
180 
181  arglst->name = cache_inc (name);
182  arglst->value = value;
183  arglst->type = type;
184  arglst->next = g_malloc0 (sizeof (struct arglist));
185  arglst->hash = mkhash (arglst->name);
186 }
int type
Definition: arglists.h:34
void * value
Definition: arglists.h:32
const char * name
Definition: nasl_init.c:524

References arglist::name, and arglist::next.

Referenced by exec_nasl_script(), init(), and nasl_start_denial().

Here is the caller graph for this function:

◆ arg_del_value()

void arg_del_value ( struct arglist ,
const char *  name 
)

Definition at line 358 of file arglists.c.

361 {
362  int h = mkhash (name);
363  struct arglist *pivot;
364  struct arglist *element = NULL;
365  struct arglist store;
366 
367  if (args == NULL)
368  return;
369 
370  pivot = args;
371 
372  while (pivot->next != NULL)
373  {
374  if (pivot->hash == h && strcmp (pivot->name, name) == 0)
375  {
376  element = pivot;
377  break;
378  }
379  pivot = pivot->next;
380  }
381 
382  if (!element || element->hash != h || strcmp (element->name, name))
383  return;
384 
385  if (args == element)
386  {
387  element = args->next;
388  memcpy (&store, element, sizeof (struct arglist));
389  memcpy (element, args, sizeof (struct arglist));
390  memcpy (args, &store, sizeof (struct arglist));
391  }
392  else
393  {
394  pivot = args;
395  while (pivot->next != NULL && pivot->next != element)
396  pivot = pivot->next;
397  pivot->next = element->next;
398  }
399  element->next = NULL;
400 
401  arg_free (element);
402 }
void arg_free(struct arglist *arg)
Definition: arglists.c:322
struct arglist * next
Definition: arglists.h:33
const char * name
Definition: nasl_init.c:524
int hash
Definition: arglists.h:35
char * name
Definition: arglists.h:31

◆ arg_dump()

void arg_dump ( struct arglist ,
int   
)

Definition at line 280 of file arglists.c.

283 {
284  const char *spaces = "--------------------";
285  if (!args)
286  {
287  log_legacy_write ("Error ! args == NULL");
288  return;
289  }
290 
291  if (args)
292  while (args->next)
293  {
294  switch (args->type)
295  {
296  case ARG_STRING:
297 
298  log_legacy_write ("%sargs->%s : %s\n", spaces + (20 - level),
299  args->name, (char *) args->value);
300  break;
301  case ARG_ARGLIST:
302 
303  log_legacy_write ("%sargs->%s :\n", spaces + (20 - level),
304  args->name);
305  arg_dump (args->value, level + 1);
306  break;
307  case ARG_INT:
308  log_legacy_write ("%sargs->%s : %d\n", spaces + (20 - level),
309  args->name, (int) GPOINTER_TO_SIZE (args->value));
310  break;
311  default:
312  log_legacy_write ("%sargs->%s : %d\n", spaces + (20 - level),
313  args->name, (int) GPOINTER_TO_SIZE (args->value));
314  break;
315  }
316  args = args->next;
317  }
318 }
#define ARG_INT
Definition: arglists.h:40
void log_legacy_write(const char *format,...)
Legacy function to write a log message.
void arg_dump(struct arglist *args, int level)
Definition: arglists.c:280
#define ARG_STRING
Definition: arglists.h:38
#define ARG_ARGLIST
Definition: arglists.h:41

References ARG_ARGLIST, arg_dump(), ARG_INT, ARG_STRING, log_legacy_write(), arglist::name, arglist::next, arglist::type, and arglist::value.

Referenced by arg_dump(), and open_sock_option().

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

◆ arg_free()

void arg_free ( struct arglist )

Definition at line 322 of file arglists.c.

324 {
325  while (arg)
326  {
327  struct arglist *next = arg->next;
328  cache_dec (arg->name);
329  g_free (arg);
330  arg = next;
331  }
332 }
struct arglist * next
Definition: arglists.h:33

References arglist::next.

◆ arg_free_all()

void arg_free_all ( struct arglist )

Definition at line 336 of file arglists.c.

338 {
339  while (arg)
340  {
341  struct arglist *next = arg->next;
342  switch (arg->type)
343  {
344  case ARG_ARGLIST:
345  arg_free_all (arg->value);
346  break;
347  case ARG_STRING:
348  g_free (arg->value);
349  break;
350  }
351  cache_dec (arg->name);
352  g_free (arg);
353  arg = next;
354  }
355 }
void arg_free_all(struct arglist *arg)
Definition: arglists.c:336
struct arglist * next
Definition: arglists.h:33
#define ARG_STRING
Definition: arglists.h:38
#define ARG_ARGLIST
Definition: arglists.h:41

References ARG_ARGLIST, arg_free_all(), ARG_STRING, arglist::next, arglist::type, and arglist::value.

Referenced by arg_free_all().

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

◆ arg_get_type()

int arg_get_type ( struct arglist ,
const char *   
)

Definition at line 268 of file arglists.c.

271 {
272  args = arg_get (args, name);
273  if (args != NULL)
274  return (args->type);
275  else
276  return -1;
277 }
const char * name
Definition: nasl_init.c:524

◆ arg_get_value()

◆ arg_get_value_int()

int arg_get_value_int ( struct arglist ,
const char *   
)

Definition at line 246 of file arglists.c.

247 {
248  return GPOINTER_TO_SIZE (arg_get_value (args, name));
249 }
const char * name
Definition: nasl_init.c:524
void * arg_get_value(struct arglist *args, const char *name)
Definition: arglists.c:252

References arg_get_value(), and name.

Referenced by nasl_end_denial(), and plugin_run_find_service().

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

◆ arg_prepend_value()

void arg_prepend_value ( struct arglist **  ,
const char *  ,
int  ,
void *   
)

Definition at line 189 of file arglists.c.

191 {
192  struct arglist *new;
193 
194  if (!list || !*list)
195  return;
196 
197  new = g_malloc0 (sizeof (struct arglist));
198  new->name = cache_inc (name);
199  new->value = value;
200  new->type = type;
201  new->next = *list;
202  new->hash = mkhash (new->name);
203  *list = new;
204 }
int type
Definition: arglists.h:34
void * value
Definition: arglists.h:32
const char * name
Definition: nasl_init.c:524

◆ arg_set_value()

int arg_set_value ( struct arglist ,
const char *  ,
void *   
)

Definition at line 225 of file arglists.c.

229 {
230 
231  if (name == NULL)
232  return -1;
233 
234  arglst = arg_get (arglst, name);
235 
236  if (arglst != NULL)
237  {
238  arglst->value = value;
239  return 0;
240  }
241  else
242  return -1;
243 }
void * value
Definition: arglists.h:32
const char * name
Definition: nasl_init.c:524

References name.

Referenced by exec_nasl_script(), and nasl_start_denial().

Here is the caller graph for this function: