initial commit
[xdos] / src / proto.c
1 #include "proto.h"
2
3 static uint16_t swap16(uint16_t x)
4 {
5         return ((x & 0xff) << 8) | ((x & 0xff00) >> 8);
6 }
7
8 static uint32_t swap32(uint32_t x)
9 {
10         return ((x & 0xff) << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) |
11                 ((x & 0xff000000) >> 24);
12 }
13
14 #define SWAP16(x)       ((x) = swap16(x))
15 #define SWAP32(x)       ((x) = swap32(x))
16
17 void swap_xconn_accept(struct xconn_accept_header *hdr)
18 {
19         SWAP16(hdr->proto_major);
20         SWAP16(hdr->proto_minor);
21         SWAP16(hdr->add_length);
22         SWAP32(hdr->release);
23         SWAP32(hdr->resid_base);
24         SWAP32(hdr->resid_mask);
25         SWAP32(hdr->motionbuf_size);
26         SWAP16(hdr->vendor_length);
27         SWAP16(hdr->max_req_length);
28         /* TODO swap pixel formats and screens */
29 }
30
31 void swap_xreq_header(struct xrequest_header *hdr)
32 {
33 }