Skip to content
Snippets Groups Projects
Commit 9f471427 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Speed up by an order of magnitude the loading of new ctrl/????.ini files

By using the new iniCutSection() function primarily, parse and consume
each .ini file section, reducing the search area (ini content/list) for each
section consumed.

The use of iniFreeStringList() intead of strListFree() appeared to have some
benefit to performance as well, likely due to a DLL heap dance.

This brought the file.ini file loading on Vertrauen (8518 lines) down from 10+
seconds (on Windows over SMB/1Gb link to a Samba sever) to less than one scond.
parent d31aab91
No related branches found
No related tags found
No related merge requests found
......@@ -43,7 +43,6 @@ BOOL read_node_cfg(scfg_t* cfg, char* error, size_t maxerrlen)
FILE* fp;
str_list_t ini;
char value[INI_MAX_VALUE_LEN];
const char* section = ROOT_SECTION;
const char* fname = "node.ini";
SAFEPRINTF2(path,"%s%s",cfg->node_dir,fname);
......@@ -54,21 +53,21 @@ BOOL read_node_cfg(scfg_t* cfg, char* error, size_t maxerrlen)
ini = iniReadFile(fp);
fclose(fp);
SAFECOPY(cfg->node_phone, iniGetString(ini, section, "phone", "", value));
SAFECOPY(cfg->node_daily, iniGetString(ini, section, "daily", "", value));
SAFECOPY(cfg->text_dir, iniGetString(ini, section, "text_dir", "../text/", value));
SAFECOPY(cfg->temp_dir, iniGetString(ini, section, "temp_dir", "temp", value));
SAFECOPY(cfg->node_arstr, iniGetString(ini, section, "ars", "", value));
SAFECOPY(cfg->node_phone, iniGetString(ini, ROOT_SECTION, "phone", "", value));
SAFECOPY(cfg->node_daily, iniGetString(ini, ROOT_SECTION, "daily", "", value));
SAFECOPY(cfg->text_dir, iniGetString(ini, ROOT_SECTION, "text_dir", "../text/", value));
SAFECOPY(cfg->temp_dir, iniGetString(ini, ROOT_SECTION, "temp_dir", "temp", value));
SAFECOPY(cfg->node_arstr, iniGetString(ini, ROOT_SECTION, "ars", "", value));
arstr(NULL, cfg->node_arstr, cfg, cfg->node_ar);
cfg->node_misc = iniGetLongInt(ini, section, "settings", 0);
cfg->node_valuser = iniGetShortInt(ini, section, "valuser", 0);
cfg->node_sem_check = iniGetShortInt(ini, section, "sem_check", 60);
cfg->node_stat_check = iniGetShortInt(ini, section, "stat_check", 10);
cfg->sec_warn = iniGetShortInt(ini, section, "sec_warn", 180);
cfg->sec_hangup = iniGetShortInt(ini, section, "sec_hangup", 300);
cfg->node_erruser = iniGetShortInt(ini, section, "erruser", 300);
cfg->node_errlevel = (uchar)iniGetShortInt(ini, section, "errlevel", 0);
cfg->node_misc = iniGetLongInt(ini, ROOT_SECTION, "settings", 0);
cfg->node_valuser = iniGetShortInt(ini, ROOT_SECTION, "valuser", 0);
cfg->node_sem_check = iniGetShortInt(ini, ROOT_SECTION, "sem_check", 60);
cfg->node_stat_check = iniGetShortInt(ini, ROOT_SECTION, "stat_check", 10);
cfg->sec_warn = iniGetShortInt(ini, ROOT_SECTION, "sec_warn", 180);
cfg->sec_hangup = iniGetShortInt(ini, ROOT_SECTION, "sec_hangup", 300);
cfg->node_erruser = iniGetShortInt(ini, ROOT_SECTION, "erruser", 300);
cfg->node_errlevel = (uchar)iniGetShortInt(ini, ROOT_SECTION, "errlevel", 0);
iniFreeStringList(ini);
......@@ -86,7 +85,7 @@ BOOL read_main_cfg(scfg_t* cfg, char* error, size_t maxerrlen)
FILE* fp;
str_list_t ini = NULL;
char value[INI_MAX_VALUE_LEN];
const char* section = ROOT_SECTION;
str_list_t section;
const char* fname = "main.ini";
SAFEPRINTF2(path,"%s%s",cfg->ctrl_dir,fname);
......@@ -98,146 +97,154 @@ BOOL read_main_cfg(scfg_t* cfg, char* error, size_t maxerrlen)
result = TRUE;
}
SAFECOPY(cfg->sys_name, iniGetString(ini, section, "name", "", value));
SAFECOPY(cfg->sys_op, iniGetString(ini, section, "operator", "", value));
SAFECOPY(cfg->sys_pass, iniGetString(ini, section, "password", "", value));
SAFECOPY(cfg->sys_id, iniGetString(ini, section, "qwk_id", "", value));
SAFECOPY(cfg->sys_guru, iniGetString(ini, section, "guru", "", value));
SAFECOPY(cfg->sys_location, iniGetString(ini, section, "location", "", value));
SAFECOPY(cfg->sys_phonefmt, iniGetString(ini, section, "phonefmt", "", value));
SAFECOPY(cfg->sys_chat_arstr, iniGetString(ini, section, "chat_ars", "", value));
SAFECOPY(cfg->sys_name, iniGetString(ini, ROOT_SECTION, "name", "", value));
SAFECOPY(cfg->sys_op, iniGetString(ini, ROOT_SECTION, "operator", "", value));
SAFECOPY(cfg->sys_pass, iniGetString(ini, ROOT_SECTION, "password", "", value));
SAFECOPY(cfg->sys_id, iniGetString(ini, ROOT_SECTION, "qwk_id", "", value));
SAFECOPY(cfg->sys_guru, iniGetString(ini, ROOT_SECTION, "guru", "", value));
SAFECOPY(cfg->sys_location, iniGetString(ini, ROOT_SECTION, "location", "", value));
SAFECOPY(cfg->sys_phonefmt, iniGetString(ini, ROOT_SECTION, "phonefmt", "", value));
SAFECOPY(cfg->sys_chat_arstr, iniGetString(ini, ROOT_SECTION, "chat_ars", "", value));
arstr(NULL, cfg->sys_chat_arstr, cfg, cfg->sys_chat_ar);
cfg->sys_timezone = iniGetShortInt(ini, section, "timezone", 0);
cfg->sys_misc = iniGetLongInt(ini, section, "settings", 0);
cfg->sys_pwdays = iniGetInteger(ini, section, "pwdays", 0);
cfg->sys_deldays = iniGetInteger(ini, section, "deldays", 0);
cfg->sys_exp_warn = iniGetInteger(ini, section, "exp_warn", 0);
cfg->sys_autodel = iniGetInteger(ini, section, "autodel", 0);
cfg->cdt_min_value = iniGetBytes(ini, section, "cdt_min_value", 1, 0);
cfg->max_minutes = iniGetInteger(ini, section, "max_minutes", 0);
cfg->cdt_per_dollar = iniGetBytes(ini, section, "cdt_per_dollar", 1, 0);
cfg->guest_msgscan_init = iniGetInteger(ini, section, "guest_msgscan_init", 0);
cfg->min_pwlen = iniGetInteger(ini, section, "min_pwlen", 0);
cfg->sys_timezone = iniGetShortInt(ini, ROOT_SECTION, "timezone", 0);
cfg->sys_misc = iniGetLongInt(ini, ROOT_SECTION, "settings", 0);
cfg->sys_pwdays = iniGetInteger(ini, ROOT_SECTION, "pwdays", 0);
cfg->sys_deldays = iniGetInteger(ini, ROOT_SECTION, "deldays", 0);
cfg->sys_exp_warn = iniGetInteger(ini, ROOT_SECTION, "exp_warn", 0);
cfg->sys_autodel = iniGetInteger(ini, ROOT_SECTION, "autodel", 0);
cfg->cdt_min_value = iniGetBytes(ini, ROOT_SECTION, "cdt_min_value", 1, 0);
cfg->max_minutes = iniGetInteger(ini, ROOT_SECTION, "max_minutes", 0);
cfg->cdt_per_dollar = iniGetBytes(ini, ROOT_SECTION, "cdt_per_dollar", 1, 0);
cfg->guest_msgscan_init = iniGetInteger(ini, ROOT_SECTION, "guest_msgscan_init", 0);
cfg->min_pwlen = iniGetInteger(ini, ROOT_SECTION, "min_pwlen", 0);
if(cfg->min_pwlen < MIN_PASS_LEN)
cfg->min_pwlen = MIN_PASS_LEN;
if(cfg->min_pwlen > LEN_PASS)
cfg->min_pwlen = LEN_PASS;
cfg->max_log_size = iniGetLongInt(ini, section, "max_log_size", 0);
cfg->max_logs_kept = iniGetInteger(ini, section, "max_logs_kept", 0);
cfg->ctrlkey_passthru = iniGetInteger(ini, section, "ctrlkey_passthru", 0);
cfg->max_log_size = iniGetLongInt(ini, ROOT_SECTION, "max_log_size", 0);
cfg->max_logs_kept = iniGetInteger(ini, ROOT_SECTION, "max_logs_kept", 0);
cfg->ctrlkey_passthru = iniGetInteger(ini, ROOT_SECTION, "ctrlkey_passthru", 0);
cfg->user_backup_level = iniGetInteger(ini, section, "user_backup_level", 5);
cfg->mail_backup_level = iniGetInteger(ini, section, "mail_backup_level", 5);
cfg->new_install = iniGetBool(ini, section, "new_install", FALSE);
cfg->user_backup_level = iniGetInteger(ini, ROOT_SECTION, "user_backup_level", 5);
cfg->mail_backup_level = iniGetInteger(ini, ROOT_SECTION, "mail_backup_level", 5);
cfg->new_install = iniGetBool(ini, ROOT_SECTION, "new_install", FALSE);
// fixed events
SAFECOPY(cfg->sys_logon, iniGetString(ini, "logon_event", "cmd", "", value));
SAFECOPY(cfg->sys_logout, iniGetString(ini, "logout_event", "cmd", "", value));
SAFECOPY(cfg->sys_daily, iniGetString(ini, "daily_event", "cmd", "", value));
str_list_t node_dirs = iniGetKeyList(ini, "node_dir");
section = iniCutSection(ini, "node_dir");
str_list_t node_dirs = iniGetKeyList(section, NULL);
cfg->sys_nodes = strListCount(node_dirs);
for(size_t i=0; i<cfg->sys_nodes; i++) {
SAFECOPY(cfg->node_path[i], iniGetString(ini, "node_dir", node_dirs[i], "", value));
SAFECOPY(cfg->node_path[i], iniGetString(section, NULL, node_dirs[i], "", value));
#if defined(__unix__)
strlwr(cfg->node_path[i]);
#endif
}
strListFree(&node_dirs);
iniFreeStringList(node_dirs);
iniFreeStringList(section);
cfg->sys_lastnode = iniGetInteger(ini, section, "lastnode", cfg->sys_nodes);
cfg->sys_lastnode = iniGetInteger(ini, ROOT_SECTION, "lastnode", cfg->sys_nodes);
section = "dir";
SAFECOPY(cfg->data_dir, iniGetString(ini, section, "data", "../data/", value));
SAFECOPY(cfg->exec_dir, iniGetString(ini, section, "exec", "../exec/", value));
SAFECOPY(cfg->mods_dir, iniGetString(ini, section, "mods", "../mods/", value));
SAFECOPY(cfg->logs_dir, iniGetString(ini, section, "logs", cfg->data_dir, value));
section = iniCutSection(ini, "dir");
SAFECOPY(cfg->data_dir, iniGetString(section, NULL, "data", "../data/", value));
SAFECOPY(cfg->exec_dir, iniGetString(section, NULL, "exec", "../exec/", value));
SAFECOPY(cfg->mods_dir, iniGetString(section, NULL, "mods", "../mods/", value));
SAFECOPY(cfg->logs_dir, iniGetString(section, NULL, "logs", cfg->data_dir, value));
iniFreeStringList(section);
/*********************/
/* New User Settings */
/*********************/
section = "newuser";
cfg->uq = iniGetLongInt(ini, section, "questions", 0);
SAFECOPY(cfg->new_genders, iniGetString(ini, section, "gender_options", "MFX", value));
SAFECOPY(cfg->new_pass, iniGetString(ini, section, "password", "", value));
SAFECOPY(cfg->new_magic, iniGetString(ini, section, "magic_word", "", value));
SAFECOPY(cfg->new_sif, iniGetString(ini, section, "sif", "", value));
SAFECOPY(cfg->new_sof, iniGetString(ini, section, "sof", cfg->new_sif, value));
cfg->new_prot = *iniGetString(ini, section, "download_protocol", " ", value);
section = iniCutSection(ini, "newuser");
cfg->uq = iniGetLongInt(section, NULL, "questions", 0);
SAFECOPY(cfg->new_genders, iniGetString(section, NULL, "gender_options", "MFX", value));
SAFECOPY(cfg->new_pass, iniGetString(section, NULL, "password", "", value));
SAFECOPY(cfg->new_magic, iniGetString(section, NULL, "magic_word", "", value));
SAFECOPY(cfg->new_sif, iniGetString(section, NULL, "sif", "", value));
SAFECOPY(cfg->new_sof, iniGetString(section, NULL, "sof", cfg->new_sif, value));
cfg->new_prot = *iniGetString(section, NULL, "download_protocol", " ", value);
char new_shell[LEN_CODE + 1];
SAFECOPY(new_shell, iniGetString(ini, section, "shell", "default", value));
SAFECOPY(cfg->new_xedit, iniGetString(ini, section, "editor", "", value));
cfg->new_level = iniGetInteger(ini, section, "level", 0);
cfg->new_flags1 = iniGetLongInt(ini, section, "flags1", 0);
cfg->new_flags2 = iniGetLongInt(ini, section, "flags2", 0);
cfg->new_flags3 = iniGetLongInt(ini, section, "flags3", 0);
cfg->new_flags4 = iniGetLongInt(ini, section, "flags4", 0);
cfg->new_exempt = iniGetLongInt(ini, section, "exemptions", 0);
cfg->new_rest = iniGetLongInt(ini, section, "restrictions", 0);
cfg->new_cdt = iniGetBytes(ini, section, "credits", 1, 0);
cfg->new_min = iniGetLongInt(ini, section, "minutes", 0);
cfg->new_expire = iniGetInteger(ini, section, "expire", 0);
cfg->new_misc = iniGetLongInt(ini, section, "settings", 0);
cfg->new_msgscan_init = iniGetInteger(ini, section, "msgscan_init", 0);
SAFECOPY(new_shell, iniGetString(section, NULL, "shell", "default", value));
SAFECOPY(cfg->new_xedit, iniGetString(section, NULL, "editor", "", value));
cfg->new_level = iniGetInteger(section, NULL, "level", 0);
cfg->new_flags1 = iniGetLongInt(section, NULL, "flags1", 0);
cfg->new_flags2 = iniGetLongInt(section, NULL, "flags2", 0);
cfg->new_flags3 = iniGetLongInt(section, NULL, "flags3", 0);
cfg->new_flags4 = iniGetLongInt(section, NULL, "flags4", 0);
cfg->new_exempt = iniGetLongInt(section, NULL, "exemptions", 0);
cfg->new_rest = iniGetLongInt(section, NULL, "restrictions", 0);
cfg->new_cdt = iniGetBytes(section, NULL, "credits", 1, 0);
cfg->new_min = iniGetLongInt(section, NULL, "minutes", 0);
cfg->new_expire = iniGetInteger(section, NULL, "expire", 0);
cfg->new_misc = iniGetLongInt(section, NULL, "settings", 0);
cfg->new_msgscan_init = iniGetInteger(section, NULL, "msgscan_init", 0);
iniFreeStringList(section);
/*************************/
/* Expired User Settings */
/*************************/
section = "expired";
cfg->expired_level = iniGetInteger(ini, section, "level", 0);
cfg->expired_flags1 = iniGetLongInt(ini, section, "flags1", 0);
cfg->expired_flags2 = iniGetLongInt(ini, section, "flags2", 0);
cfg->expired_flags3 = iniGetLongInt(ini, section, "flags3", 0);
cfg->expired_flags4 = iniGetLongInt(ini, section, "flags4", 0);
cfg->expired_exempt = iniGetLongInt(ini, section, "exemptions", 0);
cfg->expired_rest = iniGetLongInt(ini, section, "restrictions", 0);
section = iniCutSection(ini, "expired");
cfg->expired_level = iniGetInteger(section, NULL, "level", 0);
cfg->expired_flags1 = iniGetLongInt(section, NULL, "flags1", 0);
cfg->expired_flags2 = iniGetLongInt(section, NULL, "flags2", 0);
cfg->expired_flags3 = iniGetLongInt(section, NULL, "flags3", 0);
cfg->expired_flags4 = iniGetLongInt(section, NULL, "flags4", 0);
cfg->expired_exempt = iniGetLongInt(section, NULL, "exemptions", 0);
cfg->expired_rest = iniGetLongInt(section, NULL, "restrictions", 0);
iniFreeStringList(section);
/***********/
/* Modules */
/***********/
section = "module";
SAFECOPY(cfg->logon_mod, iniGetString(ini, section, "logon", "logon", value));
SAFECOPY(cfg->logoff_mod, iniGetString(ini, section, "logoff", "", value));
SAFECOPY(cfg->newuser_mod, iniGetString(ini, section, "newuser", "newuser", value));
SAFECOPY(cfg->login_mod, iniGetString(ini, section, "login", "login", value));
SAFECOPY(cfg->logout_mod, iniGetString(ini, section, "logout", "", value));
SAFECOPY(cfg->sync_mod, iniGetString(ini, section, "sync", "", value));
SAFECOPY(cfg->expire_mod, iniGetString(ini, section, "expire", "", value));
SAFECOPY(cfg->readmail_mod, iniGetString(ini, section, "readmail", "", value));
SAFECOPY(cfg->scanposts_mod, iniGetString(ini, section, "scanposts", "", value));
SAFECOPY(cfg->scansubs_mod, iniGetString(ini, section, "scansubs", "", value));
SAFECOPY(cfg->listmsgs_mod, iniGetString(ini, section, "listmsgs", "", value));
SAFECOPY(cfg->textsec_mod, iniGetString(ini, section, "text_sec", "text_sec", value));
SAFECOPY(cfg->automsg_mod, iniGetString(ini, section, "automsg", "automsg", value));
SAFECOPY(cfg->xtrnsec_mod, iniGetString(ini, section, "xtrnsec", "xtrn_sec", value));
SAFECOPY(cfg->nodelist_mod, iniGetString(ini, section, "nodelist", "nodelist", value));
SAFECOPY(cfg->whosonline_mod, iniGetString(ini, section, "whosonline", "nodelist -active", value));
SAFECOPY(cfg->privatemsg_mod, iniGetString(ini, section, "privatemsg", "privatemsg", value));
SAFECOPY(cfg->logonlist_mod, iniGetString(ini, section, "logonlist", "logonlist", value));
SAFECOPY(cfg->prextrn_mod, iniGetString(ini, section, "prextrn", "prextrn", value));
SAFECOPY(cfg->postxtrn_mod, iniGetString(ini, section, "postxtrn", "postxtrn", value));
SAFECOPY(cfg->tempxfer_mod, iniGetString(ini, section, "tempxfer", "tempxfer", value));
section = iniCutSection(ini, "module");
SAFECOPY(cfg->logon_mod, iniGetString(section, NULL, "logon", "logon", value));
SAFECOPY(cfg->logoff_mod, iniGetString(section, NULL, "logoff", "", value));
SAFECOPY(cfg->newuser_mod, iniGetString(section, NULL, "newuser", "newuser", value));
SAFECOPY(cfg->login_mod, iniGetString(section, NULL, "login", "login", value));
SAFECOPY(cfg->logout_mod, iniGetString(section, NULL, "logout", "", value));
SAFECOPY(cfg->sync_mod, iniGetString(section, NULL, "sync", "", value));
SAFECOPY(cfg->expire_mod, iniGetString(section, NULL, "expire", "", value));
SAFECOPY(cfg->readmail_mod, iniGetString(section, NULL, "readmail", "", value));
SAFECOPY(cfg->scanposts_mod, iniGetString(section, NULL, "scanposts", "", value));
SAFECOPY(cfg->scansubs_mod, iniGetString(section, NULL, "scansubs", "", value));
SAFECOPY(cfg->listmsgs_mod, iniGetString(section, NULL, "listmsgs", "", value));
SAFECOPY(cfg->textsec_mod, iniGetString(section, NULL, "text_sec", "text_sec", value));
SAFECOPY(cfg->automsg_mod, iniGetString(section, NULL, "automsg", "automsg", value));
SAFECOPY(cfg->xtrnsec_mod, iniGetString(section, NULL, "xtrnsec", "xtrn_sec", value));
SAFECOPY(cfg->nodelist_mod, iniGetString(section, NULL, "nodelist", "nodelist", value));
SAFECOPY(cfg->whosonline_mod, iniGetString(section, NULL, "whosonline", "nodelist -active", value));
SAFECOPY(cfg->privatemsg_mod, iniGetString(section, NULL, "privatemsg", "privatemsg", value));
SAFECOPY(cfg->logonlist_mod, iniGetString(section, NULL, "logonlist", "logonlist", value));
SAFECOPY(cfg->prextrn_mod, iniGetString(section, NULL, "prextrn", "prextrn", value));
SAFECOPY(cfg->postxtrn_mod, iniGetString(section, NULL, "postxtrn", "postxtrn", value));
SAFECOPY(cfg->tempxfer_mod, iniGetString(section, NULL, "tempxfer", "tempxfer", value));
iniFreeStringList(section);
/*******************/
/* Validation Sets */
/*******************/
for(uint i=0; i<10; i++) {
char str[128];
SAFEPRINTF(str, "valset:%u", i);
section = str;
cfg->val_level[i] = iniGetInteger(ini, section, "level", 0);
cfg->val_expire[i] = iniGetInteger(ini, section, "expire", 0);
cfg->val_flags1[i] = iniGetLongInt(ini, section, "flags1", 0);
cfg->val_flags2[i] = iniGetLongInt(ini, section, "flags2", 0);
cfg->val_flags3[i] = iniGetLongInt(ini, section, "flags3", 0);
cfg->val_flags4[i] = iniGetLongInt(ini, section, "flags4", 0);
cfg->val_cdt[i] = iniGetBytes(ini, section, "credits", 1, 0);
cfg->val_exempt[i] = iniGetLongInt(ini, section, "exemptions", 0);
cfg->val_rest[i] = iniGetLongInt(ini, section, "restrictions", 0);
char name[128];
SAFEPRINTF(name, "valset:%u", i);
section = iniCutSection(ini, name);
cfg->val_level[i] = iniGetInteger(section, NULL, "level", 0);
cfg->val_expire[i] = iniGetInteger(section, NULL, "expire", 0);
cfg->val_flags1[i] = iniGetLongInt(section, NULL, "flags1", 0);
cfg->val_flags2[i] = iniGetLongInt(section, NULL, "flags2", 0);
cfg->val_flags3[i] = iniGetLongInt(section, NULL, "flags3", 0);
cfg->val_flags4[i] = iniGetLongInt(section, NULL, "flags4", 0);
cfg->val_cdt[i] = iniGetBytes(section, NULL, "credits", 1, 0);
cfg->val_exempt[i] = iniGetLongInt(section, NULL, "exemptions", 0);
cfg->val_rest[i] = iniGetLongInt(section, NULL, "restrictions", 0);
iniFreeStringList(section);
}
/***************************/
......@@ -245,18 +252,19 @@ BOOL read_main_cfg(scfg_t* cfg, char* error, size_t maxerrlen)
/***************************/
for(uint i=0; i<100; i++) {
char str[128];
SAFEPRINTF(str, "level:%u", i);
section = str;
cfg->level_timeperday[i] = iniGetInteger(ini, section, "timeperday", 0);
cfg->level_timepercall[i] = iniGetInteger(ini, section, "timepercall", 0);
cfg->level_callsperday[i] = iniGetInteger(ini, section, "callsperday", 0);
cfg->level_linespermsg[i] = iniGetInteger(ini, section, "linespermsg", 0);
cfg->level_postsperday[i] = iniGetInteger(ini, section, "postsperday", 0);
cfg->level_emailperday[i] = iniGetInteger(ini, section, "emailperday", 0);
cfg->level_misc[i] = iniGetLongInt(ini, section, "settings", 0);
cfg->level_expireto[i] = iniGetInteger(ini, section, "expireto", 0);
cfg->level_freecdtperday[i] = iniGetBytes(ini, section, "freecdtperday", 1, 0);
char name[128];
SAFEPRINTF(name, "level:%u", i);
section = iniCutSection(ini, name);
cfg->level_timeperday[i] = iniGetInteger(section, NULL, "timeperday", 0);
cfg->level_timepercall[i] = iniGetInteger(section, NULL, "timepercall", 0);
cfg->level_callsperday[i] = iniGetInteger(section, NULL, "callsperday", 0);
cfg->level_linespermsg[i] = iniGetInteger(section, NULL, "linespermsg", 0);
cfg->level_postsperday[i] = iniGetInteger(section, NULL, "postsperday", 0);
cfg->level_emailperday[i] = iniGetInteger(section, NULL, "emailperday", 0);
cfg->level_misc[i] = iniGetLongInt(section, NULL, "settings", 0);
cfg->level_expireto[i] = iniGetInteger(section, NULL, "expireto", 0);
cfg->level_freecdtperday[i] = iniGetBytes(section, NULL, "freecdtperday", 1, 0);
iniFreeStringList(section);
}
str_list_t shell_list = iniGetSectionList(ini, "shell:");
......@@ -280,14 +288,16 @@ BOOL read_main_cfg(scfg_t* cfg, char* error, size_t maxerrlen)
return allocerr(error, maxerrlen, fname, "shell", sizeof(shell_t));
memset(cfg->shell[i],0,sizeof(shell_t));
section = shell_list[i];
SAFECOPY(cfg->shell[i]->code, section + 6);
SAFECOPY(cfg->shell[i]->name, iniGetString(ini, section, "name", section + 6, value));
SAFECOPY(cfg->shell[i]->arstr, iniGetString(ini, section, "ars", "", value));
const char* name = shell_list[i];
section = iniCutSection(ini, name);
SAFECOPY(cfg->shell[i]->code, name + 6);
SAFECOPY(cfg->shell[i]->name, iniGetString(section, NULL, "name", name + 6, value));
SAFECOPY(cfg->shell[i]->arstr, iniGetString(section, NULL, "ars", "", value));
arstr(NULL,cfg->shell[i]->arstr,cfg,cfg->shell[i]->ar);
cfg->shell[i]->misc = iniGetLongInt(ini, section, "settings", 0);
cfg->shell[i]->misc = iniGetLongInt(section, NULL, "settings", 0);
if(stricmp(cfg->shell[i]->code, new_shell) == 0)
cfg->new_shell = i;
iniFreeStringList(section);
}
iniFreeStringList(shell_list);
......@@ -306,7 +316,6 @@ BOOL read_msgs_cfg(scfg_t* cfg, char* error, size_t maxerrlen)
FILE* fp;
str_list_t ini;
char value[INI_MAX_VALUE_LEN];
const char* section = ROOT_SECTION;
const char* fname = "msgs.ini";
SAFEPRINTF2(path,"%s%s",cfg->ctrl_dir,fname);
......@@ -320,22 +329,24 @@ BOOL read_msgs_cfg(scfg_t* cfg, char* error, size_t maxerrlen)
/*************************/
/* General Message Stuff */
/*************************/
cfg->smb_retry_time = iniGetInteger(ini, section, "smb_retry_time", 30);
cfg->smb_retry_time = iniGetInteger(ini, ROOT_SECTION, "smb_retry_time", 30);
/* QWK stuff */
section = "QWK";
cfg->msg_misc = iniGetLongInt(ini, section, "settings", 0xffff0000);
cfg->max_qwkmsgs = iniGetInteger(ini, section, "max_msgs", 0);
cfg->max_qwkmsgage = iniGetInteger(ini, section, "max_age", 0);
SAFECOPY(cfg->qnet_tagline, iniGetString(ini, section, "default_tagline", "", value));
SAFECOPY(cfg->preqwk_arstr, iniGetString(ini, section, "prepack_ars", "", value));
str_list_t section = iniCutSection(ini, "QWK");
cfg->msg_misc = iniGetLongInt(section, NULL, "settings", 0xffff0000);
cfg->max_qwkmsgs = iniGetInteger(section, NULL, "max_msgs", 0);
cfg->max_qwkmsgage = iniGetInteger(section, NULL, "max_age", 0);
SAFECOPY(cfg->qnet_tagline, iniGetString(section, NULL, "default_tagline", "", value));
SAFECOPY(cfg->preqwk_arstr, iniGetString(section, NULL, "prepack_ars", "", value));
arstr(NULL, cfg->preqwk_arstr, cfg, cfg->preqwk_ar);
iniFreeStringList(section);
/* E-Mail stuff */
section = "mail";
cfg->mail_maxcrcs = iniGetInteger(ini, section, "max_crcs", 0);
cfg->mail_maxage = iniGetInteger(ini, section, "max_age", 0);
cfg->max_spamage = iniGetInteger(ini, section, "max_spam_age", 0);
section = iniCutSection(ini, "mail");
cfg->mail_maxcrcs = iniGetInteger(section, NULL, "max_crcs", 0);
cfg->mail_maxage = iniGetInteger(section, NULL, "max_age", 0);
cfg->max_spamage = iniGetInteger(section, NULL, "max_spam_age", 0);
iniFreeStringList(section);
/******************/
/* Message Groups */
......@@ -352,18 +363,20 @@ BOOL read_msgs_cfg(scfg_t* cfg, char* error, size_t maxerrlen)
for(uint i=0; i<cfg->total_grps; i++) {
section = grp_list[i];
const char* name = grp_list[i];
if((cfg->grp[i]=(grp_t *)malloc(sizeof(grp_t)))==NULL)
return allocerr(error, maxerrlen, fname, "group", sizeof(grp_t));
section = iniCutSection(ini, name);
memset(cfg->grp[i],0,sizeof(grp_t));
SAFECOPY(cfg->grp[i]->sname, section + 4);
SAFECOPY(cfg->grp[i]->lname, iniGetString(ini, section, "description", section + 4, value));
SAFECOPY(cfg->grp[i]->code_prefix, iniGetString(ini, section, "code_prefix", "", value));
SAFECOPY(cfg->grp[i]->arstr, iniGetString(ini, section, "ars", "", value));
SAFECOPY(cfg->grp[i]->sname, name + 4);
SAFECOPY(cfg->grp[i]->lname, iniGetString(section, NULL, "description", name + 4, value));
SAFECOPY(cfg->grp[i]->code_prefix, iniGetString(section, NULL, "code_prefix", "", value));
SAFECOPY(cfg->grp[i]->arstr, iniGetString(section, NULL, "ars", "", value));
arstr(NULL, cfg->grp[i]->arstr, cfg, cfg->grp[i]->ar);
cfg->grp[i]->sort = iniGetInteger(ini, section, "sort", 0);
cfg->grp[i]->sort = iniGetInteger(section, NULL, "sort", 0);
iniFreeStringList(section);
}
strListFree(&grp_list);
iniFreeStringList(grp_list);
/**********************/
/* Message Sub-boards */
......@@ -382,8 +395,8 @@ BOOL read_msgs_cfg(scfg_t* cfg, char* error, size_t maxerrlen)
for(uint i=0; sub_list[i] != NULL; i++) {
char group[INI_MAX_VALUE_LEN];
section = sub_list[i];
SAFECOPY(group, section + 4);
const char* name = sub_list[i];
SAFECOPY(group, name + 4);
char* p = strchr(group, ':');
if(p == NULL)
continue;
......@@ -394,21 +407,22 @@ BOOL read_msgs_cfg(scfg_t* cfg, char* error, size_t maxerrlen)
continue;
if((cfg->sub[i]=(sub_t *)malloc(sizeof(sub_t)))==NULL)
return allocerr(error, maxerrlen, fname, "sub", sizeof(sub_t));
section = iniCutSection(ini, name);
memset(cfg->sub[i],0,sizeof(sub_t));
SAFECOPY(cfg->sub[i]->code_suffix, code);
cfg->sub[i]->subnum = i;
cfg->sub[i]->grp = grpnum;
SAFECOPY(cfg->sub[i]->lname, iniGetString(ini, section, "description", code, value));
SAFECOPY(cfg->sub[i]->sname, iniGetString(ini, section, "name", code, value));
SAFECOPY(cfg->sub[i]->qwkname, iniGetString(ini, section, "qwk_name", code, value));
SAFECOPY(cfg->sub[i]->data_dir, iniGetString(ini, section, "data_dir", "", value));
SAFECOPY(cfg->sub[i]->lname, iniGetString(section, NULL, "description", code, value));
SAFECOPY(cfg->sub[i]->sname, iniGetString(section, NULL, "name", code, value));
SAFECOPY(cfg->sub[i]->qwkname, iniGetString(section, NULL, "qwk_name", code, value));
SAFECOPY(cfg->sub[i]->data_dir, iniGetString(section, NULL, "data_dir", "", value));
SAFECOPY(cfg->sub[i]->arstr, iniGetString(ini, section, "ars", "", value));
SAFECOPY(cfg->sub[i]->read_arstr, iniGetString(ini, section, "read_ars", "", value));
SAFECOPY(cfg->sub[i]->post_arstr, iniGetString(ini, section, "post_ars", "", value));
SAFECOPY(cfg->sub[i]->op_arstr, iniGetString(ini, section, "operator_ars", "", value));
SAFECOPY(cfg->sub[i]->mod_arstr, iniGetString(ini, section, "moderated_ars", "", value));
SAFECOPY(cfg->sub[i]->arstr, iniGetString(section, NULL, "ars", "", value));
SAFECOPY(cfg->sub[i]->read_arstr, iniGetString(section, NULL, "read_ars", "", value));
SAFECOPY(cfg->sub[i]->post_arstr, iniGetString(section, NULL, "post_ars", "", value));
SAFECOPY(cfg->sub[i]->op_arstr, iniGetString(section, NULL, "operator_ars", "", value));
SAFECOPY(cfg->sub[i]->mod_arstr, iniGetString(section, NULL, "moderated_ars", "", value));
arstr(NULL, cfg->sub[i]->arstr, cfg, cfg->sub[i]->ar);
arstr(NULL, cfg->sub[i]->read_arstr, cfg, cfg->sub[i]->read_ar);
......@@ -416,21 +430,21 @@ BOOL read_msgs_cfg(scfg_t* cfg, char* error, size_t maxerrlen)
arstr(NULL, cfg->sub[i]->op_arstr, cfg, cfg->sub[i]->op_ar);
arstr(NULL, cfg->sub[i]->mod_arstr, cfg,cfg->sub[i]->mod_ar);
cfg->sub[i]->misc = iniGetLongInt(ini, section, "settings", 0);
cfg->sub[i]->misc = iniGetLongInt(section, NULL, "settings", 0);
if((cfg->sub[i]->misc&(SUB_FIDO|SUB_INET)) && !(cfg->sub[i]->misc&SUB_QNET))
cfg->sub[i]->misc|=SUB_NOVOTING;
SAFECOPY(cfg->sub[i]->tagline, iniGetString(ini, section, "qwknet_tagline", "", value));
SAFECOPY(cfg->sub[i]->origline, iniGetString(ini, section, "fidonet_origin", "", value));
SAFECOPY(cfg->sub[i]->post_sem, iniGetString(ini, section, "post_sem", "", value));
SAFECOPY(cfg->sub[i]->newsgroup, iniGetString(ini, section, "newsgroup", "", value));
SAFECOPY(cfg->sub[i]->area_tag, iniGetString(ini, section, "area_tag", "", value));
cfg->sub[i]->faddr = smb_atofaddr(NULL, iniGetString(ini, section, "fidonet_addr", "", value));
cfg->sub[i]->maxmsgs = iniGetInteger(ini, section, "max_msgs", 0);
cfg->sub[i]->maxcrcs = iniGetInteger(ini, section, "max_crcs", 0);
cfg->sub[i]->maxage = iniGetInteger(ini, section, "max_age", 0);
cfg->sub[i]->ptridx = iniGetInteger(ini, section, "ptridx", 0);
SAFECOPY(cfg->sub[i]->tagline, iniGetString(section, NULL, "qwknet_tagline", "", value));
SAFECOPY(cfg->sub[i]->origline, iniGetString(section, NULL, "fidonet_origin", "", value));
SAFECOPY(cfg->sub[i]->post_sem, iniGetString(section, NULL, "post_sem", "", value));
SAFECOPY(cfg->sub[i]->newsgroup, iniGetString(section, NULL, "newsgroup", "", value));
SAFECOPY(cfg->sub[i]->area_tag, iniGetString(section, NULL, "area_tag", "", value));
cfg->sub[i]->faddr = smb_atofaddr(NULL, iniGetString(section, NULL, "fidonet_addr", "", value));
cfg->sub[i]->maxmsgs = iniGetInteger(section, NULL, "max_msgs", 0);
cfg->sub[i]->maxcrcs = iniGetInteger(section, NULL, "max_crcs", 0);
cfg->sub[i]->maxage = iniGetInteger(section, NULL, "max_age", 0);
cfg->sub[i]->ptridx = iniGetInteger(section, NULL, "ptridx", 0);
#ifdef SBBS
for(uint j=0; j<i; j++)
if(cfg->sub[i]->ptridx==cfg->sub[j]->ptridx) {
......@@ -442,18 +456,19 @@ BOOL read_msgs_cfg(scfg_t* cfg, char* error, size_t maxerrlen)
#endif
cfg->sub[i]->qwkconf = iniGetShortInt(ini, section, "qwk_conf", 0);
cfg->sub[i]->pmode = iniGetLongInt(ini, section, "print_mode", 0);
cfg->sub[i]->n_pmode = iniGetLongInt(ini, section, "print_mode_neg", 0);
cfg->sub[i]->qwkconf = iniGetShortInt(section, NULL, "qwk_conf", 0);
cfg->sub[i]->pmode = iniGetLongInt(section, NULL, "print_mode", 0);
cfg->sub[i]->n_pmode = iniGetLongInt(section, NULL, "print_mode_neg", 0);
iniFreeStringList(section);
++cfg->total_subs;
}
strListFree(&sub_list);
iniFreeStringList(sub_list);
/***********/
/* FidoNet */
/***********/
section = "fidonet";
str_list_t faddr_list = iniGetStringList(ini, section, "addr_list", ",", "");
section = iniCutSection(ini, "fidonet");
str_list_t faddr_list = iniGetStringList(section, NULL, "addr_list", ",", "");
cfg->total_faddrs = strListCount(faddr_list);
if(cfg->total_faddrs) {
......@@ -464,19 +479,20 @@ BOOL read_msgs_cfg(scfg_t* cfg, char* error, size_t maxerrlen)
for(uint i=0;i<cfg->total_faddrs;i++)
cfg->faddr[i] = smb_atofaddr(NULL, faddr_list[i]);
strListFree(&faddr_list);
iniFreeStringList(faddr_list);
// Sanity-check each sub's FidoNet-style address
for(uint i = 0; i < cfg->total_subs; i++)
cfg->sub[i]->faddr = *nearest_sysfaddr(cfg, &cfg->sub[i]->faddr);
SAFECOPY(cfg->origline, iniGetString(ini, section, "default_origin", "", value));
SAFECOPY(cfg->netmail_sem, iniGetString(ini, section, "netmail_sem", "", value));
SAFECOPY(cfg->echomail_sem, iniGetString(ini, section, "echomail_sem", "", value));
SAFECOPY(cfg->netmail_dir, iniGetString(ini, section, "netmail_dir", "", value));
SAFECOPY(cfg->fidofile_dir, iniGetString(ini, section, "file_dir", "", value));
cfg->netmail_misc = iniGetLongInt(ini, section, "netmail_settings", 0);
cfg->netmail_cost = iniGetLongInt(ini, section, "netmail_cost", 0);
SAFECOPY(cfg->origline, iniGetString(section, NULL, "default_origin", "", value));
SAFECOPY(cfg->netmail_sem, iniGetString(section, NULL, "netmail_sem", "", value));
SAFECOPY(cfg->echomail_sem, iniGetString(section, NULL, "echomail_sem", "", value));
SAFECOPY(cfg->netmail_dir, iniGetString(section, NULL, "netmail_dir", "", value));
SAFECOPY(cfg->fidofile_dir, iniGetString(section, NULL, "file_dir", "", value));
cfg->netmail_misc = iniGetLongInt(section, NULL, "netmail_settings", 0);
cfg->netmail_cost = iniGetLongInt(section, NULL, "netmail_cost", 0);
iniFreeStringList(section);
/**********/
/* QWKnet */
......@@ -492,21 +508,22 @@ BOOL read_msgs_cfg(scfg_t* cfg, char* error, size_t maxerrlen)
cfg->total_qhubs = 0;
for(uint i=0; qhub_list[i] != NULL; i++) {
section = qhub_list[i];
const char* name = qhub_list[i];
if((cfg->qhub[i]=(qhub_t *)malloc(sizeof(qhub_t)))==NULL)
return allocerr(error, maxerrlen, fname, "qhub", sizeof(qhub_t));
section = iniCutSection(ini, name);
memset(cfg->qhub[i],0,sizeof(qhub_t));
SAFECOPY(cfg->qhub[i]->id, section + 5);
cfg->qhub[i]->time = iniGetShortInt(ini, section, "time", 0);
cfg->qhub[i]->freq = iniGetShortInt(ini, section, "freq", 0);
cfg->qhub[i]->days = iniGetShortInt(ini, section, "days", 0);
cfg->qhub[i]->node = iniGetShortInt(ini, section, "node", 0);
SAFECOPY(cfg->qhub[i]->call, iniGetString(ini, section, "call", "", value));
SAFECOPY(cfg->qhub[i]->pack, iniGetString(ini, section, "pack", "", value));
SAFECOPY(cfg->qhub[i]->unpack, iniGetString(ini, section, "unpack", "", value));
SAFECOPY(cfg->qhub[i]->fmt, iniGetString(ini, section, "format", "zip", value));
cfg->qhub[i]->misc = iniGetLongInt(ini, section, "settings", 0);
SAFECOPY(cfg->qhub[i]->id, name + 5);
cfg->qhub[i]->time = iniGetShortInt(section, NULL, "time", 0);
cfg->qhub[i]->freq = iniGetShortInt(section, NULL, "freq", 0);
cfg->qhub[i]->days = iniGetShortInt(section, NULL, "days", 0);
cfg->qhub[i]->node = iniGetShortInt(section, NULL, "node_num", 0);
SAFECOPY(cfg->qhub[i]->call, iniGetString(section, NULL, "call", "", value));
SAFECOPY(cfg->qhub[i]->pack, iniGetString(section, NULL, "pack", "", value));
SAFECOPY(cfg->qhub[i]->unpack, iniGetString(section, NULL, "unpack", "", value));
SAFECOPY(cfg->qhub[i]->fmt, iniGetString(section, NULL, "format", "zip", value));
cfg->qhub[i]->misc = iniGetLongInt(section, NULL, "settings", 0);
char str[128];
SAFEPRINTF(str, "qhubsub:%s:", cfg->qhub[i]->id);
......@@ -523,14 +540,14 @@ BOOL read_msgs_cfg(scfg_t* cfg, char* error, size_t maxerrlen)
for(uint j=0;j<k;j++) {
uint16_t confnum;
uint16_t subnum;
int subnum;
char subcode[LEN_EXTCODE + 1];
uint8_t mode;
confnum = atoi(qsub_list[j] + strlen(str));
SAFECOPY(subcode, iniGetString(ini, qsub_list[j], "sub", "", value));
subnum = getsubnum(cfg, subcode);
mode = iniGetLongInt(ini, qsub_list[i], "mode", 0);
if(subnum < cfg->total_subs) {
if(is_valid_subnum(cfg, subnum)) {
cfg->sub[subnum]->misc |= SUB_QNET;
cfg->qhub[i]->sub[cfg->qhub[i]->subs] = cfg->sub[subnum];
cfg->qhub[i]->mode[cfg->qhub[i]->subs] = mode;
......@@ -538,20 +555,22 @@ BOOL read_msgs_cfg(scfg_t* cfg, char* error, size_t maxerrlen)
cfg->qhub[i]->subs++;
}
}
strListFree(&qsub_list);
iniFreeStringList(qsub_list);
iniFreeStringList(section);
++cfg->total_qhubs;
}
strListFree(&qhub_list);
iniFreeStringList(qhub_list);
/************/
/* Internet */
/************/
section = "Internet";
SAFECOPY(cfg->sys_inetaddr, iniGetString(ini, section, "addr", "", value));
SAFECOPY(cfg->inetmail_sem, iniGetString(ini, section, "netmail_sem", "", value));
SAFECOPY(cfg->smtpmail_sem, iniGetString(ini, section, "smtp_sem", "", value));
cfg->inetmail_misc = iniGetLongInt(ini, section, "settings", 0);
cfg->inetmail_cost = iniGetLongInt(ini, section, "cost", 0);
section = iniCutSection(ini, "Internet");
SAFECOPY(cfg->sys_inetaddr, iniGetString(section, NULL, "addr", "", value));
SAFECOPY(cfg->inetmail_sem, iniGetString(section, NULL, "netmail_sem", "", value));
SAFECOPY(cfg->smtpmail_sem, iniGetString(section, NULL, "smtp_sem", "", value));
cfg->inetmail_misc = iniGetLongInt(section, NULL, "settings", 0);
cfg->inetmail_cost = iniGetLongInt(section, NULL, "cost", 0);
iniFreeStringList(section);
iniFreeStringList(ini);
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment