This commit is contained in:
Christian Grothoff
2007-06-13 07:03:22 +00:00
parent d05460508f
commit e0f5ecea32
6 changed files with 69 additions and 35 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ libmicrohttpd_la_LDFLAGS = \
# -lm
libmicrohttpd_la_SOURCES = \
daemon.c \
internal.h \
internal.c internal.h \
response.c response.h \
session.c session.h
+9 -28
View File
@@ -26,32 +26,13 @@
* @version 0.1.0
*/
#include "microhttpd.h"
#include "internal.h"
#include "response.h"
#include "session.h"
#include "config.h"
#define MHD_MAX_CONNECTIONS FD_SETSIZE -4
/**
* fprintf-like helper function for logging debug
* messages.
*/
static void DLOG(const struct MHD_Daemon * daemon,
const char * format,
...) {
va_list va;
if ( (daemon->options & MHD_USE_DEBUG) == 0)
return;
va_start(va, format);
vfprintf(stderr, format, va);
va_end(va);
}
/**
* Register an access handler for all URIs beginning with uri_prefix.
*
@@ -234,9 +215,9 @@ MHD_accept_connection(struct MHD_Daemon * daemon) {
&addr,
&addrlen))) ||
(addrlen <= 0) ) {
DLOG(daemon,
"Error accepting connection: %s\n",
strerror(errno));
MHD_DLOG(daemon,
"Error accepting connection: %s\n",
strerror(errno));
return MHD_NO;
}
if (MHD_NO == daemon->apc(daemon->apc_cls,
@@ -261,9 +242,9 @@ MHD_accept_connection(struct MHD_Daemon * daemon) {
NULL,
&MHD_handle_connection,
session)) ) {
DLOG(daemon,
"Failed to create a thread: %s\n",
strerror(errno));
MHD_DLOG(daemon,
"Failed to create a thread: %s\n",
strerror(errno));
free(session->addr);
close(s);
free(session);
@@ -354,9 +335,9 @@ MHD_select(struct MHD_Daemon * daemon) {
if (num_ready < 0) {
if (errno == EINTR)
return MHD_YES;
DLOG(daemon,
"Select failed: %s\n",
strerror(errno));
MHD_DLOG(daemon,
"Select failed: %s\n",
strerror(errno));
return MHD_NO;
}
if (FD_ISSET(daemon->socket_fd,
+47
View File
@@ -0,0 +1,47 @@
/*
This file is part of libmicrohttpd
(C) 2007 Daniel Pittman
libmicrohttpd is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your
option) any later version.
libmicrohttpd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with libmicrohttpd; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/**
* @file internal.h
* @brief internal shared structures
* @author Daniel Pittman
* @author Christian Grothoff
* @version 0.1.0
*/
#include "internal.h"
/**
* fprintf-like helper function for logging debug
* messages.
*/
void MHD_DLOG(const struct MHD_Daemon * daemon,
const char * format,
...) {
va_list va;
if ( (daemon->options & MHD_USE_DEBUG) == 0)
return;
va_start(va, format);
vfprintf(stderr, format, va);
va_end(va);
}
+10
View File
@@ -48,6 +48,16 @@
#define MAX(a,b) ((a)<(b)) ? (b) : (a)
/**
* fprintf-like helper function for logging debug
* messages.
*/
void MHD_DLOG(const struct MHD_Daemon * daemon,
const char * format,
...);
/**
* Header or cookie in HTTP request or response.
*/
+1 -3
View File
@@ -26,10 +26,8 @@
* @version 0.1.0
*/
#include "microhttpd.h"
#include "response.h"
#include "internal.h"
#include "config.h"
#include "response.h"
/**
* Add a header line to the response.
+1 -3
View File
@@ -26,11 +26,9 @@
* @version 0.1.0
*/
#include "microhttpd.h"
#include "internal.h"
#include "session.h"
#include "response.h"
#include "internal.h"
#include "config.h"
/**