diff options
author | oharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2008-07-10 18:24:30 +0000 |
---|---|---|
committer | oharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2008-07-10 18:24:30 +0000 |
commit | 2858a9f740a49998bf2db1e6379c5c47133aea98 (patch) | |
tree | f5838d57fe9224d441b3fb090c83dceeb5c0637e /src/helper | |
parent | 5a2b824b2650b5a7ee8366f6dfca5b6c2a9c3033 (diff) | |
download | openocd+libswd-2858a9f740a49998bf2db1e6379c5c47133aea98.tar.gz openocd+libswd-2858a9f740a49998bf2db1e6379c5c47133aea98.tar.bz2 openocd+libswd-2858a9f740a49998bf2db1e6379c5c47133aea98.tar.xz openocd+libswd-2858a9f740a49998bf2db1e6379c5c47133aea98.zip |
- added search paths before running tcl/commands.tcl.
- improved error handling for missing tcl/commands.tcl
git-svn-id: svn://svn.berlios.de/openocd/trunk@785 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/helper')
-rw-r--r-- | src/helper/configuration.h | 1 | ||||
-rw-r--r-- | src/helper/options.c | 55 |
2 files changed, 31 insertions, 25 deletions
diff --git a/src/helper/configuration.h b/src/helper/configuration.h index 1d315cc2..d1f537d7 100644 --- a/src/helper/configuration.h +++ b/src/helper/configuration.h @@ -30,5 +30,6 @@ extern void add_script_search_dir (const char *dir); extern int configuration_output_handler(struct command_context_s *context, const char* line); extern FILE *open_file_from_path (char *file, char *mode); extern char *find_file(char *name); +int add_default_dirs(void); #endif /* CONFIGURATION_H */ diff --git a/src/helper/options.c b/src/helper/options.c index afff55ba..f62ab16b 100644 --- a/src/helper/options.c +++ b/src/helper/options.c @@ -52,6 +52,36 @@ int configuration_output_handler(struct command_context_s *context, const char* return ERROR_OK; } +int add_default_dirs(void) +{ +#ifdef _WIN32 + /* Add the parent of the directory where openocd.exe resides to the + * config script search path. + * Directory layout: + * bin\openocd.exe + * lib\openocd + * event\at91eb40a_reset.cfg + * target\at91eb40a.cfg + */ + { + char strExePath [MAX_PATH]; + GetModuleFileName (NULL, strExePath, MAX_PATH); + /* Either this code will *always* work or it will SEGFAULT giving + * excellent information on the culprit. + */ + *strrchr(strExePath, '\\')=0; + strcat(strExePath, "\\.."); + add_script_search_dir(strExePath); + } +#else + /* Add dir for openocd supplied scripts last so that user can over + ride those scripts if desired. */ + add_script_search_dir(PKGDATADIR); + add_script_search_dir(PKGLIBDIR); +#endif + return ERROR_OK; +} + int parse_cmdline_args(struct command_context_s *cmd_ctx, int argc, char *argv[]) { int c; @@ -138,31 +168,6 @@ int parse_cmdline_args(struct command_context_s *cmd_ctx, int argc, char *argv[] exit(-1); } -#ifdef _WIN32 - /* Add the parent of the directory where openocd.exe resides to the - * config script search path. - * Directory layout: - * bin\openocd.exe - * lib\openocd - * event\at91eb40a_reset.cfg - * target\at91eb40a.cfg - */ - { - char strExePath [MAX_PATH]; - GetModuleFileName (NULL, strExePath, MAX_PATH); - /* Either this code will *always* work or it will SEGFAULT giving - * excellent information on the culprit. - */ - *strrchr(strExePath, '\\')=0; - strcat(strExePath, "\\.."); - add_script_search_dir(strExePath); - } -#else - /* Add dir for openocd supplied scripts last so that user can over - ride those scripts if desired. */ - add_script_search_dir(PKGDATADIR); - add_script_search_dir(PKGLIBDIR); -#endif return ERROR_OK; } |