diff options
author | Sebastian Gerhardt <sebgerhardt@gmx.net> | 2008-08-13 22:04:28 +0000 |
---|---|---|
committer | Sebastian Gerhardt <sebgerhardt@gmx.net> | 2008-08-13 22:04:28 +0000 |
commit | 480239ed2e343df560ec80b467500beee838360c (patch) | |
tree | 72d5f55fd2e1e73e694ce7e30e747d06e459fe4a /doc | |
parent | 6fb7dc2055f63d5dbf46a3ab6afa118a2c4d15f1 (diff) | |
download | libmicrohttpd-480239ed2e343df560ec80b467500beee838360c.tar.gz libmicrohttpd-480239ed2e343df560ec80b467500beee838360c.zip |
improved adherence to GNU coding standards (Hello, Browser-example)
Diffstat (limited to 'doc')
-rw-r--r-- | doc/examples/hellobrowser.c | 17 | ||||
-rw-r--r-- | doc/hellobrowser.inc | 24 |
2 files changed, 22 insertions, 19 deletions
diff --git a/doc/examples/hellobrowser.c b/doc/examples/hellobrowser.c index a5aa64d6..15cb5788 100644 --- a/doc/examples/hellobrowser.c +++ b/doc/examples/hellobrowser.c | |||
@@ -5,9 +5,9 @@ | |||
5 | 5 | ||
6 | #define PORT 8888 | 6 | #define PORT 8888 |
7 | 7 | ||
8 | int AnswerToConnection(void *cls, struct MHD_Connection *connection, const char *url, | 8 | int answer_to_connection (void *cls, struct MHD_Connection *connection, const char *url, |
9 | const char *method, const char *version, const char *upload_data, | 9 | const char *method, const char *version, const char *upload_data, |
10 | unsigned int *upload_data_size, void **con_cls) | 10 | unsigned int *upload_data_size, void **con_cls) |
11 | { | 11 | { |
12 | const char *page = "<html><body>Hello, browser!</body></html>"; | 12 | const char *page = "<html><body>Hello, browser!</body></html>"; |
13 | struct MHD_Response *response; | 13 | struct MHD_Response *response; |
@@ -16,6 +16,7 @@ int AnswerToConnection(void *cls, struct MHD_Connection *connection, const char | |||
16 | response = MHD_create_response_from_data (strlen (page), (void*) page, MHD_NO, MHD_NO); | 16 | response = MHD_create_response_from_data (strlen (page), (void*) page, MHD_NO, MHD_NO); |
17 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 17 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
18 | MHD_destroy_response (response); | 18 | MHD_destroy_response (response); |
19 | |||
19 | return ret; | 20 | return ret; |
20 | } | 21 | } |
21 | 22 | ||
@@ -23,12 +24,12 @@ int main () | |||
23 | { | 24 | { |
24 | struct MHD_Daemon *daemon; | 25 | struct MHD_Daemon *daemon; |
25 | 26 | ||
26 | daemon = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY, PORT, NULL, NULL, | 27 | daemon = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY, PORT, NULL, NULL, |
27 | &AnswerToConnection, NULL, MHD_OPTION_END); | 28 | &answer_to_connection, NULL, MHD_OPTION_END); |
28 | if (daemon == NULL) return 1; | 29 | if (NULL == daemon) return 1; |
29 | 30 | ||
30 | getchar(); | 31 | getchar (); |
31 | 32 | ||
32 | MHD_stop_daemon(daemon); | 33 | MHD_stop_daemon (daemon); |
33 | return 0; | 34 | return 0; |
34 | } | 35 | } |
diff --git a/doc/hellobrowser.inc b/doc/hellobrowser.inc index 552846f1..0513a674 100644 --- a/doc/hellobrowser.inc +++ b/doc/hellobrowser.inc | |||
@@ -35,9 +35,9 @@ daemon to sent the reply. | |||
35 | 35 | ||
36 | Talking about the reply, it is defined as a string right after the function header | 36 | Talking about the reply, it is defined as a string right after the function header |
37 | @verbatim | 37 | @verbatim |
38 | int AnswerToConnection(void *cls, struct MHD_Connection *connection, | 38 | int answer_to_connection (void *cls, struct MHD_Connection *connection, const char *url, |
39 | const char *url, const char *method, const char *version, | 39 | const char *method, const char *version, const char *upload_data, |
40 | const char *upload_data, unsigned int *upload_data_size, void **con_cls) | 40 | unsigned int *upload_data_size, void **con_cls) |
41 | { | 41 | { |
42 | const char *page = "<html><body>Hello, browser!</body></html>"; | 42 | const char *page = "<html><body>Hello, browser!</body></html>"; |
43 | @end verbatim | 43 | @end verbatim |
@@ -55,8 +55,8 @@ no internal copy to be done because the @emph{constant} string won't change anyw | |||
55 | struct MHD_Response *response; | 55 | struct MHD_Response *response; |
56 | int ret; | 56 | int ret; |
57 | 57 | ||
58 | response = MHD_create_response_from_data(strlen(page), | 58 | response = MHD_create_response_from_data (strlen (page), |
59 | (void*)page, MHD_NO, MHD_NO); | 59 | (void*) page, MHD_NO, MHD_NO); |
60 | @end verbatim | 60 | @end verbatim |
61 | @noindent | 61 | @noindent |
62 | Now that the the response has been laced up, it is ready for delivery and can be queued for sending. | 62 | Now that the the response has been laced up, it is ready for delivery and can be queued for sending. |
@@ -72,6 +72,7 @@ already being set at this point to either MHD_YES or MHD_NO in case of success o | |||
72 | @verbatim | 72 | @verbatim |
73 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 73 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
74 | MHD_destroy_response (response); | 74 | MHD_destroy_response (response); |
75 | |||
75 | return ret; | 76 | return ret; |
76 | } | 77 | } |
77 | @end verbatim | 78 | @end verbatim |
@@ -81,11 +82,11 @@ on @code{PORT} for connections. This is done in the main function. | |||
81 | @verbatim | 82 | @verbatim |
82 | int main () | 83 | int main () |
83 | { | 84 | { |
84 | struct MHD_Daemon *d; | 85 | struct MHD_Daemon *daemon; |
85 | 86 | ||
86 | d = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY, PORT, NULL, NULL, | 87 | daemon = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY, PORT, NULL, NULL, |
87 | &AnswerToConnection, NULL, MHD_OPTION_END); | 88 | &answer_to_connection, NULL, MHD_OPTION_END); |
88 | if (d == NULL) return 1; | 89 | if (NULL == daemon) return 1; |
89 | @end verbatim | 90 | @end verbatim |
90 | @noindent | 91 | @noindent |
91 | The first parameter is one of three possible modes of operation. Here we want the daemon to run in | 92 | The first parameter is one of three possible modes of operation. Here we want the daemon to run in |
@@ -107,11 +108,12 @@ main thread or else the program will terminate prematurely. We let it pause in a | |||
107 | friendly manner by waiting for the enter key to be pressed. In the end, we stop the daemon so it can | 108 | friendly manner by waiting for the enter key to be pressed. In the end, we stop the daemon so it can |
108 | do its cleanup tasks. | 109 | do its cleanup tasks. |
109 | @verbatim | 110 | @verbatim |
110 | getchar(); | 111 | getchar (); |
111 | 112 | ||
112 | MHD_stop_daemon(d); | 113 | MHD_stop_daemon (daemon); |
113 | return 0; | 114 | return 0; |
114 | } | 115 | } |
116 | |||
115 | @end verbatim | 117 | @end verbatim |
116 | @noindent | 118 | @noindent |
117 | The first example is now complete. | 119 | The first example is now complete. |