FOSSology
4.4.0
Open Source License Compliance by Open Source Software
|
Go to the source code of this file.
Functions | |
OjoState | getState (DbManager &dbManager, OjoCliOptions &&cliOptions) |
Create a new state for the current agent based on CliOptions. More... | |
OjoState | getState (OjoCliOptions &&cliOptions) |
Create a new state for the agent without DB manager. More... | |
int | queryAgentId (DbManager &dbManager) |
int | writeARS (const OjoState &state, int arsId, int uploadId, int success, DbManager &dbManager) |
void | bail (int exitval) |
Disconnect with scheduler returning an error code and exit. More... | |
bool | processUploadId (const OjoState &state, int uploadId, OjosDatabaseHandler &databaseHandler, bool ignoreFilesWithMimeType) |
bool | storeResultInDb (const vector< ojomatch > &matches, OjosDatabaseHandler &databaseHandle, const int agent_fk, const int pfile_fk) |
Store the results from scan to DB. More... | |
bool | parseCliOptions (int argc, char **argv, OjoCliOptions &dest, std::vector< std::string > &fileNames, string &directoryToScan) |
Parse the options sent by CLI to CliOptions object. More... | |
void | appendToJson (const std::string fileName, const std::pair< string, vector< ojomatch >> resultPair, bool &printComma) |
void | printResultToStdout (const std::string fileName, const std::pair< string, vector< ojomatch >> resultPair) |
The utility functions for OJO agent
Definition in file OjoUtils.cc.
void appendToJson | ( | const std::string | fileName, |
const std::pair< string, vector< ojomatch >> | resultPair, | ||
bool & | printComma | ||
) |
Append a new result from scanner to STDOUT
fileName | File which was scanned |
resultPair | The result pair from scanSingleFile() |
printComma | Set true to print comma. Will be set true after first data is printed |
Definition at line 355 of file OjoUtils.cc.
void bail | ( | int | exitval | ) |
Disconnect with scheduler returning an error code and exit.
Disconnect scheduler and exit in case of failure.
exitval | Exit code to be sent to scheduler and returned by program |
Definition at line 88 of file OjoUtils.cc.
OjoState getState | ( | DbManager & | dbManager, |
OjoCliOptions && | cliOptions | ||
) |
Create a new state for the current agent based on CliOptions.
Called during instantiation of agent.
cliOptions | CLI options passed to the agent |
Definition at line 25 of file OjoUtils.cc.
OjoState getState | ( | OjoCliOptions && | cliOptions | ) |
Create a new state for the agent without DB manager.
cliOptions | CLI options passed |
Definition at line 36 of file OjoUtils.cc.
bool parseCliOptions | ( | int | argc, |
char ** | argv, | ||
OjoCliOptions & | dest, | ||
std::vector< std::string > & | fileNames, | ||
string & | directoryToScan | ||
) |
Parse the options sent by CLI to CliOptions object.
[in] | argc | |
[in] | argv | |
[out] | dest | The parsed OjoCliOptions object |
[out] | fileNames | List of files to be scanned |
[out] | directoryToScan | Path of the directory to be scanned |
Definition at line 228 of file OjoUtils.cc.
void printResultToStdout | ( | const std::string | fileName, |
const std::pair< string, vector< ojomatch >> | resultPair | ||
) |
Print the result of current scan to stdout
fileName | File which was scanned |
resultPair | Result pair from scanSingleFile() |
Definition at line 421 of file OjoUtils.cc.
bool processUploadId | ( | const OjoState & | state, |
int | uploadId, | ||
OjosDatabaseHandler & | databaseHandler, | ||
bool | ignoreFilesWithMimeType | ||
) |
Process a given upload id
state | State of the agent |
uploadId | Upload ID to be scanned |
databaseHandler | Database handler to be used |
ignoreFilesWithMimeType | To ignore files with particular mimetype |
Definition at line 102 of file OjoUtils.cc.
int queryAgentId | ( | DbManager & | dbManager | ) |
Query the agent ID from the DB.
dbManager | DbManager to be used |
Definition at line 46 of file OjoUtils.cc.
bool storeResultInDb | ( | const vector< ojomatch > & | matches, |
OjosDatabaseHandler & | databaseHandle, | ||
const int | agent_fk, | ||
const int | pfile_fk | ||
) |
Store the results from scan to DB.
Store the license finding (if found) and highlight to the database.
Store not found entries for empty matches to the database.
matches | List of matches. |
databaseHandle | Database handler to be used |
agent_fk | Current agent id |
pfile_fk | Current pfile id |
Definition at line 181 of file OjoUtils.cc.
int writeARS | ( | const OjoState & | state, |
int | arsId, | ||
int | uploadId, | ||
int | success, | ||
DbManager & | dbManager | ||
) |
Write ARS to the agent's ars table
state | State of the agent |
arsId | ARS id (0 for new entry) |
uploadId | Upload ID |
success | Success status |
dbManager | DbManager to use |
Definition at line 74 of file OjoUtils.cc.