Global variables: state

Previous: Interpreting the process definition ] [ Top: wftk core index ] [ Next: Printing the current stack as a locator ]

The state of the current process is kept in global variables. These globals would naturally be put into a struct in a daemon version of the core engine, but for a command-line version, globals make more sense.

Our three chief data structures are the process definition, the datasheet, and the command stack.
 
XML * procdef;
XML * datasheet;
COMMAND * command_stack;
Then we have some special parts of the datasheet which we'll point to separately.
 
XML * state;
XML * queue;
int idcount;

char * process;

char sbuf[1024];


Initializing global variables from the command line
About the only thing the initialization code has to do at this point is to read the command off the command line and call command_add to start off the list.

The big switch is horrendous but I'm too rushed to think of an elegant way to do this -- get yer name here, folks! Step right up and tell me how it's done!
 
if (argc < 3) {
   See Print usage description
}
process = argv[2];
switch (argc) {
   case 3:
      command_stack = command_add (NULL, argv[1], 0);
      break;
   case 4:
      command_stack = command_add (NULL, argv[1], 1, argv[3]);
      break;
   case 5:
      command_stack = command_add (NULL, argv[1], 2, argv[3], argv[4]);
      break;
   case 6:
      command_stack = command_add (NULL, argv[1], 3, argv[3], argv[4], argv[5]);
      break;
   case 7:
      command_stack = command_add (NULL, argv[1], 4, argv[3], argv[4], argv[5], argv[6]);
      break;
}



Previous: Interpreting the process definition ] [ Top: wftk core index ] [ Next: Printing the current stack as a locator ]


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.