Renamed 'con_cls' -> 'req_cls' for access handler callback

The argument is actually request-specific, not connection specific. The
name was confusing.
Fixed related documentation and clarified usage.

Also fixed code where argument named 'unused' was actually used.
This commit is contained in:
Evgeny Grin (Karlson2k)
2022-01-18 15:18:40 +03:00
parent 17c22c2c3b
commit bd41946e8f
105 changed files with 507 additions and 510 deletions
+2 -2
View File
@@ -45,12 +45,12 @@ ahc_echo (void *cls,
const char *method,
const char *version,
const char *upload_data, size_t *upload_data_size,
void **unused)
void **req_cls)
{
struct MHD_Response *response;
enum MHD_Result ret;
(void) cls; (void) url; (void) method; (void) version; /* Unused. Silent compiler warning. */
(void) upload_data; (void) upload_data_size; (void) unused; /* Unused. Silent compiler warning. */
(void) upload_data; (void) upload_data_size; (void) req_cls; /* Unused. Silent compiler warning. */
response = MHD_create_response_from_buffer (0, NULL,
MHD_RESPMEM_PERSISTENT);
+4 -4
View File
@@ -99,7 +99,7 @@ ahc_empty (void *cls,
const char *version,
const char *upload_data,
size_t *upload_data_size,
void **unused)
void **req_cls)
{
static int ptr;
struct MHD_Response *response;
@@ -114,12 +114,12 @@ ahc_empty (void *cls,
if (0 != strcmp ("GET",
method))
return MHD_NO; /* unexpected method */
if (&ptr != *unused)
if (&ptr != *req_cls)
{
*unused = &ptr;
*req_cls = &ptr;
return MHD_YES;
}
*unused = NULL;
*req_cls = NULL;
response = MHD_create_response_from_buffer (0,
NULL,
MHD_RESPMEM_PERSISTENT);
+8 -8
View File
@@ -91,7 +91,7 @@ iovec_ahc (void *cls,
const char *version,
const char *upload_data,
size_t *upload_data_size,
void **ptr)
void **req_cls)
{
static int aptr;
struct MHD_Response *response;
@@ -105,13 +105,13 @@ iovec_ahc (void *cls,
if (0 != strcmp (method, MHD_HTTP_METHOD_GET))
return MHD_NO; /* unexpected method */
if (&aptr != *ptr)
if (&aptr != *req_cls)
{
/* do never respond on first call */
*ptr = &aptr;
*req_cls = &aptr;
return MHD_YES;
}
*ptr = NULL; /* reset when done */
*req_cls = NULL; /* reset when done */
/* Create some test data. */
if (NULL == (data = malloc (TESTSTR_SIZE)))
@@ -248,7 +248,7 @@ ahc_empty (void *cls,
const char *version,
const char *upload_data,
size_t *upload_data_size,
void **unused)
void **req_cls)
{
static int ptr;
struct MHD_Response *response;
@@ -264,12 +264,12 @@ ahc_empty (void *cls,
if (0 != strcmp ("GET",
method))
return MHD_NO; /* unexpected method */
if (&ptr != *unused)
if (&ptr != *req_cls)
{
*unused = &ptr;
*req_cls = &ptr;
return MHD_YES;
}
*unused = NULL;
*req_cls = NULL;
iov.iov_base = NULL;
iov.iov_len = 0;
+4 -4
View File
@@ -46,7 +46,7 @@ ahc_echo (void *cls,
const char *method,
const char *version,
const char *upload_data, size_t *upload_data_size,
void **unused)
void **req_cls)
{
static int ptr;
const char *me = cls;
@@ -56,12 +56,12 @@ ahc_echo (void *cls,
if (0 != strcmp (me, method))
return MHD_NO; /* unexpected method */
if (&ptr != *unused)
if (&ptr != *req_cls)
{
*unused = &ptr;
*req_cls = &ptr;
return MHD_YES;
}
*unused = NULL;
*req_cls = NULL;
response = MHD_create_response_from_buffer (strlen (url),
(void *) url,
MHD_RESPMEM_MUST_COPY);
+3 -3
View File
@@ -47,7 +47,7 @@ static enum MHD_Result
query_session_ahc (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)
size_t *upload_data_size, void **req_cls)
{
struct MHD_Response *response;
enum MHD_Result ret;
@@ -55,9 +55,9 @@ query_session_ahc (void *cls, struct MHD_Connection *connection,
(void) cls; (void) url; (void) method; (void) version; /* Unused. Silent compiler warning. */
(void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */
if (NULL == *ptr)
if (NULL == *req_cls)
{
*ptr = (void *) &query_session_ahc;
*req_cls = (void *) &query_session_ahc;
return MHD_YES;
}
+6 -6
View File
@@ -207,7 +207,7 @@ http_ahc (void *cls,
const char *version,
const char *upload_data,
size_t *upload_data_size,
void **ptr)
void **req_cls)
{
static int aptr;
struct MHD_Response *response;
@@ -217,13 +217,13 @@ http_ahc (void *cls,
if (0 != strcmp (method, MHD_HTTP_METHOD_GET))
return MHD_NO; /* unexpected method */
if (&aptr != *ptr)
if (&aptr != *req_cls)
{
/* do never respond on first call */
*ptr = &aptr;
*req_cls = &aptr;
return MHD_YES;
}
*ptr = NULL; /* reset when done */
*req_cls = NULL; /* reset when done */
response = MHD_create_response_from_buffer (strlen (test_data),
(void *) test_data,
MHD_RESPMEM_PERSISTENT);
@@ -242,7 +242,7 @@ http_dummy_ahc (void *cls,
const char *version,
const char *upload_data,
size_t *upload_data_size,
void **ptr)
void **req_cls)
{
(void) cls;
(void) connection;
@@ -251,7 +251,7 @@ http_dummy_ahc (void *cls,
(void) version; /* Unused. Silent compiler warning. */
(void) upload_data;
(void) upload_data_size;
(void) ptr; /* Unused. Silent compiler warning. */
(void) req_cls; /* Unused. Silent compiler warning. */
return 0;
}
+2 -2
View File
@@ -106,13 +106,13 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx);
enum MHD_Result
http_ahc (void *cls, struct MHD_Connection *connection,
const char *url, const char *method, const char *upload_data,
const char *version, size_t *upload_data_size, void **ptr);
const char *version, size_t *upload_data_size, void **req_cls);
enum MHD_Result
http_dummy_ahc (void *cls, struct MHD_Connection *connection,
const char *url, const char *method, const char *upload_data,
const char *version, size_t *upload_data_size,
void **ptr);
void **req_cls);
/**