Advertisement
Guest User

Untitled

a guest
Aug 24th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. /**
  2. * Usunie z danej w parametrze wiadomości sekwencje sterujące protokołu telnet.
  3. */
  4. void delete_control_sequences(unsigned char *message) {
  5.  
  6. unsigned char tmp_buffer[MAX_COMMAND_SIZE];
  7.  
  8. int i, j;
  9.  
  10. memset(&tmp_buffer, 0, MAX_COMMAND_SIZE);
  11.  
  12. while (i < MAX_COMMAND_SIZE + 2) {
  13.  
  14. if (message[i] == 0xff) {
  15.  
  16. // Sekwencja [255][255] -> 255
  17. if (message[i + 1] == 0xff) {
  18. tmp_buffer[j] = tmp_buffer[i];
  19. i += 2;
  20. }
  21. else
  22. // Sekwencja [255][251 - 254][coś] -> null
  23. if (message[i + 1] >= 0xfb) {
  24. i += 3;
  25. }
  26. // Sekwencja [255][coś] -> null
  27. else {
  28. i += 2;
  29. }
  30. }
  31. else {
  32. tmp_buffer[j] = message[i];
  33. ++i;
  34. }
  35.  
  36. ++j;
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement