Guest User

Untitled

a guest
Jan 23rd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. struct Request
  2. {
  3. char b[4];
  4. uint16_t operand1;
  5. uint16_t operand2;
  6. };
  7.  
  8. struct Response
  9. {
  10. char b[4];
  11. int32_t answer;
  12. };
  13.  
  14. struct Request process(char *msg)
  15. {
  16. struct Request req;
  17. char *input = NULL;
  18. char space[] = " ";
  19.  
  20. req.b[0] = 0;
  21. req.b[1] = 0;
  22. req.b[2] = 0;
  23.  
  24. input = strtok(msg, space);
  25. req.b[3] = input;
  26.  
  27. input = strtok(NULL, space);
  28. req.operand1 = htonl((uint16_t)input);
  29.  
  30. input = strtok(NULL, space);
  31. input[strlen(input)-1] = '\0';
  32. req.operand2 = htonl((uint16_t)input);
  33.  
  34. return req;
  35. }
Add Comment
Please, Sign In to add comment