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

Add support for configuring data/stop bits and parity for modem and serial

Also, straighten out the confusing option adjuster thing when editing
an entry.

The help text still needs an overhaul, but now I have to re-test this
whole mess.
parent 0076679b
Branches
Tags
No related merge requests found
Pipeline #7206 failed
...@@ -283,6 +283,8 @@ char music_helpbuf[] = "`ANSI Music Setup`\n\n" ...@@ -283,6 +283,8 @@ char music_helpbuf[] = "`ANSI Music Setup`\n\n"
static char *address_families[] = {"PerDNS", "IPv4", "IPv6", NULL}; static char *address_families[] = {"PerDNS", "IPv4", "IPv6", NULL};
static char *address_family_names[] = {"As per DNS", "IPv4 only", "IPv6 only", NULL}; static char *address_family_names[] = {"As per DNS", "IPv4 only", "IPv6 only", NULL};
static char *parity_enum[] = {"None", "Even", "Odd"};
static char *address_family_help = "`Address Family`\n\n" static char *address_family_help = "`Address Family`\n\n"
"Select the address family to resolve\n\n" "Select the address family to resolve\n\n"
"`As per DNS`..: Uses what is in the DNS system\n" "`As per DNS`..: Uses what is in the DNS system\n"
...@@ -779,10 +781,10 @@ read_item(str_list_t listfile, struct bbslist *entry, char *bbsname, int id, int ...@@ -779,10 +781,10 @@ read_item(str_list_t listfile, struct bbslist *entry, char *bbsname, int id, int
iniGetSString(section, NULL, "Address", "", entry->addr, sizeof(entry->addr)); iniGetSString(section, NULL, "Address", "", entry->addr, sizeof(entry->addr));
entry->conn_type = iniGetEnum(section, NULL, "ConnectionType", conn_types_enum, CONN_TYPE_SSH); entry->conn_type = iniGetEnum(section, NULL, "ConnectionType", conn_types_enum, CONN_TYPE_SSH);
entry->flow_control = fc_from_enum(iniGetEnum(section, NULL, "FlowControl", fc_enum, 0)); entry->flow_control = fc_from_enum(iniGetEnum(section, NULL, "FlowControl", fc_enum, 0));
entry->port = iniGetShortInt(section, NULL, "Port", conn_ports[entry->conn_type]); entry->port = iniGetUShortInt(section, NULL, "Port", conn_ports[entry->conn_type]);
entry->added = iniGetDateTime(section, NULL, "Added", 0); entry->added = iniGetDateTime(section, NULL, "Added", 0);
entry->connected = iniGetDateTime(section, NULL, "LastConnected", 0); entry->connected = iniGetDateTime(section, NULL, "LastConnected", 0);
entry->calls = iniGetInteger(section, NULL, "TotalCalls", 0); entry->calls = iniGetUInteger(section, NULL, "TotalCalls", 0);
iniGetSString(section, NULL, "UserName", "", entry->user, sizeof(entry->user)); iniGetSString(section, NULL, "UserName", "", entry->user, sizeof(entry->user));
iniGetSString(section, NULL, "Password", "", entry->password, sizeof(entry->password)); iniGetSString(section, NULL, "Password", "", entry->password, sizeof(entry->password));
iniGetSString(section, NULL, "SystemPassword", "", entry->syspass, sizeof(entry->syspass)); iniGetSString(section, NULL, "SystemPassword", "", entry->syspass, sizeof(entry->syspass));
...@@ -814,6 +816,13 @@ read_item(str_list_t listfile, struct bbslist *entry, char *bbsname, int id, int ...@@ -814,6 +816,13 @@ read_item(str_list_t listfile, struct bbslist *entry, char *bbsname, int id, int
entry->sftp_public_key = iniGetBool(section, NULL, "SFTPPublicKey", false); entry->sftp_public_key = iniGetBool(section, NULL, "SFTPPublicKey", false);
iniGetSString(section, NULL, "DownloadPath", home, entry->dldir, sizeof(entry->dldir)); iniGetSString(section, NULL, "DownloadPath", home, entry->dldir, sizeof(entry->dldir));
iniGetSString(section, NULL, "UploadPath", home, entry->uldir, sizeof(entry->uldir)); iniGetSString(section, NULL, "UploadPath", home, entry->uldir, sizeof(entry->uldir));
entry->data_bits = iniGetUShortInt(section, NULL, "DataBits", 8);
if (entry->data_bits < 7 || entry->data_bits > 8)
entry->data_bits = 8;
entry->stop_bits = iniGetUShortInt(section, NULL, "StopBits", 1);
if (entry->stop_bits < 1 || entry->stop_bits > 2)
entry->stop_bits = 1;
entry->parity = iniGetEnum(section, NULL, "Parity", parity_enum, PARITY_NONE);
/* Log Stuff */ /* Log Stuff */
iniGetSString(section, NULL, "LogFile", "", entry->logfile, sizeof(entry->logfile)); iniGetSString(section, NULL, "LogFile", "", entry->logfile, sizeof(entry->logfile));
...@@ -1119,7 +1128,9 @@ edit_name(char *itemname, struct bbslist **list, str_list_t inifile, bool edit_t ...@@ -1119,7 +1128,9 @@ edit_name(char *itemname, struct bbslist **list, str_list_t inifile, bool edit_t
int int
edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdefault) edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdefault)
{ {
char opt[22][69]; /* 21=Holds number of menu items, 80=Number of columns */ char opt[25][69]; /* 21=Holds number of menu items, 80=Number of columns */
char optname[69];
int optmap[25];
char *opts[(sizeof(opt) / sizeof(opt[0])) + 1]; char *opts[(sizeof(opt) / sizeof(opt[0])) + 1];
int changed = 0; int changed = 0;
int copt = 0, i, j; int copt = 0, i, j;
...@@ -1159,61 +1170,106 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef ...@@ -1159,61 +1170,106 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef
itemname = item->name; itemname = item->name;
for (; !quitting;) { for (; !quitting;) {
i = 0; i = 0;
memset(optmap, 0, sizeof(optmap));
if (!isdefault) { if (!isdefault) {
optmap[i] = 0;
sprintf(opt[i++], "Name %s", itemname); sprintf(opt[i++], "Name %s", itemname);
if (item->conn_type == CONN_TYPE_MODEM) optmap[i] = 1;
sprintf(opt[i++], "Phone Number %s", item->addr); switch (item->conn_type) {
else if ((item->conn_type == CONN_TYPE_SERIAL) || (item->conn_type == CONN_TYPE_SERIAL_NORTS)) case CONN_TYPE_MODEM:
sprintf(opt[i++], "Device Name %s", item->addr); sprintf(opt[i++], "Phone Number %s", item->addr);
else if (item->conn_type == CONN_TYPE_SHELL) break;
sprintf(opt[i++], "Command %s", item->addr); case CONN_TYPE_SERIAL:
else case CONN_TYPE_SERIAL_NORTS:
sprintf(opt[i++], "Address %s", item->addr); sprintf(opt[i++], "Device Name %s", item->addr);
break;
case CONN_TYPE_SHELL:
sprintf(opt[i++], "Command %s", item->addr);
break;
default:
sprintf(opt[i++], "Address %s", item->addr);
break;
}
} }
optmap[i] = 2;
sprintf(opt[i++], "Connection Type %s", conn_types[item->conn_type]); sprintf(opt[i++], "Connection Type %s", conn_types[item->conn_type]);
if ((item->conn_type == CONN_TYPE_MODEM) || (item->conn_type == CONN_TYPE_SERIAL) || (item->conn_type == CONN_TYPE_SERIAL_NORTS)) if ((item->conn_type == CONN_TYPE_MODEM) || (item->conn_type == CONN_TYPE_SERIAL) || (item->conn_type == CONN_TYPE_SERIAL_NORTS)) {
optmap[i] = 3;
fc_str(opt[i++], item->flow_control); fc_str(opt[i++], item->flow_control);
else if (item->conn_type != CONN_TYPE_SHELL) optmap[i] = 4;
sprintf(opt[i++], "Stop Bits %hu", item->stop_bits);
optmap[i] = 5;
sprintf(opt[i++], "Data Bits %hu", item->data_bits);
optmap[i] = 6;
sprintf(opt[i++], "Parity %s", parity_enum[item->parity]);
}
else if (item->conn_type != CONN_TYPE_SHELL) {
optmap[i] = 7;
sprintf(opt[i++], "TCP Port %hu", item->port); sprintf(opt[i++], "TCP Port %hu", item->port);
}
if (item->conn_type == CONN_TYPE_MBBS_GHOST) { if (item->conn_type == CONN_TYPE_MBBS_GHOST) {
optmap[i] = 8;
printf_trunc(opt[i], sizeof(opt[i]), "Username %s", item->user); printf_trunc(opt[i], sizeof(opt[i]), "Username %s", item->user);
i++; i++;
optmap[i] = 9;
sprintf(opt[i++], "GHost Program %s", item->password); sprintf(opt[i++], "GHost Program %s", item->password);
optmap[i] = 10;
sprintf(opt[i++], "System Password %s", item->syspass[0] ? "********" : "<none>"); sprintf(opt[i++], "System Password %s", item->syspass[0] ? "********" : "<none>");
} }
else if (item->conn_type == CONN_TYPE_SSHNA) { else if (item->conn_type == CONN_TYPE_SSHNA) {
optmap[i] = 8;
printf_trunc(opt[i], sizeof(opt[i]), "SSH Username %s", item->user); printf_trunc(opt[i], sizeof(opt[i]), "SSH Username %s", item->user);
i++; i++;
optmap[i] = 9;
sprintf(opt[i++], "BBS Username %s", item->password); sprintf(opt[i++], "BBS Username %s", item->password);
optmap[i] = 10;
sprintf(opt[i++], "BBS Password %s", item->syspass[0] ? "********" : "<none>"); sprintf(opt[i++], "BBS Password %s", item->syspass[0] ? "********" : "<none>");
} }
else { else {
optmap[i] = 8;
printf_trunc(opt[i], sizeof(opt[i]), "Username %s", item->user); printf_trunc(opt[i], sizeof(opt[i]), "Username %s", item->user);
i++; i++;
optmap[i] = 9;
sprintf(opt[i++], "Password %s", item->password[0] ? "********" : "<none>"); sprintf(opt[i++], "Password %s", item->password[0] ? "********" : "<none>");
optmap[i] = 10;
sprintf(opt[i++], "System Password %s", item->syspass[0] ? "********" : "<none>"); sprintf(opt[i++], "System Password %s", item->syspass[0] ? "********" : "<none>");
} }
optmap[i] = 11;
sprintf(opt[i++], "Screen Mode %s", screen_modes[item->screen_mode]); sprintf(opt[i++], "Screen Mode %s", screen_modes[item->screen_mode]);
optmap[i] = 12;
sprintf(opt[i++], "Hide Status Line %s", item->nostatus ? "Yes" : "No"); sprintf(opt[i++], "Hide Status Line %s", item->nostatus ? "Yes" : "No");
optmap[i] = 13;
printf_trunc(opt[i], sizeof(opt[i]), "Download Path %s", item->dldir); printf_trunc(opt[i], sizeof(opt[i]), "Download Path %s", item->dldir);
i++; i++;
optmap[i] = 14;
printf_trunc(opt[i], sizeof(opt[i]), "Upload Path %s", item->uldir); printf_trunc(opt[i], sizeof(opt[i]), "Upload Path %s", item->uldir);
i++; i++;
optmap[i] = 15;
strcpy(opt[i++], "Log Configuration"); strcpy(opt[i++], "Log Configuration");
if (item->bpsrate) if (item->bpsrate)
sprintf(str, "%ubps", item->bpsrate); sprintf(str, "%ubps", item->bpsrate);
else else
strcpy(str, "Current"); strcpy(str, "Current");
optmap[i] = 16;
sprintf(opt[i++], "Comm Rate %s", str); sprintf(opt[i++], "Comm Rate %s", str);
optmap[i] = 17;
sprintf(opt[i++], "ANSI Music %s", music_names[item->music]); sprintf(opt[i++], "ANSI Music %s", music_names[item->music]);
optmap[i] = 18;
sprintf(opt[i++], "Address Family %s", address_family_names[item->address_family]); sprintf(opt[i++], "Address Family %s", address_family_names[item->address_family]);
optmap[i] = 19;
sprintf(opt[i++], "Font %s", item->font); sprintf(opt[i++], "Font %s", item->font);
optmap[i] = 20;
sprintf(opt[i++], "Hide Popups %s", item->hidepopups ? "Yes" : "No"); sprintf(opt[i++], "Hide Popups %s", item->hidepopups ? "Yes" : "No");
optmap[i] = 21;
sprintf(opt[i++], "RIP %s", rip_versions[item->rip]); sprintf(opt[i++], "RIP %s", rip_versions[item->rip]);
optmap[i] = 22;
sprintf(opt[i++], "Force LCF Mode %s", item->force_lcf ? "Yes" : "No"); sprintf(opt[i++], "Force LCF Mode %s", item->force_lcf ? "Yes" : "No");
optmap[i] = 23;
sprintf(opt[i++], "Yellow is Yellow %s", item->yellow_is_yellow ? "Yes" : "No"); sprintf(opt[i++], "Yellow is Yellow %s", item->yellow_is_yellow ? "Yes" : "No");
if (item->conn_type == CONN_TYPE_SSH || item->conn_type == CONN_TYPE_SSHNA) if (item->conn_type == CONN_TYPE_SSH || item->conn_type == CONN_TYPE_SSHNA) {
optmap[i] = 24;
sprintf(opt[i++], "SFTP Public Key %s", item->sftp_public_key ? "Yes" : "No"); sprintf(opt[i++], "SFTP Public Key %s", item->sftp_public_key ? "Yes" : "No");
}
opt[i][0] = 0; opt[i][0] = 0;
uifc.changes = 0; uifc.changes = 0;
...@@ -1314,10 +1370,28 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef ...@@ -1314,10 +1370,28 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef
i = uifc.list(WIN_MID | WIN_SAV | WIN_ACT, 0, 0, 0, &copt, &bar, i = uifc.list(WIN_MID | WIN_SAV | WIN_ACT, 0, 0, 0, &copt, &bar,
isdefault ? "Edit Default Connection" : "Edit Directory Entry", isdefault ? "Edit Default Connection" : "Edit Directory Entry",
opts); opts);
if ((i >= 0) && isdefault) if (i < -1)
i += 2; continue;
if ((i >= 3) && (item->conn_type == CONN_TYPE_SHELL)) // Remember, i gets converted to (unsigned) size_t in comparison
i++; /* no port number */ if (i > 0 && i >= (sizeof(optmap) / sizeof(optmap[0]))) {
continue;
}
if (i >= 0) {
if (optmap[i] == 0)
continue;
i = optmap[i];
strcpy(optname, opt[i]);
for (tmpptr = optname; *tmpptr; tmpptr++) {
if (tmpptr[0] == 0)
break;
if (tmpptr[0] == ' ') {
if (tmpptr[1] == ' ' || tmpptr[1] == 0) {
*tmpptr = 0;
break;
}
}
}
}
switch (i) { switch (i) {
case -1: case -1:
check_exit(false); check_exit(false);
...@@ -1343,74 +1417,157 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef ...@@ -1343,74 +1417,157 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef
} }
strListFree(&inifile); strListFree(&inifile);
return changed; return changed;
case 0: case 0: // name
edit_name(itemname, list, inifile, false); edit_name(itemname, list, inifile, false);
break; break;
case 1: case 1: // address
uifc.helpbuf = address_help; uifc.helpbuf = address_help;
uifc.input(WIN_MID | WIN_SAV, uifc.input(WIN_MID | WIN_SAV,
0, 0, 0 ,optname ,item->addr, LIST_ADDR_MAX, K_EDIT);
0
,
item->conn_type == CONN_TYPE_MODEM ? "Phone Number"
: item->conn_type == CONN_TYPE_SERIAL ? "Device Name"
: item->conn_type == CONN_TYPE_SERIAL_NORTS ? "Device Name"
: item->conn_type == CONN_TYPE_SHELL ? "Command"
: "Address"
,
item->addr,
LIST_ADDR_MAX,
K_EDIT);
check_exit(false); check_exit(false);
iniSetString(&inifile, itemname, "Address", item->addr, &ini_style); iniSetString(&inifile, itemname, "Address", item->addr, &ini_style);
break; break;
case 3: case 2: // conn_type
if ((item->conn_type == CONN_TYPE_MODEM) || (item->conn_type == CONN_TYPE_SERIAL) i = item->conn_type;
|| (item->conn_type == CONN_TYPE_SERIAL_NORTS)) { item->conn_type--;
uifc.helpbuf = "`Flow Control`\n\n" uifc.helpbuf = conn_type_help;
"Select the desired flow control type.\n" switch (uifc.list(WIN_SAV, 0, 0, 0, &(item->conn_type), NULL, optname,
"This should usually be left as \"RTS/CTS\".\n"; &(conn_types[1]))) {
i = fc_to_enum(item->flow_control); case -1:
j = i; check_exit(false);
switch (uifc.list(WIN_SAV, 0, 0, 0, &j, NULL, "Flow Control", fc_names)) { item->conn_type = i;
case -1: break;
check_exit(false); default:
break; item->conn_type++;
default: iniSetEnum(&inifile,
item->flow_control = fc_from_enum(j); itemname,
if (j != i) { "ConnectionType",
iniSetEnum(&inifile, conn_types_enum,
itemname, item->conn_type,
"FlowControl", &ini_style);
fc_enum,
j, // TODO: NOTE: This is destructive! Beware! Ooooooo....
&ini_style); if ((i == CONN_TYPE_SSHNA) && (item->conn_type != CONN_TYPE_SSHNA)) {
uifc.changes = 1; SAFECOPY(item->user, item->password);
} SAFECOPY(item->password, item->syspass);
break; item->syspass[0] = 0;
} }
if ((i != CONN_TYPE_SSHNA) && (item->conn_type == CONN_TYPE_SSHNA)) {
SAFECOPY(item->syspass, item->password);
SAFECOPY(item->password, item->user);
item->user[0] = 0;
}
if ((item->conn_type != CONN_TYPE_MODEM)
&& (item->conn_type != CONN_TYPE_SERIAL)
&& (item->conn_type != CONN_TYPE_SERIAL_NORTS)
&& (item->conn_type != CONN_TYPE_SHELL)) {
/* Set the port too */
j = conn_ports[item->conn_type];
if ((j < 1) || (j > 65535))
j = item->port;
item->port = j;
iniSetShortInt(&inifile,
itemname,
"Port",
item->port,
&ini_style);
}
changed = 1;
break;
} }
else { break;
i = item->port; case 3: // flow_control
sprintf(str, "%hu", item->port); uifc.helpbuf = "`Flow Control`\n\n"
uifc.helpbuf = "`TCP Port`\n\n" "Select the desired flow control type.\n"
"Enter the TCP port number that the server is listening to on the remote system.\n" "This should usually be left as \"RTS/CTS\".\n";
"Telnet is generally port 23, RLogin is generally 513 and SSH is\n" i = fc_to_enum(item->flow_control);
"generally 22\n"; j = i;
uifc.input(WIN_MID | WIN_SAV, 0, 0, "TCP Port", str, 5, K_EDIT | K_NUMBER); switch (uifc.list(WIN_SAV, 0, 0, 0, &j, NULL, optname, fc_names)) {
check_exit(false); case -1:
j = atoi(str); check_exit(false);
if ((j < 1) || (j > 65535)) break;
j = conn_ports[item->conn_type]; default:
item->port = j; item->flow_control = fc_from_enum(j);
iniSetShortInt(&inifile, itemname, "Port", item->port, &ini_style); if (j != i) {
if (i != j) iniSetEnum(&inifile,
uifc.changes = 1; itemname,
else "FlowControl",
uifc.changes = 0; fc_enum,
j,
&ini_style);
uifc.changes = 1;
}
break;
} }
break; break;
case 4: case 4: // stop_bits
switch(item->stop_bits) {
case 1:
item->stop_bits = 2;
break;
default:
item->stop_bits = 1;
break;
}
iniSetUShortInt(&inifile,
itemname,
"StopBits",
item->stop_bits,
&ini_style);
uifc.changes = 1;
break;
case 5: // data_bits
switch(item->data_bits) {
case 8:
item->data_bits = 7;
break;
default:
item->data_bits = 8;
break;
}
iniSetUShortInt(&inifile,
itemname,
"DataBits",
item->data_bits,
&ini_style);
uifc.changes = 1;
break;
case 6: // Parity
uifc.helpbuf = "`Parity`\n\n"
"Select the parity setting.";
i = item->parity;
switch (uifc.list(WIN_SAV, 0, 0, 0, &i, NULL, "Parity", parity_enum)) {
case -1:
check_exit(false);
break;
default:
item->parity = i;
iniSetEnum(&inifile, itemname, "Parity", parity_enum, item->parity, &ini_style);
changed = 1;
}
break;
case 7: // port
i = item->port;
sprintf(str, "%hu", item->port);
uifc.helpbuf = "`TCP Port`\n\n"
"Enter the TCP port number that the server is listening to on the remote system.\n"
"Telnet is generally port 23, RLogin is generally 513 and SSH is\n"
"generally 22\n";
uifc.input(WIN_MID | WIN_SAV, 0, 0, "TCP Port", str, 5, K_EDIT | K_NUMBER);
check_exit(false);
j = atoi(str);
if ((j < 1) || (j > 65535))
j = conn_ports[item->conn_type];
item->port = j;
iniSetUShortInt(&inifile, itemname, "Port", item->port, &ini_style);
if (i != j)
uifc.changes = 1;
else
uifc.changes = 0;
break;
case 8: // user
if (item->conn_type == CONN_TYPE_SSHNA) { if (item->conn_type == CONN_TYPE_SSHNA) {
uifc.helpbuf = "`SSH Username`\n\n" uifc.helpbuf = "`SSH Username`\n\n"
"Enter the username for passwordless SSH authentication."; "Enter the username for passwordless SSH authentication.";
...@@ -1420,32 +1577,29 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef ...@@ -1420,32 +1577,29 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef
"Enter the username to attempt auto-login to the remote with.\n" "Enter the username to attempt auto-login to the remote with.\n"
"For SSH, this must be the SSH user name."; "For SSH, this must be the SSH user name.";
} }
uifc.input(WIN_MID | WIN_SAV, 0, 0, "Username", item->user, MAX_USER_LEN, K_EDIT); uifc.input(WIN_MID | WIN_SAV, 0, 0, optname, item->user, MAX_USER_LEN, K_EDIT);
check_exit(false); check_exit(false);
iniSetString(&inifile, itemname, "UserName", item->user, &ini_style); iniSetString(&inifile, itemname, "UserName", item->user, &ini_style);
break; break;
case 5: case 9: // password
if (item->conn_type == CONN_TYPE_MBBS_GHOST) { if (item->conn_type == CONN_TYPE_MBBS_GHOST) {
uifc.helpbuf = "`GHost Program`\n\n" uifc.helpbuf = "`GHost Program`\n\n"
"Enter the program name to be sent."; "Enter the program name to be sent.";
tmpptr = "GHost Program";
} }
else if (item->conn_type == CONN_TYPE_SSHNA) { else if (item->conn_type == CONN_TYPE_SSHNA) {
uifc.helpbuf = "`BBS Username`\n\n" uifc.helpbuf = "`BBS Username`\n\n"
"Enter the username to be sent for auto-login (ALT-L)."; "Enter the username to be sent for auto-login (ALT-L).";
tmpptr = "BBS Username";
} }
else { else {
uifc.helpbuf = "`Password`\n\n" uifc.helpbuf = "`Password`\n\n"
"Enter your password for auto-login.\n" "Enter your password for auto-login.\n"
"For SSH, this must be the SSH password if it exists.\n"; "For SSH, this must be the SSH password if it exists.\n";
tmpptr = "Password";
} }
uifc.input(WIN_MID | WIN_SAV, 0, 0, tmpptr, item->password, MAX_PASSWD_LEN, K_EDIT); uifc.input(WIN_MID | WIN_SAV, 0, 0, optname, item->password, MAX_PASSWD_LEN, K_EDIT);
check_exit(false); check_exit(false);
iniSetString(&inifile, itemname, "Password", item->password, &ini_style); iniSetString(&inifile, itemname, "Password", item->password, &ini_style);
break; break;
case 6: case 10: // syspass
if (item->conn_type == CONN_TYPE_SSHNA) { if (item->conn_type == CONN_TYPE_SSHNA) {
uifc.helpbuf = "`BBS Password`\n\n" uifc.helpbuf = "`BBS Password`\n\n"
"Enter your password for auto-login. (ALT-L)\n"; "Enter your password for auto-login. (ALT-L)\n";
...@@ -1460,65 +1614,14 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef ...@@ -1460,65 +1614,14 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef
uifc.input(WIN_MID | WIN_SAV, uifc.input(WIN_MID | WIN_SAV,
0, 0,
0, 0,
"System Password", optname,
item->syspass, item->syspass,
MAX_SYSPASS_LEN, MAX_SYSPASS_LEN,
K_EDIT); K_EDIT);
check_exit(false); check_exit(false);
iniSetString(&inifile, itemname, "SystemPassword", item->syspass, &ini_style); iniSetString(&inifile, itemname, "SystemPassword", item->syspass, &ini_style);
break; break;
case 2: case 11: // screen_mode
i = item->conn_type;
item->conn_type--;
uifc.helpbuf = conn_type_help;
switch (uifc.list(WIN_SAV, 0, 0, 0, &(item->conn_type), NULL, "Connection Type",
&(conn_types[1]))) {
case -1:
check_exit(false);
item->conn_type = i;
break;
default:
item->conn_type++;
iniSetEnum(&inifile,
itemname,
"ConnectionType",
conn_types_enum,
item->conn_type,
&ini_style);
// TODO: NOTE: This is destructive! Beware! Ooooooo....
if ((i == CONN_TYPE_SSHNA) && (item->conn_type != CONN_TYPE_SSHNA)) {
SAFECOPY(item->user, item->password);
SAFECOPY(item->password, item->syspass);
item->syspass[0] = 0;
}
if ((i != CONN_TYPE_SSHNA) && (item->conn_type == CONN_TYPE_SSHNA)) {
SAFECOPY(item->syspass, item->password);
SAFECOPY(item->password, item->user);
item->user[0] = 0;
}
if ((item->conn_type != CONN_TYPE_MODEM)
&& (item->conn_type != CONN_TYPE_SERIAL)
&& (item->conn_type != CONN_TYPE_SERIAL_NORTS)
&& (item->conn_type != CONN_TYPE_SHELL)) {
/* Set the port too */
j = conn_ports[item->conn_type];
if ((j < 1) || (j > 65535))
j = item->port;
item->port = j;
iniSetShortInt(&inifile,
itemname,
"Port",
item->port,
&ini_style);
}
changed = 1;
break;
}
break;
case 7:
i = item->screen_mode; i = item->screen_mode;
uifc.helpbuf = "`Screen Mode`\n\n" uifc.helpbuf = "`Screen Mode`\n\n"
"Select the screen size for this connection\n"; "Select the screen size for this connection\n";
...@@ -1620,12 +1723,12 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef ...@@ -1620,12 +1723,12 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef
break; break;
} }
break; break;
case 8: case 12: // nostatus
item->nostatus = !item->nostatus; item->nostatus = !item->nostatus;
changed = 1; changed = 1;
iniSetBool(&inifile, itemname, "NoStatus", item->nostatus, &ini_style); iniSetBool(&inifile, itemname, "NoStatus", item->nostatus, &ini_style);
break; break;
case 9: case 13: // dldir
uifc.helpbuf = "`Download Path`\n\n" uifc.helpbuf = "`Download Path`\n\n"
"Enter the path where downloads will be placed."; "Enter the path where downloads will be placed.";
if (uifc.input(WIN_MID | WIN_SAV, 0, 0, "Download Path", item->dldir, MAX_PATH, if (uifc.input(WIN_MID | WIN_SAV, 0, 0, "Download Path", item->dldir, MAX_PATH,
...@@ -1634,7 +1737,7 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef ...@@ -1634,7 +1737,7 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef
else else
check_exit(false); check_exit(false);
break; break;
case 10: case 14: // uldir
uifc.helpbuf = "`Upload Path`\n\n" uifc.helpbuf = "`Upload Path`\n\n"
"Enter the path where uploads will be browsed from."; "Enter the path where uploads will be browsed from.";
if (uifc.input(WIN_MID | WIN_SAV, 0, 0, "Upload Path", item->uldir, MAX_PATH, if (uifc.input(WIN_MID | WIN_SAV, 0, 0, "Upload Path", item->uldir, MAX_PATH,
...@@ -1643,10 +1746,10 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef ...@@ -1643,10 +1746,10 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef
else else
check_exit(false); check_exit(false);
break; break;
case 11: case 15: // log
configure_log(item, itemname, inifile, &changed); configure_log(item, itemname, inifile, &changed);
break; break;
case 12: case 16: // bpsrate
uifc.helpbuf = "`Comm Rate (in bits-per-second)`\n\n" uifc.helpbuf = "`Comm Rate (in bits-per-second)`\n\n"
"`For TCP connections:`\n" "`For TCP connections:`\n"
"Select the rate which received characters will be displayed.\n\n" "Select the rate which received characters will be displayed.\n\n"
...@@ -1665,7 +1768,7 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef ...@@ -1665,7 +1768,7 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef
changed = 1; changed = 1;
} }
break; break;
case 13: case 17: // music
uifc.helpbuf = music_helpbuf; uifc.helpbuf = music_helpbuf;
i = item->music; i = item->music;
if (uifc.list(WIN_SAV, 0, 0, 0, &i, NULL, "ANSI Music Setup", music_names) != -1) { if (uifc.list(WIN_SAV, 0, 0, 0, &i, NULL, "ANSI Music Setup", music_names) != -1) {
...@@ -1677,7 +1780,7 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef ...@@ -1677,7 +1780,7 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef
check_exit(false); check_exit(false);
} }
break; break;
case 14: case 18: // address_family
uifc.helpbuf = address_family_help; uifc.helpbuf = address_family_help;
i = item->address_family; i = item->address_family;
if (uifc.list(WIN_SAV, 0, 0, 0, &i, NULL, "Address Family", if (uifc.list(WIN_SAV, 0, 0, 0, &i, NULL, "Address Family",
...@@ -1695,7 +1798,7 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef ...@@ -1695,7 +1798,7 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef
check_exit(false); check_exit(false);
} }
break; break;
case 15: case 19: // font
uifc.helpbuf = "`Font`\n\n" uifc.helpbuf = "`Font`\n\n"
"Select the desired font for this connection.\n\n" "Select the desired font for this connection.\n\n"
"Some fonts do not allow some modes. When this is the case, an\n" "Some fonts do not allow some modes. When this is the case, an\n"
...@@ -1714,12 +1817,12 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef ...@@ -1714,12 +1817,12 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef
} }
} }
break; break;
case 16: case 20: // hidepopups
item->hidepopups = !item->hidepopups; item->hidepopups = !item->hidepopups;
changed = 1; changed = 1;
iniSetBool(&inifile, itemname, "HidePopups", item->hidepopups, &ini_style); iniSetBool(&inifile, itemname, "HidePopups", item->hidepopups, &ini_style);
break; break;
case 17: case 21: // rip
item->rip = get_rip_version(item->rip, &changed); item->rip = get_rip_version(item->rip, &changed);
if (item->rip == RIP_VERSION_1) { if (item->rip == RIP_VERSION_1) {
item->screen_mode = SCREEN_MODE_80X43; item->screen_mode = SCREEN_MODE_80X43;
...@@ -1732,17 +1835,17 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef ...@@ -1732,17 +1835,17 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef
} }
iniSetEnum(&inifile, itemname, "RIP", rip_versions, item->rip, &ini_style); iniSetEnum(&inifile, itemname, "RIP", rip_versions, item->rip, &ini_style);
break; break;
case 18: case 22: // force_lcf
item->force_lcf = !item->force_lcf; item->force_lcf = !item->force_lcf;
changed = 1; changed = 1;
iniSetBool(&inifile, itemname, "ForceLCF", item->force_lcf, &ini_style); iniSetBool(&inifile, itemname, "ForceLCF", item->force_lcf, &ini_style);
break; break;
case 19: case 23: // yellow_is_yellow
item->yellow_is_yellow = !item->yellow_is_yellow; item->yellow_is_yellow = !item->yellow_is_yellow;
changed = 1; changed = 1;
iniSetBool(&inifile, itemname, "YellowIsYellow", item->yellow_is_yellow, &ini_style); iniSetBool(&inifile, itemname, "YellowIsYellow", item->yellow_is_yellow, &ini_style);
break; break;
case 20: case 24: // sftp_public_key
item->sftp_public_key = !item->sftp_public_key; item->sftp_public_key = !item->sftp_public_key;
changed = 1; changed = 1;
iniSetBool(&inifile, itemname, "SFTPPublicKey", item->sftp_public_key, &ini_style); iniSetBool(&inifile, itemname, "SFTPPublicKey", item->sftp_public_key, &ini_style);
...@@ -1820,6 +1923,9 @@ add_bbs(char *listpath, struct bbslist *bbs, bool new_entry) ...@@ -1820,6 +1923,9 @@ add_bbs(char *listpath, struct bbslist *bbs, bool new_entry)
iniWriteFile(listfile, inifile); iniWriteFile(listfile, inifile);
fclose(listfile); fclose(listfile);
} }
iniSetUShortInt(&inifile, bbs->name, "StopBits", bbs->stop_bits, &ini_style);
iniSetUShortInt(&inifile, bbs->name, "DataBits", bbs->data_bits, &ini_style);
iniSetEnum(&inifile, bbs->name, "Parity", parity_enum, bbs->parity, &ini_style);
strListFree(&inifile); strListFree(&inifile);
} }
......
...@@ -109,6 +109,12 @@ enum { ...@@ -109,6 +109,12 @@ enum {
RIP_VERSION_3 RIP_VERSION_3
}; };
enum {
PARITY_NONE,
PARITY_EVEN,
PARITY_ODD,
};
/* NOTE: changing this may require updating sort_order in bbslist.c */ /* NOTE: changing this may require updating sort_order in bbslist.c */
struct bbslist { struct bbslist {
char name[LIST_NAME_MAX + 1]; char name[LIST_NAME_MAX + 1];
...@@ -145,6 +151,11 @@ struct bbslist { ...@@ -145,6 +151,11 @@ struct bbslist {
bool has_fingerprint; bool has_fingerprint;
uint8_t ssh_fingerprint[20]; uint8_t ssh_fingerprint[20];
bool sftp_public_key; bool sftp_public_key;
// No way to get a uint8_t from an ini file.
short unsigned int stop_bits;
short unsigned int data_bits;
// Enums are ints (actually, they're unsigned, but ints are what they are
int parity;
}; };
extern char *music_names[]; extern char *music_names[];
......
...@@ -164,7 +164,7 @@ modem_connect(struct bbslist *bbs) ...@@ -164,7 +164,7 @@ modem_connect(struct bbslist *bbs)
return -1; return -1;
} }
} }
if (!comSetParity(com, false, false)) { if (!comSetParity(com, bbs->parity != PARITY_NONE, bbs->parity == PARITY_ODD)) {
if (!bbs->hidepopups) if (!bbs->hidepopups)
uifcmsg("Cannot Set Parity", "`Cannot Set Parity`\n\n" uifcmsg("Cannot Set Parity", "`Cannot Set Parity`\n\n"
"Cannot open the specified serial device.\n"); "Cannot open the specified serial device.\n");
...@@ -172,7 +172,7 @@ modem_connect(struct bbslist *bbs) ...@@ -172,7 +172,7 @@ modem_connect(struct bbslist *bbs)
comClose(com); comClose(com);
return -1; return -1;
} }
if (!comSetBits(com, 8, 1)) { if (!comSetBits(com, bbs->data_bits, bbs->stop_bits)) {
if (!bbs->hidepopups) if (!bbs->hidepopups)
uifcmsg("Cannot Set Data Bits", "`Cannot Set Data Bits`\n\n" uifcmsg("Cannot Set Data Bits", "`Cannot Set Data Bits`\n\n"
"Cannot open the specified serial device.\n"); "Cannot open the specified serial device.\n");
...@@ -209,6 +209,22 @@ modem_connect(struct bbslist *bbs) ...@@ -209,6 +209,22 @@ modem_connect(struct bbslist *bbs)
return -1; return -1;
} }
} }
if (!comSetParity(com, bbs->parity != PARITY_NONE, bbs->parity == PARITY_ODD)) {
if (!bbs->hidepopups)
uifcmsg("Cannot Set Parity", "`Cannot Set Parity`\n\n"
"Cannot open the specified serial device.\n");
conn_api.terminate = -1;
comClose(com);
return -1;
}
if (!comSetBits(com, bbs->data_bits, bbs->stop_bits)) {
if (!bbs->hidepopups)
uifcmsg("Cannot Set Data Bits", "`Cannot Set Data Bits`\n\n"
"Cannot open the specified serial device.\n");
conn_api.terminate = -1;
comClose(com);
return -1;
}
if (!comRaiseDTR(com)) { if (!comRaiseDTR(com)) {
if (!bbs->hidepopups) if (!bbs->hidepopups)
uifcmsg("Cannot Raise DTR", "`Cannot Raise DTR`\n\n" uifcmsg("Cannot Raise DTR", "`Cannot Raise DTR`\n\n"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment