Skip to content

Instantly share code, notes, and snippets.

@iratqq
Created November 2, 2010 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iratqq/659783 to your computer and use it in GitHub Desktop.
Save iratqq/659783 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
#include <ecl/ecl.h>
size_t
sexp_to_str(char *dest, size_t len, char *fmt, const char *exp)
{
cl_object exp_ = c_string_to_object(exp);
cl_object fmt_;
fmt_ = cl_format(3, Cnil, make_constant_base_string(fmt), exp_);
return strlcpy(dest, ecl_base_string_pointer_safe(fmt_), len);
}
int
main(int argc, char *argv[])
{
char buf[256];
cl_boot(argc, argv);
sexp_to_str(buf, sizeof(buf), "hello ~a~%", "(1 2 3)");
printf("%s", buf);
cl_shutdown();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment