LCOV - code coverage report
Current view: top level - auditor - taler-auditor-httpd_progress-get.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 20 0
Test Date: 2025-12-28 14:06:02 Functions: 0.0 % 2 0

            Line data    Source code
       1              : /*
       2              :    This file is part of TALER
       3              :    Copyright (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 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              : #include "taler/platform.h"
      17              : #include <gnunet/gnunet_util_lib.h>
      18              : #include <gnunet/gnunet_json_lib.h>
      19              : #include <jansson.h>
      20              : #include <microhttpd.h>
      21              : #include <pthread.h>
      22              : #include "taler/taler_json_lib.h"
      23              : #include "taler/taler_mhd_lib.h"
      24              : #include "taler-auditor-httpd.h"
      25              : #include "taler-auditor-httpd_progress-get.h"
      26              : 
      27              : 
      28              : /**
      29              :  * Add progress to the list.
      30              :  *
      31              :  * @param[in,out] cls a `json_t *` array to extend
      32              :  * @param dc struct with progress data
      33              :  * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
      34              :  */
      35              : static enum GNUNET_GenericReturnValue
      36            0 : process_progress (
      37              :   void *cls,
      38              :   const struct TALER_AUDITORDB_Progress *dc)
      39              : {
      40            0 :   json_t *list = cls;
      41              :   json_t *obj;
      42              : 
      43            0 :   obj = GNUNET_JSON_PACK (
      44              :     GNUNET_JSON_pack_string ("progress_key",
      45              :                              dc->progress_key),
      46              :     GNUNET_JSON_pack_int64 ("progress_offset",
      47              :                             dc->progress_offset)
      48              :     );
      49            0 :   GNUNET_break (0 ==
      50              :                 json_array_append_new (list,
      51              :                                        obj));
      52            0 :   return GNUNET_OK;
      53              : }
      54              : 
      55              : 
      56              : MHD_RESULT
      57            0 : TAH_PROGRESS_handler_get (
      58              :   struct TAH_RequestHandler *rh,
      59              :   struct MHD_Connection *connection,
      60              :   void **connection_cls,
      61              :   const char *upload_data,
      62              :   size_t *upload_data_size,
      63              :   const char *const args[])
      64              : {
      65              :   json_t *ja;
      66              :   enum GNUNET_DB_QueryStatus qs;
      67              :   const char *progress_key;
      68              : 
      69              :   (void) rh;
      70              :   (void) connection_cls;
      71              :   (void) upload_data;
      72              :   (void) upload_data_size;
      73            0 :   if (GNUNET_SYSERR ==
      74            0 :       TAH_plugin->preflight (TAH_plugin->cls))
      75              :   {
      76            0 :     GNUNET_break (0);
      77            0 :     return TALER_MHD_reply_with_error (connection,
      78              :                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
      79              :                                        TALER_EC_GENERIC_DB_SETUP_FAILED,
      80              :                                        NULL);
      81              :   }
      82              :   progress_key
      83            0 :     = MHD_lookup_connection_value (connection,
      84              :                                    MHD_GET_ARGUMENT_KIND,
      85              :                                    "progress_key");
      86            0 :   ja = json_array ();
      87            0 :   GNUNET_break (NULL != ja);
      88            0 :   qs = TAH_plugin->get_progress_points (
      89            0 :     TAH_plugin->cls,
      90              :     progress_key,
      91              :     &process_progress,
      92              :     ja);
      93            0 :   if (0 > qs)
      94              :   {
      95            0 :     GNUNET_break (0);
      96            0 :     json_decref (ja);
      97            0 :     return TALER_MHD_reply_with_error (connection,
      98              :                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
      99              :                                        TALER_EC_GENERIC_DB_FETCH_FAILED,
     100              :                                        "progress");
     101              :   }
     102            0 :   return TALER_MHD_REPLY_JSON_PACK (
     103              :     connection,
     104              :     MHD_HTTP_OK,
     105              :     GNUNET_JSON_pack_array_steal ("progress",
     106              :                                   ja));
     107              : }
        

Generated by: LCOV version 2.0-1