Add -C option for specifying alternative config file.
This commit is contained in:
parent
eacf4b8be4
commit
dc3b154ef9
|
@ -54,6 +54,9 @@ Specify a particular USB device serial number to connect to. Use this
|
||||||
option to distinguish between multiple devices of the same type.
|
option to distinguish between multiple devices of the same type.
|
||||||
.IP "\-n"
|
.IP "\-n"
|
||||||
Do not process the startup file (~/.mspdebug).
|
Do not process the startup file (~/.mspdebug).
|
||||||
|
.IP "\-C \fIfile\fR"
|
||||||
|
Specify an alternative configuration file (default is ~/.mspdebug). If -n
|
||||||
|
is specified as well, no file will be read.
|
||||||
.IP "\--long-password"
|
.IP "\--long-password"
|
||||||
When using the flash-bsl driver, send a 32-byte BSL password instead
|
When using the flash-bsl driver, send a 32-byte BSL password instead
|
||||||
of the standard 16-byte password.
|
of the standard 16-byte password.
|
||||||
|
|
33
ui/main.c
33
ui/main.c
|
@ -60,6 +60,7 @@
|
||||||
|
|
||||||
struct cmdline_args {
|
struct cmdline_args {
|
||||||
const char *driver_name;
|
const char *driver_name;
|
||||||
|
const char *alt_config;
|
||||||
int flags;
|
int flags;
|
||||||
struct device_args devarg;
|
struct device_args devarg;
|
||||||
};
|
};
|
||||||
|
@ -106,7 +107,9 @@ static void usage(const char *progname)
|
||||||
" -v voltage\n"
|
" -v voltage\n"
|
||||||
" Set the supply voltage, in millivolts.\n"
|
" Set the supply voltage, in millivolts.\n"
|
||||||
" -n\n"
|
" -n\n"
|
||||||
" Do not read ~/.mspdebug on startup.\n"
|
" Do not read a configuration file on startup.\n"
|
||||||
|
" -C <file>\n"
|
||||||
|
" Load an alternative configuration file.\n"
|
||||||
" --long-password\n"
|
" --long-password\n"
|
||||||
" Send 32-byte IVT as BSL password (flash-bsl only)\n"
|
" Send 32-byte IVT as BSL password (flash-bsl only)\n"
|
||||||
" --help\n"
|
" --help\n"
|
||||||
|
@ -144,17 +147,23 @@ static void usage(const char *progname)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void process_rc_file(void)
|
static void process_rc_file(const char *config)
|
||||||
{
|
{
|
||||||
const char *home = getenv("HOME");
|
|
||||||
char text[256];
|
char text[256];
|
||||||
|
|
||||||
if (!home)
|
if (!config) {
|
||||||
return;
|
const char *home = getenv("HOME");
|
||||||
|
|
||||||
snprintf(text, sizeof(text), "%s/.mspdebug", home);
|
if (!home)
|
||||||
if (!access(text, F_OK))
|
return;
|
||||||
process_file(text, 0);
|
|
||||||
|
snprintf(text, sizeof(text), "%s/.mspdebug", home);
|
||||||
|
if (!access(text, F_OK))
|
||||||
|
config = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config)
|
||||||
|
process_file(config, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int add_fet_device(void *user_data, const struct fet_db_record *r)
|
static int add_fet_device(void *user_data, const struct fet_db_record *r)
|
||||||
|
@ -234,9 +243,13 @@ static int parse_cmdline_args(int argc, char **argv,
|
||||||
int opt;
|
int opt;
|
||||||
int want_usb = 0;
|
int want_usb = 0;
|
||||||
|
|
||||||
while ((opt = getopt_long(argc, argv, "d:jv:nU:s:q",
|
while ((opt = getopt_long(argc, argv, "d:jv:nU:s:qC:",
|
||||||
longopts, NULL)) >= 0)
|
longopts, NULL)) >= 0)
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
|
case 'C':
|
||||||
|
args->alt_config = optarg;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'q':
|
case 'q':
|
||||||
{
|
{
|
||||||
static const union opdb_value v = {
|
static const union opdb_value v = {
|
||||||
|
@ -426,7 +439,7 @@ int main(int argc, char **argv)
|
||||||
simio_init();
|
simio_init();
|
||||||
|
|
||||||
if (!(args.flags & OPT_NO_RC))
|
if (!(args.flags & OPT_NO_RC))
|
||||||
process_rc_file();
|
process_rc_file(args.alt_config);
|
||||||
|
|
||||||
/* Process commands */
|
/* Process commands */
|
||||||
if (optind < argc) {
|
if (optind < argc) {
|
||||||
|
|
Loading…
Reference in New Issue