gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: expose language check logic


From: gnunet
Subject: [taler-exchange] branch master updated: expose language check logic
Date: Mon, 03 Aug 2020 01:16:55 +0200

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

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new f1cc1ca2 expose language check logic
f1cc1ca2 is described below

commit f1cc1ca2085de9b112d42f7e2c68d21e4753781b
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Mon Aug 3 01:16:53 2020 +0200

    expose language check logic
---
 src/include/taler_mhd_lib.h | 16 ++++++++++++++++
 src/mhd/mhd_legal.c         | 14 +++++++-------
 2 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/src/include/taler_mhd_lib.h b/src/include/taler_mhd_lib.h
index 4b34f41d..7d281662 100644
--- a/src/include/taler_mhd_lib.h
+++ b/src/include/taler_mhd_lib.h
@@ -96,6 +96,22 @@ MHD_RESULT
 TALER_MHD_can_compress (struct MHD_Connection *connection);
 
 
+/**
+ * Check if @a lang matches the @a language_pattern, and if so with
+ * which preference.
+ * See also: https://tools.ietf.org/html/rfc7231#section-5.3.1
+ *
+ * @param language_pattern a language preferences string
+ *        like "fr-CH, fr;q=0.9, en;q=0.8, *;q=0.1"
+ * @param lang the 2-digit language to match
+ * @return q-weight given for @a lang in @a language_pattern, 1.0 if no 
weights are given;
+ *         0 if @a lang is not in @a language_pattern
+ */
+double
+TALER_MHD_language_matches (const char *language_pattern,
+                            const char *lang);
+
+
 /**
  * Send JSON object as response.
  *
diff --git a/src/mhd/mhd_legal.c b/src/mhd/mhd_legal.c
index a6c26bba..7de189cc 100644
--- a/src/mhd/mhd_legal.c
+++ b/src/mhd/mhd_legal.c
@@ -165,9 +165,9 @@ xmime_matches (const char *accept_pattern,
  * @return q-weight given for @a lang in @a language_pattern, 1.0 if no 
weights are given;
  *         0 if @a lang is not in @a language_pattern
  */
-static double
-language_matches (const char *language_pattern,
-                  const char *lang)
+double
+TALER_MHD_language_matches (const char *language_pattern,
+                            const char *lang)
 {
   char *p = GNUNET_strdup (language_pattern);
   char *sptr;
@@ -271,10 +271,10 @@ TALER_MHD_reply_legal (struct MHD_Connection *conn,
         if ( (NULL == t) ||
              (! xmime_matches (mime,
                                t->mime_type)) ||
-             (language_matches (lang,
-                                p->language) >
-              language_matches (lang,
-                                t->language) ) )
+             (TALER_MHD_language_matches (lang,
+                                          p->language) >
+              TALER_MHD_language_matches (lang,
+                                          t->language) ) )
           t = p;
       }
     }

-- 
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]