* cmdparse.c 	Parse command line and call function.
 *
 * DRH	920916	Prepare for external use.
 *

include cmdparse.h

*.< Imported Functions >*

extern unsigned int		tokenize_quote();

*======================.============<  >===================================*
char * cmdparse( p1, p2, cmds, line)

char					* p1;
char					* p2;
CMDS					cmds[];
register char			* line;
{
		* Parse command line, set up command arguments Unixstyle, and call 
		 * function.
		 * Note: argument is modified (delimiters are overwritten with nulls)
		 *
	CMDS				* cmdp;
	char				* argv[NARG];
	int					argc;
	unsigned int		i;
	char				* msg;
	static char			work[128];
	static char			msg_bad_cmd[] = Invalid command\r\n;
	static char			quote[] = \026;

	argc = tokenize_quote( line, quote);
	for( i = 0; i < argc; i++) {
		argv[i] = line;
		line += strlen( line) + 1;
	}
	if( argc == 0 || argv[0][0] == '') {		*  lines are comments		*
		return NULLCHAR;
	}

		* Look up command in table; prefix matches are OK *
	for( cmdp = cmds; cmdp>name = NULLCHAR; cmdp++){
		if( strncmpi( argv[0], cmdp>name, strlen( argv[0])) == 0) {
			break;
		}
	}
	if( cmdp>name == NULLCHAR) {			* i.e. not in table *
		return cmdp>msg;
	} else {
		if( ( argc  1) < cmdp>argcmin) {	* Insufficient arguments *
			sprintf( work, Usage: s s\r\n, cmdp>name, cmdp>msg);
			return work;
		} else {
			return( (*cmdp>func)( p1, p2, argc, argv));
		}
	}
}
ne	set_timer( t, x)	( ( ( t)>start) =