LCOV - code coverage report
Current view: top level - testing - testing_api_helpers.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 66.7 % 21 14
Test Date: 2025-11-13 17:46:01 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /*
       2              :   This file is part of TALER
       3              :   Copyright (C) 2014-2018 Taler Systems SA
       4              : 
       5              :   TALER is free software; you can redistribute it and/or modify
       6              :   it under the terms of the GNU General Public License as
       7              :   published by the Free Software Foundation; either version 3, or
       8              :   (at your option) any later version.
       9              : 
      10              :   TALER is distributed in the hope that it will be useful, but
      11              :   WITHOUT ANY WARRANTY; without even the implied warranty of
      12              :   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      13              :   GNU General Public License for more details.
      14              : 
      15              :   You should have received a copy of the GNU General Public
      16              :   License along with TALER; see the file COPYING.  If not, see
      17              :   <http://www.gnu.org/licenses/>
      18              : */
      19              : 
      20              : /**
      21              :  * @file testing_api_helpers.c
      22              :  * @brief helper functions for test library.
      23              :  * @author Christian Grothoff
      24              :  */
      25              : #include "platform.h"
      26              : #include <taler/taler_exchange_service.h>
      27              : #include <taler/taler_testing_lib.h>
      28              : #include "taler_merchant_testing_lib.h"
      29              : 
      30              : 
      31              : char *
      32           19 : TALER_MERCHANT_TESTING_extract_host (const char *merchant_url)
      33              : {
      34           19 :   const char *hosts = strchr (merchant_url, '/');
      35              :   const char *hend;
      36              :   const char *pstr;
      37              :   const char *pend;
      38              :   char *host;
      39              : 
      40           19 :   if (NULL == hosts)
      41              :   {
      42            0 :     GNUNET_break (0);
      43            0 :     return NULL;
      44              :   }
      45           19 :   if (hosts[1] != '/')
      46              :   {
      47            0 :     GNUNET_break (0);
      48            0 :     return NULL;
      49              :   }
      50           19 :   hosts += 2;
      51           19 :   pstr = strchr (hosts, ':');
      52           19 :   if (NULL == pstr)
      53              :   {
      54            0 :     hend = &hosts[strlen (hosts)];
      55            0 :     pstr = "80";
      56            0 :     pend = &pstr[2];
      57              :   }
      58              :   else
      59              :   {
      60           19 :     hend = pstr;
      61           19 :     pstr++;
      62           19 :     pend = strchr (pstr, '/');
      63              :   }
      64           19 :   GNUNET_asprintf (&host,
      65              :                    "%.*s:%.*s",
      66           19 :                    (int) (hend - hosts),
      67              :                    hosts,
      68           19 :                    (int) (pend - pstr),
      69              :                    pstr);
      70           19 :   return host;
      71              : }
        

Generated by: LCOV version 2.0-1