xmlrpc_server_abyss.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /* Copyright (C) 2001 by First Peer, Inc. All rights reserved.
  2. **
  3. ** Redistribution and use in source and binary forms, with or without
  4. ** modification, are permitted provided that the following conditions
  5. ** are met:
  6. ** 1. Redistributions of source code must retain the above copyright
  7. ** notice, this list of conditions and the following disclaimer.
  8. ** 2. Redistributions in binary form must reproduce the above copyright
  9. ** notice, this list of conditions and the following disclaimer in the
  10. ** documentation and/or other materials provided with the distribution.
  11. ** 3. The name of the author may not be used to endorse or promote products
  12. ** derived from this software without specific prior written permission.
  13. **
  14. ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  15. ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16. ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  17. ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  18. ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  19. ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  20. ** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  21. ** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  22. ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  23. ** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  24. ** SUCH DAMAGE. */
  25. #ifndef _XMLRPC_SERVER_ABYSS_H_
  26. #define _XMLRPC_SERVER_ABYSS_H_ 1
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif /* __cplusplus */
  30. struct _TServer;
  31. /*=========================================================================
  32. ** XML-RPC Server (based on Abyss)
  33. **=========================================================================
  34. ** A simple XML-RPC server based on the Abyss web server. If errors
  35. ** occur during server setup, the server will exit. In general, if you
  36. ** want to use this API, you'll need to be familiar with Abyss.
  37. **
  38. ** There are two ways to use Abyss:
  39. ** 1) You can use the handy wrapper functions.
  40. ** 2) You can set up Abyss yourself, and install the appropriate
  41. ** handlers manually.
  42. */
  43. #define XMLRPC_SERVER_ABYSS_NO_FLAGS (0)
  44. /*=========================================================================
  45. ** Basic Abyss Server Functions
  46. **=======================================================================*/
  47. typedef void ((*runfirstFn)(void *));
  48. typedef struct {
  49. const char * config_file_name;
  50. xmlrpc_registry * registryP;
  51. runfirstFn runfirst;
  52. void * runfirst_arg;
  53. } xmlrpc_server_abyss_parms;
  54. #define XMLRPC_APSIZE(MBRNAME) \
  55. XMLRPC_STRUCTSIZE(xmlrpc_server_abyss_parms, MBRNAME)
  56. /* XMLRPC_APSIZE(xyz) is the minimum size a struct xmlrpc_server_abyss_parms
  57. must be to include the 'xyz' member. This is essential to forward and
  58. backward compatbility, as new members will be added to the end of the
  59. struct in future releases. This is how the callee knows whether or
  60. not the caller is new enough to have supplied a certain parameter.
  61. */
  62. void
  63. xmlrpc_server_abyss(xmlrpc_env * const envP,
  64. const xmlrpc_server_abyss_parms * const parms,
  65. unsigned int const parm_size);
  66. void
  67. xmlrpc_server_abyss_set_handlers(struct _TServer * const srvP,
  68. xmlrpc_registry * const registryP);
  69. /*=========================================================================
  70. ** Handy Abyss Extensions
  71. **=======================================================================*/
  72. /* These are functions that have nothing to do with Xmlrpc-c, but provide
  73. convenient Abyss services beyond those provided by the Abyss library.
  74. */
  75. /* Start an Abyss webserver running (previously created and
  76. ** initialized). Under Unix, this routine will attempt to do a
  77. ** detaching fork, drop root privileges (if any) and create a pid
  78. ** file. Under Windows, this routine merely starts the server. This
  79. ** routine never returns.
  80. **
  81. ** Once you call this routine, it is illegal to modify the server any
  82. ** more, including changing any method registry.
  83. */
  84. void
  85. xmlrpc_server_abyss_run(void);
  86. /* Same as xmlrpc_server_abyss_run(), except you get to specify a "runfirst"
  87. ** function. The server runs this just before executing the actual server
  88. ** function, after any daemonizing. NULL for 'runfirst' means no runfirst
  89. ** function. 'runfirstArg' is the argument the server passes to the runfirst
  90. ** function.
  91. **/
  92. void
  93. xmlrpc_server_abyss_run_first(void (runfirst(void *)),
  94. void * const runfirstArg);
  95. /*=========================================================================
  96. ** Method Registry
  97. **=========================================================================
  98. These functions are for the built-in xmlrpc_server_abyss registry.
  99. It's usually simpler to skip all this and use the regular method
  100. registry services (from xmlrpc_server.h) to build a registry and
  101. pass it to xmlrpc_server_abyss.
  102. */
  103. /* Call this function to create a new Abyss webserver with the default
  104. ** options and the built-in method registry. If you've already
  105. ** initialized Abyss using Abyss functions, you can instead call
  106. ** xmlrpc_server_abyss_init_registry() to make it an Xmlrpc-c server.
  107. ** Or use a regular method registry and call
  108. ** xmlrpc_server_abyss_set_handlers().
  109. **/
  110. void
  111. xmlrpc_server_abyss_init(int const flags,
  112. const char * const config_file);
  113. /* This is called automatically by xmlrpc_server_abyss_init. */
  114. void xmlrpc_server_abyss_init_registry (void);
  115. /* Fetch the internal registry, if you happen to need it.
  116. If you're using this, you really shouldn't be using the built-in
  117. registry at all. It exists today only for backward compatibilty.
  118. */
  119. extern xmlrpc_registry *
  120. xmlrpc_server_abyss_registry (void);
  121. /* A quick & easy shorthand for adding a method. Depending on
  122. ** how you've configured your copy of Abyss, it's probably not safe to
  123. ** call this method after calling xmlrpc_server_abyss_run. */
  124. void xmlrpc_server_abyss_add_method (char *method_name,
  125. xmlrpc_method method,
  126. void *user_data);
  127. /* As above, but provide documentation (see xmlrpc_registry_add_method_w_doc
  128. ** for more information). You should really use this one. */
  129. extern void
  130. xmlrpc_server_abyss_add_method_w_doc (char *method_name,
  131. xmlrpc_method method,
  132. void *user_data,
  133. char *signature,
  134. char *help);
  135. /*=========================================================================
  136. ** Content Handlers
  137. **=======================================================================*/
  138. /* Abyss contents handlers xmlrpc_server_abyss_rpc2_handler()
  139. and xmlrpc_server_abyss_default_handler() were available in older
  140. Xmlrpc-c, but starting with Release 1.01, they are not. Instead,
  141. call xmlrpc_server_abyss_set_handlers() to install them.
  142. Alternatively, you can write your own handlers that do the same thing.
  143. It's not hard, and if you're writing low enough level Abyss code that
  144. you can't use xmlrpc_server_abyss_set_handlers(), you probably want to
  145. anyway.
  146. */
  147. #ifdef __cplusplus
  148. }
  149. #endif /* __cplusplus */
  150. #endif