gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-anastasis] branch master updated: add square number validation fo


From: gnunet
Subject: [taler-anastasis] branch master updated: add square number validation for testcountry
Date: Sat, 20 Mar 2021 22:05:35 +0100

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 2105f44  add square number validation for testcountry
2105f44 is described below

commit 2105f44a1912c93fdd2a52f79d4580b72c681034
Author: Christian Grothoff <grothoff@gnunet.org>
AuthorDate: Sat Mar 20 22:05:33 2021 +0100

    add square number validation for testcountry
---
 contrib/redux.xx.json              | 16 ++++++-------
 src/reducer/Makefile.am            |  4 +++-
 src/reducer/validation_XX_SQUARE.c | 48 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 59 insertions(+), 9 deletions(-)

diff --git a/contrib/redux.xx.json b/contrib/redux.xx.json
index 28b60ad..b852c61 100644
--- a/contrib/redux.xx.json
+++ b/contrib/redux.xx.json
@@ -28,16 +28,16 @@
        },
        {
            "type": "string",
-           "name": "ahv_number",
-           "label": "AHV number",
+           "name": "sq_number",
+           "label": "Squre number",
            "label_i18n":{
-               "de_DE":"AHV-Nummer",
-               "de_CH":"AHV-Nummer"
+               "de_DE":"Quadratzahl",
+               "de_CH":"Quadratzahl"
            },
-           "widget": "anastasis_gtk_ia_ahv",
-            "uuid" : "1da87570-ba16-4f62-8a7e-cbda92f51591",
-           "validation-regex": 
"^(756).[0-9]{4}.[0-9]{4}.[0-9]{2}|(756)[0-9]{10}$",
-           "validation-logic": "CH_AHV_check"
+           "widget": "anastasis_gtk_xx_sqare",
+            "uuid" : "ed790bca-89bf-11eb-96f2-233996cf644e",
+           "validation-regex": "^[0-9]+$",
+           "validation-logic": "XX_SQUARE_check"
        }
     ]
 }
diff --git a/src/reducer/Makefile.am b/src/reducer/Makefile.am
index 68c1494..eae9a63 100644
--- a/src/reducer/Makefile.am
+++ b/src/reducer/Makefile.am
@@ -19,7 +19,8 @@ libanastasisredux_la_SOURCES = \
   anastasis_api_recovery_redux.c \
   anastasis_api_backup_redux.c \
   validation_CH_AHV.c \
-  validation_DE_SVN.c
+  validation_DE_SVN.c \
+  validation_XX_SQUARE.c 
 libanastasisredux_la_LIBADD = \
   $(top_builddir)/src/restclient/libanastasisrest.la \
   $(top_builddir)/src/lib/libanastasis.la \
@@ -34,4 +35,5 @@ libanastasisredux_la_LIBADD = \
   -ltalerjson \
   -ljansson \
   -ldl \
+  -lm \
   $(XLIB)
diff --git a/src/reducer/validation_XX_SQUARE.c 
b/src/reducer/validation_XX_SQUARE.c
new file mode 100644
index 0000000..fa3ebfb
--- /dev/null
+++ b/src/reducer/validation_XX_SQUARE.c
@@ -0,0 +1,48 @@
+/*
+  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_XX_PRIME.c
+ * @brief anastasis reducer api
+ * @author Christian Grothoff
+ * @author Dominik Meister
+ * @author Dennis Neufeld
+ */
+#include <string.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <math.h>
+
+/**
+ * Function to validate a square number.
+ *
+ * @param sq_number square number to validate (input)
+ * @return true if sq_number is a square, else false
+ */
+bool
+XX_SQUARE_check (const char *sq_number)
+{
+  unsigned long long n;
+  unsigned long long r;
+  char dummy;
+
+  if (1 != sscanf (sq_number,
+                   "%llu%c",
+                   &n,
+                   &dummy))
+    return false;
+  r = sqrt (n);
+  return (n == r * r);
+}

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]