summaryrefslogtreecommitdiffstats
path: root/nanohttp
diff options
context:
space:
mode:
authorGravatar m0gg2006-12-31 17:24:22 +0000
committerGravatar m0gg2006-12-31 17:24:22 +0000
commitd95f9da3572131ceeefd245d99c795ab8bc11880 (patch)
tree21897c4cec8b0d7b19d915a9c19c8366cad268a1 /nanohttp
parent2fbfdcdff09db6a1c0041022b208320d15e24d13 (diff)
downloadcsoap-d95f9da3572131ceeefd245d99c795ab8bc11880.tar.gz
csoap-d95f9da3572131ceeefd245d99c795ab8bc11880.tar.bz2
Addded hooks for Web Service Management
Diffstat (limited to 'nanohttp')
-rw-r--r--nanohttp/nanohttp-admin.c43
-rw-r--r--nanohttp/nanohttp-server.c24
-rw-r--r--nanohttp/nanohttp-server.h12
3 files changed, 49 insertions, 30 deletions
diff --git a/nanohttp/nanohttp-admin.c b/nanohttp/nanohttp-admin.c
index c06577b..3dbdbd6 100644
--- a/nanohttp/nanohttp-admin.c
+++ b/nanohttp/nanohttp-admin.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-admin.c,v 1.10 2006/12/19 08:55:17 m0gg Exp $
+* $Id: nanohttp-admin.c,v 1.11 2006/12/31 17:24:22 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -53,24 +53,31 @@ static void
_httpd_admin_send_title(httpd_conn_t *conn, const char *title)
{
httpd_send_header(conn, 200, HTTP_STATUS_200_REASON_PHRASE);
+
http_output_stream_write_string(conn->out,
- "<html><head><style>");
+ "<html>"
+ "<head>");
http_output_stream_write_string(conn->out,
- ".logo {"
- " color: #005177;"
- " background-color: transparent;"
- " font-family: Calligraphic, arial, sans-serif;"
- " font-size: 36px;"
- "}");
+ "<style>"
+ ".logo {"
+ " color: #005177;"
+ " background-color: transparent;"
+ " font-family: Calligraphic, arial, sans-serif;"
+ " font-size: 36px;"
+ "}"
+ "</style>");
+
http_output_stream_write_string(conn->out,
- "</style></head><body><span class=\"logo\">nhttpd</span> ");
+ "</head>"
+ "<body>"
+ "<span class=\"logo\">nhttpd</span> ");
http_output_stream_write_string(conn->out, title);
http_output_stream_write_string(conn->out, "<hr />");
return;
}
-static void
+static inline void
_httpd_admin_send_footer(httpd_conn_t *conn)
{
http_output_stream_write_string(conn->out, "</body></html>");
@@ -92,11 +99,23 @@ _httpd_admin_list_services(httpd_conn_t *conn)
switch (node->status)
{
case NHTTPD_SERVICE_DOWN:
- sprintf(buffer, "<li><a href=\"%s\">%s</a> <a href=\"?" NHTTPD_ADMIN_QUERY_ACTIVATE_SERVICE "=%s\">[Activate]</a> <a href=\"?" NHTTPD_ADMIN_QUERY_STATISTICS "=%s\">[Statistics]</a></li>", node->ctx, node->ctx, node->ctx, node->ctx);
+ sprintf(buffer,
+ "<li>"
+ "<a href=\"%s\">%s</a> "
+ "<a href=\"?" NHTTPD_ADMIN_QUERY_ACTIVATE_SERVICE "=%s\">[Activate]</a> "
+ "<a href=\"?" NHTTPD_ADMIN_QUERY_STATISTICS "=%s\">[Statistics]</a>"
+ "</li>",
+ node->context, node->context, node->context, node->context);
break;
case NHTTPD_SERVICE_UP:
default:
- sprintf(buffer, "<li><a href=\"%s\">%s</a> <a href=\"?" NHTTPD_ADMIN_QUERY_PASSIVATE_SERVICE "=%s\">[Passivate]</a> <a href=\"?" NHTTPD_ADMIN_QUERY_STATISTICS "=%s\">[Statistics]</a></li>", node->ctx, node->ctx, node->ctx, node->ctx);
+ sprintf(buffer,
+ "<li>"
+ "<a href=\"%s\">%s</a> "
+ "<a href=\"?" NHTTPD_ADMIN_QUERY_PASSIVATE_SERVICE "=%s\">[Passivate]</a> "
+ "<a href=\"?" NHTTPD_ADMIN_QUERY_STATISTICS "=%s\">[Statistics]</a> "
+ "</li>",
+ node->context, node->context, node->context, node->context);
break;
}
http_output_stream_write_string(conn->out, buffer);
diff --git a/nanohttp/nanohttp-server.c b/nanohttp/nanohttp-server.c
index 078eb76..bca46f4 100644
--- a/nanohttp/nanohttp-server.c
+++ b/nanohttp/nanohttp-server.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-server.c,v 1.77 2006/12/19 08:55:17 m0gg Exp $
+* $Id: nanohttp-server.c,v 1.78 2006/12/31 17:24:22 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -303,7 +303,7 @@ httpd_init(int argc, char **argv)
}
herror_t
-httpd_register_secure(const char *ctx, httpd_service func, httpd_auth auth)
+httpd_register_secure(const char *context, httpd_service func, httpd_auth auth)
{
hservice_t *service;
@@ -328,9 +328,9 @@ httpd_register_secure(const char *ctx, httpd_service func, httpd_auth auth)
service->auth = auth;
service->func = func;
service->status = NHTTPD_SERVICE_UP;
- strcpy(service->ctx, ctx);
+ service->context = strdup(context);
- log_verbose3("register service (%p) for \"%s\"", service, SAVE_STR(ctx));
+ log_verbose3("register service (%p) for \"%s\"", service, context);
if (_httpd_services_head == NULL)
{
_httpd_services_head = _httpd_services_tail = service;
@@ -345,17 +345,17 @@ httpd_register_secure(const char *ctx, httpd_service func, httpd_auth auth)
}
herror_t
-httpd_register(const char *ctx, httpd_service service)
+httpd_register(const char *context, httpd_service service)
{
- return httpd_register_secure(ctx, service, NULL);
+ return httpd_register_secure(context, service, NULL);
}
herror_t
-httpd_register_default_secure(const char *ctx, httpd_service service, httpd_auth auth)
+httpd_register_default_secure(const char *context, httpd_service service, httpd_auth auth)
{
herror_t ret;
- ret = httpd_register_secure(ctx, service, auth);
+ ret = httpd_register_secure(context, service, auth);
/* XXX: this is broken, but working */
_httpd_services_default = _httpd_services_tail;
@@ -364,9 +364,9 @@ httpd_register_default_secure(const char *ctx, httpd_service service, httpd_auth
}
herror_t
-httpd_register_default(const char *ctx, httpd_service service)
+httpd_register_default(const char *context, httpd_service service)
{
- return httpd_register_default_secure(ctx, service, NULL);
+ return httpd_register_default_secure(context, service, NULL);
}
short
@@ -456,7 +456,7 @@ httpd_find_service(const char *context)
for (cur = _httpd_services_head; cur; cur = cur->next)
{
- if (!strcmp(cur->ctx, context))
+ if (!strcmp(cur->context, context))
return cur;
}
@@ -739,7 +739,7 @@ httpd_session_main(void *data)
if ((service = httpd_find_service(req->path)))
{
- log_verbose3("service '%s' for '%s' found", service->ctx, req->path);
+ log_verbose3("service '%s' for '%s' found", service->context, req->path);
if (service->status == NHTTPD_SERVICE_UP)
{
diff --git a/nanohttp/nanohttp-server.h b/nanohttp/nanohttp-server.h
index 7491722..bdb421c 100644
--- a/nanohttp/nanohttp-server.h
+++ b/nanohttp/nanohttp-server.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: nanohttp-server.h,v 1.33 2006/12/19 08:55:17 m0gg Exp $
+ * $Id: nanohttp-server.h,v 1.34 2006/12/31 17:24:22 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -261,7 +261,7 @@ struct service_statistics
*/
typedef struct tag_hservice
{
- char ctx[255];
+ char *context;
int status;
httpd_service func;
httpd_auth auth;
@@ -292,11 +292,11 @@ extern void httpd_destroy(void);
extern herror_t httpd_run(void);
-extern herror_t httpd_register(const char *ctx, httpd_service service);
-extern herror_t httpd_register_secure(const char *ctx, httpd_service service, httpd_auth auth);
+extern herror_t httpd_register(const char *context, httpd_service service);
+extern herror_t httpd_register_secure(const char *context, httpd_service service, httpd_auth auth);
-extern herror_t httpd_register_default(const char *ctx, httpd_service service);
-extern herror_t httpd_register_default_secure(const char *ctx, httpd_service service, httpd_auth auth);
+extern herror_t httpd_register_default(const char *context, httpd_service service);
+extern herror_t httpd_register_default_secure(const char *context, httpd_service service, httpd_auth auth);
extern short httpd_get_port(void);
extern int httpd_get_timeout(void);