libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 28f02d2eaa30c08743d95565fe7404cba17b3955
parent d1c74589fba965e9e1f5fc1479a3a3d5a4cfe00a
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Sat, 23 Apr 2022 16:16:22 +0300

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

Diffstat:
Mdoc/examples/largepost.c | 18+++++++++---------
Mdoc/examples/sessions.c | 12++++++------
Mdoc/examples/simplepost.c | 6+++---
3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/doc/examples/largepost.c b/doc/examples/largepost.c @@ -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, diff --git a/doc/examples/sessions.c b/doc/examples/sessions.c @@ -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 */ diff --git a/doc/examples/simplepost.c b/doc/examples/simplepost.c @@ -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