On 5/19/07, Dan Muresan <[EMAIL PROTECTED]> wrote:
Well, I was in a rush, so I've wrapped strftime(). This might actually be useful to others, so I'm posting it. I've used SWIG, but I'm sure it's trivial using the Chicken FFI (which I don't know though):
You could do it like this, though it probably doesn't save much: (define system-time (foreign-lambda* c-string* ((c-string fmt)) #<<EOF char *res; time_t t; struct tm tm; time (& t); localtime_r (& t, & tm); char buf [500]; size_t ret = strftime (buf, sizeof (buf), fmt, &tm); if (ret == 0) res = NULL; else { res = malloc (ret + 1); memcpy (res, buf, ret + 1); } return (res); EOF )) The c-string* return-form will free the result-buffer after copying to a Scheme string. The return value must be parenthesized, not sure why exactly. G _______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users