X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Fhelper%2Foptions.c;h=75d4f2e9b217bcd5959ae44dcdb2eaa2ab5ee88e;hb=c1ee650a9aead0bd25d7aa37fd65e5a3ed0c6e38;hp=5ad09fbd482cecea6cf49b91d2220016d2695154;hpb=d47e1b8f362379d8a2307f49e2b42115a3f40524;p=openocd.git diff --git a/src/helper/options.c b/src/helper/options.c index 5ad09fbd48..75d4f2e9b2 100644 --- a/src/helper/options.c +++ b/src/helper/options.c @@ -45,13 +45,43 @@ static struct option long_options[] = {0, 0, 0, 0} }; -int configuration_output_handler(struct command_context_s *context, char* line) +int configuration_output_handler(struct command_context_s *context, const char* line) { LOG_INFO_N(line); 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; @@ -79,9 +109,11 @@ int parse_cmdline_args(struct command_context_s *cmd_ctx, int argc, char *argv[] version_flag = 1; break; case 'f': /* --file | -f */ - snprintf(command_buffer, 128, "script %s", optarg); - add_config_file_name(command_buffer); + { + snprintf(command_buffer, 128, "script {%s}", optarg); + add_config_command(command_buffer); break; + } case 's': /* --search | -s */ add_script_search_dir(optarg); break; @@ -102,7 +134,7 @@ int parse_cmdline_args(struct command_context_s *cmd_ctx, int argc, char *argv[] case 'c': /* --command | -c */ if (optarg) { - add_config_file_name(optarg); + add_config_command(optarg); } break; @@ -128,31 +160,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; }