diff --git a/CHANGES b/CHANGES index 209f724d3b..9aa74a5eb9 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,12 @@ +3.2.0-dev.382 | 2020-04-09 13:17:03 -0700 + + * Remove 'using namespace std' as well as other using statements from headers. + + This unfortunately cuases a ton of flow-down changes because a lot of other + code was depending on that definition existing. This has a fairly large chance + to break builds of external plugins, considering how many internal ones it broke. (Tim Wojtulewicz, Corelight) + 3.2.0-dev.378 | 2020-04-09 08:47:44 -0700 * Replace most of the uses of 0 or NULL to indicate null pointers with nullptr. diff --git a/NEWS b/NEWS index 22ef03c325..88fa60871b 100644 --- a/NEWS +++ b/NEWS @@ -67,6 +67,11 @@ Changed Functionality - Data members of many C++ classes/structs were reordered to achieve better packing and smaller memory footprint. +- "using namespace std" was removed from the Zeek header files; Zeek now always + explicitly specifies std when using STL functionality in headers. This may + necessitate small changes in external plugins, if they relied on the using + statement in Zeek headers. + Removed Functionality --------------------- diff --git a/VERSION b/VERSION index 4ea7de2eb6..ca15c8f14a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.2.0-dev.378 +3.2.0-dev.382 diff --git a/src/Anon.cc b/src/Anon.cc index 41544ab8c8..1d92892311 100644 --- a/src/Anon.cc +++ b/src/Anon.cc @@ -56,7 +56,7 @@ int bi_ffs(uint32_t value) ipaddr32_t AnonymizeIPAddr::Anonymize(ipaddr32_t addr) { - map::iterator p = mapping.find(addr); + std::map::iterator p = mapping.find(addr); if ( p != mapping.end() ) return p->second; else diff --git a/src/Anon.h b/src/Anon.h index a3d7016cb7..3b2e704083 100644 --- a/src/Anon.h +++ b/src/Anon.h @@ -13,8 +13,6 @@ #include #include -using std::map; - // TODO: Anon.h may not be the right place to put these functions ... enum ip_addr_anonymization_class_t { @@ -51,7 +49,7 @@ public: bool PreserveNet(ipaddr32_t input); protected: - map mapping; + std::map mapping; }; class AnonymizeIPAddr_Seq : public AnonymizeIPAddr { diff --git a/src/Attr.cc b/src/Attr.cc index bf39c7f9c9..49cbecfcba 100644 --- a/src/Attr.cc +++ b/src/Attr.cc @@ -106,7 +106,7 @@ void Attr::DescribeReST(ODesc* d, bool shorten) const ODesc dd; dd.SetQuotes(true); expr->Describe(&dd); - string s = dd.Description(); + std::string s = dd.Description(); add_long_expr_string(d, s, shorten); } @@ -114,7 +114,7 @@ void Attr::DescribeReST(ODesc* d, bool shorten) const { ODesc dd; expr->Eval(nullptr)->Describe(&dd); - string s = dd.Description(); + std::string s = dd.Description(); for ( size_t i = 0; i < s.size(); ++i ) if ( s[i] == '\n' ) diff --git a/src/Base64.cc b/src/Base64.cc index 16e43d296c..419e6faf8c 100644 --- a/src/Base64.cc +++ b/src/Base64.cc @@ -7,7 +7,7 @@ #include int Base64Converter::default_base64_table[256]; -const string Base64Converter::default_alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +const std::string Base64Converter::default_alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; void Base64Converter::Encode(int len, const unsigned char* data, int* pblen, char** pbuf) { @@ -46,7 +46,7 @@ void Base64Converter::Encode(int len, const unsigned char* data, int* pblen, cha } -int* Base64Converter::InitBase64Table(const string& alphabet) +int* Base64Converter::InitBase64Table(const std::string& alphabet) { assert(alphabet.size() == 64); @@ -86,7 +86,7 @@ int* Base64Converter::InitBase64Table(const string& alphabet) return base64_table; } -Base64Converter::Base64Converter(Connection* arg_conn, const string& arg_alphabet) +Base64Converter::Base64Converter(Connection* arg_conn, const std::string& arg_alphabet) { if ( arg_alphabet.size() > 0 ) { diff --git a/src/Base64.h b/src/Base64.h index 2348eccc11..a138a3aa8e 100644 --- a/src/Base64.h +++ b/src/Base64.h @@ -2,8 +2,6 @@ #include -using std::string; - class BroString; class Connection; @@ -15,7 +13,7 @@ public: // encode_base64()), encoding-errors will go to Reporter instead of // Weird. Usage errors go to Reporter in any case. Empty alphabet // indicates the default base64 alphabet. - explicit Base64Converter(Connection* conn, const string& alphabet = ""); + explicit Base64Converter(Connection* conn, const std::string& alphabet = ""); ~Base64Converter(); // A note on Decode(): @@ -44,10 +42,10 @@ protected: char error_msg[256]; protected: - static const string default_alphabet; - string alphabet; + static const std::string default_alphabet; + std::string alphabet; - static int* InitBase64Table(const string& alphabet); + static int* InitBase64Table(const std::string& alphabet); static int default_base64_table[256]; char base64_group[4]; int base64_group_next; diff --git a/src/BroString.cc b/src/BroString.cc index cfd7e92c15..e9708d1852 100644 --- a/src/BroString.cc +++ b/src/BroString.cc @@ -44,7 +44,7 @@ BroString::BroString(const char* str) : BroString() Set(str); } -BroString::BroString(const string &str) : BroString() +BroString::BroString(const std::string &str) : BroString() { Set(str); } @@ -137,7 +137,7 @@ void BroString::Set(const char* str) use_free_to_delete = false; } -void BroString::Set(const string& str) +void BroString::Set(const std::string& str) { Reset(); @@ -234,7 +234,7 @@ char* BroString::Render(int format, int* len) const return s; } -ostream& BroString::Render(ostream &os, int format) const +std::ostream& BroString::Render(std::ostream &os, int format) const { char* tmp = Render(format); os << tmp; @@ -242,7 +242,7 @@ ostream& BroString::Render(ostream &os, int format) const return os; } -istream& BroString::Read(istream &is, int format) +std::istream& BroString::Read(std::istream &is, int format) { if ( (format & BroString::ESC_SER) ) { @@ -260,7 +260,7 @@ istream& BroString::Read(istream &is, int format) } else { - string str; + std::string str; is >> str; Set(str); } @@ -376,7 +376,7 @@ BroString::Vec* BroString::VecFromPolicy(VectorVal* vec) char* BroString::VecToString(const Vec* vec) { - string result("["); + std::string result("["); for ( BroString::VecCIt it = vec->begin(); it != vec->end(); ++it ) { @@ -396,7 +396,7 @@ bool BroStringLenCmp::operator()(BroString * const& bst1, (bst1->Len() > bst2->Len()); } -ostream& operator<<(ostream& os, const BroString& bs) +std::ostream& operator<<(std::ostream& os, const BroString& bs) { char* tmp = bs.Render(BroString::EXPANDED_STRING); os << tmp; @@ -414,7 +414,7 @@ int Bstr_eq(const BroString* s1, const BroString* s2) int Bstr_cmp(const BroString* s1, const BroString* s2) { - int n = min(s1->Len(), s2->Len()); + int n = std::min(s1->Len(), s2->Len()); int cmp = memcmp(s1->Bytes(), s2->Bytes(), n); if ( cmp || s1->Len() == s2->Len() ) diff --git a/src/Brofiler.cc b/src/Brofiler.cc index a2391145cd..ba7ff1b358 100644 --- a/src/Brofiler.cc +++ b/src/Brofiler.cc @@ -13,6 +13,8 @@ #include "Reporter.h" #include "util.h" +using namespace std; + Brofiler::Brofiler() : ignoring(0), delim('\t') { diff --git a/src/Brofiler.h b/src/Brofiler.h index 0587d6e5c6..4d6bb2eaf5 100644 --- a/src/Brofiler.h +++ b/src/Brofiler.h @@ -5,11 +5,6 @@ #include #include -using std::list; -using std::map; -using std::pair; -using std::string; - class Stmt; /** @@ -50,7 +45,7 @@ private: /** * The current, global Brofiler instance creates this list at parse-time. */ - list stmts; + std::list stmts; /** * Indicates whether new statments will not be considered as part of @@ -69,7 +64,7 @@ private: * startup time and modified at shutdown time before writing back * to a file. */ - map, uint64_t> usage_map; + std::map, uint64_t> usage_map; /** * A canonicalization routine for Stmt descriptions containing characters diff --git a/src/CompHash.cc b/src/CompHash.cc index 7d9a29da62..be576228fd 100644 --- a/src/CompHash.cc +++ b/src/CompHash.cc @@ -906,7 +906,7 @@ const char* CompositeHash::RecoverOneVal(const HashKey* k, const char* kp0, RecordType* rt = t->AsRecordType(); int num_fields = rt->NumFields(); - vector values; + std::vector values; int i; for ( i = 0; i < num_fields; ++i ) { diff --git a/src/Conn.h b/src/Conn.h index bc33effd57..90410be516 100644 --- a/src/Conn.h +++ b/src/Conn.h @@ -369,7 +369,7 @@ protected: static uint64_t total_connections; static uint64_t current_connections; - string history; + std::string history; uint32_t hist_seen; analyzer::TransportLayerAnalyzer* root_analyzer; diff --git a/src/DNS_Mgr.cc b/src/DNS_Mgr.cc index b39ba83aab..d627a09c73 100644 --- a/src/DNS_Mgr.cc +++ b/src/DNS_Mgr.cc @@ -50,6 +50,7 @@ extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); #include "nb_dns.h" } +using namespace std; class DNS_Mgr_Request { public: diff --git a/src/DNS_Mgr.h b/src/DNS_Mgr.h index 76d1ff50c4..c0a3370487 100644 --- a/src/DNS_Mgr.h +++ b/src/DNS_Mgr.h @@ -60,8 +60,8 @@ public: bool Save(); const char* LookupAddrInCache(const IPAddr& addr); - IntrusivePtr LookupNameInCache(const string& name); - const char* LookupTextInCache(const string& name); + IntrusivePtr LookupNameInCache(const std::string& name); + const char* LookupTextInCache(const std::string& name); // Support for async lookups. class LookupCallback { @@ -75,8 +75,8 @@ public: }; void AsyncLookupAddr(const IPAddr& host, LookupCallback* callback); - void AsyncLookupName(const string& name, LookupCallback* callback); - void AsyncLookupNameText(const string& name, LookupCallback* callback); + void AsyncLookupName(const std::string& name, LookupCallback* callback); + void AsyncLookupNameText(const std::string& name, LookupCallback* callback); struct Stats { unsigned long requests; // These count only async requests. @@ -108,9 +108,9 @@ protected: IntrusivePtr AddrListDelta(ListVal* al1, ListVal* al2); void DumpAddrList(FILE* f, ListVal* al); - typedef map > HostMap; - typedef map AddrMap; - typedef map TextMap; + typedef std::map > HostMap; + typedef std::map AddrMap; + typedef std::map TextMap; void LoadCache(FILE* f); void Save(FILE* f, const AddrMap& m); void Save(FILE* f, const HostMap& m); @@ -159,12 +159,12 @@ protected: RecordType* dm_rec; - typedef list CallbackList; + typedef std::list CallbackList; struct AsyncRequest { double time; IPAddr host; - string name; + std::string name; CallbackList callbacks; bool is_txt; bool processed; @@ -211,16 +211,16 @@ protected: }; - typedef map AsyncRequestAddrMap; + typedef std::map AsyncRequestAddrMap; AsyncRequestAddrMap asyncs_addrs; - typedef map AsyncRequestNameMap; + typedef std::map AsyncRequestNameMap; AsyncRequestNameMap asyncs_names; - typedef map AsyncRequestTextMap; + typedef std::map AsyncRequestTextMap; AsyncRequestTextMap asyncs_texts; - typedef list QueuedList; + typedef std::list QueuedList; QueuedList asyncs_queued; struct AsyncRequestCompare { @@ -230,7 +230,7 @@ protected: } }; - typedef priority_queue, AsyncRequestCompare> TimeoutQueue; + typedef std::priority_queue, AsyncRequestCompare> TimeoutQueue; TimeoutQueue asyncs_timeouts; int asyncs_pending; diff --git a/src/DbgBreakpoint.cc b/src/DbgBreakpoint.cc index 60c67f887d..e238156eec 100644 --- a/src/DbgBreakpoint.cc +++ b/src/DbgBreakpoint.cc @@ -90,7 +90,7 @@ void DbgBreakpoint::AddToGlobalMap() void DbgBreakpoint::RemoveFromGlobalMap() { - pair p; + std::pair p; p = g_debugger_state.breakpoint_map.equal_range(at_stmt); for ( BPMapType::iterator i = p.first; i != p.second; ) @@ -120,7 +120,7 @@ void DbgBreakpoint::RemoveFromStmt() } -bool DbgBreakpoint::SetLocation(ParseLocationRec plr, string_view loc_str) +bool DbgBreakpoint::SetLocation(ParseLocationRec plr, std::string_view loc_str) { if ( plr.type == plrUnknown ) { @@ -224,7 +224,7 @@ bool DbgBreakpoint::Reset() return false; } -bool DbgBreakpoint::SetCondition(const string& new_condition) +bool DbgBreakpoint::SetCondition(const std::string& new_condition) { condition = new_condition; return true; diff --git a/src/DbgBreakpoint.h b/src/DbgBreakpoint.h index ae86e83b69..2e8e59a16c 100644 --- a/src/DbgBreakpoint.h +++ b/src/DbgBreakpoint.h @@ -4,8 +4,6 @@ #include -using std::string; - struct ParseLocationRec; class Stmt; @@ -40,8 +38,8 @@ public: BreakCode ShouldBreak(Stmt* s); BreakCode ShouldBreak(double t); - const string& GetCondition() const { return condition; } - bool SetCondition(const string& new_condition); + const std::string& GetCondition() const { return condition; } + bool SetCondition(const std::string& new_condition); int GetRepeatCount() const { return repeat_count; } bool SetRepeatCount(int count); // implements function of ignore command in gdb @@ -66,7 +64,7 @@ protected: int32_t BPID; char description[512]; - string function_name; // location + std::string function_name; // location const char* source_filename; int32_t source_line; bool enabled; // ### comment this and next @@ -79,5 +77,5 @@ protected: int32_t repeat_count; // if positive, break after this many hits int32_t hit_count; // how many times it's been hit (w/o breaking) - string condition; // condition to evaluate; nil for none + std::string condition; // condition to evaluate; nil for none }; diff --git a/src/DebugCmds.cc b/src/DebugCmds.cc index eb284a6c69..e0d2cf843e 100644 --- a/src/DebugCmds.cc +++ b/src/DebugCmds.cc @@ -25,6 +25,8 @@ #include "Val.h" #include "util.h" +using namespace std; + // // Helper routines // diff --git a/src/DebugLogger.cc b/src/DebugLogger.cc index 4fac89414e..8234e14b08 100644 --- a/src/DebugLogger.cc +++ b/src/DebugLogger.cc @@ -165,7 +165,7 @@ void DebugLogger::Log(DebugStream stream, const char* fmt, ...) void DebugLogger::Log(const plugin::Plugin& plugin, const char* fmt, ...) { - string tok = string("plugin-") + plugin.Name(); + std::string tok = std::string("plugin-") + plugin.Name(); tok = strreplace(tok, "::", "-"); if ( enabled_streams.find(tok) == enabled_streams.end() ) diff --git a/src/Desc.cc b/src/Desc.cc index c02347f42f..57edf40d39 100644 --- a/src/Desc.cc +++ b/src/Desc.cc @@ -251,7 +251,7 @@ size_t ODesc::StartsWithEscapeSequence(const char* start, const char* end) for ( it = escape_sequences.begin(); it != escape_sequences.end(); ++it ) { - const string& esc_str = *it; + const std::string& esc_str = *it; size_t esc_len = esc_str.length(); if ( start + esc_len > end ) @@ -264,9 +264,9 @@ size_t ODesc::StartsWithEscapeSequence(const char* start, const char* end) return 0; } -pair ODesc::FirstEscapeLoc(const char* bytes, size_t n) +std::pair ODesc::FirstEscapeLoc(const char* bytes, size_t n) { - typedef pair escape_pos; + typedef std::pair escape_pos; if ( IsBinary() ) return escape_pos(0, 0); @@ -327,7 +327,7 @@ void ODesc::AddBytes(const void* bytes, unsigned int n) while ( s < e ) { - pair p = FirstEscapeLoc(s, e - s); + std::pair p = FirstEscapeLoc(s, e - s); if ( p.first ) { diff --git a/src/Discard.cc b/src/Discard.cc index bdfda9128d..77e83620db 100644 --- a/src/Discard.cc +++ b/src/Discard.cc @@ -161,7 +161,7 @@ Val* Discarder::BuildData(const u_char* data, int hdrlen, int len, int caplen) caplen -= hdrlen; data += hdrlen; - len = max(min(min(len, caplen), discarder_maxlen), 0); + len = std::max(std::min(std::min(len, caplen), discarder_maxlen), 0); return new StringVal(new BroString(data, len, true)); } diff --git a/src/EventHandler.cc b/src/EventHandler.cc index c1fad45a91..fa1d90bbd2 100644 --- a/src/EventHandler.cc +++ b/src/EventHandler.cc @@ -83,7 +83,7 @@ void EventHandler::Call(const zeek::Args& vl, bool no_remote) auto opt_data = bro_broker::val_to_data(vl[i].get()); if ( opt_data ) - xs.emplace_back(move(*opt_data)); + xs.emplace_back(std::move(*opt_data)); else { valid_args = false; diff --git a/src/EventRegistry.cc b/src/EventRegistry.cc index 44018421c0..7dbae7a83b 100644 --- a/src/EventRegistry.cc +++ b/src/EventRegistry.cc @@ -8,10 +8,10 @@ EventRegistry::~EventRegistry() noexcept = default; void EventRegistry::Register(EventHandlerPtr handler) { - handlers[string(handler->Name())] = std::unique_ptr(handler.Ptr()); + handlers[std::string(handler->Name())] = std::unique_ptr(handler.Ptr()); } -EventHandler* EventRegistry::Lookup(const string& name) +EventHandler* EventRegistry::Lookup(const std::string& name) { auto it = handlers.find(name); if ( it != handlers.end() ) @@ -86,7 +86,7 @@ void EventRegistry::PrintDebug() } } -void EventRegistry::SetErrorHandler(const string& name) +void EventRegistry::SetErrorHandler(const std::string& name) { EventHandler* eh = Lookup(name); diff --git a/src/EventRegistry.h b/src/EventRegistry.h index 2619f3e044..31b859986b 100644 --- a/src/EventRegistry.h +++ b/src/EventRegistry.h @@ -7,9 +7,6 @@ #include #include -using std::string; -using std::vector; - class EventHandler; class EventHandlerPtr; class RE_Matcher; @@ -23,17 +20,17 @@ public: void Register(EventHandlerPtr handler); // Return nil if unknown. - EventHandler* Lookup(const string& name); + EventHandler* Lookup(const std::string& name); // Returns a list of all local handlers that match the given pattern. // Passes ownership of list. - typedef vector string_list; + using string_list = std::vector; string_list Match(RE_Matcher* pattern); // Marks a handler as handling errors. Error handler will not be called // recursively to avoid infinite loops in case they trigger an error // themselves. - void SetErrorHandler(const string& name); + void SetErrorHandler(const std::string& name); string_list UnusedHandlers(); string_list UsedHandlers(); diff --git a/src/Expr.cc b/src/Expr.cc index cb34859ea6..7301422a76 100644 --- a/src/Expr.cc +++ b/src/Expr.cc @@ -709,7 +709,7 @@ IntrusivePtr BinaryExpr::StringFold(Val* v1, Val* v2) const case EXPR_ADD: case EXPR_ADD_TO: { - vector strings; + std::vector strings; strings.push_back(s1); strings.push_back(s2); @@ -3602,7 +3602,7 @@ RecordCoerceExpr::RecordCoerceExpr(IntrusivePtr arg_op, if ( ! is_arithmetic_promotable(sup_t_i, sub_t_i) && ! is_record_promotable(sup_t_i, sub_t_i) ) { - string error_msg = fmt( + std::string error_msg = fmt( "type clash for field \"%s\"", sub_r->FieldName(i)); Error(error_msg.c_str(), sub_t_i); SetError(); @@ -3622,7 +3622,7 @@ RecordCoerceExpr::RecordCoerceExpr(IntrusivePtr arg_op, { if ( ! t_r->FieldDecl(i)->FindAttr(ATTR_OPTIONAL) ) { - string error_msg = fmt( + std::string error_msg = fmt( "non-optional field \"%s\" missing", t_r->FieldName(i)); Error(error_msg.c_str()); SetError(); @@ -4832,7 +4832,7 @@ RecordAssignExpr::RecordAssignExpr(const IntrusivePtr& record, } else { - string s = "No such field '"; + std::string s = "No such field '"; s += field_name; s += "'"; init_list->SetError(s.c_str()); diff --git a/src/Expr.h b/src/Expr.h index 543efa1cee..e540d45b2d 100644 --- a/src/Expr.h +++ b/src/Expr.h @@ -2,6 +2,12 @@ #pragma once +#include +#include +#include +#include +#include + #include "BroList.h" #include "IntrusivePtr.h" #include "Timer.h" @@ -11,14 +17,6 @@ #include "Val.h" #include "ZeekArgs.h" -#include -#include -#include -#include -#include - -using std::string; - enum BroExprTag : int { EXPR_ANY = -1, EXPR_NAME, EXPR_CONST, @@ -683,7 +681,7 @@ public: protected: void ExprDescribe(ODesc* d) const override; - string field_name; + std::string field_name; }; class ArithCoerceExpr final : public UnaryExpr { @@ -843,7 +841,7 @@ public: protected: void ExprDescribe(ODesc* d) const override; - string name; + std::string name; EventHandlerPtr handler; IntrusivePtr args; }; diff --git a/src/Frame.cc b/src/Frame.cc index 9785ce1ccc..9a7fa733d6 100644 --- a/src/Frame.cc +++ b/src/Frame.cc @@ -12,7 +12,7 @@ #include "Val.h" #include "ID.h" -vector g_frame_stack; +std::vector g_frame_stack; Frame::Frame(int arg_size, const BroFunc* func, const zeek::Args* fn_args) { @@ -61,7 +61,7 @@ void Frame::AddFunctionWithClosureRef(BroFunc* func) ::Ref(func); if ( ! functions_with_closure_frame_reference ) - functions_with_closure_frame_reference = make_unique>(); + functions_with_closure_frame_reference = std::make_unique>(); functions_with_closure_frame_reference->emplace_back(func); } @@ -183,7 +183,7 @@ Frame* Frame::Clone() const Frame* other = new Frame(size, function, func_args); if ( offset_map ) - other->offset_map = make_unique(*offset_map); + other->offset_map = std::make_unique(*offset_map); other->CaptureClosure(closure, outer_ids); @@ -278,7 +278,7 @@ Frame* Frame::SelectiveClone(const id_list& selection, BroFunc* func) const if ( offset_map ) { if ( ! other->offset_map ) - other->offset_map = make_unique(*offset_map); + other->offset_map = std::make_unique(*offset_map); else *(other->offset_map) = *offset_map; } @@ -462,7 +462,7 @@ std::pair> Frame::Unserialize(const broker::vector& da // We'll associate this frame with a function later. auto rf = make_intrusive(frame_size, nullptr, nullptr); - rf->offset_map = make_unique(std::move(offset_map)); + rf->offset_map = std::make_unique(std::move(offset_map)); // Frame takes ownership of unref'ing elements in outer_ids rf->outer_ids = std::move(outer_ids); @@ -499,7 +499,7 @@ std::pair> Frame::Unserialize(const broker::vector& da void Frame::AddKnownOffsets(const id_list& ids) { if ( ! offset_map ) - offset_map = make_unique(); + offset_map = std::make_unique(); std::transform(ids.begin(), ids.end(), std::inserter(*offset_map, offset_map->end()), [] (const ID* id) -> std::pair diff --git a/src/Func.cc b/src/Func.cc index e9933a6a6a..efefa3e04a 100644 --- a/src/Func.cc +++ b/src/Func.cc @@ -56,10 +56,10 @@ extern RETSIGTYPE sig_handler(int signo); -vector call_stack; +std::vector call_stack; bool did_builtin_init = false; -vector Func::unique_ids; +std::vector Func::unique_ids; static const std::pair empty_hook_result(false, NULL); std::string render_call_stack() diff --git a/src/Func.h b/src/Func.h index 9c1c816e33..ef22bb6aa1 100644 --- a/src/Func.h +++ b/src/Func.h @@ -2,13 +2,6 @@ #pragma once -#include "BroList.h" -#include "Obj.h" -#include "IntrusivePtr.h" -#include "Type.h" /* for function_flavor */ -#include "TraverseTypes.h" -#include "ZeekArgs.h" - #include #include #include @@ -19,8 +12,12 @@ #include #include -using std::string; -using std::vector; +#include "BroList.h" +#include "Obj.h" +#include "IntrusivePtr.h" +#include "Type.h" /* for function_flavor */ +#include "TraverseTypes.h" +#include "ZeekArgs.h" class Val; class ListExpr; @@ -49,7 +46,7 @@ public: { return priority > other.priority; } // reverse sort }; - const vector& GetBodies() const { return bodies; } + const std::vector& GetBodies() const { return bodies; } bool HasBodies() const { return bodies.size(); } [[deprecated("Remove in v4.1. Use zeek::Args overload instead.")]] @@ -108,13 +105,13 @@ protected: // Helper function for handling result of plugin hook. std::pair HandlePluginResult(std::pair plugin_result, function_flavor flavor) const; - vector bodies; + std::vector bodies; IntrusivePtr scope; Kind kind; uint32_t unique_id; IntrusivePtr type; - string name; - static vector unique_ids; + std::string name; + static std::vector unique_ids; }; @@ -244,7 +241,7 @@ struct function_ingredients { IntrusivePtr scope; }; -extern vector call_stack; +extern std::vector call_stack; extern std::string render_call_stack(); diff --git a/src/ID.cc b/src/ID.cc index 3494d8a175..2475ef9a1e 100644 --- a/src/ID.cc +++ b/src/ID.cc @@ -45,7 +45,7 @@ ID::~ID() Unref(val); } -string ID::ModuleName() const +std::string ID::ModuleName() const { return extract_module_name(name); } @@ -214,9 +214,9 @@ void ID::MakeDeprecated(IntrusivePtr deprecation) AddAttrs(make_intrusive(attr, IntrusivePtr{NewRef{}, Type()}, false, IsGlobal())); } -string ID::GetDeprecationWarning() const +std::string ID::GetDeprecationWarning() const { - string result; + std::string result; Attr* depr_attr = FindAttr(ATTR_DEPRECATED); if ( depr_attr ) { @@ -541,12 +541,12 @@ void ID::AddOptionHandler(IntrusivePtr callback, int priority) option_handlers.emplace(priority, std::move(callback)); } -vector ID::GetOptionHandlers() const +std::vector ID::GetOptionHandlers() const { // multimap is sorted // It might be worth caching this if we expect it to be called // a lot... - vector v; + std::vector v; for ( auto& element : option_handlers ) v.push_back(element.second.get()); return v; diff --git a/src/IP.h b/src/IP.h index 5eaac66a2b..bb62d30b04 100644 --- a/src/IP.h +++ b/src/IP.h @@ -4,8 +4,6 @@ #include "zeek-config.h" -#include - #include // for u_char #include #include @@ -14,7 +12,7 @@ #include #endif -using std::vector; +#include class IPAddr; class RecordVal; @@ -263,7 +261,7 @@ protected: void ProcessDstOpts(const struct ip6_dest* d, uint16_t len); #endif - vector chain; + std::vector chain; /** * The summation of all header lengths in the chain in bytes. diff --git a/src/IPAddr.cc b/src/IPAddr.cc index cbcb8dc867..f097307daf 100644 --- a/src/IPAddr.cc +++ b/src/IPAddr.cc @@ -153,7 +153,7 @@ void IPAddr::Init(const char* s) } } -string IPAddr::AsString() const +std::string IPAddr::AsString() const { if ( GetFamily() == IPv4 ) { @@ -175,7 +175,7 @@ string IPAddr::AsString() const } } -string IPAddr::AsHexString() const +std::string IPAddr::AsHexString() const { char buf[33]; @@ -195,7 +195,7 @@ string IPAddr::AsHexString() const return buf; } -string IPAddr::PtrName() const +std::string IPAddr::PtrName() const { if ( GetFamily() == IPv4 ) { @@ -212,7 +212,7 @@ string IPAddr::PtrName() const else { static const char hex_digit[] = "0123456789abcdef"; - string ptr_name("ip6.arpa"); + std::string ptr_name("ip6.arpa"); uint32_t* p = (uint32_t*) in6.s6_addr; for ( unsigned int i = 0; i < 4; ++i ) @@ -290,7 +290,7 @@ IPPrefix::IPPrefix(const IPAddr& addr, uint8_t length, bool len_is_v6_relative) prefix.Mask(this->length); } -string IPPrefix::AsString() const +std::string IPPrefix::AsString() const { char l[16]; @@ -317,10 +317,10 @@ HashKey* IPPrefix::GetHashKey() const bool IPPrefix::ConvertString(const char* text, IPPrefix* result) { - string s(text); + std::string s(text); size_t slash_loc = s.find('/'); - if ( slash_loc == string::npos ) + if ( slash_loc == std::string::npos ) return false; auto ip_str = s.substr(0, slash_loc); diff --git a/src/IPAddr.h b/src/IPAddr.h index ba423a5026..6fb5a124dc 100644 --- a/src/IPAddr.h +++ b/src/IPAddr.h @@ -2,14 +2,13 @@ #pragma once -#include "threading/SerialTypes.h" - #include #include #include #include -using std::string; +#include "threading/SerialTypes.h" + struct ConnID; class BroString; class HashKey; @@ -317,7 +316,7 @@ public: if ( GetFamily() == IPv4 ) return AsString(); - return string("[") + AsString() + "]"; + return std::string("[") + AsString() + "]"; } /** diff --git a/src/Net.cc b/src/Net.cc index 21542aad04..1334aacd44 100644 --- a/src/Net.cc +++ b/src/Net.cc @@ -65,7 +65,7 @@ iosource::PktSrc* current_pktsrc = nullptr; iosource::IOSource* current_iosrc = nullptr; std::list files_scanned; -std::vector sig_files; +std::vector sig_files; RETSIGTYPE watchdog(int /* signo */) { diff --git a/src/Net.h b/src/Net.h index 9d556456ac..ad9871063a 100644 --- a/src/Net.h +++ b/src/Net.h @@ -2,15 +2,13 @@ #pragma once +#include // for ino_t + #include #include #include #include -#include // for ino_t - -using std::string; - namespace iosource { class IOSource; class PktSrc; @@ -95,10 +93,10 @@ struct ScannedFile { int include_level; bool skipped; // This ScannedFile was @unload'd. bool prefixes_checked; // If loading prefixes for this file has been tried. - string name; + std::string name; ScannedFile(dev_t arg_dev, ino_t arg_inode, int arg_include_level, - const string& arg_name, bool arg_skipped = false, + const std::string& arg_name, bool arg_skipped = false, bool arg_prefixes_checked = false) : dev(arg_dev), inode(arg_inode), include_level(arg_include_level), @@ -109,4 +107,4 @@ struct ScannedFile { }; extern std::list files_scanned; -extern std::vector sig_files; +extern std::vector sig_files; diff --git a/src/OpaqueVal.cc b/src/OpaqueVal.cc index 607376ed60..28e5f0f9e4 100644 --- a/src/OpaqueVal.cc +++ b/src/OpaqueVal.cc @@ -777,7 +777,7 @@ bool BloomFilterVal::Empty() const return bloom_filter->Empty(); } -string BloomFilterVal::InternalState() const +std::string BloomFilterVal::InternalState() const { return bloom_filter->InternalState(); } diff --git a/src/OpaqueVal.h b/src/OpaqueVal.h index 288e94a7db..6ad65a4df3 100644 --- a/src/OpaqueVal.h +++ b/src/OpaqueVal.h @@ -306,7 +306,7 @@ public: size_t Count(const Val* val) const; void Clear(); bool Empty() const; - string InternalState() const; + std::string InternalState() const; static IntrusivePtr Merge(const BloomFilterVal* x, const BloomFilterVal* y); diff --git a/src/PrefixTable.cc b/src/PrefixTable.cc index 36012af5a3..765108f507 100644 --- a/src/PrefixTable.cc +++ b/src/PrefixTable.cc @@ -63,9 +63,9 @@ void* PrefixTable::Insert(const Val* value, void* data) } } -list> PrefixTable::FindAll(const IPAddr& addr, int width) const +std::list> PrefixTable::FindAll(const IPAddr& addr, int width) const { - std::list> out; + std::list> out; prefix_t* prefix = MakePrefix(addr, width); int elems = 0; @@ -81,7 +81,7 @@ list> PrefixTable::FindAll(const IPAddr& addr, int width) return out; } -list> PrefixTable::FindAll(const SubNetVal* value) const +std::list> PrefixTable::FindAll(const SubNetVal* value) const { return FindAll(value->AsSubNet().Prefix(), value->AsSubNet().LengthIPv6()); } diff --git a/src/PrefixTable.h b/src/PrefixTable.h index 2bd640772d..7d1bb96645 100644 --- a/src/PrefixTable.h +++ b/src/PrefixTable.h @@ -1,15 +1,12 @@ #pragma once -#include "IPAddr.h" - extern "C" { #include "patricia.h" } #include -using std::list; -using std::tuple; +#include "IPAddr.h" class Val; class SubNetVal; @@ -42,8 +39,8 @@ public: void* Lookup(const Val* value, bool exact = false) const; // Returns list of all found matches or empty list otherwise. - list> FindAll(const IPAddr& addr, int width) const; - list> FindAll(const SubNetVal* value) const; + std::list> FindAll(const IPAddr& addr, int width) const; + std::list> FindAll(const SubNetVal* value) const; // Returns pointer to data or nil if not found. void* Remove(const IPAddr& addr, int width); diff --git a/src/RE.cc b/src/RE.cc index ac59567f4d..de8995fd4e 100644 --- a/src/RE.cc +++ b/src/RE.cc @@ -195,13 +195,13 @@ bool Specific_RE_Matcher::CompileSet(const string_list& set, const int_list& idx return true; } -string Specific_RE_Matcher::LookupDef(const string& def) +std::string Specific_RE_Matcher::LookupDef(const std::string& def) { const auto& iter = defs.find(def); if ( iter != defs.end() ) return iter->second; - return string(); + return std::string(); } bool Specific_RE_Matcher::MatchAll(const char* s) diff --git a/src/Reporter.cc b/src/Reporter.cc index 5ab4d923b7..e49c9eca75 100644 --- a/src/Reporter.cc +++ b/src/Reporter.cc @@ -78,7 +78,7 @@ void Reporter::InitOptions() while ( (v = wl_table->NextEntry(k, c)) ) { auto index = wl_val->RecoverIndex(k); - string key = index->Index(0)->AsString()->CheckString(); + std::string key = index->Index(0)->AsString()->CheckString(); weird_sampling_whitelist.emplace(move(key)); delete k; } @@ -384,11 +384,11 @@ void Reporter::DoLog(const char* prefix, EventHandlerPtr event, FILE* out, char* buffer = tmp; char* alloced = nullptr; - string loc_str; + std::string loc_str; if ( location ) { - string loc_file = ""; + std::string loc_file = ""; int loc_line = 0; if ( locations.size() ) @@ -427,7 +427,7 @@ void Reporter::DoLog(const char* prefix, EventHandlerPtr event, FILE* out, loc_str = filename; char tmp[32]; snprintf(tmp, 32, "%d", line_number); - loc_str += string(", line ") + string(tmp); + loc_str += std::string(", line ") + std::string(tmp); } } @@ -514,21 +514,21 @@ void Reporter::DoLog(const char* prefix, EventHandlerPtr event, FILE* out, if ( out ) { - string s = ""; + std::string s = ""; if ( bro_start_network_time != 0.0 ) { char tmp[32]; snprintf(tmp, 32, "%.6f", network_time); - s += string(tmp) + " "; + s += std::string(tmp) + " "; } if ( prefix && *prefix ) { if ( loc_str != "" ) - s += string(prefix) + " in " + loc_str + ": "; + s += std::string(prefix) + " in " + loc_str + ": "; else - s += string(prefix) + ": "; + s += std::string(prefix) + ": "; } else diff --git a/src/RuleAction.h b/src/RuleAction.h index 8604fa89a8..4719fdea01 100644 --- a/src/RuleAction.h +++ b/src/RuleAction.h @@ -6,8 +6,6 @@ #include // for u_char -using std::string; - class Rule; class RuleEndpointState; @@ -50,7 +48,7 @@ public: void PrintDebug() override; - string GetMIME() const + std::string GetMIME() const { return mime; } int GetStrength() const diff --git a/src/RuleMatcher.cc b/src/RuleMatcher.cc index 0abafcb4da..79a778eb34 100644 --- a/src/RuleMatcher.cc +++ b/src/RuleMatcher.cc @@ -21,6 +21,8 @@ #include "Reporter.h" #include "module_util.h" +using namespace std; + // FIXME: Things that are not fully implemented/working yet: // // - "ip-options" always evaluates to false diff --git a/src/RuleMatcher.h b/src/RuleMatcher.h index 6e0cd864a5..8e644a2aa0 100644 --- a/src/RuleMatcher.h +++ b/src/RuleMatcher.h @@ -1,8 +1,7 @@ #pragma once -#include "Rule.h" -#include "RE.h" -#include "CCL.h" +#include // for u_char +#include #include #include @@ -10,8 +9,9 @@ #include #include -#include // for u_char -#include +#include "Rule.h" +#include "RE.h" +#include "CCL.h" //#define MATCHER_PRINT_STATS @@ -27,11 +27,6 @@ extern FILE* rules_in; extern int rules_line_number; extern const char* current_rule_file; -using std::vector; -using std::map; -using std::set; -using std::string; - class Val; class BroFile; class IntSet; @@ -67,7 +62,7 @@ typedef PList bstr_list; // Get values from Bro's script-level variables. extern void id_to_maskedvallist(const char* id, maskedvalue_list* append_to, - vector* prefix_vector = nullptr); + std::vector* prefix_vector = nullptr); extern char* id_to_str(const char* id); extern uint32_t id_to_uint(const char* id); @@ -79,7 +74,7 @@ public: RuleHdrTest(Prot arg_prot, uint32_t arg_offset, uint32_t arg_size, Comp arg_comp, maskedvalue_list* arg_vals); - RuleHdrTest(Prot arg_prot, Comp arg_comp, vector arg_v); + RuleHdrTest(Prot arg_prot, Comp arg_comp, std::vector arg_v); ~RuleHdrTest(); void PrintDebug(); @@ -96,7 +91,7 @@ private: Prot prot; Comp comp; maskedvalue_list* vals; - vector prefix_vals; // for use with IPSrc/IPDst comparisons + std::vector prefix_vals; // for use with IPSrc/IPDst comparisons uint32_t offset; uint32_t size; @@ -240,7 +235,7 @@ public: * Ordered from greatest to least strength. Matches of the same strength * will be in the set in lexicographic order of the MIME type string. */ - typedef map, std::greater > MIME_Matches; + using MIME_Matches = std::map, std::greater>; /** * Matches a chunk of data against file magic signatures. diff --git a/src/Scope.cc b/src/Scope.cc index c324c6a134..f8a6f6d8bf 100644 --- a/src/Scope.cc +++ b/src/Scope.cc @@ -121,9 +121,9 @@ IntrusivePtr lookup_ID(const char* name, const char* curr_module, bool no_global, bool same_module_only, bool check_export) { - string fullname = make_full_var_name(curr_module, name); + std::string fullname = make_full_var_name(curr_module, name); - string ID_module = extract_module_name(fullname.c_str()); + std::string ID_module = extract_module_name(fullname.c_str()); bool need_export = check_export && (ID_module != GLOBAL_MODULE_NAME && ID_module != curr_module); @@ -143,7 +143,7 @@ IntrusivePtr lookup_ID(const char* name, const char* curr_module, if ( ! no_global && (strcmp(GLOBAL_MODULE_NAME, curr_module) == 0 || ! same_module_only) ) { - string globalname = make_full_var_name(GLOBAL_MODULE_NAME, name); + std::string globalname = make_full_var_name(GLOBAL_MODULE_NAME, name); ID* id = global_scope()->Lookup(globalname); if ( id ) return {NewRef{}, id}; @@ -168,7 +168,7 @@ IntrusivePtr install_ID(const char* name, const char* module_name, else scope = SCOPE_FUNCTION; - string full_name = make_full_var_name(module_name, name); + std::string full_name = make_full_var_name(module_name, name); auto id = make_intrusive(full_name.data(), scope, is_export); diff --git a/src/SerializationFormat.cc b/src/SerializationFormat.cc index f2dd26bf5b..2074cd4756 100644 --- a/src/SerializationFormat.cc +++ b/src/SerializationFormat.cc @@ -219,7 +219,7 @@ bool BinarySerializationFormat::Read(char** str, int* len, const char* tag) return true; } -bool BinarySerializationFormat::Read(string* v, const char* tag) +bool BinarySerializationFormat::Read(std::string* v, const char* tag) { char* buffer; int len; @@ -227,7 +227,7 @@ bool BinarySerializationFormat::Read(string* v, const char* tag) if ( ! Read(&buffer, &len, tag) ) return false; - *v = string(buffer, len); + *v = std::string(buffer, len); delete [] buffer; return true; @@ -362,7 +362,7 @@ bool BinarySerializationFormat::Write(const char* s, const char* tag) return Write(s, strlen(s), tag); } -bool BinarySerializationFormat::Write(const string& s, const char* tag) +bool BinarySerializationFormat::Write(const std::string& s, const char* tag) { return Write(s.data(), s.size(), tag); } diff --git a/src/Sessions.cc b/src/Sessions.cc index 104a39f28e..2970a5383f 100644 --- a/src/Sessions.cc +++ b/src/Sessions.cc @@ -1196,7 +1196,7 @@ Connection* NetSessions::LookupConn(const ConnectionMap& conns, const ConnIDKey& bool NetSessions::IsLikelyServerPort(uint32_t port, TransportProto proto) const { // We keep a cached in-core version of the table to speed up the lookup. - static set port_cache; + static std::set port_cache; static bool have_cache = false; if ( ! have_cache ) diff --git a/src/Sessions.h b/src/Sessions.h index ade677f0b9..9cefd6156a 100644 --- a/src/Sessions.h +++ b/src/Sessions.h @@ -221,9 +221,9 @@ protected: SessionStats stats; - typedef pair IPPair; - typedef pair TunnelActivity; - typedef std::map IPTunnelMap; + using IPPair = std::pair; + using TunnelActivity = std::pair; + using IPTunnelMap = std::map; IPTunnelMap ip_tunnels; analyzer::arp::ARP_Analyzer* arp_analyzer; diff --git a/src/SmithWaterman.cc b/src/SmithWaterman.cc index c9896d3c19..695d087848 100644 --- a/src/SmithWaterman.cc +++ b/src/SmithWaterman.cc @@ -143,7 +143,7 @@ BroSubstring::Vec* BroSubstring::VecFromPolicy(VectorVal* vec) char* BroSubstring::VecToString(Vec* vec) { - string result("["); + std::string result("["); for ( BroSubstring::VecIt it = vec->begin(); it != vec->end(); ++it ) { @@ -276,7 +276,7 @@ private: static void sw_collect_single(BroSubstring::Vec* result, SWNodeMatrix& matrix, SWNode* node, SWParams& params) { - string substring(""); + std::string substring(""); int row = 0, col = 0; while ( node ) @@ -340,7 +340,7 @@ static void sw_collect_single(BroSubstring::Vec* result, SWNodeMatrix& matrix, static void sw_collect_multiple(BroSubstring::Vec* result, SWNodeMatrix& matrix, SWParams& params) { - vector als; + std::vector als; for ( int i = matrix.GetHeight() - 1; i > 0; --i ) { @@ -354,7 +354,7 @@ static void sw_collect_multiple(BroSubstring::Vec* result, BroSubstring::Vec* new_al = new BroSubstring::Vec(); sw_collect_single(new_al, matrix, node, params); - for ( vector::iterator it = als.begin(); + for ( std::vector::iterator it = als.begin(); it != als.end(); ++it ) { BroSubstring::Vec* old_al = *it; @@ -393,7 +393,7 @@ end_loop: } } - for ( vector::iterator it = als.begin(); + for ( std::vector::iterator it = als.begin(); it != als.end(); ++it ) { BroSubstring::Vec* al = *it; @@ -506,7 +506,7 @@ BroSubstring::Vec* smith_waterman(const BroString* s1, const BroString* s2, if ( current->swn_byte_assigned ) current->swn_score = score_tl; else - current->swn_score = max(max(score_t, score_l), score_tl); + current->swn_score = std::max(std::max(score_t, score_l), score_tl); // Establish predecessor chain according to neighbor // with best score. diff --git a/src/Trigger.h b/src/Trigger.h index ae559b7995..c26e6e7b05 100644 --- a/src/Trigger.h +++ b/src/Trigger.h @@ -20,8 +20,6 @@ namespace trigger { // Triggers are the heart of "when" statements: expressions that when // they become true execute a body of statements. -using std::map; - class TriggerTimer; class TriggerTraversalCallback; @@ -110,7 +108,7 @@ private: std::vector> objs; - using ValCache = map; + using ValCache = std::map; ValCache cache; }; diff --git a/src/TunnelEncapsulation.h b/src/TunnelEncapsulation.h index 9dbf169326..4fc0d19b3e 100644 --- a/src/TunnelEncapsulation.h +++ b/src/TunnelEncapsulation.h @@ -10,7 +10,6 @@ #include -using std::vector; class Connection; /** @@ -135,7 +134,7 @@ public: EncapsulationStack(const EncapsulationStack& other) { if ( other.conns ) - conns = new vector(*(other.conns)); + conns = new std::vector(*(other.conns)); else conns = nullptr; } @@ -148,7 +147,7 @@ public: delete conns; if ( other.conns ) - conns = new vector(*(other.conns)); + conns = new std::vector(*(other.conns)); else conns = nullptr; @@ -165,7 +164,7 @@ public: void Add(const EncapsulatingConn& c) { if ( ! conns ) - conns = new vector(); + conns = new std::vector(); conns->push_back(c); } @@ -215,5 +214,5 @@ public: } protected: - vector* conns; + std::vector* conns; }; diff --git a/src/Type.cc b/src/Type.cc index a55781c648..39d4f4425b 100644 --- a/src/Type.cc +++ b/src/Type.cc @@ -20,6 +20,8 @@ #include #include +using namespace std; + BroType::TypeAliasMap BroType::type_aliases; // Note: This function must be thread-safe. diff --git a/src/Val.cc b/src/Val.cc index 580ff4d58c..58e78ea4a7 100644 --- a/src/Val.cc +++ b/src/Val.cc @@ -40,6 +40,8 @@ #include "threading/formatters/JSON.h" +using namespace std; + Val::Val(Func* f) : val(f), type(f->FType()->Ref()) { diff --git a/src/Val.h b/src/Val.h index 20339e27b1..6c2fb5ac1c 100644 --- a/src/Val.h +++ b/src/Val.h @@ -15,9 +15,6 @@ #include // for u_char -using std::vector; -using std::string; - // We have four different port name spaces: TCP, UDP, ICMP, and UNKNOWN. // We distinguish between them based on the bits specified in the *_PORT_MASK // entries specified below. @@ -85,7 +82,7 @@ union BroValUnion { PDict* table_val; val_list* val_list_val; - vector* vector_val; + std::vector* vector_val; BroValUnion() = default; @@ -122,7 +119,7 @@ union BroValUnion { constexpr BroValUnion(val_list* value) noexcept : val_list_val(value) {} - constexpr BroValUnion(vector *value) noexcept + constexpr BroValUnion(std::vector *value) noexcept : vector_val(value) {} }; @@ -214,7 +211,7 @@ public: CONST_ACCESSOR(TYPE_RECORD, val_list*, val_list_val, AsRecord) CONST_ACCESSOR(TYPE_FILE, BroFile*, file_val, AsFile) CONST_ACCESSOR(TYPE_PATTERN, RE_Matcher*, re_val, AsPattern) - CONST_ACCESSOR(TYPE_VECTOR, vector*, vector_val, AsVector) + CONST_ACCESSOR(TYPE_VECTOR, std::vector*, vector_val, AsVector) const IPPrefix& AsSubNet() const { @@ -248,7 +245,7 @@ public: ACCESSOR(TYPE_FUNC, Func*, func_val, AsFunc) ACCESSOR(TYPE_FILE, BroFile*, file_val, AsFile) ACCESSOR(TYPE_PATTERN, RE_Matcher*, re_val, AsPattern) - ACCESSOR(TYPE_VECTOR, vector*, vector_val, AsVector) + ACCESSOR(TYPE_VECTOR, std::vector*, vector_val, AsVector) const IPPrefix& AsSubNet() { @@ -475,7 +472,7 @@ public: // Returns the port number in host order (not including the mask). uint32_t Port() const; - string Protocol() const; + std::string Protocol() const; // Tests for protocol types. bool IsTCP() const; @@ -553,7 +550,7 @@ class StringVal final : public Val { public: explicit StringVal(BroString* s); explicit StringVal(const char* s); - explicit StringVal(const string& s); + explicit StringVal(const std::string& s); StringVal(int length, const char* s); IntrusivePtr SizeVal() const override; diff --git a/src/Var.cc b/src/Var.cc index ac1a0647fb..a6e2a79f42 100644 --- a/src/Var.cc +++ b/src/Var.cc @@ -272,8 +272,8 @@ extern IntrusivePtr add_and_assign_local(IntrusivePtr id, void add_type(ID* id, IntrusivePtr t, attr_list* attr) { - string new_type_name = id->Name(); - string old_type_name = t->GetName(); + std::string new_type_name = id->Name(); + std::string old_type_name = t->GetName(); IntrusivePtr tnew; if ( (t->Tag() == TYPE_RECORD || t->Tag() == TYPE_ENUM) && @@ -427,7 +427,7 @@ public: TraversalCode PostExpr(const Expr*) override; std::vector scopes; - vector outer_id_references; + std::vector outer_id_references; }; TraversalCode OuterIDBindingFinder::PreExpr(const Expr* expr) diff --git a/src/analyzer/Analyzer.h b/src/analyzer/Analyzer.h index a4bd7b7a20..43ad21b004 100644 --- a/src/analyzer/Analyzer.h +++ b/src/analyzer/Analyzer.h @@ -2,6 +2,13 @@ #pragma once +#include // for u_char + +#include +#include +#include +#include + #include "Tag.h" #include "../Obj.h" @@ -9,16 +16,6 @@ #include "../Timer.h" #include "../IntrusivePtr.h" -#include -#include -#include -#include - -#include // for u_char - -using std::list; -using std::string; - class BroFile; class Rule; class Connection; @@ -34,7 +31,7 @@ class AnalyzerTimer; class SupportAnalyzer; class OutputHandler; -typedef list analyzer_list; +using analyzer_list = std::list; typedef uint32_t ID; typedef void (Analyzer::*analyzer_timer_func)(double t); @@ -624,8 +621,8 @@ protected: * Return a string represantation of an analyzer, containing its name * and ID. */ - static string fmt_analyzer(const Analyzer* a) - { return string(a->GetAnalyzerName()) + fmt("[%d]", a->GetID()); } + static std::string fmt_analyzer(const Analyzer* a) + { return std::string(a->GetAnalyzerName()) + fmt("[%d]", a->GetID()); } /** * Associates a connection with this analyzer. Must be called if diff --git a/src/analyzer/Manager.cc b/src/analyzer/Manager.cc index 948e2d09b2..e0cbaad957 100644 --- a/src/analyzer/Manager.cc +++ b/src/analyzer/Manager.cc @@ -108,8 +108,8 @@ void Manager::DumpDebug() { #ifdef DEBUG DBG_LOG(DBG_ANALYZER, "Available analyzers after zeek_init():"); - list all_analyzers = GetComponents(); - for ( list::const_iterator i = all_analyzers.begin(); i != all_analyzers.end(); ++i ) + std::list all_analyzers = GetComponents(); + for ( std::list::const_iterator i = all_analyzers.begin(); i != all_analyzers.end(); ++i ) DBG_LOG(DBG_ANALYZER, " %s (%s)", (*i)->Name().c_str(), IsEnabled((*i)->Tag()) ? "enabled" : "disabled"); @@ -118,20 +118,20 @@ void Manager::DumpDebug() for ( analyzer_map_by_port::const_iterator i = analyzers_by_port_tcp.begin(); i != analyzers_by_port_tcp.end(); i++ ) { - string s; + std::string s; for ( tag_set::const_iterator j = i->second->begin(); j != i->second->end(); j++ ) - s += string(GetComponentName(*j)) + " "; + s += std::string(GetComponentName(*j)) + " "; DBG_LOG(DBG_ANALYZER, " %d/tcp: %s", i->first, s.c_str()); } for ( analyzer_map_by_port::const_iterator i = analyzers_by_port_udp.begin(); i != analyzers_by_port_udp.end(); i++ ) { - string s; + std::string s; for ( tag_set::const_iterator j = i->second->begin(); j != i->second->end(); j++ ) - s += string(GetComponentName(*j)) + " "; + s += std::string(GetComponentName(*j)) + " "; DBG_LOG(DBG_ANALYZER, " %d/udp: %s", i->first, s.c_str()); } @@ -199,8 +199,8 @@ void Manager::DisableAllAnalyzers() { DBG_LOG(DBG_ANALYZER, "Disabling all analyzers"); - list all_analyzers = GetComponents(); - for ( list::const_iterator i = all_analyzers.begin(); i != all_analyzers.end(); ++i ) + std::list all_analyzers = GetComponents(); + for ( std::list::const_iterator i = all_analyzers.begin(); i != all_analyzers.end(); ++i ) (*i)->SetEnabled(false); } diff --git a/src/analyzer/Manager.h b/src/analyzer/Manager.h index 084f4535fb..123851016d 100644 --- a/src/analyzer/Manager.h +++ b/src/analyzer/Manager.h @@ -342,8 +342,9 @@ public: { return vxlan_ports; } private: - typedef set tag_set; - typedef map analyzer_map_by_port; + + using tag_set = std::set; + using analyzer_map_by_port = std::map; tag_set* LookupPort(PortVal* val, bool add_if_not_found); tag_set* LookupPort(TransportProto proto, uint32_t port, bool add_if_not_found); @@ -387,10 +388,10 @@ private: }; }; - typedef std::multimap conns_map; - typedef std::priority_queue, - ScheduledAnalyzer::Comparator> conns_queue; + using conns_map = std::multimap; + using conns_queue = std::priority_queue, + ScheduledAnalyzer::Comparator>; conns_map conns; conns_queue conns_by_timeout; diff --git a/src/analyzer/protocol/bittorrent/BitTorrentTracker.cc b/src/analyzer/protocol/bittorrent/BitTorrentTracker.cc index d4ee18edab..d60bfcbfc4 100644 --- a/src/analyzer/protocol/bittorrent/BitTorrentTracker.cc +++ b/src/analyzer/protocol/bittorrent/BitTorrentTracker.cc @@ -745,7 +745,7 @@ int BitTorrentTracker_Analyzer::ResponseParseBenc(void) if ( benc_str_have < benc_str_len ) { unsigned int seek = - min(len, benc_str_len - benc_str_have); + std::min(len, benc_str_len - benc_str_have); benc_str_have += seek; if ( benc_raw_type != BENC_TYPE_NONE ) diff --git a/src/analyzer/protocol/bittorrent/BitTorrentTracker.h b/src/analyzer/protocol/bittorrent/BitTorrentTracker.h index ebd7e03955..5fbaba7a15 100644 --- a/src/analyzer/protocol/bittorrent/BitTorrentTracker.h +++ b/src/analyzer/protocol/bittorrent/BitTorrentTracker.h @@ -106,8 +106,8 @@ protected: TableVal* res_val_peers; TableVal* res_val_benc; - vector benc_stack; - vector benc_count; + std::vector benc_stack; + std::vector benc_count; enum btt_benc_states benc_state; char* benc_raw; diff --git a/src/analyzer/protocol/file/File.cc b/src/analyzer/protocol/file/File.cc index 7dca15c119..1889eca104 100644 --- a/src/analyzer/protocol/file/File.cc +++ b/src/analyzer/protocol/file/File.cc @@ -21,7 +21,7 @@ void File_Analyzer::DeliverStream(int len, const u_char* data, bool orig) { tcp::TCP_ApplicationAnalyzer::DeliverStream(len, data, orig); - int n = min(len, BUFFER_SIZE - buffer_len); + int n = std::min(len, BUFFER_SIZE - buffer_len); if ( n ) { @@ -75,7 +75,7 @@ void File_Analyzer::Identify() RuleMatcher::MIME_Matches matches; file_mgr->DetectMIME(reinterpret_cast(buffer), buffer_len, &matches); - string match = matches.empty() ? "" + std::string match = matches.empty() ? "" : *(matches.begin()->second.begin()); if ( file_transferred ) diff --git a/src/analyzer/protocol/file/File.h b/src/analyzer/protocol/file/File.h index ff2a190880..504747718e 100644 --- a/src/analyzer/protocol/file/File.h +++ b/src/analyzer/protocol/file/File.h @@ -27,8 +27,8 @@ protected: static const int BUFFER_SIZE = 1024; char buffer[BUFFER_SIZE]; int buffer_len; - string file_id_orig; - string file_id_resp; + std::string file_id_orig; + std::string file_id_resp; }; class IRC_Data : public File_Analyzer { @@ -51,4 +51,4 @@ public: { return new FTP_Data(conn); } }; -} } // namespace analyzer::* +} } // namespace analyzer::* diff --git a/src/analyzer/protocol/ftp/FTP.cc b/src/analyzer/protocol/ftp/FTP.cc index 31eaa481d1..310c7e896a 100644 --- a/src/analyzer/protocol/ftp/FTP.cc +++ b/src/analyzer/protocol/ftp/FTP.cc @@ -107,7 +107,7 @@ void FTP_Analyzer::DeliverStream(int length, const u_char* data, bool orig) if ( strncmp((const char*) cmd_str->Bytes(), "AUTH", cmd_len) == 0 ) - auth_requested = string(line, end_of_line - line); + auth_requested = std::string(line, end_of_line - line); if ( rule_matcher ) Conn()->Match(Rule::FTP, (const u_char *) cmd, diff --git a/src/analyzer/protocol/ftp/FTP.h b/src/analyzer/protocol/ftp/FTP.h index 385d3323c3..ea769e9adb 100644 --- a/src/analyzer/protocol/ftp/FTP.h +++ b/src/analyzer/protocol/ftp/FTP.h @@ -24,7 +24,7 @@ protected: login::NVT_Analyzer* nvt_orig; login::NVT_Analyzer* nvt_resp; uint32_t pending_reply; // code associated with multi-line reply, or 0 - string auth_requested; // AUTH method requested + std::string auth_requested; // AUTH method requested }; /** diff --git a/src/analyzer/protocol/ftp/functions.bif b/src/analyzer/protocol/ftp/functions.bif index d75f4bb899..4207ff3e13 100644 --- a/src/analyzer/protocol/ftp/functions.bif +++ b/src/analyzer/protocol/ftp/functions.bif @@ -86,7 +86,7 @@ static Val* parse_eftp(const char* line) good = 0; } - string s(line, nptr-line); // extract IP address + std::string s(line, nptr-line); // extract IP address IPAddr tmp(s); // on error, "tmp" will have all 128 bits zero if ( tmp == addr ) diff --git a/src/analyzer/protocol/gnutella/Gnutella.cc b/src/analyzer/protocol/gnutella/Gnutella.cc index a6d36218c8..5f162d2b68 100644 --- a/src/analyzer/protocol/gnutella/Gnutella.cc +++ b/src/analyzer/protocol/gnutella/Gnutella.cc @@ -112,9 +112,9 @@ bool Gnutella_Analyzer::NextLine(const u_char* data, int len) } -bool Gnutella_Analyzer::IsHTTP(string header) +bool Gnutella_Analyzer::IsHTTP(std::string header) { - if ( header.find(" HTTP/1.") == string::npos ) + if ( header.find(" HTTP/1.") == std::string::npos ) return false; if ( gnutella_http_notify ) @@ -139,7 +139,7 @@ bool Gnutella_Analyzer::IsHTTP(string header) } -bool Gnutella_Analyzer::GnutellaOK(string header) +bool Gnutella_Analyzer::GnutellaOK(std::string header) { if ( strncmp("GNUTELLA", header.data(), 8) ) return false; @@ -223,7 +223,7 @@ void Gnutella_Analyzer::SendEvents(GnutellaMsgState* p, bool is_orig) IntrusivePtr{AdoptRef{}, val_mgr->GetCount(p->msg_len)}, make_intrusive(p->payload), IntrusivePtr{AdoptRef{}, val_mgr->GetCount(p->payload_len)}, - IntrusivePtr{AdoptRef{}, val_mgr->GetBool((p->payload_len < min(p->msg_len, (unsigned int)GNUTELLA_MAX_PAYLOAD)))}, + IntrusivePtr{AdoptRef{}, val_mgr->GetBool((p->payload_len < std::min(p->msg_len, (unsigned int)GNUTELLA_MAX_PAYLOAD)))}, IntrusivePtr{AdoptRef{}, val_mgr->GetBool((p->payload_left == 0))} ); } diff --git a/src/analyzer/protocol/gnutella/Gnutella.h b/src/analyzer/protocol/gnutella/Gnutella.h index e7f22ece6e..416e6ccb59 100644 --- a/src/analyzer/protocol/gnutella/Gnutella.h +++ b/src/analyzer/protocol/gnutella/Gnutella.h @@ -16,10 +16,10 @@ class GnutellaMsgState { public: GnutellaMsgState (); - string buffer; + std::string buffer; int current_offset; int got_CR; - string headers; + std::string headers; char msg[GNUTELLA_MSG_SIZE]; u_char msg_hops; unsigned int msg_len; @@ -47,8 +47,8 @@ public: private: bool NextLine(const u_char* data, int len); - bool GnutellaOK(string header); - bool IsHTTP(string header); + bool GnutellaOK(std::string header); + bool IsHTTP(std::string header); bool Established() const { return state == (ORIG_OK | RESP_OK); } diff --git a/src/analyzer/protocol/icmp/ICMP.cc b/src/analyzer/protocol/icmp/ICMP.cc index 552f87c947..bb3b4fcedd 100644 --- a/src/analyzer/protocol/icmp/ICMP.cc +++ b/src/analyzer/protocol/icmp/ICMP.cc @@ -45,7 +45,7 @@ void ICMP_Analyzer::DeliverPacket(int len, const u_char* data, // caplen > len. if ( packet_contents ) // Subtract off the common part of ICMP header. - PacketContents(data + 8, min(len, caplen) - 8); + PacketContents(data + 8, std::min(len, caplen) - 8); const struct icmp* icmpp = (const struct icmp*) data; @@ -209,7 +209,7 @@ void ICMP_Analyzer::ICMP_Sent(const struct icmp* icmpp, int len, int caplen, if ( icmp_sent_payload ) { - BroString* payload = new BroString(data, min(len, caplen), false); + BroString* payload = new BroString(data, std::min(len, caplen), false); EnqueueConnEvent(icmp_sent_payload, IntrusivePtr{AdoptRef{}, BuildConnVal()}, @@ -841,7 +841,7 @@ VectorVal* ICMP_Analyzer::BuildNDOptionsVal(int caplen, const u_char* data) if ( set_payload_field ) { - BroString* payload = new BroString(data, min((int)length, caplen), false); + BroString* payload = new BroString(data, std::min((int)length, caplen), false); rv->Assign(6, make_intrusive(payload)); } diff --git a/src/analyzer/protocol/irc/IRC.cc b/src/analyzer/protocol/irc/IRC.cc index 258ae51086..834ac3a824 100644 --- a/src/analyzer/protocol/irc/IRC.cc +++ b/src/analyzer/protocol/irc/IRC.cc @@ -10,6 +10,7 @@ #include "events.bif.h" using namespace analyzer::irc; +using namespace std; IRC_Analyzer::IRC_Analyzer(Connection* conn) : tcp::TCP_ApplicationAnalyzer("IRC", conn) diff --git a/src/analyzer/protocol/irc/IRC.h b/src/analyzer/protocol/irc/IRC.h index 5bd11c47f7..b63d6f6bc8 100644 --- a/src/analyzer/protocol/irc/IRC.h +++ b/src/analyzer/protocol/irc/IRC.h @@ -46,7 +46,7 @@ protected: private: void StartTLS(); - inline void SkipLeadingWhitespace(string& str); + inline void SkipLeadingWhitespace(std::string& str); /** \brief counts number of invalid IRC messages */ int invalid_msg_count; @@ -62,7 +62,7 @@ private: * \param split character which separates the words * \return vector containing words */ - vector SplitWords(const string& input, char split); + std::vector SplitWords(const std::string& input, char split); tcp::ContentLine_Analyzer* cl_orig; tcp::ContentLine_Analyzer* cl_resp; diff --git a/src/analyzer/protocol/mime/MIME.cc b/src/analyzer/protocol/mime/MIME.cc index d644f00bb0..a509625d45 100644 --- a/src/analyzer/protocol/mime/MIME.cc +++ b/src/analyzer/protocol/mime/MIME.cc @@ -1215,7 +1215,7 @@ void MIME_Entity::DataOctets(int len, const char* data) if ( data_buf_offset < 0 && ! GetDataBuffer() ) return; - int n = min(data_buf_length - data_buf_offset, len); + int n = std::min(data_buf_length - data_buf_offset, len); memcpy(data_buf_data + data_buf_offset, data, n); data += n; data_buf_offset += n; diff --git a/src/analyzer/protocol/mime/MIME.h b/src/analyzer/protocol/mime/MIME.h index eb8c75a581..000ad77d15 100644 --- a/src/analyzer/protocol/mime/MIME.h +++ b/src/analyzer/protocol/mime/MIME.h @@ -5,7 +5,6 @@ #include #include #include -using namespace std; #include "BroString.h" #include "Reporter.h" @@ -61,7 +60,7 @@ public: BroString* get_concatenated_line(); protected: - vector buffer; + std::vector buffer; BroString* line; }; @@ -86,7 +85,7 @@ protected: }; -typedef vector MIME_HeaderList; +using MIME_HeaderList = std::vector; class MIME_Entity { public: @@ -255,13 +254,13 @@ protected: int compute_content_hash; int content_hash_length; EVP_MD_CTX* md5_hash; - vector entity_content; - vector all_content; + std::vector entity_content; + std::vector all_content; BroString* data_buffer; uint64_t cur_entity_len; - string cur_entity_id; + std::string cur_entity_id; }; diff --git a/src/analyzer/protocol/pop3/POP3.cc b/src/analyzer/protocol/pop3/POP3.cc index 174d11b826..0efcc4f14b 100644 --- a/src/analyzer/protocol/pop3/POP3.cc +++ b/src/analyzer/protocol/pop3/POP3.cc @@ -86,7 +86,7 @@ void POP3_Analyzer::DeliverStream(int len, const u_char* data, bool orig) ProcessReply(len, (char*) terminated_string.Bytes()); } -static string trim_whitespace(const char* in) +static std::string trim_whitespace(const char* in) { int n = strlen(in); char* out = new char[n + 1]; @@ -121,7 +121,7 @@ static string trim_whitespace(const char* in) *out_p = 0; - string rval(out); + std::string rval(out); delete [] out; return rval; } @@ -231,7 +231,7 @@ void POP3_Analyzer::ProcessRequest(int length, const char* line) // Some clients pipeline their commands (i.e., keep sending // without waiting for a server's responses). Therefore we // keep a list of pending commands. - cmds.push_back(string(line)); + cmds.push_back(std::string(line)); if ( cmds.size() == 1 ) // Not waiting for another server response, @@ -241,7 +241,7 @@ void POP3_Analyzer::ProcessRequest(int length, const char* line) } -static string commands[] = { +static std::string commands[] = { "OK", "ERR", "USER", "PASS", "APOP", "AUTH", "STAT", "LIST", "RETR", "DELE", "RSET", "NOOP", "LAST", "QUIT", "TOP", "CAPA", "UIDL", "STLS", "XSENDER", @@ -258,8 +258,8 @@ void POP3_Analyzer::ProcessClientCmd() if ( ! cmds.size() ) return; - string str = trim_whitespace(cmds.front().c_str()); - vector tokens = TokenizeLine(str, ' '); + std::string str = trim_whitespace(cmds.front().c_str()); + std::vector tokens = TokenizeLine(str, ' '); int cmd_code = -1; const char* cmd = ""; @@ -593,7 +593,7 @@ void POP3_Analyzer::FinishClientCmd() void POP3_Analyzer::ProcessReply(int length, const char* line) { const char* end_of_line = line + length; - string str = trim_whitespace(line); + std::string str = trim_whitespace(line); if ( multiLine == true ) { @@ -631,7 +631,7 @@ void POP3_Analyzer::ProcessReply(int length, const char* line) int cmd_code = -1; const char* cmd = ""; - vector tokens = TokenizeLine(str, ' '); + std::vector tokens = TokenizeLine(str, ' '); if ( tokens.size() > 0 ) cmd_code = ParseCmd(tokens[0]); @@ -863,7 +863,7 @@ void POP3_Analyzer::ProcessData(int length, const char* line) mail->Deliver(length, line, true); } -int POP3_Analyzer::ParseCmd(string cmd) +int POP3_Analyzer::ParseCmd(std::string cmd) { if ( cmd.size() == 0 ) return -1; @@ -884,18 +884,18 @@ int POP3_Analyzer::ParseCmd(string cmd) return -1; } -vector POP3_Analyzer::TokenizeLine(const string& input, char split) +std::vector POP3_Analyzer::TokenizeLine(const std::string& input, char split) { - vector tokens; + std::vector tokens; if ( input.size() < 1 ) return tokens; int start = 0; unsigned int splitPos = 0; - string token = ""; + std::string token = ""; - if ( input.find(split, 0) == string::npos ) + if ( input.find(split, 0) == std::string::npos ) { tokens.push_back(input); return tokens; diff --git a/src/analyzer/protocol/pop3/POP3.h b/src/analyzer/protocol/pop3/POP3.h index 8d3db050df..542e5e762a 100644 --- a/src/analyzer/protocol/pop3/POP3.h +++ b/src/analyzer/protocol/pop3/POP3.h @@ -86,8 +86,8 @@ protected: int lastRequiredCommand; int authLines; - string user; - string password; + std::string user; + std::string password; void ProcessRequest(int length, const char* line); void ProcessReply(int length, const char* line); @@ -99,14 +99,14 @@ protected: void EndData(); void StartTLS(); - vector TokenizeLine(const string& input, char split); - int ParseCmd(string cmd); + std::vector TokenizeLine(const std::string& input, char split); + int ParseCmd(std::string cmd); void AuthSuccessfull(); void POP3Event(EventHandlerPtr event, bool is_orig, const char* arg1 = nullptr, const char* arg2 = nullptr); mime::MIME_Mail* mail; - list cmds; + std::list cmds; private: bool tls; diff --git a/src/analyzer/protocol/rpc/NFS.cc b/src/analyzer/protocol/rpc/NFS.cc index b709bee680..b3bebcbfee 100644 --- a/src/analyzer/protocol/rpc/NFS.cc +++ b/src/analyzer/protocol/rpc/NFS.cc @@ -309,8 +309,8 @@ StringVal* NFS_Interp::nfs3_file_data(const u_char*& buf, int& n, uint64_t offse return nullptr; // Ok, so we want to return some data - data_n = min(data_n, size); - data_n = min(data_n, int(BifConst::NFS3::return_data_max)); + data_n = std::min(data_n, size); + data_n = std::min(data_n, int(BifConst::NFS3::return_data_max)); if ( data && data_n > 0 ) return new StringVal(new BroString(data, data_n, false)); diff --git a/src/analyzer/protocol/rpc/RPC.cc b/src/analyzer/protocol/rpc/RPC.cc index 50c86a69dd..01c45cacf9 100644 --- a/src/analyzer/protocol/rpc/RPC.cc +++ b/src/analyzer/protocol/rpc/RPC.cc @@ -394,14 +394,14 @@ bool RPC_Reasm_Buffer::ConsumeChunk(const u_char*& data, int& len) // How many bytes do we want to process with this call? Either the // all of the bytes available or the number of bytes that we are // still missing. - int64_t to_process = min(int64_t(len), (expected-processed)); + int64_t to_process = std::min(int64_t(len), (expected-processed)); if ( fill < maxsize ) { // We haven't yet filled the buffer. How many bytes to copy // into the buff. Either all of the bytes we want to process // or the number of bytes until we reach maxsize. - int64_t to_copy = min( to_process, (maxsize-fill) ); + int64_t to_copy = std::min( to_process, (maxsize-fill) ); if ( to_copy ) memcpy(buf+fill, data, to_copy); @@ -741,7 +741,7 @@ void RPC_Analyzer::DeliverPacket(int len, const u_char* data, bool orig, uint64_t seq, const IP_Hdr* ip, int caplen) { tcp::TCP_ApplicationAnalyzer::DeliverPacket(len, data, orig, seq, ip, caplen); - len = min(len, caplen); + len = std::min(len, caplen); if ( orig ) { diff --git a/src/analyzer/protocol/smtp/SMTP.h b/src/analyzer/protocol/smtp/SMTP.h index c98b500a79..4a1ffe96a5 100644 --- a/src/analyzer/protocol/smtp/SMTP.h +++ b/src/analyzer/protocol/smtp/SMTP.h @@ -3,7 +3,6 @@ #pragma once #include -using namespace std; #include "analyzer/protocol/tcp/TCP.h" #include "analyzer/protocol/tcp/ContentLine.h" @@ -83,7 +82,7 @@ protected: int last_replied_cmd; int first_cmd; // first un-replied SMTP cmd, or -1 int pending_reply; // code assoc. w/ multi-line reply, or 0 - list pending_cmd_q; // to support pipelining + std::list pending_cmd_q; // to support pipelining bool skip_data; // whether to skip message body BroString* line_after_gap; // last line before the first reply // after a gap diff --git a/src/analyzer/protocol/tcp/ContentLine.cc b/src/analyzer/protocol/tcp/ContentLine.cc index 5e0dfd81b2..a58ae3e892 100644 --- a/src/analyzer/protocol/tcp/ContentLine.cc +++ b/src/analyzer/protocol/tcp/ContentLine.cc @@ -145,7 +145,7 @@ void ContentLine_Analyzer::DoDeliver(int len, const u_char* data) if ( plain_delivery_length > 0 ) { - int deliver_plain = min(plain_delivery_length, (int64_t)len); + int deliver_plain = std::min(plain_delivery_length, (int64_t)len); last_char = 0; // clear last_char plain_delivery_length -= deliver_plain; diff --git a/src/analyzer/protocol/tcp/TCP.cc b/src/analyzer/protocol/tcp/TCP.cc index 8a8f300397..f9ce7d59b5 100644 --- a/src/analyzer/protocol/tcp/TCP.cc +++ b/src/analyzer/protocol/tcp/TCP.cc @@ -794,7 +794,7 @@ void TCP_Analyzer::GeneratePacketEvent( IntrusivePtr{AdoptRef{}, val_mgr->GetCount(len)}, // We need the min() here because Ethernet padding can lead to // caplen > len. - make_intrusive(min(caplen, len), (const char*) data) + make_intrusive(std::min(caplen, len), (const char*) data) ); } @@ -1055,7 +1055,7 @@ void TCP_Analyzer::DeliverPacket(int len, const u_char* data, bool is_orig, // We need the min() here because Ethernet frame padding can lead to // caplen > len. if ( packet_contents ) - PacketContents(data, min(len, caplen)); + PacketContents(data, std::min(len, caplen)); TCP_Endpoint* endpoint = is_orig ? orig : resp; TCP_Endpoint* peer = endpoint->peer; @@ -1906,7 +1906,7 @@ void TCP_ApplicationAnalyzer::DeliverPacket(int len, const u_char* data, Analyzer::DeliverPacket(len, data, is_orig, seq, ip, caplen); DBG_LOG(DBG_ANALYZER, "TCP_ApplicationAnalyzer ignoring DeliverPacket(%d, %s, %" PRIu64", %p, %d) [%s%s]", len, is_orig ? "T" : "F", seq, ip, caplen, - fmt_bytes((const char*) data, min(40, len)), len > 40 ? "..." : ""); + fmt_bytes((const char*) data, std::min(40, len)), len > 40 ? "..." : ""); } void TCP_ApplicationAnalyzer::SetEnv(bool /* is_orig */, char* name, char* val) diff --git a/src/analyzer/protocol/tcp/TCP.h b/src/analyzer/protocol/tcp/TCP.h index a5e67330d2..f8b668b35a 100644 --- a/src/analyzer/protocol/tcp/TCP.h +++ b/src/analyzer/protocol/tcp/TCP.h @@ -169,7 +169,7 @@ private: TCP_Endpoint* orig; TCP_Endpoint* resp; - typedef list analyzer_list; + using analyzer_list = std::list; analyzer_list packet_children; unsigned int first_packet_seen: 2; diff --git a/src/analyzer/protocol/tcp/TCP_Flags.h b/src/analyzer/protocol/tcp/TCP_Flags.h index 8b2b8820c6..d15bbe5468 100644 --- a/src/analyzer/protocol/tcp/TCP_Flags.h +++ b/src/analyzer/protocol/tcp/TCP_Flags.h @@ -14,13 +14,13 @@ public: bool URG() const { return flags & TH_URG; } bool PUSH() const { return flags & TH_PUSH; } - string AsString() const; + std::string AsString() const; protected: u_char flags; }; -inline string TCP_Flags::AsString() const +inline std::string TCP_Flags::AsString() const { char tcp_flags[10]; char* p = tcp_flags; diff --git a/src/analyzer/protocol/udp/UDP.cc b/src/analyzer/protocol/udp/UDP.cc index 23f6f88188..b585f4b227 100644 --- a/src/analyzer/protocol/udp/UDP.cc +++ b/src/analyzer/protocol/udp/UDP.cc @@ -58,7 +58,7 @@ void UDP_Analyzer::DeliverPacket(int len, const u_char* data, bool is_orig, // We need the min() here because Ethernet frame padding can lead to // caplen > len. if ( packet_contents ) - PacketContents(data, min(len, caplen) - sizeof(struct udphdr)); + PacketContents(data, std::min(len, caplen) - sizeof(struct udphdr)); int chksum = up->uh_sum; diff --git a/src/broker/Manager.h b/src/broker/Manager.h index 284f5a7538..2a38967458 100644 --- a/src/broker/Manager.h +++ b/src/broker/Manager.h @@ -194,7 +194,7 @@ public: * See the Broker::SendFlags record type. * @return true if the message is sent successfully. */ - bool PublishLogWrite(EnumVal* stream, EnumVal* writer, string path, int num_vals, + bool PublishLogWrite(EnumVal* stream, EnumVal* writer, std::string path, int num_vals, const threading::Value* const * vals); /** diff --git a/src/broker/Store.h b/src/broker/Store.h index dc1ff844df..b8a4301c09 100644 --- a/src/broker/Store.h +++ b/src/broker/Store.h @@ -52,7 +52,7 @@ class StoreQueryCallback { public: StoreQueryCallback(trigger::Trigger* arg_trigger, const CallExpr* arg_call, broker::store store) - : trigger(arg_trigger), call(arg_call), store(move(store)) + : trigger(arg_trigger), call(arg_call), store(std::move(store)) { Ref(trigger); } diff --git a/src/file_analysis/AnalyzerSet.h b/src/file_analysis/AnalyzerSet.h index d52937ca45..4605371eef 100644 --- a/src/file_analysis/AnalyzerSet.h +++ b/src/file_analysis/AnalyzerSet.h @@ -7,8 +7,6 @@ #include "Dict.h" #include "Tag.h" -using std::queue; - class CompositeHash; class RecordVal; @@ -204,7 +202,7 @@ private: HashKey* key; }; - typedef queue ModQueue; + using ModQueue = std::queue; ModQueue mod_queue; /**< A queue of analyzer additions/removals requests. */ }; diff --git a/src/file_analysis/File.cc b/src/file_analysis/File.cc index b526fdd80c..a8420e85c5 100644 --- a/src/file_analysis/File.cc +++ b/src/file_analysis/File.cc @@ -80,7 +80,7 @@ void File::StaticInit() meta_inferred_idx = Idx("inferred", fa_metadata_type); } -File::File(const string& file_id, const string& source_name, Connection* conn, +File::File(const std::string& file_id, const std::string& source_name, Connection* conn, analyzer::Tag tag, bool is_orig) : id(file_id), val(nullptr), file_reassembler(nullptr), stream_offset(0), reassembly_max_buffer(0), did_metadata_inference(false), @@ -174,7 +174,7 @@ double File::LookupFieldDefaultInterval(int idx) const return v->AsInterval(); } -int File::Idx(const string& field, const RecordType* type) +int File::Idx(const std::string& field, const RecordType* type) { int rval = type->FieldOffset(field.c_str()); @@ -185,14 +185,14 @@ int File::Idx(const string& field, const RecordType* type) return rval; } -string File::GetSource() const +std::string File::GetSource() const { Val* v = val->Lookup(source_idx); - return v ? v->AsString()->CheckString() : string(); + return v ? v->AsString()->CheckString() : std::string(); } -void File::SetSource(const string& source) +void File::SetSource(const std::string& source) { val->Assign(source_idx, make_intrusive(source.c_str())); } @@ -288,7 +288,7 @@ void File::SetReassemblyBuffer(uint64_t max) reassembly_max_buffer = max; } -bool File::SetMime(const string& mime_type) +bool File::SetMime(const std::string& mime_type) { if ( mime_type.empty() || bof_buffer.size != 0 || did_metadata_inference ) return false; @@ -329,7 +329,7 @@ void File::InferMetadata() RuleMatcher::MIME_Matches matches; const u_char* data = bof_buffer_val->AsString()->Bytes(); uint64_t len = bof_buffer_val->AsString()->Len(); - len = min(len, LookupFieldDefaultCount(bof_buffer_size_idx)); + len = std::min(len, LookupFieldDefaultCount(bof_buffer_size_idx)); file_mgr->DetectMIME(data, len, &matches); auto meta = make_intrusive(fa_metadata_type); @@ -383,7 +383,7 @@ void File::DeliverStream(const u_char* data, uint64_t len) "[%s] %" PRIu64 " stream bytes in at offset %" PRIu64 "; %s [%s%s]", id.c_str(), len, stream_offset, IsComplete() ? "complete" : "incomplete", - fmt_bytes((const char*) data, min((uint64_t)40, len)), + fmt_bytes((const char*) data, std::min((uint64_t)40, len)), len > 40 ? "..." : ""); file_analysis::Analyzer* a = nullptr; @@ -487,7 +487,7 @@ void File::DeliverChunk(const u_char* data, uint64_t len, uint64_t offset) "[%s] %" PRIu64 " chunk bytes in at offset %" PRIu64 "; %s [%s%s]", id.c_str(), len, offset, IsComplete() ? "complete" : "incomplete", - fmt_bytes((const char*) data, min((uint64_t)40, len)), + fmt_bytes((const char*) data, std::min((uint64_t)40, len)), len > 40 ? "..." : ""); file_analysis::Analyzer* a = nullptr; diff --git a/src/file_analysis/File.h b/src/file_analysis/File.h index ee9c447278..97e6e0817a 100644 --- a/src/file_analysis/File.h +++ b/src/file_analysis/File.h @@ -13,8 +13,6 @@ #include "ZeekArgs.h" #include "WeirdState.h" -using std::string; - class Connection; class RecordType; class RecordVal; @@ -46,13 +44,13 @@ public: * @return the value of the "source" field from #val record or an empty * string if it's not initialized. */ - string GetSource() const; + std::string GetSource() const; /** * Set the "source" field from #val record to \a source. * @param source the new value of the "source" field. */ - void SetSource(const string& source); + void SetSource(const std::string& source); /** * @return value (seconds) of the "timeout_interval" field from #val record. @@ -76,7 +74,7 @@ public: /** * @return value of the "id" field from #val record. */ - string GetID() const { return id; } + std::string GetID() const { return id; } /** * @return value of "last_active" field in #val record; @@ -212,7 +210,7 @@ public: * @return true if the mime type was set. False if it could not be set because * a mime type was already set or inferred. */ - bool SetMime(const string& mime_type); + bool SetMime(const std::string& mime_type); /** * Whether to permit a weird to carry on through the full reporter/weird @@ -236,7 +234,7 @@ protected: * of the connection to the responder. False indicates the other * direction. */ - File(const string& file_id, const string& source_name, Connection* conn = nullptr, + File(const std::string& file_id, const std::string& source_name, Connection* conn = nullptr, analyzer::Tag tag = analyzer::Tag::Error, bool is_orig = false); /** @@ -313,7 +311,7 @@ protected: */ void DeliverStream(const u_char* data, uint64_t len); - /** + /** * Perform chunk-wise delivery for analyzers that need it. */ void DeliverChunk(const u_char* data, uint64_t len, uint64_t offset); @@ -324,7 +322,7 @@ protected: * @param type the record type for which the field will be looked up. * @return the field offset in #val record corresponding to \a field_name. */ - static int Idx(const string& field_name, const RecordType* type); + static int Idx(const std::string& field_name, const RecordType* type); /** * Initializes static member. @@ -332,7 +330,7 @@ protected: static void StaticInit(); protected: - string id; /**< A pretty hash that likely identifies file */ + std::string id; /**< A pretty hash that likely identifies file */ RecordVal* val; /**< \c fa_file from script layer. */ FileReassembler* file_reassembler; /**< A reassembler for the file if it's needed. */ uint64_t stream_offset; /**< The offset of the file which has been forwarded. */ diff --git a/src/file_analysis/FileTimer.cc b/src/file_analysis/FileTimer.cc index b43a5de677..cd85a965e6 100644 --- a/src/file_analysis/FileTimer.cc +++ b/src/file_analysis/FileTimer.cc @@ -6,7 +6,7 @@ using namespace file_analysis; -FileTimer::FileTimer(double t, const string& id, double interval) +FileTimer::FileTimer(double t, const std::string& id, double interval) : Timer(t + interval, TIMER_FILE_ANALYSIS_INACTIVITY), file_id(id) { DBG_LOG(DBG_FILE_ANALYSIS, "New %f second timeout timer for %s", diff --git a/src/file_analysis/FileTimer.h b/src/file_analysis/FileTimer.h index 4664b904bb..9c5488a45f 100644 --- a/src/file_analysis/FileTimer.h +++ b/src/file_analysis/FileTimer.h @@ -2,11 +2,8 @@ #pragma once -#include "Timer.h" - #include - -using std::string; +#include "Timer.h" namespace file_analysis { @@ -22,7 +19,7 @@ public: * @param id the file identifier which will be checked for inactivity. * @param interval amount of time after \a t to check for inactivity. */ - FileTimer(double t, const string& id, double interval); + FileTimer(double t, const std::string& id, double interval); /** * Check inactivity of file_analysis::File corresponding to #file_id, @@ -33,7 +30,7 @@ public: void Dispatch(double t, bool is_expire) override; private: - string file_id; + std::string file_id; }; } // namespace file_analysis diff --git a/src/file_analysis/Manager.cc b/src/file_analysis/Manager.cc index 9383041394..c5406ae132 100644 --- a/src/file_analysis/Manager.cc +++ b/src/file_analysis/Manager.cc @@ -15,6 +15,7 @@ #include using namespace file_analysis; +using namespace std; TableVal* Manager::disabled = nullptr; TableType* Manager::tag_set_type = nullptr; diff --git a/src/file_analysis/Manager.h b/src/file_analysis/Manager.h index 6eb23acf73..f01d99d88c 100644 --- a/src/file_analysis/Manager.h +++ b/src/file_analysis/Manager.h @@ -14,9 +14,6 @@ #include "analyzer/Tag.h" -using std::map; -using std::set; - class TableVal; class VectorVal; @@ -75,7 +72,7 @@ public: * a single file. * @return a prettified MD5 hash of \a handle, truncated to *bits_per_uid* bits. */ - string HashHandle(const string& handle) const; + std::string HashHandle(const std::string& handle) const; /** * Take in a unique file handle string to identify next piece of @@ -83,7 +80,7 @@ public: * @param handle a unique string (may contain NULs) which identifies * a single file. */ - void SetHandle(const string& handle); + void SetHandle(const std::string& handle); /** * Pass in non-sequential file data. @@ -150,8 +147,8 @@ public: * in human-readable form where the file input is coming from (e.g. * a local file path). */ - void DataIn(const u_char* data, uint64_t len, const string& file_id, - const string& source); + void DataIn(const u_char* data, uint64_t len, const std::string& file_id, + const std::string& source); /** * Signal the end of file data regardless of which direction it is being @@ -173,7 +170,7 @@ public: * Signal the end of file data being transferred using the file identifier. * @param file_id the file identifier/hash. */ - void EndOfFile(const string& file_id); + void EndOfFile(const std::string& file_id); /** * Signal a gap in the file data stream. @@ -219,7 +216,7 @@ public: * @param file_id the file identifier/hash. * @return false if file identifier did not map to anything, else true. */ - bool IgnoreFile(const string& file_id); + bool IgnoreFile(const std::string& file_id); /** * Set's an inactivity threshold for the file. @@ -229,22 +226,22 @@ public: * to be considered stale, timed out, and then resource reclaimed. * @return false if file identifier did not map to anything, else true. */ - bool SetTimeoutInterval(const string& file_id, double interval) const; + bool SetTimeoutInterval(const std::string& file_id, double interval) const; /** * Enable the reassembler for a file. */ - bool EnableReassembly(const string& file_id); - + bool EnableReassembly(const std::string& file_id); + /** * Disable the reassembler for a file. */ - bool DisableReassembly(const string& file_id); + bool DisableReassembly(const std::string& file_id); /** * Set the reassembly for a file in bytes. */ - bool SetReassemblyBuffer(const string& file_id, uint64_t max); + bool SetReassemblyBuffer(const std::string& file_id, uint64_t max); /** * Sets a limit on the maximum size allowed for extracting the file @@ -256,7 +253,7 @@ public: * @return false if file identifier and analyzer did not map to anything, * else true. */ - bool SetExtractionLimit(const string& file_id, RecordVal* args, + bool SetExtractionLimit(const std::string& file_id, RecordVal* args, uint64_t n) const; /** @@ -265,7 +262,7 @@ public: * @return the File object mapped to \a file_id, or a null pointer if no * mapping exists. */ - File* LookupFile(const string& file_id) const; + File* LookupFile(const std::string& file_id) const; /** * Queue attachment of an analzer to the file identifier. Multiple @@ -276,7 +273,7 @@ public: * @param args a \c AnalyzerArgs value which describes a file analyzer. * @return false if the analyzer failed to be instantiated, else true. */ - bool AddAnalyzer(const string& file_id, const file_analysis::Tag& tag, + bool AddAnalyzer(const std::string& file_id, const file_analysis::Tag& tag, RecordVal* args) const; /** @@ -286,7 +283,7 @@ public: * @param args a \c AnalyzerArgs value which describes a file analyzer. * @return true if the analyzer is active at the time of call, else false. */ - bool RemoveAnalyzer(const string& file_id, const file_analysis::Tag& tag, + bool RemoveAnalyzer(const std::string& file_id, const file_analysis::Tag& tag, RecordVal* args) const; /** @@ -294,7 +291,7 @@ public: * @param file_id the file identifier/hash. * @return whether the file mapped to \a file_id is being ignored. */ - bool IsIgnored(const string& file_id); + bool IsIgnored(const std::string& file_id); /** * Instantiates a new file analyzer instance for the file. @@ -358,7 +355,7 @@ protected: * exist, the activity time is refreshed along with any * connection-related fields. */ - File* GetFile(const string& file_id, Connection* conn = nullptr, + File* GetFile(const std::string& file_id, Connection* conn = nullptr, const analyzer::Tag& tag = analyzer::Tag::Error, bool is_orig = false, bool update_conn = true, const char* source_name = nullptr); @@ -370,14 +367,14 @@ protected: * @param is_termination whether the Manager (and probably Bro) is in a * terminating state. If true, then the timeout cannot be postponed. */ - void Timeout(const string& file_id, bool is_terminating = ::terminating); + void Timeout(const std::string& file_id, bool is_terminating = ::terminating); /** * Immediately remove file_analysis::File object associated with \a file_id. * @param file_id the file identifier/hash. * @return false if file id string did not map to anything, else true. */ - bool RemoveFile(const string& file_id); + bool RemoveFile(const std::string& file_id); /** * Sets #current_file_id to a hash of a unique file handle string based on @@ -403,20 +400,20 @@ protected: static bool IsDisabled(const analyzer::Tag& tag); private: - typedef set TagSet; - typedef map MIMEMap; + typedef std::set TagSet; + typedef std::map MIMEMap; - TagSet* LookupMIMEType(const string& mtype, bool add_if_not_found); + TagSet* LookupMIMEType(const std::string& mtype, bool add_if_not_found); - std::map id_map; /**< Map file ID to file_analysis::File records. */ - std::set ignored; /**< Ignored files. Will be finally removed on EOF. */ - string current_file_id; /**< Hash of what get_file_handle event sets. */ + std::map id_map; /**< Map file ID to file_analysis::File records. */ + std::set ignored; /**< Ignored files. Will be finally removed on EOF. */ + std::string current_file_id; /**< Hash of what get_file_handle event sets. */ RuleFileMagicState* magic_state; /**< File magic signature match state. */ MIMEMap mime_types;/**< Mapping of MIME types to analyzers. */ static TableVal* disabled; /**< Table of disabled analyzers. */ static TableType* tag_set_type; /**< Type for set[tag]. */ - static string salt; /**< A salt added to file handles before hashing. */ + static std::string salt; /**< A salt added to file handles before hashing. */ size_t cumulative_files; size_t max_files; diff --git a/src/file_analysis/analyzer/extract/Extract.cc b/src/file_analysis/analyzer/extract/Extract.cc index 203b201635..5db2f8a0e0 100644 --- a/src/file_analysis/analyzer/extract/Extract.cc +++ b/src/file_analysis/analyzer/extract/Extract.cc @@ -10,7 +10,7 @@ using namespace file_analysis; -Extract::Extract(RecordVal* args, File* file, const string& arg_filename, +Extract::Extract(RecordVal* args, File* file, const std::string& arg_filename, uint64_t arg_limit) : file_analysis::Analyzer(file_mgr->GetComponentTag("EXTRACT"), args, file), filename(arg_filename), limit(arg_limit), depth(0) diff --git a/src/file_analysis/analyzer/extract/Extract.h b/src/file_analysis/analyzer/extract/Extract.h index acf581be59..5d2cd5b10b 100644 --- a/src/file_analysis/analyzer/extract/Extract.h +++ b/src/file_analysis/analyzer/extract/Extract.h @@ -66,11 +66,11 @@ protected: * to which the contents of the file will be extracted/written. * @param arg_limit the maximum allowed file size. */ - Extract(RecordVal* args, File* file, const string& arg_filename, + Extract(RecordVal* args, File* file, const std::string& arg_filename, uint64_t arg_limit); private: - string filename; + std::string filename; int fd; uint64_t limit; uint64_t depth; diff --git a/src/file_analysis/analyzer/x509/functions.bif b/src/file_analysis/analyzer/x509/functions.bif index 9f5635122f..c881e9afdb 100644 --- a/src/file_analysis/analyzer/x509/functions.bif +++ b/src/file_analysis/analyzer/x509/functions.bif @@ -703,7 +703,7 @@ function sct_verify%(cert: opaque of x509, logid: string, log_key: string, signa EVP_MD_CTX *mdctx = EVP_MD_CTX_create(); assert(mdctx); - string errstr; + std::string errstr; int success = 0; const EVP_MD* hash = hash_to_evp(hash_algorithm); diff --git a/src/input/Manager.cc b/src/input/Manager.cc index b8a5a4be37..4d6702e5f6 100644 --- a/src/input/Manager.cc +++ b/src/input/Manager.cc @@ -22,6 +22,7 @@ #include "../threading/SerialTypes.h" using namespace input; +using namespace std; using threading::Value; using threading::Field; diff --git a/src/input/Manager.h b/src/input/Manager.h index 1077a07cae..191692f9e6 100644 --- a/src/input/Manager.h +++ b/src/input/Manager.h @@ -4,14 +4,14 @@ #pragma once +#include + #include "Component.h" #include "EventHandler.h" #include "plugin/ComponentManager.h" #include "threading/SerialTypes.h" #include "Tag.h" -#include - class RecordVal; namespace input { @@ -81,7 +81,7 @@ public: * This method corresponds directly to the internal BiF defined in * input.bif, which just forwards here. */ - bool ForceUpdate(const string &id); + bool ForceUpdate(const std::string &id); /** * Deletes an existing input stream. @@ -91,7 +91,7 @@ public: * This method corresponds directly to the internal BiF defined in * input.bif, which just forwards here. */ - bool RemoveStream(const string &id); + bool RemoveStream(const std::string &id); /** * Signals the manager to shutdown at Bro's termination. @@ -145,7 +145,7 @@ protected: // Allows readers to directly send Bro events. The num_vals and vals // must be the same the named event expects. Takes ownership of // threading::Value fields. - bool SendEvent(ReaderFrontend* reader, const string& name, const int num_vals, threading::Value* *vals) const; + bool SendEvent(ReaderFrontend* reader, const std::string& name, const int num_vals, threading::Value* *vals) const; // Instantiates a new ReaderBackend of the given type (note that // doing so creates a new thread!). @@ -205,11 +205,11 @@ private: // Check if a record is made up of compatible types and return a list // of all fields that are in the record in order. Recursively unrolls // records - bool UnrollRecordType(vector *fields, const RecordType *rec, const string& nameprepend, bool allow_file_func) const; + bool UnrollRecordType(std::vector *fields, const RecordType *rec, const std::string& nameprepend, bool allow_file_func) const; // Send events void SendEvent(EventHandlerPtr ev, const int numvals, ...) const; - void SendEvent(EventHandlerPtr ev, list events) const; + void SendEvent(EventHandlerPtr ev, std::list events) const; // Implementation of SendEndOfData (send end_of_data event). void SendEndOfData(const Stream *i); @@ -257,12 +257,12 @@ private: void ErrorHandler(const Stream* i, ErrorType et, bool reporter_send, const char* fmt, ...) const __attribute__((format(printf, 5, 6))); void ErrorHandler(const Stream* i, ErrorType et, bool reporter_send, const char* fmt, va_list ap) const __attribute__((format(printf, 5, 0))); - Stream* FindStream(const string &name) const; + Stream* FindStream(const std::string &name) const; Stream* FindStream(ReaderFrontend* reader) const; enum StreamType { TABLE_STREAM, EVENT_STREAM, ANALYSIS_STREAM }; - map readers; + std::map readers; EventHandlerPtr end_of_data; }; @@ -271,4 +271,3 @@ private: } extern input::Manager* input_mgr; - diff --git a/src/input/readers/ascii/Ascii.cc b/src/input/readers/ascii/Ascii.cc index d04fbe713d..3b108e365c 100644 --- a/src/input/readers/ascii/Ascii.cc +++ b/src/input/readers/ascii/Ascii.cc @@ -14,6 +14,7 @@ using namespace input::reader; using namespace threading; +using namespace std; using threading::Value; using threading::Field; @@ -468,4 +469,3 @@ bool Ascii::DoHeartbeat(double network_time, double current_time) return true; } - diff --git a/src/input/readers/ascii/Ascii.h b/src/input/readers/ascii/Ascii.h index 019e215c4f..858e6f94cd 100644 --- a/src/input/readers/ascii/Ascii.h +++ b/src/input/readers/ascii/Ascii.h @@ -15,15 +15,15 @@ namespace input { namespace reader { // Description for input field mapping. struct FieldMapping { - string name; + std::string name; TypeTag type; TypeTag subtype; // internal type for sets and vectors int position; int secondary_position; // for ports: pos of the second field bool present; - FieldMapping(const string& arg_name, const TypeTag& arg_type, int arg_position); - FieldMapping(const string& arg_name, const TypeTag& arg_type, const TypeTag& arg_subtype, int arg_position); + FieldMapping(const std::string& arg_name, const TypeTag& arg_type, int arg_position); + FieldMapping(const std::string& arg_name, const TypeTag& arg_type, const TypeTag& arg_subtype, int arg_position); FieldMapping(const FieldMapping& arg); FieldMapping() { position = -1; secondary_position = -1; } @@ -54,32 +54,32 @@ protected: private: bool ReadHeader(bool useCached); - bool GetLine(string& str); + bool GetLine(std::string& str); bool OpenFile(); - ifstream file; + std::ifstream file; time_t mtime; ino_t ino; // The name using which we actually load the file -- compared // to the input source name, this one may have a path_prefix // attached to it. - string fname; + std::string fname; // map columns in the file to columns to send back to the manager - vector columnMap; + std::vector columnMap; // keep a copy of the headerline to determine field locations when stream descriptions change - string headerline; + std::string headerline; // options set from the script-level. - string separator; - string set_separator; - string empty_field; - string unset_field; + std::string separator; + std::string set_separator; + std::string empty_field; + std::string unset_field; bool fail_on_invalid_lines; bool fail_on_file_problem; - string path_prefix; + std::string path_prefix; std::unique_ptr formatter; }; diff --git a/src/input/readers/benchmark/Benchmark.cc b/src/input/readers/benchmark/Benchmark.cc index 32d57787c1..a7b0cc7c44 100644 --- a/src/input/readers/benchmark/Benchmark.cc +++ b/src/input/readers/benchmark/Benchmark.cc @@ -55,9 +55,9 @@ bool Benchmark::DoInit(const ReaderInfo& info, int num_fields, const Field* cons return true; } -string Benchmark::RandomString(const int len) +std::string Benchmark::RandomString(const int len) { - string s(len, ' '); + std::string s(len, ' '); static const char values[] = "0123456789!@#$%^&*()-_=+{}[]\\|" @@ -135,7 +135,7 @@ threading::Value* Benchmark::EntryToVal(TypeTag type, TypeTag subtype) case TYPE_STRING: { - string rnd = RandomString(10); + std::string rnd = RandomString(10); val->val.string_val.data = copy_string(rnd.c_str()); val->val.string_val.length = rnd.size(); break; diff --git a/src/input/readers/benchmark/Benchmark.h b/src/input/readers/benchmark/Benchmark.h index 944c85d06e..173d4eccda 100644 --- a/src/input/readers/benchmark/Benchmark.h +++ b/src/input/readers/benchmark/Benchmark.h @@ -25,7 +25,7 @@ protected: private: double CurrTime(); - string RandomString(const int len); + std::string RandomString(const int len); threading::Value* EntryToVal(TypeTag Type, TypeTag subtype); int num_lines; diff --git a/src/input/readers/binary/Binary.cc b/src/input/readers/binary/Binary.cc index 22a7121e13..9aa815cb47 100644 --- a/src/input/readers/binary/Binary.cc +++ b/src/input/readers/binary/Binary.cc @@ -8,6 +8,7 @@ #include "threading/SerialTypes.h" using namespace input::reader; +using namespace std; using threading::Value; using threading::Field; diff --git a/src/input/readers/binary/Binary.h b/src/input/readers/binary/Binary.h index 13a3d586cc..dd9c6b5c13 100644 --- a/src/input/readers/binary/Binary.h +++ b/src/input/readers/binary/Binary.h @@ -30,18 +30,18 @@ protected: private: bool OpenInput(); bool CloseInput(); - streamsize GetChunk(char** chunk); + std::streamsize GetChunk(char** chunk); int UpdateModificationTime(); - string fname; - ifstream* in; + std::string fname; + std::ifstream* in; time_t mtime; ino_t ino; bool firstrun; // options set from the script-level. - static streamsize chunk_size; - string path_prefix; + static std::streamsize chunk_size; + std::string path_prefix; }; } diff --git a/src/input/readers/config/Config.cc b/src/input/readers/config/Config.cc index 2908484f37..f31226a69b 100644 --- a/src/input/readers/config/Config.cc +++ b/src/input/readers/config/Config.cc @@ -72,7 +72,7 @@ bool Config::DoInit(const ReaderInfo& info, int num_fields, const Field* const* BifConst::InputConfig::empty_field->Len()); formatter::Ascii::SeparatorInfo sep_info("\t", set_separator, "", empty_field); - formatter = unique_ptr(new formatter::Ascii(this, sep_info)); + formatter = std::unique_ptr(new formatter::Ascii(this, sep_info)); return DoUpdate(); } @@ -94,7 +94,7 @@ bool Config::OpenFile() return true; } -bool Config::GetLine(string& str) +bool Config::GetLine(std::string& str) { while ( getline(file, str) ) { @@ -170,7 +170,7 @@ bool Config::DoUpdate() assert(false); } - string line; + std::string line; file.sync(); // keep a list of options to remove because they were no longer in the input file. @@ -197,8 +197,8 @@ bool Config::DoUpdate() continue; } - string key = line.substr(match[1].rm_so, match[1].rm_eo - match[1].rm_so); - string value; + std::string key = line.substr(match[1].rm_so, match[1].rm_eo - match[1].rm_so); + std::string value; if ( match[2].rm_so > 0 ) value = line.substr(match[2].rm_so, match[2].rm_eo - match[2].rm_so); @@ -308,4 +308,3 @@ bool Config::DoHeartbeat(double network_time, double current_time) return true; } - diff --git a/src/input/readers/config/Config.h b/src/input/readers/config/Config.h index fde24e29d9..e56576d375 100644 --- a/src/input/readers/config/Config.h +++ b/src/input/readers/config/Config.h @@ -37,17 +37,17 @@ protected: bool DoHeartbeat(double network_time, double current_time) override; private: - bool GetLine(string& str); + bool GetLine(std::string& str); bool OpenFile(); - ifstream file; + std::ifstream file; time_t mtime; ino_t ino; bool fail_on_file_problem; - string set_separator; - string empty_field; + std::string set_separator; + std::string empty_field; std::unique_ptr formatter; std::unordered_map> option_types; diff --git a/src/input/readers/raw/Raw.cc b/src/input/readers/raw/Raw.cc index 81627ac169..b8bfbdb1da 100644 --- a/src/input/readers/raw/Raw.cc +++ b/src/input/readers/raw/Raw.cc @@ -348,7 +348,7 @@ bool Raw::DoInit(const ReaderInfo& info, int num_fields, const Field* const* fie int want_fields = 1; bool result; - string source = string(info.source); + std::string source = std::string(info.source); char last = info.source[source.length() - 1]; if ( last == '|' ) { @@ -379,7 +379,7 @@ bool Raw::DoInit(const ReaderInfo& info, int num_fields, const Field* const* fie it = info.config.find("offset"); // we want to seek to a given offset inside the file if ( it != info.config.end() && ! execute && (Info().mode == MODE_STREAM || Info().mode == MODE_MANUAL) ) { - string offset_s = it->second; + std::string offset_s = it->second; offset = strtoll(offset_s.c_str(), 0, 10); } else if ( it != info.config.end() ) @@ -585,7 +585,7 @@ bool Raw::DoUpdate() } } - string line; + std::string line; assert ( (NumFields() == 1 && !use_stderr) || (NumFields() == 2 && use_stderr)); for ( ;; ) { diff --git a/src/input/readers/raw/Raw.h b/src/input/readers/raw/Raw.h index e5b9c9bdc6..6076503b23 100644 --- a/src/input/readers/raw/Raw.h +++ b/src/input/readers/raw/Raw.h @@ -45,7 +45,7 @@ private: bool Execute(); void WriteToStdin(); - string fname; // Source with a potential "|" removed. + std::string fname; // Source with a potential "|" removed. std::unique_ptr file; std::unique_ptr stderrfile; bool execute; @@ -54,7 +54,7 @@ private: ino_t ino; // options set from the script-level. - string separator; + std::string separator; unsigned int sep_length; // length of the separator int bufpos; @@ -65,7 +65,7 @@ private: int stdout_fileno; int stderr_fileno; - string stdin_string; + std::string stdin_string; uint64_t stdin_towrite; bool use_stderr; diff --git a/src/input/readers/sqlite/SQLite.cc b/src/input/readers/sqlite/SQLite.cc index e831db8c62..e5e3a133e4 100644 --- a/src/input/readers/sqlite/SQLite.cc +++ b/src/input/readers/sqlite/SQLite.cc @@ -38,7 +38,7 @@ SQLite::SQLite(ReaderFrontend *frontend) BifConst::InputSQLite::empty_field->Len() ); - io = new threading::formatter::Ascii(this, threading::formatter::Ascii::SeparatorInfo(string(), set_separator, unset_field, empty_field)); + io = new threading::formatter::Ascii(this, threading::formatter::Ascii::SeparatorInfo(std::string(), set_separator, unset_field, empty_field)); } SQLite::~SQLite() @@ -90,10 +90,10 @@ bool SQLite::DoInit(const ReaderInfo& info, int arg_num_fields, const threading: started = false; - string fullpath(info.source); + std::string fullpath(info.source); fullpath.append(".sqlite"); - string query; + std::string query; ReaderInfo::config_map::const_iterator it = info.config.find("query"); if ( it == info.config.end() ) { @@ -199,7 +199,7 @@ Value* SQLite::EntryToVal(sqlite3_stmt *st, const threading::Field *field, int p Error("Port protocol definition did not contain text"); else { - string s(text, sqlite3_column_bytes(st, subpos)); + std::string s(text, sqlite3_column_bytes(st, subpos)); val->val.port_val.proto = io->ParseProto(s); } } @@ -209,10 +209,10 @@ Value* SQLite::EntryToVal(sqlite3_stmt *st, const threading::Field *field, int p case TYPE_SUBNET: { const char *text = (const char*) sqlite3_column_text(st, pos); - string s(text, sqlite3_column_bytes(st, pos)); + std::string s(text, sqlite3_column_bytes(st, pos)); int pos = s.find('/'); int width = atoi(s.substr(pos+1).c_str()); - string addr = s.substr(0, pos); + std::string addr = s.substr(0, pos); val->val.subnet_val.prefix = io->ParseAddr(addr); val->val.subnet_val.length = width; @@ -222,7 +222,7 @@ Value* SQLite::EntryToVal(sqlite3_stmt *st, const threading::Field *field, int p case TYPE_ADDR: { const char *text = (const char*) sqlite3_column_text(st, pos); - string s(text, sqlite3_column_bytes(st, pos)); + std::string s(text, sqlite3_column_bytes(st, pos)); val->val.addr_val = io->ParseAddr(s); break; } @@ -231,7 +231,7 @@ Value* SQLite::EntryToVal(sqlite3_stmt *st, const threading::Field *field, int p case TYPE_VECTOR: { const char *text = (const char*) sqlite3_column_text(st, pos); - string s(text, sqlite3_column_bytes(st, pos)); + std::string s(text, sqlite3_column_bytes(st, pos)); delete val; val = io->ParseValue(s, "", field->type, field->subtype); break; @@ -342,4 +342,3 @@ bool SQLite::DoUpdate() return true; } - diff --git a/src/input/readers/sqlite/SQLite.h b/src/input/readers/sqlite/SQLite.h index b85af944db..fbab67df7a 100644 --- a/src/input/readers/sqlite/SQLite.h +++ b/src/input/readers/sqlite/SQLite.h @@ -35,14 +35,14 @@ private: unsigned int num_fields; int mode; bool started; - string query; + std::string query; sqlite3 *db; sqlite3_stmt *st; threading::formatter::Ascii* io; - string set_separator; - string unset_field; - string empty_field; + std::string set_separator; + std::string unset_field; + std::string empty_field; }; diff --git a/src/iosource/Component.cc b/src/iosource/Component.cc index a285cd8552..1d8a431df5 100644 --- a/src/iosource/Component.cc +++ b/src/iosource/Component.cc @@ -38,7 +38,7 @@ const std::vector& PktSrcComponent::Prefixes() const return prefixes; } -bool PktSrcComponent::HandlesPrefix(const string& prefix) const +bool PktSrcComponent::HandlesPrefix(const std::string& prefix) const { for ( std::vector::const_iterator i = prefixes.begin(); i != prefixes.end(); i++ ) @@ -69,7 +69,7 @@ void PktSrcComponent::DoDescribe(ODesc* d) const { iosource::Component::DoDescribe(d); - string prefs; + std::string prefs; for ( std::vector::const_iterator i = prefixes.begin(); i != prefixes.end(); i++ ) @@ -128,7 +128,7 @@ const std::vector& PktDumperComponent::Prefixes() const return prefixes; } -bool PktDumperComponent::HandlesPrefix(const string& prefix) const +bool PktDumperComponent::HandlesPrefix(const std::string& prefix) const { for ( std::vector::const_iterator i = prefixes.begin(); i != prefixes.end(); i++ ) @@ -144,7 +144,7 @@ void PktDumperComponent::DoDescribe(ODesc* d) const { plugin::Component::DoDescribe(d); - string prefs; + std::string prefs; for ( std::vector::const_iterator i = prefixes.begin(); i != prefixes.end(); i++ ) diff --git a/src/iosource/Manager.cc b/src/iosource/Manager.cc index 217bdf0f8a..00fc61ff5c 100644 --- a/src/iosource/Manager.cc +++ b/src/iosource/Manager.cc @@ -364,7 +364,7 @@ PktSrc* Manager::OpenPktSrc(const std::string& path, bool is_live) } -PktDumper* Manager::OpenPktDumper(const string& path, bool append) +PktDumper* Manager::OpenPktDumper(const std::string& path, bool append) { std::pair t = split_prefix(path); std::string prefix = t.first; diff --git a/src/iosource/PktSrc.cc b/src/iosource/PktSrc.cc index 53c2a747aa..0aa1a2568e 100644 --- a/src/iosource/PktSrc.cc +++ b/src/iosource/PktSrc.cc @@ -273,10 +273,10 @@ bool PktSrc::PrecompileBPFFilter(int index, const std::string& filter) if ( ! code->Compile(BifConst::Pcap::snaplen, LinkType(), filter.c_str(), Netmask(), errbuf, sizeof(errbuf)) ) { - string msg = fmt("cannot compile BPF filter \"%s\"", filter.c_str()); + std::string msg = fmt("cannot compile BPF filter \"%s\"", filter.c_str()); if ( *errbuf ) - msg += ": " + string(errbuf); + msg += ": " + std::string(errbuf); Error(msg); diff --git a/src/iosource/pcap/Source.cc b/src/iosource/pcap/Source.cc index 6f50f17263..31599139ac 100644 --- a/src/iosource/pcap/Source.cc +++ b/src/iosource/pcap/Source.cc @@ -308,7 +308,7 @@ void PcapSource::Statistics(Stats* s) void PcapSource::PcapError(const char* where) { - string location; + std::string location; if ( where ) location = fmt(" (%s)", where); diff --git a/src/logging/Manager.cc b/src/logging/Manager.cc index 92485a7777..5d9075ba37 100644 --- a/src/logging/Manager.cc +++ b/src/logging/Manager.cc @@ -26,6 +26,7 @@ #include +using namespace std; using namespace logging; struct Manager::Filter { diff --git a/src/logging/Manager.h b/src/logging/Manager.h index 55dc5b68c0..8db9904e86 100644 --- a/src/logging/Manager.h +++ b/src/logging/Manager.h @@ -112,7 +112,7 @@ public: * This methods corresponds directly to the internal BiF defined in * logging.bif, which just forwards here. */ - bool RemoveFilter(EnumVal* id, const string& name); + bool RemoveFilter(EnumVal* id, const std::string& name); /** * Write a record to a log stream. @@ -165,7 +165,7 @@ public: * @param vals An array of log values to write, of size num_fields. * The method takes ownership of the array. */ - bool WriteFromRemote(EnumVal* stream, EnumVal* writer, const string& path, + bool WriteFromRemote(EnumVal* stream, EnumVal* writer, const std::string& path, int num_fields, threading::Value** vals); /** @@ -241,7 +241,7 @@ protected: // Takes ownership of fields and info. WriterFrontend* CreateWriter(EnumVal* id, EnumVal* writer, WriterBackend::WriterInfo* info, int num_fields, const threading::Field* const* fields, - bool local, bool remote, bool from_remote, const string& instantiating_filter=""); + bool local, bool remote, bool from_remote, const std::string& instantiating_filter=""); // Signals that a file has been rotated. bool FinishedRotation(WriterFrontend* writer, const char* new_name, const char* old_name, @@ -256,7 +256,7 @@ private: struct WriterInfo; bool TraverseRecord(Stream* stream, Filter* filter, RecordType* rt, - TableVal* include, TableVal* exclude, const string& path, const list& indices); + TableVal* include, TableVal* exclude, const std::string& path, const std::list& indices); threading::Value** RecordToFilterVals(Stream* stream, Filter* filter, RecordVal* columns); @@ -270,7 +270,7 @@ private: bool CompareFields(const Filter* filter, const WriterFrontend* writer); bool CheckFilterWriterConflict(const WriterInfo* winfo, const Filter* filter); - vector streams; // Indexed by stream enum. + std::vector streams; // Indexed by stream enum. int rotations_pending; // Number of rotations not yet finished. }; diff --git a/src/logging/writers/ascii/Ascii.cc b/src/logging/writers/ascii/Ascii.cc index 71c47042ba..8c502b498b 100644 --- a/src/logging/writers/ascii/Ascii.cc +++ b/src/logging/writers/ascii/Ascii.cc @@ -10,6 +10,7 @@ #include "Ascii.h" #include "ascii.bif.h" +using namespace std; using namespace logging::writer; using namespace threading; using threading::Value; diff --git a/src/logging/writers/ascii/Ascii.h b/src/logging/writers/ascii/Ascii.h index 0fa073a158..c7376fe8fd 100644 --- a/src/logging/writers/ascii/Ascii.h +++ b/src/logging/writers/ascii/Ascii.h @@ -17,7 +17,7 @@ public: explicit Ascii(WriterFrontend* frontend); ~Ascii() override; - static string LogExt(); + static std::string LogExt(); static WriterBackend* Instantiate(WriterFrontend* frontend) { return new Ascii(frontend); } @@ -35,11 +35,11 @@ protected: bool DoHeartbeat(double network_time, double current_time) override; private: - bool IsSpecial(const string &path) { return path.find("/dev/") == 0; } - bool WriteHeader(const string& path); - bool WriteHeaderField(const string& key, const string& value); + bool IsSpecial(const std::string &path) { return path.find("/dev/") == 0; } + bool WriteHeader(const std::string& path); + bool WriteHeaderField(const std::string& key, const std::string& value); void CloseFile(double t); - string Timestamp(double t); // Uses current time if t is zero. + std::string Timestamp(double t); // Uses current time if t is zero. void InitConfigOptions(); bool InitFilterOptions(); bool InitFormatter(); @@ -48,7 +48,7 @@ private: int fd; gzFile gzfile; - string fname; + std::string fname; ODesc desc; bool ascii_done; @@ -57,17 +57,17 @@ private: bool include_meta; bool tsv; - string separator; - string set_separator; - string empty_field; - string unset_field; - string meta_prefix; + std::string separator; + std::string set_separator; + std::string empty_field; + std::string unset_field; + std::string meta_prefix; int gzip_level; // level > 0 enables gzip compression - string gzip_file_extension; + std::string gzip_file_extension; bool use_json; bool enable_utf_8; - string json_timestamps; + std::string json_timestamps; threading::formatter::Formatter* formatter; bool init_options; diff --git a/src/logging/writers/none/None.cc b/src/logging/writers/none/None.cc index 5691430476..a668dde3cc 100644 --- a/src/logging/writers/none/None.cc +++ b/src/logging/writers/none/None.cc @@ -21,14 +21,14 @@ bool None::DoInit(const WriterInfo& info, int num_fields, // Output the config sorted by keys. - std::vector > keys; + std::vector > keys; for ( WriterInfo::config_map::const_iterator i = info.config.begin(); i != info.config.end(); i++ ) keys.push_back(std::make_pair(i->first, i->second)); std::sort(keys.begin(), keys.end()); - for ( std::vector >::const_iterator i = keys.begin(); i != keys.end(); i++ ) + for ( std::vector >::const_iterator i = keys.begin(); i != keys.end(); i++ ) std::cout << " config[" << (*i).first << "] = " << (*i).second << std::endl; for ( int i = 0; i < num_fields; i++ ) diff --git a/src/logging/writers/sqlite/SQLite.cc b/src/logging/writers/sqlite/SQLite.cc index 48930a6225..5043ad75c6 100644 --- a/src/logging/writers/sqlite/SQLite.cc +++ b/src/logging/writers/sqlite/SQLite.cc @@ -11,6 +11,7 @@ #include "SQLite.h" #include "sqlite.bif.h" +using namespace std; using namespace logging; using namespace writer; using threading::Value; diff --git a/src/logging/writers/sqlite/SQLite.h b/src/logging/writers/sqlite/SQLite.h index 87003f35cb..6d6914be1f 100644 --- a/src/logging/writers/sqlite/SQLite.h +++ b/src/logging/writers/sqlite/SQLite.h @@ -37,7 +37,7 @@ private: bool checkError(int code); int AddParams(threading::Value* val, int pos); - string GetTableType(int, int); + std::string GetTableType(int, int); const threading::Field* const * fields; // raw mapping unsigned int num_fields; @@ -45,9 +45,9 @@ private: sqlite3 *db; sqlite3_stmt *st; - string set_separator; - string unset_field; - string empty_field; + std::string set_separator; + std::string unset_field; + std::string empty_field; threading::formatter::Ascii* io; }; diff --git a/src/net_util.cc b/src/net_util.cc index 549d257d7e..4136031f13 100644 --- a/src/net_util.cc +++ b/src/net_util.cc @@ -137,8 +137,8 @@ const char* fmt_conn_id(const IPAddr& src_addr, uint32_t src_port, static char buffer[512]; snprintf(buffer, sizeof(buffer), "%s:%d > %s:%d", - string(src_addr).c_str(), src_port, - string(dst_addr).c_str(), dst_port); + std::string(src_addr).c_str(), src_port, + std::string(dst_addr).c_str(), dst_port); return buffer; } diff --git a/src/parse.y b/src/parse.y index afc2d81a17..5b1c20bb22 100644 --- a/src/parse.y +++ b/src/parse.y @@ -114,7 +114,7 @@ extern int brolex(); * Part of the module facility: while parsing, keep track of which * module to put things in. */ -string current_module = GLOBAL_MODULE_NAME; +std::string current_module = GLOBAL_MODULE_NAME; bool is_export = false; // true if in an export {} block /* @@ -196,7 +196,7 @@ static attr_list* copy_attr_list(attr_list* al) static void extend_record(ID* id, type_decl_list* fields, attr_list* attrs) { - set types = BroType::GetAliases(id->Name()); + std::set types = BroType::GetAliases(id->Name()); if ( types.empty() ) { @@ -204,7 +204,7 @@ static void extend_record(ID* id, type_decl_list* fields, attr_list* attrs) return; } - for ( set::const_iterator it = types.begin(); it != types.end(); ) + for ( std::set::const_iterator it = types.begin(); it != types.end(); ) { RecordType* add_to = (*it)->AsRecordType(); const char* error = 0; diff --git a/src/plugin/ComponentManager.h b/src/plugin/ComponentManager.h index c58db68765..2448597004 100644 --- a/src/plugin/ComponentManager.h +++ b/src/plugin/ComponentManager.h @@ -37,7 +37,7 @@ public: * @param local_id The local part of the ID of the new enum type * (e.g., "Tag"). */ - ComponentManager(const string& module, const string& local_id); + ComponentManager(const std::string& module, const std::string& local_id); /** * @return The script-layer module in which the component's "Tag" ID lives. @@ -47,7 +47,7 @@ public: /** * @return A list of all registered components. */ - list GetComponents() const; + std::list GetComponents() const; /** * @return The enum type associated with the script-layer "Tag". @@ -77,7 +77,7 @@ public: * @return The component's tag, or a tag representing an error if * no such component assoicated with the name exists. */ - T GetComponentTag(const string& name) const; + T GetComponentTag(const std::string& name) const; /** * Get a component tag from its enum value. @@ -97,14 +97,14 @@ public: * value will be a concatenation of this prefix and the component's * canonical name. */ - void RegisterComponent(C* component, const string& prefix = ""); + void RegisterComponent(C* component, const std::string& prefix = ""); /** * @param name The canonical name of a component. * @return The component associated with the name or a null pointer if no * such component exists. */ - C* Lookup(const string& name) const; + C* Lookup(const std::string& name) const; /** * @param name A component tag. @@ -121,15 +121,15 @@ public: C* Lookup(EnumVal* val) const; private: - string module; /**< Script layer module in which component tags live. */ + std::string module; /**< Script layer module in which component tags live. */ IntrusivePtr tag_enum_type; /**< Enum type of component tags. */ - map components_by_name; - map components_by_tag; - map components_by_val; + std::map components_by_name; + std::map components_by_tag; + std::map components_by_val; }; template -ComponentManager::ComponentManager(const string& arg_module, const string& local_id) +ComponentManager::ComponentManager(const std::string& arg_module, const std::string& local_id) : module(arg_module), tag_enum_type(make_intrusive(module + "::" + local_id)) { @@ -145,10 +145,10 @@ const std::string& ComponentManager::GetModule() const } template -list ComponentManager::GetComponents() const +std::list ComponentManager::GetComponents() const { - list rval; - typename map::const_iterator i; + std::list rval; + typename std::map::const_iterator i; for ( i = components_by_tag.begin(); i != components_by_tag.end(); ++i ) rval.push_back(i->second); @@ -187,7 +187,7 @@ const std::string& ComponentManager::GetComponentName(Val* val) const } template -T ComponentManager::GetComponentTag(const string& name) const +T ComponentManager::GetComponentTag(const std::string& name) const { C* c = Lookup(name); return c ? c->Tag() : T(); @@ -201,9 +201,9 @@ T ComponentManager::GetComponentTag(Val* v) const } template -C* ComponentManager::Lookup(const string& name) const +C* ComponentManager::Lookup(const std::string& name) const { - typename map::const_iterator i = + typename std::map::const_iterator i = components_by_name.find(to_upper(name)); return i != components_by_name.end() ? i->second : 0; } @@ -211,21 +211,21 @@ C* ComponentManager::Lookup(const string& name) const template C* ComponentManager::Lookup(const T& tag) const { - typename map::const_iterator i = components_by_tag.find(tag); + typename std::map::const_iterator i = components_by_tag.find(tag); return i != components_by_tag.end() ? i->second : 0; } template C* ComponentManager::Lookup(EnumVal* val) const { - typename map::const_iterator i = + typename std::map::const_iterator i = components_by_val.find(val->InternalInt()); return i != components_by_val.end() ? i->second : 0; } template void ComponentManager::RegisterComponent(C* component, - const string& prefix) + const std::string& prefix) { std::string cname = component->CanonicalName(); @@ -242,7 +242,7 @@ void ComponentManager::RegisterComponent(C* component, component->Tag().AsEnumVal()->InternalInt(), component)); // Install an identfier for enum value - string id = fmt("%s%s", prefix.c_str(), cname.c_str()); + std::string id = fmt("%s%s", prefix.c_str(), cname.c_str()); tag_enum_type->AddName(module, id.c_str(), component->Tag().AsEnumVal()->InternalInt(), true, nullptr); diff --git a/src/plugin/Manager.cc b/src/plugin/Manager.cc index 09275e639f..084e421945 100644 --- a/src/plugin/Manager.cc +++ b/src/plugin/Manager.cc @@ -17,6 +17,7 @@ #include "../util.h" #include "../input.h" +using namespace std; using namespace plugin; Plugin* Manager::current_plugin = nullptr; diff --git a/src/plugin/Manager.h b/src/plugin/Manager.h index 9c0ffecad5..f2e46ca68e 100644 --- a/src/plugin/Manager.h +++ b/src/plugin/Manager.h @@ -238,7 +238,7 @@ public: * if a plugin took over the file but had trouble loading it; and -1 if * no plugin was interested in the file at all. */ - virtual int HookLoadFile(const Plugin::LoadType type, const string& file, const string& resolved); + virtual int HookLoadFile(const Plugin::LoadType type, const std::string& file, const std::string& resolved); /** * Hook that filters calls to a script function/event/hook. diff --git a/src/probabilistic/BloomFilter.cc b/src/probabilistic/BloomFilter.cc index e9289a9db9..f31762dcf4 100644 --- a/src/probabilistic/BloomFilter.cc +++ b/src/probabilistic/BloomFilter.cc @@ -254,7 +254,7 @@ CountingBloomFilter* CountingBloomFilter::Clone() const return copy; } -string CountingBloomFilter::InternalState() const +std::string CountingBloomFilter::InternalState() const { return fmt("%" PRIu64, cells->Hash()); } diff --git a/src/probabilistic/CardinalityCounter.cc b/src/probabilistic/CardinalityCounter.cc index a2d224a09e..502d44946c 100644 --- a/src/probabilistic/CardinalityCounter.cc +++ b/src/probabilistic/CardinalityCounter.cc @@ -173,7 +173,7 @@ bool CardinalityCounter::Merge(CardinalityCounter* c) if ( m != c->GetM() ) return false; - const vector& temp = c->GetBuckets(); + const std::vector& temp = c->GetBuckets(); V = 0; @@ -189,7 +189,7 @@ bool CardinalityCounter::Merge(CardinalityCounter* c) return true; } -const vector &CardinalityCounter::GetBuckets() const +const std::vector &CardinalityCounter::GetBuckets() const { return buckets; } diff --git a/src/rule-parse.y b/src/rule-parse.y index cd44e4d205..34199c1443 100644 --- a/src/rule-parse.y +++ b/src/rule-parse.y @@ -81,7 +81,7 @@ static uint8_t ip4_mask_to_len(uint32_t mask) Rule* rule; RuleHdrTest* hdr_test; maskedvalue_list* vallist; - vector* prefix_val_list; + std::vector* prefix_val_list; IPPrefix* prefixval; bool bl; @@ -318,12 +318,12 @@ prefix_value_list: } | prefix_value { - $$ = new vector(); + $$ = new std::vector(); $$->push_back(*($1)); } | TOK_IDENT { - $$ = new vector(); + $$ = new std::vector(); id_to_maskedvallist($1, 0, $$); } ; diff --git a/src/rule-scan.l b/src/rule-scan.l index f34935d361..bc64963161 100644 --- a/src/rule-scan.l +++ b/src/rule-scan.l @@ -48,7 +48,7 @@ PID {PIDCOMPONENT}(::{PIDCOMPONENT})* {IP6}{OWS}"/"{OWS}{D} { int len = 0; - string ip = extract_ip_and_len(yytext, &len); + std::string ip = extract_ip_and_len(yytext, &len); rules_lval.prefixval = new IPPrefix(IPAddr(ip), len, true); return TOK_IP6; } diff --git a/src/scan.l b/src/scan.l index 682f5c39c8..516fb4edf2 100644 --- a/src/scan.l +++ b/src/scan.l @@ -77,10 +77,10 @@ static void deprecated_attr(const char* attr) reporter->Warning("Use of deprecated attribute: %s", attr); } -static string find_relative_file(const string& filename, const string& ext) +static std::string find_relative_file(const std::string& filename, const std::string& ext) { if ( filename.empty() ) - return string(); + return std::string(); if ( filename[0] == '.' ) return find_file(filename, SafeDirname(::filename).result, ext); @@ -88,10 +88,10 @@ static string find_relative_file(const string& filename, const string& ext) return find_file(filename, bro_path(), ext); } -static string find_relative_script_file(const string& filename) +static std::string find_relative_script_file(const std::string& filename) { if ( filename.empty() ) - return string(); + return std::string(); if ( filename[0] == '.' ) return find_script_file(filename, SafeDirname(::filename).result); @@ -99,7 +99,7 @@ static string find_relative_script_file(const string& filename) return find_script_file(filename, bro_path()); } -static ZeekINode get_inode(FILE* f, const string& path) +static ZeekINode get_inode(FILE* f, const std::string& path) { struct stat b; @@ -110,7 +110,7 @@ static ZeekINode get_inode(FILE* f, const string& path) return {b.st_dev, b.st_ino}; } -static ZeekINode get_inode(const string& path) +static ZeekINode get_inode(const std::string& path) { FILE* f = open_file(path); @@ -125,11 +125,11 @@ static ZeekINode get_inode(const string& path) class FileInfo { public: - FileInfo(string restore_module = ""); + FileInfo(std::string restore_module = ""); ~FileInfo(); YY_BUFFER_STATE buffer_state; - string restore_module; + std::string restore_module; const char* name; int line; int level; @@ -176,7 +176,7 @@ ESCSEQ (\\([^\n]|[0-7]+|x[[:xdigit:]]+)) } ##<.* { - string hint(cur_enum_type && last_id_tok ? + std::string hint(cur_enum_type && last_id_tok ? make_full_var_name(current_module.c_str(), last_id_tok) : ""); zeekygen_mgr->PostComment(yytext + 3, hint); @@ -206,7 +206,7 @@ ESCSEQ (\\([^\n]|[0-7]+|x[[:xdigit:]]+)) {IP6}{OWS}"/"{OWS}{D} { int len = 0; - string ip = extract_ip_and_len(yytext, &len); + std::string ip = extract_ip_and_len(yytext, &len); RET_CONST(new SubNetVal(IPPrefix(IPAddr(ip), len, true))) } @@ -215,7 +215,7 @@ ESCSEQ (\\([^\n]|[0-7]+|x[[:xdigit:]]+)) ({D}"."){3}{D}{OWS}"/"{OWS}{D} { int len = 0; - string ip = extract_ip_and_len(yytext, &len); + std::string ip = extract_ip_and_len(yytext, &len); RET_CONST(new SubNetVal(IPPrefix(IPAddr(ip), len))) } @@ -332,7 +332,7 @@ when return TOK_WHEN; @DEBUG return TOK_DEBUG; // marks input for debugger @DIR { - string rval = SafeDirname(::filename).result; + std::string rval = SafeDirname(::filename).result; if ( ! rval.empty() && rval[0] == '.' ) { @@ -341,7 +341,7 @@ when return TOK_WHEN; if ( ! getcwd(path, MAXPATHLEN) ) reporter->InternalError("getcwd failed: %s", strerror(errno)); else - rval = string(path) + "/" + rval; + rval = std::string(path) + "/" + rval; } RET_CONST(new StringVal(rval.c_str())); @@ -353,15 +353,15 @@ when return TOK_WHEN; @load{WS}{FILE} { const char* new_file = skip_whitespace(yytext + 5); // Skip "@load". - string loader = ::filename; // load_files may change ::filename, save copy - string loading = find_relative_script_file(new_file); + std::string loader = ::filename; // load_files may change ::filename, save copy + std::string loading = find_relative_script_file(new_file); (void) load_files(new_file); zeekygen_mgr->ScriptDependency(loader, loading); } @load-sigs{WS}{FILE} { const char* file = skip_whitespace(yytext + 10); - string path = find_relative_file(file, ".sig"); + std::string path = find_relative_file(file, ".sig"); int rc = PLUGIN_HOOK_WITH_RESULT(HOOK_LOAD_FILE, HookLoadFile(plugin::Plugin::SIGNATURES, file, path), -1); switch ( rc ) { @@ -421,7 +421,7 @@ when return TOK_WHEN; @unload{WS}{FILE} { // Skip "@unload". const char* file = skip_whitespace(yytext + 7); - string path = find_relative_script_file(file); + std::string path = find_relative_script_file(file); if ( path.empty() ) reporter->Error("failed find file associated with @unload %s", file); @@ -605,14 +605,14 @@ static bool already_scanned(ZeekINode in) return false; } -static bool already_scanned(const string& path) +static bool already_scanned(const std::string& path) { return already_scanned(get_inode(path)); } static int load_files(const char* orig_file) { - string file_path = find_relative_script_file(orig_file); + std::string file_path = find_relative_script_file(orig_file); int rc = PLUGIN_HOOK_WITH_RESULT(HOOK_LOAD_FILE, HookLoadFile(plugin::Plugin::SCRIPT, orig_file, file_path), -1); if ( rc == 1 ) @@ -953,9 +953,9 @@ int yywrap() if ( ! zeek_script_prefixes[i][0] ) continue; - string canon = without_bropath_component(it->name); - string flat = flatten_script_name(canon, zeek_script_prefixes[i]); - string path = find_relative_script_file(flat); + std::string canon = without_bropath_component(it->name); + std::string flat = flatten_script_name(canon, zeek_script_prefixes[i]); + std::string path = find_relative_script_file(flat); if ( ! path.empty() ) { @@ -978,7 +978,7 @@ int yywrap() // Add redef statements for any X=Y command line parameters. if ( params.size() > 0 ) { - string policy; + std::string policy; for ( unsigned int i = 0; i < params.size(); ++i ) { @@ -999,13 +999,13 @@ int yywrap() // that just means quoting the value if it's a // string type.) If no type is found, the value // is left unchanged. - string opt_quote; // no optional quote by default + std::string opt_quote; // no optional quote by default Val* v = opt_internal_val(param); if ( v && v->Type() && v->Type()->Tag() == TYPE_STRING ) opt_quote = "\""; // use quotes - policy += string("redef ") + param + "=" + policy += std::string("redef ") + param + "=" + opt_quote + val + opt_quote + ";"; delete [] param; @@ -1042,7 +1042,7 @@ int yywrap() return 1; } -FileInfo::FileInfo(string arg_restore_module) +FileInfo::FileInfo(std::string arg_restore_module) { buffer_state = YY_CURRENT_BUFFER; restore_module = arg_restore_module; diff --git a/src/threading/BasicThread.h b/src/threading/BasicThread.h index fba5acaeeb..fa1e097536 100644 --- a/src/threading/BasicThread.h +++ b/src/threading/BasicThread.h @@ -1,12 +1,10 @@ #pragma once -#include -#include - #include -using namespace std; +#include +#include namespace threading { diff --git a/src/threading/Formatter.cc b/src/threading/Formatter.cc index ec89ebed97..17e015452d 100644 --- a/src/threading/Formatter.cc +++ b/src/threading/Formatter.cc @@ -22,7 +22,7 @@ Formatter::~Formatter() { } -string Formatter::Render(const threading::Value::addr_t& addr) +std::string Formatter::Render(const threading::Value::addr_t& addr) { if ( addr.family == IPv4 ) { @@ -44,7 +44,7 @@ string Formatter::Render(const threading::Value::addr_t& addr) } } -TransportProto Formatter::ParseProto(const string &proto) const +TransportProto Formatter::ParseProto(const std::string &proto) const { if ( proto == "unknown" ) return TRANSPORT_UNKNOWN; @@ -62,7 +62,7 @@ TransportProto Formatter::ParseProto(const string &proto) const // More or less verbose copy from IPAddr.cc -- which uses reporter. -threading::Value::addr_t Formatter::ParseAddr(const string &s) const +threading::Value::addr_t Formatter::ParseAddr(const std::string &s) const { threading::Value::addr_t val; @@ -90,7 +90,7 @@ threading::Value::addr_t Formatter::ParseAddr(const string &s) const return val; } -string Formatter::Render(const threading::Value::subnet_t& subnet) +std::string Formatter::Render(const threading::Value::subnet_t& subnet) { char l[16]; @@ -99,19 +99,19 @@ string Formatter::Render(const threading::Value::subnet_t& subnet) else modp_uitoa10(subnet.length, l); - string s = Render(subnet.prefix) + "/" + l; + std::string s = Render(subnet.prefix) + "/" + l; return s; } -string Formatter::Render(double d) +std::string Formatter::Render(double d) { char buf[256]; modp_dtoa(d, buf, 6); return buf; } -string Formatter::Render(TransportProto proto) +std::string Formatter::Render(TransportProto proto) { if ( proto == TRANSPORT_UDP ) return "udp"; diff --git a/src/threading/Formatter.h b/src/threading/Formatter.h index 64a8502bc5..83a3667145 100644 --- a/src/threading/Formatter.h +++ b/src/threading/Formatter.h @@ -2,12 +2,10 @@ #pragma once -#include "Type.h" -#include "SerialTypes.h" - #include -using std::string; +#include "Type.h" +#include "SerialTypes.h" namespace threading { @@ -17,7 +15,7 @@ namespace formatter { /** * A thread-safe class for converting values into some textual format. This - * is a base class that implements the interface for common + * is a base class that implements the interface for common * rendering/parsing code needed by a number of input/output threads. */ class Formatter { @@ -69,7 +67,7 @@ public: * @return Returns true on success, false on error. Errors are also * flagged via the thread. */ - virtual bool Describe(ODesc* desc, threading::Value* val, const string& name = "") const = 0; + virtual bool Describe(ODesc* desc, threading::Value* val, const std::string& name = "") const = 0; /** * Convert an implementation-specific textual representation of a @@ -83,7 +81,7 @@ public: * @return The new value, or null on error. Errors must also be * flagged via the thread. */ - virtual threading::Value* ParseValue(const string& s, const string& name, TypeTag type, TypeTag subtype = TYPE_ERROR) const = 0; + virtual threading::Value* ParseValue(const std::string& s, const std::string& name, TypeTag type, TypeTag subtype = TYPE_ERROR) const = 0; /** * Convert an IP address into a string. @@ -94,7 +92,7 @@ public: * * @return An ASCII representation of the address. */ - static string Render(const threading::Value::addr_t& addr); + static std::string Render(const threading::Value::addr_t& addr); /** * Convert an subnet value into a string. @@ -105,7 +103,7 @@ public: * * @return An ASCII representation of the subnet. */ - static string Render(const threading::Value::subnet_t& subnet); + static std::string Render(const threading::Value::subnet_t& subnet); /** * Convert a double into a string. This renders the double with Bro's @@ -117,7 +115,7 @@ public: * * @return An ASCII representation of the double. */ - static string Render(double d); + static std::string Render(double d); /** * Convert a transport protocol into a string. @@ -128,7 +126,7 @@ public: * * @return An ASCII representation of the protocol. */ - static string Render(TransportProto proto); + static std::string Render(TransportProto proto); /** * Convert a string into a TransportProto. The string must be one of @@ -141,7 +139,7 @@ public: * @return The transport protocol, which will be \c TRANSPORT_UNKNOWN * on error. Errors are also flagged via the thread. */ - TransportProto ParseProto(const string &proto) const; + TransportProto ParseProto(const std::string &proto) const; /** * Convert a string into a Value::addr_t. @@ -153,7 +151,7 @@ public: * @return The address, which will be all-zero on error. Errors are * also flagged via the thread. */ - threading::Value::addr_t ParseAddr(const string &addr) const; + threading::Value::addr_t ParseAddr(const std::string &addr) const; protected: /** diff --git a/src/threading/Manager.h b/src/threading/Manager.h index 3285b8e4b6..2c5b05d9b5 100644 --- a/src/threading/Manager.h +++ b/src/threading/Manager.h @@ -59,7 +59,7 @@ public: */ bool Terminating() const { return terminating; } - typedef std::list > msg_stats_list; + typedef std::list > msg_stats_list; /** * Returns statistics from all current MsgThread instances. diff --git a/src/threading/MsgThread.cc b/src/threading/MsgThread.cc index 2b6ef01ead..3d2fa66271 100644 --- a/src/threading/MsgThread.cc +++ b/src/threading/MsgThread.cc @@ -382,7 +382,7 @@ BasicInputMessage* MsgThread::RetrieveIn() return nullptr; #ifdef DEBUG - string s = Fmt("Retrieved '%s' in %s", msg->Name(), Name()); + std::string s = Fmt("Retrieved '%s' in %s", msg->Name(), Name()); Debug(DBG_THREADING, s.c_str()); #endif diff --git a/src/threading/SerialTypes.cc b/src/threading/SerialTypes.cc index b04549f0b6..a115c37351 100644 --- a/src/threading/SerialTypes.cc +++ b/src/threading/SerialTypes.cc @@ -11,7 +11,7 @@ bool Field::Read(SerializationFormat* fmt) { int t; int st; - string tmp_name; + std::string tmp_name; bool have_2nd; if ( ! fmt->Read(&have_2nd, "have_2nd") ) @@ -19,7 +19,7 @@ bool Field::Read(SerializationFormat* fmt) if ( have_2nd ) { - string tmp_secondary_name; + std::string tmp_secondary_name; if ( ! fmt->Read(&tmp_secondary_name, "secondary_name") ) return false; @@ -64,9 +64,9 @@ bool Field::Write(SerializationFormat* fmt) const fmt->Write(optional, "optional")); } -string Field::TypeName() const +std::string Field::TypeName() const { - string n; + std::string n; // We do not support tables, if the internal Bro type is table it // always is a set. diff --git a/src/threading/SerialTypes.h b/src/threading/SerialTypes.h index 628c3b40f7..f424eb9143 100644 --- a/src/threading/SerialTypes.h +++ b/src/threading/SerialTypes.h @@ -9,8 +9,6 @@ #include "Type.h" #include "net_util.h" -using namespace std; - class SerializationFormat; namespace threading { @@ -73,7 +71,7 @@ struct Field { * Returns a textual description of the field's type. This method is * thread-safe. */ - string TypeName() const; + std::string TypeName() const; private: // Force usage of constructor above. diff --git a/src/threading/formatters/Ascii.cc b/src/threading/formatters/Ascii.cc index a5337dac1e..dd2aa3983a 100644 --- a/src/threading/formatters/Ascii.cc +++ b/src/threading/formatters/Ascii.cc @@ -9,6 +9,7 @@ #include #include +using namespace std; using namespace threading::formatter; // If the value we'd write out would match exactly the a reserved string, we diff --git a/src/threading/formatters/Ascii.h b/src/threading/formatters/Ascii.h index 16a20425e9..e6fd757aab 100644 --- a/src/threading/formatters/Ascii.h +++ b/src/threading/formatters/Ascii.h @@ -14,16 +14,17 @@ public: */ struct SeparatorInfo { - string separator; // Separator between columns - string set_separator; // Separator between set elements. - string unset_field; // String marking an unset field. - string empty_field; // String marking an empty (but set) field. + std::string separator; // Separator between columns + std::string set_separator; // Separator between set elements. + std::string unset_field; // String marking an unset field. + std::string empty_field; // String marking an empty (but set) field. /** * Constructor that defines all the configuration options. * Use if you need either ValToODesc or EntryToVal. */ - SeparatorInfo(const string& separator, const string& set_separator, const string& unset_field, const string& empty_field); + SeparatorInfo(const std::string& separator, const std::string& set_separator, + const std::string& unset_field, const std::string& empty_field); /** * Constructor that leaves separators etc unset to dummy @@ -46,10 +47,11 @@ public: Ascii(threading::MsgThread* t, const SeparatorInfo& info); virtual ~Ascii(); - virtual bool Describe(ODesc* desc, threading::Value* val, const string& name = "") const; + virtual bool Describe(ODesc* desc, threading::Value* val, const std::string& name = "") const; virtual bool Describe(ODesc* desc, int num_fields, const threading::Field* const * fields, threading::Value** vals) const; - virtual threading::Value* ParseValue(const string& s, const string& name, TypeTag type, TypeTag subtype = TYPE_ERROR) const; + virtual threading::Value* ParseValue(const std::string& s, const std::string& name, + TypeTag type, TypeTag subtype = TYPE_ERROR) const; private: bool CheckNumberError(const char* start, const char* end) const; diff --git a/src/threading/formatters/JSON.cc b/src/threading/formatters/JSON.cc index 72b1624352..e6d702bafe 100644 --- a/src/threading/formatters/JSON.cc +++ b/src/threading/formatters/JSON.cc @@ -55,7 +55,7 @@ bool JSON::Describe(ODesc* desc, int num_fields, const Field* const * fields, return true; } -bool JSON::Describe(ODesc* desc, Value* val, const string& name) const +bool JSON::Describe(ODesc* desc, Value* val, const std::string& name) const { if ( desc->IsBinary() ) { @@ -78,13 +78,13 @@ bool JSON::Describe(ODesc* desc, Value* val, const string& name) const return true; } -threading::Value* JSON::ParseValue(const string& s, const string& name, TypeTag type, TypeTag subtype) const +threading::Value* JSON::ParseValue(const std::string& s, const std::string& name, TypeTag type, TypeTag subtype) const { GetThread()->Error("JSON formatter does not support parsing yet."); return nullptr; } -void JSON::BuildJSON(NullDoubleWriter& writer, Value* val, const string& name) const +void JSON::BuildJSON(NullDoubleWriter& writer, Value* val, const std::string& name) const { if ( ! val->present ) { @@ -174,7 +174,7 @@ void JSON::BuildJSON(NullDoubleWriter& writer, Value* val, const string& name) c case TYPE_FILE: case TYPE_FUNC: { - writer.String(json_escape_utf8(string(val->val.string_val.data, val->val.string_val.length))); + writer.String(json_escape_utf8(std::string(val->val.string_val.data, val->val.string_val.length))); break; } diff --git a/src/threading/formatters/JSON.h b/src/threading/formatters/JSON.h index 46f0769782..2a9e07a1a9 100644 --- a/src/threading/formatters/JSON.h +++ b/src/threading/formatters/JSON.h @@ -25,10 +25,10 @@ public: JSON(threading::MsgThread* t, TimeFormat tf); ~JSON() override; - bool Describe(ODesc* desc, threading::Value* val, const string& name = "") const override; + bool Describe(ODesc* desc, threading::Value* val, const std::string& name = "") const override; bool Describe(ODesc* desc, int num_fields, const threading::Field* const * fields, threading::Value** vals) const override; - threading::Value* ParseValue(const string& s, const string& name, TypeTag type, TypeTag subtype = TYPE_ERROR) const override; + threading::Value* ParseValue(const std::string& s, const std::string& name, TypeTag type, TypeTag subtype = TYPE_ERROR) const override; class NullDoubleWriter : public rapidjson::Writer { public: @@ -37,7 +37,7 @@ public: }; private: - void BuildJSON(NullDoubleWriter& writer, Value* val, const string& name = "") const; + void BuildJSON(NullDoubleWriter& writer, Value* val, const std::string& name = "") const; TimeFormat timestamps; bool surrounding_braces; diff --git a/src/util.cc b/src/util.cc index 0b1128b296..70a53bc005 100644 --- a/src/util.cc +++ b/src/util.cc @@ -65,6 +65,8 @@ #endif #endif +using namespace std; + static bool starts_with(std::string_view s, std::string_view beginning) { if ( beginning.size() > s.size() ) diff --git a/src/zeekygen/Manager.h b/src/zeekygen/Manager.h index 3c3b7a91b9..6edc9c1d17 100644 --- a/src/zeekygen/Manager.h +++ b/src/zeekygen/Manager.h @@ -234,8 +234,8 @@ private: }; template -bool Manager::IsUpToDate(const string& target_file, - const vector& dependencies) const +bool Manager::IsUpToDate(const std::string& target_file, + const std::vector& dependencies) const { struct stat s; diff --git a/testing/btest/plugins/pktsrc-plugin/src/Foo.cc b/testing/btest/plugins/pktsrc-plugin/src/Foo.cc index 012b1f226a..ce70177c1b 100644 --- a/testing/btest/plugins/pktsrc-plugin/src/Foo.cc +++ b/testing/btest/plugins/pktsrc-plugin/src/Foo.cc @@ -13,10 +13,10 @@ using namespace plugin::Demo_Foo; Foo::Foo(const std::string& path, bool is_live) { packet = - string("\x45\x00\x00\x40\x15\x55\x40\x00\x3e\x06\x25\x5b\x01\x02\x00\x02" - "\x01\x02\x00\x03\x09\xdf\x19\xf9\x5d\x8a\x36\x7c\x00\x00\x00\x00" - "\xb0\x02\x40\x00\x3c\x72\x00\x00\x02\x04\x05\x5c\x01\x03\x03\x00" - "\x01\x01\x08\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01\x04\x02", 64); + std::string("\x45\x00\x00\x40\x15\x55\x40\x00\x3e\x06\x25\x5b\x01\x02\x00\x02" + "\x01\x02\x00\x03\x09\xdf\x19\xf9\x5d\x8a\x36\x7c\x00\x00\x00\x00" + "\xb0\x02\x40\x00\x3c\x72\x00\x00\x02\x04\x05\x5c\x01\x03\x03\x00" + "\x01\x01\x08\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01\x04\x02", 64); props.path = path; props.selectable_fd = open("/bin/sh", O_RDONLY); // any fd is fine. @@ -49,7 +49,7 @@ bool Foo::ExtractNextPacket(Packet* pkt) } pkt_timeval ts = { 1409193037, 0 }; - pkt->Init(props.link_type, &ts, packet.size(), packet.size(), + pkt->Init(props.link_type, &ts, packet.size(), packet.size(), (const u_char *)packet.c_str()); return true; } diff --git a/testing/btest/plugins/pktsrc-plugin/src/Foo.h b/testing/btest/plugins/pktsrc-plugin/src/Foo.h index 7896440229..678403983b 100644 --- a/testing/btest/plugins/pktsrc-plugin/src/Foo.h +++ b/testing/btest/plugins/pktsrc-plugin/src/Foo.h @@ -24,7 +24,7 @@ protected: private: Properties props; - string packet; + std::string packet; }; } diff --git a/testing/btest/plugins/reader-plugin/src/Foo.cc b/testing/btest/plugins/reader-plugin/src/Foo.cc index acfd094aa9..c008babff9 100644 --- a/testing/btest/plugins/reader-plugin/src/Foo.cc +++ b/testing/btest/plugins/reader-plugin/src/Foo.cc @@ -35,9 +35,9 @@ bool Foo::DoInit(const ReaderInfo& info, int num_fields, const Field* const* fie return true; } -string Foo::RandomString(const int len) +std::string Foo::RandomString(const int len) { - string s(len, ' '); + std::string s(len, ' '); static const char values[] = "0123456789!@#$%^&*()-_=+{}[]\\|" @@ -83,7 +83,7 @@ threading::Value* Foo::EntryToVal(TypeTag type, TypeTag subtype) case TYPE_STRING: { - string rnd = RandomString(10); + std::string rnd = RandomString(10); val->val.string_val.data = copy_string(rnd.c_str()); val->val.string_val.length = rnd.size(); break; diff --git a/testing/btest/plugins/reader-plugin/src/Foo.h b/testing/btest/plugins/reader-plugin/src/Foo.h index 9e7fa133ae..38bddcda94 100644 --- a/testing/btest/plugins/reader-plugin/src/Foo.h +++ b/testing/btest/plugins/reader-plugin/src/Foo.h @@ -23,7 +23,7 @@ protected: virtual bool DoHeartbeat(double network_time, double current_time); private: - string RandomString(const int len); + std::string RandomString(const int len); threading::Value* EntryToVal(TypeTag Type, TypeTag subtype); threading::formatter::Ascii* ascii; }; diff --git a/testing/btest/plugins/writer-plugin/src/Foo.h b/testing/btest/plugins/writer-plugin/src/Foo.h index 5a3e336fbf..f04b453ceb 100644 --- a/testing/btest/plugins/writer-plugin/src/Foo.h +++ b/testing/btest/plugins/writer-plugin/src/Foo.h @@ -29,7 +29,7 @@ protected: virtual bool DoHeartbeat(double network_time, double current_time) { return true; } private: - string path; + std::string path; ODesc desc; threading::formatter::Formatter* formatter; };