Commit | Line | Data |
---|---|---|
6d4e718f WD |
1 | /* |
2 | * Copyright (C) 2007 Wayne Davison | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
4fd842f9 | 5 | * it under the terms of the GNU General Public License version 3 as |
6d4e718f WD |
6 | * published by the Free Software Foundation. |
7 | * | |
8 | * This program is distributed in the hope that it will be useful, | |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | * GNU General Public License for more details. | |
12 | * | |
13 | * You should have received a copy of the GNU General Public License along | |
4fd842f9 | 14 | * with this program; if not, visit the http://fsf.org website. |
6d4e718f WD |
15 | */ |
16 | ||
17 | extern int protocol_version; | |
18 | ||
19 | static inline int32 | |
f31514ad | 20 | read_varint30(int f) |
6d4e718f WD |
21 | { |
22 | if (protocol_version < 30) | |
23 | return read_int(f); | |
f31514ad | 24 | return read_varint(f); |
6d4e718f WD |
25 | } |
26 | ||
473feecf WD |
27 | static inline int64 |
28 | read_varlong30(int f, uchar min_bytes) | |
29 | { | |
30 | if (protocol_version < 30) | |
31 | return read_longint(f); | |
32 | return read_varlong(f, min_bytes); | |
33 | } | |
34 | ||
6d4e718f | 35 | static inline void |
f31514ad | 36 | write_varint30(int f, int32 x) |
6d4e718f WD |
37 | { |
38 | if (protocol_version < 30) | |
39 | write_int(f, x); | |
40 | else | |
f31514ad | 41 | write_varint(f, x); |
6d4e718f | 42 | } |
473feecf WD |
43 | |
44 | static inline void | |
45 | write_varlong30(int f, int64 x, uchar min_bytes) | |
46 | { | |
47 | if (protocol_version < 30) | |
48 | write_longint(f, x); | |
49 | else | |
50 | write_varlong(f, x, min_bytes); | |
51 | } |