AmendHub

Download:

jcs

/

subtext

/

amendments

/

60

db: Expand phone number field


jcs made amendment 60 over 2 years ago
--- db.c Mon Jan 17 15:21:30 2022 +++ db.c Sat Jan 22 20:30:23 2022 @@ -228,7 +228,7 @@ db_config_load(struct db *tdb) panic("db_config_load: error reading config: %d", bile_error(tdb->bile)); if (rlen != sizeof(tdb->config)) - panic("db_config_load: read config of size %lu, but expected %lu", + warn("db_config_load: read config of size %lu, but expected %lu", rlen, sizeof(tdb->config)); memcpy(&tdb->config, newconfig, sizeof(tdb->config)); --- db.h Sun Jan 16 21:16:37 2022 +++ db.h Sat Jan 22 20:23:41 2022 @@ -47,7 +47,7 @@ struct config { char name[32]; - char phone_number[16]; + char phone_number[32]; char location[64]; char hostname[32]; short telnet_port; --- settings.c Fri Jan 21 14:53:22 2022 +++ settings.c Sat Jan 22 20:35:04 2022 @@ -28,6 +28,8 @@ enum { CONFIG_TYPE_SHORT }; +#define member_size(type, member) sizeof(((type *)0)->member) + struct config_field { char name[32]; short type; @@ -37,15 +39,25 @@ struct config_field { short ditl_id; } config_fields[] = { { "BBS Name", CONFIG_TYPE_STRING, - offsetof(struct config, name), 1, 32, SETTINGS_BBS_NAME_ID }, + offsetof(struct config, name), + 1, member_size(struct config, name), + SETTINGS_BBS_NAME_ID }, { "Phone Number", CONFIG_TYPE_STRING, - offsetof(struct config, phone_number), 1, 16, SETTINGS_PHONE_ID }, + offsetof(struct config, phone_number), + 1, member_size(struct config, phone_number), + SETTINGS_PHONE_ID }, { "Location", CONFIG_TYPE_STRING, - offsetof(struct config, location), 1, 64, SETTINGS_LOCATION_ID }, + offsetof(struct config, location), + 1, member_size(struct config, location), + SETTINGS_LOCATION_ID }, { "Hostname", CONFIG_TYPE_STRING, - offsetof(struct config, hostname), 1, 32, SETTINGS_HOSTNAME_ID }, + offsetof(struct config, hostname), + 1, member_size(struct config, hostname), + SETTINGS_HOSTNAME_ID }, { "Telnet Port", CONFIG_TYPE_SHORT, - offsetof(struct config, telnet_port), 1, 65535, SETTINGS_TELNET_PORT_ID } + offsetof(struct config, telnet_port), + 1, 65535, + SETTINGS_TELNET_PORT_ID } }; struct view_editor {