exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

bank_api_helper.c (2498B)


      1 /*
      2   This file is part of TALER
      3   Copyright (C) 2026 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
     15   <http://www.gnu.org/licenses/>
     16 */
     17 /**
     18  * @file bank-lib/bank_api_helper.c
     19  * @brief convenience functions for the ``struct TALER_BANK_TransferSubject``
     20  * @author Christian Grothoff
     21  */
     22 #include "taler/platform.h"
     23 #include "bank_api_common.h"
     24 #include <microhttpd.h> /* just for HTTP status codes */
     25 #include "taler/taler_signatures.h"
     26 #include "taler/taler_curl_lib.h"
     27 
     28 
     29 void
     30 TALER_BANK_transfer_subject_copy (
     31   struct TALER_BANK_TransferSubject *dst,
     32   const struct TALER_BANK_TransferSubject *src)
     33 {
     34   dst->format = src->format;
     35 
     36   switch (src->format)
     37   {
     38   case TALER_BANK_SUBJECT_FORMAT_SIMPLE:
     39     dst->details.simple.credit_amount = src->details.simple.credit_amount;
     40     dst->details.simple.subject =
     41       (src->details.simple.subject != NULL)
     42       ? GNUNET_strdup (src->details.simple.subject)
     43       : NULL;
     44     return;
     45 
     46   case TALER_BANK_SUBJECT_FORMAT_URI:
     47     dst->details.uri.uri =
     48       (src->details.uri.uri != NULL)
     49       ? GNUNET_strdup (src->details.uri.uri)
     50       : NULL;
     51     return;
     52 
     53   case TALER_BANK_SUBJECT_FORMAT_CH_QR_BILL:
     54     dst->details.ch_qr_bill.credit_amount =
     55       src->details.ch_qr_bill.credit_amount;
     56     dst->details.ch_qr_bill.qr_reference_number =
     57       (src->details.ch_qr_bill.qr_reference_number != NULL)
     58       ? GNUNET_strdup (src->details.ch_qr_bill.qr_reference_number)
     59       : NULL;
     60     return;
     61   }
     62   GNUNET_break (0);
     63 }
     64 
     65 
     66 void
     67 TALER_BANK_transfer_subject_free (
     68   struct TALER_BANK_TransferSubject *subject)
     69 {
     70   switch (subject->format)
     71   {
     72   case TALER_BANK_SUBJECT_FORMAT_SIMPLE:
     73     GNUNET_free (subject->details.simple.subject);
     74     return;
     75 
     76   case TALER_BANK_SUBJECT_FORMAT_URI:
     77     GNUNET_free (subject->details.uri.uri);
     78     return;
     79 
     80   case TALER_BANK_SUBJECT_FORMAT_CH_QR_BILL:
     81     GNUNET_free (subject->details.ch_qr_bill.qr_reference_number);
     82     return;
     83   }
     84   GNUNET_break (0);
     85 }