Created
November 15, 2016 21:45
-
-
Save enkore/ec4de5326b34716de1dee208e058d85d to your computer and use it in GitHub Desktop.
SFTP open flags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static int | |
flags_from_portable(int pflags) | |
{ | |
int flags = 0; | |
if ((pflags & SSH2_FXF_READ) && | |
(pflags & SSH2_FXF_WRITE)) { | |
flags = O_RDWR; | |
} else if (pflags & SSH2_FXF_READ) { | |
flags = O_RDONLY; | |
} else if (pflags & SSH2_FXF_WRITE) { | |
flags = O_WRONLY; | |
} | |
if (pflags & SSH2_FXF_APPEND) | |
flags |= O_APPEND; | |
if (pflags & SSH2_FXF_CREAT) | |
flags |= O_CREAT; | |
if (pflags & SSH2_FXF_TRUNC) | |
flags |= O_TRUNC; | |
if (pflags & SSH2_FXF_EXCL) | |
flags |= O_EXCL; | |
return flags; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment