mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 08:08:19 +00:00
Miscellaneous deprecations and renaming
This commit is contained in:
parent
d875ad1a96
commit
4d4c6280e9
14 changed files with 57 additions and 57 deletions
16
src/Expr.cc
16
src/Expr.cc
|
@ -29,7 +29,7 @@
|
||||||
namespace zeek::detail
|
namespace zeek::detail
|
||||||
{
|
{
|
||||||
|
|
||||||
const char* expr_name(BroExprTag t)
|
const char* expr_name(ExprTag t)
|
||||||
{
|
{
|
||||||
static const char* expr_names[int(NUM_EXPRS)] = {
|
static const char* expr_names[int(NUM_EXPRS)] = {
|
||||||
"name",
|
"name",
|
||||||
|
@ -112,7 +112,7 @@ const char* expr_name(BroExprTag t)
|
||||||
|
|
||||||
int Expr::num_exprs = 0;
|
int Expr::num_exprs = 0;
|
||||||
|
|
||||||
Expr::Expr(BroExprTag arg_tag) : tag(arg_tag), paren(false), type(nullptr)
|
Expr::Expr(ExprTag arg_tag) : tag(arg_tag), paren(false), type(nullptr)
|
||||||
{
|
{
|
||||||
SetLocationInfo(&start_location, &end_location);
|
SetLocationInfo(&start_location, &end_location);
|
||||||
opt_info = new ExprOptInfo();
|
opt_info = new ExprOptInfo();
|
||||||
|
@ -606,7 +606,7 @@ TraversalCode ConstExpr::Traverse(TraversalCallback* cb) const
|
||||||
HANDLE_TC_EXPR_POST(tc);
|
HANDLE_TC_EXPR_POST(tc);
|
||||||
}
|
}
|
||||||
|
|
||||||
UnaryExpr::UnaryExpr(BroExprTag arg_tag, ExprPtr arg_op) : Expr(arg_tag), op(std::move(arg_op))
|
UnaryExpr::UnaryExpr(ExprTag arg_tag, ExprPtr arg_op) : Expr(arg_tag), op(std::move(arg_op))
|
||||||
{
|
{
|
||||||
if ( op->IsError() )
|
if ( op->IsError() )
|
||||||
SetError();
|
SetError();
|
||||||
|
@ -1386,7 +1386,7 @@ ValPtr CloneExpr::Fold(Val* v) const
|
||||||
return v->Clone();
|
return v->Clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
IncrExpr::IncrExpr(BroExprTag arg_tag, ExprPtr arg_op) : UnaryExpr(arg_tag, arg_op->MakeLvalue())
|
IncrExpr::IncrExpr(ExprTag arg_tag, ExprPtr arg_op) : UnaryExpr(arg_tag, arg_op->MakeLvalue())
|
||||||
{
|
{
|
||||||
if ( IsError() )
|
if ( IsError() )
|
||||||
return;
|
return;
|
||||||
|
@ -1997,7 +1997,7 @@ ModExpr::ModExpr(ExprPtr arg_op1, ExprPtr arg_op2)
|
||||||
CheckScalarAggOp();
|
CheckScalarAggOp();
|
||||||
}
|
}
|
||||||
|
|
||||||
BoolExpr::BoolExpr(BroExprTag arg_tag, ExprPtr arg_op1, ExprPtr arg_op2)
|
BoolExpr::BoolExpr(ExprTag arg_tag, ExprPtr arg_op1, ExprPtr arg_op2)
|
||||||
: BinaryExpr(arg_tag, std::move(arg_op1), std::move(arg_op2))
|
: BinaryExpr(arg_tag, std::move(arg_op1), std::move(arg_op2))
|
||||||
{
|
{
|
||||||
if ( IsError() )
|
if ( IsError() )
|
||||||
|
@ -2137,7 +2137,7 @@ ValPtr BoolExpr::Eval(Frame* f) const
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
BitExpr::BitExpr(BroExprTag arg_tag, ExprPtr arg_op1, ExprPtr arg_op2)
|
BitExpr::BitExpr(ExprTag arg_tag, ExprPtr arg_op1, ExprPtr arg_op2)
|
||||||
: BinaryExpr(arg_tag, std::move(arg_op1), std::move(arg_op2))
|
: BinaryExpr(arg_tag, std::move(arg_op1), std::move(arg_op2))
|
||||||
{
|
{
|
||||||
if ( IsError() )
|
if ( IsError() )
|
||||||
|
@ -2186,7 +2186,7 @@ BitExpr::BitExpr(BroExprTag arg_tag, ExprPtr arg_op1, ExprPtr arg_op2)
|
||||||
ExprError("requires \"count\" or compatible \"set\" operands");
|
ExprError("requires \"count\" or compatible \"set\" operands");
|
||||||
}
|
}
|
||||||
|
|
||||||
EqExpr::EqExpr(BroExprTag arg_tag, ExprPtr arg_op1, ExprPtr arg_op2)
|
EqExpr::EqExpr(ExprTag arg_tag, ExprPtr arg_op1, ExprPtr arg_op2)
|
||||||
: BinaryExpr(arg_tag, std::move(arg_op1), std::move(arg_op2))
|
: BinaryExpr(arg_tag, std::move(arg_op1), std::move(arg_op2))
|
||||||
{
|
{
|
||||||
if ( IsError() )
|
if ( IsError() )
|
||||||
|
@ -2301,7 +2301,7 @@ bool EqExpr::InvertSense()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
RelExpr::RelExpr(BroExprTag arg_tag, ExprPtr arg_op1, ExprPtr arg_op2)
|
RelExpr::RelExpr(ExprTag arg_tag, ExprPtr arg_op1, ExprPtr arg_op2)
|
||||||
: BinaryExpr(arg_tag, std::move(arg_op1), std::move(arg_op2))
|
: BinaryExpr(arg_tag, std::move(arg_op1), std::move(arg_op2))
|
||||||
{
|
{
|
||||||
if ( IsError() )
|
if ( IsError() )
|
||||||
|
|
26
src/Expr.h
26
src/Expr.h
|
@ -31,7 +31,7 @@ struct function_ingredients;
|
||||||
using IDPtr = IntrusivePtr<ID>;
|
using IDPtr = IntrusivePtr<ID>;
|
||||||
using ScopePtr = IntrusivePtr<Scope>;
|
using ScopePtr = IntrusivePtr<Scope>;
|
||||||
|
|
||||||
enum BroExprTag : int
|
enum ExprTag : int
|
||||||
{
|
{
|
||||||
EXPR_ANY = -1,
|
EXPR_ANY = -1,
|
||||||
EXPR_NAME,
|
EXPR_NAME,
|
||||||
|
@ -104,7 +104,9 @@ enum BroExprTag : int
|
||||||
#define NUM_EXPRS (int(EXPR_NOP) + 1)
|
#define NUM_EXPRS (int(EXPR_NOP) + 1)
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const char* expr_name(BroExprTag t);
|
using BroExprTag [[deprecated("Remove in v6.1. Use ExprTag.")]] = ExprTag;
|
||||||
|
|
||||||
|
extern const char* expr_name(ExprTag t);
|
||||||
|
|
||||||
class AddToExpr;
|
class AddToExpr;
|
||||||
class AnyIndexExpr;
|
class AnyIndexExpr;
|
||||||
|
@ -151,7 +153,7 @@ public:
|
||||||
|
|
||||||
template <class T> IntrusivePtr<T> GetType() const { return cast_intrusive<T>(type); }
|
template <class T> IntrusivePtr<T> GetType() const { return cast_intrusive<T>(type); }
|
||||||
|
|
||||||
BroExprTag Tag() const { return tag; }
|
ExprTag Tag() const { return tag; }
|
||||||
|
|
||||||
Expr* Ref()
|
Expr* Ref()
|
||||||
{
|
{
|
||||||
|
@ -416,7 +418,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Expr() = default;
|
Expr() = default;
|
||||||
explicit Expr(BroExprTag arg_tag);
|
explicit Expr(ExprTag arg_tag);
|
||||||
|
|
||||||
virtual void ExprDescribe(ODesc* d) const = 0;
|
virtual void ExprDescribe(ODesc* d) const = 0;
|
||||||
void AddTag(ODesc* d) const;
|
void AddTag(ODesc* d) const;
|
||||||
|
@ -435,7 +437,7 @@ protected:
|
||||||
[[noreturn]] void RuntimeError(const std::string& msg) const;
|
[[noreturn]] void RuntimeError(const std::string& msg) const;
|
||||||
[[noreturn]] void RuntimeErrorWithCallStack(const std::string& msg) const;
|
[[noreturn]] void RuntimeErrorWithCallStack(const std::string& msg) const;
|
||||||
|
|
||||||
BroExprTag tag;
|
ExprTag tag;
|
||||||
bool paren;
|
bool paren;
|
||||||
TypePtr type;
|
TypePtr type;
|
||||||
|
|
||||||
|
@ -533,7 +535,7 @@ public:
|
||||||
void SetOp1(ExprPtr _op) override final { op = std::move(_op); }
|
void SetOp1(ExprPtr _op) override final { op = std::move(_op); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
UnaryExpr(BroExprTag arg_tag, ExprPtr arg_op);
|
UnaryExpr(ExprTag arg_tag, ExprPtr arg_op);
|
||||||
|
|
||||||
void ExprDescribe(ODesc* d) const override;
|
void ExprDescribe(ODesc* d) const override;
|
||||||
|
|
||||||
|
@ -573,7 +575,7 @@ public:
|
||||||
void SetOp2(ExprPtr _op) override final { op2 = std::move(_op); }
|
void SetOp2(ExprPtr _op) override final { op2 = std::move(_op); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BinaryExpr(BroExprTag arg_tag, ExprPtr arg_op1, ExprPtr arg_op2)
|
BinaryExpr(ExprTag arg_tag, ExprPtr arg_op1, ExprPtr arg_op2)
|
||||||
: Expr(arg_tag), op1(std::move(arg_op1)), op2(std::move(arg_op2))
|
: Expr(arg_tag), op1(std::move(arg_op1)), op2(std::move(arg_op2))
|
||||||
{
|
{
|
||||||
if ( ! (op1 && op2) )
|
if ( ! (op1 && op2) )
|
||||||
|
@ -654,7 +656,7 @@ protected:
|
||||||
class IncrExpr final : public UnaryExpr
|
class IncrExpr final : public UnaryExpr
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IncrExpr(BroExprTag tag, ExprPtr op);
|
IncrExpr(ExprTag tag, ExprPtr op);
|
||||||
|
|
||||||
ValPtr Eval(Frame* f) const override;
|
ValPtr Eval(Frame* f) const override;
|
||||||
ValPtr DoSingleEval(Frame* f, Val* v) const;
|
ValPtr DoSingleEval(Frame* f, Val* v) const;
|
||||||
|
@ -839,7 +841,7 @@ public:
|
||||||
class BoolExpr final : public BinaryExpr
|
class BoolExpr final : public BinaryExpr
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BoolExpr(BroExprTag tag, ExprPtr op1, ExprPtr op2);
|
BoolExpr(ExprTag tag, ExprPtr op1, ExprPtr op2);
|
||||||
|
|
||||||
ValPtr Eval(Frame* f) const override;
|
ValPtr Eval(Frame* f) const override;
|
||||||
ValPtr DoSingleEval(Frame* f, ValPtr v1, Expr* op2) const;
|
ValPtr DoSingleEval(Frame* f, ValPtr v1, Expr* op2) const;
|
||||||
|
@ -858,7 +860,7 @@ protected:
|
||||||
class BitExpr final : public BinaryExpr
|
class BitExpr final : public BinaryExpr
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BitExpr(BroExprTag tag, ExprPtr op1, ExprPtr op2);
|
BitExpr(ExprTag tag, ExprPtr op1, ExprPtr op2);
|
||||||
|
|
||||||
// Optimization-related:
|
// Optimization-related:
|
||||||
ExprPtr Duplicate() override;
|
ExprPtr Duplicate() override;
|
||||||
|
@ -869,7 +871,7 @@ public:
|
||||||
class EqExpr final : public BinaryExpr
|
class EqExpr final : public BinaryExpr
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EqExpr(BroExprTag tag, ExprPtr op1, ExprPtr op2);
|
EqExpr(ExprTag tag, ExprPtr op1, ExprPtr op2);
|
||||||
void Canonicize() override;
|
void Canonicize() override;
|
||||||
|
|
||||||
// Optimization-related:
|
// Optimization-related:
|
||||||
|
@ -885,7 +887,7 @@ protected:
|
||||||
class RelExpr final : public BinaryExpr
|
class RelExpr final : public BinaryExpr
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RelExpr(BroExprTag tag, ExprPtr op1, ExprPtr op2);
|
RelExpr(ExprTag tag, ExprPtr op1, ExprPtr op2);
|
||||||
void Canonicize() override;
|
void Canonicize() override;
|
||||||
|
|
||||||
// Optimization-related:
|
// Optimization-related:
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
#include "zeek/util.h" // for zeek_int_t
|
#include "zeek/util.h" // for zeek_int_t
|
||||||
|
|
||||||
// to allow bro_md5_hmac access to the hmac seed
|
// to allow md5_hmac_bif access to the hmac seed
|
||||||
#include "zeek/ZeekArgs.h"
|
#include "zeek/ZeekArgs.h"
|
||||||
|
|
||||||
namespace zeek
|
namespace zeek
|
||||||
|
|
|
@ -1327,7 +1327,7 @@ void RuleMatcher::DumpStateStats(File* f, RuleHdrTest* hdr_test)
|
||||||
DumpStateStats(f, h);
|
DumpStateStats(f, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Val* get_bro_val(const char* label)
|
static Val* get_zeek_val(const char* label)
|
||||||
{
|
{
|
||||||
auto id = lookup_ID(label, GLOBAL_MODULE_NAME, false);
|
auto id = lookup_ID(label, GLOBAL_MODULE_NAME, false);
|
||||||
if ( ! id )
|
if ( ! id )
|
||||||
|
@ -1410,7 +1410,7 @@ static bool val_to_maskedval(Val* v, maskedvalue_list* append_to, vector<IPPrefi
|
||||||
void id_to_maskedvallist(const char* id, maskedvalue_list* append_to,
|
void id_to_maskedvallist(const char* id, maskedvalue_list* append_to,
|
||||||
vector<IPPrefix>* prefix_vector)
|
vector<IPPrefix>* prefix_vector)
|
||||||
{
|
{
|
||||||
Val* v = get_bro_val(id);
|
Val* v = get_zeek_val(id);
|
||||||
if ( ! v )
|
if ( ! v )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1432,7 +1432,7 @@ char* id_to_str(const char* id)
|
||||||
const String* src;
|
const String* src;
|
||||||
char* dst;
|
char* dst;
|
||||||
|
|
||||||
Val* v = get_bro_val(id);
|
Val* v = get_zeek_val(id);
|
||||||
if ( ! v )
|
if ( ! v )
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
@ -1455,7 +1455,7 @@ error:
|
||||||
|
|
||||||
uint32_t id_to_uint(const char* id)
|
uint32_t id_to_uint(const char* id)
|
||||||
{
|
{
|
||||||
Val* v = get_bro_val(id);
|
Val* v = get_zeek_val(id);
|
||||||
if ( ! v )
|
if ( ! v )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
|
@ -2448,7 +2448,7 @@ void TableVal::DoExpire(double t)
|
||||||
{
|
{
|
||||||
// This happens when we insert val while network_time
|
// This happens when we insert val while network_time
|
||||||
// hasn't been initialized yet (e.g. in zeek_init()), and
|
// hasn't been initialized yet (e.g. in zeek_init()), and
|
||||||
// also when bro_start_network_time hasn't been initialized
|
// also when zeek_start_network_time hasn't been initialized
|
||||||
// (e.g. before first packet). The expire_access_time is
|
// (e.g. before first packet). The expire_access_time is
|
||||||
// correct, so we just need to wait.
|
// correct, so we just need to wait.
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,9 +26,6 @@ using namespace std::string_literals;
|
||||||
namespace zeek
|
namespace zeek
|
||||||
{
|
{
|
||||||
|
|
||||||
constexpr int String::EXPANDED_STRING;
|
|
||||||
constexpr int String::BRO_STRING_LITERAL;
|
|
||||||
|
|
||||||
// This constructor forces the user to specify arg_final_NUL. When str
|
// This constructor forces the user to specify arg_final_NUL. When str
|
||||||
// is a *normal* NUL-terminated string, make arg_n == strlen(str) and
|
// is a *normal* NUL-terminated string, make arg_n == strlen(str) and
|
||||||
// arg_final_NUL == 1; when str is a sequence of n bytes, make
|
// arg_final_NUL == 1; when str is a sequence of n bytes, make
|
||||||
|
@ -678,7 +675,7 @@ TEST_CASE("rendering")
|
||||||
CHECK_EQ(test_length, 7);
|
CHECK_EQ(test_length, 7);
|
||||||
delete[] r;
|
delete[] r;
|
||||||
|
|
||||||
r = s2.Render(zeek::String::BRO_STRING_LITERAL);
|
r = s2.Render(zeek::String::ZEEK_STRING_LITERAL);
|
||||||
CHECK_EQ(std::string(r), "\\x03\\x04\\x05\\x06\\\\\\\'");
|
CHECK_EQ(std::string(r), "\\x03\\x04\\x05\\x06\\\\\\\'");
|
||||||
delete[] r;
|
delete[] r;
|
||||||
|
|
||||||
|
|
|
@ -101,9 +101,12 @@ public:
|
||||||
static constexpr int EXPANDED_STRING = // the original style
|
static constexpr int EXPANDED_STRING = // the original style
|
||||||
ESC_HEX;
|
ESC_HEX;
|
||||||
|
|
||||||
static constexpr int BRO_STRING_LITERAL = // as in a Bro/Zeek string literal
|
static constexpr int ZEEK_STRING_LITERAL = // as in a Zeek string literal
|
||||||
ESC_ESC | ESC_QUOT | ESC_HEX;
|
ESC_ESC | ESC_QUOT | ESC_HEX;
|
||||||
|
|
||||||
|
static constexpr int BRO_STRING_LITERAL
|
||||||
|
[[deprecated("Remove in v6.1. Use ZEEK_STRING_LITERAL.")]] = ZEEK_STRING_LITERAL;
|
||||||
|
|
||||||
// Renders a string into a newly allocated character array that
|
// Renders a string into a newly allocated character array that
|
||||||
// you have to delete[]. You can combine the render styles given
|
// you have to delete[]. You can combine the render styles given
|
||||||
// above to achieve the representation you desire. If you pass a
|
// above to achieve the representation you desire. If you pass a
|
||||||
|
|
|
@ -339,7 +339,7 @@ static bool component_cmp(const Component* a, const Component* b)
|
||||||
return a->Name() < b->Name();
|
return a->Name() < b->Name();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Plugin::LoadBroFile(const std::string& file)
|
bool Plugin::LoadZeekFile(const std::string& file)
|
||||||
{
|
{
|
||||||
::add_input_file(file.c_str());
|
::add_input_file(file.c_str());
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -726,7 +726,12 @@ public:
|
||||||
* @return True if successful (which however may only mean
|
* @return True if successful (which however may only mean
|
||||||
* "successfully queued").
|
* "successfully queued").
|
||||||
*/
|
*/
|
||||||
bool LoadBroFile(const std::string& file);
|
bool LoadZeekFile(const std::string& file);
|
||||||
|
|
||||||
|
[[deprecated("Remove in v6.1. Use LoadZeekFile.")]] bool LoadBroFile(const std::string& file)
|
||||||
|
{
|
||||||
|
return LoadZeekFile(file);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class Manager;
|
friend class Manager;
|
||||||
|
|
|
@ -609,7 +609,7 @@ function clean%(str: string%): string
|
||||||
## .. zeek:see:: clean escape_string
|
## .. zeek:see:: clean escape_string
|
||||||
function to_string_literal%(str: string%): string
|
function to_string_literal%(str: string%): string
|
||||||
%{
|
%{
|
||||||
char* s = str->AsString()->Render(zeek::String::BRO_STRING_LITERAL);
|
char* s = str->AsString()->Render(zeek::String::ZEEK_STRING_LITERAL);
|
||||||
return zeek::make_intrusive<zeek::StringVal>(new zeek::String(1, byte_vec(s), strlen(s)));
|
return zeek::make_intrusive<zeek::StringVal>(new zeek::String(1, byte_vec(s), strlen(s)));
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
|
@ -456,7 +456,7 @@ static void atexit_handler()
|
||||||
util::detail::set_processing_status("TERMINATED", "atexit");
|
util::detail::set_processing_status("TERMINATED", "atexit");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bro_new_handler()
|
static void zeek_new_handler()
|
||||||
{
|
{
|
||||||
out_of_memory("new");
|
out_of_memory("new");
|
||||||
}
|
}
|
||||||
|
@ -498,7 +498,7 @@ static void set_signal_mask(bool do_block)
|
||||||
SetupResult setup(int argc, char** argv, Options* zopts)
|
SetupResult setup(int argc, char** argv, Options* zopts)
|
||||||
{
|
{
|
||||||
ZEEK_LSAN_DISABLE();
|
ZEEK_LSAN_DISABLE();
|
||||||
std::set_new_handler(bro_new_handler);
|
std::set_new_handler(zeek_new_handler);
|
||||||
|
|
||||||
auto zeek_exe_path = util::detail::get_exe_path(argv[0]);
|
auto zeek_exe_path = util::detail::get_exe_path(argv[0]);
|
||||||
|
|
||||||
|
|
11
src/zeek.bif
11
src/zeek.bif
|
@ -437,19 +437,12 @@ static bool prepare_environment(zeek::TableVal* tbl, bool set)
|
||||||
char* tmp = zeek::util::copy_string(key->AsString()->CheckString());
|
char* tmp = zeek::util::copy_string(key->AsString()->CheckString());
|
||||||
zeek::util::to_upper(tmp);
|
zeek::util::to_upper(tmp);
|
||||||
std::string var1 = zeek::util::fmt("ZEEK_ARG_%s", tmp);
|
std::string var1 = zeek::util::fmt("ZEEK_ARG_%s", tmp);
|
||||||
std::string var2 = zeek::util::fmt("BRO_ARG_%s", tmp); // legacy support
|
|
||||||
delete [] tmp;
|
delete [] tmp;
|
||||||
|
|
||||||
if ( set )
|
if ( set )
|
||||||
{
|
|
||||||
setenv(var1.data(), val->AsString()->CheckString(), 1);
|
setenv(var1.data(), val->AsString()->CheckString(), 1);
|
||||||
setenv(var2.data(), val->AsString()->CheckString(), 1);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
unsetenv(var1.data());
|
unsetenv(var1.data());
|
||||||
unsetenv(var2.data());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -3174,7 +3167,7 @@ function decode_base64_conn%(cid: conn_id, s: string, a: string &default=""%): s
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%%{
|
%%{
|
||||||
struct bro_uuid_t {
|
struct zeek_uuid_t {
|
||||||
uint32_t time_low;
|
uint32_t time_low;
|
||||||
uint16_t time_mid;
|
uint16_t time_mid;
|
||||||
uint16_t time_hi_and_version;
|
uint16_t time_hi_and_version;
|
||||||
|
@ -3197,7 +3190,7 @@ function uuid_to_string%(uuid: string%): string
|
||||||
if ( uuid->Len() != 16 )
|
if ( uuid->Len() != 16 )
|
||||||
return zeek::make_intrusive<zeek::StringVal>("<Invalid UUID>");
|
return zeek::make_intrusive<zeek::StringVal>("<Invalid UUID>");
|
||||||
|
|
||||||
bro_uuid_t* id = (bro_uuid_t*) uuid->Bytes();
|
zeek_uuid_t* id = (zeek_uuid_t*) uuid->Bytes();
|
||||||
|
|
||||||
static char s[1024];
|
static char s[1024];
|
||||||
char* sp = s;
|
char* sp = s;
|
||||||
|
|
|
@ -53,37 +53,37 @@ static string RemoveLeadingSpace(const string& s)
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
Manager::Manager(const string& arg_config, const string& bro_command)
|
Manager::Manager(const string& arg_config, const string& command)
|
||||||
: disabled(), comment_buffer(), comment_buffer_map(), packages(), scripts(), identifiers(),
|
: disabled(), comment_buffer(), comment_buffer_map(), packages(), scripts(), identifiers(),
|
||||||
all_info(), last_identifier_seen(), incomplete_type(), enum_mappings(), config(arg_config),
|
all_info(), last_identifier_seen(), incomplete_type(), enum_mappings(), config(arg_config),
|
||||||
bro_mtime()
|
mtime()
|
||||||
{
|
{
|
||||||
if ( getenv("ZEEK_DISABLE_ZEEKYGEN") )
|
if ( getenv("ZEEK_DISABLE_ZEEKYGEN") )
|
||||||
disabled = true;
|
disabled = true;
|
||||||
|
|
||||||
// If running Zeek without the "-X" option, then we don't need bro_mtime.
|
// If running Zeek without the "-X" option, then we don't need mtime.
|
||||||
if ( disabled || arg_config.empty() )
|
if ( disabled || arg_config.empty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Find the absolute or relative path to Zeek by checking each PATH
|
// Find the absolute or relative path to Zeek by checking each PATH
|
||||||
// component and also the current directory (so that this works if
|
// component and also the current directory (so that this works if
|
||||||
// bro_command is a relative path).
|
// command is a relative path).
|
||||||
const char* env_path = getenv("PATH");
|
const char* env_path = getenv("PATH");
|
||||||
string path = env_path ? string(env_path) + ":." : ".";
|
string path = env_path ? string(env_path) + ":." : ".";
|
||||||
string path_to_bro = util::find_file(bro_command, path);
|
string path_to_zeek = util::find_file(command, path);
|
||||||
struct stat s;
|
struct stat s;
|
||||||
|
|
||||||
// One way that find_file() could fail is when Zeek is located in
|
// One way that find_file() could fail is when Zeek is located in
|
||||||
// a PATH component that starts with a tilde (such as "~/bin"). A simple
|
// a PATH component that starts with a tilde (such as "~/bin"). A simple
|
||||||
// workaround is to just run Zeek with a relative or absolute path.
|
// workaround is to just run Zeek with a relative or absolute path.
|
||||||
if ( path_to_bro.empty() || stat(path_to_bro.c_str(), &s) < 0 )
|
if ( path_to_zeek.empty() || stat(path_to_zeek.c_str(), &s) < 0 )
|
||||||
reporter->InternalError("Zeekygen can't get mtime of zeek binary %s (try again by "
|
reporter->InternalError("Zeekygen can't get mtime of zeek binary %s (try again by "
|
||||||
"specifying the absolute or relative path to Zeek): %s",
|
"specifying the absolute or relative path to Zeek): %s",
|
||||||
path_to_bro.c_str(), strerror(errno));
|
path_to_zeek.c_str(), strerror(errno));
|
||||||
|
|
||||||
// Internal error will abort above in the case that stat isn't initialized
|
// Internal error will abort above in the case that stat isn't initialized
|
||||||
// NOLINTNEXTLINE(clang-analyzer-core.uninitialized.Assign)
|
// NOLINTNEXTLINE(clang-analyzer-core.uninitialized.Assign)
|
||||||
bro_mtime = s.st_mtime;
|
mtime = s.st_mtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
Manager::~Manager()
|
Manager::~Manager()
|
||||||
|
|
|
@ -58,11 +58,11 @@ public:
|
||||||
* Ctor.
|
* Ctor.
|
||||||
* @param config Path to a Zeekygen config file if documentation is to be
|
* @param config Path to a Zeekygen config file if documentation is to be
|
||||||
* written to disk.
|
* written to disk.
|
||||||
* @param bro_command The command used to invoke the Zeek process.
|
* @param command The command used to invoke the Zeek process.
|
||||||
* It's used when checking for out-of-date targets. If the Zeek binary is
|
* It's used when checking for out-of-date targets. If the Zeek binary is
|
||||||
* newer then a target, it needs to be rebuilt.
|
* newer then a target, it needs to be rebuilt.
|
||||||
*/
|
*/
|
||||||
Manager(const std::string& config, const std::string& bro_command);
|
Manager(const std::string& config, const std::string& command);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dtor.
|
* Dtor.
|
||||||
|
@ -233,7 +233,7 @@ private:
|
||||||
IdentifierInfo* incomplete_type;
|
IdentifierInfo* incomplete_type;
|
||||||
std::map<std::string, std::string> enum_mappings; // enum id -> enum type id
|
std::map<std::string, std::string> enum_mappings; // enum id -> enum type id
|
||||||
Config config;
|
Config config;
|
||||||
time_t bro_mtime;
|
time_t mtime;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
@ -251,7 +251,7 @@ bool Manager::IsUpToDate(const std::string& target_file, const std::vector<T*>&
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( difftime(bro_mtime, s.st_mtime) > 0 )
|
if ( difftime(mtime, s.st_mtime) > 0 )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( difftime(config.GetModificationTime(), s.st_mtime) > 0 )
|
if ( difftime(config.GetModificationTime(), s.st_mtime) > 0 )
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue