[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r5085 - libmicrohttpd/src/daemon
From: |
gnunet |
Subject: |
[GNUnet-SVN] r5085 - libmicrohttpd/src/daemon |
Date: |
Sat, 16 Jun 2007 01:33:00 -0600 (MDT) |
Author: grothoff
Date: 2007-06-16 01:33:00 -0600 (Sat, 16 Jun 2007)
New Revision: 5085
Modified:
libmicrohttpd/src/daemon/daemon.c
libmicrohttpd/src/daemon/daemontest.c
libmicrohttpd/src/daemon/daemontest_get.c
libmicrohttpd/src/daemon/daemontest_post.c
libmicrohttpd/src/daemon/daemontest_put.c
libmicrohttpd/src/daemon/internal.c
libmicrohttpd/src/daemon/internal.h
libmicrohttpd/src/daemon/minimal_example.c
libmicrohttpd/src/daemon/response.c
libmicrohttpd/src/daemon/session.c
libmicrohttpd/src/daemon/session.h
Log:
removing whitespace
Modified: libmicrohttpd/src/daemon/daemon.c
===================================================================
--- libmicrohttpd/src/daemon/daemon.c 2007-06-16 07:32:47 UTC (rev 5084)
+++ libmicrohttpd/src/daemon/daemon.c 2007-06-16 07:33:00 UTC (rev 5085)
@@ -29,26 +29,26 @@
#include "response.h"
#include "session.h"
-#define MHD_MAX_CONNECTIONS FD_SETSIZE -4
+#define MHD_MAX_CONNECTIONS FD_SETSIZE -4
/**
* Register an access handler for all URIs beginning with uri_prefix.
*
- * @param uri_prefix
+ * @param uri_prefix
* @return MRI_NO if a handler for this exact prefix
* already exists
*/
-int
+int
MHD_register_handler(struct MHD_Daemon * daemon,
const char * uri_prefix,
MHD_AccessHandlerCallback dh,
void * dh_cls) {
struct MHD_Access_Handler * ah;
- if ( (daemon == NULL) ||
+ if ( (daemon == NULL) ||
(uri_prefix == NULL) ||
- (dh == NULL) )
+ (dh == NULL) )
return MHD_NO;
ah = daemon->handlers;
while (ah != NULL) {
@@ -71,11 +71,11 @@
* Unregister an access handler for the URIs beginning with
* uri_prefix.
*
- * @param uri_prefix
+ * @param uri_prefix
* @return MHD_NO if a handler for this exact prefix
* is not known for this daemon
*/
-int
+int
MHD_unregister_handler(struct MHD_Daemon * daemon,
const char * uri_prefix,
MHD_AccessHandlerCallback dh,
@@ -83,9 +83,9 @@
struct MHD_Access_Handler * prev;
struct MHD_Access_Handler * pos;
- if ( (daemon == NULL) ||
+ if ( (daemon == NULL) ||
(uri_prefix == NULL) ||
- (dh == NULL) )
+ (dh == NULL) )
return MHD_NO;
pos = daemon->handlers;
prev = NULL;
@@ -114,7 +114,7 @@
* daemon was not started with the right
* options for this call.
*/
-int
+int
MHD_get_fdset(struct MHD_Daemon * daemon,
fd_set * read_fd_set,
fd_set * write_fd_set,
@@ -123,13 +123,13 @@
struct MHD_Session * pos;
if ( (daemon == NULL) ||
- (read_fd_set == NULL) ||
+ (read_fd_set == NULL) ||
(write_fd_set == NULL) ||
(except_fd_set == NULL) ||
(max_fd == NULL) ||
( (daemon->options & MHD_USE_THREAD_PER_CONNECTION) != 0) )
return MHD_NO;
- FD_SET(daemon->socket_fd,
+ FD_SET(daemon->socket_fd,
read_fd_set);
if ( (*max_fd) < daemon->socket_fd)
*max_fd = daemon->socket_fd;
@@ -159,14 +159,14 @@
fd_set ws;
fd_set es;
int max;
-
+
if (con == NULL)
abort();
while ( (! con->daemon->shutdown) &&
- (con->socket_fd != -1) ) {
+ (con->socket_fd != -1) ) {
FD_ZERO(&rs);
- FD_ZERO(&ws);
- FD_ZERO(&es);
+ FD_ZERO(&ws);
+ FD_ZERO(&es);
max = 0;
MHD_session_get_fdset(con,
&rs,
@@ -174,9 +174,9 @@
&es,
&max);
num_ready = SELECT(max + 1,
- &rs,
+ &rs,
&ws,
- &es,
+ &es,
NULL);
if (num_ready <= 0) {
if (errno == EINTR)
@@ -192,7 +192,7 @@
if ( (con->headersReceived == 1) &&
(con->response == NULL) )
MHD_call_session_handler(con);
- }
+ }
if (con->socket_fd != -1) {
CLOSE(con->socket_fd);
con->socket_fd = -1;
@@ -214,10 +214,10 @@
int s;
addrlen = sizeof(struct sockaddr);
- memset(&addr,
+ memset(&addr,
0,
sizeof(struct sockaddr));
- s = ACCEPT(daemon->socket_fd,
+ s = ACCEPT(daemon->socket_fd,
&addr,
&addrlen);
if ( (s < 0) ||
@@ -246,8 +246,8 @@
session->daemon = daemon;
if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION) ) &&
(0 != pthread_create(&session->pid,
- NULL,
- &MHD_handle_connection,
+ NULL,
+ &MHD_handle_connection,
session)) ) {
MHD_DLOG(daemon,
"Failed to create a thread: %s\n",
@@ -273,7 +273,7 @@
* calling the application again with upload data when
* the upload data buffer is full).
*/
-static void
+static void
MHD_cleanup_sessions(struct MHD_Daemon * daemon) {
struct MHD_Session * pos;
struct MHD_Session * prev;
@@ -316,14 +316,14 @@
else
pos = prev->next;
continue;
- }
+ }
if ( (pos->headersReceived == 1) &&
(pos->response == NULL) )
MHD_call_session_handler(pos);
-
+
prev = pos;
- pos = pos->next;
+ pos = pos->next;
}
}
@@ -345,14 +345,14 @@
int max;
struct timeval timeout;
int ds;
-
+
timeout.tv_sec = 0;
timeout.tv_usec = 0;
- if(daemon == NULL)
+ if(daemon == NULL)
abort();
FD_ZERO(&rs);
- FD_ZERO(&ws);
- FD_ZERO(&es);
+ FD_ZERO(&ws);
+ FD_ZERO(&es);
max = 0;
if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) {
@@ -372,21 +372,21 @@
&rs,
&ws,
&es,
- may_block == MHD_NO ? &timeout : NULL);
- if (num_ready < 0) {
+ may_block == MHD_NO ? &timeout : NULL);
+ if (num_ready < 0) {
if (errno == EINTR)
return MHD_YES;
MHD_DLOG(daemon,
"Select failed: %s\n",
STRERROR(errno));
- return MHD_NO;
+ return MHD_NO;
}
ds = daemon->socket_fd;
if (ds == -1)
return MHD_YES;
if (FD_ISSET(ds,
- &rs))
- MHD_accept_connection(daemon);
+ &rs))
+ MHD_accept_connection(daemon);
if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) {
/* do not have a thread per connection, process all connections now */
pos = daemon->connections;
@@ -396,7 +396,7 @@
pos = pos->next;
continue;
}
- if (FD_ISSET(ds, &rs))
+ if (FD_ISSET(ds, &rs))
MHD_session_handle_read(pos);
if (FD_ISSET(ds, &ws))
MHD_session_handle_write(pos);
@@ -411,7 +411,7 @@
* Run webserver operations (without blocking unless
* in client callbacks). This method should be called
* by clients in combination with MHD_get_fdset
- * if the client-controlled select method is used.
+ * if the client-controlled select method is used.
*
* @return MHD_YES on success, MHD_NO if this
* daemon was not started with the right
@@ -466,12 +466,12 @@
int socket_fd;
struct sockaddr_in servaddr;
- if ((options & MHD_USE_SSL) != 0)
- return NULL;
- if ((options & MHD_USE_IPv6) != 0)
- return NULL;
- if ((options & MHD_USE_IPv4) == 0)
- return NULL;
+ if ((options & MHD_USE_SSL) != 0)
+ return NULL;
+ if ((options & MHD_USE_IPv6) != 0)
+ return NULL;
+ if ((options & MHD_USE_IPv4) == 0)
+ return NULL;
if ( (port == 0) ||
(dh == NULL) )
return NULL;
@@ -486,11 +486,11 @@
/* FIXME: setsockopt: SO_REUSEADDR? */
memset(&servaddr,
0,
- sizeof(struct sockaddr_in));
+ sizeof(struct sockaddr_in));
servaddr.sin_family = AF_INET;
servaddr.sin_port = htons(port);
- if (BIND(socket_fd,
- (struct sockaddr *)&servaddr,
+ if (BIND(socket_fd,
+ (struct sockaddr *)&servaddr,
sizeof(struct sockaddr_in)) < 0) {
if ( (options & MHD_USE_DEBUG) != 0)
fprintf(stderr,
@@ -506,7 +506,7 @@
"Failed to listen for connections: %s\n",
STRERROR(errno));
CLOSE(socket_fd);
- return NULL;
+ return NULL;
}
retVal = malloc(sizeof(struct MHD_Daemon));
memset(retVal,
@@ -524,15 +524,15 @@
if ( ( (0 != (options & MHD_USE_THREAD_PER_CONNECTION)) ||
(0 != (options & MHD_USE_SELECT_INTERNALLY)) ) &&
(0 != pthread_create(&retVal->pid,
- NULL,
- &MHD_select_thread,
+ NULL,
+ &MHD_select_thread,
retVal)) ) {
MHD_DLOG(retVal,
"Failed to create listen thread: %s\n",
STRERROR(errno));
free(retVal);
CLOSE(socket_fd);
- return NULL;
+ return NULL;
}
return retVal;
}
@@ -544,12 +544,12 @@
MHD_stop_daemon(struct MHD_Daemon * daemon) {
void * unused;
- if (daemon == NULL)
- return;
+ if (daemon == NULL)
+ return;
daemon->shutdown = 1;
CLOSE(daemon->socket_fd);
daemon->socket_fd = -1;
- if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) ||
+ if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) ||
(0 != (daemon->options & MHD_USE_SELECT_INTERNALLY)) ) {
pthread_kill(daemon->pid, SIGALRM);
pthread_join(daemon->pid, &unused);
Modified: libmicrohttpd/src/daemon/daemontest.c
===================================================================
--- libmicrohttpd/src/daemon/daemontest.c 2007-06-16 07:32:47 UTC (rev
5084)
+++ libmicrohttpd/src/daemon/daemontest.c 2007-06-16 07:33:00 UTC (rev
5085)
@@ -35,7 +35,7 @@
struct MHD_Daemon * d;
d = MHD_start_daemon(MHD_USE_DEBUG, 0, NULL, NULL, NULL, NULL);
- if (d != NULL)
+ if (d != NULL)
return 1;
return 0;
}
@@ -70,8 +70,8 @@
NULL,
&ahc_nothing,
NULL);
- if (d == NULL)
- return 2;
+ if (d == NULL)
+ return 2;
MHD_stop_daemon(d);
return 0;
}
@@ -89,8 +89,8 @@
&ahc_nothing,
NULL);
- if (d == NULL)
- return 4;
+ if (d == NULL)
+ return 4;
i = 0;
while(i < 15) {
maxfd = 0;
@@ -115,9 +115,9 @@
&ahc_nothing,
NULL);
- if (d == NULL)
- return 16;
- if (MHD_run(d) != MHD_NO)
+ if (d == NULL)
+ return 16;
+ if (MHD_run(d) != MHD_NO)
return 32;
MHD_stop_daemon(d);
return 0;
@@ -132,11 +132,11 @@
&ahc_nothing,
NULL);
- if (d == NULL)
- return 64;
- if (MHD_run(d) != MHD_NO)
+ if (d == NULL)
+ return 64;
+ if (MHD_run(d) != MHD_NO)
return 128;
- MHD_stop_daemon(d);
+ MHD_stop_daemon(d);
return 0;
}
@@ -149,8 +149,8 @@
errorCount += testThread();
errorCount += testMultithread();
if (errorCount != 0)
- fprintf(stderr,
- "Error (code: %u)\n",
+ fprintf(stderr,
+ "Error (code: %u)\n",
errorCount);
return errorCount != 0; /* 0 == pass */
}
Modified: libmicrohttpd/src/daemon/daemontest_get.c
===================================================================
--- libmicrohttpd/src/daemon/daemontest_get.c 2007-06-16 07:32:47 UTC (rev
5084)
+++ libmicrohttpd/src/daemon/daemontest_get.c 2007-06-16 07:33:00 UTC (rev
5085)
@@ -125,18 +125,18 @@
// crashes on my system!
curl_easy_setopt(c,
CURLOPT_NOSIGNAL,
- 1);
+ 1);
if (CURLE_OK != curl_easy_perform(c)) {
- curl_easy_cleanup(c);
- MHD_stop_daemon(d);
+ curl_easy_cleanup(c);
+ MHD_stop_daemon(d);
return 2;
- }
- curl_easy_cleanup(c);
+ }
+ curl_easy_cleanup(c);
if (cbc.pos != strlen("/hello_world")) {
MHD_stop_daemon(d);
return 4;
}
-
+
if (0 != strncmp("/hello_world",
cbc.buf,
strlen("/hello_world"))) {
@@ -144,7 +144,7 @@
return 8;
}
MHD_stop_daemon(d);
-
+
return 0;
}
@@ -189,16 +189,16 @@
// crashes on my system!
curl_easy_setopt(c,
CURLOPT_NOSIGNAL,
- 1);
+ 1);
if (CURLE_OK != curl_easy_perform(c)) {
- MHD_stop_daemon(d);
+ MHD_stop_daemon(d);
return 32;
}
curl_easy_cleanup(c);
if (cbc.pos != strlen("/hello_world")) {
- MHD_stop_daemon(d);
+ MHD_stop_daemon(d);
return 64;
- }
+ }
if (0 != strncmp("/hello_world",
cbc.buf,
strlen("/hello_world"))) {
@@ -206,7 +206,7 @@
return 128;
}
MHD_stop_daemon(d);
-
+
return 0;
}
@@ -263,20 +263,20 @@
// crashes on my system!
curl_easy_setopt(c,
CURLOPT_NOSIGNAL,
- 1);
+ 1);
multi = curl_multi_init();
if (multi == NULL) {
- curl_easy_cleanup(c);
- MHD_stop_daemon(d);
+ curl_easy_cleanup(c);
+ MHD_stop_daemon(d);
return 512;
}
mret = curl_multi_add_handle(multi, c);
if (mret != CURLM_OK) {
curl_multi_cleanup(multi);
- curl_easy_cleanup(c);
- MHD_stop_daemon(d);
+ curl_easy_cleanup(c);
+ MHD_stop_daemon(d);
return 1024;
}
start = time(NULL);
@@ -295,9 +295,9 @@
if (mret != CURLM_OK) {
curl_multi_remove_handle(multi, c);
curl_multi_cleanup(multi);
- curl_easy_cleanup(c);
- MHD_stop_daemon(d);
- return 2048;
+ curl_easy_cleanup(c);
+ MHD_stop_daemon(d);
+ return 2048;
}
if (MHD_YES != MHD_get_fdset(d,
&rs,
@@ -306,8 +306,8 @@
&max)) {
curl_multi_remove_handle(multi, c);
curl_multi_cleanup(multi);
- curl_easy_cleanup(c);
- MHD_stop_daemon(d);
+ curl_easy_cleanup(c);
+ MHD_stop_daemon(d);
return 4096;
}
tv.tv_sec = 0;
@@ -316,7 +316,7 @@
&rs,
&ws,
&es,
- &tv);
+ &tv);
curl_multi_perform(multi, &running);
if (running == 0) {
msg = curl_multi_info_read(multi,
@@ -341,15 +341,15 @@
}
if (multi != NULL) {
curl_multi_remove_handle(multi, c);
- curl_easy_cleanup(c);
+ curl_easy_cleanup(c);
curl_multi_cleanup(multi);
}
MHD_stop_daemon(d);
- if (cbc.pos != strlen("/hello_world"))
+ if (cbc.pos != strlen("/hello_world"))
return 8192;
if (0 != strncmp("/hello_world",
cbc.buf,
- strlen("/hello_world")))
+ strlen("/hello_world")))
return 16384;
return 0;
}
@@ -360,14 +360,14 @@
char * const * argv) {
unsigned int errorCount = 0;
- if (0 != curl_global_init(CURL_GLOBAL_WIN32))
- return 2;
+ if (0 != curl_global_init(CURL_GLOBAL_WIN32))
+ return 2;
errorCount += testInternalGet();
- errorCount += testMultithreadedGet();
+ errorCount += testMultithreadedGet();
errorCount += testExternalGet();
if (errorCount != 0)
- fprintf(stderr,
- "Error (code: %u)\n",
+ fprintf(stderr,
+ "Error (code: %u)\n",
errorCount);
curl_global_cleanup();
return errorCount != 0; /* 0 == pass */
Modified: libmicrohttpd/src/daemon/daemontest_post.c
===================================================================
--- libmicrohttpd/src/daemon/daemontest_post.c 2007-06-16 07:32:47 UTC (rev
5084)
+++ libmicrohttpd/src/daemon/daemontest_post.c 2007-06-16 07:33:00 UTC (rev
5085)
@@ -21,7 +21,7 @@
/**
* @file daemontest_post.c
* @brief Testcase for libmicrohttpd POST operations
- * TODO: use curl_formadd to produce POST data and
+ * TODO: use curl_formadd to produce POST data and
* add that to the CURL operation; then check
* on the server side if the headers arrive
* nicely (need to implement parsing POST data
@@ -137,18 +137,18 @@
// crashes on my system!
curl_easy_setopt(c,
CURLOPT_NOSIGNAL,
- 1);
+ 1);
if (CURLE_OK != curl_easy_perform(c)) {
- curl_easy_cleanup(c);
- MHD_stop_daemon(d);
+ curl_easy_cleanup(c);
+ MHD_stop_daemon(d);
return 2;
- }
- curl_easy_cleanup(c);
+ }
+ curl_easy_cleanup(c);
if (cbc.pos != strlen("/hello_world")) {
MHD_stop_daemon(d);
return 4;
}
-
+
if (0 != strncmp("/hello_world",
cbc.buf,
strlen("/hello_world"))) {
@@ -156,7 +156,7 @@
return 8;
}
MHD_stop_daemon(d);
-
+
return 0;
}
@@ -207,17 +207,17 @@
// crashes on my system!
curl_easy_setopt(c,
CURLOPT_NOSIGNAL,
- 1);
+ 1);
if (CURLE_OK != curl_easy_perform(c)) {
curl_easy_cleanup(c);
- MHD_stop_daemon(d);
+ MHD_stop_daemon(d);
return 32;
}
curl_easy_cleanup(c);
if (cbc.pos != strlen("/hello_world")) {
- MHD_stop_daemon(d);
+ MHD_stop_daemon(d);
return 64;
- }
+ }
if (0 != strncmp("/hello_world",
cbc.buf,
strlen("/hello_world"))) {
@@ -225,7 +225,7 @@
return 128;
}
MHD_stop_daemon(d);
-
+
return 0;
}
@@ -288,20 +288,20 @@
// crashes on my system!
curl_easy_setopt(c,
CURLOPT_NOSIGNAL,
- 1);
+ 1);
multi = curl_multi_init();
if (multi == NULL) {
- curl_easy_cleanup(c);
- MHD_stop_daemon(d);
+ curl_easy_cleanup(c);
+ MHD_stop_daemon(d);
return 512;
}
mret = curl_multi_add_handle(multi, c);
if (mret != CURLM_OK) {
curl_multi_cleanup(multi);
- curl_easy_cleanup(c);
- MHD_stop_daemon(d);
+ curl_easy_cleanup(c);
+ MHD_stop_daemon(d);
return 1024;
}
start = time(NULL);
@@ -320,9 +320,9 @@
if (mret != CURLM_OK) {
curl_multi_remove_handle(multi, c);
curl_multi_cleanup(multi);
- curl_easy_cleanup(c);
- MHD_stop_daemon(d);
- return 2048;
+ curl_easy_cleanup(c);
+ MHD_stop_daemon(d);
+ return 2048;
}
if (MHD_YES != MHD_get_fdset(d,
&rs,
@@ -331,8 +331,8 @@
&max)) {
curl_multi_remove_handle(multi, c);
curl_multi_cleanup(multi);
- curl_easy_cleanup(c);
- MHD_stop_daemon(d);
+ curl_easy_cleanup(c);
+ MHD_stop_daemon(d);
return 4096;
}
tv.tv_sec = 0;
@@ -341,7 +341,7 @@
&rs,
&ws,
&es,
- &tv);
+ &tv);
curl_multi_perform(multi, &running);
if (running == 0) {
msg = curl_multi_info_read(multi,
@@ -366,15 +366,15 @@
}
if (multi != NULL) {
curl_multi_remove_handle(multi, c);
- curl_easy_cleanup(c);
+ curl_easy_cleanup(c);
curl_multi_cleanup(multi);
}
MHD_stop_daemon(d);
- if (cbc.pos != strlen("/hello_world"))
+ if (cbc.pos != strlen("/hello_world"))
return 8192;
if (0 != strncmp("/hello_world",
cbc.buf,
- strlen("/hello_world")))
+ strlen("/hello_world")))
return 16384;
return 0;
}
@@ -385,14 +385,14 @@
char * const * argv) {
unsigned int errorCount = 0;
- if (0 != curl_global_init(CURL_GLOBAL_WIN32))
- return 2;
+ if (0 != curl_global_init(CURL_GLOBAL_WIN32))
+ return 2;
errorCount += testInternalPost();
- errorCount += testMultithreadedPost();
+ errorCount += testMultithreadedPost();
errorCount += testExternalPost();
if (errorCount != 0)
- fprintf(stderr,
- "Error (code: %u)\n",
+ fprintf(stderr,
+ "Error (code: %u)\n",
errorCount);
curl_global_cleanup();
return errorCount != 0; /* 0 == pass */
Modified: libmicrohttpd/src/daemon/daemontest_put.c
===================================================================
--- libmicrohttpd/src/daemon/daemontest_put.c 2007-06-16 07:32:47 UTC (rev
5084)
+++ libmicrohttpd/src/daemon/daemontest_put.c 2007-06-16 07:33:00 UTC (rev
5085)
@@ -86,11 +86,11 @@
struct MHD_Response * response;
int ret;
- if (0 != strcmp("PUT", method))
- return MHD_NO; /* unexpected method */
+ if (0 != strcmp("PUT", method))
+ return MHD_NO; /* unexpected method */
if ((*done) == 0) {
- if (*upload_data_size != 8)
- return MHD_YES; /* not yet ready */
+ if (*upload_data_size != 8)
+ return MHD_YES; /* not yet ready */
if (0 == memcmp(upload_data,
"Hello123",
8)) {
@@ -170,18 +170,18 @@
// crashes on my system!
curl_easy_setopt(c,
CURLOPT_NOSIGNAL,
- 1);
+ 1);
if (CURLE_OK != curl_easy_perform(c)) {
- curl_easy_cleanup(c);
- MHD_stop_daemon(d);
+ curl_easy_cleanup(c);
+ MHD_stop_daemon(d);
return 2;
- }
- curl_easy_cleanup(c);
+ }
+ curl_easy_cleanup(c);
if (cbc.pos != strlen("/hello_world")) {
MHD_stop_daemon(d);
return 4;
}
-
+
if (0 != strncmp("/hello_world",
cbc.buf,
strlen("/hello_world"))) {
@@ -189,7 +189,7 @@
return 8;
}
MHD_stop_daemon(d);
-
+
return 0;
}
@@ -248,17 +248,17 @@
// crashes on my system!
curl_easy_setopt(c,
CURLOPT_NOSIGNAL,
- 1);
+ 1);
if (CURLE_OK != curl_easy_perform(c)) {
curl_easy_cleanup(c);
- MHD_stop_daemon(d);
+ MHD_stop_daemon(d);
return 32;
}
curl_easy_cleanup(c);
if (cbc.pos != strlen("/hello_world")) {
- MHD_stop_daemon(d);
+ MHD_stop_daemon(d);
return 64;
- }
+ }
if (0 != strncmp("/hello_world",
cbc.buf,
strlen("/hello_world"))) {
@@ -266,7 +266,7 @@
return 128;
}
MHD_stop_daemon(d);
-
+
return 0;
}
@@ -337,20 +337,20 @@
// crashes on my system!
curl_easy_setopt(c,
CURLOPT_NOSIGNAL,
- 1);
+ 1);
multi = curl_multi_init();
if (multi == NULL) {
- curl_easy_cleanup(c);
- MHD_stop_daemon(d);
+ curl_easy_cleanup(c);
+ MHD_stop_daemon(d);
return 512;
}
mret = curl_multi_add_handle(multi, c);
if (mret != CURLM_OK) {
curl_multi_cleanup(multi);
- curl_easy_cleanup(c);
- MHD_stop_daemon(d);
+ curl_easy_cleanup(c);
+ MHD_stop_daemon(d);
return 1024;
}
start = time(NULL);
@@ -369,9 +369,9 @@
if (mret != CURLM_OK) {
curl_multi_remove_handle(multi, c);
curl_multi_cleanup(multi);
- curl_easy_cleanup(c);
- MHD_stop_daemon(d);
- return 2048;
+ curl_easy_cleanup(c);
+ MHD_stop_daemon(d);
+ return 2048;
}
if (MHD_YES != MHD_get_fdset(d,
&rs,
@@ -380,8 +380,8 @@
&max)) {
curl_multi_remove_handle(multi, c);
curl_multi_cleanup(multi);
- curl_easy_cleanup(c);
- MHD_stop_daemon(d);
+ curl_easy_cleanup(c);
+ MHD_stop_daemon(d);
return 4096;
}
tv.tv_sec = 0;
@@ -390,7 +390,7 @@
&rs,
&ws,
&es,
- &tv);
+ &tv);
curl_multi_perform(multi, &running);
if (running == 0) {
msg = curl_multi_info_read(multi,
@@ -415,15 +415,15 @@
}
if (multi != NULL) {
curl_multi_remove_handle(multi, c);
- curl_easy_cleanup(c);
+ curl_easy_cleanup(c);
curl_multi_cleanup(multi);
}
MHD_stop_daemon(d);
- if (cbc.pos != strlen("/hello_world"))
+ if (cbc.pos != strlen("/hello_world"))
return 8192;
if (0 != strncmp("/hello_world",
cbc.buf,
- strlen("/hello_world")))
+ strlen("/hello_world")))
return 16384;
return 0;
}
@@ -434,14 +434,14 @@
char * const * argv) {
unsigned int errorCount = 0;
- if (0 != curl_global_init(CURL_GLOBAL_WIN32))
- return 2;
+ if (0 != curl_global_init(CURL_GLOBAL_WIN32))
+ return 2;
errorCount += testInternalPut();
- errorCount += testMultithreadedPut();
+ errorCount += testMultithreadedPut();
errorCount += testExternalPut();
if (errorCount != 0)
- fprintf(stderr,
- "Error (code: %u)\n",
+ fprintf(stderr,
+ "Error (code: %u)\n",
errorCount);
curl_global_cleanup();
return errorCount != 0; /* 0 == pass */
Modified: libmicrohttpd/src/daemon/internal.c
===================================================================
--- libmicrohttpd/src/daemon/internal.c 2007-06-16 07:32:47 UTC (rev 5084)
+++ libmicrohttpd/src/daemon/internal.c 2007-06-16 07:33:00 UTC (rev 5085)
@@ -36,7 +36,7 @@
const char * format,
...) {
va_list va;
-
+
if ( (daemon->options & MHD_USE_DEBUG) == 0)
return;
va_start(va, format);
Modified: libmicrohttpd/src/daemon/internal.h
===================================================================
--- libmicrohttpd/src/daemon/internal.h 2007-06-16 07:32:47 UTC (rev 5084)
+++ libmicrohttpd/src/daemon/internal.h 2007-06-16 07:33:00 UTC (rev 5085)
@@ -90,7 +90,7 @@
/**
* Representation of a response.
- */
+ */
struct MHD_Response {
/**
@@ -109,9 +109,9 @@
/**
* Closure to give to the content reader
* free callback.
- */
+ */
void * crc_cls;
-
+
/**
* How do we get more data? NULL if we are
* given all of the data up front.
@@ -135,7 +135,7 @@
* once the counter hits zero.
*/
unsigned int reference_count;
-
+
/**
* Set to -1 if size is not known.
*/
@@ -151,7 +151,7 @@
* beginning of data located?
*/
size_t data_start;
-
+
};
@@ -162,7 +162,7 @@
struct MHD_Daemon * daemon;
struct MHD_HTTP_Header * headers_received;
-
+
struct MHD_Response * response;
/**
@@ -184,7 +184,7 @@
* Buffer for writing response.
*/
char * write_buffer;
-
+
/**
* Foreign address (of length addr_len).
*/
@@ -237,19 +237,19 @@
* we are done sending our response.
*/
int read_close;
-
+
/**
* Have we finished receiving all of the headers yet?
* Set to 1 once we are done processing all of the
* headers. Note that due to pipelining, it is
- * possible that the NEXT request is already
+ * possible that the NEXT request is already
* (partially) waiting in the read buffer.
*/
int headersReceived;
/**
* Have we finished receiving the data from a
- * potential file-upload?
+ * potential file-upload?
*/
int bodyReceived;
@@ -275,7 +275,7 @@
struct MHD_Access_Handler default_handler;
struct MHD_Session * connections;
-
+
MHD_AcceptPolicyCallback apc;
void * apc_cls;
Modified: libmicrohttpd/src/daemon/minimal_example.c
===================================================================
--- libmicrohttpd/src/daemon/minimal_example.c 2007-06-16 07:32:47 UTC (rev
5084)
+++ libmicrohttpd/src/daemon/minimal_example.c 2007-06-16 07:33:00 UTC (rev
5085)
@@ -82,7 +82,7 @@
if (d == NULL)
return 1;
sleep(atoi(argv[2]));
- MHD_stop_daemon(d);
+ MHD_stop_daemon(d);
return 0;
}
Modified: libmicrohttpd/src/daemon/response.c
===================================================================
--- libmicrohttpd/src/daemon/response.c 2007-06-16 07:32:47 UTC (rev 5084)
+++ libmicrohttpd/src/daemon/response.c 2007-06-16 07:33:00 UTC (rev 5085)
@@ -38,11 +38,11 @@
const char * header,
const char * content) {
struct MHD_HTTP_Header * hdr;
-
- if ( (response == NULL) ||
- (header == NULL) ||
+
+ if ( (response == NULL) ||
+ (header == NULL) ||
(content == NULL) ||
- (strlen(header) == 0) ||
+ (strlen(header) == 0) ||
(strlen(content) == 0) ||
(NULL != strstr(header, "\t")) ||
(NULL != strstr(header, "\r")) ||
@@ -72,14 +72,14 @@
struct MHD_HTTP_Header * pos;
struct MHD_HTTP_Header * prev;
- if ( (header == NULL) ||
- (content == NULL) )
- return MHD_NO;
+ if ( (header == NULL) ||
+ (content == NULL) )
+ return MHD_NO;
prev = NULL;
pos = response->first_header;
while (pos != NULL) {
- if ( (0 == strcmp(header, pos->header)) &&
- (0 == strcmp(content, pos->value)) ) {
+ if ( (0 == strcmp(header, pos->header)) &&
+ (0 == strcmp(content, pos->value)) ) {
free(pos->header);
free(pos->value);
if (prev == NULL)
@@ -102,7 +102,7 @@
* maybe NULL (then just count headers)
* @param iterator_cls extra argument to iterator
* @return number of entries iterated over
- */
+ */
int
MHD_get_response_headers(struct MHD_Response * response,
MHD_KeyValueIterator iterator,
@@ -129,7 +129,7 @@
*
* @param key which header to get
* @return NULL if header does not exist
- */
+ */
const char *
MHD_get_response_header(struct MHD_Response * response,
const char * key) {
@@ -162,7 +162,7 @@
MHD_ContentReaderFreeCallback crfc) {
struct MHD_Response * retVal;
- if (crc == NULL)
+ if (crc == NULL)
return NULL;
retVal = malloc(sizeof(struct MHD_Response));
memset(retVal,
@@ -187,7 +187,7 @@
* @param size size of the data portion of the response
* @param data the data itself
* @param must_free libmicrohttpd should free data when done
- * @param must_copy libmicrohttpd must make a copy of data
+ * @param must_copy libmicrohttpd must make a copy of data
* right away, the data maybe released anytime after
* this call returns
* @return NULL on error (i.e. invalid arguments, out of memory)
@@ -199,7 +199,7 @@
int must_copy) {
struct MHD_Response * retVal;
void * tmp;
-
+
if ( (data == NULL) &&
(size > 0) )
return NULL;
@@ -215,11 +215,11 @@
(size > 0) ) {
tmp = malloc(size);
memcpy(tmp,
- data,
+ data,
size);
must_free = 1;
data = tmp;
- }
+ }
retVal->crc = NULL;
retVal->crfc = must_free ? &free : NULL;
retVal->crc_cls = must_free ? data : NULL;
@@ -240,10 +240,10 @@
MHD_destroy_response(struct MHD_Response * response) {
struct MHD_HTTP_Header * pos;
- if (response == NULL)
+ if (response == NULL)
return;
pthread_mutex_lock(&response->mutex);
- if (0 != --response->reference_count) {
+ if (0 != --response->reference_count) {
pthread_mutex_unlock(&response->mutex);
return;
}
@@ -252,7 +252,7 @@
if (response->crfc != NULL)
response->crfc(response->crc_cls);
while (response->first_header != NULL) {
- pos = response->first_header;
+ pos = response->first_header;
response->first_header = pos->next;
free(pos->header);
free(pos->value);
Modified: libmicrohttpd/src/daemon/session.c
===================================================================
--- libmicrohttpd/src/daemon/session.c 2007-06-16 07:32:47 UTC (rev 5084)
+++ libmicrohttpd/src/daemon/session.c 2007-06-16 07:33:00 UTC (rev 5085)
@@ -37,7 +37,7 @@
* maybe NULL (then just count headers)
* @param iterator_cls extra argument to iterator
* @return number of entries iterated over
- */
+ */
int
MHD_get_session_values(struct MHD_Session * session,
enum MHD_ValueKind kind,
@@ -46,7 +46,7 @@
int ret;
struct MHD_HTTP_Header * pos;
- if (session == NULL)
+ if (session == NULL)
return -1;
ret = 0;
pos = session->headers_received;
@@ -54,11 +54,11 @@
if (0 != (pos->kind & kind)) {
ret++;
if ( (iterator != NULL) &&
- (MHD_YES != iterator(iterator_cls,
- kind,
- pos->header,
- pos->value)) )
- return ret;
+ (MHD_YES != iterator(iterator_cls,
+ kind,
+ pos->header,
+ pos->value)) )
+ return ret;
}
pos = pos->next;
}
@@ -72,14 +72,14 @@
*
* @param key the header to look for
* @return NULL if no such item was found
- */
+ */
const char *
MHD_lookup_session_value(struct MHD_Session * session,
enum MHD_ValueKind kind,
const char * key) {
struct MHD_HTTP_Header * pos;
- if (session == NULL)
+ if (session == NULL)
return NULL;
pos = session->headers_received;
while (pos != NULL) {
@@ -95,18 +95,18 @@
/**
* Queue a response to be transmitted to the client (as soon as
* possible).
- *
+ *
* @param session the session identifying the client
* @param status_code HTTP status code (i.e. 200 for OK)
* @param response response to transmit
* @return MHD_NO on error (i.e. reply already sent),
* MHD_YES on success or if message has been queued
*/
-int
+int
MHD_queue_response(struct MHD_Session * session,
unsigned int status_code,
struct MHD_Response * response) {
- if ( (session == NULL) ||
+ if ( (session == NULL) ||
(response == NULL) ||
(session->response != NULL) ||
(session->bodyReceived == 0) ||
@@ -124,7 +124,7 @@
*
* @return MHD_YES on success
*/
-int
+int
MHD_session_get_fdset(struct MHD_Session * session,
fd_set * read_fd_set,
fd_set * write_fd_set,
@@ -135,11 +135,11 @@
fd = session->socket_fd;
if (fd == -1)
return MHD_YES;
- if ( (session->read_close == 0) &&
+ if ( (session->read_close == 0) &&
( (session->headersReceived == 0) ||
(session->readLoc < session->read_buffer_size) ) )
FD_SET(fd, read_fd_set);
- if (session->response != NULL)
+ if (session->response != NULL)
FD_SET(fd, write_fd_set);
if ( (fd > *max_fd) &&
( (session->headersReceived == 0) ||
@@ -157,7 +157,7 @@
* found (incomplete, buffer too small, line too long),
* return NULL. Otherwise return a copy of the line.
*/
-static char *
+static char *
MHD_get_next_header_line(struct MHD_Session * session) {
char * rbuf;
size_t pos;
@@ -201,10 +201,10 @@
session->read_buffer,
pos);
rbuf[pos] = '\0';
- if ( (session->read_buffer[pos] == '\r') &&
+ if ( (session->read_buffer[pos] == '\r') &&
(session->read_buffer[pos+1] == '\n') )
pos++; /* skip both r and n */
- pos++;
+ pos++;
memmove(session->read_buffer,
&session->read_buffer[pos],
session->readLoc - pos);
@@ -212,7 +212,7 @@
return rbuf;
}
-static void
+static void
MHD_session_add_header(struct MHD_Session * session,
const char * key,
const char * value,
@@ -227,7 +227,7 @@
session->headers_received = hdr;
}
-static void
+static void
MHD_http_unescape(char * val) {
char * esc;
unsigned int num;
@@ -248,7 +248,7 @@
}
}
-static void
+static void
MHD_parse_arguments(struct MHD_Session * session,
char * args) {
char * equals;
@@ -264,7 +264,7 @@
if (amper != NULL) {
amper[0] = '\0';
amper++;
- }
+ }
MHD_http_unescape(args);
MHD_http_unescape(equals);
MHD_session_add_header(session,
@@ -278,7 +278,7 @@
/**
* Parse the cookie header (see RFC 2109).
*/
-static void
+static void
MHD_parse_cookie_header(struct MHD_Session * session) {
const char * hdr;
char * cpy;
@@ -336,7 +336,7 @@
* This function is designed to parse the input buffer of a given session.
*
* Once the header is complete, it should have set the
- * headers_received, url and method values and set
+ * headers_received, url and method values and set
* headersReceived to 1. If no body is expected, it should
* also set "bodyReceived" to 1. Otherwise, it should
* set "uploadSize" to the expected size of the body. If the
@@ -354,7 +354,7 @@
if (session->bodyReceived == 1)
abort();
- while (NULL != (line = MHD_get_next_header_line(session))) {
+ while (NULL != (line = MHD_get_next_header_line(session))) {
if (session->url == NULL) {
/* line must be request line */
uri = strstr(line, " ");
@@ -387,7 +387,7 @@
MHD_HEADER_KIND,
"Content-Length");
if (clen != NULL) {
- if (1 != sscanf(clen,
+ if (1 != sscanf(clen,
"%llu",
&cval)) {
MHD_DLOG(session->daemon,
@@ -409,7 +409,7 @@
session->bodyReceived = 0;
}
}
- break;
+ break;
}
/* line should be normal header line, find colon */
colon = strstr(line, ": ");
@@ -438,8 +438,8 @@
/**
* Find the handler responsible for this request.
- */
-static struct MHD_Access_Handler *
+ */
+static struct MHD_Access_Handler *
MHD_find_access_handler(struct MHD_Session * session) {
struct MHD_Access_Handler * pos;
@@ -455,7 +455,7 @@
/**
* Call the handler of the application for this
- * session.
+ * session.
*/
void
MHD_call_session_handler(struct MHD_Session * session) {
@@ -484,7 +484,7 @@
&session->read_buffer[session->readLoc - processed],
processed);
if (session->uploadSize != -1)
- session->uploadSize -= (session->readLoc - processed);
+ session->uploadSize -= (session->readLoc - processed);
session->readLoc = processed;
if ( (session->uploadSize == 0) ||
( (session->readLoc == 0) &&
@@ -503,13 +503,13 @@
* This function handles a particular connection when it has been
* determined that there is data to be read off a socket. All implementations
* (multithreaded, external select, internal select) call this function
- * to handle reads.
+ * to handle reads.
*/
int
MHD_session_handle_read(struct MHD_Session * session) {
int bytes_read;
void * tmp;
-
+
if ( (session->readLoc >= session->read_buffer_size) &&
(session->headersReceived == 0) ) {
/* need to grow read buffer */
@@ -526,7 +526,7 @@
MHD_DLOG(session->daemon,
"Unexpected call to %s.\n",
__FUNCTION__);
- return MHD_NO;
+ return MHD_NO;
}
bytes_read = RECV(session->socket_fd,
&session->read_buffer[session->readLoc],
@@ -544,15 +544,15 @@
}
if (bytes_read == 0) {
/* other side closed connection */
- if (session->readLoc > 0)
- MHD_call_session_handler(session);
+ if (session->readLoc > 0)
+ MHD_call_session_handler(session);
shutdown(session->socket_fd, SHUT_RD);
return MHD_YES;
}
session->readLoc += bytes_read;
- if (session->headersReceived == 0)
+ if (session->headersReceived == 0)
MHD_parse_session_headers(session);
- if (session->headersReceived == 1)
+ if (session->headersReceived == 1)
MHD_call_session_handler(session);
return MHD_YES;
}
@@ -561,7 +561,7 @@
* Check if we need to set some additional headers
* for http-compiliance.
*/
-static void
+static void
MHD_add_extra_headers(struct MHD_Session * session) {
const char * have;
char buf[128];
@@ -600,7 +600,7 @@
MHD_add_extra_headers(session);
SPRINTF(code,
- "HTTP/1.1 %u\r\n",
+ "HTTP/1.1 %u\r\n",
session->responseCode);
off = strlen(code);
/* estimate size */
@@ -627,10 +627,10 @@
sprintf(&data[off],
"\r\n");
off += 2;
- if (off != size)
+ if (off != size)
abort();
session->write_buffer = data;
- session->write_buffer_size = size;
+ session->write_buffer_size = size;
}
/**
@@ -654,7 +654,7 @@
if (! session->headersSent) {
if (session->write_buffer == NULL)
MHD_build_header_response(session);
- ret = SEND(session->socket_fd,
+ ret = SEND(session->socket_fd,
&session->write_buffer[session->writeLoc],
session->write_buffer_size - session->writeLoc,
0);
@@ -678,10 +678,10 @@
}
return MHD_YES;
}
- if (response->total_size <= session->messagePos)
+ if (response->total_size <= session->messagePos)
abort(); /* internal error */
if (response->crc != NULL)
- pthread_mutex_lock(&response->mutex);
+ pthread_mutex_lock(&response->mutex);
/* prepare send buffer */
if ( (response->data == NULL) ||
@@ -708,16 +708,16 @@
response->data_start = session->messagePos;
response->data_size = ret;
if (ret == 0)
- return MHD_YES;
+ return MHD_YES;
}
-
+
/* transmit */
- ret = SEND(session->socket_fd,
+ ret = SEND(session->socket_fd,
&response->data[session->messagePos - response->data_start],
response->data_size - (session->messagePos - response->data_start),
0);
if (response->crc != NULL)
- pthread_mutex_unlock(&response->mutex);
+ pthread_mutex_unlock(&response->mutex);
if (ret < 0) {
if (errno == EINTR)
return MHD_YES;
@@ -729,7 +729,7 @@
return MHD_YES;
}
session->messagePos += ret;
- if (session->messagePos > response->data_size)
+ if (session->messagePos > response->data_size)
abort(); /* internal error */
if (session->messagePos == response->data_size) {
if ( (session->bodyReceived == 0) ||
Modified: libmicrohttpd/src/daemon/session.h
===================================================================
--- libmicrohttpd/src/daemon/session.h 2007-06-16 07:32:47 UTC (rev 5084)
+++ libmicrohttpd/src/daemon/session.h 2007-06-16 07:33:00 UTC (rev 5085)
@@ -34,7 +34,7 @@
*
* @return MHD_YES on success
*/
-int
+int
MHD_session_get_fdset(struct MHD_Session * session,
fd_set * read_fd_set,
fd_set * write_fd_set,
@@ -44,7 +44,7 @@
/**
* Call the handler of the application for this
- * session.
+ * session.
*/
void
MHD_call_session_handler(struct MHD_Session * session);
@@ -53,12 +53,12 @@
* This function handles a particular connection when it has been
* determined that there is data to be read off a socket. All implementations
* (multithreaded, external select, internal select) call this function
- * to handle reads.
+ * to handle reads.
*/
int
MHD_session_handle_read(struct MHD_Session * session);
-
+
/**
* This function was created to handle writes to sockets when it has been
* determined that the socket can be written to. If there is no data
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r5085 - libmicrohttpd/src/daemon,
gnunet <=