vdr 2.7.2
runvdr.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <ctype.h>
#include <signal.h>
#include <errno.h>
#include <time.h>
#include <syslog.h>
#include <grp.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <dirent.h>
#include <sys/param.h>
#include <sys/wait.h>
#include <unistd.h>
#include <pwd.h>

Go to the source code of this file.

Classes

struct  List
 

Macros

#define _GNU_SOURCE
 
#define PIDFILE   "/var/run/vdr.pid"
 
#define VDRBIN   "/usr/bin/vdr"
 
#define errmsg(reason, ...)
 
#define errno_msg(reason, ...)
 
#define _errno_msg(reason, ...)
 
#define errno_log(reason, ...)
 
#define _errno_log(reason, ...)
 
#define errexit(fn, reason, ...)
 
#define _errexit(fn, reason, ...)
 
#define BASEMOD   (budget ? mod_budget : mod_dvb)
 
#define NUM_STOPTIMES   5
 

Functions

static int dowait (int which)
 
static void sig_quit (int sig)
 
static void sig_propagate (int sig)
 
static void sig_default (int sig)
 
static char * parse_modules_24 (char *line, int budget)
 
static char * parse_modules_26 (char *line, int budget)
 
static const char * getenv_default (const char *var, const char *dflt)
 
static void list_append (List *list, const char *item)
 
static void list_free (List *list)
 
static size_t list_find (List *list, const char *cmp)
 
static void list_remove (List *list, size_t index)
 
static void scan_plugins (List *args)
 
static void pidfile_write (void)
 
static void pidfile_remove (void)
 
int main (int argc, char *argv[])
 

Variables

static const char * progname
 
static const char mod_dvb [] = "dvb-core\0\0"
 
static const char mod_budget [] = "budget-core\0\0"
 
static time_t stoptimes [NUM_STOPTIMES]
 
static size_t stoptimecount = 0
 
static volatile int usr1 = 0
 
static pid_t vdr = 0
 

Macro Definition Documentation

◆ _errexit

#define _errexit ( fn,
reason,
... )
Value:
do { if ((fn) == -1) { _errno_msg (reason, ## __VA_ARGS__); } } while (0)
#define _errno_msg(reason,...)
Definition runvdr.c:63

Definition at line 88 of file runvdr.c.

Referenced by scan_plugins().

◆ _errno_log

#define _errno_log ( reason,
... )
Value:
do { \
int err = errno; \
fprintf (stderr, "%s: " reason ": %s\n", progname, ## __VA_ARGS__, strerror (err)); \
syslog (LOG_ERR, reason ": %s", ## __VA_ARGS__, strerror (err)); \
_exit (2); \
} while (0)
static const char * progname
Definition runvdr.c:92

Definition at line 77 of file runvdr.c.

Referenced by main().

◆ _errno_msg

#define _errno_msg ( reason,
... )
Value:
do { \
fprintf (stderr, "%s: " reason ": %s\n", progname, ## __VA_ARGS__, strerror (errno)); \
_exit (2); \
} while (0)

Definition at line 63 of file runvdr.c.

Referenced by scan_plugins().

◆ _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 28 of file runvdr.c.

◆ BASEMOD

#define BASEMOD   (budget ? mod_budget : mod_dvb)

Definition at line 96 of file runvdr.c.

Referenced by parse_modules_24(), and parse_modules_26().

◆ errexit

#define errexit ( fn,
reason,
... )
Value:
do { if ((fn) == -1) { errno_msg (reason, ## __VA_ARGS__); } } while (0)
#define errno_msg(reason,...)
Definition runvdr.c:57

Definition at line 85 of file runvdr.c.

Referenced by main(), parse_modules_24(), parse_modules_26(), and scan_plugins().

◆ errmsg

#define errmsg ( reason,
... )
Value:
do { \
fprintf (stderr, "%s: " reason "\n", progname, ## __VA_ARGS__); \
exit (1); \
} while (0)

Definition at line 51 of file runvdr.c.

Referenced by list_append(), main(), pidfile_write(), and scan_plugins().

◆ errno_log

#define errno_log ( reason,
... )
Value:
do { \
int err = errno; \
fprintf (stderr, "%s: " reason ": %s\n", progname, ## __VA_ARGS__, strerror (err)); \
syslog (LOG_ERR, reason ": %s", ## __VA_ARGS__, strerror (err)); \
exit (2); \
} while (0)

Definition at line 69 of file runvdr.c.

Referenced by main().

◆ errno_msg

#define errno_msg ( reason,
... )
Value:
do { \
fprintf (stderr, "%s: " reason ": %s\n", progname, ## __VA_ARGS__, strerror (errno)); \
exit (2); \
} while (0)

Definition at line 57 of file runvdr.c.

Referenced by dowait(), main(), pidfile_write(), and scan_plugins().

◆ NUM_STOPTIMES

#define NUM_STOPTIMES   5

Definition at line 98 of file runvdr.c.

Referenced by main().

◆ PIDFILE

#define PIDFILE   "/var/run/vdr.pid"

Definition at line 48 of file runvdr.c.

Referenced by pidfile_remove(), and pidfile_write().

◆ VDRBIN

#define VDRBIN   "/usr/bin/vdr"

Definition at line 49 of file runvdr.c.

Referenced by main().

Function Documentation

◆ dowait()

static int dowait ( int which)
static

Definition at line 114 of file runvdr.c.

References errno_msg.

Referenced by main(), scan_plugins(), and sig_quit().

◆ getenv_default()

static const char * getenv_default ( const char * var,
const char * dflt )
static

Definition at line 217 of file runvdr.c.

Referenced by scan_plugins().

◆ list_append()

static void list_append ( List * list,
const char * item )
static

Definition at line 225 of file runvdr.c.

References errmsg, List::items, and List::length.

Referenced by main(), and scan_plugins().

◆ list_find()

static size_t list_find ( List * list,
const char * cmp )
static

Definition at line 256 of file runvdr.c.

References List::items, and List::length.

Referenced by scan_plugins().

◆ list_free()

static void list_free ( List * list)
static

Definition at line 238 of file runvdr.c.

References List::items, and List::length.

Referenced by main(), and scan_plugins().

◆ list_remove()

static void list_remove ( List * list,
size_t index )
static

Definition at line 268 of file runvdr.c.

References List::items, and List::length.

Referenced by scan_plugins().

◆ main()

◆ parse_modules_24()

static char * parse_modules_24 ( char * line,
int budget )
static

Definition at line 170 of file runvdr.c.

References BASEMOD, and errexit.

Referenced by main().

◆ parse_modules_26()

static char * parse_modules_26 ( char * line,
int budget )
static

Definition at line 191 of file runvdr.c.

References BASEMOD, and errexit.

Referenced by main().

◆ pidfile_remove()

static void pidfile_remove ( void )
static

Definition at line 531 of file runvdr.c.

References PIDFILE, and progname.

Referenced by main().

◆ pidfile_write()

static void pidfile_write ( void )
static

Definition at line 513 of file runvdr.c.

References errmsg, errno_msg, and PIDFILE.

Referenced by main().

◆ scan_plugins()

static void scan_plugins ( List * args)
static

◆ sig_default()

static void sig_default ( int sig)
static

Definition at line 163 of file runvdr.c.

References sig_default().

Referenced by main(), and sig_default().

◆ sig_propagate()

static void sig_propagate ( int sig)
static

Definition at line 152 of file runvdr.c.

References sig_propagate(), usr1, and vdr.

Referenced by main(), and sig_propagate().

◆ sig_quit()

static void sig_quit ( int sig)
static

Definition at line 139 of file runvdr.c.

References dowait(), and vdr.

Referenced by main().

Variable Documentation

◆ mod_budget

const char mod_budget[] = "budget-core\0\0"
static

Definition at line 95 of file runvdr.c.

◆ mod_dvb

const char mod_dvb[] = "dvb-core\0\0"
static

Definition at line 94 of file runvdr.c.

◆ progname

const char* progname
static

Definition at line 92 of file runvdr.c.

Referenced by main(), and pidfile_remove().

◆ stoptimecount

size_t stoptimecount = 0
static

Definition at line 100 of file runvdr.c.

Referenced by main().

◆ stoptimes

time_t stoptimes[NUM_STOPTIMES]
static

Definition at line 99 of file runvdr.c.

Referenced by main().

◆ usr1

volatile int usr1 = 0
static

Definition at line 102 of file runvdr.c.

Referenced by main(), and sig_propagate().

◆ vdr

pid_t vdr = 0
static

Definition at line 104 of file runvdr.c.

Referenced by main(), sig_propagate(), and sig_quit().