mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 17:48:21 +00:00
Giving analyzer/ its own CMakeLists.txt.
Also moving src/analyzer.bif to src/analyzer/analyzer.bif, along with the infrastructure to build/incude bif code at other locations. We should generally move to having per-directory CMakeLists.txt. I'll convert the others over later.
This commit is contained in:
parent
bccaea6883
commit
897be0e147
10 changed files with 83 additions and 40 deletions
|
@ -139,6 +139,7 @@ extern int yyparse();
|
|||
char* input_filename = 0;
|
||||
char* input_filename_with_path = 0;
|
||||
char* plugin = 0;
|
||||
int alternative_mode = 0;
|
||||
|
||||
FILE* fp_bro_init = 0;
|
||||
FILE* fp_func_def = 0;
|
||||
|
@ -176,7 +177,7 @@ void usage()
|
|||
exit(1);
|
||||
}
|
||||
|
||||
void init_plugin_mode()
|
||||
void init_alternative_mode()
|
||||
{
|
||||
fp_bro_init = open_output_file("bro");
|
||||
fp_func_h = open_output_file("h");
|
||||
|
@ -191,8 +192,8 @@ void init_plugin_mode()
|
|||
char auto_gen_comment[n];
|
||||
|
||||
snprintf(auto_gen_comment, n,
|
||||
"This file was automatically generated by bifcl from %s (plugin mode).",
|
||||
input_filename_with_path);
|
||||
"This file was automatically generated by bifcl from %s (%s mode).",
|
||||
input_filename_with_path, plugin ? "plugin" : "subdir");
|
||||
|
||||
fprintf(fp_bro_init, "# %s\n\n", auto_gen_comment);
|
||||
fprintf(fp_func_def, "// %s\n\n", auto_gen_comment);
|
||||
|
@ -225,42 +226,53 @@ void init_plugin_mode()
|
|||
if ( dot )
|
||||
*dot = '\0';
|
||||
|
||||
fprintf(fp_func_init, "\n");
|
||||
fprintf(fp_func_init, "#include <list>\n");
|
||||
fprintf(fp_func_init, "#include <string>\n");
|
||||
fprintf(fp_func_init, "#include \"%s.h\"\n", input_filename);
|
||||
fprintf(fp_func_init, "\n");
|
||||
fprintf(fp_func_init, "namespace plugin { namespace %s {\n", plugin);
|
||||
fprintf(fp_func_init, "\n");
|
||||
fprintf(fp_func_init, "std::list<std::pair<std::string, int> > __bif_%s_init()\n", name);
|
||||
fprintf(fp_func_init, "\t{\n");
|
||||
fprintf(fp_func_init, "\tstd::list<std::pair<std::string, int> > bifs;\n");
|
||||
fprintf(fp_func_init, "\n");
|
||||
if ( plugin )
|
||||
{
|
||||
fprintf(fp_func_init, "\n");
|
||||
fprintf(fp_func_init, "#include <list>\n");
|
||||
fprintf(fp_func_init, "#include <string>\n");
|
||||
fprintf(fp_func_init, "#include \"%s.h\"\n", input_filename);
|
||||
fprintf(fp_func_init, "\n");
|
||||
fprintf(fp_func_init, "namespace plugin { namespace %s {\n", plugin);
|
||||
fprintf(fp_func_init, "\n");
|
||||
fprintf(fp_func_init, "std::list<std::pair<std::string, int> > __bif_%s_init()\n", name);
|
||||
fprintf(fp_func_init, "\t{\n");
|
||||
fprintf(fp_func_init, "\tstd::list<std::pair<std::string, int> > bifs;\n");
|
||||
fprintf(fp_func_init, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
void finish_plugin_mode()
|
||||
void finish_alternative_mode()
|
||||
{
|
||||
fprintf(fp_func_h, "\n");
|
||||
fprintf(fp_func_h, "#endif\n");
|
||||
|
||||
fprintf(fp_func_init, "\n");
|
||||
fprintf(fp_func_init, "\treturn bifs;\n");
|
||||
fprintf(fp_func_init, "\t}\n");
|
||||
fprintf(fp_func_init, "} }\n");
|
||||
fprintf(fp_func_init, "\n");
|
||||
}
|
||||
if ( plugin )
|
||||
{
|
||||
fprintf(fp_func_init, "\n");
|
||||
fprintf(fp_func_init, "\treturn bifs;\n");
|
||||
fprintf(fp_func_init, "\t}\n");
|
||||
fprintf(fp_func_init, "} }\n");
|
||||
fprintf(fp_func_init, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
char opt;
|
||||
|
||||
while ( (opt = getopt(argc, argv, "p:")) != -1 )
|
||||
while ( (opt = getopt(argc, argv, "p:s")) != -1 )
|
||||
{
|
||||
switch ( opt ) {
|
||||
case 'p':
|
||||
alternative_mode = 1;
|
||||
plugin = optarg;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
alternative_mode = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
|
@ -284,7 +296,7 @@ int main(int argc, char* argv[])
|
|||
if ( slash )
|
||||
input_filename = slash + 1;
|
||||
|
||||
if ( ! plugin )
|
||||
if ( ! alternative_mode )
|
||||
{
|
||||
fp_bro_init = open_output_file("bro");
|
||||
fp_func_h = open_output_file("func_h");
|
||||
|
@ -311,13 +323,13 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
|
||||
else
|
||||
init_plugin_mode();
|
||||
init_alternative_mode();
|
||||
|
||||
yy_switch_to_buffer(yy_create_buffer(fp_input, YY_BUF_SIZE));
|
||||
yyparse();
|
||||
|
||||
if ( plugin )
|
||||
finish_plugin_mode();
|
||||
if ( alternative_mode )
|
||||
finish_alternative_mode();
|
||||
|
||||
fclose(fp_input);
|
||||
close_all_output_files();
|
||||
|
@ -339,7 +351,7 @@ void close_all_output_files(void)
|
|||
close_if_open(&fp_func_def);
|
||||
close_if_open(&fp_func_init);
|
||||
|
||||
if ( ! plugin )
|
||||
if ( ! alternative_mode )
|
||||
{
|
||||
close_if_open(&fp_netvar_h);
|
||||
close_if_open(&fp_netvar_def);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue