/* This file is part of libXMLRPC - a C library for xml-encoded function calls. Author: Dan Libby (dan@libby.com) Epinions.com may be contacted at feedback@epinions-inc.com */ /* Copyright 2001 Epinions, Inc. Subject to the following 3 conditions, Epinions, Inc. permits you, free of charge, to (a) use, copy, distribute, modify, perform and display this software and associated documentation files (the "Software"), and (b) permit others to whom the Software is furnished to do so as well. 1) The above copyright notice and this permission notice shall be included without modification in all copies or substantial portions of the Software. 2) THE SOFTWARE IS PROVIDED "AS IS", WITHOUT ANY WARRANTY OR CONDITION OF ANY KIND, EXPRESS, IMPLIED OR STATUTORY, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OF ACCURACY, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. 3) IN NO EVENT SHALL EPINIONS, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE (HOWEVER ARISING, INCLUDING NEGLIGENCE), EVEN IF EPINIONS, INC. IS AWARE OF THE POSSIBILITY OF SUCH DAMAGES. */ /****h* ABOUT/system_methods * AUTHOR * Dan Libby, aka danda (dan@libby.com) * HISTORY * $Log$ * Revision 1.7 2001/09/29 21:58:05 danda * adding cvs log to history section * * 4/28/2001 -- danda -- adding system.multicall and separating out system methods. * TODO * NOTES *******/ #include "queue.h" #include "xmlrpc.h" #include "xmlrpc_private.h" #include "xmlrpc_introspection_private.h" #include "system_methods_private.h" #include #include #include static const char* xsm_introspection_xml = "" "" "" "" "value identifier" "value's xmlrpc or user-defined type" "value's textual description " "true if value is optional, else it is required " "a child of this element. n/a for scalar types " "" "" "" "" "" "" "" "" "" "" "" "Dan Libby" "fully describes the methods and types implemented by this XML-RPC server." "1.1" "" "" "" "" "a valid method name" "" "" "" "" "" "" "method name" "method version" "method author" "method purpose" "" "" "parameter list" "return value list" "" "" "list of known bugs" "list of possible errors and error codes" "list of examples" "list of modifications" "list of notes" "see also. list of related methods" "list of unimplemented features" "" "" "" "a type description" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "Dan Libby" "enumerates the methods implemented by this XML-RPC server." "1.0" "" "" "" "" "name of a method implemented by the server." "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "Dan Libby" "provides documentation string for a single method" "1.0" "" "" "" "name of the method for which documentation is desired" "" "" "help text if defined for the method passed, otherwise an empty string" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "Dan Libby" "provides 1 or more signatures for a single method" "1.0" "" "" "" "name of the method for which documentation is desired" "" "" "" "" "a string indicating the xmlrpc type of a value. one of: string, int, double, base64, datetime, array, struct" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "Dan Libby" "executes multiple methods in sequence and returns the results" "1.0" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "Dan Libby" "returns a list of capabilities supported by this server" "1.0" "spec url: http://groups.yahoo.com/group/xml-rpc/message/2897" "" "" "" "" "" "www address of the specification defining this capability" "version of the spec that this server's implementation conforms to" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""; /* forward declarations for static (non public, non api) funcs */ static XMLRPC_VALUE xsm_system_multicall_cb(XMLRPC_SERVER server, XMLRPC_REQUEST input, void* userData); static XMLRPC_VALUE xsm_system_get_capabilities_cb(XMLRPC_SERVER server, XMLRPC_REQUEST input, void* userData); /*-******************* * System Methods API * *********************/ static void xsm_lazy_doc_methods_cb(XMLRPC_SERVER server, void* userData) { XMLRPC_VALUE xDesc = XMLRPC_IntrospectionCreateDescription(xsm_introspection_xml, NULL); XMLRPC_ServerAddIntrospectionData(server, xDesc); XMLRPC_CleanupValue(xDesc); } void xsm_register(XMLRPC_SERVER server) { xi_register_system_methods(server); XMLRPC_ServerRegisterMethod(server, xsm_token_system_multicall, xsm_system_multicall_cb); XMLRPC_ServerRegisterMethod(server, xsm_token_system_get_capabilities, xsm_system_get_capabilities_cb); /* callback for documentation generation should it be requested */ XMLRPC_ServerRegisterIntrospectionCallback(server, xsm_lazy_doc_methods_cb); } XMLRPC_VALUE xsm_system_multicall_cb(XMLRPC_SERVER server, XMLRPC_REQUEST input, void* userData) { XMLRPC_VALUE xArray = XMLRPC_VectorRewind(XMLRPC_RequestGetData(input)); XMLRPC_VALUE xReturn = XMLRPC_CreateVector(0, xmlrpc_vector_array); if (xArray) { XMLRPC_VALUE xMethodIter = XMLRPC_VectorRewind(xArray); while (xMethodIter) { XMLRPC_REQUEST request = XMLRPC_RequestNew(); if(request) { const char* methodName = XMLRPC_VectorGetStringWithID(xMethodIter, "methodName"); XMLRPC_VALUE params = XMLRPC_VectorGetValueWithID(xMethodIter, "params"); if(methodName && params) { XMLRPC_VALUE xRandomArray = XMLRPC_CreateVector(0, xmlrpc_vector_array); XMLRPC_RequestSetMethodName(request, methodName); XMLRPC_RequestSetData(request, params); XMLRPC_RequestSetRequestType(request, xmlrpc_request_call); XMLRPC_AddValueToVector(xRandomArray, XMLRPC_ServerCallMethod(server, request, userData)); XMLRPC_AddValueToVector(xReturn, xRandomArray); } XMLRPC_RequestFree(request, 1); } xMethodIter = XMLRPC_VectorNext(xArray); } } return xReturn; } XMLRPC_VALUE xsm_system_get_capabilities_cb(XMLRPC_SERVER server, XMLRPC_REQUEST input, void* userData) { XMLRPC_VALUE xReturn = XMLRPC_CreateVector(0, xmlrpc_vector_struct); XMLRPC_VALUE xFaults = XMLRPC_CreateVector("faults_interop", xmlrpc_vector_struct); XMLRPC_VALUE xIntro = XMLRPC_CreateVector("introspection", xmlrpc_vector_struct); /* support for fault spec */ XMLRPC_VectorAppendString(xFaults, "specURL", "http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php", 0); XMLRPC_VectorAppendInt(xFaults, "specVersion", 20010516); /* support for introspection spec */ XMLRPC_VectorAppendString(xIntro, "specURL", "http://xmlrpc-epi.sourceforge.net/specs/rfc.introspection.php", 0); XMLRPC_VectorAppendInt(xIntro, "specVersion", 20010516); XMLRPC_AddValuesToVector(xReturn, xFaults, xIntro, NULL); return xReturn; } /*-*********************** * End System Methods API * *************************/