FOSSology  4.5.1
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
bool processUploadId(const CompatibilityState &state, int uploadId, CompatibilityDatabaseHandler &databaseHandler, int groupId)
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 bail(int exitval)
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.
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.
Utility functions for file handling.
The main FOSSology C library.
fo_dbManager * dbManager
fo_dbManager object
Definition: process.c:16