c9e79426f5c27ebf621367ce24b1c073c4e97e23
[paraslash.git] / fd.h
1 /* Copyright (C) 2006 Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */
2
3 /** \file fd.h exported symbols from fd.c */
4
5 int xrename(const char *oldpath, const char *newpath);
6 int write_all(int fd, const char *buf, size_t len);
7 __printf_2_3 int write_va_buffer(int fd, const char *fmt, ...);
8 bool file_exists(const char *);
9 int para_select(int n, fd_set *readfds, fd_set *writefds,
10                 struct timeval *timeout_tv);
11 __must_check int mark_fd_nonblocking(int fd);
12 __must_check int mark_fd_blocking(int fd);
13 void para_fd_set(int fd, fd_set *fds, int *max_fileno);
14 int para_mmap(size_t length, int prot, int flags, int fd, void *map);
15 int para_open(const char *path, int flags, mode_t mode);
16 int para_mkdir(const char *path, mode_t mode);
17 int para_chdir(const char *path);
18 int mmap_full_file(const char *filename, int open_mode, void **map,
19         size_t *size, int *fd_ptr);
20 int para_munmap(void *start, size_t length);
21 int write_ok(int fd);
22 void valid_fd_012(void);
23 int readv_nonblock(int fd, struct iovec *iov, int iovcnt, fd_set *rfds,
24                 size_t *num_bytes);
25 int read_nonblock(int fd, void *buf, size_t sz, fd_set *rfds, size_t *num_bytes);
26 int read_pattern(int fd, const char *pattern, size_t bufsize, fd_set *rfds);
27 int xwrite(int fd, const char *buf, size_t len);
28 int xwritev(int fd, struct iovec *iov, int iovcnt);
29 int for_each_file_in_dir(const char *dirname,
30                 int (*func)(const char *, void *), void *private_data);
31 /**
32  * Write a \p NULL-terminated buffer.
33  *
34  * \param fd The file descriptor.
35  * \param buf The null-terminated buffer to be send.
36  *
37  * This is equivalent to write_all(fd, buf, strlen(buf)).
38  *
39  * \return Standard.
40  */
41 _static_inline_ int write_buffer(int fd, const char *buf)
42 {
43         return write_all(fd, buf, strlen(buf));
44 }