Skip to content

Commit

Permalink
minor changes to include files; does not change API
Browse files Browse the repository at this point in the history
  • Loading branch information
simsong committed Nov 15, 2012
1 parent cacac61 commit 56d7a92
Show file tree
Hide file tree
Showing 8 changed files with 236 additions and 388 deletions.
22 changes: 15 additions & 7 deletions plugins/be13_api/bulk_extractor_i.h
Expand Up @@ -115,7 +115,7 @@ class scanner_info {
histograms_t histogram_defs; // v1: histogram definition info
};

#include <tr1/unordered_map>
#include <map>
class scanner_params {
public:
/** Construct a scanner_params from a sbuf and other sensible defaults.
Expand Down Expand Up @@ -213,7 +213,7 @@ class recursion_control_block {
bool returnAfterFound; /* only run once */
};

/* plugin.cpp */
/* plugin.cpp. This will become a class... */
class scanner_def {
public:;
static uint32_t max_depth;
Expand All @@ -223,15 +223,23 @@ public:;
scanner_info info;
string pathPrefix; /* path prefix for recursive scanners */
};
void load_scanner(const scanner_t &scanner,histograms_t &histograms);
void load_scanners(const scanner_t *scanners[],histograms_t &histograms); // load the scan_ plugins
void load_scanner_directory(const string &dirname,histograms_t &histograms); // load the scan_ plugins
void disable_all_scanners();
void load_scanner(const scanner_t &scanner);
void load_scanners(const scanner_t *scanners[]); // load the scan_ plugins
void load_scanner_directory(const string &dirname); // load the scan_ plugins
typedef vector<scanner_def *> scanner_vector;
extern scanner_vector current_scanners; // current scanners
extern histograms_t histograms;
void enable_feature_recorders(feature_file_names_t &feature_file_names);
void info_scanners(bool detailed,const scanner_t *scanners_builtin[]); // print info about the scanners
void scanners_enable(const std::string &name); // saves a command to enable this scanner
void scanners_enable_all(); // enable all of them
void scanners_disable(const std::string &name); // saves a command to disable this scanner
void scanners_disable_all(); // saves a command to disable all
void scanners_process_commands(); // process the saved commands

/* plugin.cpp */
void phase_shutdown(feature_recorder_set &fs, xml &xreport);
void phase_histogram(feature_recorder_set &fs, xml &xreport);
void process_sbuf(const class scanner_params &sp); /* process for feature extraction */

inline std::string itos(int i){ std::stringstream ss; ss << i;return ss.str();}
inline std::string dtos(double d){ std::stringstream ss; ss << d;return ss.str();}
Expand Down
5 changes: 3 additions & 2 deletions plugins/be13_api/feature_recorder.h
Expand Up @@ -41,7 +41,6 @@ using namespace std;
#include <stdarg.h>
#include <fstream>
#include <set>
#include <map>

#include "md5.h"
#include "regex.h"
Expand Down Expand Up @@ -101,6 +100,8 @@ class feature_recorder {
static const string bulk_extractor_version_header;
static const uint8_t UTF8_BOM[3]; // UTF-8 byte order mark
static const string BOM_EXPLAINATION; // what is this BOM thing? Put at the top of each file
static uint32_t opt_max_context_size;
static uint32_t opt_max_feature_size;
static size_t context_window; // global option
static int64_t offset_add; // added to every reported offset, for use with hadoop
static string banner_file; // banner for top of every file
Expand Down Expand Up @@ -166,7 +167,7 @@ class feature_recorder {
* Carving writes the filename to the feature file; the context is the file's MD5
* Automatically de-duplicates.
*/
set<md5_t> carved_set; /* set of MD5 hash codes of objects we've carved; */
std::set<md5_t> carved_set; /* set of MD5 hash codes of objects we've carved; */
int64_t file_number; /* starts at 0; gets incremented by carve() */
string file_extension; /* includes "."; must be set by caller */
virtual void carve(const sbuf_t &sbuf,size_t pos,size_t len);
Expand Down
30 changes: 14 additions & 16 deletions plugins/be13_api/feature_recorder_set.h
Expand Up @@ -12,11 +12,11 @@
* This used to be done with a set, but now it's done with a map.
*
*/
#include <tr1/unordered_map>
#include <map>
#include <set>

//typedef tr1::unordered_map<string,class feature_recorder *> feature_recorder_map;
typedef map<string,class feature_recorder *> feature_recorder_map;
typedef set<string>feature_file_names_t;
typedef std::map<string,class feature_recorder *> feature_recorder_map;
typedef std::set<string>feature_file_names_t;
class feature_recorder_set {
private:
/*** neither copying nor assignment is implemented ***
Expand All @@ -27,13 +27,14 @@ class feature_recorder_set {
}
};
feature_recorder_set(const feature_recorder_set &fs):
flags(0),outdir(),frm(),Mstats(),scanner_stats(){ throw new not_impl(); }
flags(0),input_fname(),outdir(),frm(),Mstats(),scanner_stats(){ throw new not_impl(); }
const feature_recorder_set &operator=(const feature_recorder_set &fs){ throw new not_impl(); }
uint32_t flags;
public:
// instance data //
static feature_recorder *alert_recorder;
string outdir; // where output goes
std::string input_fname; // input file
std::string outdir; // where output goes
feature_recorder_map frm; // map of feature recorders
cppmutex Mstats;
class pstats {
Expand All @@ -44,21 +45,18 @@ class feature_recorder_set {
typedef map<string,class pstats> scanner_stats_map;
scanner_stats_map scanner_stats;

static const string ALERT_RECORDER; // the name of the alert recorder
static const string ALERT_RECORDER_NAME; // the name of the alert recorder
static const uint32_t DISABLED=0x02; // the set is effectively disabled
static const uint32_t ONLY_ALERT=0x01; // always return the alert recorder

/** Create a properly functioning feature recorder set. */
feature_recorder_set(const feature_file_names_t &feature_files,const std::string &outdir);
feature_recorder_set(const feature_file_names_t &feature_files,
const std::string &input_fname,
const std::string &outdir,
bool create_stop_files);

/** create a dummy feature_recorder_set with no output directory */
feature_recorder_set(uint32_t flags_):flags(flags_),outdir(),frm(),Mstats(),scanner_stats(){
//if(flags & DISABLED){
//create_name(ALERT_RECORDER); // create a bogus alert recorder
//this->flags |=ONLY_ALERT; // only return this one
//get_name(ALERT_RECORDER)->set_flag(feature_recorder::FLAG_DISABLED);
//}
}
feature_recorder_set(uint32_t flags_):flags(flags_),input_fname(),outdir(),frm(),Mstats(),scanner_stats(){ }
virtual ~feature_recorder_set() {
for(feature_recorder_map::iterator i = frm.begin();i!=frm.end();i++){
delete i->second;
Expand All @@ -69,7 +67,7 @@ class feature_recorder_set {
void close_all();
bool has_name(string name) const; /* does the named feature exist? */
void set_flag(uint32_t f){flags|=f;}
void create_name(string name);
void create_name(string name,bool create_stop_also);
void clear_flag(uint32_t f){flags|=f;}
void add_stats(string bucket,double seconds);
void dump_stats(class xml &xml);
Expand Down

0 comments on commit 56d7a92

Please sign in to comment.