Add $HOME/.openocd as the first default script search directory, allowing
the user to override the standard scripts.

Signed-off-by: Andreas Fritiofson <[email protected]>
---
 src/helper/options.c |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/src/helper/options.c b/src/helper/options.c
index 5792e11..2187ff7 100644
--- a/src/helper/options.c
+++ b/src/helper/options.c
@@ -29,6 +29,7 @@
 #include "server.h"
 
 #include <getopt.h>
+#include <stdlib.h>
 
 static int help_flag, version_flag;
 
@@ -54,6 +55,10 @@ int configuration_output_handler(struct command_context 
*context, const char* li
 
 static void add_default_dirs(void)
 {
+#ifndef MAX_PATH
+#define MAX_PATH 1024
+#endif
+
 #ifdef _WIN32
        /* Add the parent of the directory where openocd.exe resides to the
         * config script search path.
@@ -101,7 +106,16 @@ 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").
+
+       char *home = getenv("HOME");
+
+       if (home) {
+               char path[MAX_PATH];
+
+               if (snprintf(path, MAX_PATH, "%s/.openocd", home) < MAX_PATH)
+                       add_script_search_dir(path);
+       }
+
        add_script_search_dir(PKGDATADIR "/site");
        add_script_search_dir(PKGDATADIR "/scripts");
 #endif
-- 
1.6.3.3

_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to