Re: Help in using gsapi_set_stdio() to capture stdout into a memory buffer
Chris Liddell <[email protected]>
| Newsgroups | gmane.comp.printing.ghostscript.devel |
|---|---|
| Message-ID | <CAGy8pWp7RKpTLaqxMZz0s0asjoSbszmKy7xtk3t96f4GqjxRdA@mail.gmail.com> |
It's just been pointed out to me that -12 is actually ioerror, but the rest of my reply stands..... and, actually, ioerror makes more sense. Chris On 24 March 2016 at 13:33, Chris Liddell <[email protected]> wrote: > If you look in base/gserrors.h, you'll see that -12 is a limitcheck error, > > But, firstly, gsapi_run_string() is a really bad idea for anything > other than a basic string, because Postscript can contain binary data > (and in fact, Postscript itself can be binary encoded), so it will > fool functions like strlen() which we use in that API call. > > So, *maybe* gsapi_run_string_with_length() would work. > > Personally, I would use gsapi_run_string_continue() in loop, passing > in buffers of data - probably keep to about 4k buffer size, that way > your not going to hit any other string length limits that might still > be in there. > > Chris > > > > > On 24 March 2016 at 06:18, Joaquim Luis <[email protected]> wrote: >> Hi again. I'm afraid I have to get back to this because I got stuck in a >> mystery. >> The attached code, sorry for the #ifdefs mess used for debugging, works when >> compiled as a standalone program (use the -DI_AM_MAIN pre-processor flag). >> It works only with small files where we can just do >> >> gs_rasterize ps_file.ps >> >> However, if I built it as a dll and send as argument the postscript code as >> a string, which will be called either from Matlab or Julia, than the call >> >> gsapi_run_string (GSinst, ps, 0, &GSexitCode) >> >> returns an error code GSexitCode = -12 >> >> I confirmed that the problem is not in the PS in memory with the code chunk >> under the #if 0. That is, that piece of code runs well from the stand-alone >> but fails when run from a dll. >> >> I'm completely clueless with this. Can it be because gs tries to do >> something that it has not right to do when controlled by another process >> (the one that calls the dll)? >> >> Thanks again >> >> Joaquim >> >> >>> At 16:17 17/03/2016 +0000, Joaquim Luis wrote: >>> >>> >>>> NOTE: the code file is attached, as it was in my first message. >>> >>> >>> I'm afraid (for me) your email ended up in a Google spam folder and I had >>> to dig it out manually. Somewhere in there the code obviously fell off, >>> apologies for that. >>> >>> >>> Ken >> >> >> _______________________________________________ >> gs-devel mailing list >> [email protected] >> http://ghostscript.com/cgi-bin/mailman/listinfo/gs-devel