mie: select: add filename parameter to graphviz dump function

This commit is contained in:
2025-11-15 22:34:16 +00:00
parent 5bf893651e
commit b1bab9ce29
2 changed files with 9 additions and 6 deletions

View File

@@ -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

View File

@@ -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, "<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, "<unknown-value:%d>", 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);
}