Update README.md
[puttycyg-ng.git] / windows / cthelper / message.h
blob9cc2ad155d53f49f89f3f7afec01e734ea34a9be
1 #ifndef MESSAGE_H
2 #define MESSAGE_H
4 #if __STDC__VERSION >= 199901L
5 #include <stdint.h>
6 #elif defined(__INTERIX)
7 #include <sys/types.h>
8 #else
9 typedef unsigned char uint8_t;
10 typedef unsigned short uint16_t;
11 #endif
13 typedef struct message_tag Message;
14 struct message_tag {
15 uint8_t size;
16 uint8_t type;
17 union {
18 struct {
19 uint16_t width, height;
20 } resize;
21 } msg;
24 /* message types */
25 #define MSG_RESIZE (21)
27 #define MESSAGE_MIN (2)
28 #define MESSAGE_MAX (sizeof(struct message_tag))
30 /* Fills in a Message structure from `data'. Does not attempt to validate
31 * the message type, but returns 0 if a partial message is received.
32 * Returns -1 if the size is impossible (bigger than largest possible
33 * message or smaller than smallest possible message).
34 * Returns 1 if the message structure is filled in properly.
36 int message_get(Message *m, const unsigned char *data, size_t len);
38 #endif /* MESSAGE_H */