|
#include "wftk.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
WFTK_ADAPTOR_INFO_FN DSREP_localxml_get_info;
WFTK_ADAPTOR_INFO_FN PDREP_localxml_get_info;
WFTK_ADAPTOR_INFO_FN USER_localxml_get_info;
WFTK_ADAPTOR_INFO_FN PERMS_localxml_get_info;
WFTK_ADAPTOR_INFO_FN TASKINDEX_stdout_get_info;
WFTK_ADAPTOR_INFO_FN ACTION_wftk_get_info;
WFTK_ADAPTOR_INFO_FN ACTION_system_get_info;
WFTK_ADAPTOR_INFO_FN DATASTORE_role_get_info;
WFTK_ADAPTOR_INFO_FN DATASTORE_currecord_get_info;
WFTK_ADAPTOR_INFO_FN DATATYPE_option_get_info;
struct wftk_adaptor_info * lookup_static_modules (int adaptor_class, int name_length, const char * adaptor_descriptor)
{
switch (adaptor_class) {
case DSREP:
if (!name_length || (name_length == 8 && !strncmp ("localxml", adaptor_descriptor, 8))) {
return DSREP_localxml_get_info();
}
break;
case DATASTORE:
if (name_length == 4 && (!strncmp ("role", adaptor_descriptor, 4))) {
return DATASTORE_role_get_info();
}
if (name_length == 9 && (!strncmp ("currecord", adaptor_descriptor, 9))) {
return DATASTORE_currecord_get_info();
}
break;
case DATATYPE:
if (name_length == 6 && (!strncmp ("option", adaptor_descriptor, 6))) {
return DATATYPE_option_get_info();
}
break;
case PDREP:
if (!name_length || (name_length == 8 && !strncmp ("localxml", adaptor_descriptor, 8))) {
return PDREP_localxml_get_info();
}
break;
case USER:
if (!name_length || (name_length == 8 && !strncmp ("localxml", adaptor_descriptor, 8))) {
return USER_localxml_get_info();
}
break;
case PERMS:
/* Perms are different -- the caller gets no choice.
Otherwise I figure we're in trouble, security-wise.
Probably are anyway. */
return PERMS_localxml_get_info();
break;
case TASKINDEX:
if (name_length == 6 && !strncmp ("stdout", adaptor_descriptor, 6)) {
return TASKINDEX_stdout_get_info();
break;
}
break;
case NOTIFY:
break;
case ACTION:
if (name_length == 6 && !strncmp ("system", adaptor_descriptor, 6)) {
return ACTION_system_get_info();
break;
}
if (!name_length || (name_length == 4 && !strncmp ("wftk", adaptor_descriptor, 4))) {
return ACTION_wftk_get_info();
}
break;
case DEBUG_MSG:
break;
default:
return NULL;
}
return NULL;
}
#define PERIOD_TO_NULL(x) (strcmp(x, ".") ? x : (char *)0)
main (int argc, char * argv[])
{
char config_path[512];
char * chmark;
FILE * config_file;
FILE * file;
int len;
int complain_if_no_file = 0;
int argp = 1; /* We'll use this to skip flags like -c for location of the config file. */
#define argsleft (argc - argp)
XML * datasheet = (XML *) 0;
XML * task = (XML *) 0;
XML * list = (XML *) 0;
XML * session = NULL;
XML * mark;
XML * action = (XML *) 0;
char * value;
if (argc < 2) {
printf ("usage: wftk [command] -- type wftk help for more information.\n");
exit (1);
}
session = wftk_session_alloc();
wftk_session_setlookup (session, lookup_static_modules);
while (*argv[argp] == '-') {
if (!strcmp (argv[argp], "-c")) {
argp++;
strcpy (config_path, argv[argp++]);
complain_if_no_file = 1;
} else if (!strcmp (argv[argp], "-u")) {
argp++;
wftk_session_setuser (session, argv[argp++]);
}
}
if (!complain_if_no_file) {
strcpy (config_path, argv[0]);
chmark = strrchr (config_path, '\\');
if (chmark) chmark[1] = '\0';
strcat (config_path, "config.xml");
}
config_file = fopen (config_path, "r");
if (!config_file && complain_if_no_file) {
printf ("wftk: can't open config file '%s'\n", config_path);
exit (1);
}
if (config_file) {
mark = xml_read_error (config_file);
if (!strcmp (mark->name, "xml-error")) {
printf ("wftk: error reading config file '%s'; '%s' in line %s\n", config_path, xml_attrval (mark, "message"), xml_attrval (mark, "line"));
exit (1);
} else wftk_session_configure (session, mark);
fclose (config_file);
}
argp++;
if (!strcmp (argv[argp-1], "help")) {
See The list of commands in printf format
} else if (!strcmp (argv[argp-1], "create")) {
See create: Creating a new datasheet
} else if (!strcmp (argv[argp-1], "delete")) {
See delete: Deleting an existing process
} else if (!strcmp (argv[argp-1], "define")) {
See define: Attach a procdef
} else if (!strcmp (argv[argp-1], "start")) {
See start: Start a procdef
} else if (!strcmp (argv[argp-1], "show")) {
See show: Displaying process information
} else if (!strcmp (argv[argp-1], "adhoc")) {
See adhoc: Running ad-hoc workflow
} else if (!strcmp (argv[argp-1], "task")) {
See task: Show a task, including data requirements
} else if (!strcmp (argv[argp-1], "tasks")) {
See tasks: List tasks
} else if (!strcmp (argv[argp-1], "todo")) {
See todo: List indexed tasks
} else if (!strcmp (argv[argp-1], "complete")) {
See complete: Complete a task (or start the process)
} else if (!strcmp (argv[argp-1], "reject")) {
See reject: Reject a task
} else if (!strcmp (argv[argp-1], "newtask")) {
See newtask: Create an ad-hoc task
} else if (!strcmp (argv[argp-1], "rescind")) {
See rescind: Delete an ad-hoc task
} else if (!strcmp (argv[argp-1], "assign")) {
See assign: Attach a user to a task
} else if (!strcmp (argv[argp-1], "ask")) {
See ask: Make a request
} else if (!strcmp (argv[argp-1], "requests")) {
See requests: List requests
} else if (!strcmp (argv[argp-1], "request")) {
See request: Show a request
} else if (!strcmp (argv[argp-1], "accept")) {
See accept: Accept a request
} else if (!strcmp (argv[argp-1], "decline")) {
See decline: Decline a request
} else if (!strcmp (argv[argp-1], "forget")) {
See forget: Rescind a request
} else if (!strcmp (argv[argp-1], "set")) {
See set: setting named values
} else if (!strcmp (argv[argp-1], "get")) {
See get: getting named values
} else if (!strcmp (argv[argp-1], "values")) {
See values: listing named values
} else if (!strcmp (argv[argp-1], "html")) {
See html: getting HTML for a named value
} else if (!strcmp (argv[argp-1], "htmlblank")) {
See htmlblank: getting a blank field
} else if (!strcmp (argv[argp-1], "log")) {
See log: get or write to enactment history
} else if (!strcmp (argv[argp-1], "roles")) {
See roles: list roles in a datasheet
} else if (!strcmp (argv[argp-1], "role")) {
See role: display or assign a role
} else if (!strcmp (argv[argp-1], "users")) {
See users: list users in a datasheet
} else if (!strcmp (argv[argp-1], "user")) {
See user: display user or set attribute
} else if (!strcmp (argv[argp-1], "action")) {
See action: Performing actions with possible deferment
} else {
printf ("Unknown command %s.\n", argv[argp-1]);
}
xml_free (session);
if (task) xml_free (task);
if (list) xml_free (list);
if (action) xml_free (action);
}
|