summaryrefslogtreecommitdiffstats
path: root/libcsoap
diff options
context:
space:
mode:
Diffstat (limited to 'libcsoap')
-rw-r--r--libcsoap/soap-admin.c99
-rw-r--r--libcsoap/soap-admin.h16
-rw-r--r--libcsoap/soap-server.c37
-rw-r--r--libcsoap/soap-service.c4
-rw-r--r--libcsoap/soap-service.h28
5 files changed, 137 insertions, 47 deletions
diff --git a/libcsoap/soap-admin.c b/libcsoap/soap-admin.c
index 715e3ca..efc9651 100644
--- a/libcsoap/soap-admin.c
+++ b/libcsoap/soap-admin.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-admin.c,v 1.10 2006/11/26 20:13:05 m0gg Exp $
+* $Id: soap-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
@@ -62,23 +62,38 @@ static void
_soap_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\">csoap</span> ");
+ "</head>"
+ "<body>"
+ "<span class=\"logo\">csoap</span> ");
http_output_stream_write_string(conn->out, title);
http_output_stream_write_string(conn->out, "<hr />");
return;
}
+static inline void
+_soap_admin_send_footer(httpd_conn_t *conn)
+{
+ http_output_stream_write_string(conn->out, "</body></html>");
+
+ return;
+}
static void
_soap_admin_list_routers(httpd_conn_t *conn)
@@ -91,18 +106,22 @@ _soap_admin_list_routers(httpd_conn_t *conn)
http_output_stream_write_string(conn->out, "<ul>");
for (node = soap_server_get_routers(); node; node = node->next)
{
- sprintf(buffer, "<li><a href=\"?" SOAP_ADMIN_QUERY_ROUTER "=%s\">%s</a> - <a href=\"%s\">[Service Description]</a> - <a href=\"../nhttp?" NHTTPD_ADMIN_QUERY_STATISTICS "=%s\">[Statistics]</a></li>",
- node->context, node->context, node->context, node->context);
+ sprintf(buffer,
+ "<li>"
+ "<a href=\"?" CSOAP_ADMIN_QUERY_ROUTER "=%s\">%s</a> - "
+ "<a href=\"%s\">[Service Description]</a> - "
+ "<a href=\"../nhttp?" NHTTPD_ADMIN_QUERY_STATISTICS "=%s\">[Statistics]</a>"
+ "</li>",
+ node->context, node->context, node->context, node->context);
http_output_stream_write_string(conn->out, buffer);
}
http_output_stream_write_string(conn->out, "</ul>");
- http_output_stream_write_string(conn->out, "</body></html>");
+ _soap_admin_send_footer(conn);
return;
}
-
static void
_soap_admin_list_services(httpd_conn_t *conn, const char *routername)
{
@@ -124,47 +143,78 @@ _soap_admin_list_services(httpd_conn_t *conn, const char *routername)
node = router->service_head;
http_output_stream_write_string(conn->out, "<ul>");
- while (node)
+ for (node = router->service_head; node; node = node->next)
{
- sprintf(buffer, "<li> [%s] (%s) </li>",
- node->service->urn,
- node->service->method);
+ switch (node->service->status)
+ {
+ case CSOAP_SERVICE_DOWN:
+ sprintf(buffer,
+ "<li>"
+ "%s (%s) <a href=\"?" CSOAP_ADMIN_QUERY_ACTIVATE "=%s&amp;" CSOAP_ADMIN_URN "=%s\">[Activate]</a>"
+ "</li>",
+ node->service->urn,
+ node->service->method,
+ node->service->method,
+ node->service->urn);
+ break;
+ case CSOAP_SERVICE_UP:
+ default:
+ sprintf(buffer,
+ "<li>"
+ "%s (%s) <a href=\"?" CSOAP_ADMIN_QUERY_PASSIVATE "=%s&amp;" CSOAP_ADMIN_URN "=%s\">[Passivate]</a>"
+ "</li>",
+ node->service->urn,
+ node->service->method,
+ node->service->method,
+ node->service->urn);
+ break;
+ }
http_output_stream_write_string(conn->out, buffer);
- node = node->next;
}
http_output_stream_write_string(conn->out, "</ul>");
- http_output_stream_write_string(conn->out, "</body></html>");
+ _soap_admin_send_footer(conn);
return;
}
-
static void
_soap_admin_handle_get(httpd_conn_t * conn, struct hrequest_t * req)
{
char *param;
- if ((param = hpairnode_get_ignore_case(req->query, SOAP_ADMIN_QUERY_ROUTERS)))
+ if ((param = hpairnode_get_ignore_case(req->query, CSOAP_ADMIN_QUERY_ROUTERS)))
{
_soap_admin_list_routers(conn);
}
- else if ((param = hpairnode_get_ignore_case(req->query, SOAP_ADMIN_QUERY_ROUTER)))
+ else if ((param = hpairnode_get_ignore_case(req->query, CSOAP_ADMIN_QUERY_ROUTER)))
{
_soap_admin_list_services(conn, param);
}
+ else if ((param = hpairnode_get_ignore_case(req->query, CSOAP_ADMIN_QUERY_ACTIVATE)))
+ {
+ _soap_admin_send_title(conn, "Not implemented");
+ _soap_admin_send_footer(conn);
+ // _soap_admin_activate_service(conn, param);
+ }
+ else if ((param = hpairnode_get_ignore_case(req->query, CSOAP_ADMIN_QUERY_PASSIVATE)))
+ {
+ _soap_admin_send_title(conn, "Not implemented");
+ _soap_admin_send_footer(conn);
+ // _soap_admin_passivate_service(conn, param);
+ }
else
{
_soap_admin_send_title(conn, "Welcome to the admin site");
http_output_stream_write_string(conn->out,
"<ul>"
- "<li><a href=\"?" SOAP_ADMIN_QUERY_ROUTERS "\">Routers</a></li>"
+ "<li><a href=\"?" CSOAP_ADMIN_QUERY_ROUTERS "\">Routers</a></li>"
"<li><a href=\"../inspection.wsil\">inspection.wsil</a> (try: -CSOAPwsil)</li>"
"<li><a href=\"../nhttp\">nanoHTTP</a></li>"
"</ul>");
- http_output_stream_write_string(conn->out, "</body></html>");
+ _soap_admin_send_footer(conn);
}
return;
@@ -192,6 +242,7 @@ _soap_admin_entry(httpd_conn_t * conn, struct hrequest_t * req)
"</body>"
"</html>");
}
+
return;
}
diff --git a/libcsoap/soap-admin.h b/libcsoap/soap-admin.h
index 1d121b3..2e0ca80 100644
--- a/libcsoap/soap-admin.h
+++ b/libcsoap/soap-admin.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: soap-admin.h,v 1.4 2006/11/23 15:27:33 m0gg Exp $
+ * $Id: soap-admin.h,v 1.5 2006/12/31 17:24:22 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -24,11 +24,17 @@
#ifndef __csoap_admin_h
#define __csoap_admin_h
-#define CSOAP_ENABLE_ADMIN "-CSOAPadmin"
+#define CSOAP_ENABLE_ADMIN "-CSOAPadmin"
-#define SOAP_ADMIN_QUERY_ROUTERS "routers"
-#define SOAP_ADMIN_QUERY_ROUTER "router"
-#define SOAP_ADMIN_QUERY_SERVICES "services"
+#define CSOAP_ADMIN_QUERY_ROUTERS "routers"
+#define CSOAP_ADMIN_QUERY_ROUTER "router"
+#define CSOAP_ADMIN_QUERY_SERVICES "services"
+
+#define CSOAP_ADMIN_QUERY_ACTIVATE "activate"
+#define CSOAP_ADMIN_QUERY_PASSIVATE "passivate"
+
+#define CSOAP_ADMIN_URN "urn"
+#define CSOAP_ADMIN_METHOD "method"
#ifdef __cplusplus
extern "C" {
diff --git a/libcsoap/soap-server.c b/libcsoap/soap-server.c
index b21688b..34b053f 100644
--- a/libcsoap/soap-server.c
+++ b/libcsoap/soap-server.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-server.c,v 1.35 2006/11/29 11:04:25 m0gg Exp $
+* $Id: soap-server.c,v 1.36 2006/12/31 17:24:22 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -179,19 +179,30 @@ soap_server_process(struct SoapCtx *request, struct SoapCtx **response)
if ((service = soap_router_find_service(router, urn, method)))
{
log_verbose3("service (%p) found, function (%p)", service, service->func);
- if ((err = service->func(request, *response)) == H_OK)
+ switch (service->status)
{
- if ((*response)->env == NULL)
- {
- sprintf(buffer, "Service for \"%s\" returned no envelope", urn);
- _soap_server_env_new_with_fault("Internal service error", buffer, &((*response)->env));
- }
- }
- else
- {
- sprintf(buffer, "Service returned following error message: \"%s\"", herror_message(err));
- herror_release(err);
- _soap_server_env_new_with_fault("Internal service error", buffer, &((*response)->env));
+ case CSOAP_SERVICE_UP:
+
+ if ((err = service->func(request, *response)) == H_OK)
+ {
+ if ((*response)->env == NULL)
+ {
+ sprintf(buffer, "Service for \"%s\" returned no envelope", urn);
+ _soap_server_env_new_with_fault("Internal service error", buffer, &((*response)->env));
+ }
+ }
+ else
+ {
+ sprintf(buffer, "Service returned following error message: \"%s\"", herror_message(err));
+ herror_release(err);
+ _soap_server_env_new_with_fault("Internal service error", buffer, &((*response)->env));
+ }
+ break;
+ case CSOAP_SERVICE_DOWN:
+ default:
+ sprintf(buffer, "Service for \"%s\" is down", urn);
+ _soap_server_env_new_with_fault("Internal service error", buffer, &((*response)->env));
+ break;
}
}
else
diff --git a/libcsoap/soap-service.c b/libcsoap/soap-service.c
index e63dd22..b731d76 100644
--- a/libcsoap/soap-service.c
+++ b/libcsoap/soap-service.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-service.c,v 1.12 2006/11/25 15:06:57 m0gg Exp $
+* $Id: soap-service.c,v 1.13 2006/12/31 17:24:22 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -100,6 +100,8 @@ soap_service_new(const char *urn, const char *method, SoapServiceFunc f)
}
service->method = strdup(method);
+ service->status = CSOAP_SERVICE_UP;
+
return service;
}
diff --git a/libcsoap/soap-service.h b/libcsoap/soap-service.h
index 33d69f6..47072b4 100644
--- a/libcsoap/soap-service.h
+++ b/libcsoap/soap-service.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: soap-service.h,v 1.9 2006/11/27 10:49:57 m0gg Exp $
+ * $Id: soap-service.h,v 1.10 2006/12/31 17:24:22 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -33,12 +33,31 @@
* messages, typically conveyed using HTTP with an XML serialization in
* conjunction with other Web-related standards.
*
- * @see http://www.w3.org/TR/wslc/,
- * http://www.w3.org/TR/wsdl,
- * http://www.w3.org/TR/owl-ref/
+ * @see http://www.w3.org/TR/wslc/
+ * @see http://www.w3.org/TR/wsdl
+ * @see http://www.w3.org/TR/owl-ref/
*
*/
+/**
+ *
+ * This service status shows that the provider agent is not capable of accepting
+ * any requests (i.e. the service is not available).
+ *
+ * @see http://www.w3.org/TR/wslc/
+ *
+ */
+#define CSOAP_SERVICE_DOWN 0
+
+/**
+ *
+ * This service status shows that the provider agent is capable of accepting and
+ * processing requests (i.e. the service is available)
+ *
+ * @see http://www.w3.org/TR/wslc/
+ *
+ */
+#define CSOAP_SERVICE_UP 1
typedef herror_t (*SoapServiceFunc)(struct SoapCtx *request, struct SoapCtx *response);
@@ -46,6 +65,7 @@ typedef struct _SoapService
{
char *urn;
char *method;
+ int status;
SoapServiceFunc func;
} SoapService;