LCOV - code coverage report
Current view: top level - backend - taler-merchant-httpd_contract.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 16 0.0 %
Date: 2025-06-23 16:22:09 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /*
       2             :   This file is part of TALER
       3             :   (C) 2024 Taler Systems SA
       4             : 
       5             :   TALER is free software; you can redistribute it and/or modify it under the
       6             :   terms of the GNU Lesser 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 taler-merchant-httpd_contract.c
      18             :  * @brief shared logic for contract terms handling
      19             :  * @author Christian Blättler
      20             :  */
      21             : #include "platform.h"
      22             : #include <gnunet/gnunet_common.h>
      23             : #include <jansson.h>
      24             : #include <stdint.h>
      25             : #include <taler/taler_json_lib.h>
      26             : #include "taler-merchant-httpd_contract.h"
      27             : 
      28             : 
      29             : enum GNUNET_GenericReturnValue
      30           0 : TMH_find_token_family_key (
      31             :   const char *slug,
      32             :   struct GNUNET_TIME_Timestamp valid_after,
      33             :   const struct TALER_MERCHANT_ContractTokenFamily *families,
      34             :   unsigned int families_len,
      35             :   struct TALER_MERCHANT_ContractTokenFamily *family,
      36             :   struct TALER_MERCHANT_ContractTokenFamilyKey *key)
      37             : {
      38           0 :   for (unsigned int i = 0; i < families_len; i++)
      39             :   {
      40           0 :     const struct TALER_MERCHANT_ContractTokenFamily *fami
      41           0 :       = &families[i];
      42             : 
      43           0 :     if (0 != strcmp (fami->slug,
      44             :                      slug))
      45           0 :       continue;
      46           0 :     if (NULL != family)
      47           0 :       *family = *fami;
      48           0 :     for (unsigned int k = 0; k < fami->keys_len; k++)
      49             :     {
      50           0 :       struct TALER_MERCHANT_ContractTokenFamilyKey *ki = &fami->keys[k];
      51             : 
      52           0 :       if (GNUNET_TIME_timestamp_cmp (ki->valid_after,
      53             :                                      ==,
      54             :                                      valid_after))
      55             :       {
      56           0 :         if (NULL != key)
      57           0 :           *key = *ki;
      58           0 :         return GNUNET_OK;
      59             :       }
      60             :     }
      61             :     /* matching family found, but no key. */
      62           0 :     return GNUNET_NO;
      63             :   }
      64             : 
      65             :   /* no matching family found */
      66           0 :   return GNUNET_SYSERR;
      67             : }

Generated by: LCOV version 1.16