Loading database from string (C API)

Edd Barrett <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
Hi,

I am writing a VM which embeds SWI-prolog using the C interface (I am
actually calling the SWI C interface via Python-CFFI, but it is all the
same).

I need to be able to parse Prolog source code (in a C string) into the Prolog
database. Looking at the FFI documentation [1] I don't see an obvious way to do
this. I guess one way is to write the Prolog source code to a file and
construct a query to consult/1.

Maybe it is possible to write the code to a memory file and use load_file/2
to load from a stream, but that seems convoluted too.

Is there a better way?

Thanks

P.S. Typo in documentation:
"security riscs" -> "security risks"
http://www.swi-prolog.org/pldoc/man?section=memory-files

[1] http://www.swi-prolog.org/pldoc/man?section=foreign
-- 
Best Regards
Edd Barrett

http://www.theunixzoo.co.uk
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.