virtual.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 (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright (c) 1986 AT&T
* All Rights Reserved
*/
#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.14 */
#include <stdio.h>
#include <ctype.h>
#include "wish.h"
#include "token.h"
#include "vtdefs.h"
#include "actrec.h"
#include "slk.h"
#include "moremacros.h"
#include "message.h"
/*
* Caution: MAX_ARGS is defined in several files and should ultimately reside
* in wish.h
*/
#define MAX_ARGS 25
extern int Arg_count;
extern bool Nobang;
register token t;
{
char *s;
char *tok_to_cmd();
if ( t > 037 && t < 0177 )
return t;
Arg_count = 0;
if (s = tok_to_cmd(t))
t = cmd_to_tok(s);
if (t == TOK_COMMAND)
{
/* single equals sign is correct, here */
if (Command_mode = !Command_mode)
{
char *cur_cmd();
"$VMSYS/OBJECTS/Menu.h6.list", NULL);
t = TOK_NOP;
}
else
t = TOK_CANCEL;
}
else
{
t = slk_token(t);
}
return t;
}
static token
done_cmd(s, t)
char *s;
token t;
{
char *strchr();
if (t == TOK_CANCEL)
t = TOK_NOP;
else
{
int i;
/* Remove all blanks in the beginning of the command line */
while(*s && isspace(*s))
s++;
if (s[0] == '!') /* execute shell cmd from cmd line */
if (Nobang) /* feature disabled by application developer */
{
mess_temp("Command ignored: the ! prefix is disabled in this application");
mess_lock();
t = TOK_NOP;
}
else
{
char *tok_to_cmd();
t = TOK_OPEN;
for (i=0; i < 5; i++)
if (Args[i])
Arg_count = 5;
}
else
{
set_Args(s);
/* changed if's to switch and added security clauses. abs k17 */
t = cmd_to_tok(Args[0]);
switch(t)
{
case TOK_NOP:
{
/* change to unknown_command which becomes a goto or
** open (see global_stream() ) unless command was
** entered from command line while Nobang is set;
** in this case only change to unknown_command if
** it will turn into a goto. abs k17
*/
t = TOK_UNK_CMD;
else
{
mess_temp("Command ignored: open is disabled in this application");
mess_lock();
}
break;
}
case TOK_NUNIQUE:
{
t = TOK_NOP;
break;
}
case TOK_RUN: /* added clause. abs k17 */
{
if (Nobang)
{
mess_temp("Command ignored: run is disabled in this application");
mess_lock();
t = TOK_NOP;
}
break;
}
case TOK_OPEN: /* added clause. abs k17 */
{
if (Nobang)
{
mess_temp("Command ignored: open is disabled in this application");
mess_lock();
t = TOK_NOP;
}
break;
}
default:
{
if (t < 0)
t = do_app_cmd(); /* Application defined command */
break;
}
}
}
}
return t;
}
set_Args(s)
char *s;
{
while (*s && isspace(*s))
s++;
if (*s == '\0')
break;
while (*s && !isspace(*s))
s++;
if (*s != '\0')
*s++ = '\0';
#ifdef _DEBUG
#endif
}
}