summaryrefslogtreecommitdiffstats
path: root/nanohttp
diff options
context:
space:
mode:
Diffstat (limited to 'nanohttp')
-rw-r--r--nanohttp/nanohttp-server.c84
-rw-r--r--nanohttp/nanohttp-server.h3
2 files changed, 45 insertions, 42 deletions
diff --git a/nanohttp/nanohttp-server.c b/nanohttp/nanohttp-server.c
index 9b51cd6..467d253 100644
--- a/nanohttp/nanohttp-server.c
+++ b/nanohttp/nanohttp-server.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-server.c,v 1.15 2004/09/01 07:58:08 snowdrop Exp $
+* $Id: nanohttp-server.c,v 1.16 2004/09/01 14:10:23 snowdrop Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -68,49 +68,51 @@ static conndata_t *_httpd_connection;
int
httpd_init(int argc, char *argv[])
{
- int i, status;
- status = hsocket_module_init();
- if (status != 0)
- return status;
-
- /* write argument information */
- log_verbose1("Arguments:");
- for (i = 0; i < argc; i++)
- log_verbose3("argv[%i] = '%s'", i, SAVE_STR(argv[i]));
-
- /* initialize from arguments */
- for (i = 0; i < argc; i++) {
- if (!strcmp(argv[i], NHTTPD_ARG_PORT) && i < argc - 1) {
- _httpd_port = atoi(argv[i + 1]);
- } else if (!strcmp(argv[i], NHTTPD_ARG_TERMSIG) && i < argc - 1) {
- _httpd_terminate_signal = atoi(argv[i + 1]);
- }
- }
-
- log_verbose2("socket bind to port '%d'", _httpd_port);
-
- /* init built-in services */
- /*
- * httpd_register("/httpd/list", service_list);
- */
- _httpd_connection = calloc(_httpd_max_connections, sizeof(conndata_t));
- for (i = 0; i < _httpd_max_connections; i++) {
- memset((char *) &_httpd_connection[i], 0,
- sizeof(_httpd_connection[i]));
- }
-
+ int i, status;
+ status = hsocket_module_init();
+ if (status != 0)
+ return status;
+
+ /* write argument information */
+ log_verbose1("Arguments:");
+ for (i = 0; i < argc; i++)
+ log_verbose3("argv[%i] = '%s'", i, SAVE_STR(argv[i]));
+
+ /* initialize from arguments */
+ for (i = 0; i < argc; i++) {
+ if (!strcmp(argv[i], NHTTPD_ARG_PORT) && i < argc - 1) {
+ _httpd_port = atoi(argv[i + 1]);
+ } else if (!strcmp(argv[i], NHTTPD_ARG_TERMSIG) && i < argc - 1) {
+ _httpd_terminate_signal = atoi(argv[i + 1]);
+ } else if (!strcmp(argv[i], NHTTPD_ARG_MAXCONN) && i < argc - 1) {
+ _httpd_max_connections = atoi(argv[i + 1]);
+ }
+ }
+
+ log_verbose2("socket bind to port '%d'", _httpd_port);
+
+ /* init built-in services */
+ /*
+ * httpd_register("/httpd/list", service_list);
+ */
+ _httpd_connection = calloc(_httpd_max_connections, sizeof(conndata_t));
+ for (i = 0; i < _httpd_max_connections; i++) {
+ memset((char *) &_httpd_connection[i], 0,
+ sizeof(_httpd_connection[i]));
+ }
+
#ifdef WIN32
- if (_beginthread(WSAReaper, 0, NULL) == -1) {
- log_error1("Winsock reaper thread failed to start");
- return (-1);
- }
+ if (_beginthread(WSAReaper, 0, NULL) == -1) {
+ log_error1("Winsock reaper thread failed to start");
+ return (-1);
+ }
#endif
- /* create socket */
- hsocket_init(&_httpd_socket);
- status = hsocket_bind(&_httpd_socket, _httpd_port);
-
- return status;
+ /* create socket */
+ hsocket_init(&_httpd_socket);
+ status = hsocket_bind(&_httpd_socket, _httpd_port);
+
+ return status;
}
/*
diff --git a/nanohttp/nanohttp-server.h b/nanohttp/nanohttp-server.h
index 30992ac..d7ff39e 100644
--- a/nanohttp/nanohttp-server.h
+++ b/nanohttp/nanohttp-server.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: nanohttp-server.h,v 1.3 2004/05/18 16:37:21 snowdrop Exp $
+ * $Id: nanohttp-server.h,v 1.4 2004/09/01 14:09:44 snowdrop Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -31,6 +31,7 @@
#define NHTTPD_ARG_PORT "-NHTTPport"
#define NHTTPD_ARG_TERMSIG "-NHTTPtsig"
+#define NHTTPD_ARG_MAXCONN "-NHTTPmaxconn"
typedef struct httpd_conn
{