Hi,
I'm trying to call a C foreign function which uses command-line arguments...
; ;Isectd echo worker in Scheme ; (c-declare "#include "isdio.h"")
(define isdLogInit (c-lambda (int (pointer (pointer char)#f)) void "isdLogInit")) (isdLogInit (-(length (command-line))1) (command-line))
The FFI C function isdLogInit function is:
Xport void isdLogInit(int argc, char **argv) { int i; char isdLogFileName[1024];
sprintf(isdLogFileName, "/isect/logs/%s.log", argv[1]);
isdLogFile = fopen(isdLogFileName, "a"); if (isdLogFile == NULL) isdLogFile = stderr;
isdLog("\nSTARTING\n"); for (i = 0; i < argc; i++) isdLog("%s ", argv[i]); }
It compiles OK, but when I run it, I get the message (Argument 2) Can't convert to C pointer. That's because (command-line) is a list of strings. Seems I can't cast to the required char **argv using Scheme. How do I capture the command-line as the correct type. Sorry, if this is straightforward. I'm not an academic or a professional programmer, just an electrician who likes to play with things to see how they work. If I can understand Scheme then I might eventually be able to contribute to GnuCash which I use in my business every day.
Cheers,
Rob.