diff options
author | Christian Grothoff <christian@grothoff.org> | 2007-12-06 01:47:36 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2007-12-06 01:47:36 +0000 |
commit | 82f18e91985a790f7b4abac77e6de801da7bdec9 (patch) | |
tree | 133200e7490ce76a248f3168971878f45c2a316c | |
parent | f3d7e0ac8765ed03f1729f54da074ddafe93f768 (diff) | |
download | libmicrohttpd-82f18e91985a790f7b4abac77e6de801da7bdec9.tar.gz libmicrohttpd-82f18e91985a790f7b4abac77e6de801da7bdec9.zip |
code cleanup
-rw-r--r-- | src/daemon/connection.c | 46 | ||||
-rw-r--r-- | src/daemon/daemon.c | 4 | ||||
-rw-r--r-- | src/daemon/memorypool.c | 8 |
3 files changed, 29 insertions, 29 deletions
diff --git a/src/daemon/connection.c b/src/daemon/connection.c index 2102017d..8217932e 100644 --- a/src/daemon/connection.c +++ b/src/daemon/connection.c | |||
@@ -153,7 +153,7 @@ MHD_queue_response (struct MHD_Connection *connection, | |||
153 | if ((connection == NULL) || | 153 | if ((connection == NULL) || |
154 | (response == NULL) || | 154 | (response == NULL) || |
155 | (connection->response != NULL) || | 155 | (connection->response != NULL) || |
156 | (connection->bodyReceived == 0) || (connection->headersReceived == 0)) | 156 | (connection->bodyReceived == MHD_NO) || (connection->headersReceived == MHD_NO)) |
157 | return MHD_NO; | 157 | return MHD_NO; |
158 | MHD_increment_response_rc (response); | 158 | MHD_increment_response_rc (response); |
159 | connection->response = response; | 159 | connection->response = response; |
@@ -180,7 +180,7 @@ MHD_need_100_continue (struct MHD_Connection *connection) | |||
180 | return ((connection->version != NULL) && | 180 | return ((connection->version != NULL) && |
181 | (0 == strcasecmp (connection->version, | 181 | (0 == strcasecmp (connection->version, |
182 | MHD_HTTP_VERSION_1_1)) && | 182 | MHD_HTTP_VERSION_1_1)) && |
183 | (connection->headersReceived == 1) && | 183 | (connection->headersReceived == MHD_YES) && |
184 | (NULL != (expect = MHD_lookup_connection_value (connection, | 184 | (NULL != (expect = MHD_lookup_connection_value (connection, |
185 | MHD_HEADER_KIND, | 185 | MHD_HEADER_KIND, |
186 | MHD_HTTP_HEADER_EXPECT))) | 186 | MHD_HTTP_HEADER_EXPECT))) |
@@ -279,7 +279,7 @@ MHD_connection_get_fdset (struct MHD_Connection *connection, | |||
279 | if (fd == -1) | 279 | if (fd == -1) |
280 | return MHD_YES; | 280 | return MHD_YES; |
281 | if ((connection->read_close == MHD_NO) && | 281 | if ((connection->read_close == MHD_NO) && |
282 | ((connection->headersReceived == 0) || | 282 | ((connection->headersReceived == MHD_NO) || |
283 | (connection->readLoc < connection->read_buffer_size))) | 283 | (connection->readLoc < connection->read_buffer_size))) |
284 | { | 284 | { |
285 | FD_SET (fd, read_fd_set); | 285 | FD_SET (fd, read_fd_set); |
@@ -289,7 +289,7 @@ MHD_connection_get_fdset (struct MHD_Connection *connection, | |||
289 | else | 289 | else |
290 | { | 290 | { |
291 | if ((connection->read_close == MHD_NO) && | 291 | if ((connection->read_close == MHD_NO) && |
292 | ((connection->headersReceived == 1) && | 292 | ((connection->headersReceived == MHD_YES) && |
293 | (connection->readLoc == connection->read_buffer_size))) | 293 | (connection->readLoc == connection->read_buffer_size))) |
294 | { | 294 | { |
295 | /* try growing the read buffer, just in case */ | 295 | /* try growing the read buffer, just in case */ |
@@ -591,8 +591,8 @@ parse_initial_message_line (struct MHD_Connection *connection, char *line) | |||
591 | * | 591 | * |
592 | * Once the header is complete, it should have set the | 592 | * Once the header is complete, it should have set the |
593 | * headers_received, url and method values and set | 593 | * headers_received, url and method values and set |
594 | * headersReceived to 1. If no body is expected, it should | 594 | * headersReceived to MHD_YES. If no body is expected, it should |
595 | * also set "bodyReceived" to 1. Otherwise, it should | 595 | * also set "bodyReceived" to MHD_YES. Otherwise, it should |
596 | * set "uploadSize" to the expected size of the body. If the | 596 | * set "uploadSize" to the expected size of the body. If the |
597 | * size of the body is unknown, it should be set to -1. | 597 | * size of the body is unknown, it should be set to -1. |
598 | */ | 598 | */ |
@@ -608,7 +608,7 @@ MHD_parse_connection_headers (struct MHD_Connection *connection) | |||
608 | unsigned long long cval; | 608 | unsigned long long cval; |
609 | struct MHD_Response *response; | 609 | struct MHD_Response *response; |
610 | 610 | ||
611 | if (connection->bodyReceived == 1) | 611 | if (connection->bodyReceived == MHD_YES) |
612 | abort (); | 612 | abort (); |
613 | colon = NULL; /* make gcc happy */ | 613 | colon = NULL; /* make gcc happy */ |
614 | last = NULL; | 614 | last = NULL; |
@@ -673,7 +673,7 @@ MHD_parse_connection_headers (struct MHD_Connection *connection) | |||
673 | goto DIE; | 673 | goto DIE; |
674 | } | 674 | } |
675 | connection->uploadSize = cval; | 675 | connection->uploadSize = cval; |
676 | connection->bodyReceived = cval == 0 ? 1 : 0; | 676 | connection->bodyReceived = cval == 0 ? MHD_YES : MHD_NO; |
677 | } | 677 | } |
678 | else | 678 | else |
679 | { | 679 | { |
@@ -683,12 +683,12 @@ MHD_parse_connection_headers (struct MHD_Connection *connection) | |||
683 | { | 683 | { |
684 | /* this request does not have a body */ | 684 | /* this request does not have a body */ |
685 | connection->uploadSize = 0; | 685 | connection->uploadSize = 0; |
686 | connection->bodyReceived = 1; | 686 | connection->bodyReceived = MHD_YES; |
687 | } | 687 | } |
688 | else | 688 | else |
689 | { | 689 | { |
690 | connection->uploadSize = -1; /* unknown size */ | 690 | connection->uploadSize = -1; /* unknown size */ |
691 | connection->bodyReceived = 0; | 691 | connection->bodyReceived = MHD_NO; |
692 | } | 692 | } |
693 | } | 693 | } |
694 | end = MHD_lookup_connection_value (connection, | 694 | end = MHD_lookup_connection_value (connection, |
@@ -796,7 +796,7 @@ MHD_call_connection_handler (struct MHD_Connection *connection) | |||
796 | 796 | ||
797 | if (connection->response != NULL) | 797 | if (connection->response != NULL) |
798 | return; /* already queued a response */ | 798 | return; /* already queued a response */ |
799 | if (connection->headersReceived == 0) | 799 | if (connection->headersReceived == MHD_NO) |
800 | abort (); /* bad timing... */ | 800 | abort (); /* bad timing... */ |
801 | ah = MHD_find_access_handler (connection); | 801 | ah = MHD_find_access_handler (connection); |
802 | processed = connection->readLoc; | 802 | processed = connection->readLoc; |
@@ -827,7 +827,7 @@ MHD_call_connection_handler (struct MHD_Connection *connection) | |||
827 | ((connection->readLoc == 0) && | 827 | ((connection->readLoc == 0) && |
828 | (connection->uploadSize == -1) && (connection->socket_fd == -1))) | 828 | (connection->uploadSize == -1) && (connection->socket_fd == -1))) |
829 | { | 829 | { |
830 | connection->bodyReceived = 1; | 830 | connection->bodyReceived = MHD_YES; |
831 | if (connection->read_buffer != NULL) | 831 | if (connection->read_buffer != NULL) |
832 | MHD_pool_reallocate (connection->pool, | 832 | MHD_pool_reallocate (connection->pool, |
833 | connection->read_buffer, | 833 | connection->read_buffer, |
@@ -864,7 +864,7 @@ MHD_connection_handle_read (struct MHD_Connection *connection) | |||
864 | return MHD_NO; | 864 | return MHD_NO; |
865 | } | 865 | } |
866 | if ((connection->readLoc >= connection->read_buffer_size) && | 866 | if ((connection->readLoc >= connection->read_buffer_size) && |
867 | (connection->headersReceived == 0)) | 867 | (connection->headersReceived == MHD_NO)) |
868 | { | 868 | { |
869 | /* need to grow read buffer */ | 869 | /* need to grow read buffer */ |
870 | tmp = MHD_pool_reallocate (connection->pool, | 870 | tmp = MHD_pool_reallocate (connection->pool, |
@@ -912,7 +912,7 @@ MHD_connection_handle_read (struct MHD_Connection *connection) | |||
912 | { | 912 | { |
913 | /* other side closed connection */ | 913 | /* other side closed connection */ |
914 | connection->read_close = MHD_YES; | 914 | connection->read_close = MHD_YES; |
915 | if ((connection->headersReceived == 1) && (connection->readLoc > 0)) | 915 | if ((connection->headersReceived == MHD_YES) && (connection->readLoc > 0)) |
916 | MHD_call_connection_handler (connection); | 916 | MHD_call_connection_handler (connection); |
917 | #if DEBUG_CLOSE | 917 | #if DEBUG_CLOSE |
918 | #if HAVE_MESSAGES | 918 | #if HAVE_MESSAGES |
@@ -924,9 +924,9 @@ MHD_connection_handle_read (struct MHD_Connection *connection) | |||
924 | return MHD_YES; | 924 | return MHD_YES; |
925 | } | 925 | } |
926 | connection->readLoc += bytes_read; | 926 | connection->readLoc += bytes_read; |
927 | if (connection->headersReceived == 0) | 927 | if (connection->headersReceived == MHD_NO) |
928 | MHD_parse_connection_headers (connection); | 928 | MHD_parse_connection_headers (connection); |
929 | if ((connection->headersReceived == 1) && (connection->method != NULL)) | 929 | if ((connection->headersReceived == MHD_YES) && (connection->method != NULL)) |
930 | MHD_call_connection_handler (connection); | 930 | MHD_call_connection_handler (connection); |
931 | return MHD_YES; | 931 | return MHD_YES; |
932 | } | 932 | } |
@@ -1093,7 +1093,7 @@ MHD_connection_handle_write (struct MHD_Connection *connection) | |||
1093 | #endif | 1093 | #endif |
1094 | return MHD_NO; | 1094 | return MHD_NO; |
1095 | } | 1095 | } |
1096 | if (!connection->headersSent) | 1096 | if (MHD_NO == connection->headersSent) |
1097 | { | 1097 | { |
1098 | if ((connection->write_buffer == NULL) && | 1098 | if ((connection->write_buffer == NULL) && |
1099 | (MHD_NO == MHD_build_header_response (connection))) | 1099 | (MHD_NO == MHD_build_header_response (connection))) |
@@ -1131,7 +1131,7 @@ MHD_connection_handle_write (struct MHD_Connection *connection) | |||
1131 | { | 1131 | { |
1132 | connection->writeLoc = 0; | 1132 | connection->writeLoc = 0; |
1133 | connection->writePos = 0; | 1133 | connection->writePos = 0; |
1134 | connection->headersSent = 1; | 1134 | connection->headersSent = MHD_YES; |
1135 | MHD_pool_reallocate (connection->pool, | 1135 | MHD_pool_reallocate (connection->pool, |
1136 | connection->write_buffer, | 1136 | connection->write_buffer, |
1137 | connection->write_buffer_size, 0); | 1137 | connection->write_buffer_size, 0); |
@@ -1184,8 +1184,8 @@ MHD_connection_handle_write (struct MHD_Connection *connection) | |||
1184 | abort (); /* internal error */ | 1184 | abort (); /* internal error */ |
1185 | if (connection->messagePos == response->total_size) | 1185 | if (connection->messagePos == response->total_size) |
1186 | { | 1186 | { |
1187 | if ((connection->bodyReceived == 0) || | 1187 | if ((connection->bodyReceived == MHD_NO) || |
1188 | (connection->headersReceived == 0)) | 1188 | (connection->headersReceived == MHD_NO)) |
1189 | abort (); /* internal error */ | 1189 | abort (); /* internal error */ |
1190 | MHD_destroy_response (response); | 1190 | MHD_destroy_response (response); |
1191 | if (connection->daemon->notify_completed != NULL) | 1191 | if (connection->daemon->notify_completed != NULL) |
@@ -1199,9 +1199,9 @@ MHD_connection_handle_write (struct MHD_Connection *connection) | |||
1199 | connection->responseCode = 0; | 1199 | connection->responseCode = 0; |
1200 | connection->response = NULL; | 1200 | connection->response = NULL; |
1201 | connection->headers_received = NULL; | 1201 | connection->headers_received = NULL; |
1202 | connection->headersReceived = 0; | 1202 | connection->headersReceived = MHD_NO; |
1203 | connection->headersSent = 0; | 1203 | connection->headersSent = MHD_NO; |
1204 | connection->bodyReceived = 0; | 1204 | connection->bodyReceived = MHD_NO; |
1205 | connection->messagePos = 0; | 1205 | connection->messagePos = 0; |
1206 | connection->method = NULL; | 1206 | connection->method = NULL; |
1207 | connection->url = NULL; | 1207 | connection->url = NULL; |
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c index 326a13b8..e5317c04 100644 --- a/src/daemon/daemon.c +++ b/src/daemon/daemon.c | |||
@@ -218,7 +218,7 @@ MHD_handle_connection (void *data) | |||
218 | (FD_ISSET (con->socket_fd, &ws)) && | 218 | (FD_ISSET (con->socket_fd, &ws)) && |
219 | (MHD_YES != MHD_connection_handle_write (con)))) | 219 | (MHD_YES != MHD_connection_handle_write (con)))) |
220 | break; | 220 | break; |
221 | if ((con->headersReceived == 1) && (con->response == NULL)) | 221 | if ((con->headersReceived == MHD_YES) && (con->response == NULL)) |
222 | MHD_call_connection_handler (con); | 222 | MHD_call_connection_handler (con); |
223 | if ((con->socket_fd != -1) && | 223 | if ((con->socket_fd != -1) && |
224 | ((FD_ISSET (con->socket_fd, &rs)) || | 224 | ((FD_ISSET (con->socket_fd, &rs)) || |
@@ -425,7 +425,7 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon) | |||
425 | continue; | 425 | continue; |
426 | } | 426 | } |
427 | 427 | ||
428 | if ((pos->headersReceived == 1) && (pos->response == NULL)) | 428 | if ((pos->headersReceived == MHD_YES) && (pos->response == NULL)) |
429 | MHD_call_connection_handler (pos); | 429 | MHD_call_connection_handler (pos); |
430 | 430 | ||
431 | prev = pos; | 431 | prev = pos; |
diff --git a/src/daemon/memorypool.c b/src/daemon/memorypool.c index 1721fcfe..6310d7d7 100644 --- a/src/daemon/memorypool.c +++ b/src/daemon/memorypool.c | |||
@@ -54,7 +54,7 @@ struct MemoryPool | |||
54 | unsigned int end; | 54 | unsigned int end; |
55 | 55 | ||
56 | /** | 56 | /** |
57 | * 0 if pool was malloc'ed, 1 if mmapped. | 57 | * MHD_NO if pool was malloc'ed, MHD_YES if mmapped. |
58 | */ | 58 | */ |
59 | int is_mmap; | 59 | int is_mmap; |
60 | }; | 60 | }; |
@@ -82,11 +82,11 @@ MHD_pool_create (unsigned int max) | |||
82 | free (pool); | 82 | free (pool); |
83 | return NULL; | 83 | return NULL; |
84 | } | 84 | } |
85 | pool->is_mmap = 0; | 85 | pool->is_mmap = MHD_NO; |
86 | } | 86 | } |
87 | else | 87 | else |
88 | { | 88 | { |
89 | pool->is_mmap = 1; | 89 | pool->is_mmap = MHD_YES; |
90 | } | 90 | } |
91 | pool->pos = 0; | 91 | pool->pos = 0; |
92 | pool->end = max; | 92 | pool->end = max; |
@@ -102,7 +102,7 @@ MHD_pool_destroy (struct MemoryPool *pool) | |||
102 | { | 102 | { |
103 | if (pool == NULL) | 103 | if (pool == NULL) |
104 | return; | 104 | return; |
105 | if (pool->is_mmap == 0) | 105 | if (pool->is_mmap == MHD_NO) |
106 | free (pool->memory); | 106 | free (pool->memory); |
107 | else | 107 | else |
108 | MUNMAP (pool->memory, pool->size); | 108 | MUNMAP (pool->memory, pool->size); |