Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Request
- {
- char b[4];
- uint16_t operand1;
- uint16_t operand2;
- };
- struct Response
- {
- char b[4];
- int32_t answer;
- };
- struct Request process(char *msg)
- {
- struct Request req;
- char *input = NULL;
- char space[] = " ";
- req.b[0] = 0;
- req.b[1] = 0;
- req.b[2] = 0;
- input = strtok(msg, space);
- req.b[3] = input;
- input = strtok(NULL, space);
- req.operand1 = htonl((uint16_t)input);
- input = strtok(NULL, space);
- input[strlen(input)-1] = '\0';
- req.operand2 = htonl((uint16_t)input);
- return req;
- }
Add Comment
Please, Sign In to add comment