# Core
#
SRCS = src/main.c \
+ src/wrappers.c \
src/version.c \
src/access.c \
src/dtable.c \
</center>
Tvheadend is part of the <b>HTS</b> project hosted at
-<a href="%%_SITEROOT_%%">%%_SITEROOT_%%</a>
+<a href="http://www.lonelycoder.com/hts">http://www.lonelycoder.com/hts</a>
<p>
It functions primarily as a TV streaming backend for the Showtime Mediaplayer but
can be used standalone for other purposes, such as a Digital Video Recorder.
snprintf(fname, sizeof(fname), "%s/frontend0", path);
- fe = open(fname, O_RDWR | O_NONBLOCK);
+ fe = tvh_open(fname, O_RDWR | O_NONBLOCK, 0);
if(fe == -1) {
if(errno != ENOENT)
tvhlog(LOG_ALERT, "dvb",
uint8_t tsb[188 * 10];
th_transport_t *t;
- fd = open(tda->tda_dvr_path, O_RDONLY);
+ fd = tvh_open(tda->tda_dvr_path, O_RDONLY, 0);
if(fd == -1) {
tvhlog(LOG_ALERT, "dvb", "%s: unable to open dvr", tda->tda_dvr_path);
return NULL;
assert(tdt->tdt_fd == -1);
TAILQ_REMOVE(&tdmi->tdmi_table_queue, tdt, tdt_pending_link);
- tdt->tdt_fd = open(tda->tda_demux_path, O_RDWR);
+ tdt->tdt_fd = tvh_open(tda->tda_demux_path, O_RDWR, 0);
if(tdt->tdt_fd != -1) {
if(st->st_demuxer_fd != -1)
continue;
- fd = open(tda->tda_demux_path, O_RDWR);
+ fd = tvh_open(tda->tda_demux_path, O_RDWR, 0);
st->st_cc_valid = 0;
if(fd == -1) {
{
int fd, n;
- if((fd = open("/dev/urandom", O_RDONLY)) < 0)
+ if((fd = tvh_open("/dev/urandom", O_RDONLY, 0)) < 0)
return -1;
n = read(fd, &htsp->htsp_challenge, 32);
{
pthread_t ptid;
rawts_t *rt;
- int fd = open(filename, O_RDONLY);
+ int fd = tvh_open(filename, O_RDONLY, 0);
if(fd == -1) {
fprintf(stderr, "Unable to open %s -- %s\n", filename, strerror(errno));
{
int fd, n;
- if((fd = open("/dev/urandom", O_RDONLY)) < 0)
+ if((fd = tvh_open("/dev/urandom", O_RDONLY, 0)) < 0)
return -1;
n = read(fd, r, 32);
snprintf(fullpath, sizeof(fullpath), "%s/%s.tmp", settingspath, path);
- if((fd = open(fullpath, O_CREAT | O_TRUNC | O_RDWR, 0700)) < 0) {
+ if((fd = tvh_open(fullpath, O_CREAT | O_TRUNC | O_RDWR, 0700)) < 0) {
tvhlog(LOG_ALERT, "settings", "Unable to create \"%s\" - %s",
fullpath, strerror(errno));
return;
if(stat(filename, &st) < 0)
return NULL;
- if((fd = open(filename, O_RDONLY)) < 0)
+ if((fd = tvh_open(filename, O_RDONLY, 0)) < 0)
return NULL;
mem = malloc(st.st_size + 1);
#define tvh_strlcatf(buf, size, fmt...) \
snprintf((buf) + strlen(buf), (size) - strlen(buf), fmt)
+int tvh_open(const char *pathname, int flags, mode_t mode);
+
#endif /* TV_HEAD_H */
if(va->va_current_transport != NULL)
return 1; // Adapter busy
- fd = open(va->va_path, O_RDWR | O_NONBLOCK);
+ fd = tvh_open(va->va_path, O_RDWR | O_NONBLOCK, 0);
if(fd == -1) {
tvhlog(LOG_ERR, "v4l",
"%s: Unable to open device: %s\n", va->va_path,
{
int fd;
- fd = open(path, O_RDWR | O_NONBLOCK);
+ fd = tvh_open(path, O_RDWR | O_NONBLOCK, 0);
if(fd == -1) {
if(errno != ENOENT)
snprintf(path, sizeof(path), "%s/%s", base, remain);
- if((fd = open(path, O_RDONLY)) < 0) {
+ if((fd = open(path, O_RDONLY | O_CLOEXEC)) < 0) {
tvhlog(LOG_ERR, "webui",
"Unable to open file %s -- %s", path, strerror(errno));
return 404;
content = "video/x-matroska";
}
- fd = open(fname, O_RDONLY);
+ fd = open(fname, O_RDONLY | O_CLOEXEC);
free(fname);
if(fd < 0)
return 404;
--- /dev/null
+#define _GNU_SOURCE
+#include <fcntl.h>
+#include "tvhead.h"
+
+int
+tvh_open(const char *pathname, int flags, mode_t mode)
+{
+ return open(pathname, flags | O_CLOEXEC, mode);
+}