LCOV - code coverage report
Current view: top level - auditor - taler-auditor-httpd_delete-generic.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 23 0
Test Date: 2026-04-14 15:39:31 Functions: 0.0 % 1 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 <gnunet/gnunet_util_lib.h>
      17              : #include <gnunet/gnunet_json_lib.h>
      18              : #include <jansson.h>
      19              : #include <microhttpd.h>
      20              : #include <pthread.h>
      21              : #include "taler/taler_json_lib.h"
      22              : #include "taler/taler_mhd_lib.h"
      23              : #include "taler-auditor-httpd.h"
      24              : #include "taler-auditor-httpd_delete-generic.h"
      25              : #include "auditor-database/delete_generic.h"
      26              : #include "auditor-database/preflight.h"
      27              : 
      28              : 
      29              : MHD_RESULT
      30            0 : TAH_delete_generic (
      31              :   struct TAH_RequestHandler *rh,
      32              :   struct MHD_Connection *connection,
      33              :   void **connection_cls,
      34              :   const char *upload_data,
      35              :   size_t *upload_data_size,
      36              :   const char *const args[])
      37              : {
      38              :   enum GNUNET_DB_QueryStatus qs;
      39              :   unsigned long long row_id;
      40              :   char dummy;
      41              : 
      42              :   (void) connection_cls;
      43            0 :   if (GNUNET_SYSERR ==
      44            0 :       TALER_AUDITORDB_preflight (TAH_apg))
      45              :   {
      46            0 :     GNUNET_break (0);
      47            0 :     return TALER_MHD_reply_with_error (connection,
      48              :                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
      49              :                                        TALER_EC_GENERIC_DB_SETUP_FAILED,
      50              :                                        NULL);
      51              :   }
      52              : 
      53            0 :   if ((NULL == args[1]) ||
      54            0 :       (1 != sscanf (args[1],
      55              :                     "%llu%c",
      56              :                     &row_id,
      57              :                     &dummy)))
      58              :   {
      59            0 :     GNUNET_break_op (0);
      60            0 :     return TALER_MHD_reply_with_error (connection,
      61              :                                        MHD_HTTP_BAD_REQUEST,
      62              :                                        TALER_EC_AUDITOR_RESOURCE_NOT_FOUND,
      63              :                                        "no row id specified");
      64              :   }
      65              : 
      66              :   /* execute transaction */
      67            0 :   qs = TALER_AUDITORDB_delete_generic (TAH_apg,
      68              :                                        rh->table,
      69              :                                        row_id);
      70            0 :   switch (qs)
      71              :   {
      72            0 :   case GNUNET_DB_STATUS_HARD_ERROR:
      73            0 :     GNUNET_break (0);
      74            0 :     return TALER_MHD_reply_with_error (connection,
      75              :                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
      76              :                                        TALER_EC_GENERIC_DB_STORE_FAILED,
      77              :                                        "db store failed");
      78            0 :   case GNUNET_DB_STATUS_SOFT_ERROR:
      79            0 :     GNUNET_break (0);
      80            0 :     return TALER_MHD_reply_with_error (connection,
      81              :                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
      82              :                                        TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
      83              :                                        "unexpected serialization problem");
      84            0 :   case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
      85            0 :     return TALER_MHD_reply_with_error (connection,
      86              :                                        MHD_HTTP_NOT_FOUND,
      87              :                                        TALER_EC_AUDITOR_RESOURCE_NOT_FOUND,
      88              :                                        "no delete executed");
      89            0 :   case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
      90            0 :     return TALER_MHD_reply_static (connection,
      91              :                                    MHD_HTTP_NO_CONTENT,
      92              :                                    NULL,
      93              :                                    NULL,
      94              :                                    0);
      95              :   }
      96            0 :   GNUNET_break (0);
      97            0 :   return MHD_NO;
      98              : }
        

Generated by: LCOV version 2.0-1