pw-dot: using output - will write the output to stdout

This enables single-liners for viewing the graph in applicable shells.
This commit is contained in:
Erkki Seppälä 2021-04-02 11:33:19 +03:00
parent 4a0b7fa9b8
commit 21a36f3c51
2 changed files with 15 additions and 10 deletions

View file

@ -55,7 +55,7 @@ This file is part of PipeWire.
<option>
<p><opt>-o FILE | --output</opt><arg>=FILE</arg></p>
<optdesc><p>Output file name (Default pw.dot).</p></optdesc>
<optdesc><p>Output file name (Default pw.dot). Use - for stdout.</p></optdesc>
</option>
</options>

View file

@ -493,6 +493,10 @@ static int draw_graph(struct data *d, const char *path)
/* draw the footer */
dot_str_add(&d->dot_str, "}\n");
if (strcmp(path, "-") == 0) {
/* wire the dot graph into to stdout */
fputs(d->dot_str, stdout);
} else {
/* open the file */
fp = fopen(path, "w");
if (fp == NULL) {
@ -503,6 +507,7 @@ static int draw_graph(struct data *d, const char *path)
/* wire the dot graph into the file */
fputs(d->dot_str, fp);
fclose(fp);
}
return 0;
}