MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / xdr_datum

Function xdr_datum

src/common/xdr.cpp:158–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156
157
158bool_t xdr_datum( xdr_t* xdrs, const dsc* desc, UCHAR* buffer)
159{
160/**************************************
161 *
162 * x d r _ d a t u m
163 *
164 **************************************
165 *
166 * Functional description
167 * Map from external to internal representation (or vice versa).
168 * Handle a data item by relative descriptor and buffer.
169 *
170 **************************************/
171 BLOB_PTR* p = buffer + (IPTR) desc->dsc_address;
172
173 switch (desc->dsc_dtype)
174 {
175 case dtype_dbkey:
176 fb_assert(false); // dbkey should not get outside jrd,
177 // but in case it happenned in production server treat it as text
178 // Fall through ...
179
180 case dtype_text:
181 case dtype_boolean:
182 if (!xdr_opaque(xdrs, reinterpret_cast<SCHAR*>(p), desc->dsc_length))
183 return FALSE;
184 break;
185
186 case dtype_varying:
187 {
188 fb_assert(desc->dsc_length >= sizeof(USHORT));
189 vary* v = reinterpret_cast<vary*>(p);
190 if (!xdr_short(xdrs, reinterpret_cast<SSHORT*>(&v->vary_length)))
191 {
192 return FALSE;
193 }
194 if (!xdr_opaque(xdrs, v->vary_string,
195 MIN((USHORT) (desc->dsc_length - 2), v->vary_length)))
196 {
197 return FALSE;
198 }
199 if (xdrs->x_op == XDR_DECODE && desc->dsc_length - 2 > v->vary_length)
200 {
201 memset(v->vary_string + v->vary_length, 0, desc->dsc_length - 2 - v->vary_length);
202 }
203 }
204 break;
205
206 case dtype_cstring:
207 {
208 //SSHORT n;
209 USHORT n;
210 if (xdrs->x_op == XDR_ENCODE)
211 {
212 n = MIN(static_cast<ULONG>(strlen(reinterpret_cast<char*>(p))), (ULONG)(desc->dsc_length - 1));
213 }
214 if (!xdr_short(xdrs, reinterpret_cast<SSHORT*>(&n)))
215 return FALSE;

Callers 4

xdr_messageFunction · 0.85
xdr_packed_messageFunction · 0.85
xdr_sliceFunction · 0.85
xdr_sliceFunction · 0.85

Calls 10

xdr_opaqueFunction · 0.85
xdr_shortFunction · 0.85
xdr_longFunction · 0.85
xdr_floatFunction · 0.85
xdr_doubleFunction · 0.85
xdr_dec64Function · 0.85
xdr_dec128Function · 0.85
xdr_int128Function · 0.85
xdr_hyperFunction · 0.85
xdr_quadFunction · 0.85

Tested by

no test coverage detected