/*
   This file is part of TALER
   Copyright (C) 2024 Taler Systems SA

   TALER is free software; you can redistribute it and/or modify it under the
   terms of the GNU General Public License as published by the Free Software
   Foundation; either version 3, or (at your option) any later version.

   TALER is distributed in the hope that it will be useful, but WITHOUT ANY
   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
   A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

   You should have received a copy of the GNU General Public License along with
   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
 */

#ifndef AUDITOR_DATABASE_ITERATE_PURSE_NOT_CLOSED_INCONSISTENCIES_H
#define AUDITOR_DATABASE_ITERATE_PURSE_NOT_CLOSED_INCONSISTENCIES_H

#include "taler/taler_util.h"
#include "auditordb_lib.h"


/**
 * Function called with purse not closed inconsistencies stored in
 * the auditor's database.
 *
 * @param cls closure
 * @param dc the structure itself
 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
 */
#ifndef TALER_AUDITORDB_PURSE_NOT_CLOSED_INCONSISTENCIES_RESULT_CLOSURE
/**
 * Type of the closure for #TALER_AUDITORDB_PurseNotClosedInconsistenciesCallback.
 */
#define TALER_AUDITORDB_PURSE_NOT_CLOSED_INCONSISTENCIES_RESULT_CLOSURE void
#endif
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_PurseNotClosedInconsistenciesCallback)(
  TALER_AUDITORDB_PURSE_NOT_CLOSED_INCONSISTENCIES_RESULT_CLOSURE *cls,
  const struct TALER_AUDITORDB_PurseNotClosedInconsistencies *dc);


/* Callback typedefs */
/**
 * Function called with purse not closed inconsistencies stored in
 * the auditor's database.
 *
 * @param cls closure
 * @param dc the structure itself
 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
 */
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_PurseNotClosedInconsistenciesCallback)(
  TALER_AUDITORDB_PURSE_NOT_CLOSED_INCONSISTENCIES_RESULT_CLOSURE *cls,
  const struct TALER_AUDITORDB_PurseNotClosedInconsistencies *dc);

/**
 * Get information about purse not closed inconsistencies from the database.
 *
 * @param pg the database context
 * @param limit number of records to return, negative for descending
 * @param offset table row to start from, exclusive, direction determined by @a limit
 * @param return_suppressed should suppressed rows be returned anyway?
 * @param cb function to call with results
 * @param cb_cls closure for @a cb
 * @return query result status
 */
enum GNUNET_DB_QueryStatus
TALER_AUDITORDB_iterate_purse_not_closed_inconsistencies (struct
                                                          TALER_AUDITORDB_PostgresContext
                                                          *pg,
                                                          int64_t limit,
                                                          uint64_t offset,
                                                          bool return_suppressed
                                                          ,
                                                          TALER_AUDITORDB_PurseNotClosedInconsistenciesCallback
                                                          cb,
                                                          TALER_AUDITORDB_PURSE_NOT_CLOSED_INCONSISTENCIES_RESULT_CLOSURE
                                                          *cb_cls);

#endif
