cmd.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include "wish.h"
#include "token.h"
#include "slk.h"
#include "actrec.h"
#include "terror.h"
#include "ctl.h"
#include "menudefs.h"
#include "vtdefs.h"
#include "fm_mn_par.h"
#include "moremacros.h"
#include "eval.h"
#include "interrupt.h"
#include "sizes.h"
extern char *Args[];
extern char nil[];
extern int Arg_count;
static struct cmdspec {
char *name;
int helpindex;
char *tokstr;
char *helpaction;
char *intr;
char *onintr;
};
#define NOTEXT ((int) -1)
/*
* NODISP is used for internal commands not to be displayed on the
* command menu.
*/
#define NODISP ((int) -2)
/*
* Table from which command defaults are selected
*/
};
/*
* Commands with NODISP have to be last in the above table befor the
* NULL command.
*/
#define MAX_CMD 64
/*
* Command table, presented to the user via the command menu.
* This table, once initialized, is kept in alphabetical order.
*/
/*
* Commands that the user doesn't see in the cmd menu, but exist
* none-the-less, (most are used for token translations from within
* the FMLI language).
*/
/* Secret commands, they wouldn't let us document them... */
/*{"?", TOK_REDO, NOTEXT, NULL, NULL, NULL, NULL },*/
/*{"%", TOK_DEBUG, NOTEXT, NULL, NULL, NULL, NULL },*/
};
static char *Tokstr;
static int Cmd_index;
extern int Vflag; /* is this the User Interface ?? */
{
register int i, j;
for (i = 0, j = 0; i < Numdefaults; i++) {
}
}
static struct menu_line
int n;
char *ptr;
{
struct menu_line m;
m.description = NULL;
m.flags = 0;
/* Commands marked as NODISP do not go on the command menu */
else
return m;
}
static int
cmd_odsh(a, t)
struct actrec *a;
token t;
{
extern int Arg_count;
char **actstr, **eval_string();
int flags;
t = menu_stream(t);
int line;
else {
/* update the interrupt structures based on
the values for the current command, if
defined else with the inherited values.
*/
}
}
else if (t == TOK_NEXT)
t = TOK_NOP; /* eat it up */
else if (t == TOK_CANCEL) {
ar_backup();
t = TOK_NOP;
}
return t;
}
static int
cmd_close(a)
struct actrec *a;
{
return(AR_MEN_CLOSE(a));
}
char *cmd;
{
int flags;
char **helpaction, **eval_string();
extern char *Filesys;
char *cur_cmd(), *tok_to_cmd();
extern int Vflag;
{
/* below cannot destinguish between user defined cmds. abs k17
** cmd = tok_to_cmd(cmd_to_tok(cmd));
*/
{
return(SUCCESS); /* abs k17 */
}
}
else
mess_temp("Could not find help on that command");
return(SUCCESS);
}
/*
* If there is a help action defined then do it ...
* else if there is a "hardcoded" help string use that
* else if FACE is running use the FACE help files
* else there is no help available ....
*/
return(tok);
}
else if (Vflag) { /* FACE has its own help file setup */
return(SUCCESS);
}
else
mess_temp("Could not find help on that command");
return SUCCESS;
}
extern char *Help_text[];
char *Help_args[3] = {
"OPEN",
"TEXT",
"-i"
};
char *name;
int helpindex;
{
extern char *Args[];
extern int Arg_count;
extern int Vflag;
if (Vflag) {
}
{
}
return(TOK_OPEN);
}
struct actrec *
{
struct actrec a;
if (Numcommands == 0) {
mess_temp("There are no commands in the command menu");
return(NULL);
}
ar_menu_init(&a);
a.flags = 0;
/* theres no frame level interrupt or oninterrupt descriptors.. */
/* .. so set up values in the actrec now since they'll only .. */
/* .. change on a re-init. */
}
char *cmd;
bool partial;
bool slk;
{
register int i;
Cmd_index = -1;
if (!cmd) /* no input (^j <return>) */
return(TOK_CANCEL);
if (slk) {
for (i = 0; i < MAX_SLK; i++) {
/*
* If there is another match BUT ...
* the command token is the same
* OR the name strings match exactly
* then ignore the 'ith' SLK
*/
if (slknumatch == 1 &&
continue;
slknumatch++;
slkmatch = i;
}
}
}
for (i = 0; i < Numcommands; i++) {
/*
* if there is an exact match then break
*/
cmdmatch = i;
cmdnumatch = 1;
break;
}
cmdnumatch++;
cmdmatch = i;
}
}
/* since "unix" is unadvertised, don't get confused by 2 partial matches
* for unix and unix-system. mek k17
*/
if (slknumatch + cmdnumatch == 0) {
/*
* no matches, check internal command table
*/
return(TOK_NOP);
}
return(TOK_NUNIQUE);
}
}
else {
/*
* If there is only ONE match in both the
* SLKS and the Command Menu then
* - the SLK takes precedence if both match exactly
* - match is not unique if both match "partially"
*/
}
else
return(TOK_NUNIQUE);
}
}
/* LES: replace with MACRO's
token
cmd_to_tok(cmd)
char *cmd;
{
return(_cmd_to_tok(cmd, TRUE, TRUE));
}
NEVER CALLED
token
fullcmd_to_tok(cmd)
char *cmd;
{
return(_cmd_to_tok(cmd, FALSE, TRUE));
}
token
mencmd_to_tok(cmd)
char *cmd;
{
return(_cmd_to_tok(cmd, FALSE, FALSE));
}
*/
char *
{
register int i;
/* Most frequently referenced command is open, make it QUICK !!! */
return("open");
for (i = 0; i < Numcommands; i++)
return NULL;
}
char *
cur_cmd()
{
int line;
/* char *cur_hist(); */
if (ar_get_current() != Cmd_ar)
return(NULL);
}
/*
* ADD_CMD will add a command to the command list preserving
* alphabetical ordering
*/
char *name;
char *tokstr;
char *help;
char *intr;
char *onintr;
{
register int i, j, comp;
return; /* internal command conflict */
}
if (comp < 0) {
/*
* shift list to make room for new entry
*/
for (j = MAX_CMD - 1; j > i; j--)
break;
}
else if (comp == 0) {
/*
* Command already exists
*/
/*
* Name conflict with a generic command,
* only accept redefinitions for helpaction
*/
}
}
else {
/*
* Redefine a previous definition
*/
}
break;
}
}
}
/*
* DEL_CMD will remove a command from the command menu
* (shifting the command menu accordingly)
*/
char *name;
{
register int i, j;
/*
* scrunch list to remove entry
*/
for (j = i; j < MAX_CMD - 1; j++)
break;
}
}
}
static struct cmdspec *
char *cmdstr;
{
register int i;
return(&(Commands[i]));
return(NULL);
}
{
char **strlist, **eval_string();
token t, make_action();
int flags;
if (Tokstr) /* set in _cmd_to_tok */
{
if (Cmd_index >= 0) /* set in _cmd_to_tok */
{
/* update the interrupt structures based on
the values for the current command, if
defined else with the inherited values.
*/
}
t = make_action(strlist);
}
else
t = TOK_NOP;
}
int argc;
char *argv[];
{
{
set_def_colors(); /* moved above next line. k17 */
return(SUCCESS);
}
else
return(FAIL);
}