execute_cmd.c revision 56a424cca6b3f91f31bdab72a4626c48c779fe8b
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Copyright 1987, 1988, 1989 by Massachusetts Institute of Technology
*
* For copyright info, see copyright.h.
*/
#include "ss_internal.h"
#include "copyright.h"
#include <stdio.h>
/*
* get_request(tbl, idx)
*
* Function:
* Gets the idx'th request from the request table pointed to
* by tbl.
* Arguments:
* tbl (ss_request_table *)
* pointer to request table
* idx (int)
* index into table
* Returns:
* (ss_request_entry *)
* pointer to request table entry
* Notes:
* Has been replaced by a macro.
*/
#ifdef __SABER__
/* sigh. saber won't deal with pointer-to-const-struct */
int idx;
{
return e + idx;
}
#else
#endif
/*
* check_request_table(rqtbl, argc, argv, sci_idx)
*
* Function:
* If the command string in argv[0] is in the request table, execute
* the commands and return error code 0. Otherwise, return error
* code ss_et_command_not_found.
* Arguments:
* rqtbl (ss_request_table *)
* pointer to request table
* argc (int)
* number of elements in argv[]
* argv (char *[])
* argument string array
* sci_idx (int)
* ss-internal index for subsystem control info structure
* Returns:
* (int)
* zero if command found, ss_et_command_not_found otherwise
* Notes:
*/
register ss_request_table *rqtbl;
int argc;
char *argv[];
int sci_idx;
{
#ifdef __SABER__
struct _ss_request_entry *request;
#else
register ss_request_entry *request;
#endif
register char const * const * name;
int i;
return(0);
}
}
return(SS_ET_COMMAND_NOT_FOUND);
}
/*
* really_execute_command(sci_idx, argc, argv)
*
* Function:
* Fills in the argc, argv values in the subsystem entry and
* call the appropriate routine.
* Arguments:
* sci_idx (int)
* ss-internal index for subsystem control info structure
* argc (int)
* number of arguments in argument list
* argv (char **[])
* pointer to parsed argument list (may be reallocated
* on abbrev expansion)
*
* Returns:
* (int)
* Zero if successful, ss_et_command_not_found otherwise.
* Notes:
*/
int sci_idx;
int argc;
char **argv[];
{
register ss_request_table **rqtbl;
return(0);
}
return(SS_ET_COMMAND_NOT_FOUND);
}
/*
* ss_execute_command(sci_idx, argv)
*
* Function:
* Executes a parsed command list within the subsystem.
* Arguments:
* sci_idx (int)
* ss-internal index for subsystem control info structure
* argv (char *[])
* parsed argument list
* Returns:
* (int)
* Zero if successful, ss_et_command_not_found otherwise.
* Notes:
*/
int
int sci_idx;
register char *argv[];
{
register int i, argc;
char **argp;
argc = 0;
argc++;
for (i = 0; i <= argc; i++)
return(i);
}
/*
* ss_execute_line(sci_idx, line_ptr)
*
* Function:
* Parses and executes a command line within a subsystem.
* Arguments:
* sci_idx (int)
* ss-internal index for subsystem control info structure
* line_ptr (char *)
* Pointer to command line to be parsed.
* Returns:
* (int)
* Error code.
* Notes:
*/
int sci_idx;
char *line_ptr;
{
char **argv;
/* flush leading whitespace */
line_ptr++;
/* check if it should be sent to operating system for execution */
if (*line_ptr == '!') {
return SS_ET_ESCAPE_DISABLED;
else {
line_ptr++;
return 0;
}
}
/* parse it */
if (argc == 0)
return 0;
/* look it up in the request tables, execute if found */
return(ret);
}