[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r31647 - in libmicrohttpd: . src/examples
From: |
gnunet |
Subject: |
[GNUnet-SVN] r31647 - in libmicrohttpd: . src/examples |
Date: |
Sat, 21 Dec 2013 17:27:07 +0100 |
Author: grothoff
Date: 2013-12-21 17:27:06 +0100 (Sat, 21 Dec 2013)
New Revision: 31647
Modified:
libmicrohttpd/ChangeLog
libmicrohttpd/src/examples/post_example.c
Log:
-fix postexample
Modified: libmicrohttpd/ChangeLog
===================================================================
--- libmicrohttpd/ChangeLog 2013-12-21 15:12:07 UTC (rev 31646)
+++ libmicrohttpd/ChangeLog 2013-12-21 16:27:06 UTC (rev 31647)
@@ -1,5 +1,10 @@
+Sat Dec 21 17:26:08 CET 2013
+ Fixed an issue with a missing argument in the postexample.
+ Fixed issue with bogus offset increment involving sendfile
+ on GNU/Linux.
+
Mon Dec 9 21:41:57 CET 2013
- Fix for per-worker daemon pipes enabled with
+ Fix for per-worker daemon pipes enabled with
MHD_USE_SUSPEND_RESUME that were not closed in
MHD_stop_daemon. -MH
Modified: libmicrohttpd/src/examples/post_example.c
===================================================================
--- libmicrohttpd/src/examples/post_example.c 2013-12-21 15:12:07 UTC (rev
31646)
+++ libmicrohttpd/src/examples/post_example.c 2013-12-21 16:27:06 UTC (rev
31647)
@@ -76,7 +76,7 @@
struct Session *next;
/**
- * Unique ID for this session.
+ * Unique ID for this session.
*/
char sid[33];
@@ -122,7 +122,7 @@
struct MHD_PostProcessor *pp;
/**
- * URL to serve in response to this POST (if this request
+ * URL to serve in response to this POST (if this request
* was a 'POST')
*/
const char *post_url;
@@ -140,7 +140,7 @@
/**
- * Return the session handle for this connection, or
+ * Return the session handle for this connection, or
* create one if this is a new user.
*/
static struct Session *
@@ -171,9 +171,9 @@
/* create fresh session */
ret = calloc (1, sizeof (struct Session));
if (NULL == ret)
- {
+ {
fprintf (stderr, "calloc error: %s\n", strerror (errno));
- return NULL;
+ return NULL;
}
/* not a super-secure way to generate a random session ID,
but should do for a simple example... */
@@ -184,7 +184,7 @@
(unsigned int) rand (),
(unsigned int) rand (),
(unsigned int) rand ());
- ret->rc++;
+ ret->rc++;
ret->start = time (NULL);
ret->next = sessions;
sessions = ret;
@@ -209,7 +209,7 @@
/**
* Entry we generate for each page served.
- */
+ */
struct Page
{
/**
@@ -229,7 +229,7 @@
/**
* Extra argument to handler.
- */
+ */
const void *handler_cls;
};
@@ -239,7 +239,7 @@
*
* @param session session to use
* @param response response to modify
- */
+ */
static void
add_session_cookie (struct Session *session,
struct MHD_Response *response)
@@ -250,12 +250,12 @@
"%s=%s",
COOKIE_NAME,
session->sid);
- if (MHD_NO ==
+ if (MHD_NO ==
MHD_add_response_header (response,
MHD_HTTP_HEADER_SET_COOKIE,
cstr))
{
- fprintf (stderr,
+ fprintf (stderr,
"Failed to set session cookie header!\n");
}
}
@@ -267,7 +267,7 @@
*
* @param cls a 'const char *' with the HTML webpage to return
* @param mime mime type to use
- * @param session session handle
+ * @param session session handle
* @param connection connection to use
*/
static int
@@ -290,8 +290,8 @@
MHD_add_response_header (response,
MHD_HTTP_HEADER_CONTENT_ENCODING,
mime);
- ret = MHD_queue_response (connection,
- MHD_HTTP_OK,
+ ret = MHD_queue_response (connection,
+ MHD_HTTP_OK,
response);
MHD_destroy_response (response);
return ret;
@@ -301,9 +301,9 @@
/**
* Handler that adds the 'v1' value to the given HTML code.
*
- * @param cls a 'const char *' with the HTML webpage to return
+ * @param cls unused
* @param mime mime type to use
- * @param session session handle
+ * @param session session handle
* @param connection connection to use
*/
static int
@@ -313,16 +313,15 @@
struct MHD_Connection *connection)
{
int ret;
- const char *form = cls;
char *reply;
struct MHD_Response *response;
- reply = malloc (strlen (form) + strlen (session->value_1) + 1);
+ reply = malloc (strlen (MAIN_PAGE) + strlen (session->value_1) + 1);
if (NULL == reply)
return MHD_NO;
snprintf (reply,
- strlen (form) + strlen (session->value_1) + 1,
- form,
+ strlen (MAIN_PAGE) + strlen (session->value_1) + 1,
+ MAIN_PAGE,
session->value_1);
/* return static form */
response = MHD_create_response_from_buffer (strlen (reply),
@@ -334,8 +333,8 @@
MHD_add_response_header (response,
MHD_HTTP_HEADER_CONTENT_ENCODING,
mime);
- ret = MHD_queue_response (connection,
- MHD_HTTP_OK,
+ ret = MHD_queue_response (connection,
+ MHD_HTTP_OK,
response);
MHD_destroy_response (response);
return ret;
@@ -345,9 +344,9 @@
/**
* Handler that adds the 'v1' and 'v2' values to the given HTML code.
*
- * @param cls a 'const char *' with the HTML webpage to return
+ * @param cls unused
* @param mime mime type to use
- * @param session session handle
+ * @param session session handle
* @param connection connection to use
*/
static int
@@ -357,17 +356,17 @@
struct MHD_Connection *connection)
{
int ret;
- const char *form = cls;
char *reply;
struct MHD_Response *response;
- reply = malloc (strlen (form) + strlen (session->value_1) + strlen
(session->value_2) + 1);
+ reply = malloc (strlen (SECOND_PAGE) + strlen (session->value_1) + strlen
(session->value_2) + 1);
if (NULL == reply)
return MHD_NO;
snprintf (reply,
- strlen (form) + strlen (session->value_1) + strlen
(session->value_2) + 1,
- form,
- session->value_1);
+ strlen (SECOND_PAGE) + strlen (session->value_1) + strlen
(session->value_2) + 1,
+ SECOND_PAGE,
+ session->value_1,
+ session->value_2);
/* return static form */
response = MHD_create_response_from_buffer (strlen (reply),
(void *) reply,
@@ -378,8 +377,8 @@
MHD_add_response_header (response,
MHD_HTTP_HEADER_CONTENT_ENCODING,
mime);
- ret = MHD_queue_response (connection,
- MHD_HTTP_OK,
+ ret = MHD_queue_response (connection,
+ MHD_HTTP_OK,
response);
MHD_destroy_response (response);
return ret;
@@ -391,7 +390,7 @@
*
* @param cls a 'const char *' with the HTML webpage to return
* @param mime mime type to use
- * @param session session handle
+ * @param session session handle
* @param connection connection to use
*/
static int
@@ -409,8 +408,8 @@
MHD_RESPMEM_PERSISTENT);
if (NULL == response)
return MHD_NO;
- ret = MHD_queue_response (connection,
- MHD_HTTP_NOT_FOUND,
+ ret = MHD_queue_response (connection,
+ MHD_HTTP_NOT_FOUND,
response);
MHD_add_response_header (response,
MHD_HTTP_HEADER_CONTENT_ENCODING,
@@ -423,10 +422,10 @@
/**
* List of all pages served by this HTTP server.
*/
-static struct Page pages[] =
+static struct Page pages[] =
{
- { "/", "text/html", &fill_v1_form, MAIN_PAGE },
- { "/2", "text/html", &fill_v1_v2_form, SECOND_PAGE },
+ { "/", "text/html", &fill_v1_form, NULL },
+ { "/2", "text/html", &fill_v1_v2_form, NULL },
{ "/S", "text/html", &serve_simple_form, SUBMIT_PAGE },
{ "/F", "text/html", &serve_simple_form, LAST_PAGE },
{ NULL, NULL, ¬_found_page, NULL } /* 404 */
@@ -476,27 +475,27 @@
}
if (0 == strcmp ("v1", key))
{
- if (size + off > sizeof(session->value_1))
- size = sizeof (session->value_1) - off;
+ if (size + off >= sizeof(session->value_1))
+ size = sizeof (session->value_1) - off - 1;
memcpy (&session->value_1[off],
data,
size);
- if (size + off < sizeof (session->value_1))
- session->value_1[size+off] = '\0';
+ session->value_1[size+off] = '\0';
return MHD_YES;
}
if (0 == strcmp ("v2", key))
{
- if (size + off > sizeof(session->value_2))
- size = sizeof (session->value_2) - off;
+ if (size + off >= sizeof(session->value_2))
+ size = sizeof (session->value_2) - off - 1;
memcpy (&session->value_2[off],
data,
size);
- if (size + off < sizeof (session->value_2))
- session->value_2[size+off] = '\0';
+ session->value_2[size+off] = '\0';
return MHD_YES;
}
- fprintf (stderr, "Unsupported form value `%s'\n", key);
+ fprintf (stderr,
+ "Unsupported form value `%s'\n",
+ key);
return MHD_YES;
}
@@ -540,7 +539,7 @@
const char *url,
const char *method,
const char *version,
- const char *upload_data,
+ const char *upload_data,
size_t *upload_data_size,
void **ptr)
{
@@ -586,7 +585,7 @@
session = request->session;
session->start = time (NULL);
if (0 == strcmp (method, MHD_HTTP_METHOD_POST))
- {
+ {
/* evaluate POST data */
MHD_post_process (request->pp,
upload_data,
@@ -612,7 +611,7 @@
while ( (pages[i].url != NULL) &&
(0 != strcmp (pages[i].url, url)) )
i++;
- ret = pages[i].handler (pages[i].handler_cls,
+ ret = pages[i].handler (pages[i].handler_cls,
pages[i].mime,
session, connection);
if (ret != MHD_YES)
@@ -624,8 +623,8 @@
response = MHD_create_response_from_buffer (strlen (METHOD_ERROR),
(void *) METHOD_ERROR,
MHD_RESPMEM_PERSISTENT);
- ret = MHD_queue_response (connection,
- MHD_HTTP_METHOD_NOT_ACCEPTABLE,
+ ret = MHD_queue_response (connection,
+ MHD_HTTP_METHOD_NOT_ACCEPTABLE,
response);
MHD_destroy_response (response);
return ret;
@@ -689,7 +688,7 @@
else
prev = pos;
pos = next;
- }
+ }
}
@@ -718,8 +717,8 @@
srand ((unsigned int) time (NULL));
d = MHD_start_daemon (MHD_USE_DEBUG,
atoi (argv[1]),
- NULL, NULL,
- &create_response, NULL,
+ NULL, NULL,
+ &create_response, NULL,
MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 15,
MHD_OPTION_NOTIFY_COMPLETED,
&request_completed_callback, NULL,
MHD_OPTION_END);
@@ -734,11 +733,11 @@
FD_ZERO (&es);
if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max))
break; /* fatal internal error */
- if (MHD_get_timeout (d, &mhd_timeout) == MHD_YES)
+ if (MHD_get_timeout (d, &mhd_timeout) == MHD_YES)
{
tv.tv_sec = mhd_timeout / 1000;
tv.tv_usec = (mhd_timeout - (tv.tv_sec * 1000)) * 1000;
- tvp = &tv;
+ tvp = &tv;
}
else
tvp = NULL;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r31647 - in libmicrohttpd: . src/examples,
gnunet <=