LCOV - code coverage report
Current view: top level - backend - taler-merchant-httpd_private-get-otp-devices.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 14 0
Test Date: 2025-11-06 19:31:41 Functions: 0.0 % 2 0

            Line data    Source code
       1              : /*
       2              :   This file is part of TALER
       3              :   (C) 2022 Taler Systems SA
       4              : 
       5              :   TALER is free software; you can redistribute it and/or modify it under the
       6              :   terms of the GNU Affero 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_private-get-otp-devices.c
      18              :  * @brief implement GET /otp-devices
      19              :  * @author Christian Grothoff
      20              :  */
      21              : #include "platform.h"
      22              : #include "taler-merchant-httpd_private-get-otp-devices.h"
      23              : 
      24              : 
      25              : /**
      26              :  * Add OTP device details to our JSON array.
      27              :  *
      28              :  * @param cls a `json_t *` JSON array to build
      29              :  * @param otp_id ID of the OTP device
      30              :  * @param otp_description human-readable description for the OTP device
      31              :  */
      32              : static void
      33            0 : add_otp (void *cls,
      34              :          const char *otp_id,
      35              :          const char *otp_description)
      36              : {
      37            0 :   json_t *pa = cls;
      38              : 
      39            0 :   GNUNET_assert (0 ==
      40              :                  json_array_append_new (
      41              :                    pa,
      42              :                    GNUNET_JSON_PACK (
      43              :                      GNUNET_JSON_pack_string ("otp_device_id",
      44              :                                               otp_id),
      45              :                      GNUNET_JSON_pack_string ("device_description",
      46              :                                               otp_description))));
      47            0 : }
      48              : 
      49              : 
      50              : MHD_RESULT
      51            0 : TMH_private_get_otp_devices (const struct TMH_RequestHandler *rh,
      52              :                              struct MHD_Connection *connection,
      53              :                              struct TMH_HandlerContext *hc)
      54              : {
      55              :   json_t *pa;
      56              :   enum GNUNET_DB_QueryStatus qs;
      57              : 
      58            0 :   pa = json_array ();
      59            0 :   GNUNET_assert (NULL != pa);
      60            0 :   qs = TMH_db->lookup_otp_devices (TMH_db->cls,
      61            0 :                                    hc->instance->settings.id,
      62              :                                    &add_otp,
      63              :                                    pa);
      64            0 :   if (0 > qs)
      65              :   {
      66            0 :     GNUNET_break (0);
      67            0 :     json_decref (pa);
      68            0 :     return TALER_MHD_reply_with_error (connection,
      69              :                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
      70              :                                        TALER_EC_GENERIC_DB_FETCH_FAILED,
      71              :                                        NULL);
      72              :   }
      73            0 :   return TALER_MHD_REPLY_JSON_PACK (connection,
      74              :                                     MHD_HTTP_OK,
      75              :                                     GNUNET_JSON_pack_array_steal ("otp_devices",
      76              :                                                                   pa));
      77              : }
      78              : 
      79              : 
      80              : /* end of taler-merchant-httpd_private-get-otp-devices.c */
        

Generated by: LCOV version 2.0-1