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:
#include <stdio.h>
FILE *f1;
int outfn(void)
  int n;
  f1 = fopen ("c:/out.txt", "wt");
  for (n = 0; n<20; ++n)
      printf ("%d\n",n);
      fprintf (f1, "%d\n", n);
  fclose (f1);
(defun my-run (x)
(ffi:clines "#include <c:/chelper.c>")
  (ffi:c-inline(x) (:int)  :int "outfn()" :one-liner t))
;;(compile-file "c:/test.lisp")
;;(load "c:/test.fas")
(my-run nil)
(with-open-file (stream "c:/out.txt" :direction :input)
    (setq my-list (loop for input = (read stream nil stream)
          until (eq input stream) collect input)))

Be Yourself @ mail.com!
Choose From 200+ Email Addresses
Get a Free Account at www.mail.com!