diff --git a/ChangeLog b/ChangeLog index ca0a8847..3ce14755 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ Wed 08 Apr 2020 10:53:01 PM CEST - Introduce `enum MHD_Result` for #MHD_YES/#MHD_NO to avoid using 'int' so much. -CG + 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 Sat 07 Mar 2020 05:20:33 PM CET Fixed #6090 (misc. severe socket handling bugs on OS X). -CG diff --git a/doc/examples/basicauthentication.c b/doc/examples/basicauthentication.c index 88cb79b7..5d156f04 100644 --- a/doc/examples/basicauthentication.c +++ b/doc/examples/basicauthentication.c @@ -17,7 +17,7 @@ #define PORT 8888 -static int +static enum MHD_Result answer_to_connection (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, @@ -28,45 +28,47 @@ answer_to_connection (void *cls, struct MHD_Connection *connection, int fail; int ret; struct MHD_Response *response; - (void)cls; /* Unused. Silent compiler warning. */ - (void)url; /* Unused. Silent compiler warning. */ - (void)version; /* Unused. Silent compiler warning. */ - (void)upload_data; /* Unused. Silent compiler warning. */ - (void)upload_data_size; /* Unused. Silent compiler warning. */ + (void) cls; /* Unused. Silent compiler warning. */ + (void) url; /* Unused. Silent compiler warning. */ + (void) version; /* Unused. Silent compiler warning. */ + (void) upload_data; /* Unused. Silent compiler warning. */ + (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (method, "GET")) return MHD_NO; if (NULL == *con_cls) - { - *con_cls = connection; - return MHD_YES; - } + { + *con_cls = connection; + return MHD_YES; + } pass = NULL; user = MHD_basic_auth_get_username_password (connection, &pass); fail = ( (NULL == user) || - (0 != strcmp (user, "root")) || - (0 != strcmp (pass, "pa$$w0rd") ) ); - if (NULL != user) MHD_free (user); - if (NULL != pass) MHD_free (pass); + (0 != strcmp (user, "root")) || + (0 != strcmp (pass, "pa$$w0rd") ) ); + if (NULL != user) + MHD_free (user); + if (NULL != pass) + MHD_free (pass); if (fail) - { - const char *page = "
Go away."; - response = - MHD_create_response_from_buffer (strlen (page), (void *) page, - MHD_RESPMEM_PERSISTENT); - ret = MHD_queue_basic_auth_fail_response (connection, - "my realm", - response); - } + { + const char *page = "Go away."; + response = + MHD_create_response_from_buffer (strlen (page), (void *) page, + MHD_RESPMEM_PERSISTENT); + ret = MHD_queue_basic_auth_fail_response (connection, + "my realm", + response); + } else - { - const char *page = "A secret."; - response = - MHD_create_response_from_buffer (strlen (page), (void *) page, - MHD_RESPMEM_PERSISTENT); - ret = MHD_queue_response (connection, MHD_HTTP_OK, response); - } + { + const char *page = "A secret."; + response = + MHD_create_response_from_buffer (strlen (page), (void *) page, + MHD_RESPMEM_PERSISTENT); + ret = MHD_queue_response (connection, MHD_HTTP_OK, response); + } MHD_destroy_response (response); return ret; } diff --git a/doc/examples/hellobrowser.c b/doc/examples/hellobrowser.c index dce4ee6d..0c13c24d 100644 --- a/doc/examples/hellobrowser.c +++ b/doc/examples/hellobrowser.c @@ -14,7 +14,7 @@ #define PORT 8888 -static int +static enum MHD_Result answer_to_connection (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, @@ -22,18 +22,18 @@ answer_to_connection (void *cls, struct MHD_Connection *connection, { const char *page = "Hello, browser!"; struct MHD_Response *response; - int ret; - (void)cls; /* Unused. Silent compiler warning. */ - (void)url; /* Unused. Silent compiler warning. */ - (void)method; /* Unused. Silent compiler warning. */ - (void)version; /* Unused. Silent compiler warning. */ - (void)upload_data; /* Unused. Silent compiler warning. */ - (void)upload_data_size; /* Unused. Silent compiler warning. */ - (void)con_cls; /* Unused. Silent compiler warning. */ + enum MHD_Result ret; + (void) cls; /* Unused. Silent compiler warning. */ + (void) url; /* Unused. Silent compiler warning. */ + (void) method; /* Unused. Silent compiler warning. */ + (void) version; /* Unused. Silent compiler warning. */ + (void) upload_data; /* Unused. Silent compiler warning. */ + (void) upload_data_size; /* Unused. Silent compiler warning. */ + (void) con_cls; /* Unused. Silent compiler warning. */ response = - MHD_create_response_from_buffer (strlen (page), (void *) page, - MHD_RESPMEM_PERSISTENT); + MHD_create_response_from_buffer (strlen (page), (void *) page, + MHD_RESPMEM_PERSISTENT); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); @@ -46,7 +46,8 @@ main (void) { struct MHD_Daemon *daemon; - daemon = MHD_start_daemon (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD, PORT, NULL, NULL, + daemon = MHD_start_daemon (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD, + PORT, NULL, NULL, &answer_to_connection, NULL, MHD_OPTION_END); if (NULL == daemon) return 1; diff --git a/doc/examples/largepost.c b/doc/examples/largepost.c index 8ef7c9fe..8618209f 100644 --- a/doc/examples/largepost.c +++ b/doc/examples/largepost.c @@ -15,11 +15,11 @@ #ifdef _MSC_VER #ifndef strcasecmp -#define strcasecmp(a,b) _stricmp((a),(b)) +#define strcasecmp(a,b) _stricmp ((a),(b)) #endif /* !strcasecmp */ #endif /* _MSC_VER */ -#if defined(_MSC_VER) && _MSC_VER+0 <= 1800 +#if defined(_MSC_VER) && _MSC_VER + 0 <= 1800 /* Substitution is OK while return value is not used */ #define snprintf _snprintf #endif @@ -29,10 +29,10 @@ #define MAXCLIENTS 2 enum ConnectionType - { - GET = 0, - POST = 1 - }; +{ + GET = 0, + POST = 1 +}; static unsigned int nr_of_uploading_clients = 0; @@ -66,7 +66,8 @@ struct connection_info_struct }; -const char *askpage = "\n\ +const char *askpage = + "\n\ Upload a file, please!