donau

Donation authority for GNU Taler (experimental)
Log | Files | Refs | Submodules | README | LICENSE

pg_lookup_donation_unit_amount.c (2053B)


      1 /*
      2    This file is part of TALER
      3    Copyright (C) 2025 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 donaudb/pg_lookup_donation_unit_amount.c
     18  * @brief Implmentation of getting the donation unit amount
     19  *          from the donation_units table.
     20  * @author Bohdan Potuzhnyi
     21  */
     22 #include <donau_config.h>
     23 #include <taler/taler_error_codes.h>
     24 #include <taler/taler_dbevents.h>
     25 #include <taler/taler_pq_lib.h>
     26 #include "pg_template.h"
     27 #include "pg_helper.h"
     28 #include "donau_pq_lib.h"
     29 #include "pg_lookup_donation_unit_amount.h"
     30 
     31 
     32 enum GNUNET_DB_QueryStatus
     33 DH_PG_lookup_donation_unit_amount (
     34   void *cls,
     35   const struct DONAU_DonationUnitHashP *h_donation_unit_pub,
     36   struct TALER_Amount *value)
     37 {
     38   struct PostgresClosure *pg = cls;
     39 
     40   struct GNUNET_PQ_QueryParam params[] = {
     41     GNUNET_PQ_query_param_auto_from_type (h_donation_unit_pub),
     42     GNUNET_PQ_query_param_end
     43   };
     44 
     45   struct GNUNET_PQ_ResultSpec rs[] = {
     46     TALER_PQ_RESULT_SPEC_AMOUNT ("value",
     47                                  value),
     48     GNUNET_PQ_result_spec_end
     49   };
     50 
     51   PREPARE (pg,
     52            "lookup_donation_unit",
     53            "SELECT value"
     54            " FROM donation_units"
     55            " WHERE h_donation_unit_pub=$1;");
     56 
     57   return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
     58                                                    "lookup_donation_unit",
     59                                                    params,
     60                                                    rs);
     61 }