anastasis

Credential backup and recovery protocol and service
Log | Files | Refs | Submodules | README | LICENSE

validation.c (2279B)


      1 /*
      2   This file is part of Anastasis
      3   Copyright (C) 2026 Anastasis SARL
      4 
      5   Anastasis is free software; you can redistribute it and/or modify it under the
      6   terms of the GNU Lesser General Public License as published by the Free Software
      7   Foundation; either version 3, or (at your option) any later version.
      8 
      9   Anastasis 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 Lesser General Public License for more details.
     12 
     13   You should have received a copy of the GNU Lesser General Public License along with
     14   Anastasis; see the file COPYING.LGPL.  If not, see <http://www.gnu.org/licenses/>
     15 */
     16 /**
     17  * @file reducer/validation.c
     18  * @brief table of the national identity number validation functions
     19  * @author Christian Grothoff
     20  */
     21 #include "platform.h"
     22 #include <gnunet/gnunet_util_lib.h>
     23 #include "validation.h"
     24 
     25 
     26 /**
     27  * Mapping of a "validation-logic" name to its implementation.
     28  */
     29 struct ValidationLogic
     30 {
     31   /**
     32    * Name used in the redux.<cc>.json country files.
     33    */
     34   const char *name;
     35 
     36   /**
     37    * Function implementing the check.
     38    */
     39   ANASTASIS_ValidationLogic logic;
     40 };
     41 
     42 
     43 /**
     44  * All validation functions we support.  Every "validation-logic" value
     45  * appearing in contrib/redux.*.json must have an entry here; anything else is
     46  * rejected by #ANASTASIS_REDUX_validation_lookup_().
     47  */
     48 static const struct ValidationLogic logics[] = {
     49   { "BE_NRN_check", &BE_NRN_check },
     50   { "CH_AHV_check", &CH_AHV_check },
     51   { "CZ_BN_check", &CZ_BN_check },
     52   { "DE_SVN_check", &DE_SVN_check },
     53   { "DE_TIN_check", &DE_TIN_check },
     54   { "ES_DNI_check", &ES_DNI_check },
     55   { "FR_INSEE_check", &FR_INSEE_check },
     56   { "IN_AADHAR_check", &IN_AADHAR_check },
     57   { "IT_CF_check", &IT_CF_check },
     58   { "NL_BSN_check", &NL_BSN_check },
     59   { "XX_SQUARE_check", &XX_SQUARE_check },
     60   { "XY_PRIME_check", &XY_PRIME_check },
     61   { NULL, NULL }
     62 };
     63 
     64 
     65 ANASTASIS_ValidationLogic
     66 ANASTASIS_REDUX_validation_lookup_ (const char *name)
     67 {
     68   if (NULL == name)
     69     return NULL;
     70   for (unsigned int i = 0; NULL != logics[i].name; i++)
     71     if (0 == strcmp (name,
     72                      logics[i].name))
     73       return logics[i].logic;
     74   return NULL;
     75 }
     76 
     77 
     78 /* end of validation.c */