std::size_t errors = data_api.num_errors() + rule_api.num_errors();
std::cerr << "ERROR: " << errors << " errors occurred while converting\n";
std::cerr << "ERROR: see " << error_file << " for details" << std::endl;
- }
+ std::ofstream rejects; // in this case, rejects are regular configuration options
+ rejects.open(error_file, std::ifstream::out);
- return rc;
-}
+ if (data_api.failed_conversions())
+ data_api.print_errors(rejects);
+ if (rule_api.failed_conversions())
+ rule_api.print_rejects(rejects);
+
+ rejects.close();
+ }
+ return rc;
+}
\ No newline at end of file
return (stat (name.c_str(), &buffer) == 0);
}
+bool is_regular_file(std::string& path)
+{
+ struct stat s;
+
+ if (stat(path.c_str(), &s) == 0)
+ return (s.st_mode & S_IFREG);
+
+ return false;
+}
+
bool case_compare(std::string arg1, std::string arg2)
{
std::transform(arg1.begin(), arg1.end(), arg1.begin(), ::tolower);
return false;
}
} // namespace util
-
#include <sstream>
#include <vector>
-
#include "conversion_state.h"
#include "helpers/converter.h"
#include "helpers/s2l_util.h"
#include "helpers/parse_cmd_line.h"
#include "data/data_types/dt_comment.h"
+#include "keywords_api.h"
namespace keywords
{
std::string full_file = data_api.expand_vars(file);
std::string tmp = full_file; // for the error message
+ //check if the file exists using what was provided
+ //if not use the conf_dir with the file
if (!util::file_exists(full_file))
full_file = parser::get_conf_dir() + full_file;
- // if we still can't find this file, add it as a snort file
- if (util::file_exists(full_file))
- return !(cv.parse_include_file(full_file));
-
- std::string error_string = "Can't find file " + file + ". "
- " Searched locations: " + tmp + ", " + full_file;
+ // make sure its a regular file (not a directory)
+ if (util::is_regular_file(full_file))
+ {
+ return !cv.parse_include_file(full_file);
+ }
+ else
+ { //cant find it .. log error
+ std::string error_string = "Can't find file " + file + ". "
+ " Searched locations: [" + tmp + "], [" + full_file + "]";
- data_api.failed_conversion(data_stream, error_string);
+ data_api.failed_conversion(data_stream, error_string);
+ }
}
}
else
"'filename' argument");
}
- rule_api.include_rule_file(file);
return false;
}
const ConvertMap* include_map = &keyword_include;
} // namespace keywords
-