tools/env: no global variable sharing between application and library

Signed-off-by: Andreas Fenkart <andreas.fenkart@digitalstrom.com>
diff --git a/tools/env/fw_env_main.c b/tools/env/fw_env_main.c
index 2a45a0d..7a17b28 100644
--- a/tools/env/fw_env_main.c
+++ b/tools/env/fw_env_main.c
@@ -49,6 +49,14 @@
 	{NULL, 0, NULL, 0}
 };
 
+static struct env_opts env_opts;
+
+/* setenv options */
+static int noheader;
+
+/* getenv options */
+static char *script_file;
+
 void usage_printenv(void)
 {
 
@@ -108,22 +116,22 @@
 	int c;
 
 #ifdef CONFIG_FILE
-	common_args.config_file = CONFIG_FILE;
+	env_opts.config_file = CONFIG_FILE;
 #endif
 
 	while ((c = getopt_long(argc, argv, ":a:c:h", long_options, NULL)) !=
 	       EOF) {
 		switch (c) {
 		case 'a':
-			if (parse_aes_key(optarg, common_args.aes_key)) {
+			if (parse_aes_key(optarg, env_opts.aes_key)) {
 				fprintf(stderr, "AES key parse error\n");
 				exit(EXIT_FAILURE);
 			}
-			common_args.aes_flag = 1;
+			env_opts.aes_flag = 1;
 			break;
 #ifdef CONFIG_FILE
 		case 'c':
-			common_args.config_file = optarg;
+			env_opts.config_file = optarg;
 			break;
 #endif
 		case 'h':
@@ -151,7 +159,7 @@
 	       EOF) {
 		switch (c) {
 		case 'n':
-			printenv_args.value_only = 1;
+			noheader = 1;
 			break;
 		case 'a':
 		case 'c':
@@ -177,7 +185,7 @@
 	       EOF) {
 		switch (c) {
 		case 's':
-			setenv_args.script_file = optarg;
+			script_file = optarg;
 			break;
 		case 'a':
 		case 'c':
@@ -240,14 +248,14 @@
 	}
 
 	if (do_printenv) {
-		if (fw_printenv(argc, argv, printenv_args.value_only))
+		if (fw_printenv(argc, argv, noheader, &env_opts) != 0)
 			retval = EXIT_FAILURE;
 	} else {
-		if (!setenv_args.script_file) {
-			if (fw_setenv(argc, argv) != 0)
+		if (!script_file) {
+			if (fw_setenv(argc, argv, &env_opts) != 0)
 				retval = EXIT_FAILURE;
 		} else {
-			if (fw_parse_script(setenv_args.script_file) != 0)
+			if (fw_parse_script(script_file, &env_opts) != 0)
 				retval = EXIT_FAILURE;
 		}
 	}