Switching to GPL 3.
[rsync/rsync.git] / io.h
1 /*
2  * Copyright (C) 2007 Wayne Davison
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 3 as
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
14  * with this program; if not, visit the http://fsf.org website.
15  */
16
17 extern int protocol_version;
18
19 static inline int32
20 read_varint30(int f)
21 {
22         if (protocol_version < 30)
23                 return read_int(f);
24         return read_varint(f);
25 }
26
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
35 static inline void
36 write_varint30(int f, int32 x)
37 {
38         if (protocol_version < 30)
39                 write_int(f, x);
40         else
41                 write_varint(f, x);
42 }
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 }