gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] branch master updated (d588a455 -> f5c2724a)


From: gnunet
Subject: [libmicrohttpd] branch master updated (d588a455 -> f5c2724a)
Date: Wed, 27 Sep 2023 21:35:28 +0200

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

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from d588a455 Correction for 93bc2751bf5a04380de4435877344418bbeec770
     new 79470220 Fixed more compiler warnings
     new f5c2724a Fixed compatibility with more old compilers

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 configure.ac              | 14 -------
 src/microhttpd/gen_auth.c | 97 +++++++++++++++++++++++++++--------------------
 src/tools/perf_replies.c  | 76 ++++++-------------------------------
 3 files changed, 68 insertions(+), 119 deletions(-)

diff --git a/configure.ac b/configure.ac
index b9160692..2b010ddd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3903,20 +3903,6 @@ AS_VAR_IF([mhd_cv_ipv6_for_testing],["yes"],
 
 AS_VAR_IF([enable_tools],["yes"],
   [
-    MHD_CHECK_FUNC([pclose],[[#include <stdio.h>]],
-      [[
-        i][f (0 == pclose(NULL)) return 2;
-      ]],
-      [
-        MHD_CHECK_FUNC([popen],[[#include <stdio.h>]],
-          [[
-            FILE *cmd_out = popen ("cat conftest.c", "r");
-            i][f (NULL == cmd_out) return 2;
-            i][f (0 != pclose(cmd_out)) return 3;
-          ]]
-        )
-      ]
-    )
     AC_CHECK_HEADERS([features.h sys/pstat.h 
vxCpuLib.h],[],[],[AC_INCLUDES_DEFAULT])
     AC_CHECK_DECLS(
       
[_SC_NPROCESSORS_ONLN,_SC_NPROC_ONLN,_SC_CRAY_NCPU,_SC_NPROCESSORS_CONF,CTL_HW,HW_NCPUONLINE,HW_NCPU,HW_AVAILCPU],
diff --git a/src/microhttpd/gen_auth.c b/src/microhttpd/gen_auth.c
index c10e4bee..0a81b167 100644
--- a/src/microhttpd/gen_auth.c
+++ b/src/microhttpd/gen_auth.c
@@ -265,15 +265,6 @@ MHD_get_rq_bauth_params_ (struct MHD_Connection 
*connection)
 
 #ifdef DAUTH_SUPPORT
 
-/**
- * Helper structure to map token name to position where to put token's value
- */
-struct dauth_token_param
-{
-  const struct _MHD_cstr_w_len *const tk_name;
-  struct MHD_RqDAuthParam *const param;
-};
-
 
 /**
  * Get client's Digest Authorization algorithm type.
@@ -407,6 +398,7 @@ parse_dauth_params (const char *str,
                     const size_t str_len,
                     struct MHD_RqDAuth *pdauth)
 {
+  /* The tokens */
   static const struct _MHD_cstr_w_len nonce_tk = _MHD_S_STR_W_LEN ("nonce");
   static const struct _MHD_cstr_w_len opaque_tk = _MHD_S_STR_W_LEN ("opaque");
   static const struct _MHD_cstr_w_len algorithm_tk =
@@ -424,25 +416,47 @@ parse_dauth_params (const char *str,
   static const struct _MHD_cstr_w_len nc_tk = _MHD_S_STR_W_LEN ("nc");
   static const struct _MHD_cstr_w_len userhash_tk =
     _MHD_S_STR_W_LEN ("userhash");
+  /* The locally processed parameters */
   struct MHD_RqDAuthParam userhash;
   struct MHD_RqDAuthParam algorithm;
-  struct dauth_token_param map[] = {
-    {&nonce_tk, &(pdauth->nonce)},
-    {&opaque_tk, &(pdauth->opaque)},
-    {&algorithm_tk, &algorithm},
-    {&response_tk, &(pdauth->response)},
-    {&username_tk, &(pdauth->username)},
-    {&username_ext_tk, &(pdauth->username_ext)},
-    {&realm_tk, &(pdauth->realm)},
-    {&uri_tk, &(pdauth->uri)},
-    {&qop_tk, &(pdauth->qop_raw)},
-    {&cnonce_tk, &(pdauth->cnonce)},
-    {&nc_tk, &(pdauth->nc)},
-    {&userhash_tk, &userhash}
-  };
+  /* Indexes */
   size_t i;
   size_t p;
-
+  /* The list of the tokens.
+     The order of the elements matches the next array. */
+  static const struct _MHD_cstr_w_len *const tk_names[] = {
+    &nonce_tk,          /* 0 */
+    &opaque_tk,         /* 1 */
+    &algorithm_tk,      /* 2 */
+    &response_tk,       /* 3 */
+    &username_tk,       /* 4 */
+    &username_ext_tk,   /* 5 */
+    &realm_tk,          /* 6 */
+    &uri_tk,            /* 7 */
+    &qop_tk,            /* 8 */
+    &cnonce_tk,         /* 9 */
+    &nc_tk,             /* 10 */
+    &userhash_tk        /* 11 */
+  };
+  /* The list of the parameters.
+     The order of the elements matches the previous array. */
+  struct MHD_RqDAuthParam *params[sizeof(tk_names) / sizeof(tk_names[0])];
+
+  params[0 ] = &(pdauth->nonce);           /* 0 */
+  params[1 ] = &(pdauth->opaque);          /* 1 */
+  params[2 ] = &algorithm;                 /* 2 */
+  params[3 ] = &(pdauth->response);        /* 3 */
+  params[4 ] = &(pdauth->username);        /* 4 */
+  params[5 ] = &(pdauth->username_ext);    /* 5 */
+  params[6 ] = &(pdauth->realm);           /* 6 */
+  params[7 ] = &(pdauth->uri);             /* 7 */
+  params[8 ] = &(pdauth->qop_raw);         /* 8 */
+  params[9 ] = &(pdauth->cnonce);          /* 9 */
+  params[10] = &(pdauth->nc);              /* 10 */
+  params[11] = &userhash;                  /* 11 */
+
+  mhd_assert ((sizeof(tk_names) / sizeof(tk_names[0])) == \
+              (sizeof(params) / sizeof(params[0])));
   memset (&userhash, 0, sizeof(userhash));
   memset (&algorithm, 0, sizeof(algorithm));
   i = 0;
@@ -460,28 +474,29 @@ parse_dauth_params (const char *str,
     left = str_len - i;
     if ('=' == str[i])
       return false; /* The equal sign is not allowed as the first character */
-    for (p = 0; p < sizeof(map) / sizeof(map[0]); p++)
+    for (p = 0; p < (sizeof(tk_names) / sizeof(tk_names[0])); ++p)
     {
-      struct dauth_token_param *const aparam = map + p;
-      if ( (aparam->tk_name->len <= left) &&
-           MHD_str_equal_caseless_bin_n_ (str + i, aparam->tk_name->str,
-                                          aparam->tk_name->len) &&
-           ((aparam->tk_name->len == left) ||
-            ('=' == str[i + aparam->tk_name->len]) ||
-            (' ' == str[i + aparam->tk_name->len]) ||
-            ('\t' == str[i + aparam->tk_name->len]) ||
-            (',' == str[i + aparam->tk_name->len]) ||
-            (';' == str[i + aparam->tk_name->len])) )
+      const struct _MHD_cstr_w_len *const tk_name = tk_names[p];
+      struct MHD_RqDAuthParam *const param = params[p];
+      if ( (tk_name->len <= left) &&
+           MHD_str_equal_caseless_bin_n_ (str + i, tk_name->str,
+                                          tk_name->len) &&
+           ((tk_name->len == left) ||
+            ('=' == str[i + tk_name->len]) ||
+            (' ' == str[i + tk_name->len]) ||
+            ('\t' == str[i + tk_name->len]) ||
+            (',' == str[i + tk_name->len]) ||
+            (';' == str[i + tk_name->len])) )
       {
         size_t value_start;
         size_t value_len;
         bool quoted; /* Only mark as "quoted" if backslash-escape used */
 
-        if (aparam->tk_name->len == left)
+        if (tk_name->len == left)
           return false; /* No equal sign after parameter name, broken data */
 
         quoted = false;
-        i += aparam->tk_name->len;
+        i += tk_name->len;
         /* Skip all whitespaces before '=' */
         while (str_len > i && (' ' == str[i] || '\t' == str[i]))
           i++;
@@ -534,14 +549,14 @@ parse_dauth_params (const char *str,
 
         /* Have valid parameter name and value */
         mhd_assert (! quoted || 0 != value_len);
-        aparam->param->value.str = str + value_start;
-        aparam->param->value.len = value_len;
-        aparam->param->quoted = quoted;
+        param->value.str = str + value_start;
+        param->value.len = value_len;
+        param->quoted = quoted;
 
         break; /* Found matching parameter name */
       }
     }
-    if (p == sizeof(map) / sizeof(map[0]))
+    if (p == (sizeof(tk_names) / sizeof(tk_names[0])))
     {
       /* No matching parameter name */
       while (str_len > i && ',' != str[i])
diff --git a/src/tools/perf_replies.c b/src/tools/perf_replies.c
index 38ee701d..91d96030 100644
--- a/src/tools/perf_replies.c
+++ b/src/tools/perf_replies.c
@@ -108,61 +108,6 @@ set_self_name (int argc, char *const *argv)
 }
 
 
-#if defined (HAVE_POPEN) && defined(HAVE_PCLOSE)
-/**
- * Read the command output as a number and return the number.
- * Only positive decimal numbers are supported
- * @param cmd the command to run
- * @return zero or positive number read if success,
- *         negative number if any error occurs
- */
-static int
-get_cmd_out_as_number (const char *cmd)
-{
-  FILE *cmd_out;
-  char buf[255];
-  int ret;
-  size_t len;
-
-  cmd_out = popen (cmd, "r"
-#ifdef _WIN32
-                   "t"
-#endif /* _WIN32 */
-                   );
-  if (NULL == cmd_out)
-    return -1;
-  ret = -1;
-  if (buf != fgets (buf, sizeof(buf), cmd_out))
-    len = 0;
-  else
-    len = strlen (buf);
-  if ((0 != len) && (sizeof(buf) > (len + 2)) && ! ferror (cmd_out))
-  {
-    size_t digits_found;
-    unsigned int out_value;
-    digits_found = mhd_tool_str_to_uint (buf, &out_value);
-    if (0 != digits_found)
-    {
-      if ((0 == buf[digits_found])
-#ifdef _WIN32
-          || ('\r' == buf[digits_found])
-#endif /* _WIN32 */
-          || ('\n' == buf[digits_found]))
-      {
-        ret = (int) out_value; /* Possible negative cast result is interpreted 
as an error */
-      }
-    }
-  }
-  if (0 != pclose (cmd_out))
-    ret = -1;
-  return ret;
-}
-
-
-#else  /* ! HAVE_POPEN || ! HAVE_PCLOSE */
-#define read_cmd_out_as_number(ignore) (-1)
-#endif /* ! HAVE_POPEN || ! HAVE_PCLOSE */
-
 static unsigned int
 detect_cpu_core_count (void)
 {
@@ -1814,21 +1759,24 @@ run_mhd (void)
 
   if (0 != tool_params.connections)
   {
-    struct MHD_OptionItem option =
-    { MHD_OPTION_CONNECTION_LIMIT, (intptr_t) tool_params.connections, NULL };
-    opt_arr[opt_count++] = option;
+    opt_arr[opt_count].option = MHD_OPTION_CONNECTION_LIMIT;
+    opt_arr[opt_count].value = (intptr_t) tool_params.connections;
+    opt_arr[opt_count].ptr_value = NULL;
+    ++opt_count;
   }
   if (1 < use_num_threads)
   {
-    struct MHD_OptionItem option =
-    { MHD_OPTION_THREAD_POOL_SIZE, (intptr_t) use_num_threads, NULL };
-    opt_arr[opt_count++] = option;
+    opt_arr[opt_count].option = MHD_OPTION_THREAD_POOL_SIZE;
+    opt_arr[opt_count].value = (intptr_t) use_num_threads;
+    opt_arr[opt_count].ptr_value = NULL;
+    ++opt_count;
   }
   if (1)
   {
-    struct MHD_OptionItem option =
-    { MHD_OPTION_CONNECTION_TIMEOUT, (intptr_t) tool_params.timeout, NULL };
-    opt_arr[opt_count++] = option;
+    opt_arr[opt_count].option = MHD_OPTION_CONNECTION_TIMEOUT;
+    opt_arr[opt_count].value = (intptr_t) tool_params.timeout;
+    opt_arr[opt_count].ptr_value = NULL;
+    ++opt_count;
   }
   if (1)
   {

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