First let me say, please don't post code back all fixed. If you see where the error is, just tell me where it is and I will look to find it. Thanks, much appreciated!

/*
void processCmdLine(void) 
Function: parses the command line using gettok(), and constructs an argument list. 
	  Calls runCommand() when it reaches a semicolon or newline (created when 
	  Enter key is pressed).
Pre-condition: inputBuff[] is not exmpty.
Post-condition: nil
Error-checking: Check for valid arguments being entered.
*/

void processCmdLine(void) 
{
int j =(strlen(inputBuff) -1);
int i = 0;

fflush(stdout);
fflush(stdin);
while(i <= j){
if(i >= j){ break;}
	if(inArgList(inputBuff[i]) == 1 && i < j)
	{
	 char *temp = inputBuff[i];
	int atemp = gettok(&temp);
	printf("%c is %d \n",*temp, atemp);

	while(inArgList(inputBuff[i]) == 1 && i != j)
	{
		if(i >= j){ break;}
		i++;
	}
	 

	}

	
		if(i >= j){ break;}
		if(inArgList(inputBuff[i]) == 0 && i <= j)
		{

		char *temp = inputBuff[i];
		int atemp = gettok(&temp);
		printf("%c is %d \n",*temp, atemp);
		i++;
		}
	
	
}
fflush(stdout);
fflush(stdin);

}

the second function that is called within that is:

/*
int inArgList(char c) 
Function: determines if a character can be part of an ordinary argument, 
	  or a special character
*/

int inArgList(char c) 
{
   	char *wrk;
   
   	for (wrk = special; *wrk; wrk++) {
      		if (c == *wrk)
	 		return(0);
   	}
   	return(1);
}

and the final fucntion is:

/*
int gettok(char **outptr)
Function: Separates the command line arguments into tokens.
Return value: Returns the token type.
*/

int gettok(char **outptr) 
{
   	int type;
   
   	/* set the outptr string to tok */
   	*outptr = tok;
   
   	/* strip white space from the buffer containing the tokens */
   	while (*ptr == '\t' || *ptr == ' ')
      		ptr++;

   	*tok++ = *ptr;

   	/* set the variable depending on the token in the buffer */
   	switch (*ptr++) {
   		case '\n':
      			type = EOL;
      			break;
   		case '&':
      			type = AMPERSAND;
      			break;
   		case ';':
    			type = SEMICOLON;
      			break;
   		case '<':
      			type = INPUT_REDIRECT;
      			break;
   		case '>':
      			type = OUTPUT_REDIRECT;
      			break;
   		case '|':
      			type = PIPE;
      			break;
   		default:
      			type = ARG;
      			/* keep reading valid ordinary characters */
      			while (inArgList(*ptr)) 
	 			*tok++ = *ptr++;
   	}
   	*tok++ = '\0';
   	return type;
}

Recommended Answers

All 2 Replies

First let me say, please don't post code back all fixed. If you see where the error is, just tell me where it is and I will look to find it. Thanks, much appreciated!

Where what is? Don't you think it would be helpful to tell us what we're looking for?

Bah! nevermind, I found the problem!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.