[gambit-list] MySQL FFI (Version 0.2 ready), FFI questions: strings not terminated with null, passed in strings

Jonathan Arkell jonnay at jonnay.net
Sat Aug 19 16:34:04 EDT 2006


Okay, I know it was only last week, but I have a new version of the
MySQL FFI ready for testing.  As soon as a Gambit module system is in
place, I will totally be making this a module.

There are much improvements made here.  There are a few more higher
level functions (mysql-map-rows, mysql-map-fields, get-mysql-datum,
mysql-row->list, mysql-column->list, mysql-result->alist,
mysql-result->list) and better testing and error recovery.

I have also commented the source a lot more, licensed it under the
Apache 2.0 license.

As Usual, play with it, make suggestions, comments bug reports, etc.

Blog entry about it (including personal motivations for writing it! Wow!):
http://blog.jonnay.net/archives/744-More-Gambit-MySQL-Mana-From-Heaven,-due-to-Windmill-Charging..html

Link to Download:
http://blog.jonnay.net/index.php?serendipity[subpage]=downloadmanager&thiscat=2&file=5

I also have a few questions regarding how the C functions handle strings
with null values and how they handle references, The C Function
mysql_real_escape_string is defined like this:

unsigned long mysql_real_escape_string(MYSQL *mysql, char *to,const char
*from, unsigned long length);

"to" is the variable where the result of mysql_real_escape_string is
stored, "from" is the string to escape which may contain null bytes, and
length is the length of "from".

If I define my c-lambda in similar terms, will the string I pass in be
properly mutated?  Or will I have to build a wrapper function that will
return the "to" string instead? (which might be the better option anyway)

Also, what happens when I have a Scheme string that contains a null
character, and I pass it into a c-function?  Will the passed in string
be terminated at the first null byte?  If so, how do I get around this?

Thanks in Advance!
-- 

  ,-------.      The Cute Grim Floating Skull of Hello Cthulu Says
 /  |   |  \
/  _  ^  _  \    Listen To Crazy Shaman Techno
\_/ }|||{ \_/             http://www.jonnay.net
    '^"^`                                              I'm Jonnay!





More information about the Gambit-list mailing list