ACTION adaptor: system

This is the ACTION adaptor for local system calls. It allows workflow processes to do arbitrary "system stuff", meaning among other things that you can use it to provide a permissions layer on any program you want to run from the command line.
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include "xmlapi.h"
#include "../wftk_internals.h"
The adaptor_info structure is used to pass adaptor info (duh) back to the config module when it's building an adaptor instance. Here's what it contains:
static char *names[] = 

XML * ACTION_system_init (WFTK_ADAPTOR * ad, va_list args);
XML * ACTION_system_free (WFTK_ADAPTOR * ad, va_list args);
XML * ACTION_system_info (WFTK_ADAPTOR * ad, va_list args);
XML * ACTION_system_do (WFTK_ADAPTOR * ad, va_list args);

static WFTK_API_FUNC vtab[] = 

static struct adaptor_info _ACTION_system_info =
Cool. So here's the incredibly complex function which returns a pointer to that:
struct adaptor_info * ACTION_system_get_info ()
   return & _ACTION_system_info;
Thus concludes the communication with the config module. Now on with the actual implementation of functionality. It's not complicated.
XML * ACTION_system_init (WFTK_ADAPTOR * ad, va_list args) {
   xml_set (ad->parms, "spec", "wftk");
   return (XML *) 0;
XML * ACTION_system_free (WFTK_ADAPTOR * ad, va_list args) { return (XML *) 0; }
Next up is the info call, which builds and returns a little XML telling the caller about the adaptor. If the adaptor itself is NULL, then it just returns info about the installed adaptor handler; otherwise it's free to elaborate on the adaptor instance.
XML * ACTION_system_info (WFTK_ADAPTOR * ad, va_list args) {
   XML * info;

   info = xml_create ("info");
   xml_set (info, "type", "action");
   xml_set (info, "name", "system");
   xml_set (info, "ver", "1.0.0");
   xml_set (info, "compiled", __TIME__ " " __DATE__);
   xml_set (info, "author", "Michael Roberts");
   xml_set (info, "contact", "");
   xml_set (info, "extra_functions", "0");

   return (info);

Moving along at breakneck speed, we come to actual functionality: taking action. Given that the action has already been parsed thanks to its XML nature, we hardly have anything to do at all.
XML * ACTION_system_do  (WFTK_ADAPTOR * ad, va_list args)
   XML * action = (XML *) 0;
   const char * aname;
   char * content;

   if (args) action = va_arg (args, XML *);
   if (action) {
      aname = xml_attrval (action, "action");
      if (!strcmp (aname, "exec")) {
         /* TODO: Line by line, run the content of the action through the data interpreter
            and pass it over to the shell.  Primitive, yeah -- you can't break lines. */
         /* TODO: do a better parser for this, line breaks and stuff. */
         content = xml_stringcontent (action);
         system (content);
         free (content);
   return 0;

This code and documentation are released under the terms of the GNU license. They are additionally copyright (c) 2000, Vivtek. All rights reserved except those explicitly granted under the terms of the GNU license. This presentation was prepared with LPML. Try literate programming. You'll like it.