LCOV - code coverage report
Current view: top level - util - util.c (source / functions) Hit Total Coverage
Test: GNU Taler exchange coverage report Lines: 7 7 100.0 %
Date: 2021-08-30 06:43:37 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :   This file is part of TALER
       3             :   Copyright (C) 2014-2020 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 util.c
      18             :  * @brief Common utility functions
      19             :  * @author Sree Harsha Totakura <sreeharsha@totakura.in>
      20             :  * @author Florian Dold
      21             :  * @author Benedikt Mueller
      22             :  */
      23             : #include "platform.h"
      24             : #include "taler_util.h"
      25             : 
      26             : 
      27             : /**
      28             :  * Convert a buffer to an 8-character string representative of the
      29             :  * contents. This is used for logging binary data when debugging.
      30             :  *
      31             :  * @param buf buffer to log
      32             :  * @param buf_size number of bytes in @a buf
      33             :  * @return text representation of buf, valid until next
      34             :  *         call to this function
      35             :  */
      36             : const char *
      37        5079 : TALER_b2s (const void *buf,
      38             :            size_t buf_size)
      39             : {
      40             :   static GNUNET_THREAD_LOCAL char ret[9];
      41             :   struct GNUNET_HashCode hc;
      42             :   char *tmp;
      43             : 
      44        5079 :   GNUNET_CRYPTO_hash (buf,
      45             :                       buf_size,
      46             :                       &hc);
      47        5079 :   tmp = GNUNET_STRINGS_data_to_string_alloc (&hc,
      48             :                                              sizeof (hc));
      49        5079 :   memcpy (ret,
      50             :           tmp,
      51             :           8);
      52        5079 :   GNUNET_free (tmp);
      53        5079 :   ret[8] = '\0';
      54        5079 :   return ret;
      55             : }
      56             : 
      57             : 
      58             : /* end of util.c */

Generated by: LCOV version 1.14