summaryrefslogtreecommitdiff
path: root/src/open.c
blob: bb33813106f43fb26527e7d299d7ec2cf04954f7 (plain)
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
#include "open.h"

#include <fcntl.h>
#include <sys/types.h>

/**
  @file open.c
  @author djb
  @ref qmail
  @brief open a file
*/

int open_append(const char *fn)
{
  return open(fn, O_WRONLY | O_NDELAY | O_APPEND | O_CREAT, 0600);
}

int open_excl(const char *fn)
{
  return open(fn, O_WRONLY | O_EXCL | O_CREAT, 0644);
}

int open_read(const char *fn)
{
  return open(fn, O_RDONLY | O_NDELAY);
}

int open_trunc(const char *fn)
{
  return open(fn, O_WRONLY | O_NDELAY | O_TRUNC | O_CREAT, 0644);
}

int open_write(const char *fn)
{
  return open(fn, O_WRONLY | O_NDELAY);
}