mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 08:38:20 +00:00
Deprecate opt_internal_val()
This commit is contained in:
parent
26f6fe01c8
commit
447b052d11
5 changed files with 23 additions and 7 deletions
3
NEWS
3
NEWS
|
@ -166,6 +166,9 @@ Deprecated Functionality
|
|||
|
||||
- ``internal_func()`` is deprecated, use ``zeek::lookup_func()``.
|
||||
|
||||
- ``opt_internal_val()`` is deprecated, use ``lookup_ID()`` or
|
||||
``zeek::lookup_val()``.
|
||||
|
||||
Zeek 3.1.0
|
||||
==========
|
||||
|
||||
|
|
|
@ -406,7 +406,7 @@ void init_net_var()
|
|||
|
||||
pkt_profile_mode = opt_internal_int("pkt_profile_mode");
|
||||
pkt_profile_freq = opt_internal_double("pkt_profile_freq");
|
||||
pkt_profile_file = opt_internal_val("pkt_profile_file");
|
||||
pkt_profile_file = zeek::lookup_val("pkt_profile_file").get();
|
||||
|
||||
load_sample_freq = opt_internal_int("load_sample_freq");
|
||||
|
||||
|
|
20
src/Var.cc
20
src/Var.cc
|
@ -693,31 +693,41 @@ Val* opt_internal_val(const char* name)
|
|||
|
||||
double opt_internal_double(const char* name)
|
||||
{
|
||||
Val* v = opt_internal_val(name);
|
||||
auto id = lookup_ID(name, GLOBAL_MODULE_NAME);
|
||||
if ( ! id ) return 0.0;
|
||||
const auto& v = id->GetVal();
|
||||
return v ? v->InternalDouble() : 0.0;
|
||||
}
|
||||
|
||||
bro_int_t opt_internal_int(const char* name)
|
||||
{
|
||||
Val* v = opt_internal_val(name);
|
||||
auto id = lookup_ID(name, GLOBAL_MODULE_NAME);
|
||||
if ( ! id ) return 0;
|
||||
const auto& v = id->GetVal();
|
||||
return v ? v->InternalInt() : 0;
|
||||
}
|
||||
|
||||
bro_uint_t opt_internal_unsigned(const char* name)
|
||||
{
|
||||
Val* v = opt_internal_val(name);
|
||||
auto id = lookup_ID(name, GLOBAL_MODULE_NAME);
|
||||
if ( ! id ) return 0;
|
||||
const auto& v = id->GetVal();
|
||||
return v ? v->InternalUnsigned() : 0;
|
||||
}
|
||||
|
||||
StringVal* opt_internal_string(const char* name)
|
||||
{
|
||||
Val* v = opt_internal_val(name);
|
||||
auto id = lookup_ID(name, GLOBAL_MODULE_NAME);
|
||||
if ( ! id ) return nullptr;
|
||||
const auto& v = id->GetVal();
|
||||
return v ? v->AsStringVal() : nullptr;
|
||||
}
|
||||
|
||||
TableVal* opt_internal_table(const char* name)
|
||||
{
|
||||
Val* v = opt_internal_val(name);
|
||||
auto id = lookup_ID(name, GLOBAL_MODULE_NAME);
|
||||
if ( ! id ) return nullptr;
|
||||
const auto& v = id->GetVal();
|
||||
return v ? v->AsTableVal() : nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,9 @@ extern Val* internal_val(const char* name);
|
|||
[[deprecated("Remove in v4.1. Use zeek::lookup_const().")]]
|
||||
extern Val* internal_const_val(const char* name); // internal error if not const
|
||||
|
||||
[[deprecated("Remove in v4.1. Use lookup_ID() or zeek::lookup_val().")]]
|
||||
extern Val* opt_internal_val(const char* name); // returns nil if not defined
|
||||
|
||||
extern double opt_internal_double(const char* name);
|
||||
extern bro_int_t opt_internal_int(const char* name);
|
||||
extern bro_uint_t opt_internal_unsigned(const char* name);
|
||||
|
|
|
@ -1000,7 +1000,8 @@ int yywrap()
|
|||
// string type.) If no type is found, the value
|
||||
// is left unchanged.
|
||||
std::string opt_quote; // no optional quote by default
|
||||
Val* v = opt_internal_val(param);
|
||||
auto param_id = lookup_ID(param, GLOBAL_MODULE_NAME);
|
||||
Val* v = param_id ? param_id->GetVal().get() : nullptr;
|
||||
|
||||
if ( v && v->Type() && v->Type()->Tag() == TYPE_STRING )
|
||||
opt_quote = "\""; // use quotes
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue