soap-service.c

Go to the documentation of this file.
00001 /******************************************************************
00002 *  $Id: soap-service.c,v 1.13 2006/12/31 17:24:22 m0gg Exp $
00003 *
00004 * CSOAP Project:  A SOAP client/server library in C
00005 * Copyright (C) 2003  Ferhat Ayaz
00006 *
00007 * This library is free software; you can redistribute it and/or
00008 * modify it under the terms of the GNU Library General Public
00009 * License as published by the Free Software Foundation; either
00010 * version 2 of the License, or (at your option) any later version.
00011 *
00012 * This library is distributed in the hope that it will be useful,
00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 * Library General Public License for more details.
00016 *
00017 * You should have received a copy of the GNU Library General Public
00018 * License along with this library; if not, write to the
00019 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00020 * Boston, MA  02111-1307, USA.
00021 * 
00022 * Email: ayaz@jprogrammer.net
00023 ******************************************************************/
00024 #ifdef HAVE_CONFIG_H
00025 #include <config.h>
00026 #endif
00027 
00028 #ifdef HAVE_STDLIB_H
00029 #include <stdlib.h>
00030 #endif
00031 
00032 #ifdef HAVE_STDIO_H
00033 #include <stdio.h>
00034 #endif
00035 
00036 #ifdef HAVE_STRING_H
00037 #include <string.h>
00038 #endif
00039 
00040 #ifdef HAVE_ERRNO_H
00041 #include <errno.h>
00042 #endif
00043 
00044 #ifdef HAVE_NETINET_IN_H
00045 #include <netinet/in.h>
00046 #endif
00047 
00048 #include <libxml/tree.h>
00049 #include <libxml/uri.h>
00050 
00051 #include <nanohttp/nanohttp-error.h>
00052 #include <nanohttp/nanohttp-logging.h>
00053 
00054 #include "soap-fault.h"
00055 #include "soap-env.h"
00056 #include "soap-ctx.h"
00057 #include "soap-service.h"
00058 #include "soap-router.h"
00059 
00060 SoapServiceNode *
00061 soap_service_node_new(SoapService * service, SoapServiceNode * next)
00062 {
00063   SoapServiceNode *node;
00064 
00065   if (!(node = (SoapServiceNode *) malloc(sizeof(SoapServiceNode)))) {
00066 
00067     log_error2("malloc failed (%s)", strerror(errno));
00068     return NULL;
00069   }
00070   node->service = service;
00071   node->next = next;
00072 
00073   return node;
00074 }
00075 
00076 SoapService *
00077 soap_service_new(const char *urn, const char *method, SoapServiceFunc f)
00078 {
00079   SoapService *service;
00080 
00081   if (!(service = (SoapService *) malloc(sizeof(SoapService)))) {
00082 
00083     log_error2("malloc failed (%s)", strerror(errno));
00084     return NULL;
00085   }
00086 
00087   service->func = f;
00088 
00089   if (urn == NULL) {
00090 
00091     log_warn1("urn is NULL");
00092     urn = "";
00093   }
00094   service->urn = strdup(urn);
00095 
00096   if (method == NULL) {
00097 
00098     log_warn1("method is NULL");
00099     method = "";
00100   }
00101   service->method = strdup(method);
00102 
00103   service->status = CSOAP_SERVICE_UP;
00104 
00105   return service;
00106 }
00107 
00108 void
00109 soap_service_free(SoapService * service)
00110 {
00111   if (!service)
00112     return;
00113 
00114   if (service->urn)
00115           free(service->urn);
00116 
00117   if (service->method)
00118           free(service->method);
00119 
00120   free(service);
00121 
00122   return;
00123 }

Generated on Thu Jan 25 23:36:03 2007 for csoap by  doxygen 1.4.6