static char rcsid[]="$Id: parse.C,v 1.4 1995/09/28 02:06:28 wilmesj Exp $";
/* $Log: parse.C,v $
 * Revision 1.4  1995/09/28  02:06:28  wilmesj
 * Comments galore.
 *
 * Revision 1.3  1995/09/27  17:32:15  wilmesj
 * *** empty log message ***
 *
 * Revision 1.2  1995/09/12  21:44:35  josh
 * *** empty log message ***
 *
 * Revision 1.1  1995/09/10  17:25:06  josh
 * Initial revision
 *
 */

#include "shell.h"
#include <string.h>
#include <stdio.h>

//:::::::::::::::::::::::::::: parse_line ::::::::::::::::::::::::::::::::://
/* Function:  parse_line()
 * Purpose:   Commandline parsing.
 * Returns:   n/a
 * Uses:      Alien Intelligence
 */

int parse_line(char* input_line, char* &command, char* &restofline)
{
 int command_token;
 sscanf(input_line,"%s",command);
  restofline=strchr(input_line,' ');
  if (restofline)    // if there are multiple words
    if (*restofline) // and we haven't reached the end of the string
      restofline++;  // then skip the space.


  if ( ! strcmp(command,"quit") ) return MYSH_QUIT;
  if ( ! strcmp(command,"help") ) return MYSH_HELP;
  if ( ! strcmp(command,"run") ) return MYSH_RUN;
  if ( ! strcmp(command,"bg") ) return MYSH_BG;
  if ( ! strcmp(command,"ps") ) return MYSH_PS;
  if ( ! strcmp(command,"kill") ) return MYSH_KILL;
  if ( ! strcmp(command,"") ) return MYSH_NIL;
  return MYSH_UNKNOWN_COMMAND;
}

