FOSSology  4.4.0
Open Source License Compliance by Open Source Software
ninka.cc
1 /*
2  SPDX-FileCopyrightText: © 2014-2015 Siemens AG
3 
4  SPDX-License-Identifier: GPL-2.0-only
5 */
6 
7 #include "ninka.hpp"
8 
9 using namespace fo;
10 
11 int main(int argc, char** argv)
12 {
13  /* before parsing argv and argc make sure */
14  /* to initialize the scheduler connection */
15 
16  DbManager dbManager(&argc, argv);
17  NinkaDatabaseHandler databaseHandler(dbManager);
18 
19  State state = getState(dbManager);
20 
21  while (fo_scheduler_next() != NULL)
22  {
23  int uploadId = atoi(fo_scheduler_current());
24 
25  if (uploadId == 0) continue;
26 
27  int arsId = writeARS(state, 0, uploadId, 0, dbManager);
28 
29  if (arsId <= 0)
30  bail(5);
31 
32  if (!processUploadId(state, uploadId, databaseHandler))
33  bail(2);
34 
36  writeARS(state, arsId, uploadId, 1, dbManager);
37  }
39 
40  /* do not use bail, as it would prevent the destructors from running */
42  return 0;
43 }
Definition: state.hpp:16
DB wrapper for agents.
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.
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
Definition: process.c:16
fo namespace holds the FOSSology library functions.