Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int Process(char ch)
- {
- int i=0;
- if(ch==asciiescape)
- {
- return NOK;
- }
- if(countchars<MAX_INPUTLEN)
- {
- buffer[countchars]=ch; //copy char by char the chars into the buffer
- countchars++;
- }
- else
- {
- fprintf(stderr, "Cannot read more chars than MAX_INPUTLEN %u", countchars);
- countchars=0;
- return NOK;
- }
- if(ch==newline|| ch==asciienter) //check for LF and CR
- {
- buffer[countchars+1]=terminatedstring;
- }
- while(tcmd[i].fCommand != 0 && tcmd[i].Command != 0 && tcmd[i].Cmddescription != 0) //check for end criteria
- {
- int found=0;
- int charpos=0;
- while(buffer[charpos] != terminatedstring && buffer[charpos]!= ' ' && tcmd[i].Command[charpos] != 0)
- {
- if(buffer[charpos] == tcmd[i].Command[charpos])
- found=1;
- else
- break;
- charpos++;
- }
- if(found==1)
- {
- Print(buffer);
- if(tcmd[i].Command==0)
- Print("error in function!\n");
- else
- Print("successfully done the job!\n");
- }
- i++;
- }
- Print(">");
- }
Advertisement
Add Comment
Please, Sign In to add comment