From a56fa8644e888b63fbe8f97b2c356ce39bd47ee7 Mon Sep 17 00:00:00 2001 From: snowdrop Date: Mon, 27 Mar 2006 12:12:53 +0000 Subject: initial import --- libcsoap/soap-admin.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 libcsoap/soap-admin.c (limited to 'libcsoap') diff --git a/libcsoap/soap-admin.c b/libcsoap/soap-admin.c new file mode 100644 index 0000000..1ee9db5 --- /dev/null +++ b/libcsoap/soap-admin.c @@ -0,0 +1,114 @@ + + +#define SOAP_ADMIN_QUERY_ROUTERS "routers" +#define SOAP_ADMIN_QUERY_ROUTER "router" +#define SOAP_ADMIN_QUERY_SERVICES "services" + + +static void +_soap_admin_send_title(httpd_conn_t* conn, const char* title) +{ + httpd_send_header(conn, 200, "OK"); + http_output_stream_write_string(conn->out, + "csoap "); + http_output_stream_write_string(conn->out, title); + http_output_stream_write_string(conn->out, "
"); +} + + +static void +_soap_admin_list_routers(httpd_conn_t* conn) +{ + SoapRouterNode *node; + char buffer[1024]; + + _soap_admin_send_title(conn, "Available routers"); + + for (node = head; node; node = node->next) + { + sprintf(buffer, "
  • %s", + node->context, node->context); + http_output_stream_write_string(conn->out, buffer); + } + + http_output_stream_write_string(conn->out, ""); +} + +static void +_soap_admin_list_services(httpd_conn_t* conn, const char* routername) +{ + SoapRouter *router; + SoapServiceNode *node; + char buffer[1024]; + + sprintf(buffer, "Listing Services for Router %s", routername); + _soap_admin_send_title(conn, buffer); + + router = router_find(routername); + if (!router) { + http_output_stream_write_string(conn->out, "Router not found!"); + http_output_stream_write_string(conn->out, ""); + return; + } + + node = router->service_head; + + while (node) { + sprintf(buffer, "
  • [%s] (%s)", + node->service->urn, + node->service->method); + http_output_stream_write_string(conn->out, buffer); + node = node->next; + } + + http_output_stream_write_string(conn->out, ""); +} + + + +static void +_soap_admin_handle_get(httpd_conn_t * conn, hrequest_t * req) +{ + char *param; + + if ((param = hpairnode_get_ignore_case(req->query, SOAP_ADMIN_QUERY_ROUTERS))) { + _soap_admin_list_routers(conn); + } else if ((param = hpairnode_get_ignore_case(req->query, SOAP_ADMIN_QUERY_ROUTER))) { + _soap_admin_list_services(conn, param); + } else { + _soap_admin_send_title(conn, "Welcome to the admin site"); + http_output_stream_write_string(conn->out, + "
  • Routers "); + http_output_stream_write_string(conn->out, + ""); + } +} + +static void +_soap_admin_entry(httpd_conn_t * conn, hrequest_t * req) +{ + if (req->method == HTTP_REQUEST_GET) { + _soap_admin_handle_get(conn, req); + } else { + httpd_send_header(conn, 200, "OK"); + http_output_stream_write_string(conn->out, + "" + "" + "" + "" + "

    Sorry!

    " + "
    " + "
    POST Service is not implemented now. Use your browser
    " + "" + ""); + } +} -- cgit v1.1-32-gdbae