From 0bbdda2c4e1c9f0dcd71d427d09e4e2aa4eef3f4 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Sun, 25 May 2014 11:07:01 +0100 Subject: [PATCH] Allow comments in config files. --- client/client_shared.c | 2 ++ man/mosquitto_pub.1.xml | 4 +++- man/mosquitto_sub.1.xml | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/client/client_shared.c b/client/client_shared.c index 8ebb2561..5b73bfe1 100644 --- a/client/client_shared.c +++ b/client/client_shared.c @@ -92,6 +92,8 @@ int client_config_load(struct mosq_config *cfg, int pub_or_sub, int argc, char * fptr = fopen(loc, "rt"); if(fptr){ while(fgets(line, 1024, fptr)){ + if(line[0] == '#') continue; /* Comments */ + while(line[strlen(line)-1] == 10 || line[strlen(line)-1] == 13){ line[strlen(line)-1] = 0; } diff --git a/man/mosquitto_pub.1.xml b/man/mosquitto_pub.1.xml index 73dd6b42..1e4a0368 100644 --- a/man/mosquitto_pub.1.xml +++ b/man/mosquitto_pub.1.xml @@ -89,7 +89,9 @@ and can be overridden by using the command line. The exceptions to this are the message type options, of which only one can be specified. Note also that currently some options cannot be negated, - e.g. . + e.g. . Config file lines that have a + as the first character are treated as comments + and not processed any further. diff --git a/man/mosquitto_sub.1.xml b/man/mosquitto_sub.1.xml index 7541d1ba..3e0370f0 100644 --- a/man/mosquitto_sub.1.xml +++ b/man/mosquitto_sub.1.xml @@ -89,7 +89,9 @@ this are and , which if given in the config file will not be overridden. Note also that currently some options cannot be negated, e.g. - . + . Config file lines that have a + as the first character are treated as comments + and not processed any further.