global.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 <ctype.h>
#include <time.h> /* for glob_time() */
#include "wish.h"
#include "token.h"
#include "slk.h"
#include "actrec.h"
#include "ctl.h"
#include "terror.h"
#include "moremacros.h"
#include "message.h"
#define MAX_OBJNAME 15
/*
* Caution: MAX_ARGS is defined in other files and should ultimately reside
* in wish.h
*/
#define MAX_ARGS 25
static char Objtype[MAX_OBJNAME];
char Release[] = "FMLI Release 4.0 (id=K18.2)";
/* The global stream handler. Handles most tokens */
int Arg_count;
/* some strings that are used several times in this source file */
static char Open[] = "OPEN";
static char Menu[] = "MENU";
static char Form[] = "FORM";
static char Text[] = "TEXT";
static char Any[] = "Any";
static char Extra_args[] = "Extra arguments ignored";
char *path_to_full(), *cur_path();
token t;
{
register int i;
struct actrec *a;
extern char *Filesys;
char *tok_to_cmd();
char *bsd_path_to_title();
struct actrec *path_to_ar();
#ifdef _DEBUG5
#endif
/*
* no more flashing token message (yuk!)
*
* if (p = tok_to_cmd(t))
* {
* mess_flash(p);
* doupdate();
* }
*/
switch (t) {
/* commands which process objects */
case TOK_HELP:
if (Arg_count <= 1) {
extern char *Pending_op;
if (Pending_op)
else
}
else
if (t == TOK_OPEN)
goto openit;
return TOK_NOP;
case TOK_SHOW_PATH: /* checkprint */
if (Arg_count > 1)
(void) mess_temp(Extra_args);
else
(void) mess_temp("The current frame must be a non-empty folder to use this command.");
return TOK_NOP;
case TOK_SECURITY: /* security */
mess_temp("object does not exist");
else
return TOK_NOP;
}
break;
case TOK_ORGANIZE: /* organize */
bool b;
mess_temp("You may only organize File folders");
mess_temp("You do not have write permission to organize this folder");
else {
return TOK_NOP;
}
} else
mess_temp("You must open the File folder to organize");
break;
case TOK_FIND: /* find */
else
return TOK_NOP;
}
break;
/* commands which are activation record functions */
case TOK_CLEANUP: /* cleanup */
(void) ar_cleanup(AR_LONGTERM);
return TOK_NOP;
case TOK_GOTO: /* goto */
if (Arg_count <= 1)
else
return TOK_NOP;
/* case TOK_TAB: tab Removed this mapping abs k16 */
case TOK_NEXT_WDW: /* next_wdw */
ar_cur_next();
return TOK_NOP;
/* case TOK_BTAB: backtab Removed this mapping abs k16 */
case TOK_PREV_WDW: /* prev_wdw */
ar_cur_prev();
return TOK_NOP;
case TOK_LOGOUT: /* logout */
break;
case TOK_DEBUG:
/* les
mdump();
*/
return TOK_NOP;
case TOK_REREAD:
if (Arg_count <= 1)
else {
int save_life;
savear = ar_get_current();
else {
bool restore_ar = FALSE;
{
restore_ar = TRUE;
/* don't let lifetime re-evaluate or frame close if
shortterm when destar is made current. abs k15*/
}
/*
* - make the destination AR current
* (to update the window immediately)
* - if there is no third argument then
* make the save AR current
*/
if (restore_ar == TRUE)
{
}
}
}
}
return TOK_NOP;
case TOK_CLOSE:
{
struct actrec *a;
register int i;
if (Arg_count <= 1) {
a = ar_get_current();
if (!a)
mess_temp("Can't find any frames\n");
/* commented out by njp for F15 - this code was
moved to actrec.c in ar_close.
else if (a->lifetime == AR_IMMORTAL ||
a->lifetime == AR_INITIAL)
mess_temp("Can't close this frame\n", Args + i);
*/
else {
init_modes();
}
return(TOK_NOP);
}
for (i = 1; i < Arg_count; i++) {
if (!a) {
}
/** test is now in ar_close. abs k17
else if (a->lifetime == AR_IMMORTAL ||
a->lifetime == AR_INITIAL) {
sprintf(buf, "Can't close frame \"%s\"\n", Args[i]);
mess_temp(buf);
}
**/
else {
init_modes();
}
}
return TOK_NOP;
}
break;
case TOK_CHECKWORLD: /* force the world to be checked */
return TOK_NOP;
case TOK_UNK_CMD: /* unknown command, if number, goto, else like open */
{
return(TOK_NOP);
} else {
for (i = MAX_ARGS-1; i > 0; i--)
Arg_count++;
t = TOK_OPEN;
/* fall through to open - no break!! */
}
/* object operations */
case TOK_OPEN: /* open */
case TOK_ENTER:
case TOK_COPY: /* copy */
case TOK_MOVE: /* move */
case TOK_REPLACE: /* rename */
case TOK_SCRAMBLE: /* scramble */
case TOK_UNSCRAMBLE: /* unscramble */
case TOK_PRINT: /* print */
case TOK_DELETE: /* delete */
case TOK_UNDELETE: /* undelete */
case TOK_OBJOP: /* any other object operation */
#ifdef _DEBUG
#endif
if (objop_args(t) != FAIL)
return TOK_NOP;
case TOK_SREPLACE: /* redescribe */
if (objop_args(t) != FAIL) {
if (Arg_count <= 2)
else {
}
}
return TOK_NOP;
case TOK_DISPLAY: /* display */
if (objop_args(t) != FAIL)
return TOK_NOP;
case TOK_RUN:
if (objop_args(t) != FAIL) {
return(TOK_NOP);
}
break;
case TOK_CREATE: /* create */
return glob_create();
/* system functions */
case TOK_SELECT: /* select */
glob_select();
return TOK_NOP;
case TOK_CANCEL: /* cancel out of a browse */
return TOK_NOP;
case TOK_REFRESH: /* refresh the screen */
vt_redraw();
return TOK_NOP;
case TOK_TIME: /* time */
glob_time();
return TOK_NOP;
case TOK_UNIX: /* unix */
return TOK_NOP;
case TOK_WDWMGMT: /* wdw_mgmt */
if (Arg_count <= 1)
else
return TOK_NOP;
case TOK_CMD:
cmd_create();
return TOK_NOP;
case TOK_SET:
if (Arg_count < 3) {
mess_temp("Not enough arguments");
break;
} else {
for (i = 3; Args[i]; i++) {
}
return TOK_NOP;
}
case TOK_TOGSLK:
slk_toggle();
return TOK_NOP;
case TOK_RELEASE:
return TOK_NOP;
case TOK_NOP:
default:
break;
}
return t;
}
/*
* This function looks at its arglist, and parses its argument into an
* activation record. The argument could be either a window number or a path
*/
struct actrec *
int argc;
char *argv[];
int maxargs;
{
char *p;
int n;
struct actrec *path_to_ar();
if (argc <= 0) {
ret = ar_get_current();
return(ret);
}
else {
return(ret);
else {
p = path_to_full(argv[0]);
ret = path_to_ar(p);
free(p);
return ret;
}
}
}
/*
* this is used for those functions that require an argument that is
* a path inside a window by default, or a full path.
*/
static char *
path_arg()
{
char *p;
extern char *Filecabinet;
if (Arg_count > 2)
if (Arg_count >= 2)
return path_to_full(p);
return Filecabinet;
}
/*
* These should really go in separate source files when they are
* finally finished.
*/
static
{
char buf[12];
time_t t; /* EFT abs k16 */
}
/* prepare the argument array for an impending object operation */
static int
objop_args(t)
token t;
{
char *p;
register int i;
glob_mess_nosrc(t);
return(FAIL);
}
if ( Args[2] )
Arg_count = 2;
return(SUCCESS);
}
if (Arg_count > 2 &&
for (p = &Objtype[0]; *p; p++)
if (islower(*p))
*p = toupper(*p);
;
Arg_count--;
}
glob_mess_nosrc(t);
return(FAIL);
}
}
p = Args[1];
if (p)
free(p);
return SUCCESS;
}
static token
gotoarg(s, t)
char *s;
token t;
{
struct actrec *a;
if (t == TOK_CANCEL)
return t;
if (s) {
if (Arg_count < 2)
Arg_count = 2;
}
mess_temp("Unable to find a frame with that name");
return t;
}
else
return TOK_NOP;
}
/* parse for arguments of the form: command [name] [in folder] */
int
{
switch (Arg_count) {
case 0:
case 1:
break;
case 2:
break;
default:
sleep(2);
case 4:
return(FAIL);
}
break;
case 3:
else
break;
}
return SUCCESS;
}
static char *
cur_path()
{
bool arg;
char *path;
extern char *Filecabinet;
path = Filecabinet;
else
return(path);
}