Older blog entries for gabe (starting at number 4)

Ok, I'm back. Moved into a new apartment, finally sold my iBook and got a Pismo. When I've got some money I'll upgrade it to a G4. I got an iMac G4 at the office to play with now too.

Got some good work done on my import code for SRM recently. I added an additional function to the SRM server, srm_user_function_list(), so that the import code won't have to pick the user defined functions out of the list returned by srm_function_list(). The import code, in general, works. Right now it's just hooked up to a simple handler function that just prints the name of the function that was called. Adding the entries to the executor's function_table works fine, and I've added a HashTable to the SRM PHP extension's thread-safe globals to keep track of the imported functions and which connection they were imported from.

I have to add code to the module initialization call to alloc and init the HashTable and then more code to the request shutdown and module shutdown calls to handle the removal of the imported functions from the executor's function table. Probably have a bit more stuff to clean up too. Then it will be ready to really test it.

I've been learning a bit about using GDB throughout my diddling with SRM. I have to say that it's neat. I've also been learning about trying to deal with the Zend Engine's memory management and such. It's nice that it informs you of memory leaks when it shuts down. (well, I'm just testing it with the CLI SAPI, I wonder what happens when you leak with the apache SAPI or others?)

I've also changed the import interface too. It now works like this:

$srm = new SRM('/tmp/srm.socket');

$srm->import_library(); // import all library functions

$srm->import_library("my_func"); // import function "my_func"

$srm->import_library(array("func1", "func2")); // import a few select functions

13 Jul 2002 (updated 13 Jul 2002 at 15:18 UTC) »
12 Jul 2002

Ok, so this is for last night, I wasn't able to connect to write...

So I finalized my ideas / proposal for a feature for SRM to be able to import library functions into the running script's function table. It turned out that the import function was the best method to use. Much thanks to Derick again, for answering all of my questions about the inner workings of SRM and PHP. So, I started working on adding this to the SRM extension. Basically, this is all there is to it from the PHP side:

$srm = new SRM('/tmp/srm.socket');

$srm->import_library(); // import functions // OR $srm->import_library(true); // import functions, and overwrite functions that may already exist

And that's pretty much all there is to it. I've got the code to handle the method call now, and I just have to clone and slightly modify the SRM class's method handler.

So some well spent time digging around in the xdebug PHP extension, and more consultation with Derick have lead me to look into the executor part of the Zend engine for where I can properly redirect function calls. I'm at odds know as to how to approach this though. It's probably easiest to just wrap the zend_execute() function call like xdebug does and check the function hash table to see if a function call exists or not. But I still keep thinking about the possibility of just providing a method in the SRM object to "import" the functions from the SRM library into the running PHP SRM client's function hash table and have a handler function to redirect those calls to SRM. There's also the possibility of merging both of those approaches into a wrapper for zend_execute() the "learns" about SRM functions by checking if they exist in SRM, and if they do, add them to the function hash and then the function call handler will take care of calling them. I guess it all depends on what makes the most sense - so I guess I'll poll the mailing list and see what folks think.

So we've now officially begun selling our product at work today - which means this is the first (real) job I've had with a company that has produced, marketed, and sold an actual product. This is also the longest I've been at any job, the most fun I've had, the most learning & maturing I've done, and overall the most positive work experience so far. All thanks to the wonders of open source software such as PHP, Apache, MySQL, etc.

Two weeks until we move into our new apartment. :)

Well, another round of massive changes to our site at work, combined with another random GTA3 binge, and apartment hunting have delayed me from having any damn space time lately. Excuses, excuses... sheesh.

So, I think I've indefinately put off the netinfo extension for PHP in favor of doing some work with SRM. At some point when I joined the php-qa mailing list earlier this year I inevitably ran across a link to SRM in Derick's signature. A while later I asked some questions on php-dev, somewhat related to app. server type functionality with PHP, and got another pointer to the SRM. So I finally decided to download it any play with it last week, and I think it's absolutely the best thing for PHP that I've seen in a while.

I've spent the past week tearing it apart on the inside, and with help from Derick, Dan, and Jani got it working on my iBook finally. I learned a bit about Apple's dyld linker in the process too. And Derick has been helpful answering my frequent barrages of questions about SRM, PHP/Zend, gdb, etc.

So, I've figured out a few things I'd like to do to help out SRM: first is that it needs a decent authentication system, second is that I'd like for there to be a way to call SRM library functions without having to call them as methods to an SRM class object. (makes for cleaner code that one can use with & without SRM).

I have to wait on the first task until Derick is finished with his new network protocol abstraction layer. (so SRM can process requests via its native socket interface, HTTP, XML-RPC/SOAP, etc.) At some point I'd like to create an SMTP plugin (mostly to see if I can get SRM to handle bounced emails and deactivate accounts, or note whom note to send messages to etc, in our system at work), but that's another story. I'd like to create a new authentication module for SRM that these protocol plugins can make use of so that users can setup which protocols are authenticated from where, etc. There was some mentioned on the mailing list about using SRM in a hosted environment... After much thought, I think the best idea would be to just run an instance for each user - let them set it up themselves if they want to run it.

On to the second task then... figuring out how to make PHP (as an SRM Client) pass function calls on to SRM instead of having to call them through the SRM object. Well, there's two ways to go about this that I can think of: create a Zend extension to pass off failed function calls to SRM, or to somehow have the SRM extension for PHP add SRM library functions to the PHP/Zend function table, and then handle those calls directly. I've only investigated the first idea so far, after much questioning of Derick and then other folks on #php.bugs (thanks Andrei, etc.), so that's what I've started playing with. Derick pointed me to his xdebug PHP extension as a place to investigate function call handlers for the Zend Engine - so that's where I've started. I've torn up the xdebug extension to learn more about ZE, and it's pretty damn cool. I'm hoping I'll have at least figured out how to handle task #2 (properly) by the end of the week.

15 days until we get to move into our new apartment in Newburyport, Ma. and I can actually get BANDWIDTH there! No more modem! I even get a choice between cable or dsl. How cool is that? We're actually saving a bit of money too, so I'm hoping I can get an eMac for home and then run that as a server on a DSL line and perhaps provide some space for Derick and other SRM folks to test/develop SRM in OSX. After that, I think I've finally decided to sell the iBook and get an older Pismo Powerbook G3 and get it upgraded to a G4. The only thing that makes it not as good as a TiBook is the graphics card - but I honestly don't ever play games in OSX anyways... so, it's the perfect fit, and cheap too!

4 May 2002 (updated 6 May 2002 at 20:52 UTC) »

After about two years I finally have access to my advogato account again. (Thanks Raph!) I created it back in 1999 or 2000 when I was living in California. Then I forgot my password at some point and well.. here I am.

I spent some time tracking down folks I know on advogato and certifying them as the lunatics they are.

I started some work on my NetInfo extension for PHP a few weeks ago. It took a while to track down the proper API to use because Mac OS X's documentation SUCKS! Thank goodness for Darwin. I got a pointer to check out the /usr/include/netinfo stuff and I stuck with that API. Someone had previously pointed me to the directory services API in OSX, which is a diseased beast that needs to be incinerated and never seen by anyone again.

So here's the API I've come up with for this NetInfo extension:

  • ni_open(domain [, user, pw [, host [, timeout]]])
  • *ni_close()
  • ni_resync(domain [, tries])
  • ni_statistics(domain)
  • ni_domainname(domain)
  • ni_rparent(domain)

  • ni_dir_create(conn, dir)
  • ni_dir_destroy(conn, dir)
  • *ni_dir_rename(conn, dir, new)
  • ni_dir_list(conn, dir)
  • ni_dir_properties(conn, dir)

  • ni_prop_rename(conn, dir, prop, new)
  • ni_prop_create(conn, dir, prop, value)
  • ni_prop_destroy(conn, dir, prop)
  • ni_prop_append(conn, dir, prop, value)
  • ni_prop_merge(conn, dir, prop, value)
  • ni_prop_values(conn, dir, prop)

  • ni_value_insert(conn, dir, prop, value, index)
  • ni_value_destroy(conn, dir, prop, value)
  • *ni_value_append(conn, dir, prop, value)

  • *ni_find_dirs_with_prop(conn, prop) -- find directories that have a property
  • *ni_find_dirs_with_prop_value(conn, prop, value)

* = non-existant in netinfo C API, something i need to create

functions will not be required to have conn passed to them once a connection has been initiated with ni_open() successfully once. it will be optional.

This seems like it will be a good project for me to do to get back into the habits of writing C code. I found an awesome book at B&N called "Pointers on C". It's the best damn programming book I've ever read, not that I've finished it yet... So, good luck to me on getting this done. Perhaps I can get it done within a month and maybe get it included in PHP 4.3 since that's supposed to be the first official OSX-supported release.

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!