[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: add definitions for india
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: add definitions for india |
Date: |
Fri, 02 Jul 2021 23:49:29 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository anastasis.
The following commit(s) were added to refs/heads/master by this push:
new 37f65ce add definitions for india
37f65ce is described below
commit 37f65ce631836181bc5967b1d5488020d93e16c9
Author: Christian Grothoff <grothoff@gnunet.org>
AuthorDate: Fri Jul 2 23:48:15 2021 +0200
add definitions for india
---
contrib/Makefile.am | 1 +
contrib/redux.countries.json | 13 +++++
contrib/redux.in.json | 55 ++++++++++++++++++
src/reducer/Makefile.am | 1 +
src/reducer/validation_IN_AADHAR.c | 113 +++++++++++++++++++++++++++++++++++++
5 files changed, 183 insertions(+)
diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index 0c6a8db..b0721dc 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -16,6 +16,7 @@ EXTRA_DIST = \
pkgdata_DATA = \
redux.ch.json \
redux.de.json \
+ redux.in.json \
redux.us.json \
redux.xx.json \
redux.xy.json \
diff --git a/contrib/redux.countries.json b/contrib/redux.countries.json
index afcb395..d021054 100644
--- a/contrib/redux.countries.json
+++ b/contrib/redux.countries.json
@@ -25,6 +25,19 @@
},
"currency": "EUR"
},
+ {
+ "code" : "in",
+ "name" : "India",
+ "continent" : "India",
+ "continent_i18n" : { "en_EN" : "India" },
+ "name_i18n" : {
+ "de_DE": "Indien",
+ "de_CH": "Indien",
+ "fr_FR": "l'Inde",
+ "en_UK": "India"
+ },
+ "currency": "INR"
+ },
{
"code" : "us",
"name" : "United States of America (USA)",
diff --git a/contrib/redux.in.json b/contrib/redux.in.json
new file mode 100644
index 0000000..c296de9
--- /dev/null
+++ b/contrib/redux.in.json
@@ -0,0 +1,55 @@
+{
+ "required_attributes": [
+ {
+ "type": "string",
+ "name": "full_name",
+ "label": "Full name",
+ "label_i18n":{
+ "de_DE": "Vollständiger Name",
+ "de_CH": "Vollständiger Name",
+ "fr": "Nom complet",
+ "en": "Full name"
+ },
+ "widget": "anastasis_gtk_ia_full_name",
+ "uuid" : "9e8f463f-575f-42cb-85f3-759559997331"
+ },
+ {
+ "type": "date",
+ "name": "birthdate",
+ "label": "Birthdate",
+ "label_i18n":{
+ "de_DE":"Geburtsdatum",
+ "de_CH":"Geburtsdatum",
+ "fr":"Date de naissance",
+ "en":"Birthdate"
+ },
+ "widget": "anastasis_gtk_ia_birthdate",
+ "uuid" : "83d655c7-bdb6-484d-904e-80c1058c8854"
+ },
+ {
+ "type": "string",
+ "name": "birthplace",
+ "label": "Birthplace",
+ "label_i18n":{
+ "de_CH":"Geburtsort",
+ "de_CH":"Geburtsort",
+ "fr":"Place de naissance",
+ "en":"Birthplace"
+ },
+ "widget": "anastasis_gtk_ia_birthplace",
+ "uuid" : "4c822e8e-89c6-11eb-95c4-8b077ad8489f"
+ },
+ {
+ "type": "string",
+ "name": "aadhar_number",
+ "label": "Aadhar number",
+ "label_i18n":{
+ "en": "Aadhar number"
+ },
+ "widget": "anastasis_gtk_ia_aadhar_in",
+ "uuid": "55afe97a-98bc-48d1-bb37-a9658be3fdc9",
+ "validation-regex": "^[2-9]{1}[0-9]{3}\\s[0-9]{4}\\s[0-9]{4}$",
+ "validation-logic": "IN_AADHAR_check"
+ }
+ ]
+}
diff --git a/src/reducer/Makefile.am b/src/reducer/Makefile.am
index bf11409..faa9d7d 100644
--- a/src/reducer/Makefile.am
+++ b/src/reducer/Makefile.am
@@ -21,6 +21,7 @@ libanastasisredux_la_SOURCES = \
validation_CH_AHV.c \
validation_DE_SVN.c \
validation_DE_TIN.c \
+ validation_IN_AADHAR.c \
validation_XX_SQUARE.c \
validation_XY_PRIME.c
libanastasisredux_la_LIBADD = \
diff --git a/src/reducer/validation_IN_AADHAR.c
b/src/reducer/validation_IN_AADHAR.c
new file mode 100644
index 0000000..939ee72
--- /dev/null
+++ b/src/reducer/validation_IN_AADHAR.c
@@ -0,0 +1,113 @@
+/*
+ This file is part of Anastasis
+ Copyright (C) 2020, 2021 Taler Systems SA
+
+ Anastasis is free software; you can redistribute it and/or modify it under
the
+ terms of the GNU Lesser General Public License as published by the Free
Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ Anastasis; see the file COPYING.GPL. If not, see
<http://www.gnu.org/licenses/>
+*/
+/**
+ * @file redux/validation_IN_AADHAR.c
+ * @brief validation logic for Indian Aadhar numbers
+ * @author Christian Grothoff
+ */
+#include <string.h>
+#include <stdbool.h>
+#include <ctype.h>
+
+/**
+ * The multiplication table.
+ */
+static int m[10][10] = {
+ {0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
+ {1, 2, 3, 4, 0, 6, 7, 8, 9, 5},
+ {2, 3, 4, 0, 1, 7, 8, 9, 5, 6},
+ {3, 4, 0, 1, 2, 8, 9, 5, 6, 7},
+ {4, 0, 1, 2, 3, 9, 5, 6, 7, 8},
+ {5, 9, 8, 7, 6, 0, 4, 3, 2, 1},
+ {6, 5, 9, 8, 7, 1, 0, 4, 3, 2},
+ {7, 6, 5, 9, 8, 2, 1, 0, 4, 3},
+ {8, 7, 6, 5, 9, 3, 2, 1, 0, 4},
+ {9, 8, 7, 6, 5, 4, 3, 2, 1, 0}
+};
+
+
+/**
+ * The permutation table.
+ */
+static int p[10][10] = {
+ {0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
+ {1, 5, 7, 6, 2, 8, 3, 0, 9, 4},
+ {5, 8, 0, 3, 7, 9, 6, 1, 4, 2},
+ {8, 9, 1, 6, 0, 4, 3, 5, 2, 7},
+ {9, 4, 5, 3, 1, 2, 6, 8, 7, 0},
+ {4, 2, 8, 6, 5, 7, 3, 9, 0, 1},
+ {2, 7, 9, 3, 8, 0, 6, 4, 1, 5},
+ {7, 0, 4, 6, 9, 1, 3, 2, 5, 8}
+};
+
+
+/**
+ * Converts a string to a reversed integer array.
+ *
+ * @param input The numeric string data converted to reversed int array.
+ * @param[out] Integer array containing the digits in the numeric string
+ * in reverse order
+ */
+static bool
+string_to_vals (const char *input,
+ int output[12])
+{
+ unsigned int off = 0;
+
+ for (unsigned int i = 0; i < 12;)
+ {
+ int c = input[i + off];
+
+ if (0 == c)
+ return false;
+ if (isspace (c))
+ {
+ off++;
+ continue;
+ }
+ if (! isdigit (c))
+ return false;
+ output[11 - i++] = c - '0';
+ }
+ if ('\0' != input[12 + off])
+ return false;
+ return true;
+}
+
+
+/**
+ * Function to validate an Indian Aadhar number.
+ *
+ * See
https://www.geeksforgeeks.org/how-to-check-aadhar-number-is-valid-or-not-using-regular-expression/
+ * and http://en.wikipedia.org/wiki/Verhoeff_algorithm/.
+ *
+ * @param aadhar_number aadhar number to validate (input)
+ * @return true if validation passed, else false
+ */
+bool
+IN_AADHAR_check (const char *aadhar_number)
+{
+ int c = 0;
+ int vals[12];
+
+ if (! string_to_vals (aadhar_number,
+ vals))
+ return false;
+ for (unsigned int i = 0; i < 12; i++)
+ c = m[c][p[(i % 8)][vals[i]]];
+
+ return (0 == c);
+}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis] branch master updated: add definitions for india,
gnunet <=