* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#endif
#include "configuration.h"
-/* @todo the inclusion of server.h here is a layering violation */
-#include <server/server.h>
+#include "log.h"
+#include "command.h"
#include <getopt.h>
free(path);
}
}
+
+ path = getenv("OPENOCD_SCRIPTS");
+
+ if (path)
+ add_script_search_dir(path);
+
#ifdef _WIN32
const char *appdata = getenv("APPDATA");
int parse_cmdline_args(struct command_context *cmd_ctx, int argc, char *argv[])
{
int c;
- char command_buffer[128];
while (1) {
/* getopt_long stores the option index here. */
break;
case 'f': /* --file | -f */
{
- snprintf(command_buffer, 128, "script {%s}", optarg);
- add_config_command(command_buffer);
+ char *command = alloc_printf("script {%s}", optarg);
+ add_config_command(command);
+ free(command);
break;
}
case 's': /* --search | -s */
add_script_search_dir(optarg);
break;
case 'd': /* --debug | -d */
- if (optarg)
- snprintf(command_buffer, 128, "debug_level %s", optarg);
- else
- snprintf(command_buffer, 128, "debug_level 3");
- command_run_line(cmd_ctx, command_buffer);
+ {
+ char *command = alloc_printf("debug_level %s", optarg ? optarg : "3");
+ command_run_line(cmd_ctx, command);
+ free(command);
break;
+ }
case 'l': /* --log_output | -l */
if (optarg) {
- snprintf(command_buffer, 128, "log_output %s", optarg);
- command_run_line(cmd_ctx, command_buffer);
+ char *command = alloc_printf("log_output %s", optarg);
+ command_run_line(cmd_ctx, command);
+ free(command);
}
break;
case 'c': /* --command | -c */