X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Fhelper%2Foptions.c;h=573026a6e39f7396ce5e2b21b683810587e3575a;hb=c538a830cdaafa92c9e9a624d84915cc39cce05b;hp=a0c9a9e92859cef112913c985bbe1a7f4b7a856f;hpb=4b9bdd664a79d5713b22a178086b071abc049d01;p=openocd.git diff --git a/src/helper/options.c b/src/helper/options.c index a0c9a9e928..573026a6e3 100644 --- a/src/helper/options.c +++ b/src/helper/options.c @@ -25,15 +25,14 @@ #endif #include "configuration.h" -#include "log.h" // @todo the inclusion of server.h here is a layering violation -#include "server.h" +#include #include static int help_flag, version_flag; -static struct option long_options[] = +static const struct option long_options[] = { {"help", no_argument, &help_flag, 1}, {"version", no_argument, &version_flag, 1}, @@ -46,7 +45,7 @@ static struct option long_options[] = {0, 0, 0, 0} }; -int configuration_output_handler(struct command_context_s *context, const char* line) +int configuration_output_handler(struct command_context *context, const char* line) { LOG_USER_N("%s", line); @@ -102,13 +101,28 @@ static void add_default_dirs(void) * listed last in the built-in search order, so the user can * override these scripts with site-specific customizations. */ - /// @todo Implement @c add_script_search_dir("${HOME}/.openocd"). + + const char *home = getenv("HOME"); + + if (home) + { + char *path; + + path = alloc_printf("%s/.openocd", home); + + if (path) + { + add_script_search_dir(path); + free(path); + } + } + add_script_search_dir(PKGDATADIR "/site"); add_script_search_dir(PKGDATADIR "/scripts"); #endif } -int parse_cmdline_args(struct command_context_s *cmd_ctx, int argc, char *argv[]) +int parse_cmdline_args(struct command_context *cmd_ctx, int argc, char *argv[]) { int c; char command_buffer[128];