--- xds_engine_xml.c 2001/08/13 19:48:02 1.7
+++ xds_engine_xml.c 2001/08/30 14:49:49 1.8
@@ -414,6 +414,35 @@
#endif /* XDS_HAVE_64_BIT_SUPPORT */
/*
+ * Encode/decode floating point values.
+ */
+
+int xml_encode_float(xds_t *xds, void *engine_context,
+ void *buffer, size_t buffer_size,
+ size_t *used_buffer_size, va_list *args)
+ {
+ xds_init_encoding_engine(7 + 8 + 1);
+ *used_buffer_size =
+ snprintf(buffer, buffer_size, "<float>%f</float>", va_arg(*args, double));
+ if (*used_buffer_size >= buffer_size)
+ return XDS_ERR_OVERFLOW;
+ else
+ return XDS_OK;
+ }
+
+int xml_decode_float(xds_t *xds, void *engine_context,
+ void *buffer, size_t buffer_size,
+ size_t *used_buffer_size, va_list *args)
+ {
+ xds_init_decoding_engine(7 + 8 + 1);
+ if (sscanf(buffer, "<float>%f</float>%n",
+ va_arg(*args, float*), used_buffer_size) != 1)
+ return XDS_ERR_TYPE_MISMATCH;
+ else
+ return XDS_OK;
+ }
+
+/*
* Encode/decode double-precision floating point values.
*/
@@ -421,16 +450,25 @@
void *buffer, size_t buffer_size,
size_t *used_buffer_size, va_list *args)
{
- /* XXX */
- return -1;
+ xds_init_encoding_engine(8 + 9 + 1);
+ *used_buffer_size =
+ snprintf(buffer, buffer_size, "<double>%f</double>", va_arg(*args, double));
+ if (*used_buffer_size >= buffer_size)
+ return XDS_ERR_OVERFLOW;
+ else
+ return XDS_OK;
}
int xml_decode_double(xds_t *xds, void *engine_context,
void *buffer, size_t buffer_size,
size_t *used_buffer_size, va_list *args)
{
- /* XXX */
- return -1;
+ xds_init_decoding_engine(8 + 9 + 1);
+ if (sscanf(buffer, "<double>%lf</double>%n",
+ va_arg(*args, double*), used_buffer_size) != 1)
+ return XDS_ERR_TYPE_MISMATCH;
+ else
+ return XDS_OK;
}
/*
|