Annotation of embedaddon/libpdel/structs/xmlrpc.h, revision 1.1
1.1 ! misho 1:
! 2: /*
! 3: * Copyright (c) 2001-2002 Packet Design, LLC.
! 4: * All rights reserved.
! 5: *
! 6: * Subject to the following obligations and disclaimer of warranty,
! 7: * use and redistribution of this software, in source or object code
! 8: * forms, with or without modifications are expressly permitted by
! 9: * Packet Design; provided, however, that:
! 10: *
! 11: * (i) Any and all reproductions of the source or object code
! 12: * must include the copyright notice above and the following
! 13: * disclaimer of warranties; and
! 14: * (ii) No rights are granted, in any manner or form, to use
! 15: * Packet Design trademarks, including the mark "PACKET DESIGN"
! 16: * on advertising, endorsements, or otherwise except as such
! 17: * appears in the above copyright notice or in the software.
! 18: *
! 19: * THIS SOFTWARE IS BEING PROVIDED BY PACKET DESIGN "AS IS", AND
! 20: * TO THE MAXIMUM EXTENT PERMITTED BY LAW, PACKET DESIGN MAKES NO
! 21: * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING
! 22: * THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED
! 23: * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
! 24: * OR NON-INFRINGEMENT. PACKET DESIGN DOES NOT WARRANT, GUARANTEE,
! 25: * OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS
! 26: * OF THE USE OF THIS SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY,
! 27: * RELIABILITY OR OTHERWISE. IN NO EVENT SHALL PACKET DESIGN BE
! 28: * LIABLE FOR ANY DAMAGES RESULTING FROM OR ARISING OUT OF ANY USE
! 29: * OF THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY DIRECT,
! 30: * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE, OR CONSEQUENTIAL
! 31: * DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF
! 32: * USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY THEORY OF
! 33: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
! 34: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
! 35: * THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF
! 36: * THE POSSIBILITY OF SUCH DAMAGE.
! 37: *
! 38: * Author: Archie Cobbs <archie@freebsd.org>
! 39: */
! 40:
! 41: #ifndef _PDEL_STRUCTS_XMLRPC_H_
! 42: #define _PDEL_STRUCTS_XMLRPC_H_
! 43:
! 44: #define XML_RPC_URL "/RPC2"
! 45: #define XML_RPC_REQUEST_TAG "methodCall"
! 46: #define XML_RPC_REPLY_TAG "methodResponse"
! 47: #define XML_RPC_METHOD_NAME_TAG "methodName"
! 48:
! 49: /*
! 50: * XML-RPC structure definitions
! 51: */
! 52:
! 53: DEFINE_STRUCTS_UNION(xmlrpc_value_union, xmlrpc_value);
! 54: DEFINE_STRUCTS_UNION(xmlrpc_response_union, xmlrpc_response);
! 55: DEFINE_STRUCTS_ARRAY(xmlrpc_value_array, struct xmlrpc_value_union);
! 56: DEFINE_STRUCTS_ARRAY(xmlrpc_param_array, struct xmlrpc_param);
! 57: DEFINE_STRUCTS_ARRAY(xmlrpc_struct, struct xmlrpc_member);
! 58:
! 59: /* Member (of a structure) */
! 60: struct xmlrpc_member {
! 61: char *name;
! 62: struct xmlrpc_value_union value;
! 63: };
! 64:
! 65: /* Array */
! 66: struct xmlrpc_array {
! 67: struct xmlrpc_value_array data;
! 68: };
! 69:
! 70: /* Parameter (for either a request or a response) */
! 71: struct xmlrpc_param {
! 72: struct xmlrpc_value_union value;
! 73: };
! 74:
! 75: /* Value */
! 76: union xmlrpc_value {
! 77: char *string;
! 78: int32_t i4;
! 79: int32_t int_;
! 80: u_char boolean;
! 81: double double_;
! 82: time_t dateTime_iso8601;
! 83: struct structs_data base64;
! 84: struct xmlrpc_value_array array;
! 85: struct xmlrpc_struct struct_;
! 86: };
! 87:
! 88: /* Fault */
! 89: struct xmlrpc_fault {
! 90: struct xmlrpc_value_union value; /* see below */
! 91: };
! 92:
! 93: /* Fault in compact form */
! 94: struct xmlrpc_compact_fault {
! 95: int32_t faultCode;
! 96: char *faultString;
! 97: };
! 98:
! 99: /* Request */
! 100: struct xmlrpc_request {
! 101: char *methodName;
! 102: struct xmlrpc_param_array params;
! 103: };
! 104:
! 105: /* Response */
! 106: union xmlrpc_response {
! 107: struct xmlrpc_param_array params; /* params.length == 1 */
! 108: struct xmlrpc_fault fault;
! 109: };
! 110:
! 111: __BEGIN_DECLS
! 112:
! 113: /*
! 114: * Type describing an XML-RPC value in XML-RPC exploded form.
! 115: * This type describes a 'struct xmlrpc_value_union'.
! 116: */
! 117: extern const struct structs_type structs_type_xmlrpc_value;
! 118:
! 119: /*
! 120: * Type describing an XML-RPC array in XML-RPC exploded form.
! 121: * This type describes a 'struct xmlrpc_array'.
! 122: */
! 123: extern const struct structs_type structs_type_xmlrpc_array;
! 124:
! 125: /*
! 126: * Type describing an XML-RPC member in XML-RPC exploded form.
! 127: * This type describes a 'struct xmlrpc_member'.
! 128: */
! 129: extern const struct structs_type structs_type_xmlrpc_member;
! 130:
! 131: /*
! 132: * Type describing an XML-RPC struct in XML-RPC exploded form.
! 133: * This type describes a 'struct xmlrpc_struct'.
! 134: */
! 135: extern const struct structs_type structs_type_xmlrpc_struct;
! 136:
! 137: /*
! 138: * Type describing an XML-RPC request in XML-RPC exploded form.
! 139: * This type describes a 'struct xmlrpc_request'.
! 140: */
! 141: extern const struct structs_type structs_type_xmlrpc_request;
! 142:
! 143: /*
! 144: * Type describing an XML-RPC response in XML-RPC exploded form.
! 145: * This type describes a 'struct xmlrpc_response_union'.
! 146: */
! 147: extern const struct structs_type structs_type_xmlrpc_response;
! 148:
! 149: /*
! 150: * Type describing an XML-RPC fault in XML-RPC exploded form.
! 151: * This type describes a 'struct xmlrpc_fault'.
! 152: */
! 153: extern const struct structs_type structs_type_xmlrpc_fault;
! 154:
! 155: /*
! 156: * Type describing an XML-RPC fault in compact form.
! 157: * This type describes a 'struct xmlrpc_compact_fault'.
! 158: */
! 159: extern const struct structs_type structs_type_xmlrpc_compact_fault;
! 160:
! 161: /*
! 162: * Create an XML-RPC methodCall structure with the given parameters.
! 163: * The returned structure will be allocated with type "mtype"
! 164: * and have type &structs_type_xmlrpc_request.
! 165: *
! 166: * The parameters should be specified as pairs: type, data.
! 167: */
! 168: extern struct xmlrpc_request *structs_xmlrpc_build_request(const char *mtype,
! 169: const char *methodName, u_int nparams,
! 170: const struct structs_type **types, const void **params);
! 171:
! 172: /*
! 173: * Create an XML-RPC methodResponse structure with the given return value.
! 174: *
! 175: * The returned structure will be allocated with type "mtype"
! 176: * and have type &structs_type_xmlrpc_response.
! 177: */
! 178: extern struct xmlrpc_response_union *structs_xmlrpc_build_response(
! 179: const char *mtype, const struct structs_type *type,
! 180: const void *data);
! 181:
! 182: /*
! 183: * Create an XML-RPC methodResponse structure with the given fault.
! 184: *
! 185: * The returned structure will be allocated with type "mtype"
! 186: * and have type &structs_type_xmlrpc_response.
! 187: */
! 188: extern struct xmlrpc_response_union *structs_xmlrpc_build_fault_response(
! 189: const char *mtype,
! 190: const struct xmlrpc_compact_fault *fault);
! 191:
! 192: /*
! 193: * Convert a normal structure into an XML-RPC value.
! 194: */
! 195: extern int structs_struct2xmlrpc(const struct structs_type *type,
! 196: const void *data, const char *sname,
! 197: const struct structs_type *xtype,
! 198: void *xdata, const char *xname);
! 199:
! 200: /*
! 201: * Convert an XML-RPC value into a normal structure.
! 202: */
! 203: extern int structs_xmlrpc2struct(const struct structs_type *xtype,
! 204: const void *xdata, const char *xname,
! 205: const struct structs_type *type, void *data,
! 206: const char *sname, char *ebuf, size_t emax);
! 207:
! 208: __END_DECLS
! 209:
! 210: #endif /* _PDEL_STRUCTS_XMLRPC_H_ */
! 211:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>