Add a config parser to load config file in cli.

1. It supports '#' for comment.
2. Each conf line should be of format 'key=value'.
3. Blank lines are ignored.

Bug: 199189187
Test: unit tests, "VALGRIND=1 make tests"

Change-Id: I68768d55b93e7edf66ce3ffa49cac351f7a5ac30
diff --git a/config_parser.h b/config_parser.h
new file mode 100644
index 0000000..f001cdb
--- /dev/null
+++ b/config_parser.h
@@ -0,0 +1,53 @@
+/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef CONFIG_PARSER_H
+#define CONFIG_PARSER_H
+
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct config_entry {
+	const char *key;
+	const char *value;
+};
+
+struct config_entry_list {
+	struct config_entry *entries;
+	size_t num_entries;
+	size_t num_allocated_;
+};
+
+/* Allocate a new |config_entry_list| struct. */
+struct config_entry_list *new_config_entry_list(void);
+
+/* Free allocated pointers in |config_entry|. */
+void clear_config_entry(struct config_entry *entry);
+
+/* Free a |config_entry_list| struct. */
+void free_config_entry_list(struct config_entry_list *list);
+
+/*
+ * Parse one config line into a entry.
+ *
+ * Returns true for success, otherwise false for parsing failures.
+ */
+bool parse_config_line(const char *config_line, struct config_entry *entry);
+
+/*
+ * Parse a minijail config file into a |config_entry_list|.
+ *
+ * Returns true for success, otherwise false for parsing failures.
+ */
+bool parse_config_file(FILE *config_file, struct config_entry_list *list);
+
+#ifdef __cplusplus
+}; /* extern "C" */
+#endif
+
+#endif /* CONFIG_PARSER_H */