Lines 250-260
bitmap_from_gs(file, filetype, pic, urx,
Link Here
|
250 |
int urx, llx, ury, lly; |
250 |
int urx, llx, ury, lly; |
251 |
int pdf_flag; |
251 |
int pdf_flag; |
252 |
{ |
252 |
{ |
253 |
static tempseq = 0; |
|
|
254 |
char buf[300]; |
253 |
char buf[300]; |
255 |
FILE *tmpfp, *pixfile, *gsfile; |
254 |
FILE *tmpfp, *pixfile, *gsfile; |
256 |
char *psnam, *driver; |
255 |
char *psnam, *driver; |
257 |
int status, wid, ht, nbitmap; |
256 |
int status, wid, ht, nbitmap, fd; |
258 |
char tmpfile[PATH_MAX], |
257 |
char tmpfile[PATH_MAX], |
259 |
pixnam[PATH_MAX], |
258 |
pixnam[PATH_MAX], |
260 |
errnam[PATH_MAX], |
259 |
errnam[PATH_MAX], |
Lines 270-277
bitmap_from_gs(file, filetype, pic, urx,
Link Here
|
270 |
/* re-open the pipe */ |
269 |
/* re-open the pipe */ |
271 |
close_picfile(file, filetype); |
270 |
close_picfile(file, filetype); |
272 |
file = open_picfile(tmpfile, &filetype, PIPEOK, pixnam); |
271 |
file = open_picfile(tmpfile, &filetype, PIPEOK, pixnam); |
273 |
sprintf(tmpfile, "%s/%s%06d", TMPDIR, "xfig-eps", getpid()); |
272 |
snprintf(tmpfile, sizeof(tmpfile), "%s/xfig-eps.XXXXXX", TMPDIR); |
274 |
if ((tmpfp = fopen(tmpfile, "wb")) == NULL) { |
273 |
if ((fd = mkstemp(tmpfile)) == -1 || (tmpfp = fdopen(fd, "wb")) == NULL) { |
|
|
274 |
if (fd != -1) { |
275 |
unlink(tmpfile); |
276 |
close(fd); |
277 |
} |
275 |
file_msg("Couldn't open tmp file %s, %s", tmpfile, strerror(errno)); |
278 |
file_msg("Couldn't open tmp file %s, %s", tmpfile, strerror(errno)); |
276 |
return False; |
279 |
return False; |
277 |
} |
280 |
} |
Lines 280-289
bitmap_from_gs(file, filetype, pic, urx,
Link Here
|
280 |
fclose(tmpfp); |
283 |
fclose(tmpfp); |
281 |
} |
284 |
} |
282 |
/* make name /TMPDIR/xfig-pic######.pix */ |
285 |
/* make name /TMPDIR/xfig-pic######.pix */ |
283 |
sprintf(pixnam, "%s/%s%06d.pix", TMPDIR, "xfig-pic", tempseq); |
286 |
snprintf(pixnam, sizeof(pixnam), "%s/xfig-pic.XXXXXX", TMPDIR); |
|
|
287 |
if ((fd = mkstemp(pixnam)) == -1) { |
288 |
file_msg("Couldn't open tmp file %s, %s", pixnam, strerror(errno)); |
289 |
return False; |
290 |
} |
291 |
close(fd); |
292 |
|
284 |
/* and file name for any error messages from gs */ |
293 |
/* and file name for any error messages from gs */ |
285 |
sprintf(errnam, "%s/%s%06d.err", TMPDIR, "xfig-pic", tempseq); |
294 |
snprintf(errnam, sizeof(errnam), "%s/xfig-picerr.XXXXXX", TMPDIR); |
286 |
tempseq++; |
295 |
if ((fd = mkstemp(errnam)) == -1) { |
|
|
296 |
file_msg("Couldn't open tmp file %s, %s", errnam, strerror(errno)); |
297 |
return False; |
298 |
} |
299 |
close(fd); |
287 |
|
300 |
|
288 |
/* generate gs command line */ |
301 |
/* generate gs command line */ |
289 |
/* for monochrome, use pbm */ |
302 |
/* for monochrome, use pbm */ |