50 #define return_sched(retval) \
52 fo_scheduler_disconnect((retval));\
56 int main(
int argc,
char **argv)
59 vector<string> fileNames;
60 string directoryToScan;
61 if (!
parseCliOptions(argc, argv, cliOptions, fileNames, directoryToScan))
70 if (!fileNames.empty())
72 const unsigned long fileNamesCount = fileNames.size();
73 bool fileError =
false;
74 bool printComma =
false;
82 #pragma omp parallel shared(printComma)
85 for (
unsigned int argn = 0; argn < fileNamesCount; ++argn)
87 const string fileName = fileNames[argn];
92 l = agentObj.processFile(fileName);
94 catch (std::runtime_error &e)
96 cerr <<
"Unable to read " << e.what();
100 pair<string, vector<ojomatch>> scanResult(fileName, l);
113 cout << endl <<
"]" << endl;
115 return fileError ? 1 : 0;
117 else if (directoryToScan.length() > 0)
140 if (!
processUploadId(state, uploadId, databaseHandler, ignoreFilesWithMimeType))
bool processUploadId(const CompatibilityState &state, int uploadId, CompatibilityDatabaseHandler &databaseHandler, int groupId)
bool parseCliOptions(int argc, char **argv, CompatibilityCliOptions &dest, std::string &types, std::string &rules, string &jFile, string &mainLicense)
Parse the options sent by CLI to CliOptions object.
void printResultToStdout(const std::vector< tuple< string, string, bool >> &resultPair, const std::string &fileName)
CompatibilityState getState(DbManager &dbManager, CompatibilityCliOptions &&cliOptions)
Create a new state for the current agent based on CliOptions.
int writeARS(const CompatibilityState &state, int arsId, int uploadId, int success, DbManager &dbManager)
int queryAgentId(DbManager &dbManager)
void appendToJson(const std::vector< tuple< string, string, bool >> &resultPair, const std::string &fileName, bool &printComma)
Store the options sent through the CLI.
bool doJsonOutput() const
Check if JSON output is required.
bool doignoreFilesWithMimeType() const
Check ignore files with particular mimetype is required.
Store the state of the agent.
const OjoAgent & getOjoAgent() const
void setAgentId(const int agentId)
void fo_scheduler_disconnect(int retcode)
Disconnect the scheduler connection.
void fo_scheduler_heart(int i)
This function must be called by agents to let the scheduler know they are alive and how many items th...
char * fo_scheduler_current()
Get the last read string from the scheduler.
char * fo_scheduler_next()
Get the next data to process from the scheduler.
fo_dbManager * dbManager
fo_dbManager object
fo namespace holds the FOSSology library functions.
void scanDirectory(const bool json, const string &directoryPath)
#define return_sched(retval)