annotate libpurple/protocols/msn/p2p.c @ 31220:3ccddae82532

Add P2PFooter helper functions.
author masca@cpw.pidgin.im
date Tue, 08 Jun 2010 21:08:13 +0000
parents 198d5bf82e09
children 5964f65c17ed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
31209
198d5bf82e09 Oops, forgot to save before commiting.
masca@cpw.pidgin.im
parents: 31206
diff changeset
1 #include "internal.h"
198d5bf82e09 Oops, forgot to save before commiting.
masca@cpw.pidgin.im
parents: 31206
diff changeset
2
198d5bf82e09 Oops, forgot to save before commiting.
masca@cpw.pidgin.im
parents: 31206
diff changeset
3 #include "p2p.h"
31206
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
4
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
5 MsnP2PHeader *
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
6 msn_p2p_header_from_wire(MsnP2PHeader *wire)
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
7 {
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
8 MsnP2PHeader *header;
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
9
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
10 header = g_new(MsnP2PHeader, 1);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
11
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
12 header->session_id = GUINT32_FROM_LE(wire->session_id);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
13 header->id = GUINT32_FROM_LE(wire->id);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
14 header->offset = GUINT64_FROM_LE(wire->offset);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
15 header->total_size = GUINT64_FROM_LE(wire->total_size);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
16 header->length = GUINT32_FROM_LE(wire->length);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
17 header->flags = GUINT32_FROM_LE(wire->flags);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
18 header->ack_id = GUINT32_FROM_LE(wire->ack_id);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
19 header->ack_sub_id = GUINT32_FROM_LE(wire->ack_sub_id);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
20 header->ack_size = GUINT64_FROM_LE(wire->ack_size);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
21
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
22 return header;
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
23 }
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
24
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
25 MsnP2PHeader *
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
26 msn_p2p_header_to_wire(MsnP2PHeader *header)
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
27 {
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
28 MsnP2PHeader *wire;
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
29
31209
198d5bf82e09 Oops, forgot to save before commiting.
masca@cpw.pidgin.im
parents: 31206
diff changeset
30 wire = g_new(MsnP2PHeader, 1);
31206
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
31
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
32 wire->session_id = GUINT32_TO_LE(header->session_id);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
33 wire->id = GUINT32_TO_LE(header->id);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
34 wire->offset = GUINT64_TO_LE(header->offset);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
35 wire->total_size = GUINT64_TO_LE(header->total_size);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
36 wire->length = GUINT32_TO_LE(header->length);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
37 wire->flags = GUINT32_TO_LE(header->flags);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
38 wire->ack_id = GUINT32_TO_LE(header->ack_id);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
39 wire->ack_sub_id = GUINT32_TO_LE(header->ack_sub_id);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
40 wire->ack_size = GUINT64_TO_LE(header->ack_size);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
41
31209
198d5bf82e09 Oops, forgot to save before commiting.
masca@cpw.pidgin.im
parents: 31206
diff changeset
42 return wire;
198d5bf82e09 Oops, forgot to save before commiting.
masca@cpw.pidgin.im
parents: 31206
diff changeset
43
31206
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
44 }
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
45
31220
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
46 MsnP2PFooter *
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
47 msn_p2p_footer_from_wire(MsnP2PFooter *wire)
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
48 {
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
49 MsnP2PFooter *footer;
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
50
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
51 footer = g_new(MsnP2PFooter, 1);
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
52
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
53 footer->value = GUINT32_FROM_BE(wire->value);
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
54
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
55 return footer;
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
56 }
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
57
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
58 MsnP2PFooter *
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
59 msn_p2p_footer_to_wire(MsnP2PFooter *footer)
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
60 {
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
61 MsnP2PFooter *wire;
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
62
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
63 wire = g_new(MsnP2PFooter, 1);
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
64
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
65 wire->value = GUINT32_TO_BE(footer->value);
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
66
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
67 return wire;
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
68 }
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
69