summaryrefslogtreecommitdiff
path: root/boilerplate
diff options
context:
space:
mode:
Diffstat (limited to 'boilerplate')
-rw-r--r--boilerplate/cairo-boilerplate.c11
-rw-r--r--boilerplate/cairo-boilerplate.h4
2 files changed, 11 insertions, 4 deletions
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 91abbe219..b4b492fc1 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -789,7 +789,8 @@ any2ppm_daemon_exists (void)
FILE *
cairo_boilerplate_open_any2ppm (const char *filename,
int page,
- unsigned int flags)
+ unsigned int flags,
+ int (**close_cb) (FILE *))
{
char command[4096];
#if HAS_DAEMON
@@ -824,10 +825,13 @@ cairo_boilerplate_open_any2ppm (const char *filename,
goto POPEN;
}
+ *close_cb = fclose;
return fdopen (sk, "r");
POPEN:
#endif
+
+ *close_cb = pclose;
sprintf (command, "./any2ppm %s %d", filename, page);
return popen (command, "r");
}
@@ -921,10 +925,11 @@ cairo_boilerplate_convert_to_image (const char *filename,
FILE *file;
unsigned int flags = 0;
cairo_surface_t *image;
+ int (*close_cb) (FILE *);
int ret;
RETRY:
- file = cairo_boilerplate_open_any2ppm (filename, page, flags);
+ file = cairo_boilerplate_open_any2ppm (filename, page, flags, &close_cb);
if (file == NULL) {
switch (errno) {
case ENOMEM:
@@ -935,7 +940,7 @@ cairo_boilerplate_convert_to_image (const char *filename,
}
image = cairo_boilerplate_image_surface_create_from_ppm_stream (file);
- ret = pclose (file);
+ ret = close_cb (file);
/* check for fatal errors from the interpreter */
if (ret) { /* any2pmm should never die... */
cairo_surface_destroy (image);
diff --git a/boilerplate/cairo-boilerplate.h b/boilerplate/cairo-boilerplate.h
index 061522193..b1a1f1cbd 100644
--- a/boilerplate/cairo-boilerplate.h
+++ b/boilerplate/cairo-boilerplate.h
@@ -218,7 +218,9 @@ enum {
FILE *
cairo_boilerplate_open_any2ppm (const char *filename,
int page,
- unsigned int flags);
+ unsigned int flags,
+ int (**close_cb) (FILE *));
+
cairo_surface_t *
cairo_boilerplate_image_surface_create_from_ppm_stream (FILE *file);