FOSSology  4.7.1
Open Source License Compliance by Open Source Software
reuser.cc
Go to the documentation of this file.
1 /*
2  SPDX-License-Identifier: GPL-2.0-only
3  Author: Dietmar Helmut Leher <helmut.leher.ext@vaillant-group.com>
4  SPDX-FileCopyrightText: © 2026 Vaillant GmbH
5 */
31 #include "ReuserUtils.hpp"
32 
33 int main(int argc, char** argv)
34 {
35  fo::DbManager dbManager(&argc, argv);
36  ReuserDatabaseHandler databaseHandler(dbManager);
37 
39 
40  while (fo_scheduler_next() != nullptr)
41  {
42  int uploadId = atoi(fo_scheduler_current());
43  if (uploadId == 0) continue;
44 
45  int arsId = writeARS(state, 0, uploadId, 0, dbManager);
46  if (arsId <= 0)
47  {
48  LOG_ERROR("Reuser: failed to write ARS start record for upload %d, skipping.",
49  uploadId);
50  continue;
51  }
52 
53  if (!processUploadId(state, uploadId, databaseHandler))
54  {
55  writeARS(state, arsId, uploadId, 0, dbManager);
56  bail(2);
57  }
58 
60  writeARS(state, arsId, uploadId, 1, dbManager);
61  }
62 
65  return 0;
66 }
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)
void bail(int exitval)
Disconnect scheduler and exit.
Database handler for the reuser agent.
Holds the runtime state of the reuser agent (agent id).
Definition: ReuserState.hpp:15
DB wrapper for agents.
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