1 /*
2   This file is part of libXMLRPC - a C library for xml-encoded function calls.
3 
4   Author: Dan Libby (dan@libby.com)
5   Epinions.com may be contacted at feedback@epinions-inc.com
6 */
7 
8 /*
9   Copyright 2000 Epinions, Inc.
10 
11   Subject to the following 3 conditions, Epinions, Inc.  permits you, free
12   of charge, to (a) use, copy, distribute, modify, perform and display this
13   software and associated documentation files (the "Software"), and (b)
14   permit others to whom the Software is furnished to do so as well.
15 
16   1) The above copyright notice and this permission notice shall be included
17   without modification in all copies or substantial portions of the
18   Software.
19 
20   2) THE SOFTWARE IS PROVIDED "AS IS", WITHOUT ANY WARRANTY OR CONDITION OF
21   ANY KIND, EXPRESS, IMPLIED OR STATUTORY, INCLUDING WITHOUT LIMITATION ANY
22   IMPLIED WARRANTIES OF ACCURACY, MERCHANTABILITY, FITNESS FOR A PARTICULAR
23   PURPOSE OR NONINFRINGEMENT.
24 
25   3) IN NO EVENT SHALL EPINIONS, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
26   SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
27   OF OR IN CONNECTION WITH THE SOFTWARE (HOWEVER ARISING, INCLUDING
28   NEGLIGENCE), EVEN IF EPINIONS, INC.  IS AWARE OF THE POSSIBILITY OF SUCH
29   DAMAGES.
30 
31 */
32 
33 /* only non-public things should be in this file.  It is fine for any .c file
34  * in xmlrpc/src to include it, but users of the public API should never
35  * include it, and thus *.h files that are part of the public API should
36  * never include it, or they would break if this file is not present.
37  */
38 
39 #ifndef XMLRPC_PRIVATE_ALREADY_INCLUDED
40 /*
41  * Avoid include redundancy.
42  */
43 #define XMLRPC_PRIVATE_ALREADY_INCLUDED
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 
50 /*----------------------------------------------------------------------------
51  * xmlrpc_private.h
52  *
53  * Purpose:
54  *   define non-public intra-library routines & data
55  * Comments:
56  */
57 
58 /*----------------------------------------------------------------------------
59  * Constants
60  */
61 
62 
63 /*----------------------------------------------------------------------------
64  * Includes
65  */
66 
67 /*----------------------------------------------------------------------------
68  * Structures
69  */
70 
71 /* Some of these are typedef'd in xmlrpc.h for public use */
72 
73 typedef struct _xmlrpc_vector* XMLRPC_VECTOR;
74 
75 /****s* VALUE/XMLRPC_VALUE
76  * NAME
77  *   XMLRPC_VALUE
78  * NOTES
79  *   A value of variable data type. The most important object in this API.  :)
80  *
81  *  This struct is opaque to callers and should be accessed only via accessor functions.
82  * SEE ALSO
83  *   XMLRPC_REQUEST
84  *   XMLRPC_CreateValueEmpty ()
85  *   XMLRPC_CleanupValue ()
86  * SOURCE
87  */
88 typedef struct _xmlrpc_value {
89    XMLRPC_VALUE_TYPE type; /* data type of this value                        */
90    XMLRPC_VECTOR v;        /* vector type specific info                      */
91    simplestring str;       /* string value buffer                            */
92    simplestring id;        /* id of this value.  possibly empty.             */
93    int i;                  /* integer value.                                 */
94    double d;               /* double value                                   */
95    int iRefCount;          /* So we know when we can delete the value      . */
96 } STRUCT_XMLRPC_VALUE;
97 /******/
98 
99 /****s* VALUE/XMLRPC_REQUEST
100  * NAME
101  *   XMLRPC_REQUEST
102  * NOTES
103  *   Internal representation of an XML request.
104  *
105  *  This struct is opaque to callers and should be accessed only via accessor functions.
106  *
107  * SEE ALSO
108  *   XMLRPC_VALUE
109  *   XMLRPC_RequestNew ()
110  *   XMLRPC_RequestFree ()
111  * SOURCE
112  */
113 typedef struct _xmlrpc_request {
114    XMLRPC_VALUE                         io;           /* data associated with this request */
115    simplestring                         methodName;   /* name of method being called       */
116    XMLRPC_REQUEST_TYPE                  request_type; /* type of request                   */
117    STRUCT_XMLRPC_REQUEST_OUTPUT_OPTIONS output;       /* xml output options                */
118    XMLRPC_VALUE                         error;        /* error codes                       */
119 } STRUCT_XMLRPC_REQUEST;
120 /******/
121 
122 /* Vector type. Used by XMLRPC_VALUE.  Never visible to users of the API. */
123 typedef struct _xmlrpc_vector {
124    XMLRPC_VECTOR_TYPE type;                           /* vector type                       */
125    queue *q;                                          /* list of child values              */
126 } STRUCT_XMLRPC_VECTOR;
127 /******/
128 
129 /****s* VALUE/XMLRPC_SERVER
130  * NAME
131  *   XMLRPC_SERVER
132  * NOTES
133  *   internal representation of an xmlrpc server
134  *
135  *  This struct is opaque to callers and should be accessed only via accessor functions.
136  *
137  * SEE ALSO
138  *   XMLRPC_ServerCreate ()
139  *   XMLRPC_ServerDestroy ()
140  * SOURCE
141  */
142 typedef struct _xmlrpc_server {
143    queue methodlist;                                  /* list of callback methods          */
144    queue docslist;                                    /* list of introspection callbacks   */
145    XMLRPC_VALUE xIntrospection;
146 } STRUCT_XMLRPC_SERVER;
147 /******/
148 
149 typedef struct _server_method {
150    char*                   name;
151    XMLRPC_VALUE            desc;
152    XMLRPC_Callback         method;
153 } server_method;
154 
155 
156 /*----------------------------------------------------------------------------
157  * Globals
158  */
159 
160 /*----------------------------------------------------------------------------
161  * Functions
162  */
163 server_method* find_method(XMLRPC_SERVER server, const char* name);
164 const char* type_to_str(XMLRPC_VALUE_TYPE type, XMLRPC_VECTOR_TYPE vtype);
165 
166 /*----------------------------------------------------------------------------
167  * Macros
168  */
169 #define my_free(thing)  if(thing) {efree(thing); thing = 0;}
170 
171 
172 #ifdef __cplusplus
173 }
174 #endif
175 
176 
177 #endif /* XMLRPC_PRIVATE_ALREADY_INCLUDED */
178