hawxgamer

Untitled

Nov 24th, 2013
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1.  
  2. int Process(char ch)
  3. {
  4. int i=0;
  5. if(ch==asciiescape)
  6. {
  7. return NOK;
  8. }
  9.  
  10. if(countchars<MAX_INPUTLEN)
  11. {
  12. buffer[countchars]=ch; //copy char by char the chars into the buffer
  13. countchars++;
  14. }
  15. else
  16. {
  17. fprintf(stderr, "Cannot read more chars than MAX_INPUTLEN %u", countchars);
  18. countchars=0;
  19. return NOK;
  20. }
  21.  
  22. if(ch==newline|| ch==asciienter) //check for LF and CR
  23. {
  24. buffer[countchars+1]=terminatedstring;
  25. }
  26.  
  27. while(tcmd[i].fCommand != 0 && tcmd[i].Command != 0 && tcmd[i].Cmddescription != 0) //check for end criteria
  28. {
  29. int found=0;
  30. int charpos=0;
  31. while(buffer[charpos] != terminatedstring && buffer[charpos]!= ' ' && tcmd[i].Command[charpos] != 0)
  32. {
  33. if(buffer[charpos] == tcmd[i].Command[charpos])
  34. found=1;
  35. else
  36. break;
  37.  
  38. charpos++;
  39. }
  40. if(found==1)
  41. {
  42. Print(buffer);
  43. if(tcmd[i].Command==0)
  44. Print("error in function!\n");
  45. else
  46. Print("successfully done the job!\n");
  47. }
  48. i++;
  49. }
  50. Print(">");
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment