/*
   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/>
 */
/**
 * @file src/include/auditor-database/iterate_progress_points.h
 * @brief implementation of the iterate_progress_points function for Postgres
 * @author Christian Grothoff
 */
#ifndef AUDITOR_DATABASE_ITERATE_PROGRESS_POINTS_H
#define AUDITOR_DATABASE_ITERATE_PROGRESS_POINTS_H

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


/**
 * Information about progress of the audit.
 */
struct TALER_AUDITORDB_Progress
{
  char *progress_key;
  uint64_t progress_offset;
};

#ifndef TALER_AUDITORDB_PROGRESS_POINTS_RESULT_CLOSURE
/**
 * Type of the closure for #TALER_AUDITORDB_ProgressPointsCallback.
 */
#define TALER_AUDITORDB_PROGRESS_POINTS_RESULT_CLOSURE void
#endif
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_ProgressPointsCallback)(
  TALER_AUDITORDB_PROGRESS_POINTS_RESULT_CLOSURE *cls,
  const struct TALER_AUDITORDB_Progress *pp);


/* Callback typedefs */
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_ProgressPointsCallback)(
  TALER_AUDITORDB_PROGRESS_POINTS_RESULT_CLOSURE *cls,
  const struct TALER_AUDITORDB_Progress *pp);

/**
 * Get information about progress from the database.
 *
 * @param pg the database context
 * @param progress_key only return this particular progress point
 * @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_progress_points (struct
                                         TALER_AUDITORDB_PostgresContext *pg,
                                         const char *progress_key,
                                         TALER_AUDITORDB_ProgressPointsCallback
                                         cb,
                                         TALER_AUDITORDB_PROGRESS_POINTS_RESULT_CLOSURE
                                         *cb_cls);


#endif
