mbgtools-lx  4.2.8
mbgsvcd.c File Reference
#include <mbgdevio.h>
#include <pcpsutil.h>
#include <toolutil.h>
#include <mbgerror.h>
#include <pcpsmktm.h>
#include <chk_time_info.h>
#include <ntp_shm.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <syslog.h>
#include <stdarg.h>
#include <time.h>
#include <sys/ipc.h>
#include <sys/shm.h>

Go to the source code of this file.

Macros

#define RUNNING_DIR   "/var/run"
 
#define LOCK_FILE   "mbgsvcd.pid"
 
#define MBG_FIRST_COPYRIGHT_YEAR   2010
 
#define MBG_LAST_COPYRIGHT_YEAR   0
 

Functions

void mbg_log (int lvl, const char *fmt,...)
 
static int do_mbgsvctasks (void)
 
static void usage (void)
 
static void startup_daemon (void)
 
int main (int argc, char *argv[])
 

Variables

static const char * pname = "mbgsvcd"
 
static int foreground
 
static int quiet
 
static int pretend_sync
 
static int print_raw
 
static int sleep_intv = 1
 
static unsigned long trust_time_seconds
 
static int n_unit0 = 0
 
static int n_units = MAX_SHM_REFCLOCKS
 
static int frac_digits = 9
 
MBG_PC_CYCLES_FREQUENCY cyc_freq
 Must be set up tby the application. More...
 
static struct shmTimeshmTime [MAX_SHM_REFCLOCKS]
 
static CYCLES_FILTER_DATA filter [MAX_SHM_REFCLOCKS]
 
static int has_synced_after_reset [MAX_SHM_REFCLOCKS] = { 0 }
 
static long int ref_trust_time_start [MAX_SHM_REFCLOCKS] = { 0 }
 
static long int ref_trust_time_expire [MAX_SHM_REFCLOCKS] = { 0 }
 

Macro Definition Documentation

◆ LOCK_FILE

#define LOCK_FILE   "mbgsvcd.pid"

Definition at line 76 of file mbgsvcd.c.

Referenced by startup_daemon().

◆ MBG_FIRST_COPYRIGHT_YEAR

#define MBG_FIRST_COPYRIGHT_YEAR   2010

Definition at line 78 of file mbgsvcd.c.

Referenced by main().

◆ MBG_LAST_COPYRIGHT_YEAR

#define MBG_LAST_COPYRIGHT_YEAR   0

Definition at line 79 of file mbgsvcd.c.

Referenced by main().

◆ RUNNING_DIR

#define RUNNING_DIR   "/var/run"

Definition at line 75 of file mbgsvcd.c.

Referenced by startup_daemon().

Function Documentation

◆ do_mbgsvctasks()

◆ main()

◆ mbg_log()

void mbg_log ( int  lvl,
const char *  fmt,
  ... 
)

Definition at line 106 of file mbgsvcd.c.

Referenced by do_mbgsvctasks(), main(), and startup_daemon().

◆ startup_daemon()

static void startup_daemon ( void  )
static

Definition at line 339 of file mbgsvcd.c.

References LOCK_FILE, mbg_log(), and RUNNING_DIR.

Referenced by main().

◆ usage()

static void usage ( void  )
static

Variable Documentation

◆ cyc_freq

Must be set up tby the application.

Definition at line 93 of file mbgsvcd.c.

Referenced by do_mbgsvctasks(), get_htc_delta(), mbg_chk_time_info(), and snprint_chk_time_info().

◆ filter

Definition at line 97 of file mbgsvcd.c.

◆ foreground

int foreground
static

Definition at line 83 of file mbgsvcd.c.

Referenced by main().

◆ frac_digits

int frac_digits = 9
static

Definition at line 91 of file mbgsvcd.c.

Referenced by do_mbgsvctasks().

◆ has_synced_after_reset

int has_synced_after_reset[MAX_SHM_REFCLOCKS] = { 0 }
static

Definition at line 99 of file mbgsvcd.c.

Referenced by do_mbgsvctasks().

◆ n_unit0

int n_unit0 = 0
static

Definition at line 89 of file mbgsvcd.c.

Referenced by do_mbgsvctasks(), main(), and ntpshm_init().

◆ n_units

int n_units = MAX_SHM_REFCLOCKS
static

Definition at line 90 of file mbgsvcd.c.

Referenced by do_mbgsvctasks(), main(), and ntpshm_init().

◆ pname

const char* pname = "mbgsvcd"
static

Definition at line 81 of file mbgsvcd.c.

Referenced by main(), and usage().

◆ pretend_sync

int pretend_sync
static

Definition at line 85 of file mbgsvcd.c.

Referenced by do_mbgsvctasks(), and main().

◆ print_raw

int print_raw
static

Definition at line 86 of file mbgsvcd.c.

Referenced by do_mbgsvctasks(), and main().

◆ quiet

int quiet
static

Definition at line 84 of file mbgsvcd.c.

Referenced by do_mbgsvctasks(), and main().

◆ ref_trust_time_expire

long int ref_trust_time_expire[MAX_SHM_REFCLOCKS] = { 0 }
static

Definition at line 101 of file mbgsvcd.c.

Referenced by do_mbgsvctasks().

◆ ref_trust_time_start

long int ref_trust_time_start[MAX_SHM_REFCLOCKS] = { 0 }
static

Definition at line 100 of file mbgsvcd.c.

Referenced by do_mbgsvctasks().

◆ shmTime

Definition at line 96 of file mbgsvcd.c.

◆ sleep_intv

int sleep_intv = 1
static

Definition at line 87 of file mbgsvcd.c.

Referenced by do_mbgsvctasks(), and main().

◆ trust_time_seconds

unsigned long trust_time_seconds
static

Definition at line 88 of file mbgsvcd.c.

Referenced by do_mbgsvctasks(), and main().