From b1bab9ce29e13742214dc8d79fbd17b6c007d151 Mon Sep 17 00:00:00 2001 From: Max Wash Date: Sat, 15 Nov 2025 22:34:16 +0000 Subject: [PATCH] mie: select: add filename parameter to graphviz dump function --- mie/include/mie/select/graph.h | 3 ++- mie/select/dump.c | 12 +++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/mie/include/mie/select/graph.h b/mie/include/mie/select/graph.h index 7e1c25e..b514b61 100644 --- a/mie/include/mie/select/graph.h +++ b/mie/include/mie/select/graph.h @@ -43,6 +43,7 @@ MIE_API enum mie_status mie_select_graph_get_node( struct mie_type **values, size_t nr_values, struct mie_select_node **out); MIE_API void mie_select_graph_dump_text(struct mie_select_graph *graph); -MIE_API void mie_select_graph_dump_dot(struct mie_select_graph *graph); +MIE_API void mie_select_graph_dump_dot( + struct mie_select_graph *graph, const char *filename); #endif diff --git a/mie/select/dump.c b/mie/select/dump.c index 7a2d801..721d24c 100644 --- a/mie/select/dump.c +++ b/mie/select/dump.c @@ -54,7 +54,7 @@ static b_status write_operand_const(struct mie_value *value, b_stream *out) static void write_operand(struct mie_value *value, b_stream *out) { if (!value) { - b_stream_write_fmt(out, NULL, ""); + b_stream_write_fmt(out, NULL, "null"); return; } @@ -73,7 +73,7 @@ static void write_operand(struct mie_value *value, b_stream *out) break; default: b_stream_write_fmt( - out, NULL, "", value->v_type->t_id); + out, NULL, "unknown-value:%d", value->v_type->t_id); break; } } @@ -254,9 +254,9 @@ void mie_select_graph_dump_text(struct mie_select_graph *graph) } } -void mie_select_graph_dump_dot(struct mie_select_graph *graph) +void mie_select_graph_dump_dot(struct mie_select_graph *graph, const char *filename) { - FILE *fp = fopen("graph.dot", "w"); + FILE *fp = fopen(filename, "w"); b_stream *tmpstream = b_stream_open_fp(fp); @@ -284,7 +284,9 @@ void mie_select_graph_dump_dot(struct mie_select_graph *graph) b_stream_unref(tmpstream); - system("open graph.dot"); + char cmd[256]; + snprintf(cmd, sizeof cmd, "open %s", filename); + system(cmd); fclose(fp); }