configure: Detect type of length parameter for gperf generated function
authorTobias Brunner <tobias@strongswan.org>
Mon, 18 Sep 2017 15:57:05 +0000 (17:57 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 19 Sep 2017 11:24:43 +0000 (13:24 +0200)
Since 3.1 gperf uses size_t for the length parameter instead of an
unsigned int.

configure.ac
src/libstrongswan/crypto/proposal/proposal_keywords_static.h
src/starter/confread.c
src/stroke/stroke_keywords.h

index 400c33b..0cfe524 100644 (file)
@@ -378,6 +378,21 @@ AC_PATH_PROG([GPERF], [gperf], [], [$PATH:/bin:/usr/bin:/usr/local/bin])
 AC_MSG_CHECKING([gperf version >= 3.0.0])
 if test -x "$GPERF"; then
        if test "`$GPERF --version | $AWK -F' ' '/^GNU gperf/ { print $3 }' | $AWK -F. '{ print $1 }'`" -ge "3"; then
+               GPERF_OUTPUT="`echo foo | ${GPERF}`"
+               AC_COMPILE_IFELSE(
+                       [AC_LANG_PROGRAM(
+                               [[#include <string.h>
+                                 const char *in_word_set(const char*, size_t); $GPERF_OUTPUT]])],
+                       [GPERF_LEN_TYPE=size_t],
+                       [AC_COMPILE_IFELSE(
+                               [AC_LANG_PROGRAM(
+                                       [[#include <string.h>
+                                         const char *in_word_set(const char*, unsigned); $GPERF_OUTPUT]])],
+                               [GPERF_LEN_TYPE=unsigned],
+                               [AC_MSG_ERROR([unable to determine gperf len type])]
+                       )]
+               )
+               AC_DEFINE_UNQUOTED([GPERF_LEN_TYPE], [$GPERF_LEN_TYPE], [gperf len type])
                AC_MSG_RESULT([yes])
        else
                AC_MSG_RESULT([no])
index bc421dc..c046fab 100644 (file)
@@ -19,7 +19,7 @@
 #include "proposal_keywords.h"
 
 const proposal_token_t* proposal_get_token_static(register const char *str,
-                                                                                                 register unsigned int len);
+                                                                                                 register GPERF_LEN_TYPE len);
 
 #endif /* PROPOSAL_KEYWORDS_STATIC_H_ */
 
index f98fc89..e78f2a7 100644 (file)
@@ -48,7 +48,7 @@ static const char firewall_defaults[] = IPSEC_SCRIPT " _updown iptables";
 /**
  * Provided by GPERF
  */
-extern kw_entry_t *in_word_set (char *str, unsigned int len);
+extern const kw_entry_t *in_word_set(register const char*, register GPERF_LEN_TYPE);
 
 /**
  * Process deprecated keywords
@@ -95,7 +95,7 @@ static void load_setup(starter_config_t *cfg, conf_parser_t *parser)
 {
        enumerator_t *enumerator;
        dictionary_t *dict;
-       kw_entry_t *entry;
+       const kw_entry_t *entry;
        char *key, *value;
 
        DBG2(DBG_APP, "Loading config setup");
@@ -146,7 +146,7 @@ static void load_ca(starter_ca_t *ca, starter_config_t *cfg,
 {
        enumerator_t *enumerator;
        dictionary_t *dict;
-       kw_entry_t *entry;
+       const kw_entry_t *entry;
        kw_token_t token;
        char *key, *value;
 
@@ -559,7 +559,7 @@ static void load_conn(starter_conn_t *conn, starter_config_t *cfg,
 {
        enumerator_t *enumerator;
        dictionary_t *dict;
-       kw_entry_t *entry;
+       const kw_entry_t *entry;
        kw_token_t token;
        char *key, *value;
 
index 4a10162..51caba6 100644 (file)
@@ -73,6 +73,6 @@ typedef enum {
 
 typedef struct stroke_token stroke_token_t;
 
-extern const stroke_token_t* in_word_set(register const char *str, register unsigned int len);
+extern const stroke_token_t* in_word_set(register const char *str, register GPERF_LEN_TYPE len);
 
 #endif /* _STROKE_KEYWORDS_H_ */