#include <stdarg.h>
#include <stdint.h>
+#include <stdio.h>
typedef enum {
JV_KIND_INVALID,
int jv_get_refcnt(jv);
enum { JV_PRINT_PRETTY = 1, JV_PRINT_ASCII = 2, JV_PRINT_COLOUR = 4, JV_PRINT_SORTED = 8, JV_PRINT_UNBUFFERED = 16 };
+void jv_dumpf(jv, FILE *f, int flags);
void jv_dump(jv, int flags);
+void jv_show(jv, int flags);
jv jv_dump_string(jv, int flags);
jv jv_parse(const char* string);
}
}
-void jv_dump(jv x, int flags) {
+void jv_dumpf(jv x, FILE *f, int flags) {
struct dtoa_context C;
jvp_dtoa_context_init(&C);
- jv_dump_term(&C, x, flags, 0, stdout, 0);
+ jv_dump_term(&C, x, flags, 0, f, 0);
jvp_dtoa_context_free(&C);
if (flags & JV_PRINT_UNBUFFERED) {
- fflush(stdout);
+ fflush(f);
}
}
+void jv_dump(jv x, int flags) {
+ jv_dumpf(x, stdout, flags);
+}
+
+void jv_show(jv x, int flags) {
+ if (flags == -1)
+ flags = JV_PRINT_PRETTY | JV_PRINT_COLOUR | JV_PRINT_UNBUFFERED;
+ jv_dumpf(jv_copy(x), stderr, flags);
+}
+
jv jv_dump_string(jv x, int flags) {
struct dtoa_context C;
jvp_dtoa_context_init(&C);