Diff between a8025ef8edc0d27ac47f3feaa28a5fdd66513e0f and d50d267b6190cc4c12215e6afdcb333879d733bf

Changed Files

File Additions Deletions Status
src/main.c +52 -0 modified

Full Patch

diff --git a/src/main.c b/src/main.c
index 81f348f..403fe69 100644
--- a/src/main.c
+++ b/src/main.c
@@ -66,6 +66,20 @@
 
 struct main_opts main_opts;
 
+static const char * const supported_options[] = {
+	"Name",
+	"DisablePlugins",
+	"Class",
+	"DiscoverableTimeout",
+	"PairableTimeout",
+	"PageTimeout",
+	"AutoConnectTimeout",
+	"DeviceID",
+	"ReverseServiceDiscovery",
+	"NameResolving",
+	"DebugKeys",
+};
+
 static GKeyFile *load_config(const char *file)
 {
 	GError *err = NULL;
@@ -115,6 +129,42 @@ done:
 	main_opts.did_version = version;
 }
 
+static void check_config(GKeyFile *config)
+{
+	char **keys;
+	int i;
+
+	if (!config)
+		return;
+
+	keys = g_key_file_get_groups(config, NULL);
+
+	for (i = 0; keys != NULL && keys[i] != NULL; i++) {
+		if (!g_str_equal(keys[i], "General"))
+			warn("Unknown group %s in main.conf", keys[i]);
+	}
+
+	g_strfreev(keys);
+
+	keys = g_key_file_get_keys(config, "General", NULL, NULL);
+
+	for (i = 0; keys != NULL && keys[i] != NULL; i++) {
+		bool found;
+		unsigned int j;
+
+		found = false;
+		for (j = 0; j < G_N_ELEMENTS(supported_options); j++) {
+			if (g_str_equal(keys[i], supported_options[j])) {
+				found = true;
+				break;
+			}
+		}
+
+		if (!found)
+			warn("Unknown key %s in main.conf", keys[i]);
+	}
+}
+
 static void parse_config(GKeyFile *config)
 {
 	GError *err = NULL;
@@ -125,6 +175,8 @@ static void parse_config(GKeyFile *config)
 	if (!config)
 		return;
 
+	check_config(config);
+
 	DBG("parsing main.conf");
 
 	val = g_key_file_get_integer(config, "General",