/* See LICENSE file for copyright and license details. */ #include "common.h" #ifndef TEST struct liblog_output * liblog_use_file_for_range(struct liblog_context *ctx, int dirfd, const char *path, const char *prefixfmt, int use_backtrace, enum liblog_level least_verbose, enum liblog_level most_verbose) { struct liblog_output *ret; int fd; if (!path || !*path) return liblog_use_fd_for_range(ctx, dirfd, prefixfmt, use_backtrace, least_verbose, most_verbose); if (dirfd == -1 && *path != '/') { errno = EINVAL; return NULL; } fd = openat(dirfd, path, O_WRONLY | O_CREAT | O_APPEND, 0644); if (fd < 0) return NULL; ret = liblog_use_fd_for_range(ctx, fd, prefixfmt, use_backtrace, least_verbose, most_verbose); if (!ret) { close(fd); return NULL; } ret->sink.file.owns_fd = 1; return ret; } #else int main(void) {return 0;} /* TODO test */ #endif