LCOV - code coverage report
Current view: top level - exchangedb - pg_iterate_kyc_reference.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 20 0
Test Date: 2025-12-28 14:06:02 Functions: 0.0 % 2 0

            Line data    Source code
       1              : /*
       2              :    This file is part of TALER
       3              :    Copyright (C) 2022 Taler Systems SA
       4              : 
       5              :    TALER is free software; you can redistribute it and/or modify it under the
       6              :    terms of the GNU General Public License as published by the Free Software
       7              :    Foundation; either version 3, or (at your option) any later version.
       8              : 
       9              :    TALER is distributed in the hope that it will be useful, but WITHOUT ANY
      10              :    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
      11              :    A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
      12              : 
      13              :    You should have received a copy of the GNU General Public License along with
      14              :    TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
      15              :  */
      16              : /**
      17              :  * @file pg_iterate_kyc_reference.c
      18              :  * @brief Low-level (statement-level) Postgres database access for the exchange
      19              :  * @author Christian Grothoff
      20              :  */
      21              : #include "taler/platform.h"
      22              : #include "taler/taler_error_codes.h"
      23              : #include "taler/taler_dbevents.h"
      24              : #include "taler/taler_pq_lib.h"
      25              : #include "pg_iterate_kyc_reference.h"
      26              : #include "pg_helper.h"
      27              : 
      28              : 
      29              : /**
      30              :  * Closure for #iterate_kyc_reference_cb()
      31              :  */
      32              : struct IteratorContext
      33              : {
      34              :   /**
      35              :    * Function to call with the results.
      36              :    */
      37              :   TALER_EXCHANGEDB_LegitimizationProcessCallback cb;
      38              : 
      39              :   /**
      40              :    * Closure to pass to @e cb
      41              :    */
      42              :   void *cb_cls;
      43              : 
      44              :   /**
      45              :    * Plugin context.
      46              :    */
      47              :   struct PostgresClosure *pg;
      48              : };
      49              : 
      50              : 
      51              : /**
      52              :  * Helper function for #TEH_PG_iterate_kyc_reference().
      53              :  * Calls the callback with each denomination key.
      54              :  *
      55              :  * @param cls a `struct IteratorContext`
      56              :  * @param result db results
      57              :  * @param num_results number of results in @a result
      58              :  */
      59              : static void
      60            0 : iterate_kyc_reference_cb (void *cls,
      61              :                           PGresult *result,
      62              :                           unsigned int num_results)
      63              : {
      64            0 :   struct IteratorContext *ic = cls;
      65              : 
      66            0 :   for (unsigned int i = 0; i<num_results; i++)
      67              :   {
      68              :     char *kyc_provider_name_name;
      69              :     char *provider_user_id;
      70              :     char *legitimization_id;
      71            0 :     struct GNUNET_PQ_ResultSpec rs[] = {
      72            0 :       GNUNET_PQ_result_spec_string ("provider_name",
      73              :                                     &kyc_provider_name_name),
      74            0 :       GNUNET_PQ_result_spec_string ("provider_user_id",
      75              :                                     &provider_user_id),
      76            0 :       GNUNET_PQ_result_spec_string ("provider_legitimization_id",
      77              :                                     &legitimization_id),
      78              :       GNUNET_PQ_result_spec_end
      79              :     };
      80              : 
      81            0 :     if (GNUNET_OK !=
      82            0 :         GNUNET_PQ_extract_result (result,
      83              :                                   rs,
      84              :                                   i))
      85              :     {
      86            0 :       GNUNET_break (0);
      87            0 :       return;
      88              :     }
      89            0 :     ic->cb (ic->cb_cls,
      90              :             kyc_provider_name_name,
      91              :             provider_user_id,
      92              :             legitimization_id);
      93            0 :     GNUNET_PQ_cleanup_result (rs);
      94              :   }
      95              : }
      96              : 
      97              : 
      98              : enum GNUNET_DB_QueryStatus
      99            0 : TEH_PG_iterate_kyc_reference (
     100              :   void *cls,
     101              :   const struct TALER_NormalizedPaytoHashP *h_payto,
     102              :   TALER_EXCHANGEDB_LegitimizationProcessCallback lpc,
     103              :   void *lpc_cls)
     104              : {
     105            0 :   struct PostgresClosure *pg = cls;
     106            0 :   struct GNUNET_PQ_QueryParam params[] = {
     107            0 :     GNUNET_PQ_query_param_auto_from_type (h_payto),
     108              :     GNUNET_PQ_query_param_end
     109              :   };
     110            0 :   struct IteratorContext ic = {
     111              :     .cb = lpc,
     112              :     .cb_cls = lpc_cls,
     113              :     .pg = pg
     114              :   };
     115              : 
     116            0 :   PREPARE (pg,
     117              :            "iterate_kyc_reference",
     118              :            "SELECT "
     119              :            " provider_name"
     120              :            ",provider_user_id"
     121              :            ",provider_legitimization_id"
     122              :            " FROM legitimization_processes"
     123              :            " WHERE h_payto=$1;");
     124            0 :   return GNUNET_PQ_eval_prepared_multi_select (
     125              :     pg->conn,
     126              :     "iterate_kyc_reference",
     127              :     params,
     128              :     &iterate_kyc_reference_cb,
     129              :     &ic);
     130              : }
        

Generated by: LCOV version 2.0-1