c u l a t e r | net

Technical Overview

Basic Idea

Running under linux or some similar platform, CGIs process data from the standard io streams and can use the getenv() function to query additional data provided by the web server. On the Mac, this doesn't really happen. Instead, the CGI application and the web server communicate via the 'sdoc' AppleEvent.

Assumptions

There are two basic assumptions made:

  • AppleEvents are a bit of a pain
  • almost every Mac application has to be interactive

How It Works

  1. Part of the code is a wrapper that provides the bare minimum interactive shell for a Mac application. This handles menus and a couple of dialogs.

  2. The code install handling routines for the basic suite of AppleEvents which are required by all applications. Obviously, the 'sdoc' event is also supported. This is the interapplication data conduit for the CGI and the web server.

  3. The 'sdoc' processing routines parse out the server requests and create an internal data structure which the application can access via the getenv() function. Note: this is currently fairly slow code and could be sped up by placing the fields in a hash table.

  4. The application redirects the STDIN and STDOUT streams so that they can be used for communicating directly with the web server. This is really the only crafty bit of code here - the Assimilator hooks in at a really low level with in the MSL and makes this pretty seamless.

  5. An incoming request from the web server will be processed and routed to a user processing routine which matches the default main(int, char**) function signature. Internally the function is called weasel(), but the precompiled headers will take care of remapping that at compile time.

  6. The MacGetEnv() function emulates most of the abilities of the standard getenv() function. Again, the precompiled headers will remap this function at compile time.


© Mike Solomon Last modified: Monday, February 10, 2003 02:17 AM PST