This patch adds a new function into libstat:
xml_stats_container_save which handles an xml_stream_t instead of a file.
It dumps the same data stats_container_save with XML format.
Compilation is conditional to LIB_XML.
Signed-off-by: Gilles Carry <[EMAIL PROTECTED]>
---
testcases/realtime/include/libstats.h | 13 ++++++++++
testcases/realtime/lib/libstats.c | 42 +++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 0 deletions(-)
diff --git a/testcases/realtime/include/libstats.h
b/testcases/realtime/include/libstats.h
index 05c26d8..065a623 100644
--- a/testcases/realtime/include/libstats.h
+++ b/testcases/realtime/include/libstats.h
@@ -45,6 +45,9 @@
#include <errno.h>
#include <unistd.h>
#include <math.h>
+#ifdef LIB_XML
+#include <libxml.h>
+#endif
#define MIN(A,B) ((A)<(B)?(A):(B))
#define MAX(A,B) ((A)>(B)?(A):(B))
@@ -162,4 +165,14 @@ void stats_hist_print(stats_container_t *hist);
*/
int stats_container_save(char *filename, char *title, char *labelx, char
*labely, stats_container_t *data, char *mode);
+#ifdef LIB_XML
+/* stats_container_xml_save - save the x,y data to an xml file.
+ * xs: the stream previously created with xml_stream_init.
+ * labelx: the x-axis label
+ * labely: the y-axis label
+ * mode: "points" "lines" "steps" etc, see gnuplot help for plotting types
+ */
+int xml_stats_container_save(xml_stream_t *xs, char *title, char *xlabel, char
*ylabel, stats_container_t *data, char *mode);
+#endif
+
#endif /* LIBSTAT_H */
diff --git a/testcases/realtime/lib/libstats.c
b/testcases/realtime/lib/libstats.c
index 29e7ea7..4b541b1 100644
--- a/testcases/realtime/lib/libstats.c
+++ b/testcases/realtime/lib/libstats.c
@@ -43,6 +43,9 @@
#include <unistd.h>
#include <math.h>
#include <libstats.h>
+#ifdef LIB_XML
+#include <libxml.h>
+#endif
int save_stats = 0;
@@ -355,3 +358,42 @@ int stats_container_save(char *filename, char *title, char
*xlabel, char *ylabel
return 0;
}
+
+#ifdef LIB_XML
+int xml_stats_container_save(xml_stream_t *xs, char *title, char *xlabel, char
*ylabel, stats_container_t *data, char *mode)
+{
+ int i;
+ long minx = 0, maxx = 0, miny = 0, maxy = 0;
+ stats_record_t *rec;
+
+ minx = maxx = data->records[0].x;
+ miny = maxy = data->records[0].y;
+ xml_entry(xs, "xlabel",xlabel);
+ xml_entry(xs, "ylabel",ylabel);
+ xml_entry(xs, "mode",mode);
+ xml_start_tag(xs, "data");
+
+ for (i = 0; i < data->size; i++) {
+ rec = &data->records[i];
+ minx = MIN(minx, rec->x);
+ maxx = MAX(maxx, rec->x);
+ miny = MIN(miny, rec->y);
+ maxy = MAX(maxy, rec->y);
+
+ xml_start_tag(xs, "e");
+ xml_entry(xs, "r", "%d", i);
+ xml_entry(xs, "x", "%ld", rec->x);
+ xml_entry(xs, "y", "%ld", rec->y);
+ xml_end_tag(xs, "e");
+ }
+
+ xml_end_tag(xs, "data");
+ xml_entry(xs, "sample-size", "%ld", data->size);
+ xml_entry(xs, "minx", "%ld", minx);
+ xml_entry(xs, "maxx", "%ld", maxx);
+ xml_entry(xs, "miny", "%ld", miny);
+ xml_entry(xs, "maxy", "%ld", maxy);
+
+ return 0;
+}
+#endif
--
1.5.5.GIT
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list