Commit 8844bf02 authored by Mathieu Valois's avatar Mathieu Valois
Browse files

warning when stdin for memory

parent 5dcf0191
Loading
Loading
Loading
Loading
+19 −1
Changes for Statsgen/include/statsgen.h: 19 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -181,10 +181,27 @@ public:

	/**
	 * @brief Where to write masks
	 * @param outfie: the file where to write masks
	 * @param outfile: the file where to write masks
	 */
	void setOutfile(std::string outfile);

	/**
	 * @brief enable debugging
	 */
	void enableDebug();

	/**
	 * @brief print the warning message
	 * @param message: the warning message
	 */
	void warn(const std::string & message);

	/**
	 * @brief print the debug message if debug enabled
	 * @param message: the debug message
	 * */
	void debug(const std::string & message);

	/**
	 * @brief Calculate all statistics for a database
	 * @return 0 if error, 1 if success
@@ -215,6 +232,7 @@ private:
	int nbThread = 1;				// Number of usable threads, default 1
	std::string outfile_name;		// File where to write masks
	bool is_stdin = false;				// If filename is stdin
	bool debug_enabled = false;		// Enable debug output


	// Dictionary
+13 −0
Changes for Statsgen/src/statsgen.cpp: 13 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ using namespace std;
void Statsgen::setFilename(std::string name) {
	if (name == "-"){
		is_stdin = true;
		warn("reading from stdin enabled, loading the whole list in memory");
	}
	else {
		filename = name;
@@ -83,6 +84,18 @@ void Statsgen::setOutfile(string outfile){
	outfile_name = outfile;
}

void Statsgen::enableDebug(){
	debug_enabled = true;
}

void Statsgen::warn(const string & message){
	cerr << "[Warning] " << message << endl;
}
void Statsgen::debug(const string & message){
	if (debug_enabled)
		cerr << "[Debug] " << message << endl;
}


void Statsgen::setSecurityRules() {
	wcout << "\nMinimal length of a password:" << endl;