gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taler-mdb] 47/93: Merge branch 'refactor' of https://git.taler.ne


From: gnunet
Subject: [taler-taler-mdb] 47/93: Merge branch 'refactor' of https://git.taler.net/taler-mdb into refactor
Date: Mon, 18 Nov 2019 21:13:10 +0100

This is an automated email from the git hooks/post-receive script.

marco-boss pushed a commit to branch master
in repository taler-mdb.

commit 0816cc3a2f89e83251c28da99d532880ec29253f
Merge: d0f3643 f8ab6b7
Author: Boss Marco <address@hidden>
AuthorDate: Mon Nov 11 17:54:58 2019 +0100

    Merge branch 'refactor' of https://git.taler.net/taler-mdb into refactor

 configure.ac    |  39 +++++++++++++++++-
 src/Makefile.am |   1 +
 src/main.c      | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
 3 files changed, 158 insertions(+), 7 deletions(-)

diff --cc src/main.c
index c1ab881,a34353b..fd7142a
--- a/src/main.c
+++ b/src/main.c
@@@ -19,9 -19,10 +19,10 @@@ along wit
  /**
  * @file main.c
  * @brief main functionality of the application
 -* @author BOSS Marco
 +* @author Boss Marco
  * @author Christian Grothoff
  */
+ #include "config.h"
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
@@@ -129,8 -145,109 +147,87 @@@ static char *authorization
  
  static struct PaymentActivity *payment_activity;
  
 -
 -/**
 - * FIXME: read from configuration file instead!
 - * GNUNET_CONFIGURATION_* iteration over values.
 - */
 -static struct Product products[] = {
 -  {
 -    .price = "0.1",
 -    .description = "Snickers",
 -    .key = 's'
 -  },
 -  {
 -    .price = "0.1",
 -    .description = "Twix",
 -    .key = 't'
 -  },
 -  {
 -    .price = NULL,
 -    .description = NULL,
 -    .key = '\0'
 -  }
 -};
 -
 +static struct Product *products;
  
+ #if HAVE_QRENCODE_H
+ #include <qrencode.h>
+ 
+ /**
+  * Create the QR code image for our zone.
+  *
+  * @param uri what text to show in the QR code
+  */
+ static void
+ show_qrcode (const char *uri)
+ {
+   QRinput *qri;
+   QRcode *qrc;
+   uint8_t *pixels;
+   unsigned int size;
+   char *upper;
+   const unsigned int scale = 3;
+   const unsigned int n_channels = 3;
+ 
+   qri = QRinput_new2 (0, QR_ECLEVEL_M);
+   if (NULL == qri)
+   {
+     GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
+                          "QRinput_new2");
+     return;
+   }
+   upper = GNUNET_strdup (uri);
+   GNUNET_STRINGS_utf8_toupper (uri, upper);
+   /* first try encoding as uppercase-only alpha-numerical
+      QR code (much smaller encoding); if that fails, also
+      try using binary encoding (in case nick contains
+      special characters). */
+   if ((0 !=
+        QRinput_append (qri,
+                        QR_MODE_AN,
+                        strlen (upper),
+                        (unsigned char *) upper)) &&
+       (0 !=
+        QRinput_append (qri,
+                        QR_MODE_8,
+                        strlen (upper),
+                        (unsigned char *) upper)))
+   {
+     GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
+                          "QRinput_append");
+     GNUNET_free (upper);
+     return;
+   }
+   GNUNET_free (upper);
+   qrc = QRcode_encodeInput (qri);
+   if (NULL == qrc)
+   {
+     GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
+                          "QRcode_encodeInput");
+     QRinput_free (qri);
+     return;
+   }
+   size = qrc->width * scale;
+   size += 8 - (size % 8);
+   pixels = GNUNET_malloc (size * size * n_channels);
+   for (unsigned int x = 0; x < size; x++)
+     for (unsigned int y = 0; y < size; y++)
+     {
+       unsigned int off =
+         (x * qrc->width / size) + (y * qrc->width / size) * qrc->width;
+       for (int c = 0; c < n_channels; c++)
+         pixels[(y * size + x) * n_channels + c] =
+           (0 == (qrc->data[off] & 1)) ? 0xFF : 0;
+     }
+   QRcode_free (qrc);
+   QRinput_free (qri);
+   // FIXME: use 'pixels'
+   GNUNET_free (pixels);
+ }
+ 
+ 
+ #endif
+ 
+ 
  static void
  SNACK_print_hex_info (const char*message,
                        const uint8_t *hexArray,

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

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