-
Notifications
You must be signed in to change notification settings - Fork 18
/
sftpcommon.h
122 lines (105 loc) · 3.5 KB
/
sftpcommon.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
* This file is part of the Green End SFTP Server.
* Copyright (C) 2007, 2011, 2014 Richard Kettlewell
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*/
#ifndef SFTPCOMMON_H
# define SFTPCOMMON_H
/** @file sftpcommon.h @brief Common definitions */
# include <config.h>
# include <inttypes.h>
# include <sys/types.h>
# if HAVE_ENDIAN_H
# include <endian.h>
# endif
# ifndef ASM
# define ASM 1
# endif
# if __GNUC__ && __amd64__ && ASM
/** @brief Byte-swap a 64-bit value */
# define BSWAP64(N) \
({ \
uint64_t __n = (N); \
__asm__("bswap %0" : "+q"(__n)); \
__n; \
})
# endif
# if __GNUC__ && !defined BSWAP64
/** @brief Byte-swap a 64-bit value */
# define BSWAP64(N) \
({ \
uint64_t __n = (N); \
__n = ntohl(__n >> 32) | ((uint64_t)ntohl(__n) << 32); \
__n; \
})
# endif
# if WORDS_BIGENDIAN
/** @brief Convert a 64-bit value to network byte order */
# define NTOHLL(n) (n)
/** @brief Convert a 64-bit value to host byte order */
# define HTONLL(n) (n)
# endif
# if HAVE_DECL_BE64TOH && !defined NTOHLL
/** @brief Convert a 64-bit value to network byte order */
# define NTOHLL be64toh
# endif
# if HAVE_DECL_HTOBE64 && !defined HTONLL
/** @brief Convert a 64-bit value to host byte order */
# define HTONLL htobe64
# endif
# if defined BSWAP64 && !defined NTOHLL
/** @brief Convert a 64-bit value to network byte order */
# define NTOHLL BSWAP64
# endif
# if defined BSWAP64 && !defined HTONLL
/** @brief Convert a 64-bit value to host byte order */
# define HTONLL BSWAP64
# endif
struct queue;
struct allocator;
struct handleid;
struct sftpjob;
struct sftpattr;
struct worker;
struct stat;
/** @brief Return a human-readable description of @p status
* @param status SFTP status code
* @return Human-readable string
*/
const char *status_to_string(uint32_t status);
/** @brief Possible SFTP service states */
enum sftp_state {
sftp_state_run = 0,
sftp_state_stop = 1,
};
/** @brief Get the current SFTP service state
* @return State value
*/
enum sftp_state sftp_state_get(void);
/** @brief Set the SFTP service state
* @param s New state value
*/
void sftp_state_set(enum sftp_state s);
#endif /* SFTPCOMMON_H */
/*
Local Variables:
c-basic-offset:2
comment-column:40
fill-column:79
indent-tabs-mode:nil
End:
*/