|
OpenVAS Scanner 23.40.3
|
Functions related to text-related utilities in the NASL functions. More...
#include <stddef.h>#include "nasl_text_utils.h"#include "../misc/strutils.h"#include "exec.h"#include "nasl_debug.h"#include "nasl_func.h"#include "nasl_global_ctxt.h"#include "nasl_lex_ctxt.h"#include "nasl_tree.h"#include "nasl_var.h"#include <ctype.h>#include <glib.h>#include <regex.h>#include <string.h>#include <unistd.h>
Go to the source code of this file.
Macros | |
| #define | _GNU_SOURCE |
| #define | G_LOG_DOMAIN "lib nasl" |
| GLib logging domain. | |
| #define | RAW_STR_LEN 32768 |
| #define | NS 16 |
| #define | MAX_INT (~(1 << (sizeof (int) * 8 - 1))) |
Functions | |
| tree_cell * | nasl_string (lex_ctxt *lexic) |
| tree_cell * | nasl_rawstring (lex_ctxt *lexic) |
| tree_cell * | nasl_strlen (lex_ctxt *lexic) |
| tree_cell * | nasl_strcat (lex_ctxt *lexic) |
| tree_cell * | nasl_display (lex_ctxt *lexic) |
| tree_cell * | nasl_hex (lex_ctxt *lexic) |
| tree_cell * | nasl_hexstr (lex_ctxt *lexic) |
| tree_cell * | nasl_ord (lex_ctxt *lexic) |
| tree_cell * | nasl_tolower (lex_ctxt *lexic) |
| tree_cell * | nasl_toupper (lex_ctxt *lexic) |
| tree_cell * | nasl_ereg (lex_ctxt *lexic) |
| Matches a string against a regular expression. | |
| static char * | _regreplace (const char *pattern, const char *replace, const char *string, int icase, int extended) |
| tree_cell * | nasl_ereg_replace (lex_ctxt *lexic) |
| Search for a pattern in a string and replace it. | |
| tree_cell * | nasl_egrep (lex_ctxt *lexic) |
| looks for a pattern in a string, line by line. | |
| tree_cell * | nasl_eregmatch (lex_ctxt *lexic) |
| Does extended regular expression pattern matching. | |
| tree_cell * | nasl_substr (lex_ctxt *lexic) |
| tree_cell * | nasl_insstr (lex_ctxt *lexic) |
| tree_cell * | nasl_match (lex_ctxt *lexic) |
| tree_cell * | nasl_split (lex_ctxt *lexic) |
| tree_cell * | nasl_chomp (lex_ctxt *lexic) |
| Takes an unnamed string argument and removes any spaces at the end of it. "Space" means white space, vertical or horizontal tabulation, carriage return or line feed. | |
| tree_cell * | nasl_crap (lex_ctxt *lexic) |
| tree_cell * | nasl_strstr (lex_ctxt *lexic) |
| tree_cell * | nasl_stridx (lex_ctxt *lexic) |
| Returns index of a substring. | |
| tree_cell * | nasl_str_replace (lex_ctxt *lexic) |
| tree_cell * | nasl_int (lex_ctxt *lexic) |
Functions related to text-related utilities in the NASL functions.
Definition in file nasl_text_utils.c.
| #define _GNU_SOURCE |
Definition at line 13 of file nasl_text_utils.c.
| #define G_LOG_DOMAIN "lib nasl" |
GLib logging domain.
Definition at line 37 of file nasl_text_utils.c.
| #define MAX_INT (~(1 << (sizeof (int) * 8 - 1))) |
Referenced by nasl_substr().
| #define NS 16 |
Definition at line 513 of file nasl_text_utils.c.
Referenced by _regreplace(), nasl_egrep(), and nasl_eregmatch().
| #define RAW_STR_LEN 32768 |
Definition at line 136 of file nasl_text_utils.c.
Referenced by nasl_rawstring().
|
static |
Definition at line 519 of file nasl_text_utils.c.
References NS.
Referenced by nasl_ereg_replace().

Takes an unnamed string argument and removes any spaces at the end of it. "Space" means white space, vertical or horizontal tabulation, carriage return or line feed.
Definition at line 1204 of file nasl_text_utils.c.
References alloc_typed_cell(), CONST_DATA, get_str_var_by_num(), len, TC::size, TC::str_val, and TC::x.

Definition at line 1227 of file nasl_text_utils.c.
References alloc_typed_cell(), CONST_DATA, FAKE_CELL, get_int_var_by_name(), get_int_var_by_num(), get_str_var_by_name(), get_var_size_by_name(), len, nasl_perror(), TC::size, TC::str_val, and TC::x.

Definition at line 303 of file nasl_text_utils.c.
References alloc_typed_cell(), CONST_INT, deref_cell(), TC::i_val, nasl_string(), TC::size, TC::str_val, and TC::x.

looks for a pattern in a string, line by line.
| [in] | lexic | Lexical context of NASL interpreter. |
Definition at line 733 of file nasl_text_utils.c.
References alloc_typed_cell(), CONST_DATA, FAKE_CELL, get_int_var_by_name(), get_str_var_by_name(), get_var_size_by_name(), nasl_perror(), NS, TC::size, TC::str_val, and TC::x.

Matches a string against a regular expression.
| [in] | lexic | Lexical context of NASL interpreter. |
Definition at line 457 of file nasl_text_utils.c.
References alloc_typed_cell(), CONST_INT, get_int_var_by_name(), get_str_var_by_name(), get_var_size_by_name(), TC::i_val, nasl_perror(), and TC::x.

Search for a pattern in a string and replace it.
| [in] | lexic | Lexical context of NASL interpreter. |
Definition at line 678 of file nasl_text_utils.c.
References _regreplace(), alloc_typed_cell(), CONST_DATA, FAKE_CELL, get_int_var_by_name(), get_str_var_by_name(), get_var_size_by_name(), nasl_perror(), TC::size, TC::str_val, and TC::x.

Does extended regular expression pattern matching.
| [in] | lexic | Lexical context of NASL interpreter. |
Definition at line 858 of file nasl_text_utils.c.
References add_var_to_list(), alloc_typed_cell(), DYN_ARRAY, get_int_var_by_name(), get_str_var_by_name(), get_var_size_by_name(), nasl_perror(), NS, TC::ref_val, st_nasl_string::s_siz, st_nasl_string::s_val, st_a_nasl_var::v, st_a_nasl_var::v_str, VAR2_DATA, st_a_nasl_var::var_type, and TC::x.

Definition at line 327 of file nasl_text_utils.c.
References alloc_typed_cell(), CONST_STR, get_int_var_by_num(), TC::size, TC::str_val, and TC::x.

Definition at line 347 of file nasl_text_utils.c.
References alloc_typed_cell(), CONST_STR, get_str_var_by_num(), get_var_size_by_num(), len, TC::size, TC::str_val, and TC::x.

Syntax: insstr(s1, s2, i1, i2) or insstr(s1, s2, i1) Insert string s2 into slice [i1:i2] of string s1 and returns the result Warning: returns a CONST_DATA!
Definition at line 1015 of file nasl_text_utils.c.
References alloc_typed_cell(), CONST_DATA, get_int_var_by_num(), get_str_var_by_num(), get_var_size_by_num(), nasl_perror(), TC::size, TC::str_val, and TC::x.

Definition at line 1444 of file nasl_text_utils.c.
References alloc_typed_cell(), CONST_INT, get_int_var_by_num(), TC::i_val, and TC::x.

Definition at line 1073 of file nasl_text_utils.c.
References alloc_typed_cell(), CONST_INT, get_int_var_by_name(), get_str_var_by_name(), TC::i_val, nasl_perror(), str_match(), and TC::x.

Definition at line 374 of file nasl_text_utils.c.
References alloc_typed_cell(), CONST_INT, get_str_var_by_num(), TC::i_val, nasl_perror(), val, and TC::x.

Definition at line 138 of file nasl_text_utils.c.
References alloc_typed_cell(), array_max_index(), CONST_DATA, struct_lex_ctxt::ctx_vars, get_int_var_by_num(), get_str_var_by_num(), get_var_size_by_num(), get_var_type_by_num(), nasl_perror(), RAW_STR_LEN, TC::size, TC::str_val, VAR2_INT, VAR2_STRING, VAR2_UNDEF, and TC::x.

Definition at line 1097 of file nasl_text_utils.c.
References add_var_to_list(), alloc_typed_cell(), DYN_ARRAY, get_int_var_by_name(), get_str_var_by_name(), get_str_var_by_num(), get_var_size_by_name(), get_var_size_by_num(), len, nasl_perror(), TC::ref_val, st_nasl_string::s_siz, st_nasl_string::s_val, st_a_nasl_var::v, st_a_nasl_var::v_str, VAR2_DATA, st_a_nasl_var::var_type, and TC::x.

str_replace(string: s, find: f, replace: r [,count: n])
Definition at line 1366 of file nasl_text_utils.c.
References alloc_typed_cell(), CONST_DATA, get_int_var_by_name(), get_str_var_by_name(), get_var_size_by_name(), nasl_perror(), TC::size, TC::str_val, and TC::x.

Definition at line 265 of file nasl_text_utils.c.
References alloc_typed_cell(), array_max_index(), CONST_DATA, struct_lex_ctxt::ctx_vars, deref_cell(), get_str_var_by_num(), get_var_size_by_num(), nasl_perror(), TC::size, TC::str_val, and TC::x.

Returns index of a substring.
Returning NULL for "not found" is dangerous as automatic conversion to to integer would change it into 0. So we return (-1).
Definition at line 1330 of file nasl_text_utils.c.
References alloc_typed_cell(), CONST_INT, get_int_var_by_num(), get_str_var_by_num(), get_var_size_by_num(), TC::i_val, nasl_perror(), and TC::x.

Definition at line 40 of file nasl_text_utils.c.
References alloc_typed_cell(), array_max_index(), CONST_DATA, struct_lex_ctxt::ctx_vars, get_str_var_by_num(), get_var_size_by_num(), get_var_type_by_num(), nasl_perror(), TC::size, TC::str_val, VAR2_STRING, VAR2_UNDEF, and TC::x.
Referenced by nasl_display().


Definition at line 254 of file nasl_text_utils.c.
References alloc_typed_cell(), CONST_INT, get_var_size_by_num(), TC::i_val, len, and TC::x.

Definition at line 1289 of file nasl_text_utils.c.
References alloc_typed_cell(), CONST_DATA, FAKE_CELL, get_str_var_by_num(), get_var_size_by_num(), TC::size, TC::str_val, and TC::x.

Syntax: substr(s, i1) or substr(s, i1, i2) Returns character from string s starting for position i1 till the end or position i2 (start of string is 0)
Definition at line 958 of file nasl_text_utils.c.
References alloc_typed_cell(), CONST_DATA, CONST_STR, get_int_var_by_num(), get_str_var_by_num(), get_var_size_by_num(), get_var_type_by_num(), MAX_INT, nasl_perror(), TC::size, TC::str_val, TC::type, and TC::x.

Definition at line 393 of file nasl_text_utils.c.
References alloc_typed_cell(), CONST_DATA, get_str_var_by_num(), get_var_size_by_num(), TC::size, TC::str_val, and TC::x.

Definition at line 417 of file nasl_text_utils.c.
References alloc_typed_cell(), CONST_DATA, get_str_var_by_num(), get_var_size_by_num(), TC::size, TC::str_val, and TC::x.
