- if (cairo_surface_write_to_png(im->surface, im->graphfile) !=
- CAIRO_STATUS_SUCCESS) {
- rrd_set_error("Could not save png to '%s'", im->graphfile);
- return 1;
- }
+ {
+ cairo_status_t status;
+
+ if (strcmp(im->graphfile, "-") == 0) {
+ status = cairo_surface_write_to_png_stream(im->surface, &cairo_write_func_file, (void*)stdout);
+ } else {
+ status = cairo_surface_write_to_png(im->surface, im->graphfile);
+ }
+
+ if (status != CAIRO_STATUS_SUCCESS) {
+ rrd_set_error("Could not save png to '%s'", im->graphfile);
+ return 1;
+ }
+ }