summaryrefslogtreecommitdiffstats
path: root/libcsoap/soap-env.c
diff options
context:
space:
mode:
authorGravatar snowdrop2004-11-02 23:09:19 +0000
committerGravatar snowdrop2004-11-02 23:09:19 +0000
commit402e8748593a42cf6d42fda772f207e3e9300a3e (patch)
tree8c87ecde3498891a6de178f2a77dc4d9cf20fe57 /libcsoap/soap-env.c
parent15b392f1e21d3dae8f83da401199959e9f0b0db6 (diff)
downloadcsoap-402e8748593a42cf6d42fda772f207e3e9300a3e.tar.gz
csoap-402e8748593a42cf6d42fda772f207e3e9300a3e.tar.bz2
dos2unix
Diffstat (limited to 'libcsoap/soap-env.c')
-rw-r--r--libcsoap/soap-env.c212
1 files changed, 106 insertions, 106 deletions
diff --git a/libcsoap/soap-env.c b/libcsoap/soap-env.c
index 6527028..2018b3d 100644
--- a/libcsoap/soap-env.c
+++ b/libcsoap/soap-env.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-env.c,v 1.9 2004/10/28 10:30:46 snowdrop Exp $
+* $Id: soap-env.c,v 1.10 2004/11/02 23:09:26 snowdrop Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -102,91 +102,91 @@ static
/* ---------------------------------------------------------------------------- */
-
-
-herror_t
-soap_env_new_from_doc (xmlDocPtr doc, SoapEnv **out)
-{
- xmlNodePtr node;
- SoapEnv *env;
-
- if (doc == NULL)
- {
- log_error1 ("Can not create xml document!");
- return herror_new("soap_env_new_from_doc",
- GENERAL_INVALID_PARAM, "XML Document (xmlDocPtr) is NULL");
- }
-
- node = xmlDocGetRootElement (doc);
- if (node == NULL)
- {
- log_error1 ("xml document is empty!");
- return herror_new("soap_env_new_from_doc",
- XML_ERROR_EMPTY_DOCUMENT, "XML Document is empty!");
- }
-
- env = (SoapEnv *) malloc (sizeof (SoapEnv));
-
- /* set root */
- env->root = node;
-
- /* set method root
- set call->cur (current node) to <method>.
- xpath: //Envelope/Body/
- */
- node = soap_xml_get_children (env->root);/* Check for NULL ! */
- env->cur = soap_xml_get_children (node); /* Check for NULL ! */
-
- *out = env;
- return H_OK;
-}
-
-
-
-
-herror_t
-soap_env_new_from_buffer (const char *buffer, SoapEnv **out)
-{
- xmlDocPtr doc;
- herror_t err;
-
- if (buffer == NULL)
- return herror_new("soap_env_new_from_buffer",
- GENERAL_INVALID_PARAM, "buffer (first param) is NULL");
-
- doc = xmlParseDoc (BAD_CAST buffer);
- if (doc == NULL)
- return herror_new("soap_env_new_from_buffer",
- XML_ERROR_PARSE, "Can not parse xml");
-
- err = soap_env_new_from_doc (doc, out);
- if (err != H_OK) {
- xmlFreeDoc (doc);
- }
-
- return err;
-}
-
-
+
+
+herror_t
+soap_env_new_from_doc (xmlDocPtr doc, SoapEnv **out)
+{
+ xmlNodePtr node;
+ SoapEnv *env;
+
+ if (doc == NULL)
+ {
+ log_error1 ("Can not create xml document!");
+ return herror_new("soap_env_new_from_doc",
+ GENERAL_INVALID_PARAM, "XML Document (xmlDocPtr) is NULL");
+ }
+
+ node = xmlDocGetRootElement (doc);
+ if (node == NULL)
+ {
+ log_error1 ("xml document is empty!");
+ return herror_new("soap_env_new_from_doc",
+ XML_ERROR_EMPTY_DOCUMENT, "XML Document is empty!");
+ }
+
+ env = (SoapEnv *) malloc (sizeof (SoapEnv));
+
+ /* set root */
+ env->root = node;
+
+ /* set method root
+ set call->cur (current node) to <method>.
+ xpath: //Envelope/Body/
+ */
+ node = soap_xml_get_children (env->root);/* Check for NULL ! */
+ env->cur = soap_xml_get_children (node); /* Check for NULL ! */
+
+ *out = env;
+ return H_OK;
+}
+
+
+
+
+herror_t
+soap_env_new_from_buffer (const char *buffer, SoapEnv **out)
+{
+ xmlDocPtr doc;
+ herror_t err;
+
+ if (buffer == NULL)
+ return herror_new("soap_env_new_from_buffer",
+ GENERAL_INVALID_PARAM, "buffer (first param) is NULL");
+
+ doc = xmlParseDoc (BAD_CAST buffer);
+ if (doc == NULL)
+ return herror_new("soap_env_new_from_buffer",
+ XML_ERROR_PARSE, "Can not parse xml");
+
+ err = soap_env_new_from_doc (doc, out);
+ if (err != H_OK) {
+ xmlFreeDoc (doc);
+ }
+
+ return err;
+}
+
+
herror_t
soap_env_new_with_fault (fault_code_t faultcode,
const char *faultstring,
const char *faultactor, const char *detail, SoapEnv **out)
{
xmlDocPtr doc;
- herror_t err;
-
+ herror_t err;
+
doc = soap_fault_build (faultcode, faultstring, faultactor, detail);
if (doc == NULL)
- return herror_new("soap_env_new_with_fault",
- XML_ERROR_PARSE, "Can not parse fault xml");
-
- err = soap_env_new_from_doc (doc, out);
- if (err != H_OK) {
- xmlFreeDoc (doc);
- }
-
- return err;
+ return herror_new("soap_env_new_with_fault",
+ XML_ERROR_PARSE, "Can not parse fault xml");
+
+ err = soap_env_new_from_doc (doc, out);
+ if (err != H_OK) {
+ xmlFreeDoc (doc);
+ }
+
+ return err;
}
@@ -199,20 +199,20 @@ soap_env_new_with_response (SoapEnv * request, SoapEnv **out)
if (request == NULL)
{
- return herror_new("soap_env_new_with_response",
- GENERAL_INVALID_PARAM, "request (first param) is NULL");
+ return herror_new("soap_env_new_with_response",
+ GENERAL_INVALID_PARAM, "request (first param) is NULL");
}
if (request->root == NULL)
{
- return herror_new("soap_env_new_with_response",
- GENERAL_INVALID_PARAM, "request (first param) has no xml structure");
+ return herror_new("soap_env_new_with_response",
+ GENERAL_INVALID_PARAM, "request (first param) has no xml structure");
}
if (!soap_env_find_methodname (request, methodname))
{
- return herror_new("soap_env_new_with_response",
- GENERAL_INVALID_PARAM, "Method name '%s' not found in request", SAVE_STR(methodname));
+ return herror_new("soap_env_new_with_response",
+ GENERAL_INVALID_PARAM, "Method name '%s' not found in request", SAVE_STR(methodname));
}
if (!soap_env_find_urn (request, urn))
@@ -263,29 +263,29 @@ soap_env_new_with_method (const char *urn, const char *method, SoapEnv **out)
#endif
}
-
- env = xmlParseDoc (buffer);
- if (!env)
- return herror_new("soap_env_new_with_method",
- XML_ERROR_PARSE, "Can not parse xml");
+
+ env = xmlParseDoc (buffer);
+ if (!env)
+ return herror_new("soap_env_new_with_method",
+ XML_ERROR_PARSE, "Can not parse xml");
return soap_env_new_from_doc (env, out);
}
-
-
+
+
static
int _soap_env_xml_io_read(void* ctx, char *buffer, int len)
-{
+{
int readed;
- http_input_stream_t *in = (http_input_stream_t*)ctx;
+ http_input_stream_t *in = (http_input_stream_t*)ctx;
if(!http_input_stream_is_ready(in))
- return 0;
-
- readed = http_input_stream_read(in, buffer, len);
- if (readed == -1)
- return 0;
+ return 0;
+
+ readed = http_input_stream_read(in, buffer, len);
+ if (readed == -1)
+ return 0;
return readed;
}
@@ -296,21 +296,21 @@ int _soap_env_xml_io_close(void *ctx)
return 0;
}
-
+
herror_t
soap_env_new_from_stream(http_input_stream_t *in, SoapEnv **out)
{
- xmlDocPtr doc;
+ xmlDocPtr doc;
herror_t err;
-
+
doc = xmlReadIO(_soap_env_xml_io_read,
_soap_env_xml_io_close, in, "", NULL, 0);
-
- if (in->err != H_OK) return in->err;
- if (doc == NULL) return herror_new("soap_env_new_from_stream",
+
+ if (in->err != H_OK) return in->err;
+ if (doc == NULL) return herror_new("soap_env_new_from_stream",
XML_ERROR_PARSE, "Trying to parse not valid xml");
- err = soap_env_new_from_doc (doc, out);
- return err;
+ err = soap_env_new_from_doc (doc, out);
+ return err;
}