ptp4l: correct print global set functions
this patch updates the global set functions to allow the user to set the proper value instead of only being allowed to enable (or disable) a particular feature. The new patch allows the function to specify exactly what they want the value to be. This patch also clarifies what -q and -v do by removing mention of quiet mode and verbose mode. It is easy for a user to confuse and assume that -q disables -v when this is not true. Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>master
parent
df5c071599
commit
7c501032b2
4
pmc.c
4
pmc.c
|
@ -347,8 +347,8 @@ int main(int argc, char *argv[])
|
||||||
pollfd[1].fd = fdarray.fd[FD_GENERAL];
|
pollfd[1].fd = fdarray.fd[FD_GENERAL];
|
||||||
pollfd[1].events = POLLIN|POLLPRI;
|
pollfd[1].events = POLLIN|POLLPRI;
|
||||||
|
|
||||||
print_no_syslog();
|
print_set_syslog(1);
|
||||||
print_verbose();
|
print_set_verbose(1);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
cnt = poll(pollfd, N_FD, -1);
|
cnt = poll(pollfd, N_FD, -1);
|
||||||
|
|
10
print.c
10
print.c
|
@ -24,13 +24,13 @@
|
||||||
|
|
||||||
#include "print.h"
|
#include "print.h"
|
||||||
|
|
||||||
static int verbose;
|
static int verbose = 0;
|
||||||
static int print_level = LOG_INFO;
|
static int print_level = LOG_INFO;
|
||||||
static int use_syslog = 1;
|
static int use_syslog = 1;
|
||||||
|
|
||||||
void print_no_syslog(void)
|
void print_set_syslog(int value)
|
||||||
{
|
{
|
||||||
use_syslog = 0;
|
use_syslog = value ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_set_level(int level)
|
void print_set_level(int level)
|
||||||
|
@ -38,9 +38,9 @@ void print_set_level(int level)
|
||||||
print_level = level;
|
print_level = level;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_verbose(void)
|
void print_set_verbose(int value)
|
||||||
{
|
{
|
||||||
verbose = 1;
|
verbose = value ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print(int level, char const *format, ...)
|
void print(int level, char const *format, ...)
|
||||||
|
|
4
print.h
4
print.h
|
@ -24,9 +24,9 @@
|
||||||
|
|
||||||
void print(int level, char const *format, ...);
|
void print(int level, char const *format, ...);
|
||||||
|
|
||||||
void print_no_syslog(void);
|
void print_set_syslog(int value);
|
||||||
void print_set_level(int level);
|
void print_set_level(int level);
|
||||||
void print_verbose(void);
|
void print_set_verbose(int value);
|
||||||
|
|
||||||
#define pr_emerg(x...) print(LOG_EMERG, x)
|
#define pr_emerg(x...) print(LOG_EMERG, x)
|
||||||
#define pr_alert(x...) print(LOG_ALERT, x)
|
#define pr_alert(x...) print(LOG_ALERT, x)
|
||||||
|
|
8
ptp4l.c
8
ptp4l.c
|
@ -63,8 +63,8 @@ static void usage(char *progname)
|
||||||
" (ignored for SOFTWARE/LEGACY HW time stamping)\n"
|
" (ignored for SOFTWARE/LEGACY HW time stamping)\n"
|
||||||
" -s slave only mode (overrides configuration file)\n"
|
" -s slave only mode (overrides configuration file)\n"
|
||||||
" -l [num] set the logging level to 'num'\n"
|
" -l [num] set the logging level to 'num'\n"
|
||||||
" -q quiet mode, do not use syslog(3)\n"
|
" -q do not print messages to the syslog\n"
|
||||||
" -v verbose mode, print messages to stdout\n"
|
" -v print messages to stdout\n"
|
||||||
" -h prints this message and exits\n"
|
" -h prints this message and exits\n"
|
||||||
"\n",
|
"\n",
|
||||||
progname);
|
progname);
|
||||||
|
@ -137,10 +137,10 @@ int main(int argc, char *argv[])
|
||||||
print_set_level(atoi(optarg));
|
print_set_level(atoi(optarg));
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
print_no_syslog();
|
print_set_syslog(1);
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
print_verbose();
|
print_set_verbose(1);
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
usage(progname);
|
usage(progname);
|
||||||
|
|
Loading…
Reference in New Issue