OpenVAS Libraries  8.0.3
Macros | Functions
nasl_text_utils.c File Reference
#include <ctype.h>
#include <string.h>
#include <unistd.h>
#include <glib.h>
#include <regex.h>
#include "nasl_tree.h"
#include "nasl_global_ctxt.h"
#include "nasl_func.h"
#include "nasl_var.h"
#include "nasl_lex_ctxt.h"
#include "exec.h"
#include "strutils.h"
#include "nasl_debug.h"
#include "nasl_text_utils.h"

Macros

#define _GNU_SOURCE
 
#define RAW_STR_LEN   32768
 
#define NS   16
 
#define MAX_INT   (~(1 << (sizeof(int) * 8 - 1)))
 

Functions

tree_cellnasl_string (lex_ctxt *lexic)
 
tree_cellnasl_rawstring (lex_ctxt *lexic)
 
tree_cellnasl_strlen (lex_ctxt *lexic)
 
tree_cellnasl_strcat (lex_ctxt *lexic)
 
tree_cellnasl_display (lex_ctxt *lexic)
 
tree_cellnasl_hex (lex_ctxt *lexic)
 
tree_cellnasl_hexstr (lex_ctxt *lexic)
 
tree_cellnasl_ord (lex_ctxt *lexic)
 
tree_cellnasl_tolower (lex_ctxt *lexic)
 
tree_cellnasl_toupper (lex_ctxt *lexic)
 
tree_cellnasl_ereg (lex_ctxt *lexic)
 
tree_cellnasl_ereg_replace (lex_ctxt *lexic)
 
tree_cellnasl_egrep (lex_ctxt *lexic)
 
tree_cellnasl_eregmatch (lex_ctxt *lexic)
 Does extended regular expression pattern matching. More...
 
tree_cellnasl_substr (lex_ctxt *lexic)
 
tree_cellnasl_insstr (lex_ctxt *lexic)
 
tree_cellnasl_match (lex_ctxt *lexic)
 
tree_cellnasl_split (lex_ctxt *lexic)
 
tree_cellnasl_chomp (lex_ctxt *lexic)
 
tree_cellnasl_crap (lex_ctxt *lexic)
 
tree_cellnasl_strstr (lex_ctxt *lexic)
 
tree_cellnasl_stridx (lex_ctxt *lexic)
 Returns index of a substring. More...
 
tree_cellnasl_str_replace (lex_ctxt *lexic)
 
tree_cellnasl_int (lex_ctxt *lexic)
 

Detailed Description

This file implements all the functions that are related to text-related utilities in the NASL functions.

Macro Definition Documentation

#define _GNU_SOURCE
#define MAX_INT   (~(1 << (sizeof(int) * 8 - 1)))
#define NS   16
#define RAW_STR_LEN   32768

Function Documentation

tree_cell* nasl_chomp ( lex_ctxt lexic)
Todo:
evaluate early break
tree_cell* nasl_crap ( lex_ctxt lexic)
tree_cell* nasl_display ( lex_ctxt lexic)
tree_cell* nasl_egrep ( lex_ctxt lexic)
tree_cell* nasl_ereg ( lex_ctxt lexic)
tree_cell* nasl_ereg_replace ( lex_ctxt lexic)
tree_cell* nasl_eregmatch ( lex_ctxt lexic)

Does extended regular expression pattern matching.

In NASL, this function returns an array.

tree_cell* nasl_hex ( lex_ctxt lexic)
tree_cell* nasl_hexstr ( lex_ctxt lexic)
tree_cell* nasl_insstr ( lex_ctxt lexic)

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!

tree_cell* nasl_int ( lex_ctxt lexic)
tree_cell* nasl_match ( lex_ctxt lexic)
tree_cell* nasl_ord ( lex_ctxt lexic)
tree_cell* nasl_rawstring ( lex_ctxt lexic)
tree_cell* nasl_split ( lex_ctxt lexic)
tree_cell* nasl_str_replace ( lex_ctxt lexic)

str_replace(string: s, find: f, replace: r [,count: n])

tree_cell* nasl_strcat ( lex_ctxt lexic)
tree_cell* nasl_stridx ( lex_ctxt lexic)

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).

Returns
-1 if string not found, otherwise index of substring.
See also
strstr
tree_cell* nasl_string ( lex_ctxt lexic)
tree_cell* nasl_strlen ( lex_ctxt lexic)
tree_cell* nasl_strstr ( lex_ctxt lexic)
tree_cell* nasl_substr ( lex_ctxt lexic)

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)

tree_cell* nasl_tolower ( lex_ctxt lexic)
tree_cell* nasl_toupper ( lex_ctxt lexic)