44 #include "copyright.hpp"
49 #define return_sched(retval) \
51 fo_scheduler_disconnect((retval));\
55 int main(
int argc,
char** argv)
61 vector<string> fileNames;
62 string directoryToScan;
63 if (!
parseCliOptions(argc, argv, cliOptions, fileNames, directoryToScan))
71 if (!fileNames.empty())
73 const unsigned long fileNamesCount = fileNames.size();
74 bool fileError =
false;
75 bool printComma =
false;
83 #pragma omp parallel num_threads(THREADS)
86 for (
unsigned int argn = 0; argn < fileNamesCount; ++argn)
88 const string fileName = fileNames[argn];
98 if (scanResult.first.empty())
106 cout << endl <<
"]" << endl;
108 return fileError ? 1 : 0;
110 else if (directoryToScan.length() > 0)
122 if (!copyrightDatabaseHandler.createTables())
124 std::cout <<
"FATAL: initialization failed" << std::endl;
132 if (uploadId <= 0)
continue;
139 if (!
processUploadId(state, agentId, uploadId, copyrightDatabaseHandler, 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 to ignore files with particular mimetype.
Manages database related requests for agent.
Holds information about state of one agent.
#define return_sched(retval)
pair< string, list< match > > processSingleFile(const CopyrightState &state, const string fileName)
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)