Commit 2c190c27 authored by Jorand Jean-baptiste's avatar Jorand Jean-baptiste
Browse files

Attribut filename

parent ec835eb5
Loading
Loading
Loading
Loading
+12 −4
Changes for AdaptationParallel/include/statsgen.h: 12 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -102,6 +102,13 @@ public:
	 */
	void showHelp();

	/**
	 * @brief Initialise the name of the database
	 * @param : new value for "filename"
	 */
	void setFilename(std::string);


	/**
	 * @brief Modify the attribute "hiderare", defining if 
	 * user wants to see statistics below 1%
@@ -159,12 +166,10 @@ public:


	/**
	 * @brief Calculate all statistics for a database which the
	 * name is given by argument
	 * @param : database's name
	 * @brief Calculate all statistics for a database
	 * @return 0 if error, 1 if success
	 */
	int generate_stats(const std::string &);
	int generate_stats();
	
	/**
	 * @brief Print all calculated statistics
@@ -174,6 +179,9 @@ public:
	

private:
	std::string filename;


	// Filters

	int hiderare = 0; 				// Hide low statistics
+2 −2
Changes for AdaptationParallel/src/main.cpp: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -105,8 +105,8 @@ int main(int argc,char* argv[]) {
	}



	if (test.generate_stats(filename)) {
	test.setFilename(filename);
	if (test.generate_stats()) {
		test.print_stats();
	}

+12 −4
Changes for AdaptationParallel/src/statsgen.cpp: 12 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -25,6 +25,9 @@ using namespace std;
void Statsgen::showHelp() {
    wcout << "\nUsage: database.txt [options]\n" << endl;

    wcout << "To be sure the database's format can be read, please use this command before:" << endl;
    wcout << "\ticonv -f ISO-8859-1 -t UTF-8 databaseInput.txt -o databaseOutput.txt\n" << endl;

    wcout << "Options:" << endl;
    wcout << "\t--help, -h\t\t:\tShow this help message" << endl;
    wcout << "\t--withcount, -w\t\t:\tMendatory if the input database has the following format : [number of occurence] [password]\n" << endl;
@@ -44,6 +47,12 @@ void Statsgen::showHelp() {
}



void Statsgen::setFilename(std::string name) {
    filename = name;
}


void Statsgen::setHiderare(int val) {
    hiderare = val;
}
@@ -108,7 +117,8 @@ void Statsgen::setSecurityRules() {
}


int Statsgen::generate_stats(const string & filename) {

int Statsgen::generate_stats() {
    int nbline = nbline_file(filename);

    int rc;
@@ -217,8 +227,6 @@ int Statsgen::generate_stats(const string & filename) {
}




void Statsgen::print_stats() {
    int count;
    float perc = (float) 100 * (total_filter / total_counter);
@@ -235,7 +243,7 @@ void Statsgen::print_stats() {
    wcout << "\tMinimum of upper characters in a password: " << minUpper << endl;

    float perce = (float) 100 * (nbSecurePassword / total_counter);
    wcout << "\n\t\t-->" << nbSecurePassword << " passwords\t(" << perce << " %) repect the security rules\n" << endl;
    wcout << "\n\t\t--> " << nbSecurePassword << " passwords\t(" << perce << " %) respect the security rules\n" << endl;


    wcout << "\nmin - max\n" << endl;