szaszm commented on a change in pull request #674: Minificpp 1007 - ECU C2
integration.
URL: https://github.com/apache/nifi-minifi-cpp/pull/674#discussion_r371821508
##########
File path: nanofi/src/core/file_utils.c
##########
@@ -139,3 +200,46 @@ char * get_current_working_directory() {
free(cwd);
return NULL;
}
+
+properties_t * read_configuration_file(const char * file_path) {
+ if (!file_path) {
+ logc(err, "%s", "No file path provided");
+ return NULL;
+ }
+
+ properties_t * params = NULL;
+ FILE * fp = fopen(file_path, "r");
+ char * line = NULL;
+ size_t size = 0;
+ if (!fp) {
+ logc(err, "Could not open file %s", file_path);
+ return NULL;
+ }
+#ifndef WIN32
+ while (getline(&line, &size, fp) > 0) {
+#else
+ size = 1024;
+ line = (char *)malloc(1024);
+ while (fgets(line, size, fp) != NULL) {
+#endif
+ char ** tokens = parse_tokens(line, size, 2, " =\n");
+ properties_t * el = (properties_t *)malloc(sizeof(properties_t));
+
+ el->key = tokens[0];
+ el->value = tokens[1];
+
+ char ** tmp = tokens;
+ free(tmp);
Review comment:
What's the purpose of this temporary?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services