scsh-0.6/scsh/libscsh.c

56 lines
1.1 KiB
C
Raw Normal View History

2002-05-16 10:50:46 -04:00
/* This file is part of scsh.
* Copyright (c) 2002 by Martin Gasbichler and Richard Kelsey. See file COPYING.
*/
#include <stdarg.h>
#include <stdio.h>
#include "scheme48.h"
#include "libscsh.h"
#include "sysdep.h"
2002-05-16 10:50:46 -04:00
s48_value s48_command_binding;
s48_value s48_to_string_binding;
s48_value s48_command (char* fmt, ...)
{
va_list ap;
va_start (ap, fmt);
return s48_vcommand (fmt, ap);
}
s48_value s48_vcommand (char* fmt, va_list ap)
{
char* command;
s48_value ret;
#ifdef HAVE_VASPRINTF
if (vasprintf(&command, fmt, ap) == -1){
fprintf(stderr, "error in vasprintf\n");
exit(1);
}
#else
command = (char *)calloc (1000, sizeof (char));
if (vsprintf(command, fmt, ap) == -1){
fprintf(stderr, "error in vsprintf\n");
exit(1);
}
#endif
2002-05-16 10:50:46 -04:00
fprintf (stderr,"The command is: %s\n", command);
S48_SHARED_BINDING_CHECK (s48_command_binding);
2002-05-16 10:50:46 -04:00
ret = s48_call_scheme (S48_SHARED_BINDING_REF (s48_command_binding),
1,
s48_enter_string (command));
2002-05-16 10:50:46 -04:00
free (command);
va_end (ap);
return ret;
}
s48_value s48_init_libscsh(void)
{
s48_command_binding = s48_get_imported_binding ("s48-command");
return S48_UNSPECIFIC;
}