Re: Help in using gsapi_set_stdio() to capture stdout into a memory buffer
Ken Sharp <[email protected]>
| Newsgroups | gmane.comp.printing.ghostscript.devel |
|---|---|
| Message-ID | <[email protected]> |
At 15:56 24/03/2016 +0000, Joaquim Luis wrote:
>Thanks for the binary remainder (confess I hadn't thought on it) but the
>gsapi_run_string() example, taken from the API.html doc page, is being
>used as a test case.
You haven't actually supplied us with what I think is your example file
'V:/lili.ps', (actually no, that's in one of the #if 0 sections....) or
indeed any example, so its pretty hard to comment on it.
I don't think you've mentioned which version of Ghostscript you are using,
nor on which platform (though I assume Windows).
You haven't given us the output sent to PostScript stdout either, there can
be valuable information there.
We really need all the above.
The plethora of #if 0 #ifdef I_AM_MAIN and so on along with different
behaviour based on the number of arguments make it pretty near impossible
for me to read the code quickly. I appreciate that it makes it easier for
you to run tests but its confusing.
If you want us to be able to run the code, supply a zipped up project,
rather than a single C file, and give us something which goes wrong. And
make sure you give us everything we need to reproduce the problem. You can
omit the GS DLL, we have that.....
> If I can't make it run well than no good to go into
>more elaborated cases. And if I can't find out why a from-a-dll-call sends
>me into an ioerror than I'm at a dead end already.
ioerror just means there was a problem with I/O, could be anything. Without
having your test file we can't possibly comment.
But, at the very least, a file with a NULL (0x0) in it will cause premature
string termination (because you haven't used run_string_with_length) as
Chris pointed out. Seems to me it would be trivial to change your test file
to use that.
The 'run_string' API call needs the whole file in a single string, and
since it uses strlen, the string must not contain NULL bytes. Ths, plus the
memory usage, are good reasons not to use this call, its mainly there for
simple stuff like "(file.ps) run"
In passing I notice that neither Chris nor I have asked you to confirm that
you are aware of the licencing of Ghostscript. You need to be aware of the
terms of the AGPL, which is the current Ghopstscript licence for free users.
Ken