gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] 03/04: define and use 'enum MHD_Result' (merge)


From: gnunet
Subject: [libmicrohttpd] 03/04: define and use 'enum MHD_Result' (merge)
Date: Wed, 08 Apr 2020 23:47:29 +0200

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

grothoff pushed a commit to branch master
in repository libmicrohttpd.

commit 89d2ef97322ff5276e9a437e616a1e07529e0b26
Merge: de872dea da058590
Author: Christian Grothoff <address@hidden>
AuthorDate: Wed Apr 8 23:38:07 2020 +0200

    define and use 'enum MHD_Result' (merge)

 ChangeLog                                          |  24 +-
 configure.ac                                       |   8 +-
 contrib/uncrustify_precommit                       |   2 +-
 doc/chapters/basicauthentication.inc               |   4 +-
 doc/chapters/hellobrowser.inc                      |   4 +-
 doc/chapters/introduction.inc                      |   2 +-
 doc/chapters/largerpost.inc                        |   2 +-
 doc/chapters/responseheaders.inc                   |   6 +-
 doc/chapters/tlsauthentication.inc                 |   2 +-
 doc/examples/responseheaders.c                     |   2 +-
 doc/examples/sessions.c                            |   2 +-
 doc/libmicrohttpd.texi                             |   4 +-
 m4/libgcrypt.m4                                    |   2 +-
 m4/mhd_sys_extentions.m4                           |   6 +-
 m4/pkg.m4                                          |   2 +-
 po/libmicrohttpd.pot                               |   2 +-
 src/examples/.gitignore                            |   1 +
 src/examples/Makefile.am                           |  11 +-
 src/examples/demo.c                                |   2 +-
 src/examples/demo_https.c                          |   2 +-
 src/examples/msgs_i18n.c                           |   2 +-
 src/examples/post_example.c                        |   2 +-
 src/examples/websocket_threaded_example.c          | 863 +++++++++++++++++++++
 src/include/microhttpd.h                           |  22 +-
 src/include/microhttpd2.h                          |  16 +-
 src/lib/connection_add.c                           |   2 +-
 src/lib/connection_call_handlers.c                 |   2 +-
 src/lib/daemon_destroy.c                           |   2 +-
 src/lib/daemon_options.c                           |   8 +-
 src/lib/internal.h                                 |   2 +-
 src/microhttpd/connection.c                        |   2 +-
 src/microhttpd/daemon.c                            |   2 +-
 src/microhttpd/digestauth.c                        |   4 +-
 src/microhttpd/internal.h                          |   2 +-
 src/microhttpd/memorypool.h                        |   2 +-
 src/microhttpd/mhd_bithelpers.h                    |  12 +-
 src/microhttpd/mhd_send.c                          |   8 +-
 src/microhttpd/test_md5.c                          |   8 +-
 src/microhttpd/test_sha256.c                       |   8 +-
 src/microhttpd/test_upgrade.c                      |   4 +-
 src/microhttpd/test_upgrade_large.c                |   4 +-
 src/testcurl/https/test_empty_response.c           |   2 +-
 src/testcurl/https/test_https_get_parallel.c       |   4 +-
 .../https/test_https_get_parallel_threads.c        |   6 +-
 src/testcurl/https/tls_test_common.c               |   2 +-
 45 files changed, 980 insertions(+), 101 deletions(-)

diff --cc ChangeLog
index 3ce14755,36c5bdbf..9fede6ae
--- a/ChangeLog
+++ b/ChangeLog
@@@ -1,11 -1,9 +1,17 @@@
 +Wed 08 Apr 2020 10:53:01 PM CEST
 +    Introduce `enum MHD_Result` for #MHD_YES/#MHD_NO to avoid using 'int' so 
much.
 +    Note that this change WILL cause compiler warnings until (most) MHD 
callbacks
 +    in application code change their return type from 'int' to 'enum 
MHD_Result'.
 +    That said, avoiding possible confusions of different enums is going to 
make
 +    the code more robust in the future. For conditional compilation, test
 +    for "MHD_VERSION >= 0x00097002". -CG
 +
+ Tue 07 Apr 2020 02:58:39 PM BRT
+     Fixed #5501 (Added example for how to provide a tiny threaded websocket 
server). -SC
+ 
+ Tue 31 Mar 2020 02:36:40 PM BRT
+     Fixed #6142 (applied several spelling fixes). -DKG/-SC
+ 
  Sat 07 Mar 2020 05:20:33 PM CET
      Fixed #6090 (misc. severe socket handling bugs on OS X). -CG
  
diff --cc doc/examples/responseheaders.c
index 5c0580b6,391f86f6..f1cf939c
--- a/doc/examples/responseheaders.c
+++ b/doc/examples/responseheaders.c
@@@ -41,29 -41,29 +41,29 @@@ answer_to_connection (void *cls, struc
  
    if ( (-1 == (fd = open (FILENAME, O_RDONLY))) ||
         (0 != fstat (fd, &sbuf)) )
 -    {
 -      const char *errorstr =
 -        "<html><body>An internal server error has occurred!\
 +  {
 +    const char *errorstr =
-       "<html><body>An internal server error has occured!\
++      "<html><body>An internal server error has occurred!\
                                </body></html>";
 -      /* error accessing file */
 -      if (fd != -1)
 -      (void) close (fd);
 -      response =
 -      MHD_create_response_from_buffer (strlen (errorstr),
 -                                       (void *) errorstr,
 -                                       MHD_RESPMEM_PERSISTENT);
 -      if (NULL != response)
 -        {
 -          ret =
 -            MHD_queue_response (connection, MHD_HTTP_INTERNAL_SERVER_ERROR,
 -                                response);
 -          MHD_destroy_response (response);
 +    /* error accessing file */
 +    if (fd != -1)
 +      (void) close (fd);
 +    response =
 +      MHD_create_response_from_buffer (strlen (errorstr),
 +                                       (void *) errorstr,
 +                                       MHD_RESPMEM_PERSISTENT);
 +    if (NULL != response)
 +    {
 +      ret =
 +        MHD_queue_response (connection, MHD_HTTP_INTERNAL_SERVER_ERROR,
 +                            response);
 +      MHD_destroy_response (response);
  
 -          return ret;
 -        }
 -      else
 -        return MHD_NO;
 +      return ret;
      }
 +    else
 +      return MHD_NO;
 +  }
    response =
      MHD_create_response_from_fd_at_offset64 (sbuf.st_size, fd, 0);
    MHD_add_response_header (response, "Content-Type", MIMETYPE);
diff --cc doc/examples/sessions.c
index adabc610,139dcbc8..6d6cf5ba
--- a/doc/examples/sessions.c
+++ b/doc/examples/sessions.c
@@@ -557,18 -553,18 +557,18 @@@ post_iterator (void *cls
   *        can be set with the MHD_OPTION_NOTIFY_COMPLETED).
   *        Initially, <tt>*con_cls</tt> will be NULL.
   * @return MHS_YES if the connection was handled successfully,
-  *         MHS_NO if the socket must be closed due to a serios
+  *         MHS_NO if the socket must be closed due to a serious
   *         error while handling the request
   */
 -static int
 +static enum MHD_Result
  create_response (void *cls,
 -               struct MHD_Connection *connection,
 -               const char *url,
 -               const char *method,
 -               const char *version,
 -               const char *upload_data,
 -               size_t *upload_data_size,
 -               void **ptr)
 +                 struct MHD_Connection *connection,
 +                 const char *url,
 +                 const char *method,
 +                 const char *version,
 +                 const char *upload_data,
 +                 size_t *upload_data_size,
 +                 void **ptr)
  {
    struct MHD_Response *response;
    struct Request *request;
diff --cc src/examples/post_example.c
index 55ca3aa8,166d8f22..9f4fbcf9
--- a/src/examples/post_example.c
+++ b/src/examples/post_example.c
@@@ -551,10 -551,10 +551,10 @@@ post_iterator (void *cls
   *        can be set with the MHD_OPTION_NOTIFY_COMPLETED).
   *        Initially, <tt>*con_cls</tt> will be NULL.
   * @return MHS_YES if the connection was handled successfully,
-  *         MHS_NO if the socket must be closed due to a serios
+  *         MHS_NO if the socket must be closed due to a serious
   *         error while handling the request
   */
 -static int
 +static enum MHD_Result
  create_response (void *cls,
                   struct MHD_Connection *connection,
                   const char *url,
diff --cc src/include/microhttpd.h
index f0daa3df,5bf33547..00d4f9bd
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@@ -132,25 -132,17 +132,25 @@@ typedef intptr_t ssize_t
   * Current version of the library.
   * 0x01093001 = 1.9.30-1.
   */
- #define MHD_VERSION 0x00097001
+ #define MHD_VERSION 0x00097002
  
  /**
 - * MHD-internal return code for "YES".
 + * Operational results from MHD calls.
   */
 -#define MHD_YES 1
 +enum MHD_Result
 +{
 +  /**
 +   * MHD result code for "NO".
 +   */
 +  MHD_NO = 0,
 +
 +  /**
 +   * MHD result code for "YES".
 +   */
 +  MHD_YES = 1
 +
 +};
  
 -/**
 - * MHD-internal return code for "NO".
 - */
 -#define MHD_NO 0
  
  /**
   * MHD digest auth internal code for an invalid nonce.
@@@ -2168,18 -2160,18 +2168,18 @@@ typedef enum MHD_Resul
   *        can be set with the #MHD_OPTION_NOTIFY_COMPLETED).
   *        Initially, `*con_cls` will be NULL.
   * @return #MHD_YES if the connection was handled successfully,
-  *         #MHD_NO if the socket must be closed due to a serios
+  *         #MHD_NO if the socket must be closed due to a serious
   *         error while handling the request
   */
 -typedef int
 -(*MHD_AccessHandlerCallback) (void *cls,
 -                              struct MHD_Connection *connection,
 -                              const char *url,
 -                              const char *method,
 -                              const char *version,
 -                              const char *upload_data,
 -                              size_t *upload_data_size,
 -                              void **con_cls);
 +typedef enum MHD_Result
 +(*MHD_AccessHandlerCallback)(void *cls,
 +                             struct MHD_Connection *connection,
 +                             const char *url,
 +                             const char *method,
 +                             const char *version,
 +                             const char *upload_data,
 +                             size_t *upload_data_size,
 +                             void **con_cls);
  
  
  /**
diff --cc src/microhttpd/test_upgrade.c
index b3aecafa,7c76d221..fd9c2537
--- a/src/microhttpd/test_upgrade.c
+++ b/src/microhttpd/test_upgrade.c
@@@ -840,10 -840,10 +840,10 @@@ upgrade_cb (void *cls
   *        can be set with the #MHD_OPTION_NOTIFY_COMPLETED).
   *        Initially, `*con_cls` will be NULL.
   * @return #MHD_YES if the connection was handled successfully,
-  *         #MHD_NO if the socket must be closed due to a serios
+  *         #MHD_NO if the socket must be closed due to a serious
   *         error while handling the request
   */
 -static int
 +static enum MHD_Result
  ahc_upgrade (void *cls,
               struct MHD_Connection *connection,
               const char *url,
diff --cc src/microhttpd/test_upgrade_large.c
index d8d35838,89eba4b7..43c04b7f
--- a/src/microhttpd/test_upgrade_large.c
+++ b/src/microhttpd/test_upgrade_large.c
@@@ -864,10 -864,10 +864,10 @@@ upgrade_cb (void *cls
   *        can be set with the #MHD_OPTION_NOTIFY_COMPLETED).
   *        Initially, `*con_cls` will be NULL.
   * @return #MHD_YES if the connection was handled successfully,
-  *         #MHD_NO if the socket must be closed due to a serios
+  *         #MHD_NO if the socket must be closed due to a serious
   *         error while handling the request
   */
 -static int
 +static enum MHD_Result
  ahc_upgrade (void *cls,
               struct MHD_Connection *connection,
               const char *url,

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



reply via email to

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