From 402e8748593a42cf6d42fda772f207e3e9300a3e Mon Sep 17 00:00:00 2001 From: snowdrop Date: Tue, 2 Nov 2004 23:09:19 +0000 Subject: dos2unix --- libcsoap/soap-client.c | 116 ++++++++++----------- libcsoap/soap-client.h | 146 +++++++++++++------------- libcsoap/soap-ctx.c | 270 ++++++++++++++++++++++++------------------------- libcsoap/soap-ctx.h | 142 +++++++++++++------------- libcsoap/soap-env.c | 212 +++++++++++++++++++------------------- libcsoap/soap-env.h | 28 ++--- libcsoap/soap-server.c | 94 ++++++++--------- libcsoap/soap-server.h | 8 +- 8 files changed, 508 insertions(+), 508 deletions(-) (limited to 'libcsoap') diff --git a/libcsoap/soap-client.c b/libcsoap/soap-client.c index bec9044..fa65864 100644 --- a/libcsoap/soap-client.c +++ b/libcsoap/soap-client.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: soap-client.c,v 1.13 2004/11/02 22:42:52 snowdrop Exp $ +* $Id: soap-client.c,v 1.14 2004/11/02 23:09:26 snowdrop Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -25,21 +25,21 @@ #include #include -/*--------------------------------- */ +/*--------------------------------- */ static int _block_socket = 0; static herror_t _soap_client_build_result(hresponse_t *res, SoapEnv **out); /*--------------------------------- */ - -void soap_client_block_socket(int block) -{ - _block_socket = block; -} - -int soap_client_get_blockmode() -{ - return _block_socket; -} - + +void soap_client_block_socket(int block) +{ + _block_socket = block; +} + +int soap_client_get_blockmode() +{ + return _block_socket; +} + herror_t soap_client_init_args(int argc, char *argv[]) @@ -50,10 +50,10 @@ herror_t soap_client_init_args(int argc, char *argv[]) } -void soap_client_destroy() -{ - httpc_destroy(); -} +void soap_client_destroy() +{ + httpc_destroy(); +} static long _file_get_size(const char* filename) @@ -69,7 +69,7 @@ long _file_get_size(const char* filename) return size; } - + herror_t soap_client_invoke(SoapCtx *call, SoapCtx** response, const char *url, const char *soap_action) { @@ -93,17 +93,17 @@ soap_client_invoke(SoapCtx *call, SoapCtx** response, const char *url, const cha static int counter=1; part_t *part; int file_count=0; - + /* for copy attachments */ - char href[MAX_HREF_SIZE]; - + char href[MAX_HREF_SIZE]; + /* Create buffer */ buffer = xmlBufferCreate(); xmlNodeDump(buffer, call->env->root->doc,call->env->root, 1 ,0); content = (char*)xmlBufferContent(buffer); /* Transport via HTTP */ - conn = httpc_new(); + conn = httpc_new(); conn->block = soap_client_get_blockmode(); /* Set soap action */ @@ -123,7 +123,7 @@ soap_client_invoke(SoapCtx *call, SoapCtx** response, const char *url, const cha if (status != H_OK) { httpc_free(conn); - xmlBufferFree(buffer); + xmlBufferFree(buffer); return status; } @@ -131,14 +131,14 @@ soap_client_invoke(SoapCtx *call, SoapCtx** response, const char *url, const cha if (status != H_OK) { httpc_free(conn); xmlBufferFree(buffer); - return status; + return status; } status = httpc_post_end(conn, &res); if (status != H_OK) { httpc_free(conn); xmlBufferFree(buffer); - return status; + return status; } } else @@ -152,21 +152,21 @@ soap_client_invoke(SoapCtx *call, SoapCtx** response, const char *url, const cha if (status != H_OK) { httpc_free(conn); xmlBufferFree(buffer); - return status; + return status; } status = httpc_mime_next(conn, start_id, "text/xml", "binary"); if (status != H_OK) { httpc_free(conn); xmlBufferFree(buffer); - return status; + return status; } status = http_output_stream_write(conn->out, content, strlen(content)); if (status != H_OK) { httpc_free(conn); xmlBufferFree(buffer); - return status; + return status; } @@ -178,7 +178,7 @@ soap_client_invoke(SoapCtx *call, SoapCtx** response, const char *url, const cha log_error2("Send file failed. Status:%d", status); httpc_free(conn); xmlBufferFree(buffer); - return status; + return status; } } @@ -187,7 +187,7 @@ soap_client_invoke(SoapCtx *call, SoapCtx** response, const char *url, const cha { httpc_free(conn); xmlBufferFree(buffer); - return status; + return status; } } @@ -196,58 +196,58 @@ soap_client_invoke(SoapCtx *call, SoapCtx** response, const char *url, const cha /* Build result */ status = _soap_client_build_result(res, &res_env); - if (status != H_OK) { - hresponse_free(res); - httpc_free(conn); - return status; - } + if (status != H_OK) { + hresponse_free(res); + httpc_free(conn); + return status; + } /* Create Context */ *response = soap_ctx_new(res_env); -/* soap_ctx_add_files(*response, res->attachments);*/ - - if (res->attachments!=NULL) { - part = res->attachments->parts; - while (part) { - soap_ctx_add_file(*response, part->filename, part->content_type, href); - part->deleteOnExit = 0; - part = part->next; - } - part = (*response)->attachments->parts; - while (part) { - part->deleteOnExit = 1; - part = part->next; - } - } - - +/* soap_ctx_add_files(*response, res->attachments);*/ + + if (res->attachments!=NULL) { + part = res->attachments->parts; + while (part) { + soap_ctx_add_file(*response, part->filename, part->content_type, href); + part->deleteOnExit = 0; + part = part->next; + } + part = (*response)->attachments->parts; + while (part) { + part->deleteOnExit = 1; + part = part->next; + } + } + + hresponse_free(res); - httpc_free(conn); + httpc_free(conn); return H_OK; } -static +static herror_t _soap_client_build_result(hresponse_t *res, SoapEnv** env) -{ +{ herror_t err; log_verbose2("Building result (%p)", res); if (res == NULL) - return herror_new("_soap_client_build_result", + return herror_new("_soap_client_build_result", GENERAL_INVALID_PARAM, "hresponse_t is NULL"); if (res->in == NULL) - return herror_new("_soap_client_build_result", + return herror_new("_soap_client_build_result", GENERAL_INVALID_PARAM, "Empty response from server"); err = soap_env_new_from_stream(res->in, env); - if (err != H_OK) { + if (err != H_OK) { return err; } diff --git a/libcsoap/soap-client.h b/libcsoap/soap-client.h index 7042aad..e0f79bf 100644 --- a/libcsoap/soap-client.h +++ b/libcsoap/soap-client.h @@ -1,73 +1,73 @@ -/****************************************************************** - * $Id: soap-client.h,v 1.8 2004/11/02 22:42:52 snowdrop Exp $ - * - * CSOAP Project: A SOAP client/server library in C - * Copyright (C) 2003 Ferhat Ayaz - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Email: ayaz@jprogrammer.net - ******************************************************************/ -#ifndef cSOAP_CLIENT_H -#define cSOAP_CLIENT_H - -#include -#include - -/** - Initializes the client side soap engine -*/ -herror_t soap_client_init_args(int argc, char *argv[]); - - -/** - Destroy the soap client module -*/ -void soap_client_destroy(); - - -/** - Establish connection to the soap server and send - the given envelope. - - @param env envelope to send - @param response the result envelope - @param url url to the soap server - @soap_action value for "SoapAction:" in the - HTTP request header. - - @returns H_OK if success - */ -herror_t soap_client_invoke(SoapCtx *ctx, SoapCtx** response, - const char *url, - const char *soap_action); - - - -/** - Sets the underlaying socket to use while connecting - into block mode or not block mode. - The default mode is always non-blocking mode. - - @param block 1 to creat blocked sockets, 0 to create non - blocking sockets. -*/ -void soap_client_block_socket(int block); -int soap_client_get_blockmode(); - -#endif - - +/****************************************************************** + * $Id: soap-client.h,v 1.9 2004/11/02 23:09:26 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ayaz@jprogrammer.net + ******************************************************************/ +#ifndef cSOAP_CLIENT_H +#define cSOAP_CLIENT_H + +#include +#include + +/** + Initializes the client side soap engine +*/ +herror_t soap_client_init_args(int argc, char *argv[]); + + +/** + Destroy the soap client module +*/ +void soap_client_destroy(); + + +/** + Establish connection to the soap server and send + the given envelope. + + @param env envelope to send + @param response the result envelope + @param url url to the soap server + @soap_action value for "SoapAction:" in the + HTTP request header. + + @returns H_OK if success + */ +herror_t soap_client_invoke(SoapCtx *ctx, SoapCtx** response, + const char *url, + const char *soap_action); + + + +/** + Sets the underlaying socket to use while connecting + into block mode or not block mode. + The default mode is always non-blocking mode. + + @param block 1 to creat blocked sockets, 0 to create non + blocking sockets. +*/ +void soap_client_block_socket(int block); +int soap_client_get_blockmode(); + +#endif + + diff --git a/libcsoap/soap-ctx.c b/libcsoap/soap-ctx.c index 423bcfe..5fe0685 100755 --- a/libcsoap/soap-ctx.c +++ b/libcsoap/soap-ctx.c @@ -1,135 +1,135 @@ -/****************************************************************** - * $Id: soap-ctx.c,v 1.3 2004/11/01 15:16:26 snowdrop Exp $ - * - * CSOAP Project: A SOAP client/server library in C - * Copyright (C) 2003-2004 Ferhat Ayaz - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Email: ferhatayaz@jprogrammer.net - ******************************************************************/ -#include - - -SoapCtx* soap_ctx_new(SoapEnv *env) /* should only be used internally */ -{ - SoapCtx* ctx = (SoapCtx*)malloc(sizeof(SoapCtx)); - ctx->env = env; - ctx->attachments = NULL; - - return ctx; -} - - -void soap_ctx_add_files(SoapCtx* ctx, attachments_t *attachments) -{ - part_t *part; - char href[MAX_HREF_SIZE]; - - if (attachments==NULL) return; - - part = attachments->parts; - while (part) { - soap_ctx_add_file(ctx, part->filename, part->content_type, href); - part = part->next; - } -} - - -herror_t soap_ctx_add_file(SoapCtx* ctx, const char* filename, const char* content_type, char *dest_href) -{ - char cid[250]; - char id[250]; - part_t *part; - static int counter = 1; - FILE *test = fopen(filename, "r"); - if (!test) - return herror_new("soap_ctx_add_file", FILE_ERROR_OPEN, - "Can not open file '%s'", filename); - - fclose(test); - - /* generate an id */ - sprintf(id, "005512345894583%d", counter++); - sprintf(dest_href, "cid:%s", id); - sprintf(cid, "<%s>", id); - - /* add part to context */ - part = part_new(cid, filename, content_type, NULL, NULL); - if (!ctx->attachments) ctx->attachments = attachments_new(); - attachments_add_part(ctx->attachments, part); - - return H_OK; -} - -part_t *soap_ctx_get_file(SoapCtx* ctx, xmlNodePtr node) -{ - xmlChar *prop; - char href[MAX_HREF_SIZE]; - char buffer[MAX_HREF_SIZE]; - part_t *part; - - if (!ctx->attachments) return NULL; - - prop = xmlGetProp(node, "href"); - - if (!prop) NULL; - - strcpy(href, (const char*)prop); - if (!strncmp(href, "cid:", 4)) { - for (part = ctx->attachments->parts; part; part=part->next) - { - sprintf(buffer, "<%s>", href+4); - if (!strcmp(part->id, buffer)) - return part; - - } - } else { - for (part = ctx->attachments->parts; part; part=part->next) - { - if (!strcmp(part->location, href)) - return part; - - } - } - - return NULL; -} - -void soap_ctx_free(SoapCtx* ctx) -{ - if (!ctx) return; - - if (ctx->attachments) - attachments_free(ctx->attachments); - if (ctx->env) - soap_env_free(ctx->env); - - free(ctx); -} - - -herror_t soap_ctx_new_with_method(const char *urn, const char *method, SoapCtx **out) -{ - SoapEnv *env; - herror_t err; - err = soap_env_new_with_method(urn, method, &env); - if (err != H_OK) return err; - *out = soap_ctx_new(env); - - return H_OK; -} - +/****************************************************************** + * $Id: soap-ctx.c,v 1.4 2004/11/02 23:09:26 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003-2004 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ferhatayaz@jprogrammer.net + ******************************************************************/ +#include + + +SoapCtx* soap_ctx_new(SoapEnv *env) /* should only be used internally */ +{ + SoapCtx* ctx = (SoapCtx*)malloc(sizeof(SoapCtx)); + ctx->env = env; + ctx->attachments = NULL; + + return ctx; +} + + +void soap_ctx_add_files(SoapCtx* ctx, attachments_t *attachments) +{ + part_t *part; + char href[MAX_HREF_SIZE]; + + if (attachments==NULL) return; + + part = attachments->parts; + while (part) { + soap_ctx_add_file(ctx, part->filename, part->content_type, href); + part = part->next; + } +} + + +herror_t soap_ctx_add_file(SoapCtx* ctx, const char* filename, const char* content_type, char *dest_href) +{ + char cid[250]; + char id[250]; + part_t *part; + static int counter = 1; + FILE *test = fopen(filename, "r"); + if (!test) + return herror_new("soap_ctx_add_file", FILE_ERROR_OPEN, + "Can not open file '%s'", filename); + + fclose(test); + + /* generate an id */ + sprintf(id, "005512345894583%d", counter++); + sprintf(dest_href, "cid:%s", id); + sprintf(cid, "<%s>", id); + + /* add part to context */ + part = part_new(cid, filename, content_type, NULL, NULL); + if (!ctx->attachments) ctx->attachments = attachments_new(); + attachments_add_part(ctx->attachments, part); + + return H_OK; +} + +part_t *soap_ctx_get_file(SoapCtx* ctx, xmlNodePtr node) +{ + xmlChar *prop; + char href[MAX_HREF_SIZE]; + char buffer[MAX_HREF_SIZE]; + part_t *part; + + if (!ctx->attachments) return NULL; + + prop = xmlGetProp(node, "href"); + + if (!prop) NULL; + + strcpy(href, (const char*)prop); + if (!strncmp(href, "cid:", 4)) { + for (part = ctx->attachments->parts; part; part=part->next) + { + sprintf(buffer, "<%s>", href+4); + if (!strcmp(part->id, buffer)) + return part; + + } + } else { + for (part = ctx->attachments->parts; part; part=part->next) + { + if (!strcmp(part->location, href)) + return part; + + } + } + + return NULL; +} + +void soap_ctx_free(SoapCtx* ctx) +{ + if (!ctx) return; + + if (ctx->attachments) + attachments_free(ctx->attachments); + if (ctx->env) + soap_env_free(ctx->env); + + free(ctx); +} + + +herror_t soap_ctx_new_with_method(const char *urn, const char *method, SoapCtx **out) +{ + SoapEnv *env; + herror_t err; + err = soap_env_new_with_method(urn, method, &env); + if (err != H_OK) return err; + *out = soap_ctx_new(env); + + return H_OK; +} + diff --git a/libcsoap/soap-ctx.h b/libcsoap/soap-ctx.h index a55f18f..a8a8337 100755 --- a/libcsoap/soap-ctx.h +++ b/libcsoap/soap-ctx.h @@ -1,71 +1,71 @@ -/****************************************************************** - * $Id: soap-ctx.h,v 1.4 2004/11/01 15:16:26 snowdrop Exp $ - * - * CSOAP Project: A SOAP client/server library in C - * Copyright (C) 2003-2004 Ferhat Ayaz - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Email: ferhatayaz@jprogrammer.net - ******************************************************************/ -#ifndef cSOAP_CTX_H -#define cSOAP_CTX_H - - -#include -#include - - -#define SOAP_ERROR_NO_FILE_ATTACHED 4001 -#define SOAP_ERROR_EMPTY_ATTACHMENT 4002 - -#define MAX_HREF_SIZE 150 - -typedef struct _SoapCtx -{ - SoapEnv *env; - attachments_t *attachments; -}SoapCtx; - - -SoapCtx* soap_ctx_new(SoapEnv *env); /* should only be used internally */ - -/** - Returns the attached file if any found. - @param ctx the SoapCtx object which should contain the part - @param node the xml node which points to a file via the "href" xml attribute - - @returns a part_t object of attachment was found, NULL otherwise. - -*/ -part_t *soap_ctx_get_file(SoapCtx* ctx, xmlNodePtr node); - -/** - Creates a new soap context object. -*/ -herror_t soap_ctx_new_with_method(const char *urn, const char *method, SoapCtx **out); - -/* Size of destination dest_href should be MAX_HREF_SIZE */ -herror_t soap_ctx_add_file(SoapCtx* ctx, const char* filename, const char* content_type, char *dest_href); -/* -Used internally. Will switch the deleteOnExit flag from the -given one to the added part. -*/ -void soap_ctx_add_files(SoapCtx* ctx, attachments_t *attachments); -void soap_ctx_free(SoapCtx* ctx); - -#endif - +/****************************************************************** + * $Id: soap-ctx.h,v 1.5 2004/11/02 23:09:26 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003-2004 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ferhatayaz@jprogrammer.net + ******************************************************************/ +#ifndef cSOAP_CTX_H +#define cSOAP_CTX_H + + +#include +#include + + +#define SOAP_ERROR_NO_FILE_ATTACHED 4001 +#define SOAP_ERROR_EMPTY_ATTACHMENT 4002 + +#define MAX_HREF_SIZE 150 + +typedef struct _SoapCtx +{ + SoapEnv *env; + attachments_t *attachments; +}SoapCtx; + + +SoapCtx* soap_ctx_new(SoapEnv *env); /* should only be used internally */ + +/** + Returns the attached file if any found. + @param ctx the SoapCtx object which should contain the part + @param node the xml node which points to a file via the "href" xml attribute + + @returns a part_t object of attachment was found, NULL otherwise. + +*/ +part_t *soap_ctx_get_file(SoapCtx* ctx, xmlNodePtr node); + +/** + Creates a new soap context object. +*/ +herror_t soap_ctx_new_with_method(const char *urn, const char *method, SoapCtx **out); + +/* Size of destination dest_href should be MAX_HREF_SIZE */ +herror_t soap_ctx_add_file(SoapCtx* ctx, const char* filename, const char* content_type, char *dest_href); +/* +Used internally. Will switch the deleteOnExit flag from the +given one to the added part. +*/ +void soap_ctx_add_files(SoapCtx* ctx, attachments_t *attachments); +void soap_ctx_free(SoapCtx* ctx); + +#endif + 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 . - 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 . + 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; } diff --git a/libcsoap/soap-env.h b/libcsoap/soap-env.h index 58af136..523438d 100644 --- a/libcsoap/soap-env.h +++ b/libcsoap/soap-env.h @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: soap-env.h,v 1.8 2004/10/28 10:30:46 snowdrop Exp $ + * $Id: soap-env.h,v 1.9 2004/11/02 23:09:26 snowdrop Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -71,7 +71,7 @@ typedef struct _SoapEnv - */ + */ herror_t soap_env_new_with_fault(fault_code_t faultcode, const char *faultstring, @@ -85,8 +85,8 @@ soap_env_new_with_fault(fault_code_t faultcode, @param urn The urn of the soap service to invoke @param method The method name of the soap service - @param out the result envelope out parameter like follows - @returns H_OK if success + @param out the result envelope out parameter like follows + @returns H_OK if success
    
 
  */
-herror_t
+herror_t
 soap_env_new_with_method(const char *urn, const char *method, SoapEnv **out);
 
 
@@ -118,8 +118,8 @@ soap_env_new_with_method(const char *urn, const char *method, SoapEnv **out);
    @param req The request object. A response object will be created
     to this request.
 
-   @param out the result envelope out paramter like follows
-   @returns H_OK if success
+   @param out the result envelope out paramter like follows
+   @returns H_OK if success
 
    
    context);
 		free(node);
 		node = tmp;
-	}
+	}
 	httpd_destroy();
 }
 
@@ -114,7 +114,7 @@ void soap_server_entry(httpd_conn_t *conn, hrequest_t *req)
 	SoapCtx *ctx, *ctxres;
 	SoapRouter *router;
 	SoapService *service;
-	SoapEnv *env;
+	SoapEnv *env;
 	herror_t err;
 
 	if (req->method != HTTP_REQUEST_POST) {
@@ -128,15 +128,15 @@ void soap_server_entry(httpd_conn_t *conn, hrequest_t *req)
 	}
 
 
-	header = hpairnode_new(HEADER_CONTENT_TYPE, "text/xml", NULL);
-
-	err = soap_env_new_from_stream(req->in, &env);
-	if (err != H_OK) 
-	{
-  		_soap_server_send_fault(conn, header, herror_message(err));
-		herror_release(err);
-		return;
-	}
+	header = hpairnode_new(HEADER_CONTENT_TYPE, "text/xml", NULL);
+
+	err = soap_env_new_from_stream(req->in, &env);
+	if (err != H_OK) 
+	{
+  		_soap_server_send_fault(conn, header, herror_message(err));
+		herror_release(err);
+		return;
+	}
 
 
 	if (env == NULL) {
@@ -192,20 +192,20 @@ void soap_server_entry(httpd_conn_t *conn, hrequest_t *req)
 					return;
 				} else {
 
-					log_verbose2("func: %p", service->func);
+					log_verbose2("func: %p", service->func);
 					ctxres = soap_ctx_new(NULL);
 					/* ===================================== */
           /*       CALL SERVICE FUNCTION           */
 					/* ===================================== */
-					err = service->func(ctx, ctxres);
-					if (err != H_OK) {
-						sprintf(buffer, "Service returned following error message: '%s'",
-							herror_message(err));
-						herror_release(err);
-						_soap_server_send_fault(conn, header, buffer);
-						soap_ctx_free(ctx);
-						return;
-					}
+					err = service->func(ctx, ctxres);
+					if (err != H_OK) {
+						sprintf(buffer, "Service returned following error message: '%s'",
+							herror_message(err));
+						herror_release(err);
+						_soap_server_send_fault(conn, header, buffer);
+						soap_ctx_free(ctx);
+						return;
+					}
 
 					if (ctxres->env == NULL) {
 
@@ -289,37 +289,37 @@ static
 void _soap_server_send_fault(httpd_conn_t *conn, hpair_t *header, 
 							 const char* errmsg)
 {
-	SoapEnv *envres;
-	herror_t err;
+	SoapEnv *envres;
+	herror_t err;
 	char buffer[45];
 	httpd_set_headers(conn, header);
-	err = httpd_send_header(conn, 500, "FAILED");
-	if (err != H_OK) {
-		 /* WARNING: unhandled exception !*/
-		log_error4("%s():%s [%d]", herror_func(err), herror_message(err), herror_code(err));
-		return;
-	}
+	err = httpd_send_header(conn, 500, "FAILED");
+	if (err != H_OK) {
+		 /* WARNING: unhandled exception !*/
+		log_error4("%s():%s [%d]", herror_func(err), herror_message(err), herror_code(err));
+		return;
+	}
 
 	err = soap_env_new_with_fault(Fault_Server,
 		errmsg?errmsg:"General error",
-		"cSOAP_Server", NULL, &envres);
-	 if (err != H_OK) {
-		 log_error1(herror_message(err));
-		http_output_stream_write_string(conn->out, "");
-		http_output_stream_write_string(conn->out, "

Error


"); - http_output_stream_write_string(conn->out, "Error while sending fault object:
Message: "); - http_output_stream_write_string(conn->out, herror_message(err)); - http_output_stream_write_string(conn->out, "
Function: "); - http_output_stream_write_string(conn->out, herror_func(err)); - http_output_stream_write_string(conn->out, "
Error code: "); - sprintf(buffer, "%d", herror_code(err)); - http_output_stream_write_string(conn->out, buffer); - http_output_stream_write_string(conn->out, ""); - return; - - herror_release(err); + "cSOAP_Server", NULL, &envres); + if (err != H_OK) { + log_error1(herror_message(err)); + http_output_stream_write_string(conn->out, ""); + http_output_stream_write_string(conn->out, "

Error


"); + http_output_stream_write_string(conn->out, "Error while sending fault object:
Message: "); + http_output_stream_write_string(conn->out, herror_message(err)); + http_output_stream_write_string(conn->out, "
Function: "); + http_output_stream_write_string(conn->out, herror_func(err)); + http_output_stream_write_string(conn->out, "
Error code: "); + sprintf(buffer, "%d", herror_code(err)); + http_output_stream_write_string(conn->out, buffer); + http_output_stream_write_string(conn->out, ""); + return; + + herror_release(err); } else { - _soap_server_send_env(conn->out, envres); + _soap_server_send_env(conn->out, envres); } } diff --git a/libcsoap/soap-server.h b/libcsoap/soap-server.h index 62d136c..5290642 100644 --- a/libcsoap/soap-server.h +++ b/libcsoap/soap-server.h @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: soap-server.h,v 1.4 2004/10/28 10:30:46 snowdrop Exp $ + * $Id: soap-server.h,v 1.5 2004/11/02 23:09:26 snowdrop Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -34,9 +34,9 @@ - - - + + +
ArgumentDescription
-NHTTPport [port]Port to listen (default: 10000)
-NHTTPmaxconn [num]Maximum thread connections
-NHTTPlog [logfilename]logfile
-NHTTPport [port]Port to listen (default: 10000)
-NHTTPmaxconn [num]Maximum thread connections
-NHTTPlog [logfilename]logfile
@param argc commandline arg count -- cgit v1.1-32-gdbae