diff options
author | Tilo Eckert <tilo.eckert@flam.de> | 2015-07-22 15:24:14 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2015-07-30 10:47:34 +0200 |
commit | 71d86be42ec5ba4217cebaea1b65bd169c77f3ce (patch) | |
tree | 3d57e5f322ca32b0da40733b69d7e0f2f4af1766 | |
parent | 267fe0208814898e1dff5dd401cbb049ebb9a2f5 (diff) | |
download | libssh-71d86be42ec5ba4217cebaea1b65bd169c77f3ce.tar.gz libssh-71d86be42ec5ba4217cebaea1b65bd169c77f3ce.tar.xz libssh-71d86be42ec5ba4217cebaea1b65bd169c77f3ce.zip |
define our own platform-independent S_IF macros
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r-- | include/libssh/sftp.h | 10 | ||||
-rw-r--r-- | src/sftp.c | 40 |
2 files changed, 26 insertions, 24 deletions
diff --git a/include/libssh/sftp.h b/include/libssh/sftp.h index 8fb8f116..6620841b 100644 --- a/include/libssh/sftp.h +++ b/include/libssh/sftp.h @@ -962,6 +962,16 @@ void sftp_handle_remove(sftp_session sftp, void *handle); #define SSH_FXF_EXCL 0x20 #define SSH_FXF_TEXT 0x40 +/* file type flags */ +#define SSH_S_IFMT 00170000 +#define SSH_S_IFSOCK 0140000 +#define SSH_S_IFLNK 0120000 +#define SSH_S_IFREG 0100000 +#define SSH_S_IFBLK 0060000 +#define SSH_S_IFDIR 0040000 +#define SSH_S_IFCHR 0020000 +#define SSH_S_IFIFO 0010000 + /* rename flags */ #define SSH_FXF_RENAME_OVERWRITE 0x00000001 #define SSH_FXF_RENAME_ATOMIC 0x00000002 @@ -38,14 +38,6 @@ #ifndef _WIN32 #include <netinet/in.h> #include <arpa/inet.h> -#else -#define S_IFSOCK 0140000 -#define S_IFLNK 0120000 - -#ifdef _MSC_VER -#define S_IFBLK 0060000 -#define S_IFIFO 0010000 -#endif #endif #include "libssh/priv.h" @@ -1008,20 +1000,20 @@ static sftp_attributes sftp_parse_attr_4(sftp_session sftp, ssh_buffer buf, attr->permissions = ntohl(attr->permissions); /* FIXME on windows! */ - switch (attr->permissions & S_IFMT) { - case S_IFSOCK: - case S_IFBLK: - case S_IFCHR: - case S_IFIFO: + switch (attr->permissions & SSH_S_IFMT) { + case SSH_S_IFSOCK: + case SSH_S_IFBLK: + case SSH_S_IFCHR: + case SSH_S_IFIFO: attr->type = SSH_FILEXFER_TYPE_SPECIAL; break; - case S_IFLNK: + case SSH_S_IFLNK: attr->type = SSH_FILEXFER_TYPE_SYMLINK; break; - case S_IFREG: + case SSH_S_IFREG: attr->type = SSH_FILEXFER_TYPE_REGULAR; break; - case S_IFDIR: + case SSH_S_IFDIR: attr->type = SSH_FILEXFER_TYPE_DIRECTORY; break; default: @@ -1244,20 +1236,20 @@ static sftp_attributes sftp_parse_attr_3(sftp_session sftp, ssh_buffer buf, goto error; } - switch (attr->permissions & S_IFMT) { - case S_IFSOCK: - case S_IFBLK: - case S_IFCHR: - case S_IFIFO: + switch (attr->permissions & SSH_S_IFMT) { + case SSH_S_IFSOCK: + case SSH_S_IFBLK: + case SSH_S_IFCHR: + case SSH_S_IFIFO: attr->type = SSH_FILEXFER_TYPE_SPECIAL; break; - case S_IFLNK: + case SSH_S_IFLNK: attr->type = SSH_FILEXFER_TYPE_SYMLINK; break; - case S_IFREG: + case SSH_S_IFREG: attr->type = SSH_FILEXFER_TYPE_REGULAR; break; - case S_IFDIR: + case SSH_S_IFDIR: attr->type = SSH_FILEXFER_TYPE_DIRECTORY; break; default: |