aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-06-27 14:41:35 +0000
committerChristian Grothoff <christian@grothoff.org>2013-06-27 14:41:35 +0000
commitfe8202d39c32032b68a7a6760651c843b2e3e16d (patch)
treecc92301b6c92767d65912c24d5b9accb4361efc1 /src
parent79f2eea2629367ca402671cf7d033e52de0f9e8a (diff)
downloadlibmicrohttpd-fe8202d39c32032b68a7a6760651c843b2e3e16d.tar.gz
libmicrohttpd-fe8202d39c32032b68a7a6760651c843b2e3e16d.zip
-fixing misc minor bugs and compiler warnings in libmicrospdy
Diffstat (limited to 'src')
-rw-r--r--src/examples/spdy_event_loop.c36
-rw-r--r--src/examples/spdy_response_with_callback.c17
-rw-r--r--src/include/microspdy.h24
-rw-r--r--src/microspdy/applicationlayer.c10
-rw-r--r--src/microspdy/daemon.c18
-rw-r--r--src/microspdy/session.c2
-rw-r--r--src/microspdy/structures.c13
-rw-r--r--src/spdy2http/proxy.c50
8 files changed, 108 insertions, 62 deletions
diff --git a/src/examples/spdy_event_loop.c b/src/examples/spdy_event_loop.c
index e5bac293..a716028f 100644
--- a/src/examples/spdy_event_loop.c
+++ b/src/examples/spdy_event_loop.c
@@ -41,15 +41,17 @@
41//#include "../framinglayer/structures.h" 41//#include "../framinglayer/structures.h"
42//#include "../applicationlayer/alstructures.h" 42//#include "../applicationlayer/alstructures.h"
43 43
44int run = 1; 44static int run = 1;
45int run2 = 1; 45
46static int run2 = 1;
46 47
47 48
48 uint64_t loops; 49static uint64_t loops;
49 time_t start;
50 50
51static time_t start;
51 52
52void 53
54static void
53new_session_callback (void *cls, 55new_session_callback (void *cls,
54 struct SPDY_Session * session) 56 struct SPDY_Session * session)
55{ 57{
@@ -88,7 +90,8 @@ new_session_callback (void *cls,
88 } 90 }
89} 91}
90 92
91void 93
94static void
92session_closed_handler (void *cls, 95session_closed_handler (void *cls,
93 struct SPDY_Session * session, 96 struct SPDY_Session * session,
94 int by_client) 97 int by_client)
@@ -108,7 +111,8 @@ session_closed_handler (void *cls,
108 //session_closed_called = 1; 111 //session_closed_called = 1;
109} 112}
110 113
111void 114
115static void
112response_done_callback(void *cls, 116response_done_callback(void *cls,
113 struct SPDY_Response *response, 117 struct SPDY_Response *response,
114 struct SPDY_Request *request, 118 struct SPDY_Request *request,
@@ -135,7 +139,8 @@ response_done_callback(void *cls,
135 free(cls); 139 free(cls);
136} 140}
137 141
138int 142
143static int
139print_headers (void *cls, 144print_headers (void *cls,
140 const char *name, const char *value) 145 const char *name, const char *value)
141{ 146{
@@ -163,11 +168,12 @@ new_request_cb (void *cls,
163} 168}
164*/ 169*/
165 170
166int 171
172static int
167append_headers_to_data (void *cls, 173append_headers_to_data (void *cls,
168 const char *name, const char **value, int num_values) 174 const char *name, const char * const *value, int num_values)
169{ 175{
170 char **data = (char **)cls; 176 char **data = cls;
171 void *tofree = *data; 177 void *tofree = *data;
172 int i; 178 int i;
173 179
@@ -183,7 +189,8 @@ append_headers_to_data (void *cls,
183 return SPDY_YES; 189 return SPDY_YES;
184} 190}
185 191
186void 192
193static void
187standard_request_handler(void *cls, 194standard_request_handler(void *cls,
188 struct SPDY_Request * request, 195 struct SPDY_Request * request,
189 uint8_t priority, 196 uint8_t priority,
@@ -251,11 +258,14 @@ standard_request_handler(void *cls,
251 } 258 }
252} 259}
253 260
254void sig_handler(int signo) 261
262static void
263sig_handler(int signo)
255{ 264{
256 printf("received signal\n"); 265 printf("received signal\n");
257} 266}
258 267
268
259int 269int
260main (int argc, char *const *argv) 270main (int argc, char *const *argv)
261{ 271{
diff --git a/src/examples/spdy_response_with_callback.c b/src/examples/spdy_response_with_callback.c
index 14517ad1..21085c78 100644
--- a/src/examples/spdy_response_with_callback.c
+++ b/src/examples/spdy_response_with_callback.c
@@ -32,10 +32,10 @@
32#include <errno.h> 32#include <errno.h>
33#include "microspdy.h" 33#include "microspdy.h"
34 34
35int run = 1; 35static int run = 1;
36 36
37 37
38ssize_t 38static ssize_t
39response_callback (void *cls, 39response_callback (void *cls,
40 void *buffer, 40 void *buffer,
41 size_t max, 41 size_t max,
@@ -53,11 +53,12 @@ response_callback (void *cls,
53} 53}
54 54
55 55
56void 56static void
57response_done_callback(void *cls, 57response_done_callback(void *cls,
58 struct SPDY_Response *response, 58 struct SPDY_Response *response,
59 struct SPDY_Request *request, 59 struct SPDY_Request *request,
60 bool streamopened) 60 enum SPDY_RESPONSE_RESULT status,
61 bool streamopened)
61{ 62{
62 (void)streamopened; 63 (void)streamopened;
63 printf("answer for %s was sent\n", (char *)cls); 64 printf("answer for %s was sent\n", (char *)cls);
@@ -67,7 +68,8 @@ response_done_callback(void *cls,
67 free(cls); 68 free(cls);
68} 69}
69 70
70void 71
72static void
71standard_request_handler(void *cls, 73standard_request_handler(void *cls,
72 struct SPDY_Request * request, 74 struct SPDY_Request * request,
73 uint8_t priority, 75 uint8_t priority,
@@ -141,6 +143,7 @@ standard_request_handler(void *cls,
141 } 143 }
142} 144}
143 145
146
144int 147int
145main (int argc, char *const *argv) 148main (int argc, char *const *argv)
146{ 149{
diff --git a/src/include/microspdy.h b/src/include/microspdy.h
index ac9123b8..645d9343 100644
--- a/src/include/microspdy.h
+++ b/src/include/microspdy.h
@@ -51,6 +51,30 @@
51#include <zlib.h> 51#include <zlib.h>
52#include <stdbool.h> 52#include <stdbool.h>
53 53
54/* While we generally would like users to use a configure-driven
55 build process which detects which headers are present and
56 hence works on any platform, we use "standard" includes here
57 to build out-of-the-box for beginning users on common systems.
58
59 Once you have a proper build system and go for more exotic
60 platforms, you should define MHD_PLATFORM_H in some header that
61 you always include *before* "microhttpd.h". Then the following
62 "standard" includes won't be used (which might be a good
63 idea, especially on platforms where they do not exist). */
64#ifndef MHD_PLATFORM_H
65#include <unistd.h>
66#include <stdarg.h>
67#include <stdint.h>
68#ifdef __MINGW32__
69#include <ws2tcpip.h>
70#else
71#include <sys/time.h>
72#include <sys/types.h>
73#include <sys/socket.h>
74#endif
75#endif
76
77
54/** 78/**
55 * return code for "YES". 79 * return code for "YES".
56 */ 80 */
diff --git a/src/microspdy/applicationlayer.c b/src/microspdy/applicationlayer.c
index e706a89d..9ba47948 100644
--- a/src/microspdy/applicationlayer.c
+++ b/src/microspdy/applicationlayer.c
@@ -217,11 +217,11 @@ spdy_handler_response_queue_result(void * cls,
217 int streamopened; 217 int streamopened;
218 struct SPDY_Request *request = (struct SPDY_Request *)cls; 218 struct SPDY_Request *request = (struct SPDY_Request *)cls;
219 219
220 SPDYF_ASSERT(NULL == response_queue->data_frame 220 SPDYF_ASSERT( ( (NULL == response_queue->data_frame) &&
221 && NULL != response_queue->control_frame 221 (NULL != response_queue->control_frame) ) ||
222 || NULL != response_queue->data_frame 222 ( (NULL != response_queue->data_frame) &&
223 && NULL == response_queue->control_frame, 223 (NULL == response_queue->control_frame) ),
224 "response queue must have either control frame or data frame"); 224 "response queue must have either control frame or data frame");
225 225
226 streamopened = !response_queue->stream->is_out_closed; 226 streamopened = !response_queue->stream->is_out_closed;
227 227
diff --git a/src/microspdy/daemon.c b/src/microspdy/daemon.c
index 47e49ea1..09cf2107 100644
--- a/src/microspdy/daemon.c
+++ b/src/microspdy/daemon.c
@@ -423,15 +423,15 @@ SPDYF_get_fdset (struct SPDY_Daemon *daemon,
423 { 423 {
424 fd = pos->socket_fd; 424 fd = pos->socket_fd;
425 FD_SET(fd, read_fd_set); 425 FD_SET(fd, read_fd_set);
426 if(all 426 if (all
427 || NULL != pos->response_queue_head //frames pending 427 || (NULL != pos->response_queue_head) //frames pending
428 || NULL != pos->write_buffer //part of last frame pending 428 || (NULL != pos->write_buffer) //part of last frame pending
429 || SPDY_SESSION_STATUS_CLOSING == pos->status //the session is about to be closed 429 || (SPDY_SESSION_STATUS_CLOSING == pos->status) //the session is about to be closed
430 || daemon->session_timeout //timeout passed for the session 430 || (daemon->session_timeout //timeout passed for the session
431 && (pos->last_activity + daemon->session_timeout < SPDYF_monotonic_time()) 431 && (pos->last_activity + daemon->session_timeout < SPDYF_monotonic_time()))
432 || SPDY_YES == SPDYF_tls_is_pending(pos) //data in TLS' read buffer pending 432 || (SPDY_YES == SPDYF_tls_is_pending(pos)) //data in TLS' read buffer pending
433 || ((pos->read_buffer_offset - pos->read_buffer_beginning) > 0) // data in lib's read buffer pending 433 || ((pos->read_buffer_offset - pos->read_buffer_beginning) > 0) // data in lib's read buffer pending
434 ) 434 )
435 FD_SET(fd, write_fd_set); 435 FD_SET(fd, write_fd_set);
436 if(fd > max_fd) 436 if(fd > max_fd)
437 max_fd = fd; 437 max_fd = fd;
diff --git a/src/microspdy/session.c b/src/microspdy/session.c
index 46c15a96..1b62f649 100644
--- a/src/microspdy/session.c
+++ b/src/microspdy/session.c
@@ -932,6 +932,7 @@ SPDYF_session_write (struct SPDY_Session *session, bool only_one_frame)
932 //on respones with callbacks it is possible that their is no 932 //on respones with callbacks it is possible that their is no
933 //data available 933 //data available
934 if(0 == session->write_buffer_size)//nothing to write 934 if(0 == session->write_buffer_size)//nothing to write
935 {
935 if(response_queue != session->response_queue_head) 936 if(response_queue != session->response_queue_head)
936 { 937 {
937 //the handler modified the queue 938 //the handler modified the queue
@@ -942,6 +943,7 @@ SPDYF_session_write (struct SPDY_Session *session, bool only_one_frame)
942 //no need to try the same frame again 943 //no need to try the same frame again
943 break; 944 break;
944 } 945 }
946 }
945 } 947 }
946 948
947 session->last_activity = SPDYF_monotonic_time(); 949 session->last_activity = SPDYF_monotonic_time();
diff --git a/src/microspdy/structures.c b/src/microspdy/structures.c
index 6b7fc681..6308fd95 100644
--- a/src/microspdy/structures.c
+++ b/src/microspdy/structures.c
@@ -27,6 +27,7 @@
27#include "structures.h" 27#include "structures.h"
28#include "internal.h" 28#include "internal.h"
29#include "session.h" 29#include "session.h"
30#include <ctype.h>
30 31
31 32
32struct SPDY_NameValue * 33struct SPDY_NameValue *
@@ -60,7 +61,7 @@ SPDY_name_value_add (struct SPDY_NameValue *container,
60 61
61 for(i=0; i<len; ++i) 62 for(i=0; i<len; ++i)
62 { 63 {
63 if(isupper(name[i])) 64 if(isupper((int) name[i]))
64 return SPDY_INPUT_ERROR; 65 return SPDY_INPUT_ERROR;
65 } 66 }
66 67
@@ -289,12 +290,12 @@ SPDYF_response_queue_create(bool is_data,
289 unsigned int i; 290 unsigned int i;
290 bool is_last; 291 bool is_last;
291 292
292 SPDYF_ASSERT(!is_data 293 SPDYF_ASSERT((! is_data)
293 || 0 == data_size && NULL != response->rcb 294 || ((0 == data_size) && (NULL != response->rcb))
294 || 0 < data_size && NULL == response->rcb, 295 || ((0 < data_size) && (NULL == response->rcb)),
295 "either data or request->rcb must not be null"); 296 "either data or request->rcb must not be null");
296 297
297 if(is_data && data_size > SPDY_MAX_SUPPORTED_FRAME_SIZE) 298 if (is_data && (data_size > SPDY_MAX_SUPPORTED_FRAME_SIZE))
298 { 299 {
299 //separate the data in more frames and add them to the queue 300 //separate the data in more frames and add them to the queue
300 301
diff --git a/src/spdy2http/proxy.c b/src/spdy2http/proxy.c
index dc884a68..953b4bb2 100644
--- a/src/spdy2http/proxy.c
+++ b/src/spdy2http/proxy.c
@@ -127,10 +127,13 @@ struct URI
127 while(0) 127 while(0)
128 128
129 129
130int loop = 1; 130static int loop = 1;
131CURLM *multi_handle; 131
132int still_running = 0; /* keep number of running handles */ 132static CURLM *multi_handle;
133regex_t uri_preg; 133
134static int still_running = 0; /* keep number of running handles */
135
136static regex_t uri_preg;
134 137
135 138
136struct Proxy 139struct Proxy
@@ -151,7 +154,7 @@ struct Proxy
151}; 154};
152 155
153 156
154void 157static void
155free_uri(struct URI * uri) 158free_uri(struct URI * uri)
156{ 159{
157 if(NULL != uri) 160 if(NULL != uri)
@@ -170,7 +173,8 @@ free_uri(struct URI * uri)
170 } 173 }
171} 174}
172 175
173int 176
177static int
174init_parse_uri(regex_t * preg) 178init_parse_uri(regex_t * preg)
175{ 179{
176 // RFC 2396 180 // RFC 2396
@@ -186,14 +190,16 @@ init_parse_uri(regex_t * preg)
186 return regcomp(preg, "^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?", REG_EXTENDED); 190 return regcomp(preg, "^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?", REG_EXTENDED);
187} 191}
188 192
189void 193
194static void
190deinit_parse_uri(regex_t * preg) 195deinit_parse_uri(regex_t * preg)
191{ 196{
192 regfree(preg); 197 regfree(preg);
193} 198}
194 199
195int 200
196parse_uri(regex_t * preg, char * full_uri, struct URI ** uri) 201static int
202parse_uri(regex_t * preg, const char * full_uri, struct URI ** uri)
197{ 203{
198 int ret; 204 int ret;
199 char *colon; 205 char *colon;
@@ -305,7 +311,7 @@ response_callback (void *cls,
305} 311}
306 312
307 313
308void 314static void
309response_done_callback(void *cls, 315response_done_callback(void *cls,
310 struct SPDY_Response *response, 316 struct SPDY_Response *response,
311 struct SPDY_Request *request, 317 struct SPDY_Request *request,
@@ -490,7 +496,7 @@ curl_write_cb(void *contents, size_t size, size_t nmemb, void *userp)
490} 496}
491 497
492 498
493int 499static int
494iterate_cb (void *cls, const char *name, const char * const * value, int num_values) 500iterate_cb (void *cls, const char *name, const char * const * value, int num_values)
495{ 501{
496 struct Proxy *proxy = (struct Proxy *)cls; 502 struct Proxy *proxy = (struct Proxy *)cls;
@@ -528,7 +534,7 @@ iterate_cb (void *cls, const char *name, const char * const * value, int num_val
528} 534}
529 535
530 536
531void 537static void
532standard_request_handler(void *cls, 538standard_request_handler(void *cls,
533 struct SPDY_Request * request, 539 struct SPDY_Request * request,
534 uint8_t priority, 540 uint8_t priority,
@@ -627,8 +633,9 @@ standard_request_handler(void *cls,
627 } 633 }
628} 634}
629 635
630int 636
631run() 637static int
638run ()
632{ 639{
633 unsigned long long timeoutlong=0; 640 unsigned long long timeoutlong=0;
634 long curl_timeo = -1; 641 long curl_timeo = -1;
@@ -645,9 +652,7 @@ run()
645 CURLMsg *msg; 652 CURLMsg *msg;
646 int msgs_left; 653 int msgs_left;
647 struct Proxy *proxy; 654 struct Proxy *proxy;
648 struct sockaddr_in *addr; 655 struct sockaddr_in *addr;
649 struct sockaddr_in addr4;
650 struct in_addr inaddr4;
651 struct addrinfo hints; 656 struct addrinfo hints;
652 char service[NI_MAXSERV]; 657 char service[NI_MAXSERV];
653 struct addrinfo *gai; 658 struct addrinfo *gai;
@@ -679,16 +684,16 @@ run()
679 } 684 }
680 else 685 else
681 { 686 {
682 snprintf(service, sizeof(service), "%u", glob_opt.listen_port); 687 snprintf (service, sizeof(service), "%u", glob_opt.listen_port);
683 memset(&hints, 0, sizeof(struct addrinfo)); 688 memset (&hints, 0, sizeof(struct addrinfo));
684 hints.ai_family = AF_UNSPEC; 689 hints.ai_family = AF_INET;
685 hints.ai_socktype = SOCK_STREAM; 690 hints.ai_socktype = SOCK_STREAM;
686 691
687 ret = getaddrinfo(glob_opt.listen_host, service, &hints, &gai); 692 ret = getaddrinfo(glob_opt.listen_host, service, &hints, &gai);
688 if(ret != 0) 693 if(ret != 0)
689 DIE("problem with specified host"); 694 DIE("problem with specified host");
690 695
691 addr=gai->ai_addr; 696 addr = (struct sockaddr_in *) gai->ai_addr;
692 697
693 daemon = SPDY_start_daemon(0, 698 daemon = SPDY_start_daemon(0,
694 glob_opt.cert, 699 glob_opt.cert,
@@ -836,7 +841,8 @@ run()
836 return 0; 841 return 0;
837} 842}
838 843
839void 844
845static void
840display_usage() 846display_usage()
841{ 847{
842 printf( 848 printf(