diff options
author | Sebastian Gerhardt <sebgerhardt@gmx.net> | 2008-08-14 13:00:44 +0000 |
---|---|---|
committer | Sebastian Gerhardt <sebgerhardt@gmx.net> | 2008-08-14 13:00:44 +0000 |
commit | 63f23d21318034a669b1f40954041d3c1bda8ede (patch) | |
tree | e265319c9a5c8697ec678e8b8896f111fe546fd7 /doc | |
parent | 28f9d1abbea1c85cd73ad6f4a98545e42756f3bd (diff) | |
download | libmicrohttpd-63f23d21318034a669b1f40954041d3c1bda8ede.tar.gz libmicrohttpd-63f23d21318034a669b1f40954041d3c1bda8ede.zip |
improved adherence to GNU coding standards (logging-example)
Diffstat (limited to 'doc')
-rw-r--r-- | doc/examples/logging.c | 25 | ||||
-rw-r--r-- | doc/exploringrequests.inc | 19 |
2 files changed, 21 insertions, 23 deletions
diff --git a/doc/examples/logging.c b/doc/examples/logging.c index 4fc45d12..503e6087 100644 --- a/doc/examples/logging.c +++ b/doc/examples/logging.c | |||
@@ -6,20 +6,19 @@ | |||
6 | #define PORT 8888 | 6 | #define PORT 8888 |
7 | 7 | ||
8 | 8 | ||
9 | int PrintOutKey(void *cls, enum MHD_ValueKind kind, const char *key, const char *value) | 9 | int print_out_key (void *cls, enum MHD_ValueKind kind, const char *key, const char *value) |
10 | { | 10 | { |
11 | printf("%s = %s\n", key, value); | 11 | printf ("%s = %s\n", key, value); |
12 | return MHD_YES; | 12 | return MHD_YES; |
13 | } | 13 | } |
14 | 14 | ||
15 | int AnswerToConnection(void *cls, struct MHD_Connection *connection, const char *url, | 15 | int answer_to_connection(void *cls, struct MHD_Connection *connection, const char *url, |
16 | const char *method, const char *version, const char *upload_data, | 16 | const char *method, const char *version, const char *upload_data, |
17 | unsigned int *upload_data_size, void **con_cls) | 17 | unsigned int *upload_data_size, void **con_cls) |
18 | { | 18 | { |
19 | 19 | printf ("New request %s for %s using version %s\n", method, url, version); | |
20 | printf("New request %s for %s using version %s\n", method, url, version); | ||
21 | 20 | ||
22 | MHD_get_connection_values(connection, MHD_HEADER_KIND, PrintOutKey, NULL); | 21 | MHD_get_connection_values (connection, MHD_HEADER_KIND, print_out_key, NULL); |
23 | 22 | ||
24 | return MHD_NO; | 23 | return MHD_NO; |
25 | } | 24 | } |
@@ -28,12 +27,12 @@ int main () | |||
28 | { | 27 | { |
29 | struct MHD_Daemon *daemon; | 28 | struct MHD_Daemon *daemon; |
30 | 29 | ||
31 | daemon = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY, PORT, NULL, NULL, | 30 | daemon = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY, PORT, NULL, NULL, |
32 | &AnswerToConnection, NULL, MHD_OPTION_END); | 31 | &answer_to_connection, NULL, MHD_OPTION_END); |
33 | if (daemon == NULL) return 1; | 32 | if (NULL == daemon) return 1; |
34 | 33 | ||
35 | getchar(); | 34 | getchar (); |
36 | 35 | ||
37 | MHD_stop_daemon(daemon); | 36 | MHD_stop_daemon (daemon); |
38 | return 0; | 37 | return 0; |
39 | } | 38 | } |
diff --git a/doc/exploringrequests.inc b/doc/exploringrequests.inc index 25a0cd8b..fa471af7 100644 --- a/doc/exploringrequests.inc +++ b/doc/exploringrequests.inc | |||
@@ -9,9 +9,9 @@ just return MHD_NO after we have probed the request. This way, the connection is | |||
9 | without much ado by the server. | 9 | without much ado by the server. |
10 | 10 | ||
11 | @verbatim | 11 | @verbatim |
12 | int AnswerToConnection(void *cls, struct MHD_Connection *connection, | 12 | int answer_to_connection(void *cls, struct MHD_Connection *connection, const char *url, |
13 | const char *url, const char *method, const char *version, | 13 | const char *method, const char *version, const char *upload_data, |
14 | const char *upload_data, unsigned int *upload_data_size, void **con_cls) | 14 | unsigned int *upload_data_size, void **con_cls) |
15 | { | 15 | { |
16 | ... | 16 | ... |
17 | return MHD_NO; | 17 | return MHD_NO; |
@@ -27,7 +27,7 @@ It also contains a string for the version of the protocol which can be found in | |||
27 | To call it a "new request" is justified because we return only @code{MHD_NO}, thus ensuring the | 27 | To call it a "new request" is justified because we return only @code{MHD_NO}, thus ensuring the |
28 | function will not be called again for this connection. | 28 | function will not be called again for this connection. |
29 | @verbatim | 29 | @verbatim |
30 | printf("New request %s for %s using version %s\n", method, url, version); | 30 | printf ("New request %s for %s using version %s\n", method, url, version); |
31 | @end verbatim | 31 | @end verbatim |
32 | @noindent | 32 | @noindent |
33 | 33 | ||
@@ -38,10 +38,9 @@ one until there are no more left. We do this by writing a separate function whic | |||
38 | each pair just like the above function is called for each HTTP request. | 38 | each pair just like the above function is called for each HTTP request. |
39 | It can then print out the content of this pair. | 39 | It can then print out the content of this pair. |
40 | @verbatim | 40 | @verbatim |
41 | int PrintOutKey(void *cls, enum MHD_ValueKind kind, const char *key, | 41 | int print_out_key (void *cls, enum MHD_ValueKind kind, const char *key, const char *value) |
42 | const char *value) | ||
43 | { | 42 | { |
44 | printf("%s = %s\n", key, value); | 43 | printf ("%s = %s\n", key, value); |
45 | return MHD_YES; | 44 | return MHD_YES; |
46 | } | 45 | } |
47 | @end verbatim | 46 | @end verbatim |
@@ -49,7 +48,7 @@ int PrintOutKey(void *cls, enum MHD_ValueKind kind, const char *key, | |||
49 | 48 | ||
50 | To start the iteration process that calls our new function for every key, the line | 49 | To start the iteration process that calls our new function for every key, the line |
51 | @verbatim | 50 | @verbatim |
52 | MHD_get_connection_values(connection, MHD_HEADER_KIND, PrintOutKey, NULL); | 51 | MHD_get_connection_values (connection, MHD_HEADER_KIND, print_out_key, NULL); |
53 | @end verbatim | 52 | @end verbatim |
54 | @noindent | 53 | @noindent |
55 | needs to be inserted in the connection callback function too. The second parameter tells the function | 54 | needs to be inserted in the connection callback function too. The second parameter tells the function |
@@ -89,8 +88,8 @@ returned accompanied by an informative message. | |||
89 | A very interesting information has still been ignored by our logger---the client's IP address. | 88 | A very interesting information has still been ignored by our logger---the client's IP address. |
90 | Implement a callback function | 89 | Implement a callback function |
91 | @verbatim | 90 | @verbatim |
92 | int OnClientConnect(void *cls, | 91 | int on_client_connect (void *cls, |
93 | const struct sockaddr *addr,socklen_t addrlen) | 92 | const struct sockaddr *addr,socklen_t addrlen) |
94 | @end verbatim | 93 | @end verbatim |
95 | @noindent | 94 | @noindent |
96 | that prints out the IP address in an appropriate format. You might want to use the posix function | 95 | that prints out the IP address in an appropriate format. You might want to use the posix function |