/* Copyright and license information is at the end of the file */

#ifndef  XMLRPC_SERVER_H_INCLUDED
#define  XMLRPC_SERVER_H_INCLUDED

#include <xmlrpc-c/base.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef struct _xmlrpc_registry xmlrpc_registry;

typedef void
(*xmlrpc_preinvoke_method)(xmlrpc_env *   const envP,
                           const char *   const methodName,
                           xmlrpc_value * const paramArrayP,
                           void *         const userData);

typedef xmlrpc_value *
(*xmlrpc_method)(xmlrpc_env *   const envP,
                 xmlrpc_value * const paramArrayP,
                 void *         const userData);

typedef xmlrpc_value *
(*xmlrpc_default_method)(xmlrpc_env *   const envP,
                         const char *   const host,
                         const char *   const methodName,
                         xmlrpc_value * const paramArrayP,
                         void *         const userData);

xmlrpc_registry *
xmlrpc_registry_new(xmlrpc_env * const envP);

void
xmlrpc_registry_free(xmlrpc_registry * const registryP);

void
xmlrpc_registry_disable_introspection(xmlrpc_registry * const registryP);

void
xmlrpc_registry_add_method(xmlrpc_env *      const envP,
                           xmlrpc_registry * const registryP,
                           const char *      const host,
                           const char *      const methodName,
                           xmlrpc_method     const method,
                           void *            const userData);

void
xmlrpc_registry_add_method_w_doc(xmlrpc_env *      const envP,
                                 xmlrpc_registry * const registryP,
                                 const char *      const host,
                                 const char *      const methodName,
                                 xmlrpc_method     const method,
                                 void *            const userData,
                                 const char *      const signature,
                                 const char *      const help);

void
xmlrpc_registry_set_default_method(xmlrpc_env *          const envP,
                                   xmlrpc_registry *     const registryP,
                                   xmlrpc_default_method const handler,
                                   void *                const userData);

void
xmlrpc_registry_set_preinvoke_method(xmlrpc_env *            const envP,
                                     xmlrpc_registry *       const registryP,
                                     xmlrpc_preinvoke_method const method,
                                     void *                  const userData);


typedef void xmlrpc_server_shutdown_fn(xmlrpc_env *, void *, const char *);
    /* A function that shuts down a server that uses a registry.
       Second argument is context specific to that function; third
       argument is a comment to describe the shutdown.
    */

void
xmlrpc_registry_set_shutdown(xmlrpc_registry *           const registryP,
                             xmlrpc_server_shutdown_fn * const shutdownFn,
                             void *                      const context);

/*----------------------------------------------------------------------------
   Lower interface -- services to be used by an HTTP request handler
-----------------------------------------------------------------------------*/
                    
xmlrpc_mem_block *
xmlrpc_registry_process_call(xmlrpc_env *      const envP,
                             xmlrpc_registry * const registryP,
                             const char *      const host,
                             const char *      const xmlData,
                             size_t            const xmlLen);

#ifdef __cplusplus
}
#endif

/* Copyright (C) 2001 by First Peer, Inc. All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
** 1. Redistributions of source code must retain the above copyright
**    notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
**    notice, this list of conditions and the following disclaimer in the
**    documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
**    derived from this software without specific prior written permission. 
**  
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
** ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE. */
#endif
