On Fri, Dec 26, 2008 at 7:16 AM, troels knak-nielsen <span dir="ltr"><<a href="mailto:troelskn@gmail.com">troelskn@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I had a similar problem a few months back. Have a look over here:<br>
<a href="http://stackoverflow.com/questions/105816/how-do-i-access-a-char-through-ffi-in-plt-scheme" target="_blank">http://stackoverflow.com/questions/105816/how-do-i-access-a-char-through-ffi-in-plt-scheme</a></blockquote>
<div><br>Figures, the exact question I was asking was already asked - typical.<br><br>The answer doesn't really make sense to me. But, it gives me a place to start, and I'll mull it over from there.<br><br>Oh - and I have the same goals you had when you were working on the code mentioned in the above post. It's all about learning FFI...<br>
<br>Thanks,<br>Ben<br><br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<br>
--<br>
troels<br>
<div><div></div><div class="Wj3C7c"><br>
On Fri, Dec 26, 2008 at 12:44 AM, Ben Simon <<a href="mailto:benjisimon@gmail.com">benjisimon@gmail.com</a>> wrote:<br>
> Howdy -<br>
><br>
> Now that my MySQL FFI implementation doesn't crash every few moments, I've<br>
> been able to make some headway into making the API useful. This has been<br>
> going well, until I hit the row handling MySQL requires. Here's the C<br>
> example they provide:<br>
><br>
><br>
> MYSQL_ROW row;<br>
> unsigned int num_fields;<br>
> unsigned int i;<br>
><br>
> num_fields = mysql_num_fields(result);<br>
> while ((row = mysql_fetch_row(result)))<br>
> {<br>
> unsigned long *lengths;<br>
> lengths = mysql_fetch_lengths(result);<br>
> for(i = 0; i < num_fields; i++)<br>
> {<br>
> printf("[%.*s] ", (int) lengths[i],<br>
> row[i] ? row[i] : "NULL");<br>
> }<br>
> printf("\n");<br>
> }<br>
><br>
> Apparently, when I call mysql_fetch_row(...) it will return back a big array<br>
> of character data that is the series of columns. I can index into this<br>
> array by calling mysql_num_fields and mysql_fetch_lengths.<br>
><br>
> mysql_fetch_lengths returns back an array of numbers, while the row object<br>
> is essentially an array.<br>
><br>
> Given this, I think I need to focus on how Scheme handles C arrays. What's<br>
> the cleanest way to handle this? I've found some discussion about<br>
> cvectors, is that I'm looking for?<br>
><br>
> Thanks,<br>
> -Ben<br>
><br>
> --<br>
> Have an idea for software? I can make it happen -<br>
> <a href="http://www.ideas2executables.com" target="_blank">http://www.ideas2executables.com</a><br>
> My Blog: <a href="http://benjisimon.blogspot.com" target="_blank">http://benjisimon.blogspot.com</a><br>
><br>
</div></div>> _________________________________________________<br>
> For list-related administrative tasks:<br>
> <a href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme" target="_blank">http://list.cs.brown.edu/mailman/listinfo/plt-scheme</a><br>
><br>
><br>
</blockquote></div><br><br clear="all"><br>-- <br>Have an idea for software? I can make it happen - <a href="http://www.ideas2executables.com">http://www.ideas2executables.com</a><br>My Blog: <a href="http://benjisimon.blogspot.com">http://benjisimon.blogspot.com</a><br>