aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/daemon/Makefile.am2
-rw-r--r--src/daemon/daemon.c37
-rw-r--r--src/daemon/internal.c47
-rw-r--r--src/daemon/internal.h10
-rw-r--r--src/daemon/response.c4
-rw-r--r--src/daemon/session.c4
6 files changed, 69 insertions, 35 deletions
diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am
index 892d0506..f41d39ee 100644
--- a/src/daemon/Makefile.am
+++ b/src/daemon/Makefile.am
@@ -11,7 +11,7 @@ libmicrohttpd_la_LDFLAGS = \
11# -lm 11# -lm
12libmicrohttpd_la_SOURCES = \ 12libmicrohttpd_la_SOURCES = \
13 daemon.c \ 13 daemon.c \
14 internal.h \ 14 internal.c internal.h \
15 response.c response.h \ 15 response.c response.h \
16 session.c session.h 16 session.c session.h
17 17
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c
index 4b743aad..ac0a7398 100644
--- a/src/daemon/daemon.c
+++ b/src/daemon/daemon.c
@@ -26,33 +26,14 @@
26 * @version 0.1.0 26 * @version 0.1.0
27 */ 27 */
28 28
29#include "microhttpd.h"
30#include "internal.h" 29#include "internal.h"
31#include "response.h" 30#include "response.h"
32#include "session.h" 31#include "session.h"
33#include "config.h"
34 32
35#define MHD_MAX_CONNECTIONS FD_SETSIZE -4 33#define MHD_MAX_CONNECTIONS FD_SETSIZE -4
36 34
37 35
38/** 36/**
39 * fprintf-like helper function for logging debug
40 * messages.
41 */
42static void DLOG(const struct MHD_Daemon * daemon,
43 const char * format,
44 ...) {
45 va_list va;
46
47 if ( (daemon->options & MHD_USE_DEBUG) == 0)
48 return;
49 va_start(va, format);
50 vfprintf(stderr, format, va);
51 va_end(va);
52}
53
54
55/**
56 * Register an access handler for all URIs beginning with uri_prefix. 37 * Register an access handler for all URIs beginning with uri_prefix.
57 * 38 *
58 * @param uri_prefix 39 * @param uri_prefix
@@ -234,9 +215,9 @@ MHD_accept_connection(struct MHD_Daemon * daemon) {
234 &addr, 215 &addr,
235 &addrlen))) || 216 &addrlen))) ||
236 (addrlen <= 0) ) { 217 (addrlen <= 0) ) {
237 DLOG(daemon, 218 MHD_DLOG(daemon,
238 "Error accepting connection: %s\n", 219 "Error accepting connection: %s\n",
239 strerror(errno)); 220 strerror(errno));
240 return MHD_NO; 221 return MHD_NO;
241 } 222 }
242 if (MHD_NO == daemon->apc(daemon->apc_cls, 223 if (MHD_NO == daemon->apc(daemon->apc_cls,
@@ -261,9 +242,9 @@ MHD_accept_connection(struct MHD_Daemon * daemon) {
261 NULL, 242 NULL,
262 &MHD_handle_connection, 243 &MHD_handle_connection,
263 session)) ) { 244 session)) ) {
264 DLOG(daemon, 245 MHD_DLOG(daemon,
265 "Failed to create a thread: %s\n", 246 "Failed to create a thread: %s\n",
266 strerror(errno)); 247 strerror(errno));
267 free(session->addr); 248 free(session->addr);
268 close(s); 249 close(s);
269 free(session); 250 free(session);
@@ -354,9 +335,9 @@ MHD_select(struct MHD_Daemon * daemon) {
354 if (num_ready < 0) { 335 if (num_ready < 0) {
355 if (errno == EINTR) 336 if (errno == EINTR)
356 return MHD_YES; 337 return MHD_YES;
357 DLOG(daemon, 338 MHD_DLOG(daemon,
358 "Select failed: %s\n", 339 "Select failed: %s\n",
359 strerror(errno)); 340 strerror(errno));
360 return MHD_NO; 341 return MHD_NO;
361 } 342 }
362 if (FD_ISSET(daemon->socket_fd, 343 if (FD_ISSET(daemon->socket_fd,
diff --git a/src/daemon/internal.c b/src/daemon/internal.c
new file mode 100644
index 00000000..ce06e2c6
--- /dev/null
+++ b/src/daemon/internal.c
@@ -0,0 +1,47 @@
1/*
2 This file is part of libmicrohttpd
3 (C) 2007 Daniel Pittman
4
5 libmicrohttpd is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
9
10 libmicrohttpd is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with libmicrohttpd; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file internal.h
23 * @brief internal shared structures
24 * @author Daniel Pittman
25 * @author Christian Grothoff
26 * @version 0.1.0
27 */
28
29#include "internal.h"
30
31
32/**
33 * fprintf-like helper function for logging debug
34 * messages.
35 */
36void MHD_DLOG(const struct MHD_Daemon * daemon,
37 const char * format,
38 ...) {
39 va_list va;
40
41 if ( (daemon->options & MHD_USE_DEBUG) == 0)
42 return;
43 va_start(va, format);
44 vfprintf(stderr, format, va);
45 va_end(va);
46}
47
diff --git a/src/daemon/internal.h b/src/daemon/internal.h
index 4beff728..9a3ec5a2 100644
--- a/src/daemon/internal.h
+++ b/src/daemon/internal.h
@@ -48,6 +48,16 @@
48 48
49#define MAX(a,b) ((a)<(b)) ? (b) : (a) 49#define MAX(a,b) ((a)<(b)) ? (b) : (a)
50 50
51
52/**
53 * fprintf-like helper function for logging debug
54 * messages.
55 */
56void MHD_DLOG(const struct MHD_Daemon * daemon,
57 const char * format,
58 ...);
59
60
51/** 61/**
52 * Header or cookie in HTTP request or response. 62 * Header or cookie in HTTP request or response.
53 */ 63 */
diff --git a/src/daemon/response.c b/src/daemon/response.c
index 1584dbfd..7fae9f90 100644
--- a/src/daemon/response.c
+++ b/src/daemon/response.c
@@ -26,10 +26,8 @@
26 * @version 0.1.0 26 * @version 0.1.0
27 */ 27 */
28 28
29#include "microhttpd.h"
30#include "response.h"
31#include "internal.h" 29#include "internal.h"
32#include "config.h" 30#include "response.h"
33 31
34/** 32/**
35 * Add a header line to the response. 33 * Add a header line to the response.
diff --git a/src/daemon/session.c b/src/daemon/session.c
index a719c51a..9e8afa83 100644
--- a/src/daemon/session.c
+++ b/src/daemon/session.c
@@ -26,11 +26,9 @@
26 * @version 0.1.0 26 * @version 0.1.0
27 */ 27 */
28 28
29#include "microhttpd.h" 29#include "internal.h"
30#include "session.h" 30#include "session.h"
31#include "response.h" 31#include "response.h"
32#include "internal.h"
33#include "config.h"
34 32
35 33
36/** 34/**