Commit | Line | Data |
---|---|---|
791c0056 GB |
1 | /* Remote File-I/O communications |
2 | ||
3 | Copyright (C) 2003-2015 Free Software Foundation, Inc. | |
4 | ||
5 | This file is part of GDB. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 3 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
19 | ||
20 | #ifndef COMMON_REMOTE_FILEIO_H | |
21 | #define COMMON_REMOTE_FILEIO_H | |
22 | ||
23 | #include "gdb/fileio.h" | |
7f3647e2 | 24 | #include <sys/stat.h> |
791c0056 GB |
25 | |
26 | /* Pack a host-format integer into a byte buffer in big-endian format | |
27 | ready for transmission over the remote protocol. BYTES specifies | |
28 | the size of the integer to pack in bytes. */ | |
29 | ||
30 | static inline void | |
31 | remote_fileio_to_be (LONGEST num, char *buf, int bytes) | |
32 | { | |
33 | int i; | |
34 | ||
35 | for (i = 0; i < bytes; ++i) | |
36 | buf[i] = (num >> (8 * (bytes - i - 1))) & 0xff; | |
37 | } | |
38 | ||
39 | /* Pack a host-format integer into an fio_uint_t. */ | |
40 | ||
41 | static inline void | |
42 | remote_fileio_to_fio_uint (long num, fio_uint_t fnum) | |
43 | { | |
44 | remote_fileio_to_be ((LONGEST) num, (char *) fnum, 4); | |
45 | } | |
46 | ||
47 | /* Pack a host-format time_t into an fio_time_t. */ | |
48 | ||
49 | static inline void | |
50 | remote_fileio_to_fio_time (time_t num, fio_time_t fnum) | |
51 | { | |
52 | remote_fileio_to_be ((LONGEST) num, (char *) fnum, 4); | |
53 | } | |
54 | ||
55 | /* Pack a host-format struct stat into a struct fio_stat. */ | |
56 | ||
57 | extern void remote_fileio_to_fio_stat (struct stat *st, | |
58 | struct fio_stat *fst); | |
59 | ||
60 | #endif /* COMMON_REMOTE_FILEIO_H */ |