Hello,
I'm trying to provide scheme access to a C function which has the same
interface a printf(). What I'd like to do in scheme is something like
(gschem-log
"This is a %s message with %d args, pi is %g\n"
"log"
3
3.14
)
so I've gotten as far as a function which takes a variable number of
arguments and made it available from scheme but can't seem to figure out
the last step which is how to get the elements from the :
SCM g_funcs_log(SCM s_num_list)
{
SCM s_element;
int length;
int i;
/* Check that the input is a list */
SCM_ASSERT (SCM_NFALSEP (scm_list_p (s_num_list)),
s_num_list,
SCM_ARG1,
"gschem-log");
length = scm_num2int(scm_length(s_num_list), 0, "g_funcs_log()");
if (length == 0)
return SCM_BOOL_T;
/* how to actully feed the data to s_log_message which
* has a printf-like interface
*/
s_log_message ("Hi there. Length = %d\n", length);
return SCM_BOOL_T;
}
scm_c_define_gsubr ("gschem-log", 0, 0, 1, g_funcs_log);
If it would be easier I can also write a
void s_log_messagev (const char * restrict format, va_list ap);
to complement the
void s_log_message(const char * restrict format, ...);
I tried to find some sort of scm_list2_c_va_list() but haven't found it yet.
Any suggestions?
Thanks
-Dan
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user