diff options
author | irungentoo <irungentoo@gmail.com> | 2013-07-02 09:53:34 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-07-02 09:53:34 -0400 |
commit | e2967396ac73cb7410787886cdaf072a184ffc49 (patch) | |
tree | 527a74d25a4a0705fc641994fd35bfab22662034 /nacl/curvecp/open_write.c | |
parent | 8928c817df345f29aa0b194743595aa11bd6a8ba (diff) |
Added NaCl crypto library.
Diffstat (limited to 'nacl/curvecp/open_write.c')
-rw-r--r-- | nacl/curvecp/open_write.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/nacl/curvecp/open_write.c b/nacl/curvecp/open_write.c new file mode 100644 index 00000000..e23752d1 --- /dev/null +++ b/nacl/curvecp/open_write.c | |||
@@ -0,0 +1,17 @@ | |||
1 | #include <sys/types.h> | ||
2 | #include <sys/stat.h> | ||
3 | #include <unistd.h> | ||
4 | #include <fcntl.h> | ||
5 | #include "open.h" | ||
6 | |||
7 | int open_write(const char *fn) | ||
8 | { | ||
9 | #ifdef O_CLOEXEC | ||
10 | return open(fn,O_CREAT | O_WRONLY | O_NONBLOCK | O_CLOEXEC,0644); | ||
11 | #else | ||
12 | int fd = open(fn,O_CREAT | O_WRONLY | O_NONBLOCK,0644); | ||
13 | if (fd == -1) return -1; | ||
14 | fcntl(fd,F_SETFD,1); | ||
15 | return fd; | ||
16 | #endif | ||
17 | } | ||