|
#include "wftk.h"
#include <string.h>
#include <stdio.h>
#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;
void * session = (void *) 0;
XML * mark;
XML * action = (XML *) 0;
if (argc < 2) {
printf ("usage: wftk [command] -- type wftk help for more information.\n");
exit (1);
}
session = wftk_session_alloc();
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], "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]);
}
wftk_session_free (session);
if (task) xml_free (task);
if (list) xml_free (list);
if (action) xml_free (action);
}
|