December 2005


Uhm, writing scsh bindings for GPGME is a bit more work than I thought. Creating contexts and buffers works, I can copy data into a GPG buffer and read for it and even get keys from Scheme. Encrypting doesn’t work yet for some (at the moment) unknown reason.

Dealing with passwords is a bit hairy. GPGME expects the programmer to install a callback function that will be called whenever a password is needed. Among the tons of arguments for the callback there is a file descriptor. GPGME expects the callback to write the password to this file descriptor. Well, that’s probably nice for C programmers, but poses some problems for my bindings. Installing a callback that calls a Scheme function is not an option, because the callback may happen at any point in time which is not what the Scheme48 VM expects. It’s possible to call back into Scheme if the VM called a C function and that function is still running. Calling a Scheme function at an arbitrary point in time results in all kinds of weird things happening. (That’s also the reason why the Qt and Cocoa bindings use an extra GUI interrupt to notify the VM that it needs to call a Scheme callback function instead of calling the interrupt directly)

The best idea for solving this problem I had so far (partially working): Attach two pipes to each GPGME context and install a fake C callback function. The pipes connect the callback function to a Scheme thread. The fake callback function will write to the pipe when GPGME calls it. This wakes up the Scheme thread reading from the pipe. The thread than calls the real callback function written in Scheme which returns the password. Using the second pipe the thread sends the password back to the fake C callback which writes the password to the file descriptor given by GPGME and returns.

I really appreciate the fact that the GPGME developers allow to pass one opaque argument (from GPGME’s point of view) to each instance of the callback. This way I can pass a pointer to GPGME context to the C callback any identify the the correspondig Scheme record in the C callback function. I keep a global list of all Scheme records representing contexts and search for the record that represents the GPGME context struct. The record also stores the file descriptors of the pipes and that is what the callback function needs. I haven’t figured if I have to synchronize the access to that list of records yet. Might be a good idea, however. ;-)

Well, there are more things to figure out. E. g., what’s the best way to access the arguments of the C callback function from Scheme? Doing something that may trigger a GC is beyond question. Perhaps copying the arguments into a heap allocated structure and sending the address via the pipe would be an option. Well, that sound like a nice hack. ;-) Maybe serializing the data is also an option.

Next, up: Look at GPGME support for external event loops. In fact the code in tests/gpgme/t-eventloop.c seems to demonstrate exactly what I have to do.

Technorati Tags: , , ,

Some things I wished for, but Santa Claus didn’t bring:

  • a “reverse” Aqua-X11-client application for OS X that allows me to put Aqua windows inside an ion frame of an ion window manager running on XDarwin
  • an application that turns the SMS of my mobile phone into an IMAP mailbox
  • an easy to extend general interrupt mechanism for scsh that allows C code to signal the VM that there is some work to do

Technorati Tags:

The past two weeks, I talked about SUnet SUrflets in my lecture on programming web applications. Explaining call/cc, was as expected, hard. I could not resist to mention with-inspecting-error-handler and praise the excellent debugging facilities for SUrflets (see here).

Well, as for the basis of send/suspend, I hope that I managed to make clear what call/cc does. The problem is, that I won’t get feedback on this subject: The current problem set is about PHP and the next problem set (”programming with SUrflets”) will be handed out mid january. The implementation of send/suspend is quite interesting and I wish I hade more time to spend on this. Next time I’m going to give this lecture, I would like to show a minimalist web-server written in Scheme featuring send/suspend. Maybe that’s also a nice excercise for a problem set? Having such a tight shedule for the lecture is a bit annoying, when it comes to really interesting topics… Well, next up: XML and XSLT, JavaScript, and AJAX. Hm, I wonder if I can come up with an example where SUrflets work nicely in an AJAX like web application?

Technorati Tags: , ,

Recently, I have started to put some scsh bindings for GPGME together. GPGME is a C library, that allows applications to use GnuPG to encrypt, decrypt, and verify data. I’m using GnuPG in conjunction with Gnus and I’m pretty annoyed that since the introduction of the code for encrypting/decrypting mail messages the feature that replaces the encrypted message with the plain message in mailbox went away. An archive containing encrypted messages is useless: the only reason (for me) to have an archive for mails is to search (i.e., grep) it! Well, now I have to use mutt to decrypt the mails.

Well, using the GPGME bindings I could write a scsh script for that easily. Will do. Soon. However, this application of the GPGME bindings is merely a welcome side-effect. Actually, I started writing these bindings in preparation for a term project: One of my students is writing an IRC client library and an IRC client application for SUnet. The cool thing about this client will be, that is supports talking to the channel in an encrypted faishon using GnuPG (Martin’s idea). I know that there are some projects that are about the same, however they seem to use SSL.

Technorati Tags: , , ,

Some months ago I wrote about the Qt bindings for Scheme 48 and mentioned that I’m writing a small Scheme program that generates the stub files for the FFI automatically from the Qt headers. I just noticed that my last check-in for this project dates back to 4th may. Sigh. Yet another unfinished project… (Here is the darcs repository)

If I recall correctly, the code already reads the Qt header files and generates some stubs. However, it doesn’t generate stubs for the overloaded operators yet. The code for reading the C++ header files is based on Chicken’s easyffi code—that was an extremly bad idea. The code was already hairy and got even more hairy after I “fixed” the code to read Qt header files. I’m quite sure that I don’t have time to complete this stuff. Maybe I can talk a student into hacking the rest?

Technorati Tags: , ,