Re: Help in using gsapi_set_stdio() to capture stdout into a memory buffer
"Joaquim Luis" <[email protected]>
| Newsgroups | gmane.comp.printing.ghostscript.devel |
|---|---|
| Organization | UALG |
| Message-ID | <op.yeuk4ac6dbaoe8@macmarilu> |
Ken, I hadn't send a full working example because to reproduce it would be necessary to install the GMT (http://gmt.soest.hawaii.edu) trunk version, plus a MEX wrapper to call it from Matlab or alternatively install Julia plus a package to call GMT from it. A complicated procedure. So I tried to create a simple stand-alone case to provide but, surprise. It works too. So, the only case it doesn't work is when the code is called from within Matlab. Since it relies on creating a pipe to stdin and stdout I am guessing that Matlab is getting in the way and that is what is causing the ioerror. I still can send you the code if you want, but it won't serve for nothing as it works well. Again, I'm not paying to much attention to the issues you kindly point me about the 'run_string' API because I would need that the simple case worked first. Regarding the License issue, yes we are aware that Ghostscript is AGPL (actually we thought it was still GPL but it makes no big difference). Joaquim > 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