diff --git a/tools/bifcl/bif_arg.cc b/tools/bifcl/bif_arg.cc index 7018e9e02d..c4f27f96de 100644 --- a/tools/bifcl/bif_arg.cc +++ b/tools/bifcl/bif_arg.cc @@ -7,7 +7,8 @@ using namespace std; #include "bif_arg.h" -static struct { +static struct + { const char* bif_type; const char* zeek_type; const char* c_type; @@ -17,12 +18,14 @@ static struct { const char* cast_smart; const char* constructor; const char* ctor_smart; -} builtin_func_arg_type[] = { -#define DEFINE_BIF_TYPE(id, bif_type, zeek_type, c_type, c_type_smart, accessor, accessor_smart, cast_smart, constructor, ctor_smart) \ - {bif_type, zeek_type, c_type, c_type_smart, accessor, accessor_smart, cast_smart, constructor, ctor_smart}, + } builtin_func_arg_type[] = { +#define DEFINE_BIF_TYPE(id, bif_type, zeek_type, c_type, c_type_smart, accessor, accessor_smart, \ + cast_smart, constructor, ctor_smart) \ + {bif_type, zeek_type, c_type, c_type_smart, accessor, \ + accessor_smart, cast_smart, constructor, ctor_smart}, #include "bif_type.def" #undef DEFINE_BIF_TYPE -}; + }; extern const char* arg_list_name; @@ -52,17 +55,13 @@ BuiltinFuncArg::BuiltinFuncArg(const char* arg_name, const char* arg_type_str, void BuiltinFuncArg::PrintZeek(FILE* fp) { - fprintf(fp, "%s: %s%s %s", name, builtin_func_arg_type[type].zeek_type, - type_str, attr_str); + fprintf(fp, "%s: %s%s %s", name, builtin_func_arg_type[type].zeek_type, type_str, attr_str); } void BuiltinFuncArg::PrintCDef(FILE* fp, int n) { - fprintf(fp, - "\t%s %s = (%s) (", - builtin_func_arg_type[type].c_type, - name, - builtin_func_arg_type[type].c_type); + fprintf(fp, "\t%s %s = (%s) (", builtin_func_arg_type[type].c_type, name, + builtin_func_arg_type[type].c_type); char buf[1024]; snprintf(buf, sizeof(buf), "(*%s)[%d].get()", arg_list_name, n); diff --git a/tools/bifcl/include/bif_arg.h b/tools/bifcl/include/bif_arg.h index 254d766e23..4ca9de0d21 100644 --- a/tools/bifcl/include/bif_arg.h +++ b/tools/bifcl/include/bif_arg.h @@ -2,28 +2,27 @@ #include -enum builtin_func_arg_type { -#define DEFINE_BIF_TYPE(id, bif_type, bro_type, c_type, c_type_smart, accessor, accessor_smart, cast_smart, constructor, ctor_smart) \ +enum builtin_func_arg_type + { +#define DEFINE_BIF_TYPE(id, bif_type, bro_type, c_type, c_type_smart, accessor, accessor_smart, \ + cast_smart, constructor, ctor_smart) \ id, #include "bif_type.def" #undef DEFINE_BIF_TYPE -}; + }; extern const char* builtin_func_arg_type_bro_name[]; -class BuiltinFuncArg { +class BuiltinFuncArg + { public: BuiltinFuncArg(const char* arg_name, int arg_type); - BuiltinFuncArg(const char* arg_name, const char* arg_type_str, - const char* arg_attr_str = ""); + BuiltinFuncArg(const char* arg_name, const char* arg_type_str, const char* arg_attr_str = ""); - void SetAttrStr(const char* arg_attr_str) - { - attr_str = arg_attr_str; - }; + void SetAttrStr(const char* arg_attr_str) { attr_str = arg_attr_str; }; - const char* Name() const { return name; } - int Type() const { return type; } + const char* Name() const { return name; } + int Type() const { return type; } void PrintZeek(FILE* fp); void PrintCDef(FILE* fp, int n); @@ -35,4 +34,4 @@ protected: int type; const char* type_str; const char* attr_str; -}; + }; diff --git a/tools/bifcl/module_util.cc b/tools/bifcl/module_util.cc index d5817a7d7a..f2fd445eff 100644 --- a/tools/bifcl/module_util.cc +++ b/tools/bifcl/module_util.cc @@ -1,10 +1,11 @@ // // See the file "COPYING" in the main distribution directory for copyright. -#include -#include #include "module_util.h" +#include +#include + static int streq(const char* s1, const char* s2) { return ! strcmp(s1, s2); @@ -24,7 +25,7 @@ string extract_module_name(const char* name) return module_name; } -string extract_var_name(const char *name) +string extract_var_name(const char* name) { string var_name = name; string::size_type pos = var_name.rfind("::"); @@ -35,14 +36,13 @@ string extract_var_name(const char *name) if ( pos + 2 > var_name.size() ) return string(""); - return var_name.substr(pos+2); + return var_name.substr(pos + 2); } string normalized_module_name(const char* module_name) { int mod_len; - if ( (mod_len = strlen(module_name)) >= 2 && - streq(module_name + mod_len - 2, "::") ) + if ( (mod_len = strlen(module_name)) >= 2 && streq(module_name + mod_len - 2, "::") ) mod_len -= 2; return string(module_name, mod_len); @@ -50,8 +50,7 @@ string normalized_module_name(const char* module_name) string make_full_var_name(const char* module_name, const char* var_name) { - if ( ! module_name || streq(module_name, GLOBAL_MODULE_NAME) || - strstr(var_name, "::") ) + if ( ! module_name || streq(module_name, GLOBAL_MODULE_NAME) || strstr(var_name, "::") ) { if ( streq(GLOBAL_MODULE_NAME, extract_module_name(var_name).c_str()) ) return extract_var_name(var_name);