initial load of upstream version 1.06.32
[xmlrpc-c] / include / xmlrpc-c / base_int.h
1 /*============================================================================
2                          base_int.h
3 ==============================================================================
4   This header file defines the interface between modules inside
5   xmlrpc-c.
6
7   Use this in addition to xmlrpc.h, which defines the external
8   interface.
9
10   Copyright information is at the end of the file.
11 ============================================================================*/
12
13
14 #ifndef  XMLRPC_C_BASE_INT_H_INCLUDED
15 #define  XMLRPC_C_BASE_INT_H_INCLUDED
16
17 #include "xmlrpc_config.h"
18 #include "bool.h"
19
20 #include <xmlrpc-c/base.h>
21 #include <xmlrpc-c/util_int.h>
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27
28 struct _xmlrpc_value {
29     xmlrpc_type _type;
30     int _refcount;
31
32     /* Certain data types store their data directly in the xmlrpc_value. */
33     union {
34         xmlrpc_int32 i;
35         xmlrpc_bool b;
36         double d;
37         /* time_t t */
38         void *c_ptr;
39     } _value;
40     
41     /* Other data types use a memory block.
42
43        For a string, this is the characters of the string in UTF-8, plus
44        a NUL added to the end.
45     */
46     xmlrpc_mem_block _block;
47
48     xmlrpc_mem_block *_wcs_block;
49         /* This is a copy of the string value in _block, but in UTF-16
50            instead of UTF-8.  This member is not always present.  If NULL,
51            it is not present.
52
53            We keep this copy for convenience.  The value is totally
54            redundant with _block.
55
56            This member is always NULL when the data type is not string.
57
58            This member is always NULL on a system that does not have
59            Unicode wchar functions.
60         */
61 };
62
63 #define XMLRPC_ASSERT_VALUE_OK(val) \
64     XMLRPC_ASSERT((val) != NULL && (val)->_type != XMLRPC_TYPE_DEAD)
65
66 /* A handy type-checking routine. */
67 #define XMLRPC_TYPE_CHECK(env,v,t) \
68     do \
69         if ((v)->_type != (t)) \
70             XMLRPC_FAIL(env, XMLRPC_TYPE_ERROR, "Expected " #t); \
71     while (0)
72
73
74 typedef struct {
75     unsigned char key_hash;
76     xmlrpc_value *key;
77     xmlrpc_value *value;
78 } _struct_member;
79
80
81 void
82 xmlrpc_createXmlrpcValue(xmlrpc_env *    const envP,
83                          xmlrpc_value ** const valPP);
84
85 const char *
86 xmlrpc_typeName(xmlrpc_type const type);
87
88 void
89 xmlrpc_traceXml(const char * const label, 
90                 const char * const xml,
91                 unsigned int const xmlLength);
92
93 void
94 xmlrpc_destroyStruct(xmlrpc_value * const structP);
95
96 void
97 xmlrpc_destroyArrayContents(xmlrpc_value * const arrayP);
98
99 /*----------------------------------------------------------------------------
100    The following are for use by the legacy xmlrpc_parse_value().  They don't
101    do proper memory management, so they aren't appropriate for general use,
102    but there are old users that do xmlrpc_parse_value() and compensate for
103    the memory management, so we have to continue to offer this style of
104    memory management.
105
106    In particular, the functions that return xmlrpc_values don't increment
107    the reference count, and the functions that return strings don't allocate
108    new memory for them.
109 -----------------------------------------------------------------------------*/
110
111 void
112 xmlrpc_read_datetime_str_old(xmlrpc_env *         const envP,
113                              const xmlrpc_value * const valueP,
114                              const char **        const stringValueP);
115
116 void
117 xmlrpc_read_string_old(xmlrpc_env *         const envP,
118                        const xmlrpc_value * const valueP,
119                        const char **        const stringValueP);
120
121 void
122 xmlrpc_read_string_lp_old(xmlrpc_env *         const envP,
123                           const xmlrpc_value * const valueP,
124                           size_t *             const lengthP,
125                           const char **        const stringValueP);
126
127 #if XMLRPC_HAVE_WCHAR
128 void
129 xmlrpc_read_string_w_old(xmlrpc_env *     const envP,
130                          xmlrpc_value *   const valueP,
131                          const wchar_t ** const stringValueP);
132
133 void
134 xmlrpc_read_string_w_lp_old(xmlrpc_env *     const envP,
135                             xmlrpc_value *   const valueP,
136                             size_t *         const lengthP,
137                             const wchar_t ** const stringValueP);
138 #endif
139
140 void
141 xmlrpc_read_base64_old(xmlrpc_env *           const envP,
142                        const xmlrpc_value *   const valueP,
143                        size_t *               const lengthP,
144                        const unsigned char ** const byteStringValueP);
145
146
147 /* Copyright (C) 2001 by First Peer, Inc. All rights reserved.
148 **
149 ** Redistribution and use in source and binary forms, with or without
150 ** modification, are permitted provided that the following conditions
151 ** are met:
152 ** 1. Redistributions of source code must retain the above copyright
153 **    notice, this list of conditions and the following disclaimer.
154 ** 2. Redistributions in binary form must reproduce the above copyright
155 **    notice, this list of conditions and the following disclaimer in the
156 **    documentation and/or other materials provided with the distribution.
157 ** 3. The name of the author may not be used to endorse or promote products
158 **    derived from this software without specific prior written permission. 
159 **  
160 ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
161 ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
162 ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
163 ** ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
164 ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
165 ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
166 ** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
167 ** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
168 ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
169 ** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
170 ** SUCH DAMAGE. */
171
172 #ifdef __cplusplus
173 }
174 #endif
175
176 #endif