ptp4l: ignore empty lines and comments in config.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>master
parent
1a83619b17
commit
ff547aeebb
15
config.c
15
config.c
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "ether.h"
|
#include "ether.h"
|
||||||
#include "print.h"
|
#include "print.h"
|
||||||
|
@ -318,7 +319,7 @@ int config_read(char *name, struct config *cfg)
|
||||||
{
|
{
|
||||||
enum config_section current_section = GLOBAL_SECTION;
|
enum config_section current_section = GLOBAL_SECTION;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char line[1024];
|
char buf[1024], *line;
|
||||||
int current_port;
|
int current_port;
|
||||||
|
|
||||||
fp = 0 == strncmp(name, "-", 2) ? stdin : fopen(name, "r");
|
fp = 0 == strncmp(name, "-", 2) ? stdin : fopen(name, "r");
|
||||||
|
@ -328,7 +329,17 @@ int config_read(char *name, struct config *cfg)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (fgets(line, sizeof(line), fp)) {
|
while (fgets(buf, sizeof(buf), fp)) {
|
||||||
|
line = buf;
|
||||||
|
|
||||||
|
/* skip whitespace characters */
|
||||||
|
while (isspace(line[0]))
|
||||||
|
line++;
|
||||||
|
|
||||||
|
/* ignore empty lines and comments */
|
||||||
|
if (line[0] == '#' || line[0] == '\n' || line[0] == '\0')
|
||||||
|
continue;
|
||||||
|
|
||||||
if (scan_mode(line, ¤t_section) ) {
|
if (scan_mode(line, ¤t_section) ) {
|
||||||
if (current_section == PORT_SECTION) {
|
if (current_section == PORT_SECTION) {
|
||||||
char port[17];
|
char port[17];
|
||||||
|
|
3
ptp4l.8
3
ptp4l.8
|
@ -113,7 +113,8 @@ Display a help message.
|
||||||
The configuration file is divided into sections. Each section starts with a
|
The configuration file is divided into sections. Each section starts with a
|
||||||
line containing its name enclosed in brackets and it follows with settings.
|
line containing its name enclosed in brackets and it follows with settings.
|
||||||
Each setting is placed on a separate line, it contains the name of the
|
Each setting is placed on a separate line, it contains the name of the
|
||||||
option and the value separated by whitespace characters.
|
option and the value separated by whitespace characters. Empty lines and lines
|
||||||
|
starting with # are ignored.
|
||||||
|
|
||||||
The global section (indicated as
|
The global section (indicated as
|
||||||
.BR [global] )
|
.BR [global] )
|
||||||
|
|
Loading…
Reference in New Issue