doc/examples: do not use non-literals for printf()

This commit is contained in:
Evgeny Grin (Karlson2k)
2022-04-23 16:16:22 +03:00
parent d1c74589fb
commit 28f02d2eaa
3 changed files with 18 additions and 18 deletions
+9 -9
View File
@@ -66,14 +66,14 @@ struct connection_info_struct
};
const char *askpage =
"<html><body>\n\
Upload a file, please!<br>\n\
There are %u clients uploading at the moment.<br>\n\
<form action=\"/filepost\" method=\"post\" enctype=\"multipart/form-data\">\n\
<input name=\"file\" type=\"file\">\n\
<input type=\"submit\" value=\" Send \"></form>\n\
</body></html>";
#define ASKPAGE \
"<html><body>\n" \
"Upload a file, please!<br>\n" \
"There are %u clients uploading at the moment.<br>\n" \
"<form action=\"/filepost\" method=\"post\" enctype=\"multipart/form-data\">\n" \
"<input name=\"file\" type=\"file\">\n" \
"<input type=\"submit\" value=\" Send \"></form>\n" \
"</body></html>"
const char *busypage =
"<html><body>This server is busy, please try again later.</body></html>";
const char *completepage =
@@ -271,7 +271,7 @@ answer_to_connection (void *cls,
snprintf (buffer,
sizeof (buffer),
askpage,
ASKPAGE,
nr_of_uploading_clients);
return send_page (connection,
buffer,
+6 -6
View File
@@ -339,12 +339,12 @@ fill_v1_form (const void *cls,
struct MHD_Connection *connection)
{
enum MHD_Result ret;
const char *form = cls;
char *reply;
struct MHD_Response *response;
(void) cls; /* Unused */
if (-1 == asprintf (&reply,
form,
MAIN_PAGE,
session->value_1))
{
/* oops */
@@ -381,12 +381,12 @@ fill_v1_v2_form (const void *cls,
struct MHD_Connection *connection)
{
enum MHD_Result ret;
const char *form = cls;
char *reply;
struct MHD_Response *response;
(void) cls; /* Unused */
if (-1 == asprintf (&reply,
form,
SECOND_PAGE,
session->value_1,
session->value_2))
{
@@ -446,8 +446,8 @@ not_found_page (const void *cls,
* List of all pages served by this HTTP server.
*/
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, &not_found_page, NULL } /* 404 */
+3 -3
View File
@@ -41,8 +41,8 @@ const char *askpage =
<input type=\"submit\" value=\" Send \"></form>\
</body></html>";
const char *greetingpage =
"<html><body><h1>Welcome, %s!</center></h1></body></html>";
#define GREETINGPAGE \
"<html><body><h1>Welcome, %s!</center></h1></body></html>"
const char *errorpage =
"<html><body>This doesn't seem to be right.</body></html>";
@@ -88,7 +88,7 @@ iterate_post (void *coninfo_cls, enum MHD_ValueKind kind, const char *key,
if (! answerstring)
return MHD_NO;
snprintf (answerstring, MAXANSWERSIZE, greetingpage, data);
snprintf (answerstring, MAXANSWERSIZE, GREETINGPAGE, data);
con_info->answerstring = answerstring;
}
else