summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAn-Cheng Huang <ancheng@vyatta.com>2010-06-02 17:55:00 -0700
committerAn-Cheng Huang <ancheng@vyatta.com>2010-06-02 17:55:00 -0700
commit80369a816eea6fd86e3e11bd877673ec4d12d7d2 (patch)
tree84f0762a5d2e977a06c6681f0ca327f220c8b954
parent1291aa7736110abc2784d969aaccc48b53ad3657 (diff)
downloadvyatta-cfg-80369a816eea6fd86e3e11bd877673ec4d12d7d2.tar.gz
vyatta-cfg-80369a816eea6fd86e3e11bd877673ec4d12d7d2.zip
simplify output init
-rw-r--r--src/cli_new.c5
-rw-r--r--src/cli_val.h2
-rw-r--r--src/commit2.c2
-rw-r--r--src/delete.c6
-rw-r--r--src/exe_action.c2
-rw-r--r--src/set.c6
6 files changed, 8 insertions, 15 deletions
diff --git a/src/cli_new.c b/src/cli_new.c
index 50655b6..06bd4bf 100644
--- a/src/cli_new.c
+++ b/src/cli_new.c
@@ -105,7 +105,7 @@ is_deactivated(const clind_path_ref *path,const char *symbol) ;
GLOBAL FUNCTIONS
***************************************************/
-char *cli_operation_name = NULL;
+const char *cli_operation_name = NULL;
/* it is executed as "eval `my_set` in order to be able to
modify BASH env
@@ -2329,7 +2329,7 @@ int new_out_fd = -1;
int new_err_fd = -1;
int
-initialize_output()
+initialize_output(const char *op)
{
if ((out_fd = dup(STDOUT_FILENO)) == -1) {
return -1;
@@ -2358,6 +2358,7 @@ initialize_output()
return -1;
}
+ cli_operation_name = op;
return 0;
}
diff --git a/src/cli_val.h b/src/cli_val.h
index b8a30ba..fbd48d9 100644
--- a/src/cli_val.h
+++ b/src/cli_val.h
@@ -230,7 +230,7 @@ extern int out_fd;
extern FILE *out_stream;
extern FILE *err_stream;
-extern int initialize_output(void);
+extern int initialize_output(const char *op);
/* debug hooks? */
#define my_malloc(size, name) malloc(size)
diff --git a/src/commit2.c b/src/commit2.c
index 1ed0ea5..d511458 100644
--- a/src/commit2.c
+++ b/src/commit2.c
@@ -182,7 +182,7 @@ main(int argc, char** argv)
}
}
- initialize_output();
+ initialize_output("Commit");
init_paths(TRUE);
if (g_debug) {
printf("commit2: starting up\n");
diff --git a/src/delete.c b/src/delete.c
index 65dd67e..f2d3d31 100644
--- a/src/delete.c
+++ b/src/delete.c
@@ -8,8 +8,6 @@
#include "cli_val.h"
#include "cli_objects.h"
-extern char *cli_operation_name;
-
static void remove_rf(boolean do_umount)
{
char *command = NULL;
@@ -150,9 +148,7 @@ int main(int argc, char **argv)
/* this is needed before calling certain glib functions */
g_type_init();
- cli_operation_name = "Delete";
-
- if (initialize_output() == -1) {
+ if (initialize_output("Delete") == -1) {
bye("can't initialize output\n");
}
diff --git a/src/exe_action.c b/src/exe_action.c
index 77d6a87..f8920e1 100644
--- a/src/exe_action.c
+++ b/src/exe_action.c
@@ -81,7 +81,7 @@ main(int argc, char** argv)
char buf[2048];
sprintf(buf,"%s/%snode.def",root,path);
printf("%s\n",buf);
- initialize_output();
+ initialize_output(NULL);
init_paths(TRUE);
printf("[path: %s][act: %lu]\n",buf,act);
diff --git a/src/set.c b/src/set.c
index 909cb74..004f25c 100644
--- a/src/set.c
+++ b/src/set.c
@@ -10,8 +10,6 @@
#include "cli_objects.h"
#include "cli_path_utils.h"
-extern char *cli_operation_name;
-
static void handle_defaults(void);
static void make_dir()
@@ -192,9 +190,7 @@ int main(int argc, char **argv)
/* this is needed before calling certain glib functions */
g_type_init();
- cli_operation_name = "Set";
-
- if (initialize_output() == -1) {
+ if (initialize_output("Set") == -1) {
bye("can't initialize output\n");
}