// --| get tokens |-- // Semantics: (nwords, word[]) = getTokens(cmnd,delim) // where cmnd is the command line // delim is the deliminator string // nwords is number of words in command line // word[] is array of ptrs to words in command line // Usage: int nwords = getTokens(cmnd, word, " \t\n"); // where char cmnd[]; // char *word[]; int getTokens(char *cmnd, char *word[], const char *delim) { int nwords = 0; char *p = cmnd; char *token; while ((token=strtok(p,delim)) != NULL) { word[nwords] = token; if (debug) fprintf(stderr, "\tword[%d] = %s\n", nwords, token); nwords++; p = NULL; } word[nwords] = NULL; return nwords; }