FOSSology  4.4.0
Open Source License Compliance by Open Source Software
utils.hpp
1 /*
2  SPDX-FileCopyrightText: © 2014-2015 Siemens AG
3 
4  SPDX-License-Identifier: GPL-2.0-only
5 */
6 
7 #ifndef NINKA_AGENT_UTILS_HPP
8 #define NINKA_AGENT_UTILS_HPP
9 
10 #define AGENT_NAME "ninka"
11 #define AGENT_DESC "ninka agent"
12 #define AGENT_ARS "ninka_ars"
13 
14 #include <string>
15 #include <vector>
16 #include "files.hpp"
17 #include "licensematch.hpp"
18 #include "state.hpp"
19 
20 extern "C" {
21 #include "libfossology.h"
22 }
23 
24 using namespace std;
25 
28 int writeARS(const State& state, int arsId, int uploadId, int success, fo::DbManager& dbManager);
29 void bail(int exitval);
30 bool processUploadId(const State& state, int uploadId, NinkaDatabaseHandler& databaseHandler);
31 bool matchPFileWithLicenses(const State& state, unsigned long pFileId, NinkaDatabaseHandler& databaseHandler);
32 bool matchFileWithLicenses(const State& state, const fo::File& file, NinkaDatabaseHandler& databaseHandler);
33 bool saveLicenseMatchesToDatabase(const State& state, const vector<LicenseMatch>& matches, unsigned long pFileId, NinkaDatabaseHandler& databaseHandler);
34 
35 #endif // NINKA_AGENT_UTILS_HPP
Definition: state.hpp:16
DB wrapper for agents.
Class to handle file related operations.
Definition: files.hpp:26
void matchPFileWithLicenses(CopyrightState const &state, int agentId, unsigned long pFileId, CopyrightDatabaseHandler &databaseHandler)
Get the file contents, scan for statements and save findings to database.
int queryAgentId(PGconn *dbConn)
Get agent id, exit if agent id is incorrect.
void matchFileWithLicenses(const string &sContent, unsigned long pFileId, CopyrightState const &state, int agentId, CopyrightDatabaseHandler &databaseHandler)
Scan a given file with all available scanners and save findings to database.
int writeARS(int agentId, int arsId, int uploadId, int success, const fo::DbManager &dbManager)
Call C function fo_WriteARS() and translate the arguments.
CopyrightState getState(CliOptions &&cliOptions)
Create a new state for the current agent based on CliOptions.
bool processUploadId(const CopyrightState &state, int agentId, int uploadId, CopyrightDatabaseHandler &databaseHandler, bool ignoreFilesWithMimeType)
Process a given upload id, scan from statements and add to database.
void bail(int exitval)
Disconnect with scheduler returning an error code and exit.
Utility functions for file handling.
The main FOSSology C library.
fo_dbManager * dbManager
fo_dbManager object
Definition: process.c:16