f20720
---
f20720
 libmultipath/parser.c |  103 +++-----------------------------------------------
f20720
 libmultipath/parser.h |    6 --
f20720
 2 files changed, 8 insertions(+), 101 deletions(-)
f20720
f20720
Index: multipath-tools-130222/libmultipath/parser.c
f20720
===================================================================
f20720
--- multipath-tools-130222.orig/libmultipath/parser.c
f20720
+++ multipath-tools-130222/libmultipath/parser.c
f20720
@@ -280,8 +280,8 @@ out:
f20720
 	return NULL;
f20720
 }
f20720
 
f20720
-int
f20720
-read_line(char *buf, int size)
f20720
+static int
f20720
+read_line(FILE *stream, char *buf, int size)
f20720
 {
f20720
 	int ch;
f20720
 	int count = 0;
f20720
@@ -297,95 +297,6 @@ read_line(char *buf, int size)
f20720
 	return (ch == EOF) ? 0 : 1;
f20720
 }
f20720
 
f20720
-vector
f20720
-read_value_block(void)
f20720
-{
f20720
-	char *buf;
f20720
-	int i;
f20720
-	char *str = NULL;
f20720
-	char *dup;
f20720
-	vector vec = NULL;
f20720
-	vector elements = vector_alloc();
f20720
-
f20720
-	if (!elements)
f20720
-		return NULL;
f20720
-
f20720
-	buf = (char *) MALLOC(MAXBUF);
f20720
-
f20720
-	if (!buf) {
f20720
-		vector_free(elements);
f20720
-		return NULL;
f20720
-	}
f20720
-
f20720
-	while (read_line(buf, MAXBUF)) {
f20720
-		vec = alloc_strvec(buf);
f20720
-		if (vec) {
f20720
-			str = VECTOR_SLOT(vec, 0);
f20720
-			if (!strcmp(str, EOB)) {
f20720
-				free_strvec(vec);
f20720
-				break;
f20720
-			}
f20720
-
f20720
-			for (i = 0; i < VECTOR_SIZE(vec); i++) {
f20720
-				str = VECTOR_SLOT(vec, i);
f20720
-				dup = (char *) MALLOC(strlen(str) + 1);
f20720
-				if (!dup)
f20720
-					goto out;
f20720
-				memcpy(dup, str, strlen(str));
f20720
-
f20720
-				if (!vector_alloc_slot(elements)) {
f20720
-					free_strvec(vec);
f20720
-					goto out1;
f20720
-				}
f20720
-
f20720
-				vector_set_slot(elements, dup);
f20720
-			}
f20720
-			free_strvec(vec);
f20720
-		}
f20720
-		memset(buf, 0, MAXBUF);
f20720
-	}
f20720
-	FREE(buf);
f20720
-	return elements;
f20720
-out1:
f20720
-	FREE(dup);
f20720
-out:
f20720
-	FREE(buf);
f20720
-	vector_free(elements);
f20720
-	return NULL;
f20720
-}
f20720
-
f20720
-int
f20720
-alloc_value_block(vector strvec, void (*alloc_func) (vector))
f20720
-{
f20720
-	char *buf;
f20720
-	char *str = NULL;
f20720
-	vector vec = NULL;
f20720
-
f20720
-	buf = (char *) MALLOC(MAXBUF);
f20720
-
f20720
-	if (!buf)
f20720
-		return 1;
f20720
-
f20720
-	while (read_line(buf, MAXBUF)) {
f20720
-		vec = alloc_strvec(buf);
f20720
-		if (vec) {
f20720
-			str = VECTOR_SLOT(vec, 0);
f20720
-			if (!strcmp(str, EOB)) {
f20720
-				free_strvec(vec);
f20720
-				break;
f20720
-			}
f20720
-
f20720
-			if (VECTOR_SIZE(vec))
f20720
-				(*alloc_func) (vec);
f20720
-
f20720
-			free_strvec(vec);
f20720
-		}
f20720
-		memset(buf, 0, MAXBUF);
f20720
-	}
f20720
-	FREE(buf);
f20720
-	return 0;
f20720
-}
f20720
-
f20720
 void *
f20720
 set_value(vector strvec)
f20720
 {
f20720
@@ -561,7 +472,7 @@ validate_config_strvec(vector strvec, ch
f20720
 }
f20720
 
f20720
 static int
f20720
-process_stream(vector keywords, char *file)
f20720
+process_stream(FILE *stream, vector keywords, char *file)
f20720
 {
f20720
 	int i;
f20720
 	int r = 0;
f20720
@@ -582,7 +493,7 @@ process_stream(vector keywords, char *fi
f20720
 		return 1;
f20720
 	}
f20720
 
f20720
-	while (read_line(buf, MAXBUF)) {
f20720
+	while (read_line(stream, buf, MAXBUF)) {
f20720
 		line_nr++;
f20720
 		strvec = alloc_strvec(buf);
f20720
 		memset(buf,0, MAXBUF);
f20720
@@ -621,7 +532,8 @@ process_stream(vector keywords, char *fi
f20720
 
f20720
 				if (keyword->sub) {
f20720
 					kw_level++;
f20720
-					r += process_stream(keyword->sub, file);
f20720
+					r += process_stream(stream,
f20720
+							    keyword->sub, file);
f20720
 					kw_level--;
f20720
 				}
f20720
 				break;
f20720
@@ -656,6 +568,7 @@ int
f20720
 process_file(char *file)
f20720
 {
f20720
 	int r;
f20720
+	FILE *stream;
f20720
 
f20720
 	if (!keywords) {
f20720
 		condlog(0, "No keywords alocated");
f20720
@@ -670,7 +583,7 @@ process_file(char *file)
f20720
 
f20720
 	/* Stream handling */
f20720
 	line_nr = 0;
f20720
-	r = process_stream(keywords, file);
f20720
+	r = process_stream(stream, keywords, file);
f20720
 	fclose(stream);
f20720
 	//free_keywords(keywords);
f20720
 
f20720
Index: multipath-tools-130222/libmultipath/parser.h
f20720
===================================================================
f20720
--- multipath-tools-130222.orig/libmultipath/parser.h
f20720
+++ multipath-tools-130222/libmultipath/parser.h
f20720
@@ -47,9 +47,6 @@ struct keyword {
f20720
 	int unique;
f20720
 };
f20720
 
f20720
-/* global var exported */
f20720
-FILE *stream;
f20720
-
f20720
 /* Reloading helpers */
f20720
 #define SET_RELOAD      (reload = 1)
f20720
 #define UNSET_RELOAD    (reload = 0)
f20720
@@ -72,9 +69,6 @@ extern int _install_keyword(char *string
f20720
 extern void dump_keywords(vector keydump, int level);
f20720
 extern void free_keywords(vector keywords);
f20720
 extern vector alloc_strvec(char *string);
f20720
-extern int read_line(char *buf, int size);
f20720
-extern vector read_value_block(void);
f20720
-extern int alloc_value_block(vector strvec, void (*alloc_func) (vector));
f20720
 extern void *set_value(vector strvec);
f20720
 extern int alloc_keywords(void);
f20720
 extern int process_file(char *conf_file);