[getdns-api] Questions and Suggestions After Implementing PHP Language Bindings

Hollenbeck, Scott shollenbeck at verisign.com
Wed Mar 11 12:44:07 CET 2015


I've been experimenting with an effort to develop PHP language bindings for getdns. After exploring swig [1] and ultimately deciding to abandon it, I managed to get something working using the Zend engine. In the near future I hope to share the results. For the most part I found everything easy to understand and implement once I got more familiar with Zend. So far I've only found two things that tripped me up a little. So, I have a few questions and suggestions based on my implementation experience:

The callback function used with the async functions like getdns_address() includes a "void *userarg" parameter. The callback function used with getdns_context_set_context_update_callback() doesn't include a "void *userarg" parameter - why?

I found that parameter very useful. To make the PHP bindings work I need to pass the name of a callback function in PHP user space to the C code that wraps the async functions, and from there to the internal callback function that I use to call the callback function in PHP user space. It's easy to do when I can include the string that represents the PHP function name in a structure whose address gets passed with *userarg from wrapped function to internal callback. Without userarg in getdns_context_set_context_update_callback() I'm temporarily using a hard-coded PHP function name because there's no easy way get the string representing the name of a user-supplied function to the internal callback. Would it be possible to add a "void *userarg" to the list of arguments for the callback function?

The getdns_strerror() function requires the caller to allocate a buffer into which a character string will be written. The caller has no idea how long the longest returned string might be, though, so I had to pick some arbitrarily large value in the hope that it would be large enough. Would it be possible to either return a string with the expectation that the caller will be responsible for freeing it, or can a constant be defined to identify the largest buffer needed?

Scott

[1] http://getdnsapi.net/pipermail/users/2015-February/000010.html

_______________________________________________
getdns-api mailing list
getdns-api at vpnc.org



More information about the spec mailing list