Skip to content
Snippets Groups Projects
Commit 86cca22c authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Fix up handling of -b option

First, we need to parse it before load_settings() so we can deal
with it there.

Next, we need to keep the one from the config file available so it
is edited from the program settings, and not the command line version
parent 17c939f7
Branches
Tags
No related merge requests found
Pipeline #6652 passed
......@@ -1962,7 +1962,7 @@ change_settings(int connected)
SAFEPRINTF(opts[6], "Modem/Comm Rate %s", str);
SAFEPRINTF(opts[7], "Modem Init String %s", settings.mdm.init_string);
SAFEPRINTF(opts[8], "Modem Dial String %s", settings.mdm.dial_string);
SAFEPRINTF(opts[9], "List Path %s", settings.list_path);
SAFEPRINTF(opts[9], "List Path %s", settings.stored_list_path);
SAFEPRINTF(opts[10], "TERM For Shell %s", settings.TERM);
sprintf(opts[11], "Scaling %s", scaling_names[settings_to_scale()]);
if (connected)
......@@ -2211,13 +2211,15 @@ change_settings(int connected)
case 9:
uifc.helpbuf = "`List Path`\n\n"
"The complete path to the BBS list goes here.\n";
if (uifc.input(WIN_MID | WIN_SAV, 0, 0, "List Path", settings.list_path, MAX_PATH,
if (uifc.input(WIN_MID | WIN_SAV, 0, 0, "List Path", settings.stored_list_path, MAX_PATH,
K_EDIT) >= 0) {
iniSetString(&inicontents,
"SyncTERM",
"ListPath",
settings.list_path,
settings.stored_list_path,
&ini_style);
if (list_override == NULL)
SAFECOPY(settings.list_path, settings.stored_list_path);
}
else {
check_exit(false);
......
......@@ -1257,8 +1257,6 @@ get_syncterm_filename(char *fn, int fnlen, int type, bool shared)
sprintf(fn, "%.*s", fnlen - 1, config_override);
return fn;
}
if ((type == SYNCTERM_PATH_LIST) && !shared)
fprintf(stderr, "List override = %p, type = %d (%d), shared: %d\n", list_override, type, SYNCTERM_PATH_LIST, shared);
if ((list_override != NULL) && (type == SYNCTERM_PATH_LIST) && !shared) {
sprintf(fn, "%.*s", fnlen - 1, list_override);
return fn;
......@@ -1338,8 +1336,14 @@ load_settings(struct syncterm_settings *set)
set->custom_fontheight = iniReadInteger(inifile, "SyncTERM", "CustomFontHeight", 16);
set->custom_aw = iniReadInteger(inifile, "SyncTERM", "CustomAspectWidth", 4);
set->custom_ah = iniReadInteger(inifile, "SyncTERM", "CustomAspectHeight", 3);
get_syncterm_filename(set->list_path, sizeof(set->list_path), SYNCTERM_PATH_LIST, false);
iniReadSString(inifile, "SyncTERM", "ListPath", set->list_path, set->list_path, sizeof(set->list_path));
get_syncterm_filename(set->stored_list_path, sizeof(set->stored_list_path), SYNCTERM_PATH_LIST, false);
iniReadSString(inifile, "SyncTERM", "ListPath", set->stored_list_path, set->stored_list_path, sizeof(set->stored_list_path));
if (list_override != NULL) {
SAFECOPY(set->list_path, list_override);
}
else {
SAFECOPY(set->list_path, set->stored_list_path);
}
set->scaling_factor = iniReadFloat(inifile, "SyncTERM", "ScalingFactor", 0);
set->blocky = iniReadBool(inifile, "SyncTERM", "BlockyScaling", true);
set->extern_scale = iniReadBool(inifile, "SyncTERM", "ExternalScaling", false);
......@@ -1564,6 +1568,41 @@ main(int argc, char **argv)
uifc.esc_delay = 25;
url[0] = 0;
/*
* We need to parse -n and -b before we call load_settings()
* so that get_syncterm_filename works properly
*/
for (i = 1; i < argc; i++) {
if (argv[i][0] == '-'
#ifndef __unix__
|| argv[i][0] == '/'
#endif
) {
switch (toupper(argv[i][1])) {
case 'B':
if (argv[i][2] == 0) {
if ((i + 1) < argc)
list_override = argv[++i];
// Error handling below
}
else {
list_override = &argv[i][2];
}
break;
case 'N':
if (argv[i][2] == 0) {
if ((i + 1) < argc)
config_override = argv[++i];
// Error handling below
}
else {
config_override = &argv[i][2];
}
break;
}
}
}
load_settings(&settings);
cvmode = find_vmode(CIOLIB_MODE_CUSTOM);
vparams[cvmode].cols = settings.custom_cols;
......@@ -1598,24 +1637,30 @@ main(int argc, char **argv)
break;
case 'B':
if (argv[i][2] == 0) {
if ((i + 1) < argc)
list_override = argv[++i];
if ((i + 1) < argc) {
// This has already been parsed above...
//list_override = argv[++i];
}
else
goto USAGE;
}
else {
list_override = &argv[i][2];
// This has already been parsed above...
//list_override = &argv[i][2];
}
break;
case 'N':
if (argv[i][2] == 0) {
if ((i + 1) < argc)
config_override = argv[++i];
if ((i + 1) < argc) {
// This has already been parsed above...
//config_override = argv[++i];
}
else
goto USAGE;
}
else {
config_override = &argv[i][2];
// This has already been parsed above...
//config_override = &argv[i][2];
}
break;
case 'C':
......
......@@ -64,6 +64,7 @@ struct syncterm_settings {
struct modem_settings mdm;
char TERM[INI_MAX_VALUE_LEN + 1];
char list_path[MAX_PATH + 1];
char stored_list_path[MAX_PATH + 1];
double scaling_factor;
int xfer_failure_keypress_timeout; /* wait for user acknowledgement via keypress, in seconds
*/
......@@ -82,6 +83,7 @@ struct syncterm_settings {
};
extern char *inpath;
extern char *list_override;
extern const char *syncterm_version;
extern struct vmem_cell *scrollback_buf;
extern uint32_t *scrollback_fbuf;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment