From 04a5ded5af30359ac7fc764d3cc9f9d0176ad81b Mon Sep 17 00:00:00 2001 From: snowdrop Date: Wed, 12 Nov 2003 13:19:56 +0000 Subject: moved to libcsource/ --- src/csoap.c | 37 ------ src/csoap.h | 55 -------- src/csoapbody.c | 96 -------------- src/csoapbody.h | 58 --------- src/csoapcall.c | 225 -------------------------------- src/csoapcall.h | 90 ------------- src/csoapenv.c | 168 ------------------------ src/csoapenv.h | 86 ------------ src/csoaperror.h | 47 ------- src/csoapfault.c | 140 -------------------- src/csoapfault.h | 124 ------------------ src/csoaphttp.c | 153 ---------------------- src/csoaphttp.h | 45 ------- src/csoaplog.c | 65 --------- src/csoaplog.h | 26 ---- src/csoapmethod.c | 70 ---------- src/csoapmethod.h | 56 -------- src/csoapparam.c | 384 ------------------------------------------------------ src/csoapparam.h | 187 -------------------------- src/csoapres.c | 154 ---------------------- src/csoapres.h | 90 ------------- src/csoapsocket.c | 154 ---------------------- src/csoapsocket.h | 81 ------------ src/csoaptypes.h | 33 ----- src/csoapurl.c | 185 -------------------------- src/csoapurl.h | 70 ---------- src/csoapxml.c | 151 --------------------- src/csoapxml.h | 90 ------------- 28 files changed, 3120 deletions(-) delete mode 100644 src/csoap.c delete mode 100644 src/csoap.h delete mode 100644 src/csoapbody.c delete mode 100644 src/csoapbody.h delete mode 100644 src/csoapcall.c delete mode 100644 src/csoapcall.h delete mode 100644 src/csoapenv.c delete mode 100644 src/csoapenv.h delete mode 100644 src/csoaperror.h delete mode 100644 src/csoapfault.c delete mode 100644 src/csoapfault.h delete mode 100644 src/csoaphttp.c delete mode 100644 src/csoaphttp.h delete mode 100644 src/csoaplog.c delete mode 100644 src/csoaplog.h delete mode 100644 src/csoapmethod.c delete mode 100644 src/csoapmethod.h delete mode 100644 src/csoapparam.c delete mode 100644 src/csoapparam.h delete mode 100644 src/csoapres.c delete mode 100644 src/csoapres.h delete mode 100644 src/csoapsocket.c delete mode 100644 src/csoapsocket.h delete mode 100644 src/csoaptypes.h delete mode 100644 src/csoapurl.c delete mode 100644 src/csoapurl.h delete mode 100644 src/csoapxml.c delete mode 100644 src/csoapxml.h diff --git a/src/csoap.c b/src/csoap.c deleted file mode 100644 index 1203ba4..0000000 --- a/src/csoap.c +++ /dev/null @@ -1,37 +0,0 @@ -/****************************************************************** - * $Id: csoap.c,v 1.2 2003/05/01 09:11:16 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 - ******************************************************************/ -#include "csoap.h" - -#include "csoapxml.h" - - -/*----------------------------------------------------------------- - FUNCTION: SoapFreeStr -/-----------------------------------------------------------------*/ - -void SoapFreeStr(char* str) -{ - if (str) xmlFree(str); -} - diff --git a/src/csoap.h b/src/csoap.h deleted file mode 100644 index 91f4c8d..0000000 --- a/src/csoap.h +++ /dev/null @@ -1,55 +0,0 @@ -/****************************************************************** - * $Id: csoap.h,v 1.2 2003/05/20 21:00:18 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_H -#define CSOAP_H - - -/* Include csoap headers */ -#include "csoapcall.h" -#include "csoapfault.h" -#include "csoapurl.h" -#include "csoaptypes.h" - -/** - * Initialize routine. Must be called before any - * other csoap API function. - * - * @param argc command line parameter - * @param argv command line parameter - * - * @return CSOAP_OK if successfull. - */ -int SoapInit(int argc, char *argv[]); - - -/** - * Free a string allocated by a csoap - * function. - * - * @param str the string to free - */ -void SoapFreeStr(char* str); - - -#endif diff --git a/src/csoapbody.c b/src/csoapbody.c deleted file mode 100644 index ec4a3fd..0000000 --- a/src/csoapbody.c +++ /dev/null @@ -1,96 +0,0 @@ -/****************************************************************** - * $Id: csoapbody.c,v 1.2 2003/05/20 21:00:19 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 - ******************************************************************/ -#include "csoapbody.h" -#include "csoaplog.h" - - -/*----------------------------------------------------------------- - FUNCTION: SoapBodyGetMethod -/-----------------------------------------------------------------*/ - -HSOAPMETHOD SoapBodyGetMethod(HSOAPBODY body, const char* method) -{ - HSOAPXML node; - const char* FUNC = "SoapBodyGetMethod"; - SoapTraceEnter(FUNC,"Method = %s", method); - - if (body == NULL) { - SoapLog(LOG_ERROR, FUNC, - "Invalid body (null)"); - return NULL; - } - - SoapLog(LOG_DEBUG, FUNC, "Searching method '%s'", method); - - node = SoapXmlFindNode((HSOAPXML)body, method); - if (node == NULL) { - SoapTraceLeaveWithError(FUNC, "Can not find method"); - return NULL; - } -/* - cur = ((xmlNodePtr)body)->xmlChildrenNode; - while (cur != NULL) { - if (!xmlStrcmp(cur->name, (const xmlChar*)method)) { - SoapTraceLeave(FUNC, "Found method (%p)", cur); - return (HSOAPMETHOD)cur; - } - cur = cur->next; - } -*/ - SoapTraceLeave(FUNC, "Method (%p)", node); - return node; -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapBodyGetFault -/-----------------------------------------------------------------*/ - -HSOAPFAULT SoapBodyGetFault(HSOAPBODY body) -{ - HSOAPXML node; - const char* FUNC = "SoapBodyGetFault"; - SoapTraceEnter(FUNC,"Body (%p)", body); - - if (body == NULL) { - SoapLog(LOG_ERROR, FUNC, - "Invalid body (null)"); - return NULL; - } - -/* - cur = ((xmlNodePtr)body)->xmlChildrenNode; - while (cur != NULL) { - if (!xmlStrcmp(cur->name, (const xmlChar*)"Fault")) { - SoapTraceLeave(FUNC, "Found fault (%p)", cur); - return (HSOAPFAULT)cur; - } - cur = cur->next; - } -*/ - - node = SoapXmlFindNode((HSOAPXML)body, "Fault"); - SoapTraceLeave(FUNC, "Fault (%p)", node); - return node; -} diff --git a/src/csoapbody.h b/src/csoapbody.h deleted file mode 100644 index 153c18d..0000000 --- a/src/csoapbody.h +++ /dev/null @@ -1,58 +0,0 @@ -/****************************************************************** - * $Id: csoapbody.h,v 1.2 2003/05/20 21:00:19 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_BODY_H -#define CSOAP_BODY_H - -#include "csoapmethod.h" -#include "csoapfault.h" - -typedef HSOAPXML HSOAPBODY; - - - -/** - * Returns the method object assigned to - * the given body. - * - * @param body handle to the body object - * @param method the method(operation) name - * to call. - * - * @return a handle to the method object or - * NULL if the the method was not found. - */ -HSOAPMETHOD SoapBodyGetMethod(HSOAPBODY body, const char *method); - - -/** - * Returns the fault object if any exist. - * - * @param body handle to the body object - * @return a handle to a fault object or - * NULL if no fault was generated. - */ -HSOAPFAULT SoapBodyGetFault(HSOAPBODY body); - - -#endif diff --git a/src/csoapcall.c b/src/csoapcall.c deleted file mode 100644 index c4b6998..0000000 --- a/src/csoapcall.c +++ /dev/null @@ -1,225 +0,0 @@ -/****************************************************************** - * $Id: csoapcall.c,v 1.2 2003/05/20 21:00:19 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 - ******************************************************************/ -#include "csoapcall.h" -#include "csoaplog.h" -#include "csoaphttp.h" - -#include - - -HSOAPCALL SoapCallCreate( - const char* url, - const char* uri, - const char* method) -{ - const char *FUNC = "SoapCallCreate"; - HSOAPCALL call; - - SoapTraceEnter(FUNC, "url=%s;uri=%s;method=%s", - url, uri, method); - call = (HSOAPCALL)malloc(sizeof(struct SOAPCALL)); - call->m_method = (char*)malloc(strlen(method)+1); - - call->m_env = SoapEnvCreate(uri, method); - call->m_url = SoapUrlCreate(url); - strcpy(call->m_method, method); - - SoapTraceLeave(FUNC, "call (%p)", call); - return call; -} - - -HSOAPPARAM SoapCallAddParam( - HSOAPCALL call, - const char* name, - const char* type, - const char* format, - ...) -{ - const char *FUNC = "SoapCallAddParam"; - HSOAPBODY body; - HSOAPMETHOD method; - HSOAPPARAM param, result; - va_list ap; - char buffer[SOAP_MAX_STRING_BUFFER]; - - SoapTraceEnter(FUNC, "name=%s;type=%s;format=%s", - name, type, format); - - va_start(ap, format); - vsprintf(buffer, format, ap); - va_end(ap); - - body = SoapEnvGetBody(call->m_env); - method = SoapBodyGetMethod(body, call->m_method); - param = SoapMethodParamContext(method); - result = SoapParamCreate(param, type, NULL, name, "%s", buffer); - - SoapTraceLeave(FUNC, "created param (%p)", result); - return result; -} - - -HSOAPPARAM SoapCallAddStringParam( - HSOAPCALL call, - const char* name, - const char* format, - ...) -{ - const char *FUNC = "SoapCallAddStringParam"; - HSOAPBODY body; - HSOAPMETHOD method; - HSOAPPARAM param, result; - va_list ap; - char buffer[SOAP_MAX_STRING_BUFFER]; - - SoapTraceEnter(FUNC, "name=%s;format=%s", - name, format); - - va_start(ap, format); - vsprintf(buffer, format, ap); - va_end(ap); - - body = SoapEnvGetBody(call->m_env); - method = SoapBodyGetMethod(body, call->m_method); - param = SoapMethodParamContext(method); - result = SoapParamCreateString(param, name, buffer); - SoapTraceLeave(FUNC, "created param (%p)", result); - return result; -} - - -HSOAPPARAM SoapCallAddIntParam( - HSOAPCALL call, - const char* name, - int value) -{ - const char *FUNC = "SoapCallAddIntParam"; - HSOAPBODY body; - HSOAPMETHOD method; - HSOAPPARAM param, result; - - SoapTraceEnter(FUNC, "name=%s;value=%d", - name, value); - - body = SoapEnvGetBody(call->m_env); - method = SoapBodyGetMethod(body, call->m_method); - param = SoapMethodParamContext(method); - result = SoapParamCreateInt(param, name, value); - SoapTraceLeave(FUNC, "created param (%p)", result); - return result; -} - -HSOAPPARAM SoapCallAddDoubleParam( - HSOAPCALL call, - const char* name, - double value) -{ - const char *FUNC = "SoapCallAddDoubleParam"; - HSOAPBODY body; - HSOAPMETHOD method; - HSOAPPARAM param, result; - - SoapTraceEnter(FUNC, "name=%s;value=%f", - name, value); - - body = SoapEnvGetBody(call->m_env); - method = SoapBodyGetMethod(body, call->m_method); - param = SoapMethodParamContext(method); - result = SoapParamCreateDouble(param, name, value); - SoapTraceLeave(FUNC, "created param (%p)", result); - return result; -} - - -HSOAPRES SoapCallInvoke(HSOAPCALL call) -{ - const char* FUNC = "SoapCallInvoke"; - SoapTraceEnter(FUNC,"%p", call); - const char* filename = "csoap-client.xml"; - char *buf; - CSOAP_STATUS status; - HSOAPENV env; - HSOAPRES res; - - if (!call) { - SoapTraceLeaveWithError(FUNC, "Call is null!"); - return NULL; - } - - if (!call->m_env) { - SoapTraceLeaveWithError(FUNC, "Invalid envelope!"); - return NULL; - } - - if (!call->m_url) { - SoapTraceLeaveWithError(FUNC, "Invalid URL"); - return NULL; - } - -/* xmlSaveFormatFile(filename, ((xmlNodePtr)call->m_env)->doc, 1); - buffer = xmlBufferCreate(); - xmlNodeDump(buffer, ((xmlNodePtr)call->m_env)->doc, - (xmlNodePtr)call->m_env, 1 ,2); - printf("\n%s\n", (const char*)xmlBufferContent(buffer)); - xmlBufferFree(buffer); -*/ - - printf("Sending ...\n"); - status = SoapHttpSend(call->m_url, call->m_env, &env); - if (status != CSOAP_OK) { - printf("can not send. code = %d\n", status); - } - printf("Sending finished\n"); - /* - printf("Length: %d\nResponse: \n%s\n\n\r", strlen(buf), buf?buf:"null"); - */ - SoapEnvDump(env); - /* free(buf);*/ - /* SoapEnvFree(env);*/ - res = SoapResCreate(env, call->m_method); - SoapTraceLeave(FUNC, "res (%p)", res); - return res; -} - - -void SoapCallFree(HSOAPCALL call) -{ - const char* FUNC = "SoapCallFree"; - SoapTraceEnter(FUNC,"%p", call); - - if (!call) { - SoapTraceLeave(FUNC, "Call is null!"); - return; - } - - SoapEnvFree(call->m_env); - - if (call->m_url) SoapUrlFree(call->m_url); - if (call->m_method) free(call->m_method); - - free(call); - SoapTraceLeave(FUNC, "Call destroyed"); -} - diff --git a/src/csoapcall.h b/src/csoapcall.h deleted file mode 100644 index 2e499d8..0000000 --- a/src/csoapcall.h +++ /dev/null @@ -1,90 +0,0 @@ -/****************************************************************** - * $Id: csoapcall.h,v 1.2 2003/05/20 21:00:18 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_CALL_H -#define CSOAP_CALL_H - -#include "csoapparam.h" -#include "csoapres.h" -#include "csoapenv.h" -#include "csoapurl.h" - -typedef struct SOAPCALL* HSOAPCALL; - - -/** - * Stores information to - * send a soap call - */ -struct SOAPCALL -{ - HSOAPENV m_env; /* The soap envelope */ - HSOAPURL m_url; /* The target URL */ - char* m_method; /* The method to to call */ -}; - - -HSOAPCALL SoapCallCreate( - const char* url, - const char* uri, - const char* method -); - - -HSOAPPARAM SoapCallAddParam( - HSOAPCALL call, - const char* name, - const char* type, - const char* format, - ... -); - - -HSOAPPARAM SoapCallAddStringParam( - HSOAPCALL call, - const char* name, - const char* format, - ... -); - - -HSOAPPARAM SoapCallAddIntParam( - HSOAPCALL call, - const char* name, - int value -); - - -HSOAPPARAM SoapCallAddDoubleParam( - HSOAPCALL call, - const char* name, - double value -); - - -HSOAPRES SoapCallInvoke(HSOAPCALL call); - -void SoapCallFree(HSOAPCALL call); - - -#endif diff --git a/src/csoapenv.c b/src/csoapenv.c deleted file mode 100644 index 08585ca..0000000 --- a/src/csoapenv.c +++ /dev/null @@ -1,168 +0,0 @@ -/****************************************************************** - * $Id: csoapenv.c,v 1.2 2003/05/20 21:00:18 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 - ******************************************************************/ -#include "csoapenv.h" -#include "csoaplog.h" - -static char *soap_env_ns = "http://schemas.xmlsoap.org/soap/envelope/"; -static char *soap_env_enc = "http://schemas.xmlsoap.org/soap/encoding/"; -static char *soap_xsi_ns = "http://www.w3.org/1999/XMLSchema-instance"; -static char *soap_xsd_ns = "http://www.w3.org/1999/XMLSchema"; - -/* - Parameters: - 1- soap_env_ns - 2- soap_env_enc - 3- xsi_ns - 4- xsd_ns - 3- method name - 4- uri - 5- method name(again) - */ -#define SOAP_MSG_TEMPLATE \ - "" \ - " "\ - " "\ - " " \ - " "\ - "" - - - -/*----------------------------------------------------------------- - FUNCTION: SoapEnvCreate -/-----------------------------------------------------------------*/ - -HSOAPENV SoapEnvCreate(const char *uri, const char *method) -{ - xmlDocPtr env; - xmlNodePtr node; - char buffer[1054]; - - const char* FUNC = "SoapEnvCreate"; - - SoapTraceEnter( FUNC, - "URI = '%s'\nMethod = '%s'", - uri, method); - - sprintf(buffer, SOAP_MSG_TEMPLATE, - soap_env_ns, soap_env_enc, soap_xsi_ns, - soap_xsd_ns, method, uri, method); - - env = xmlParseDoc(buffer); - if (env == NULL) { - SoapLog(LOG_ERROR, FUNC, - "Can not create xml document!"); - return NULL; - } - - node = xmlDocGetRootElement(env); - if (node == NULL) { - SoapLog(LOG_ERROR, FUNC, - "xml document is empty!"); - return NULL; - } - - SoapLog(LOG_DEBUG, FUNC, - "Envelope created successfully"); - - SoapTraceLeave(FUNC, "Envelope: %p", node); - - return (HSOAPENV)node; -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapEnvGetBody -/-----------------------------------------------------------------*/ - -HSOAPBODY SoapEnvGetBody(HSOAPENV envelope) -{ - xmlNodePtr cur; - const char* FUNC = "SoapEnvGetBody"; - SoapTraceEnter(FUNC,""); - - if (envelope == NULL) { - SoapLog(LOG_ERROR, FUNC, - "Invalid envelope (null)"); - return NULL; - } - - cur = ((xmlNodePtr)envelope)->xmlChildrenNode; - while (cur != NULL) { - if (!xmlStrcmp(cur->name, (const xmlChar*)"Body")) { - SoapTraceLeave(FUNC, "Found Body (%p)", cur); - return (HSOAPBODY)cur; - } - cur = cur->next; - } - - SoapTraceLeave(FUNC, "No body found!"); - return NULL; -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapEnvFree -/-----------------------------------------------------------------*/ - -void SoapEnvFree(HSOAPENV envelope) -{ - const char* FUNC = "SoapEnvFree"; - SoapTraceEnter(FUNC,"%p", envelope); - - if (!envelope) { - SoapTraceLeave(FUNC, "Envelope is null!"); - return; - } - - xmlFreeDoc(((xmlNodePtr)envelope)->doc); - SoapTraceLeave(FUNC, "Envelope destroyed"); -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapEnvDump -/-----------------------------------------------------------------*/ - -void SoapEnvDump(HSOAPENV env) -{ - const char *FUNC = "SoapEnvDump"; - - xmlBufferPtr buffer; - xmlDocPtr doc; - char *str; - - SoapTraceEnter(FUNC, "env (%p)", env); - - buffer = xmlBufferCreate(); - xmlNodeDump(buffer, ((xmlNodePtr)env)->doc, (xmlNodePtr)env, 1 ,1); - str = (char*)xmlBufferContent(buffer); - - printf("%s\n", str?str:"null"); - - xmlBufferFree(buffer); - SoapTraceLeave(FUNC, "Leaving"); -} diff --git a/src/csoapenv.h b/src/csoapenv.h deleted file mode 100644 index 5455e69..0000000 --- a/src/csoapenv.h +++ /dev/null @@ -1,86 +0,0 @@ -/****************************************************************** - * $Id: csoapenv.h,v 1.1 2003/03/25 22:17:19 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@jprogrammet.net - ******************************************************************/ -#ifndef CSOAP_ENV_H -#define CSOAP_ENV_H - -#include "csoapxml.h" -#include "csoapbody.h" - -typedef HSOAPXML HSOAPENV; - - -/** - * Creates a new soap envelope object - * - * @param uri the URI - * @param method the method name to call - * - * @return handle to an envelope object if - * creation was successfull or NULL otherwise. - */ -HSOAPENV SoapEnvCreate(const char *uri, const char *method); - - -/** - * Creates a new soap envelope object - * - * @param uri the URI - * @param method the method name to call - * - * @return handle to an envelope object if - * creation was successfull or NULL otherwise. - */ -HSOAPENV SoapEnvCreateWithFault(const char *uri, const char *method); - - -/** - * Returns the soap body object to - * a given envelope object. - * - * @param envelope the envelope - * @return handle to a body object if - * any exist or NULL otherwise - */ -HSOAPBODY SoapEnvGetBody(HSOAPENV envelope); - - -/** - * Free a given envelope object - * - * @param envelope the envelope object - * to free - */ -void SoapEnvFree(HSOAPENV envelope); - - -/** - * Dumps an envelope object to the stdout. - * For debug puposes only. - * - * @param env the envelope object to dump - */ -void SoapEnvDump(HSOAPENV env); - - -#endif diff --git a/src/csoaperror.h b/src/csoaperror.h deleted file mode 100644 index f577600..0000000 --- a/src/csoaperror.h +++ /dev/null @@ -1,47 +0,0 @@ -/****************************************************************** - * $Id: csoaperror.h,v 1.2 2003/05/20 21:00:18 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_ERROR_H -#define CSOAP_ERROR_H - -typedef int CSOAP_STATUS; - -/* Ok status */ -#define CSOAP_OK 0 - -/* Socket related errors */ -#define ERROR_SOCKET_CAN_NOT_GET_HOSTNAME 100001 -#define ERROR_SOCKET_CAN_NOT_CONNECT 100002 -#define ERROR_SOCKET_CAN_NOT_CREATE_SOCKET 100003 -#define ERROR_SOCKET_CAN_NOT_RECEIVE 100004 -#define ERROR_SOCKET_CAN_NOT_SEND 100005 - - -/* Generic errors */ -#define ERROR_NO_MEM 110001 - - -/* xml related error */ -#define ERROR_XML_CAN_NOT_PARSE 12001 - -#endif diff --git a/src/csoapfault.c b/src/csoapfault.c deleted file mode 100644 index aae1143..0000000 --- a/src/csoapfault.c +++ /dev/null @@ -1,140 +0,0 @@ -/****************************************************************** - * $Id: csoapfault.c,v 1.2 2003/05/20 21:00:19 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 - ******************************************************************/ -#include "csoapfault.h" - - - -/*----------------------------------------------------------------- - FUNCTION: SoapFaultGetFaultCode -/-----------------------------------------------------------------*/ - -char* SoapFaultGetFaultCode(HSOAPFAULT fault) -{ - xmlNodePtr node; - const char *FUNC = "SoapFaultGetFaultCode"; - - SoapTraceEnter(FUNC, "Entering"); - - node = SoapXmlFindNode((HSOAPXML)fault, "faultcode"); - if (node == NULL) { - SoapTraceLeaveWithError(FUNC, "Can not find faultcode"); - return NULL; - } - - SoapTraceLeave(FUNC, "Leaving"); - return SoapXmlGetNodeValueAlloc(node); -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapFaultGetFaultString -/-----------------------------------------------------------------*/ - -char* SoapFaultGetFaultString(HSOAPFAULT fault) -{ - xmlNodePtr node; - const char *FUNC = "SoapFaultGetFaultString"; - - SoapTraceEnter(FUNC, "Entering"); - - node = SoapXmlFindNode((HSOAPXML)fault, "faultstring"); - if (node == NULL) { - SoapTraceLeaveWithError(FUNC, "Can not find faultstring"); - return NULL; - } - - SoapTraceLeave(FUNC, "Leaving"); - return SoapXmlGetNodeValueAlloc(node); -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapFaultGetFaultActor -/-----------------------------------------------------------------*/ - -char* SoapFaultGetFaultActor(HSOAPFAULT fault) -{ - xmlNodePtr node; - const char *FUNC = "SoapFaultGetFaultActor"; - - SoapTraceEnter(FUNC, "Entering"); - - node = SoapXmlFindNode((HSOAPXML)fault, "faultactor"); - if (node == NULL) { - SoapTraceLeaveWithError(FUNC, "Can not find faultactor"); - return NULL; - } - - SoapTraceLeave(FUNC, "Leaving"); - return SoapXmlGetNodeValueAlloc(node); -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapFaultGetFaultDetail -/-----------------------------------------------------------------*/ - -HSOAPPARAM SoapFaultGetDetail(HSOAPFAULT fault) -{ - xmlNodePtr node; - const char *FUNC = "SoapFaultGetFaultCode"; - - SoapTraceEnter(FUNC, "Entering"); - - node = SoapXmlFindNode((HSOAPXML)fault, "detail"); - if (node == NULL) { - SoapTraceLeaveWithError(FUNC, "Can not find detail"); - return NULL; - } - - SoapTraceLeave(FUNC, "Leaving"); - return (HSOAPPARAM)node; -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapFaultPrint -/-----------------------------------------------------------------*/ - -void SoapFaultPrint(FILE* f, HSOAPFAULT fault) -{ - char *str; - - if (fault == NULL) { - fprintf(f, "Fault object is null!.\n"); - return; - } - - str = SoapFaultGetFaultCode(fault); - fprintf(f, "FaultCode: %s\n", str?str:"null"); - SoapFreeStr(str); - - str = SoapFaultGetFaultString(fault); - fprintf(f, "FaultString: %s\n", str?str:"null"); - SoapFreeStr(str); - - str = SoapFaultGetFaultActor(fault); - fprintf(f, "FaultActor: %s\n", str?str:"null"); - SoapFreeStr(str); -} diff --git a/src/csoapfault.h b/src/csoapfault.h deleted file mode 100644 index fa06b1c..0000000 --- a/src/csoapfault.h +++ /dev/null @@ -1,124 +0,0 @@ -/****************************************************************** - * $Id: csoapfault.h,v 1.2 2003/05/20 21:00:19 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_FAULT_H -#define CSOAP_FAULT_H - - -#include "csoapxml.h" -#include "csoapparam.h" - -typedef HSOAPXML HSOAPFAULT; - - -/** - * Returns the [faultcode] - * - * @param fault handle to a soap fault object - * @return an allocated string or NULL - * if no [faultcode] was set. - */ -char* SoapFaultGetFaultCode(HSOAPFAULT fault); - - -/** - * Returns the [faultstring] - * - * @param fault handle to a soap fault object - * @return an allocated string or NULL - * if no [faultstring] was set. - */ -char* SoapFaultGetFaultString(HSOAPFAULT fault); - - -/** - * Returns the [faultactor] - * - * @param fault handle to a soap fault object - * @return an allocated string or NULL - * if no [faultactor] was set. - */ -char* SoapFaultGetFaultActor(HSOAPFAULT fault); - - -/** - * Returns the [detail] - * - * @param fault handle to a soap fault object - * @return handle to a soap param object - */ -HSOAPPARAM SoapFaultGetDetail(HSOAPFAULT fault); - - -/** - * Sets the a [faultcode] field. - * This will be called internally. - * - * @param fault handle to a soap fault object - * @param faultcode the faultcode to set - */ -void SoapFaultSetFaultCode(HSOAPFAULT fault, const char* faultCode); - - -/** - * Sets the a [faultstring] field. - * This will be called internally. - * - * @param fault handle to a soap fault object - * @param faultstring the faultstring to set - */ -void SoapFaultSetFaultString(HSOAPFAULT fault, const char* faultString); - - -/** - * Sets the a [faultactor] field. - * This will be called internally. - * - * @param fault handle to a soap fault object - * @param faultactor the faultactor to set - */ -void SoapFaultSetFaultActor(HSOAPFAULT fault, const char* faultActor); - - -/** - * Sets the a [faultdetail] field. - * This will be called internally. - * - * @param fault handle to a soap fault object - * @param faultcode the detail to set - */ -void SoapFaultSetFaultDetail(HSOAPFAULT fault, HSOAPPARAM param); - - -/** - * Prints a fault object into the - * given file. This is for debug puposes. - * - * @param f the file to print into - * @param fault the fault object to print - */ -void SoapFaultPrint(FILE* f, HSOAPFAULT fault); - - -#endif - diff --git a/src/csoaphttp.c b/src/csoaphttp.c deleted file mode 100644 index 2d578ce..0000000 --- a/src/csoaphttp.c +++ /dev/null @@ -1,153 +0,0 @@ -/****************************************************************** - * $Id: csoaphttp.c,v 1.1 2003/03/25 22:17:20 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@jprogrammet.net - ******************************************************************/ -#include "csoaphttp.h" -#include "csoaplog.h" -#include "csoapxml.h" - -/*----------------------------------------------------------------- - FUNCTION: SoapHttpCreateEnv -/-----------------------------------------------------------------*/ - -static -HSOAPENV SoapHttpCreateEnv(char* httpResponse) -{ - const char *FUNC = "SoapHttpCreateEnv"; - int count = 0; - int newline = 0; - xmlDocPtr env; - xmlNodePtr node; - int len; - char *tmp; - - SoapTraceEnter(FUNC, "Entering response =\n"); - while (*(httpResponse+count) != '\0') { - if (httpResponse[count]=='\r') { - count++; - continue; - } - if (httpResponse[count]=='\n') { - if (newline) break; - else newline = 1; - } else newline = 0; - - count++; - } - - len = strlen(httpResponse); - SoapLog(LOG_DEBUG, FUNC, "count = %d\n", count); - SoapLog(LOG_DEBUG, FUNC, "response length = %d\n", len); - - len = strlen(&httpResponse[count]); - SoapLog(LOG_DEBUG, FUNC, "xml response length = %d\n", len); - - while (httpResponse[count] == '\n' - || httpResponse[count] == '\r') { - count++; - } - - SoapLog(LOG_DEBUG, FUNC, "count = %d\n", count); - - SoapLog(LOG_DEBUG, FUNC, "casting\n"); - tmp = (char*)(&httpResponse[count]); - SoapLog(LOG_DEBUG, FUNC, "casting ok\n"); - - /* SoapLog(LOG_DEBUG, FUNC, "xml = %s\n",tmp?tmp:"null"); - */ - SoapLog(LOG_DEBUG, FUNC, "Starting parsing\n"); - env = xmlParseMemory((const char*)tmp, len); - if (env == NULL) { - SoapLog(LOG_ERROR, FUNC, - "Can not create xml document!"); - return NULL; - } - - node = xmlDocGetRootElement(env); - if (node == NULL) { - SoapLog(LOG_ERROR, FUNC, - "xml document is empty!"); - return NULL; - } - - SoapLog(LOG_DEBUG, FUNC, - "Envelope created successfully"); - - SoapTraceLeave(FUNC, "env (%p)", node); - return (HSOAPENV)node; -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapHttpSend -/-----------------------------------------------------------------*/ - -CSOAP_STATUS SoapHttpSend(HSOAPURL url, HSOAPENV env, HSOAPENV* res) -{ - const char *FUNC = "SoapHttpSend"; - HSOAPSOCKET http; - int len; - ssize_t size; - char *tmp; - char *response; - char tmp2[1054]; - CSOAP_STATUS status; - xmlBufferPtr buffer; - xmlDocPtr doc; - - SoapTraceEnter(FUNC, "env (%p)", env); - - buffer = xmlBufferCreate(); - xmlNodeDump(buffer, ((xmlNodePtr)env)->doc, (xmlNodePtr)env, 1 ,1); - len = strlen((const char*)xmlBufferContent(buffer)); - - tmp = (char*)malloc(1054 + len); - if (tmp == NULL) - return ERROR_NO_MEM; - - status = SoapSocketCreate(url->m_host, url->m_port, &http); - if (status != CSOAP_OK) return status; - - /*SoapSocketGetResponse(http);*/ - sprintf(tmp2, "POST %s HTTP/1.0\n", url->m_context?url->m_context:"/"); - sprintf(tmp2, "%sContent-Type: text/xml\n", tmp2); - sprintf(tmp2, "%sContent-Length: %d\n\n", tmp2, len); - - sprintf(tmp, "%s%s", tmp2, (const char*)xmlBufferContent(buffer)); - - SoapLog(LOG_DEBUG, FUNC, "sending request\n"); - status = SoapSocketSend(http, tmp, &size); - if (status != CSOAP_OK) return status; - - status = SoapSocketRecv(http, &response, &size); - SoapLog(LOG_DEBUG, FUNC, "response returned status = %d\n", status); - if (status != CSOAP_OK) return status; - - *res = SoapHttpCreateEnv(response); - free(tmp); - free(response); - xmlBufferFree(buffer); - - SoapTraceLeave(FUNC, ""); - return CSOAP_OK; -} - diff --git a/src/csoaphttp.h b/src/csoaphttp.h deleted file mode 100644 index 0fe8858..0000000 --- a/src/csoaphttp.h +++ /dev/null @@ -1,45 +0,0 @@ -/****************************************************************** - * $Id: csoaphttp.h,v 1.1 2003/03/25 22:17:20 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@jprogrammet.net - ******************************************************************/ -#ifndef CSOAP_HTTP_H -#define CSOAP_HTTP_H - -#include "csoapenv.h" -#include "csoapsocket.h" -#include "csoapurl.h" - -/** - * Sends a soap envelope to the given - * host and receives a soap envelope. - * - * @param url The target url - * @param env The soap envelope to send - * @param res The destination soap handle to - * receive the the envelope. - * - * @return CSOAP_OK if it was successfull. - */ -CSOAP_STATUS SoapHttpSend(HSOAPURL url, HSOAPENV env, HSOAPENV* res); - - -#endif diff --git a/src/csoaplog.c b/src/csoaplog.c deleted file mode 100644 index 536d1a9..0000000 --- a/src/csoaplog.c +++ /dev/null @@ -1,65 +0,0 @@ -#include "csoaplog.h" - -#include -#include - -static -void _SoapLogWrite(SoapLogLevel level, - const char* function, - const char* format, - va_list ap) -{ - char buffer[1054]; - char buffer2[1054]; - sprintf(buffer, "[%s] [%d] %s\n", function, level, format); - vsprintf(buffer2, buffer, ap); -/* printf(buffer2); - fflush(stdout); -*/ -} - - -void SoapTraceEnter(const char* function, - const char* format, ...) -{ - va_list ap; - - va_start(ap, format); - _SoapLogWrite(LOG_TRACE, function, format, ap); - va_end(ap); -} - - -void SoapTraceLeave(const char* function, - const char* format, ...) -{ - va_list ap; - - va_start(ap, format); - _SoapLogWrite(LOG_TRACE, function, format, ap); - va_end(ap); -} - - -void SoapTraceLeaveWithError(const char* function, - const char* format, ...) -{ - va_list ap; - - va_start(ap, format); - _SoapLogWrite(LOG_ERROR, function, format, ap); - va_end(ap); -} - - -void SoapLog(SoapLogLevel level, const char* function, - const char* format, ...) -{ - va_list ap; - - va_start(ap, format); - _SoapLogWrite(level, function, format, ap); - va_end(ap); -} - - diff --git a/src/csoaplog.h b/src/csoaplog.h deleted file mode 100644 index 6d7edb6..0000000 --- a/src/csoaplog.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef CSOAP_LOG_H -#define CSOAP_LOG_H - - -typedef enum tagSoapLogLevel -{ - LOG_TRACE, - LOG_DEBUG, - LOG_INFO, - LOG_WARN, - LOG_ERROR -}SoapLogLevel; - -void SoapTraceEnter(const char* function, - const char* format, ...); - -void SoapTraceLeave(const char* function, - const char* format, ...); -void SoapTraceLeaveWithError(const char* function, - const char* format, ...); - -void SoapLog(SoapLogLevel level, const char* function, - const char* format, ...); - -#endif - diff --git a/src/csoapmethod.c b/src/csoapmethod.c deleted file mode 100644 index fb85348..0000000 --- a/src/csoapmethod.c +++ /dev/null @@ -1,70 +0,0 @@ -/****************************************************************** - * $Id: csoapmethod.c,v 1.1 2003/03/25 22:17:21 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@jprogrammet.net - ******************************************************************/ -#include "csoapmethod.h" -#include "csoaplog.h" - - -/*----------------------------------------------------------------- - FUNCTION:SoapMethodGetName -/-----------------------------------------------------------------*/ - -char* SoapMethodGetName(HSOAPMETHOD method) -{ - const char* FUNC = "SoapMethodGetName"; - char *name; - xmlNodePtr node; - SoapTraceEnter(FUNC,""); - - if (method == NULL) { - SoapLog(LOG_ERROR, FUNC, - "Invalid method (null)"); - return NULL; - } - node = (xmlNodePtr)method; - name = (char*)node->name; - SoapTraceLeave(FUNC, "Name = '%s'", name); - return name; -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapMethodParamContext -/-----------------------------------------------------------------*/ - -HSOAPPARAM SoapMethodParamContext(HSOAPMETHOD method) -{ - const char* FUNC = "SoapMethodParamContext"; - char *name; - SoapTraceEnter(FUNC,""); - - if (method == NULL) { - SoapLog(LOG_ERROR, FUNC, - "Invalid method (null)"); - return NULL; - } - SoapTraceLeave(FUNC, "param context = '%p'", method); - - return (xmlNodePtr)method; -} - diff --git a/src/csoapmethod.h b/src/csoapmethod.h deleted file mode 100644 index aa8883d..0000000 --- a/src/csoapmethod.h +++ /dev/null @@ -1,56 +0,0 @@ -/****************************************************************** - * $Id: csoapmethod.h,v 1.1 2003/03/25 22:17:21 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@jprogrammet.net - ******************************************************************/ -#ifndef CSOAP_METHOD_H -#define CSOAP_METHOD_H - -#include "csoapparam.h" - - -typedef HSOAPXML HSOAPMETHOD; - - -/** - * Returns the method name - * - * @param method handle to a soap method object - * @return the method name (do not free the string) - */ -char* SoapMethodGetName(HSOAPMETHOD method); - - -/** - * Returns the param context. Param context is - * also a param object. Use the param context - * as the parent of the method parameters. - * - * @param method the method object to get - * its param context - * - * @return The root parameter object if any - * exist , NULL otherwise. - */ -HSOAPPARAM SoapMethodParamContext(HSOAPMETHOD method); - - -#endif diff --git a/src/csoapparam.c b/src/csoapparam.c deleted file mode 100644 index c90bb04..0000000 --- a/src/csoapparam.c +++ /dev/null @@ -1,384 +0,0 @@ -/****************************************************************** - * $Id: csoapparam.c,v 1.2 2003/05/20 21:00:18 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 - ******************************************************************/ -#include "csoapparam.h" -#include "csoaplog.h" -#include "csoaptypes.h" -#include "csoapxml.h" - -#include - - -/*----------------------------------------------------------------- - FUNCTION: SoapParamCreate -/-----------------------------------------------------------------*/ - -HSOAPPARAM SoapParamCreate(HSOAPPARAM parent, const char *type, - const char *ns, const char *name, - const char *format, ...) -{ - va_list ap; - char buffer[SOAP_MAX_STRING_BUFFER]; - xmlNodePtr newnode; - const char *FUNC = "SoapParamCreate"; - - SoapTraceEnter(FUNC,""); - - va_start(ap, format); - vsprintf(buffer, format, ap); - va_end(ap); - - newnode = xmlNewTextChild(parent, NULL, name, buffer); - - if (newnode == NULL) { - SoapTraceLeaveWithError(FUNC, - "Can not create new xml node"); - return NULL; - } - - if ( !xmlNewProp(newnode, "xsi:type", type)) { - SoapTraceLeaveWithError(FUNC, - "Can not create new xml attribute"); - return NULL; - } - - SoapTraceLeave(FUNC, "New xml node (%p)", newnode); - return newnode; -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapParamCreateString -/-----------------------------------------------------------------*/ - -HSOAPPARAM SoapParamCreateString(HSOAPPARAM parent, const char *name, - const char *format, ...) -{ - va_list ap; - HSOAPPARAM node; - char buffer[SOAP_MAX_STRING_BUFFER]; - const char* FUNC = "SoapParamCreateString"; - SoapTraceEnter(FUNC,""); - - if (parent == NULL) { - SoapTraceLeaveWithError(FUNC, - "Invalid parent (null)"); - return NULL; - } - - if (name == NULL) { - SoapTraceLeaveWithError(FUNC, - "Invalid name (null)"); - return NULL; - } - - if (format == NULL) { - SoapTraceLeaveWithError(FUNC, - "Invalid format (null)"); - return NULL; - } - - SoapLog(LOG_DEBUG, FUNC, - "Creating string parameter\n" \ - "Name = '%s'" \ - "Format = %s", name, format); - - va_start(ap, format); - vsprintf(buffer, format, ap); - va_end(ap); - - node = SoapParamCreate(parent , SOAP_TYPE_STRING, - NULL, name, "%s", buffer); - - if (node == NULL) { - SoapTraceLeaveWithError(FUNC, "can not create param"); - return NULL; - } - - SoapTraceLeave(FUNC, "New param (%p)", node); - return (HSOAPPARAM)node; -} - - - -/*----------------------------------------------------------------- - FUNCTION: SoapParamCreateInt -/-----------------------------------------------------------------*/ - -HSOAPPARAM SoapParamCreateInt(HSOAPPARAM parent, const char *name, - int value) -{ - HSOAPPARAM node; - const char* FUNC = "SoapParamCreateInt"; - SoapTraceEnter(FUNC,""); - - if (parent == NULL) { - SoapTraceLeaveWithError(FUNC, - "Invalid parent (null)"); - return NULL; - } - - if (name == NULL) { - SoapTraceLeaveWithError(FUNC, - "Invalid name (null)"); - return NULL; - } - - node = SoapParamCreate(parent , SOAP_TYPE_INT, - NULL, name, "%d", value); - - if (node == NULL) { - SoapTraceLeaveWithError(FUNC, "can not create param"); - return NULL; - } - - SoapTraceLeave(FUNC, "New param (%p)", node); - return node; -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapParamCreateDouble -/-----------------------------------------------------------------*/ - -HSOAPPARAM SoapParamCreateDouble(HSOAPPARAM parent, const char *name, - double value) -{ - HSOAPPARAM node; - const char* FUNC = "SoapParamCreateDouble"; - SoapTraceEnter(FUNC,""); - - if (parent == NULL) { - SoapTraceLeaveWithError(FUNC, - "Invalid parent (null)"); - return NULL; - } - - if (name == NULL) { - SoapTraceLeaveWithError(FUNC, - "Invalid name (null)"); - return NULL; - } - - node = SoapParamCreate(parent, SOAP_TYPE_DOUBLE, - NULL, name, "%f", value); - - if (node == NULL) { - SoapTraceLeaveWithError(FUNC, "can not create param"); - return NULL; - } - - SoapTraceLeave(FUNC, "New param (%p)", node); - return node; -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapParamSetValue -/-----------------------------------------------------------------*/ - -void SoapParamSetValue(HSOAPPARAM param, const char* type, - const char* format, ...) -{ - // Not implemented yet! -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapParamGetString -/-----------------------------------------------------------------*/ - -int SoapParamGetString(HSOAPPARAM param, char *dest) -{ - char *value; - int len; - xmlNodePtr xmlNode; - const char* FUNC = "SoapParamGetString"; - SoapTraceEnter(FUNC,""); - - if (param == NULL) { - SoapTraceLeaveWithError(FUNC, - "Invalid parameter 'param' (null)"); - return 0; - } - - xmlNode = (xmlNodePtr)param; - value = (char*)xmlNodeListGetString(xmlNode->doc, - xmlNode->xmlChildrenNode,1); - - if (dest) - strcpy(dest, value); - - len = strlen(value); - xmlFree(value); - - SoapTraceLeave(FUNC, "Value = '%s'\nLength=%d", dest?dest:"null", len); - return len; -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapParamGetInt -/-----------------------------------------------------------------*/ - -int SoapParamGetInt(HSOAPPARAM param) -{ - int value; - char buffer[15]; - const char* FUNC = "SoapParamGetInt"; - SoapTraceEnter(FUNC,""); - - if (param == NULL) { - SoapTraceLeaveWithError(FUNC, - "Invalid parameter 'param' (null)"); - return 0; - } - - SoapParamGetString(param, buffer); - value = atoi(buffer); - SoapTraceLeave(FUNC, "Value = %d", value); - return value; -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapParamGetDouble -/-----------------------------------------------------------------*/ - -double SoapParamGetDouble(HSOAPPARAM param) -{ - double value; - char buffer[15]; - const char* FUNC = "SoapParamGetDouble"; - SoapTraceEnter(FUNC,""); - - if (param == NULL) { - SoapTraceLeaveWithError(FUNC, - "Invalid parameter 'param' (null)"); - return 0.0; - } - - SoapParamGetString(param, buffer); - value = atof(buffer); - SoapTraceLeave(FUNC, "Value = %f", value); - return value; -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapParamGetChildren -/-----------------------------------------------------------------*/ - -HSOAPPARAM SoapParamGetChildren(HSOAPPARAM param) -{ - xmlNodePtr children; - const char* FUNC = "SoapParamGetChildren"; - SoapTraceEnter(FUNC,""); - - if (param == NULL) { - SoapTraceLeaveWithError(FUNC, - "Invalid parameter 'param' (null)"); - return NULL; - } - - children = ((xmlNodePtr)param)->xmlChildrenNode; - while (children != NULL) { - if (children->type != XML_ELEMENT_NODE) - children = children->next; - else break; - } - SoapTraceLeave(FUNC, "Children node (%p)", children); - return (HSOAPPARAM)children; -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapParamGetNext -/-----------------------------------------------------------------*/ - -HSOAPPARAM SoapParamGetNext(HSOAPPARAM param) -{ - xmlNodePtr children; - const char* FUNC = "SoapParamGetNext"; - xmlNodePtr node = (xmlNodePtr)param; - SoapTraceEnter(FUNC,"Enter. node = %s", node?(char*)node->name:"null"); - - if (param == NULL) { - SoapTraceLeaveWithError(FUNC, - "Invalid parameter 'param' (null)"); - return NULL; - } - - children = node->next; - - while (children != NULL) { - if (children->type != XML_ELEMENT_NODE) - children = children->next; - else break; - } - - SoapTraceLeave(FUNC, "Children node (%p)", children); - return (HSOAPPARAM)children; -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapParamGetType -/-----------------------------------------------------------------*/ - -char* SoapParamGetType(HSOAPPARAM param) -{ - const char* FUNC = "SoapParamGetType"; - char *value; - xmlNodePtr node = (xmlNodePtr)param; - SoapTraceEnter(FUNC,"Enter. node = %s", node?(char*)node->name:"null"); - - value = SoapXmlGetAttr(node, NULL, "type"); - - SoapTraceLeave(FUNC, "Type = %s", value?value:"(null}"); - return value; -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapParamTypeIs -/-----------------------------------------------------------------*/ - -int SoapParamTypeIs(HSOAPPARAM param, const char* type) -{ - const char* FUNC = "SoapParamTypeIs"; - char *value; - SoapTraceEnter(FUNC,"Enter. Type = %s", type?type:"(null)"); - - if (type == NULL) { - SoapTraceLeaveWithError(FUNC, "type is null"); - return 0; - } - - value = SoapParamGetType(param); - - SoapTraceLeave(FUNC, "Leave"); - return (!strcmp(value, type)); -} - - diff --git a/src/csoapparam.h b/src/csoapparam.h deleted file mode 100644 index 23a27f9..0000000 --- a/src/csoapparam.h +++ /dev/null @@ -1,187 +0,0 @@ -/****************************************************************** - * $Id: csoapparam.h,v 1.1 2003/03/25 22:17:25 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@jprogrammet.net - ******************************************************************/ -#ifndef CSOAP_PARAM_H -#define CSOAP_PARAM_H - -#include "csoapxml.h" - - -typedef HSOAPXML HSOAPPARAM; - - -#define SOAP_MAX_STRING_BUFFER 1054 - - -/** - * Creates a string soap parameter - * - *
  • Default type: "xsd:string" - * - * @param parent the parent param object - * @param name the parameter name - * @param format the parameter value - * - * @return handle to a parameter object if - * the creation was successfull, NULL otherwise - */ -HSOAPPARAM SoapParamCreateString( HSOAPPARAM parent, const char *name, - const char *format, ...); - - -/** - * Creates an integer soap parameter - * - *
  • Default type: "xsd:integer" - * - * @param parent the parent param object - * @param name the parameter name - * @param value the parameter value - * - * @return handle to a parameter object if - * the creation was successfull, NULL otherwise - */ -HSOAPPARAM SoapParamCreateInt( HSOAPPARAM parent, const char *name, - int value); - - -/** - * Creates a double soap parameter - * - *
  • Default type: "xsd:double" - * - * @param parent the parent param object - * @param name the parameter name - * @param value the parameter value - * - * @return handle to a parameter object if - * the creation was successfull, NULL otherwise - */ -HSOAPPARAM SoapParamCreateDouble( HSOAPPARAM parent, const char *name, - double value); - - -/** - * Sets the parameter value. - * - * @param param the parameter object - * @param type a custom type name - * @param format value of the parameter - */ -void SoapParamSetValue(HSOAPPARAM param,const char* type, - const char* format, ...); - - -/** - * Get the value of a soap parameter - * in string format - * - * @param param the soap parameter object - * @param buffer an allocated character buffer - * to receive the content. If this is NULL, - * this function will return the size only. - * - * @return size of the content. - */ -int SoapParamGetString(HSOAPPARAM param, char *buffer); - - -/** - * Get the value of a soap parameter - * in integer format - * - * @param param the soap parameter object - * @return the param content as integer - */ -int SoapParamGetInt(HSOAPPARAM param); - - -/** - * Get the value of a soap parameter - * in double format - * - * @param param the soap parameter object - * @return the param content as double - */ -double SoapParamGetDouble(HSOAPPARAM param); - - -/** - * Get the children parameter nodes. - * This acts actually like an xml node. - * - * @param param the soap parameter object - * @return handle to the first child node - */ -HSOAPPARAM SoapParamGetChildren(HSOAPPARAM param); - - -/** - * Get the next parameter. - * This acts actually like an xml node. - * - * @param param the soap parameter object - * @return handle to the next node - */ -HSOAPPARAM SoapParamGetNext(HSOAPPARAM param); - - -/** - * Checks if the type is equals with - * the given one. - * - * @param param the param to check - * @param type the type to check - * - * @return 0 if the parameter type not equals to 'type' - */ -int SoapParamTypeIs(HSOAPPARAM param, const char* type); - - -/** - * Returns parameters type. - * - * @param param the param to return its type - * - * @return returns parameters type - */ -char* SoapParamGetType(HSOAPPARAM param); - - -/** - * Creates a new parameter node. - * This is used internally. - * - * @param parent the parent soap parameter object - * @param type the parameter type - * @param ns the namespace of the parameter - * @param name name of the parameter - * @param format value of the parameter - * - * @return A newly created soap parameter object - */ -HSOAPPARAM SoapParamCreate(HSOAPPARAM parent, const char *type, - const char *ns, const char *name, - const char *format, ...); - -#endif diff --git a/src/csoapres.c b/src/csoapres.c deleted file mode 100644 index b379824..0000000 --- a/src/csoapres.c +++ /dev/null @@ -1,154 +0,0 @@ -/****************************************************************** - * $Id: csoapres.c,v 1.2 2003/05/20 21:00:19 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 - ******************************************************************/ -#include "csoapres.h" -#include "csoaplog.h" - - -/*----------------------------------------------------------------- - FUNCTION: SoapResCreate -/-----------------------------------------------------------------*/ - -HSOAPRES SoapResCreate(HSOAPENV env, const char* methodName) -{ - HSOAPRES res = (HSOAPRES)malloc(sizeof(struct SOAPRES)); - res->m_env = env; - res->m_method = (char*)malloc(sizeof(char)*strlen(methodName)+1); - strcpy(res->m_method, methodName); - return res; -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapResGetFault -/-----------------------------------------------------------------*/ - -HSOAPFAULT SoapResGetFault(HSOAPRES res) -{ - const char *FUNC = "SoapResGetFault"; - HSOAPBODY body; - HSOAPFAULT fault; - - SoapTraceEnter(FUNC, "Entering"); - - if (res == NULL) { - SoapTraceLeaveWithError(FUNC, "res is null"); - return NULL; - } - - if (res->m_env == NULL) { - SoapTraceLeaveWithError(FUNC, "res->m_env is null"); - return NULL; - } - - if (!(body = SoapEnvGetBody(res->m_env))) { - SoapTraceLeaveWithError(FUNC, "can not get body"); - return NULL; - } - - fault = SoapBodyGetFault(body); - SoapTraceLeave(FUNC, "Leaving fault (%p)", fault); - - return fault; -} - -/*----------------------------------------------------------------- - FUNCTION: SoapResFree -/-----------------------------------------------------------------*/ - -void SoapResFree(HSOAPRES res) -{ - const char *FUNC = "SoapResFree"; - - SoapTraceEnter(FUNC, "Entering"); - - if (res == NULL) { - SoapTraceLeaveWithError(FUNC, "res is null"); - return; - } - - if (res->m_env == NULL) { - SoapTraceLeaveWithError(FUNC, "res->m_env is null"); - return; - } - - SoapEnvFree(res->m_env); - free(res); - - SoapTraceLeave(FUNC, "Leaving"); -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapResFree -/-----------------------------------------------------------------*/ - -HSOAPPARAM SoapResGetParamChildren(HSOAPRES res) -{ - const char *FUNC = "SoapResGetParamChildren"; - HSOAPBODY body; - HSOAPMETHOD method; - HSOAPPARAM param; - char tmp[1054]; - - SoapTraceEnter(FUNC, "Entering"); - - if (res == NULL) { - SoapTraceLeaveWithError(FUNC, "res is null"); - return NULL; - } - - if (res->m_env == NULL) { - SoapTraceLeaveWithError(FUNC, "res->m_env is null"); - return NULL; - } - - if (!(body = SoapEnvGetBody(res->m_env))) { - SoapTraceLeaveWithError(FUNC, "can not get body"); - return NULL; - } - - sprintf(tmp, "%sResponse", res->m_method); - method = SoapBodyGetMethod(body, tmp); - - if (method == NULL) { - SoapTraceLeaveWithError(FUNC, "method is null"); - return NULL; - } - - param = SoapMethodParamContext(method); - - if (param == NULL) { - SoapTraceLeaveWithError(FUNC, "param is null"); - return NULL; - } - - param = SoapParamGetChildren(method); - - if (param == NULL) { - SoapTraceLeaveWithError(FUNC, "child is null"); - return NULL; - } - - return param; -} diff --git a/src/csoapres.h b/src/csoapres.h deleted file mode 100644 index 52690bd..0000000 --- a/src/csoapres.h +++ /dev/null @@ -1,90 +0,0 @@ -/****************************************************************** - * $Id: csoapres.h,v 1.2 2003/05/20 21:00:19 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_RES_H -#define CSOAP_RES_H - -#include "csoapxml.h" -#include "csoapenv.h" - -typedef struct SOAPRES* HSOAPRES; - - -/** - * The result object. Stores - * the response of a soap request. - */ -struct SOAPRES -{ - HSOAPENV m_env; /* The soap envelope object */ - char *m_method; /* The called method name */ -}; - - -/** - * Creates a new soap result object. - * This is used actually internally. - * To get a soap result see - * HSOAPCALL - * - * @param env the envelope object to use - * @param methodName the called method name - * @return handle to a soap result object. - */ -HSOAPRES SoapResCreate(HSOAPENV env, const char* methodName); - - -/** - * Returns a soap fault object - * if any exist. This can also be - * called to check if any faults - * was occured for this result. - * - * @param res handle to the soap result object - * @return handle to a fault object or - * NULL if no fault was generated. - */ -HSOAPFAULT SoapResGetFault(HSOAPRES res); - - -/** - * Returns the first parameter - * in the result object if any exist. - * - * @param res handle to the soap result object - * @return handle to a soap param object - * NULL if no parameter was received. - */ -HSOAPPARAM SoapResGetParamChildren(HSOAPRES res); - - -/** - * Free a soap result object. - * This must be called after the result - * object was used. - * - * @param res The soap result object to free - */ -void SoapResFree(HSOAPRES res); - -#endif diff --git a/src/csoapsocket.c b/src/csoapsocket.c deleted file mode 100644 index 87d5515..0000000 --- a/src/csoapsocket.c +++ /dev/null @@ -1,154 +0,0 @@ -/****************************************************************** - * $Id: csoapsocket.c,v 1.1 2003/03/25 22:17: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@jprogrammet.net - ******************************************************************/ -#include "csoapsocket.h" -#include "csoaperror.h" -#include "csoaplog.h" - -#include -#include -#include -#include - -#define SOCKET_MAX_BUFSIZE 1054 - - -/*----------------------------------------------------------------- - FUNCTION: SoapSocketCreate -/-----------------------------------------------------------------*/ - -CSOAP_STATUS SoapSocketCreate(const char* hostname, int port, HSOAPSOCKET* hSock) -{ - - int sock; - struct sockaddr_in address; - struct hostent* host; - int i; - - sock = socket(AF_INET, SOCK_STREAM, 0); - if (sock <= 0) return ERROR_SOCKET_CAN_NOT_CREATE_SOCKET; - - /* Get host data */ - host = gethostbyname(hostname); - if (host == NULL) return ERROR_SOCKET_CAN_NOT_GET_HOSTNAME; - - /* set server addresss */ - address.sin_family = host->h_addrtype;; - address.sin_port = htons(port); - memcpy((char*)&address.sin_addr.s_addr, - host->h_addr_list[0], host->h_length); - - /* connect to the server */ - if (connect(sock, (struct sockaddr*) &address, sizeof(address)) != 0) - return ERROR_SOCKET_CAN_NOT_CONNECT; - - *hSock = sock; - return CSOAP_OK; -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapSocketRecv -/-----------------------------------------------------------------*/ - -CSOAP_STATUS SoapSocketRecv(HSOAPSOCKET sock, char** buffer, ssize_t* totalSize) -{ - const char *FUNC = "SoapSocketRecv"; - ssize_t size; - int chunk=1; - char tmp[SOCKET_MAX_BUFSIZE+1]; - - SoapTraceEnter( FUNC, "Entering"); - *totalSize = 0; - *buffer = 0; - - do { - SoapLog(LOG_DEBUG, FUNC, "Receiving buffer\n"); - size = recv(sock, tmp, SOCKET_MAX_BUFSIZE, 0); - SoapLog(LOG_DEBUG, FUNC, "received = %s\n", tmp); - if (size == -1) { - printf("Error reading from socket\n"); - return ERROR_SOCKET_CAN_NOT_RECEIVE; - } - *totalSize += size; - if (*buffer) { - SoapLog(LOG_DEBUG, FUNC, "realloc\n"); - *buffer = (char*)realloc(*buffer, SOCKET_MAX_BUFSIZE*chunk+1); - strcat(*buffer, tmp); - SoapLog(LOG_DEBUG, FUNC,"realloc ok\n"); - } else { - SoapLog(LOG_DEBUG, FUNC, "alloc\n"); - *buffer = (char*)realloc(NULL, SOCKET_MAX_BUFSIZE+1); - strcpy(*buffer, tmp); - SoapLog(LOG_DEBUG, FUNC,"alloc ok\n"); - } - - SoapLog(LOG_DEBUG, FUNC, "totalSize = %d\n", *totalSize); - (*buffer)[*totalSize] = '\0'; - chunk++; - } while (size > 0); - - SoapTraceLeave(FUNC, "totalsize: %d", *totalSize); - return CSOAP_OK; -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapSocketSend -/-----------------------------------------------------------------*/ - -CSOAP_STATUS SoapSocketSend(HSOAPSOCKET sock, const char* req, ssize_t* sentSize) -{ - const char *FUNC = "SoapSocketSend"; - ssize_t size; - - SoapTraceEnter(FUNC, ""); - - size = send(sock, req, strlen(req), 0); - if (size == -1) - return ERROR_SOCKET_CAN_NOT_SEND; - - *sentSize = size; - SoapTraceLeave(FUNC, ""); - return CSOAP_OK; -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapSocketInitialize -/-----------------------------------------------------------------*/ - -CSOAP_STATUS SoapSocketInitialize() -{ - const char *FUNC = "SoapSocketInitialize"; - SoapTraceEnter(FUNC, ""); - -#ifdef WIN32 - /* Initialize WinSocket for the Windows version */ -#endif - - SoapTraceLeave(FUNC, ""); - return CSOAP_OK; -} - - diff --git a/src/csoapsocket.h b/src/csoapsocket.h deleted file mode 100644 index 216b1a2..0000000 --- a/src/csoapsocket.h +++ /dev/null @@ -1,81 +0,0 @@ -/****************************************************************** - * $Id: csoapsocket.h,v 1.1 2003/03/25 22:17:28 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@jprogrammet.net - ******************************************************************/ -#ifndef CSOAP_SOCKET_H -#define CSOAP_SOCKET_H - -#include -#include "csoaperror.h" - -typedef int HSOAPSOCKET; - - -/** - * Initializes the soap socket module. - * This is called internally. Before any - * socket operation. - * - * @return CSOAP_OK if it was successfull - */ -int SoapSocketInitialize(); - - -/** - * Creates a new soap compatible socket object. - * - * @param host the host to connect - * @param port the port to connect - * @param socket the destination pointer - * to receive a connected socket object - * - * @return CSOAP_OK if it was successfull. - */ -CSOAP_STATUS SoapSocketCreate(const char* host, int port, HSOAPSOCKET* socket); - -/** - * Sends data to the connected socket. - * - * @param sock A connected socket object - * @param req data to send - * @param sentSize the size of sent data - * - * @return CSOAP_OK if it was successfull - */ -CSOAP_STATUS SoapSocketSend(HSOAPSOCKET sock, const char* req,ssize_t* sentSize); - - -/** - * Receives data from the connected socket. - * - * @param sock A connected socket object - * @param res destination pointer to receive - * the data. This will be allocated in this - * function. So you have to free it. - * @param receivedSize the size of received data - * - * @return CSOAP_OK if it was successfull - */ -CSOAP_STATUS SoapSocketRecv(HSOAPSOCKET sock, char** res,ssize_t* receivedSize); - - -#endif diff --git a/src/csoaptypes.h b/src/csoaptypes.h deleted file mode 100644 index 64b2be1..0000000 --- a/src/csoaptypes.h +++ /dev/null @@ -1,33 +0,0 @@ -/****************************************************************** - * $Id: csoaptypes.h,v 1.2 2003/05/20 21:00:18 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_TYPES_H -#define CSOAP_TYPES_H - - -#define SOAP_TYPE_STRING "xsd:string" -#define SOAP_TYPE_INT "xsd:int" -#define SOAP_TYPE_DOUBLE "xsd:double" - - -#endif diff --git a/src/csoapurl.c b/src/csoapurl.c deleted file mode 100644 index 6c77142..0000000 --- a/src/csoapurl.c +++ /dev/null @@ -1,185 +0,0 @@ -/****************************************************************** - * $Id: csoapurl.c,v 1.2 2003/05/20 21:00:16 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 - ******************************************************************/ -#include "csoapurl.h" -#include "csoaplog.h" - -#include -#include - - -static -HSOAPURL CreateUrlFromIndex(const char* urlstr, int iprotocol, int ihost, int iport) -{ - const char *FUNC = "CreateUrlFromIndex"; - int len, size; - char tmp[8]; - HSOAPURL url; - - SoapTraceEnter(FUNC, "Entering"); - - url = (HSOAPURL)malloc(sizeof(struct SOAPURL)); - - url->m_protocol = (char*)malloc(sizeof(char)*iprotocol+1); - strncpy(url->m_protocol, urlstr, iprotocol); - - size = ihost - iprotocol - 3; - url->m_host = (char*)malloc(sizeof(char)*size); - strncpy(url->m_host, &urlstr[iprotocol+3], size); - - if (iport > ihost) - { - size = iport - ihost; - strncpy(tmp, &urlstr[ihost+1], size); - url->m_port = atoi(tmp); - } else { - url->m_port = 80; - } - - len = strlen(urlstr); - if (len > iport ) - { - size = len - iport; - url->m_context = (char*)malloc(sizeof(char)*size); - strncpy(url->m_context, &urlstr[iport], size); - } else { - url->m_context = NULL; - } - - SoapTraceEnter(FUNC, "Leaving url = %p", url); - return url; -}; - - -/*----------------------------------------------------------------- - FUNCTION: SoapUrlCreate -/-----------------------------------------------------------------*/ - -HSOAPURL SoapUrlCreate(const char* urlstr) -{ - const char *FUNC = "SoapUrlCreate"; - int iprotocol; - int ihost; - int iport; - int len; - HSOAPURL url = NULL; - - SoapTraceEnter(FUNC, "Entering. URL = %s", urlstr?urlstr:"null"); - - iprotocol = 0; - len = strlen(urlstr); - printf("len = %d\n", len); - /* find protocol */ - while (urlstr[iprotocol] != ':' && urlstr[iprotocol] != '\0') - { -/* printf("protocol: urlstr[%d] = %c\n",iprotocol, urlstr[iprotocol] );*/ - iprotocol++; - } - - if (iprotocol == 0) { - SoapTraceLeaveWithError(FUNC, "no protocol"); - return NULL; - } - - if (iprotocol + 3 >= len) { - SoapTraceLeaveWithError(FUNC, "no host"); - return NULL; - } - - if ( urlstr[iprotocol] != ':' - && urlstr[iprotocol+1] != '/' - && urlstr[iprotocol+2] != '/') - { - SoapTraceLeaveWithError(FUNC, "no protocol"); - return NULL; - } - - /* find host */ - ihost = iprotocol + 3; - while (urlstr[ihost] != ':' - && urlstr[ihost] != '/' - && urlstr[ihost] != '\0') - { -/* printf("host: urlstr[%d] = %c\n",ihost, urlstr[ihost] );*/ - ihost++; - } - - if (ihost == iprotocol + 1) { - SoapTraceLeaveWithError(FUNC, "no host"); - return NULL; - } - - /* find port */ - iport = ihost; - if (ihost + 1 < len) { - if (urlstr[ihost] == ':') { - while (urlstr[iport] != '/' && urlstr[iport] != '\0') { -/* printf("port: urlstr[%d] = %c\n", iport, urlstr[iport] );*/ - iport++; - } - } - } - -/* - printf("iprotocol = %d\nihost = %d\niport = %d\nlen = %d\n", - iprotocol, ihost, iport, len); -*/ - url = CreateUrlFromIndex(urlstr, iprotocol, ihost, iport); - SoapTraceLeave(FUNC, "Leaving url (%p)", url); - return url; -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapUrlFree -/-----------------------------------------------------------------*/ - -void SoapUrlFree(HSOAPURL url) -{ - if (url != NULL) { - if (url->m_protocol) free(url->m_protocol); - if (url->m_host) free(url->m_host); - if (url->m_context) free(url->m_context); - - free(url); - } -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapUrlDump -/-----------------------------------------------------------------*/ - -void SoapUrlDump(HSOAPURL url) -{ - if (url == NULL) { - printf("(null)\n"); - return ; - } - - printf("PROTOCOL : %s\n", url->m_protocol?url->m_protocol:"(null)"); - printf(" HOST : %s\n", url->m_host?url->m_host:"(null)"); - printf(" PORT : %d\n", url->m_port); - printf(" CONTEXT : %s\n", url->m_context?url->m_context:"(null)"); - -} diff --git a/src/csoapurl.h b/src/csoapurl.h deleted file mode 100644 index 7840f78..0000000 --- a/src/csoapurl.h +++ /dev/null @@ -1,70 +0,0 @@ -/****************************************************************** - * $Id: csoapurl.h,v 1.1 2003/03/25 22:17:30 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@jprogrammet.net - ******************************************************************/ -#ifndef CSOAP_URL_H -#define CSOAP_URL_H - - -/* Include csoap headers */ - - -typedef struct SOAPURL* HSOAPURL; - - -struct SOAPURL -{ - char *m_protocol; - char *m_host; - int m_port; - char *m_context; -}; - - -/** - * Creates a new url object - * - * @param url the url string - * - * @return A soap url object if it was - * successfull, NULL otherwise. - */ -HSOAPURL SoapUrlCreate(const char* url); - - -/** - * Free a url object - * - * @param url the url to free - */ -void SoapUrlFree(HSOAPURL url); - - -/** - * Dump the url data (for debugging) - * - * @param url the url to show its content - */ -void SoapUrlDump(HSOAPURL url); - - -#endif diff --git a/src/csoapxml.c b/src/csoapxml.c deleted file mode 100644 index 2c5ebcc..0000000 --- a/src/csoapxml.c +++ /dev/null @@ -1,151 +0,0 @@ -/****************************************************************** - * $Id: csoapxml.c,v 1.2 2003/05/20 21:00:19 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 - ******************************************************************/ -#include "csoapxml.h" - -#include "csoaplog.h" - - -/*----------------------------------------------------------------- - FUNCTION: SoapXmlFindNode -/-----------------------------------------------------------------*/ - -HSOAPXML -SoapXmlFindNode(HSOAPXML root, const char* nodeName) -{ - xmlNodePtr cur; - const char* FUNC = "SoapXmlFindNode"; - - SoapTraceEnter(FUNC,"root (%p) node (%p)", - root, nodeName?nodeName:"null"); - - if (root == NULL) { - SoapLog(LOG_ERROR, FUNC, - "Invalid root node (null)"); - return NULL; - } - - if (nodeName == NULL) { - SoapLog(LOG_ERROR, FUNC, - "Invalid node name (null)"); - return NULL; - } - - cur = ((xmlNodePtr)root)->xmlChildrenNode; - while (cur != NULL) { - if (!xmlStrcmp(cur->name, (const xmlChar*)nodeName)) { - SoapTraceLeave(FUNC, "Found '%s' (%p)", nodeName, cur); - return cur; - } - cur = cur->next; - } - - SoapTraceLeave(FUNC, "No '%s' found!", nodeName); - return NULL; -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapXmlGetNodeValue -/-----------------------------------------------------------------*/ - -int -SoapXmlGetNodeValue(HSOAPXML xmlNode, char* dest) -{ - char *value; - int len; - const char* FUNC = "SoapXmlGetNodeValue"; - SoapTraceEnter(FUNC,"Entering"); - - - if (xmlNode == NULL) { - SoapTraceLeaveWithError(FUNC, - "Invalid parameter 'xmlNode' (null)"); - return 0; - } - - value = (char*)xmlNodeListGetString(((xmlNodePtr)xmlNode)->doc, - ((xmlNodePtr)xmlNode)->xmlChildrenNode,1); - strcpy(dest, value); - len = strlen(value); - xmlFree(value); - - SoapTraceLeave(FUNC, "Value = '%s'\nLength=%d", dest, len); - return len; - -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapXmlGetNodeValueAlloc -/-----------------------------------------------------------------*/ - -char* -SoapXmlGetNodeValueAlloc(HSOAPXML xmlNode) -{ - char *value; - int len; - const char* FUNC = "SoapXmlGetNodeValueAlloc"; - SoapTraceEnter(FUNC,"Entering"); - - - if (xmlNode == NULL) { - SoapTraceLeaveWithError(FUNC, - "Invalid parameter 'xmlNode' (null)"); - return 0; - } - - value = (char*)xmlNodeListGetString(((xmlNodePtr)xmlNode)->doc, - ((xmlNodePtr)xmlNode)->xmlChildrenNode,1); - SoapTraceLeave(FUNC, "Value = '%s'\n", value); - return value; -} - - -/*----------------------------------------------------------------- - FUNCTION: SoapXmlGetAttr -/-----------------------------------------------------------------*/ - -char* SoapXmlGetAttr(HSOAPXML node, const char* ns, const char* key) -{ - char *value; - int len; - const char* FUNC = "SoapXmlGetAttr"; - SoapTraceEnter(FUNC,"Entering"); - - - if (node == NULL) { - SoapTraceLeaveWithError(FUNC, - "Invalid parameter 'node' (null)"); - return NULL; - } - - if (ns == NULL) { - value = (char*)xmlGetProp(node, key); - } else { - value = (char*)xmlGetNsProp(node, key, ns); - } - - SoapTraceLeave(FUNC, "Value = '%s'\n", value?value:"(null)"); - return value; -} diff --git a/src/csoapxml.h b/src/csoapxml.h deleted file mode 100644 index 751641e..0000000 --- a/src/csoapxml.h +++ /dev/null @@ -1,90 +0,0 @@ -/****************************************************************** - * $Id: csoapxml.h,v 1.2 2003/05/20 21:00:18 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_XML_H -#define CSOAP_XML_H - - -#include -#include - -#include "csoaperror.h" - - -typedef xmlNodePtr HSOAPXML; - - -/** - * Search for an xml node which - * has the name nodeName - * - * @param root the root xml node to search - * the nodeName in its children nodes - * @param nodeName the nodeName to find - * - * @return an xml node if any exist, - * NULL otherwise - */ -HSOAPXML SoapXmlFindNode(HSOAPXML root, const char* nodeName); - - -/** - * Receives the node value - * - * @param node the xml node to receive - * its text node - * @param dest the destination string - * - * @return length of content copied into dest - */ -int SoapXmlGetNodeValue(HSOAPXML node, char* dest); - - -/** - * Receives the node value. - * - * @param node the xml node to receive - * its text node - * - * @return An allocated string. You must free - * it using SoapFreeStr - * @see SoapFreeStr - */ -char* SoapXmlGetNodeValueAlloc(HSOAPXML node); - - -/** - * Returns the xml attribute - * - * @param node the xml node to receive its attribute - * @param ns namespace of the attribute - * @param key key of the attribute - * - * @return value of the attribute if any found, - * NULL otherwise. It's up to the caller to free - * the memory with SoapFreeStr(). - */ -char* SoapXmlGetAttr(HSOAPXML node, const char* ns, const char* key); - -#endif - -- cgit v1.1-32-gdbae