job->output_file = prevjob->output_file; /* FIXME - this is dumb ! */
}
else {
+ if (gvrender_begin_job(job))
+ continue;
gvc->active_jobs = job; /* first job of new list */
- gvrender_begin_job(job);
}
job->next_active = NULL; /* terminate active list */
job->callbacks = &gvdevice_callbacks;
extern usershape_t *gvusershape_find(char *name);
/* device */
- extern void gvdevice_initialize(GVJ_t * job);
+ extern int gvdevice_initialize(GVJ_t * job);
extern void gvdevice_format(GVJ_t * job);
extern void gvdevice_finalize(GVJ_t * job);
extern pointf gvrender_ptf(GVJ_t *job, pointf p);
extern pointf* gvrender_ptf_A(GVJ_t *job, pointf *af, pointf *AF, int n);
- extern void gvrender_begin_job(GVJ_t * job);
+ extern int gvrender_begin_job(GVJ_t * job);
extern void gvrender_end_job(GVJ_t * job);
extern int gvrender_select(GVJ_t * job, const char *lang);
extern int gvrender_features(GVJ_t * job);
#include <stdlib.h>
#include <string.h>
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
job->output_filename = buf;
}
-void gvdevice_initialize(GVJ_t * job)
+/* gvdevice_initialize:
+ * Return 0 on success, non-zero on failure
+ */
+int gvdevice_initialize(GVJ_t * job)
{
gvdevice_engine_t *gvde = job->device.engine;
GVC_t *gvc = job->gvc;
if (job->output_filename) {
job->output_file = fopen(job->output_filename, "w");
if (job->output_file == NULL) {
- perror(job->output_filename);
- exit(1);
+ (job->common->errorfn) ("Could not open \"%s\" for writing : %s\n",
+ job->output_filename, strerror(errno));
+ /* perror(job->output_filename); */
+ return(1);
}
}
else
if (deflateInit2(z, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -MAX_WBITS, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY) != Z_OK) {
(job->common->errorfn) ("Error initializing for deflation\n");
- exit(1);
+ return(1);
}
gvwrite_no_z(job, z_file_header, sizeof(z_file_header));
#else
(job->common->errorfn) ("No libz support.\n");
- exit(1);
+ return(1);
#endif
}
+ return 0;
}
size_t gvwrite (GVJ_t * job, const char *s, size_t len)
return features;
}
-void gvrender_begin_job(GVJ_t * job)
+/* gvrender_begin_job:
+ * Return 0 on success
+ */
+int gvrender_begin_job(GVJ_t * job)
{
gvrender_engine_t *gvre = job->render.engine;
- gvdevice_initialize(job);
+ if (gvdevice_initialize(job))
+ return 1;
if (gvre) {
if (gvre->begin_job)
gvre->begin_job(job);
}
+ return 0;
}
void gvrender_end_job(GVJ_t * job)