<DIV>Hi I am using ECL ffi to call a C function "chelper.c" which should output some data into an ECL list "my-list". I want to return the values of the c function directly into ECL but now I can't, I am having to pass thru an external file "out.txt". Is there a way to pass the values of the C function directly into ECL list without an intermediate writing to an external file first? Thanks. The example files are below:</DIV>
<DIV>;;;;;;;;;<BR>chelper.c<BR>;;;;;;;;<BR>#include <stdio.h> <BR>FILE *f1;<BR>int outfn(void)<BR>{<BR> int n;<BR> f1 = fopen ("c:/out.txt", "wt");<BR> for (n = 0; n<20; ++n)<BR> {<BR> printf ("%d\n",n);<BR> fprintf (f1, "%d\n", n);<BR> }<BR> fclose (f1);<BR>} </DIV>
<DIV>;;;;;;::<BR>test.lisp<BR>;;;;;;;;<BR>(defun my-run (x)<BR>(ffi:clines "#include <c:/chelper.c>")<BR> (ffi:c-inline(x) (:int) :int "outfn()" :one-liner t))<BR>;;(compile-file "c:/test.lisp")<BR>;;(load "c:/test.fas")<BR>(my-run nil)<BR>(with-open-file (stream "c:/out.txt" :direction :input)<BR> (setq my-list (loop for input = (read stream nil stream)<BR> until (eq input stream) collect input))) <BR>my-list<BR></DIV><BR>
--
<div> Be Yourself @ mail.com!<br>
Choose From 200+ Email Addresses<br>
Get a <b>Free</b> Account at <a href="http://www.mail.com/Product.aspx" target="_blank">www.mail.com</a>!</div>