From adc9b7815cd970a68d492ed08e86e09899cb9dca Mon Sep 17 00:00:00 2001 From: Rutger Hofman Date: Sat, 25 Apr 2009 15:17:16 +0000 Subject: [PATCH] Remove a global variable jtag_argv0: replace by a static var and a setter call git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1534 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- urjtag/include/jtag.h | 4 ++++ urjtag/src/cmd/cmd_jtag_data_dir.c | 9 ++++++++- urjtag/src/jtag.c | 3 +-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/urjtag/include/jtag.h b/urjtag/include/jtag.h index 050119ae..cba41e1d 100644 --- a/urjtag/include/jtag.h +++ b/urjtag/include/jtag.h @@ -43,6 +43,10 @@ extern urj_bus_t *urj_bus; extern int urj_big_endian; extern int urj_debug_mode; +/** Register the application name with cmd_jtag. + * @param argv0 is remembered as a pointer, it is not strdup()'ed. + */ +void urj_cmd_jtag_set_argv0(const char *argv0); const char *urj_cmd_jtag_get_data_dir (void); int urj_cmd_jtag_parse_file (urj_chain_t *chain, const char *filename); diff --git a/urjtag/src/cmd/cmd_jtag_data_dir.c b/urjtag/src/cmd/cmd_jtag_data_dir.c index 6bbaad9f..332eb702 100644 --- a/urjtag/src/cmd/cmd_jtag_data_dir.c +++ b/urjtag/src/cmd/cmd_jtag_data_dir.c @@ -8,6 +8,14 @@ #include #include "jtag.h" +static const char *jtag_argv0; + +void +urj_cmd_jtag_set_argv0(const char *argv0) +{ + jtag_argv0 = argv0; +} + #ifdef JTAG_RELOCATABLE #include @@ -17,7 +25,6 @@ extern char *make_relative_prefix (const char *progname, const char *bin_prefix, const char *prefix); -extern const char *jtag_argv0; static char *jtag_data_dir = NULL; const char * diff --git a/urjtag/src/jtag.c b/urjtag/src/jtag.c index 55f2d287..ccf5cc90 100644 --- a/urjtag/src/jtag.c +++ b/urjtag/src/jtag.c @@ -322,7 +322,6 @@ cleanup (urj_chain_t *chain) chain = NULL; } -const char *jtag_argv0; int main (int argc, char *const argv[]) { @@ -335,7 +334,7 @@ main (int argc, char *const argv[]) int quiet = 0; urj_chain_t *chain = NULL; - jtag_argv0 = argv[0]; + urj_cmd_jtag_set_argv0(argv[0]); if (geteuid () == 0 && getuid () != 0) {