#include <stdio.h>
#include "pdb.h"

  /***************************************************************************
    * TOKEN.C
    * WADE 6/1/89
    * This program takes a parameter string and breaks it into tokens 
    * (each token is seperated by either tabs or spaces).  The token is
    * returned to the calling program in a character pointer array.  This
    * function also returns the number of tokens found.
    *************************************************************************/

int
token(line,word)

     char  *line;          /* string to be parsed */
     char  *word[];        /* return string array */

{
  int   token_count;
  int   index;

  token_count = 0;
  index       = 0;

  /* skip over leading blanks */
  for (; line[index] == ' ' || line[index] == '\t'; index++);

  /* continue loop until last token has been found */
  while((sscanf(&line[index],"%s",word[token_count]) != EOF) &&
    (token_count < 20)) {
    index = index + (strlen(word[token_count])+1);
    for (; line[index] == ' ' || line[index] == '\t';index++);
    token_count++;
  }
  
  return(token_count);
}
