Annotation of sbbs/src/sbbs3/sbbs_ini.c, revision 1.1.1.1

1.1       root        1: /* sbbs_ini.c */
                      2: 
                      3: /* Synchronet initialization (.ini) file routines */
                      4: 
                      5: /* $Id: sbbs_ini.c,v 1.122 2006/12/31 11:16:40 rswindell Exp $ */
                      6: 
                      7: /****************************************************************************
                      8:  * @format.tab-size 4          (Plain Text/Source Code File Header)                    *
                      9:  * @format.use-tabs true       (see http://www.synchro.net/ptsc_hdr.html)              *
                     10:  *                                                                                                                                                     *
                     11:  * Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html         *
                     12:  *                                                                                                                                                     *
                     13:  * This program is free software; you can redistribute it and/or                       *
                     14:  * modify it under the terms of the GNU General Public License                         *
                     15:  * as published by the Free Software Foundation; either version 2                      *
                     16:  * of the License, or (at your option) any later version.                                      *
                     17:  * See the GNU General Public License for more details: gpl.txt or                     *
                     18:  * http://www.fsf.org/copyleft/gpl.html                                                                                *
                     19:  *                                                                                                                                                     *
                     20:  * Anonymous FTP access to the most recent released source is available at     *
                     21:  * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net     *
                     22:  *                                                                                                                                                     *
                     23:  * Anonymous CVS access to the development source and modification history     *
                     24:  * is available at cvs.synchro.net:/cvsroot/sbbs, example:                                     *
                     25:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs login                       *
                     26:  *     (just hit return, no password is necessary)                                                     *
                     27:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src                *
                     28:  *                                                                                                                                                     *
                     29:  * For Synchronet coding style and modification guidelines, see                                *
                     30:  * http://www.synchro.net/source.html                                                                          *
                     31:  *                                                                                                                                                     *
                     32:  * You are encouraged to submit any modifications (preferably in Unix diff     *
                     33:  * format) via e-mail to [email protected]                                                                      *
                     34:  *                                                                                                                                                     *
                     35:  * Note: If this box doesn't appear square, then you need to fix your tabs.    *
                     36:  ****************************************************************************/
                     37: 
                     38: #define STARTUP_INI_BITDESC_TABLES
                     39: 
                     40: #include <string.h>    /* strchr, memset */
                     41: 
                     42: #include "dirwrap.h"   /* backslash */
                     43: #include "sbbs_ini.h"
                     44: #include "sbbsdefs.h"  /* JAVASCRIPT_* macros */
                     45: 
                     46: static const char*     nulstr="";
                     47: static const char*  strAutoStart="AutoStart";
                     48: static const char*  strCtrlDirectory="CtrlDirectory";
                     49: static const char*  strTempDirectory="TempDirectory";
                     50: static const char*     strOptions="Options";
                     51: static const char*     strInterface="Interface";
                     52: static const char*     strPort="Port";
                     53: static const char*     strMaxClients="MaxClients";
                     54: static const char*     strMaxInactivity="MaxInactivity";
                     55: static const char*     strHostName="HostName";
                     56: static const char*     strLogLevel="LogLevel";
                     57: static const char*     strBindRetryCount="BindRetryCount";
                     58: static const char*     strBindRetryDelay="BindRetryDelay";
                     59: static const char*     strAnswerSound="AnswerSound";
                     60: static const char*     strHangupSound="HangupSound";
                     61: static const char*     strHackAttemptSound="HackAttemptSound";
                     62: static const char*     strJavaScriptMaxBytes           ="JavaScriptMaxBytes";
                     63: static const char*     strJavaScriptContextStack       ="JavaScriptContextStack";
                     64: static const char*     strJavaScriptThreadStack        ="JavaScriptThreadStack";
                     65: static const char*     strJavaScriptBranchLimit        ="JavaScriptBranchLimit";
                     66: static const char*     strJavaScriptGcInterval         ="JavaScriptGcInterval";
                     67: static const char*     strJavaScriptYieldInterval      ="JavaScriptYieldInterval";
                     68: static const char*     strSemFileCheckFrequency        ="SemFileCheckFrequency";
                     69: 
                     70: #define DEFAULT_LOG_LEVEL              LOG_DEBUG
                     71: #define DEFAULT_MAX_MSG_SIZE    (10*1024*1024) /* 10MB */
                     72: #define DEFAULT_BIND_RETRY_COUNT       2
                     73: #define DEFAULT_BIND_RETRY_DELAY       15
                     74: 
                     75: void sbbs_get_ini_fname(char* ini_file, char* ctrl_dir, char* pHostName)
                     76: {
                     77:     char       host_name[128];
                     78:     char       path[MAX_PATH+1];
                     79:        char*   p;
                     80: 
                     81:     if(pHostName!=NULL)
                     82:                SAFECOPY(host_name,pHostName);
                     83:        else {
                     84: #if defined(_WINSOCKAPI_)
                     85:         WSADATA WSAData;
                     86:         WSAStartup(MAKEWORD(1,1), &WSAData); /* req'd for gethostname */
                     87: #endif
                     88:        gethostname(host_name,sizeof(host_name)-1);
                     89: #if defined(_WINSOCKAPI_)
                     90:         WSACleanup();
                     91: #endif
                     92:     }
                     93:        SAFECOPY(path,ctrl_dir);
                     94:        backslash(path);
                     95:        sprintf(ini_file,"%s%s.ini",path,host_name);
                     96:        if(fexistcase(ini_file))
                     97:                return;
                     98:        if((p=strchr(host_name,'.'))!=NULL) {
                     99:                *p=0;
                    100:                sprintf(ini_file,"%s%s.ini",path,host_name);
                    101:                if(fexistcase(ini_file))
                    102:                        return;
                    103:        }
                    104: #if defined(__unix__) && defined(PREFIX)
                    105:        sprintf(ini_file,PREFIX"/etc/sbbs.ini");
                    106:        if(fexistcase(ini_file))
                    107:                return;
                    108: #endif
                    109:        iniFileName(ini_file,MAX_PATH,ctrl_dir,"sbbs.ini");
                    110:        if(fexistcase(ini_file))
                    111:                return;
                    112:        iniFileName(ini_file,MAX_PATH,ctrl_dir,"startup.ini");
                    113: }
                    114: 
                    115: static void sbbs_fix_js_settings(js_startup_t* js)
                    116: {
                    117:        /* Some sanity checking here */
                    118:        if(js->max_bytes==0)    js->max_bytes=JAVASCRIPT_MAX_BYTES;
                    119:        if(js->cx_stack==0)             js->cx_stack=JAVASCRIPT_CONTEXT_STACK;
                    120: }
                    121: 
                    122: void sbbs_get_js_settings(
                    123:         str_list_t list
                    124:        ,const char* section
                    125:        ,js_startup_t* js
                    126:        ,js_startup_t* defaults)
                    127: {
                    128:        js->max_bytes           = iniGetInteger(list,section,strJavaScriptMaxBytes              ,defaults->max_bytes);
                    129:        js->cx_stack            = iniGetInteger(list,section,strJavaScriptContextStack  ,defaults->cx_stack);
                    130:        js->thread_stack        = iniGetInteger(list,section,strJavaScriptThreadStack   ,defaults->thread_stack);
                    131:        js->branch_limit        = iniGetInteger(list,section,strJavaScriptBranchLimit   ,defaults->branch_limit);
                    132:        js->gc_interval         = iniGetInteger(list,section,strJavaScriptGcInterval    ,defaults->gc_interval);
                    133:        js->yield_interval      = iniGetInteger(list,section,strJavaScriptYieldInterval ,defaults->yield_interval);
                    134: 
                    135:        sbbs_fix_js_settings(js);
                    136: }
                    137: 
                    138: BOOL sbbs_set_js_settings(
                    139:         str_list_t* lp
                    140:        ,const char* section
                    141:        ,js_startup_t* js
                    142:        ,js_startup_t* defaults
                    143:        ,ini_style_t* style)
                    144: {
                    145:        BOOL    failure=FALSE;
                    146:        js_startup_t global_defaults = {
                    147:                         JAVASCRIPT_MAX_BYTES
                    148:                        ,JAVASCRIPT_CONTEXT_STACK
                    149:                        ,JAVASCRIPT_THREAD_STACK
                    150:                        ,JAVASCRIPT_BRANCH_LIMIT
                    151:                        ,JAVASCRIPT_GC_INTERVAL
                    152:                        ,JAVASCRIPT_YIELD_INTERVAL
                    153:                };
                    154: 
                    155:        if(defaults==NULL)
                    156:                defaults=&global_defaults;
                    157: 
                    158:        sbbs_fix_js_settings(js);
                    159: 
                    160:        if(js->max_bytes==defaults->max_bytes)
                    161:                iniRemoveValue(lp,section,strJavaScriptMaxBytes);
                    162:        else
                    163:                failure|=iniSetInteger(lp,section,strJavaScriptMaxBytes,js->max_bytes,style)==NULL;
                    164: 
                    165:        if(js->cx_stack==defaults->cx_stack)
                    166:                iniRemoveValue(lp,section,strJavaScriptContextStack);
                    167:        else 
                    168:                failure|=iniSetInteger(lp,section,strJavaScriptContextStack,js->cx_stack,style)==NULL;
                    169: 
                    170:        if(js->thread_stack==defaults->thread_stack)
                    171:                iniRemoveValue(lp,section,strJavaScriptThreadStack);
                    172:        else 
                    173:                failure|=iniSetInteger(lp,section,strJavaScriptThreadStack,js->thread_stack,style)==NULL;
                    174: 
                    175:        if(js->branch_limit==defaults->branch_limit)
                    176:                iniRemoveValue(lp,section,strJavaScriptBranchLimit);
                    177:        else
                    178:                failure|=iniSetInteger(lp,section,strJavaScriptBranchLimit,js->branch_limit,style)==NULL;
                    179: 
                    180:        if(js->gc_interval==defaults->gc_interval)
                    181:                iniRemoveValue(lp,section,strJavaScriptGcInterval);
                    182:        else 
                    183:                failure|=iniSetInteger(lp,section,strJavaScriptGcInterval,js->gc_interval,style)==NULL;
                    184: 
                    185:        if(js->yield_interval==defaults->yield_interval)
                    186:                iniRemoveValue(lp,section,strJavaScriptYieldInterval);
                    187:        else 
                    188:                failure|=iniSetInteger(lp,section,strJavaScriptYieldInterval,js->yield_interval,style)==NULL;
                    189: 
                    190:        return(!failure);
                    191: }
                    192: 
                    193: static void get_ini_globals(str_list_t list, global_startup_t* global)
                    194: {
                    195:        const char* section = "Global";
                    196:        char            value[INI_MAX_VALUE_LEN];
                    197:        char*           p;
                    198: 
                    199:        p=iniGetString(list,section,strCtrlDirectory,nulstr,value);
                    200:        if(*p) {
                    201:            SAFECOPY(global->ctrl_dir,value);
                    202:                backslash(global->ctrl_dir);
                    203:     }
                    204: 
                    205:        p=iniGetString(list,section,strTempDirectory,nulstr,value);
                    206: #if defined(__unix__)
                    207:        if(*p==0)
                    208:                p=_PATH_TMP;    /* Good idea to use "/tmp" on Unix */
                    209: #endif
                    210:        if(*p) {
                    211:            SAFECOPY(global->temp_dir,value);
                    212:                backslash(global->temp_dir);
                    213:     }
                    214: 
                    215:        p=iniGetString(list,section,strHostName,nulstr,value);
                    216:        if(*p)
                    217:         SAFECOPY(global->host_name,value);
                    218: 
                    219:        global->sem_chk_freq=iniGetShortInt(list,section,strSemFileCheckFrequency,0);
                    220:        global->interface_addr=iniGetIpAddress(list,section,strInterface,INADDR_ANY);
                    221:        global->log_level=iniGetLogLevel(list,section,strLogLevel,DEFAULT_LOG_LEVEL);
                    222:        global->bind_retry_count=iniGetInteger(list,section,strBindRetryCount,DEFAULT_BIND_RETRY_COUNT);
                    223:        global->bind_retry_delay=iniGetInteger(list,section,strBindRetryDelay,DEFAULT_BIND_RETRY_DELAY);
                    224: 
                    225:        /* Setup default values here */
                    226:        global->js.max_bytes            = JAVASCRIPT_MAX_BYTES;
                    227:        global->js.cx_stack                     = JAVASCRIPT_CONTEXT_STACK;
                    228:        global->js.thread_stack         = JAVASCRIPT_THREAD_STACK;
                    229:        global->js.branch_limit         = JAVASCRIPT_BRANCH_LIMIT;
                    230:        global->js.gc_interval          = JAVASCRIPT_GC_INTERVAL;
                    231:        global->js.yield_interval       = JAVASCRIPT_YIELD_INTERVAL;
                    232: 
                    233:        /* Read .ini values here */
                    234:        sbbs_get_js_settings(list, section, &global->js, &global->js);
                    235: }
                    236: 
                    237: 
                    238: void sbbs_read_ini(
                    239:         FILE*                                  fp
                    240:        ,global_startup_t*              global
                    241:        ,BOOL*                                  run_bbs
                    242:        ,bbs_startup_t*                 bbs
                    243:        ,BOOL*                                  run_ftp
                    244:        ,ftp_startup_t*                 ftp
                    245:        ,BOOL*                                  run_web
                    246:        ,web_startup_t*                 web
                    247:        ,BOOL*                                  run_mail                
                    248:        ,mail_startup_t*                mail
                    249:        ,BOOL*                                  run_services
                    250:        ,services_startup_t*    services
                    251:        )
                    252: {
                    253:        const char*     section;
                    254:        const char* default_term_ansi;
                    255:        const char*     default_dosemu_path;
                    256:        char            value[INI_MAX_VALUE_LEN];
                    257:        str_list_t      list;
                    258:        global_startup_t global_buf;
                    259: 
                    260:        if(global==NULL) {
                    261:                memset(&global_buf,0,sizeof(global_buf));
                    262:                global=&global_buf;
                    263:        }
                    264: 
                    265:        list=iniReadFile(fp);
                    266: 
                    267:        get_ini_globals(list, global);
                    268: 
                    269:        if(global->ctrl_dir[0]) {
                    270:                if(bbs!=NULL)           SAFECOPY(bbs->ctrl_dir,global->ctrl_dir);
                    271:                if(ftp!=NULL)           SAFECOPY(ftp->ctrl_dir,global->ctrl_dir);
                    272:                if(web!=NULL)           SAFECOPY(web->ctrl_dir,global->ctrl_dir);
                    273:                if(mail!=NULL)          SAFECOPY(mail->ctrl_dir,global->ctrl_dir);
                    274:                if(services!=NULL)      SAFECOPY(services->ctrl_dir,global->ctrl_dir);
                    275:        }
                    276:                                                                                                        
                    277:        /***********************************************************************/
                    278:        section = "BBS";
                    279: 
                    280:        if(run_bbs!=NULL)
                    281:                *run_bbs=iniGetBool(list,section,strAutoStart,TRUE);
                    282: 
                    283:        if(bbs!=NULL) {
                    284: 
                    285:                bbs->telnet_interface
                    286:                        =iniGetIpAddress(list,section,"TelnetInterface",global->interface_addr);
                    287:                bbs->telnet_port
                    288:                        =iniGetShortInt(list,section,"TelnetPort",IPPORT_TELNET);
                    289: 
                    290:                bbs->rlogin_interface
                    291:                        =iniGetIpAddress(list,section,"RLoginInterface",global->interface_addr);
                    292:                bbs->rlogin_port
                    293:                        =iniGetShortInt(list,section,"RLoginPort",513);
                    294: 
                    295:                bbs->ssh_interface
                    296:                        =iniGetIpAddress(list,section,"SSHInterface",global->interface_addr);
                    297:                bbs->ssh_port
                    298:                        =iniGetShortInt(list,section,"SSHPort",22);
                    299: 
                    300:                bbs->first_node
                    301:                        =iniGetShortInt(list,section,"FirstNode",1);
                    302:                bbs->last_node
                    303:                        =iniGetShortInt(list,section,"LastNode",4);
                    304: 
                    305:                bbs->outbuf_highwater_mark
                    306:                        =iniGetShortInt(list,section,"OutbufHighwaterMark"
                    307: #ifdef TCP_MAXSEG      /* Auto-tune if possible.  Would this be defined here? */
                    308:                        ,0
                    309: #else
                    310:                        ,1024
                    311: #endif
                    312:                        );
                    313:                bbs->outbuf_drain_timeout
                    314:                        =iniGetShortInt(list,section,"OutbufDrainTimeout",10);
                    315: 
                    316:                bbs->sem_chk_freq
                    317:                        =iniGetShortInt(list,section,strSemFileCheckFrequency,global->sem_chk_freq);
                    318: 
                    319:                /* JavaScript operating parameters */
                    320:                sbbs_get_js_settings(list, section, &bbs->js, &global->js);
                    321: 
                    322:                SAFECOPY(bbs->host_name
                    323:                        ,iniGetString(list,section,strHostName,global->host_name,value));
                    324: 
                    325:                SAFECOPY(bbs->temp_dir
                    326:                        ,iniGetString(list,section,strTempDirectory,global->temp_dir,value));
                    327: 
                    328:                /* Set default terminal type to "stock" termcap closest to "ansi-bbs" */
                    329:        #if defined(__FreeBSD__)
                    330:                default_term_ansi="cons25";
                    331:        #else
                    332:                default_term_ansi="pc3";
                    333:        #endif
                    334: 
                    335:                SAFECOPY(bbs->xtrn_term_ansi
                    336:                        ,iniGetString(list,section,"ExternalTermANSI",default_term_ansi,value));
                    337:                SAFECOPY(bbs->xtrn_term_dumb
                    338:                        ,iniGetString(list,section,"ExternalTermDumb","dumb",value));
                    339: 
                    340:        #if defined(__FreeBSD__)
                    341:                default_dosemu_path="/usr/bin/doscmd";
                    342:        #else
                    343:                default_dosemu_path="/usr/bin/dosemu.bin";
                    344:        #endif
                    345: 
                    346:                SAFECOPY(bbs->dosemu_path
                    347:                        ,iniGetString(list,section,"DOSemuPath",default_dosemu_path,value));
                    348: 
                    349:                SAFECOPY(bbs->answer_sound
                    350:                        ,iniGetString(list,section,strAnswerSound,nulstr,value));
                    351:                SAFECOPY(bbs->hangup_sound
                    352:                        ,iniGetString(list,section,strHangupSound,nulstr,value));
                    353: 
                    354:                bbs->log_level
                    355:                        =iniGetLogLevel(list,section,strLogLevel,global->log_level);
                    356:                bbs->options
                    357:                        =iniGetBitField(list,section,strOptions,bbs_options
                    358:                                ,BBS_OPT_XTRN_MINIMIZED|BBS_OPT_SYSOP_AVAILABLE);
                    359: 
                    360:                bbs->bind_retry_count=iniGetInteger(list,section,strBindRetryCount,global->bind_retry_count);
                    361:                bbs->bind_retry_delay=iniGetInteger(list,section,strBindRetryDelay,global->bind_retry_delay);
                    362:        }
                    363: 
                    364:        /***********************************************************************/
                    365:        section = "FTP";
                    366: 
                    367:        if(run_ftp!=NULL)
                    368:                *run_ftp=iniGetBool(list,section,strAutoStart,TRUE);
                    369: 
                    370:        if(ftp!=NULL) {
                    371: 
                    372:                ftp->interface_addr
                    373:                        =iniGetIpAddress(list,section,strInterface,global->interface_addr);
                    374:                ftp->port
                    375:                        =iniGetShortInt(list,section,strPort,IPPORT_FTP);
                    376:                ftp->max_clients
                    377:                        =iniGetShortInt(list,section,strMaxClients,10);
                    378:                ftp->max_inactivity
                    379:                        =iniGetShortInt(list,section,strMaxInactivity,300);     /* seconds */
                    380:                ftp->qwk_timeout
                    381:                        =iniGetShortInt(list,section,"QwkTimeout",600);         /* seconds */
                    382:                ftp->sem_chk_freq
                    383:                        =iniGetShortInt(list,section,strSemFileCheckFrequency,global->sem_chk_freq);
                    384: 
                    385:                /* Passive transfer settings (for stupid firewalls/NATs) */
                    386:                ftp->pasv_ip_addr
                    387:                        =iniGetIpAddress(list,section,"PasvIpAddress",0);
                    388:                ftp->pasv_port_low
                    389:                        =iniGetShortInt(list,section,"PasvPortLow",IPPORT_RESERVED);
                    390:                ftp->pasv_port_high
                    391:                        =iniGetShortInt(list,section,"PasvPortHigh",0xffff);
                    392: 
                    393: 
                    394:                /* JavaScript Operating Parameters */
                    395:                sbbs_get_js_settings(list, section, &ftp->js, &global->js);
                    396: 
                    397:                SAFECOPY(ftp->host_name
                    398:                        ,iniGetString(list,section,strHostName,global->host_name,value));
                    399: 
                    400:                SAFECOPY(ftp->index_file_name
                    401:                        ,iniGetString(list,section,"IndexFileName","00index",value));
                    402:                SAFECOPY(ftp->html_index_file
                    403:                        ,iniGetString(list,section,"HtmlIndexFile","00index.html",value));
                    404:                SAFECOPY(ftp->html_index_script
                    405:                        ,iniGetString(list,section,"HtmlIndexScript","ftp-html.js",value));
                    406: 
                    407:                SAFECOPY(ftp->answer_sound
                    408:                        ,iniGetString(list,section,strAnswerSound,nulstr,value));
                    409:                SAFECOPY(ftp->hangup_sound
                    410:                        ,iniGetString(list,section,strHangupSound,nulstr,value));
                    411:                SAFECOPY(ftp->hack_sound
                    412:                        ,iniGetString(list,section,strHackAttemptSound,nulstr,value));
                    413: 
                    414:                SAFECOPY(ftp->temp_dir
                    415:                        ,iniGetString(list,section,strTempDirectory,global->temp_dir,value));
                    416: 
                    417:                ftp->log_level
                    418:                        =iniGetLogLevel(list,section,strLogLevel,global->log_level);
                    419:                ftp->options
                    420:                        =iniGetBitField(list,section,strOptions,ftp_options
                    421:                                ,FTP_OPT_INDEX_FILE|FTP_OPT_HTML_INDEX_FILE|FTP_OPT_ALLOW_QWK);
                    422: 
                    423:                ftp->bind_retry_count=iniGetInteger(list,section,strBindRetryCount,global->bind_retry_count);
                    424:                ftp->bind_retry_delay=iniGetInteger(list,section,strBindRetryDelay,global->bind_retry_delay);
                    425:        }
                    426: 
                    427:        /***********************************************************************/
                    428:        section = "Mail";
                    429: 
                    430:        if(run_mail!=NULL)
                    431:                *run_mail=iniGetBool(list,section,strAutoStart,TRUE);
                    432: 
                    433:        if(mail!=NULL) {
                    434: 
                    435:                mail->interface_addr
                    436:                        =iniGetIpAddress(list,section,strInterface,global->interface_addr);
                    437:                mail->smtp_port
                    438:                        =iniGetShortInt(list,section,"SMTPPort",IPPORT_SMTP);
                    439:                mail->pop3_port
                    440:                        =iniGetShortInt(list,section,"POP3Port",IPPORT_POP3);
                    441:                mail->relay_port
                    442:                        =iniGetShortInt(list,section,"RelayPort",IPPORT_SMTP);
                    443:                mail->max_clients
                    444:                        =iniGetShortInt(list,section,strMaxClients,10);
                    445:                mail->max_inactivity
                    446:                        =iniGetShortInt(list,section,strMaxInactivity,120);             /* seconds */
                    447:                mail->max_delivery_attempts
                    448:                        =iniGetShortInt(list,section,"MaxDeliveryAttempts",50);
                    449:                mail->rescan_frequency
                    450:                        =iniGetShortInt(list,section,"RescanFrequency",3600);   /* 60 minutes */
                    451:                mail->sem_chk_freq
                    452:                        =iniGetShortInt(list,section,strSemFileCheckFrequency,global->sem_chk_freq);
                    453:                mail->lines_per_yield
                    454:                        =iniGetShortInt(list,section,"LinesPerYield",10);
                    455:                mail->max_recipients
                    456:                        =iniGetShortInt(list,section,"MaxRecipients",100);
                    457:                mail->max_msg_size
                    458:                        =iniGetInteger(list,section,"MaxMsgSize",DEFAULT_MAX_MSG_SIZE);
                    459: 
                    460:                SAFECOPY(mail->host_name
                    461:                        ,iniGetString(list,section,strHostName,global->host_name,value));
                    462: 
                    463:                SAFECOPY(mail->temp_dir
                    464:                        ,iniGetString(list,section,strTempDirectory,global->temp_dir,value));
                    465: 
                    466:                SAFECOPY(mail->relay_server
                    467:                        ,iniGetString(list,section,"RelayServer",nulstr,value));
                    468:                SAFECOPY(mail->relay_user
                    469:                        ,iniGetString(list,section,"RelayUsername",nulstr,value));
                    470:                SAFECOPY(mail->relay_pass
                    471:                        ,iniGetString(list,section,"RelayPassword",nulstr,value));
                    472: 
                    473:                SAFECOPY(mail->dns_server
                    474:                        ,iniGetString(list,section,"DNSServer",nulstr,value));
                    475: 
                    476:                SAFECOPY(mail->default_user
                    477:                        ,iniGetString(list,section,"DefaultUser",nulstr,value));
                    478: 
                    479:                SAFECOPY(mail->default_charset
                    480:                        ,iniGetString(list,section,"DefaultCharset",nulstr,value));
                    481: 
                    482:                SAFECOPY(mail->dnsbl_hdr
                    483:                        ,iniGetString(list,section,"DNSBlacklistHeader","X-DNSBL",value));
                    484:                SAFECOPY(mail->dnsbl_tag
                    485:                        ,iniGetString(list,section,"DNSBlacklistSubject","SPAM",value));
                    486: 
                    487:                SAFECOPY(mail->pop3_sound
                    488:                        ,iniGetString(list,section,"POP3Sound",nulstr,value));
                    489:                SAFECOPY(mail->inbound_sound
                    490:                        ,iniGetString(list,section,"InboundSound",nulstr,value));
                    491:                SAFECOPY(mail->outbound_sound
                    492:                        ,iniGetString(list,section,"OutboundSound",nulstr,value));
                    493: 
                    494:                /* JavaScript Operating Parameters */
                    495:                sbbs_get_js_settings(list, section, &mail->js, &global->js);
                    496: 
                    497:                mail->log_level
                    498:                        =iniGetLogLevel(list,section,strLogLevel,global->log_level);
                    499:                mail->options
                    500:                        =iniGetBitField(list,section,strOptions,mail_options
                    501:                                ,MAIL_OPT_ALLOW_POP3);
                    502: 
                    503:                mail->bind_retry_count=iniGetInteger(list,section,strBindRetryCount,global->bind_retry_count);
                    504:                mail->bind_retry_delay=iniGetInteger(list,section,strBindRetryDelay,global->bind_retry_delay);
                    505:        }
                    506: 
                    507:        /***********************************************************************/
                    508:        section = "Services";
                    509: 
                    510:        if(run_services!=NULL)
                    511:                *run_services=iniGetBool(list,section,strAutoStart,TRUE);
                    512: 
                    513:        if(services!=NULL) {
                    514: 
                    515:                services->interface_addr
                    516:                        =iniGetIpAddress(list,section,strInterface,global->interface_addr);
                    517: 
                    518:                services->sem_chk_freq
                    519:                        =iniGetShortInt(list,section,strSemFileCheckFrequency,global->sem_chk_freq);
                    520: 
                    521:                /* JavaScript operating parameters */
                    522:                sbbs_get_js_settings(list, section, &services->js, &global->js);
                    523: 
                    524:                SAFECOPY(services->host_name
                    525:                        ,iniGetString(list,section,strHostName,global->host_name,value));
                    526: 
                    527:                SAFECOPY(services->temp_dir
                    528:                        ,iniGetString(list,section,strTempDirectory,global->temp_dir,value));
                    529: 
                    530:                SAFECOPY(services->answer_sound
                    531:                        ,iniGetString(list,section,strAnswerSound,nulstr,value));
                    532:                SAFECOPY(services->hangup_sound
                    533:                        ,iniGetString(list,section,strHangupSound,nulstr,value));
                    534: 
                    535:                services->log_level
                    536:                        =iniGetLogLevel(list,section,strLogLevel,global->log_level);
                    537:                services->options
                    538:                        =iniGetBitField(list,section,strOptions,service_options
                    539:                                ,BBS_OPT_NO_HOST_LOOKUP);
                    540: 
                    541:                services->bind_retry_count=iniGetInteger(list,section,strBindRetryCount,global->bind_retry_count);
                    542:                services->bind_retry_delay=iniGetInteger(list,section,strBindRetryDelay,global->bind_retry_delay);
                    543:        }
                    544: 
                    545:        /***********************************************************************/
                    546:        section = "Web";
                    547: 
                    548:        if(run_web!=NULL)
                    549:                *run_web=iniGetBool(list,section,strAutoStart,FALSE);
                    550: 
                    551:        if(web!=NULL) {
                    552: 
                    553:                web->interface_addr
                    554:                        =iniGetIpAddress(list,section,strInterface,global->interface_addr);
                    555:                web->port
                    556:                        =iniGetShortInt(list,section,strPort,IPPORT_HTTP);
                    557:                web->max_clients
                    558:                        =iniGetShortInt(list,section,strMaxClients,10);
                    559:                web->max_inactivity
                    560:                        =iniGetShortInt(list,section,strMaxInactivity,120);             /* seconds */
                    561:                web->sem_chk_freq
                    562:                        =iniGetShortInt(list,section,strSemFileCheckFrequency,global->sem_chk_freq);
                    563: 
                    564:                /* JavaScript operating parameters */
                    565:                sbbs_get_js_settings(list, section, &web->js, &global->js);
                    566: 
                    567:                SAFECOPY(web->host_name
                    568:                        ,iniGetString(list,section,strHostName,global->host_name,value));
                    569: 
                    570:                SAFECOPY(web->temp_dir
                    571:                        ,iniGetString(list,section,strTempDirectory,global->temp_dir,value));
                    572: 
                    573:                SAFECOPY(web->root_dir
                    574:                        ,iniGetString(list,section,"RootDirectory",WEB_DEFAULT_ROOT_DIR,value));
                    575:                SAFECOPY(web->error_dir
                    576:                        ,iniGetString(list,section,"ErrorDirectory",WEB_DEFAULT_ERROR_DIR,value));
                    577:                SAFECOPY(web->cgi_dir
                    578:                        ,iniGetString(list,section,"CGIDirectory",WEB_DEFAULT_CGI_DIR,value));
                    579:                SAFECOPY(web->logfile_base
                    580:                        ,iniGetString(list,section,"HttpLogFile",nulstr,value));
                    581: 
                    582:                SAFECOPY(web->default_cgi_content
                    583:                        ,iniGetString(list,section,"DefaultCGIContent",WEB_DEFAULT_CGI_CONTENT,value));
                    584: 
                    585:                iniFreeStringList(web->index_file_name);
                    586:                web->index_file_name
                    587:                        =iniGetStringList(list,section,"IndexFileNames", "," ,"index.html,index.ssjs");
                    588:                iniFreeStringList(web->cgi_ext);
                    589:                web->cgi_ext
                    590:                        =iniGetStringList(list,section,"CGIExtensions", "," ,".cgi");
                    591:                SAFECOPY(web->ssjs_ext
                    592:                        ,iniGetString(list,section,"JavaScriptExtension",".ssjs",value));
                    593:                SAFECOPY(web->js_ext
                    594:                        ,iniGetString(list,section,"EmbJavaScriptExtension",".bbs",value));
                    595: 
                    596:                web->max_inactivity
                    597:                        =iniGetShortInt(list,section,strMaxInactivity,120);             /* seconds */
                    598:                web->max_cgi_inactivity
                    599:                        =iniGetShortInt(list,section,"MaxCgiInactivity",120);   /* seconds */
                    600: 
                    601:                SAFECOPY(web->answer_sound
                    602:                        ,iniGetString(list,section,strAnswerSound,nulstr,value));
                    603:                SAFECOPY(web->hangup_sound
                    604:                        ,iniGetString(list,section,strHangupSound,nulstr,value));
                    605:                SAFECOPY(web->hack_sound
                    606:                        ,iniGetString(list,section,strHackAttemptSound,nulstr,value));
                    607: 
                    608:                web->log_level
                    609:                        =iniGetLogLevel(list,section,strLogLevel,global->log_level);
                    610:                web->options
                    611:                        =iniGetBitField(list,section,strOptions,web_options
                    612:                                ,BBS_OPT_NO_HOST_LOOKUP | WEB_OPT_HTTP_LOGGING);
                    613:                web->outbuf_highwater_mark
                    614:                        =iniGetShortInt(list,section,"OutbufHighwaterMark"
                    615: #ifdef TCP_MAXSEG      /* Auto-tune if possible.  Would this be defined here? */
                    616:                        ,0
                    617: #else
                    618:                        ,1024
                    619: #endif
                    620:                        );
                    621:                web->outbuf_drain_timeout
                    622:                        =iniGetShortInt(list,section,"OutbufDrainTimeout",10);
                    623: 
                    624:                web->bind_retry_count=iniGetInteger(list,section,strBindRetryCount,global->bind_retry_count);
                    625:                web->bind_retry_delay=iniGetInteger(list,section,strBindRetryDelay,global->bind_retry_delay);
                    626:        }
                    627: 
                    628:        iniFreeStringList(list);
                    629: }
                    630: 
                    631: BOOL sbbs_write_ini(
                    632:         FILE*                                  fp
                    633:     ,scfg_t*                cfg
                    634:        ,global_startup_t*              global
                    635:        ,BOOL                                   run_bbs
                    636:        ,bbs_startup_t*                 bbs
                    637:        ,BOOL                                   run_ftp
                    638:        ,ftp_startup_t*                 ftp
                    639:        ,BOOL                                   run_web
                    640:        ,web_startup_t*                 web
                    641:        ,BOOL                                   run_mail                
                    642:        ,mail_startup_t*                mail
                    643:        ,BOOL                                   run_services
                    644:        ,services_startup_t*    services
                    645:        )
                    646: {
                    647:        const char*     section;
                    648:        BOOL            result=FALSE;
                    649:        str_list_t      list;
                    650:        str_list_t*     lp;
                    651:        ini_style_t style;
                    652:        global_startup_t        global_buf;
                    653: 
                    654:        memset(&style, 0, sizeof(style));
                    655:        style.key_prefix = "\t";
                    656:     style.bit_separator = " | ";
                    657: 
                    658:        if((list=iniReadFile(fp))==NULL)
                    659:                return(FALSE);
                    660: 
                    661:        if(global==NULL) {
                    662:                get_ini_globals(list, &global_buf);
                    663:                global = &global_buf;
                    664:        }
                    665:        
                    666:        lp=&list;
                    667: 
                    668:        do { /* try */
                    669: 
                    670:        /***********************************************************************/
                    671:        if(global!=&global_buf) {
                    672:                section = "Global";
                    673: 
                    674:                if(global->ctrl_dir[0]==0)
                    675:                        iniRemoveKey(lp,section,strCtrlDirectory);
                    676:                else
                    677:                        iniSetString(lp,section,strCtrlDirectory,global->ctrl_dir,&style);
                    678: 
                    679:                if(global->temp_dir[0]==0)
                    680:                        iniRemoveKey(lp,section,strTempDirectory);
                    681:                else
                    682:                        iniSetString(lp,section,strTempDirectory,global->temp_dir,&style);
                    683: 
                    684:                if(global->host_name[0]==0)
                    685:                        iniRemoveKey(lp,section,strHostName);
                    686:                else
                    687:                        iniSetString(lp,section,strHostName,global->host_name,&style);
                    688:        
                    689:                if(global->sem_chk_freq==0)
                    690:                        iniRemoveKey(lp,section,strSemFileCheckFrequency);
                    691:                else
                    692:                        iniSetShortInt(lp,section,strSemFileCheckFrequency,global->sem_chk_freq,&style);
                    693:                if(global->interface_addr==INADDR_ANY)
                    694:                        iniRemoveKey(lp,section,strInterface);
                    695:                else
                    696:                        iniSetIpAddress(lp,section,strInterface,global->interface_addr,&style);
                    697:                if(global->log_level==DEFAULT_LOG_LEVEL)
                    698:                        iniRemoveKey(lp,section,strLogLevel);
                    699:                else
                    700:                        iniSetLogLevel(lp,section,strLogLevel,global->log_level,&style);
                    701: 
                    702:                if(global->bind_retry_count==DEFAULT_BIND_RETRY_COUNT)
                    703:                        iniRemoveKey(lp,section,strBindRetryCount);
                    704:                else
                    705:                        iniSetInteger(lp,section,strBindRetryCount,global->bind_retry_count,&style);
                    706:                if(global->bind_retry_delay==DEFAULT_BIND_RETRY_DELAY)
                    707:                        iniRemoveKey(lp,section,strBindRetryDelay);
                    708:                else
                    709:                        iniSetInteger(lp,section,strBindRetryDelay,global->bind_retry_delay,&style);
                    710: 
                    711:                /* JavaScript operating parameters */
                    712:                if(!sbbs_set_js_settings(lp,section,&global->js,NULL,&style))
                    713:                        break;
                    714:        }
                    715: 
                    716:        /***********************************************************************/
                    717:        if(bbs!=NULL) {
                    718: 
                    719:                section = "BBS";
                    720: 
                    721:                if(!iniSetBool(lp,section,strAutoStart,run_bbs,&style))
                    722:                        break;
                    723: 
                    724:                if(bbs->telnet_interface==global->interface_addr)
                    725:                        iniRemoveValue(lp,section,"TelnetInterface");
                    726:                else if(!iniSetIpAddress(lp,section,"TelnetInterface",bbs->telnet_interface,&style))
                    727:                        break;
                    728: 
                    729:                if(!iniSetShortInt(lp,section,"TelnetPort",bbs->telnet_port,&style))
                    730:                        break;
                    731: 
                    732:                if(bbs->rlogin_interface==global->interface_addr)
                    733:                        iniRemoveValue(lp,section,"RLoginInterface");
                    734:                else if(!iniSetIpAddress(lp,section,"RLoginInterface",bbs->rlogin_interface,&style))
                    735:                        break;
                    736:                if(!iniSetShortInt(lp,section,"RLoginPort",bbs->rlogin_port,&style))
                    737:                        break;
                    738: 
                    739:                if(bbs->ssh_interface==global->interface_addr)
                    740:                        iniRemoveValue(lp,section,"SSHInterface");
                    741:                else if(!iniSetIpAddress(lp,section,"SSHInterface",bbs->ssh_interface,&style))
                    742:                        break;
                    743:                if(!iniSetShortInt(lp,section,"SSHPort",bbs->ssh_port,&style))
                    744:                        break;
                    745: 
                    746:                if(!iniSetShortInt(lp,section,"FirstNode",bbs->first_node,&style))
                    747:                        break;
                    748:                if(!iniSetShortInt(lp,section,"LastNode",bbs->last_node,&style))
                    749:                        break;
                    750:                if(!iniSetShortInt(lp,section,"OutbufHighwaterMark",bbs->outbuf_highwater_mark,&style))
                    751:                        break;
                    752:                if(!iniSetShortInt(lp,section,"OutbufDrainTimeout",bbs->outbuf_drain_timeout,&style))
                    753:                        break;
                    754: 
                    755:                if(bbs->sem_chk_freq==global->sem_chk_freq)
                    756:                        iniRemoveValue(lp,section,strSemFileCheckFrequency);
                    757:                else if(!iniSetShortInt(lp,section,strSemFileCheckFrequency,bbs->sem_chk_freq,&style))
                    758:                        break;
                    759: 
                    760:                if(bbs->log_level==global->log_level)
                    761:                        iniRemoveValue(lp,section,strLogLevel);
                    762:                else if(!iniSetLogLevel(lp,section,strLogLevel,bbs->log_level,&style))
                    763:                        break;
                    764: 
                    765:                /* JavaScript operating parameters */
                    766:                if(!sbbs_set_js_settings(lp,section,&bbs->js,&global->js,&style))
                    767:                        break;
                    768: 
                    769:                if(strcmp(bbs->host_name,global->host_name)==0
                    770:             || strcmp(bbs->host_name,cfg->sys_inetaddr)==0)
                    771:                        iniRemoveKey(lp,section,strHostName);
                    772:                else if(!iniSetString(lp,section,strHostName,bbs->host_name,&style))
                    773:                        break;
                    774: 
                    775:                if(stricmp(bbs->temp_dir,global->temp_dir)==0)
                    776:                        iniRemoveKey(lp,section,strTempDirectory);
                    777:                else if(!iniSetString(lp,section,strTempDirectory,bbs->temp_dir,&style))
                    778:                        break;
                    779: 
                    780:                if(!iniSetString(lp,section,"ExternalTermANSI",bbs->xtrn_term_ansi,&style))
                    781:                        break;
                    782:                if(!iniSetString(lp,section,"ExternalTermDumb",bbs->xtrn_term_dumb,&style))
                    783:                        break;
                    784:                if(!iniSetString(lp,section,"DOSemuPath",bbs->dosemu_path,&style))
                    785:                        break;
                    786: 
                    787:                if(!iniSetString(lp,section,strAnswerSound,bbs->answer_sound,&style))
                    788:                        break;
                    789:                if(!iniSetString(lp,section,strHangupSound,bbs->hangup_sound,&style))
                    790:                        break;
                    791: 
                    792:                if(!iniSetBitField(lp,section,strOptions,bbs_options,bbs->options,&style))
                    793:                        break;
                    794: 
                    795:                if(bbs->bind_retry_count==global->bind_retry_count)
                    796:                        iniRemoveValue(lp,section,strBindRetryCount);
                    797:                else if(!iniSetInteger(lp,section,strBindRetryCount,bbs->bind_retry_count,&style))
                    798:                        break;
                    799:                if(bbs->bind_retry_delay==global->bind_retry_delay)
                    800:                        iniRemoveValue(lp,section,strBindRetryDelay);
                    801:                else if(!iniSetInteger(lp,section,strBindRetryDelay,bbs->bind_retry_delay,&style))
                    802:                        break;
                    803:        }
                    804:        /***********************************************************************/
                    805:        if(ftp!=NULL) {
                    806: 
                    807:                section = "FTP";
                    808: 
                    809:                if(!iniSetBool(lp,section,strAutoStart,run_ftp,&style))
                    810:                        break;
                    811: 
                    812:                if(ftp->interface_addr==global->interface_addr)
                    813:                        iniRemoveValue(lp,section,strInterface);
                    814:                else if(!iniSetIpAddress(lp,section,strInterface,ftp->interface_addr,&style))
                    815:                        break;
                    816: 
                    817:                if(!iniSetShortInt(lp,section,strPort,ftp->port,&style))
                    818:                        break;
                    819:                if(!iniSetShortInt(lp,section,strMaxClients,ftp->max_clients,&style))
                    820:                        break;
                    821:                if(!iniSetShortInt(lp,section,strMaxInactivity,ftp->max_inactivity,&style))
                    822:                        break;
                    823:                if(!iniSetShortInt(lp,section,"QwkTimeout",ftp->qwk_timeout,&style))
                    824:                        break;
                    825: 
                    826:                /* Passive transfer settings */
                    827:                if(!iniSetIpAddress(lp,section,"PasvIpAddress",ftp->pasv_ip_addr,&style))
                    828:                        break;
                    829:                if(!iniSetShortInt(lp,section,"PasvPortLow",ftp->pasv_port_low,&style))
                    830:                        break;
                    831:                if(!iniSetShortInt(lp,section,"PasvPortHigh",ftp->pasv_port_high,&style))
                    832:                        break;
                    833: 
                    834:                if(ftp->sem_chk_freq==global->sem_chk_freq)
                    835:                        iniRemoveValue(lp,section,strSemFileCheckFrequency);
                    836:                else if(!iniSetShortInt(lp,section,strSemFileCheckFrequency,ftp->sem_chk_freq,&style))
                    837:                        break;
                    838: 
                    839:                if(ftp->log_level==global->log_level)
                    840:                        iniRemoveValue(lp,section,strLogLevel);
                    841:                else if(!iniSetLogLevel(lp,section,strLogLevel,ftp->log_level,&style))
                    842:                        break;
                    843: 
                    844:                /* JavaScript Operating Parameters */
                    845:                if(!sbbs_set_js_settings(lp,section,&ftp->js,&global->js,&style))
                    846:                        break;
                    847: 
                    848:                if(strcmp(ftp->host_name,global->host_name)==0
                    849:             || strcmp(bbs->host_name,cfg->sys_inetaddr)==0)
                    850:                        iniRemoveKey(lp,section,strHostName);
                    851:                else if(!iniSetString(lp,section,strHostName,ftp->host_name,&style))
                    852:                        break;
                    853: 
                    854:                if(stricmp(ftp->temp_dir,global->temp_dir)==0)
                    855:                        iniRemoveKey(lp,section,strTempDirectory);
                    856:                else if(!iniSetString(lp,section,strTempDirectory,ftp->temp_dir,&style))
                    857:                        break;
                    858: 
                    859:                if(!iniSetString(lp,section,"IndexFileName",ftp->index_file_name,&style))
                    860:                        break;
                    861:                if(!iniSetString(lp,section,"HtmlIndexFile",ftp->html_index_file,&style))
                    862:                        break;
                    863:                if(!iniSetString(lp,section,"HtmlIndexScript",ftp->html_index_script,&style))
                    864:                        break;
                    865: 
                    866:                if(!iniSetString(lp,section,strAnswerSound,ftp->answer_sound,&style))
                    867:                        break;
                    868:                if(!iniSetString(lp,section,strHangupSound,ftp->hangup_sound,&style))
                    869:                        break;
                    870:                if(!iniSetString(lp,section,strHackAttemptSound,ftp->hack_sound,&style))
                    871:                        break;
                    872:        
                    873:                if(!iniSetBitField(lp,section,strOptions,ftp_options,ftp->options,&style))
                    874:                        break;
                    875: 
                    876:                if(ftp->bind_retry_count==global->bind_retry_count)
                    877:                        iniRemoveValue(lp,section,strBindRetryCount);
                    878:                else if(!iniSetInteger(lp,section,strBindRetryCount,ftp->bind_retry_count,&style))
                    879:                        break;
                    880:                if(ftp->bind_retry_delay==global->bind_retry_delay)
                    881:                        iniRemoveValue(lp,section,strBindRetryDelay);
                    882:                else if(!iniSetInteger(lp,section,strBindRetryDelay,ftp->bind_retry_delay,&style))
                    883:                        break;
                    884:        }
                    885: 
                    886:        /***********************************************************************/
                    887:        if(mail!=NULL) {
                    888: 
                    889:                section = "Mail";
                    890: 
                    891:                if(!iniSetBool(lp,section,strAutoStart,run_mail,&style))
                    892:                        break;
                    893: 
                    894:                if(mail->interface_addr==global->interface_addr)
                    895:                        iniRemoveValue(lp,section,strInterface);
                    896:                else if(!iniSetIpAddress(lp,section,strInterface,mail->interface_addr,&style))
                    897:                        break;
                    898: 
                    899:                if(mail->sem_chk_freq==global->sem_chk_freq)
                    900:                        iniRemoveValue(lp,section,strSemFileCheckFrequency);
                    901:                else if(!iniSetShortInt(lp,section,strSemFileCheckFrequency,mail->sem_chk_freq,&style))
                    902:                        break;
                    903: 
                    904:                if(mail->log_level==global->log_level)
                    905:                        iniRemoveValue(lp,section,strLogLevel);
                    906:                else if(!iniSetLogLevel(lp,section,strLogLevel,mail->log_level,&style))
                    907:                        break;
                    908: 
                    909:                if(!iniSetShortInt(lp,section,"SMTPPort",mail->smtp_port,&style))
                    910:                        break;
                    911:                if(!iniSetShortInt(lp,section,"POP3Port",mail->pop3_port,&style))
                    912:                        break;
                    913:                if(!iniSetShortInt(lp,section,"RelayPort",mail->relay_port,&style))
                    914:                        break;
                    915:                if(!iniSetShortInt(lp,section,strMaxClients,mail->max_clients,&style))
                    916:                        break;
                    917:                if(!iniSetShortInt(lp,section,strMaxInactivity,mail->max_inactivity,&style))
                    918:                        break;
                    919:                if(!iniSetShortInt(lp,section,"MaxDeliveryAttempts",mail->max_delivery_attempts,&style))
                    920:                        break;
                    921:                if(!iniSetShortInt(lp,section,"RescanFrequency",mail->rescan_frequency,&style))
                    922:                        break;
                    923:                if(!iniSetShortInt(lp,section,"LinesPerYield",mail->lines_per_yield,&style))
                    924:                        break;
                    925:                if(!iniSetShortInt(lp,section,"MaxRecipients",mail->max_recipients,&style))
                    926:                        break;
                    927:                if(!iniSetInteger(lp,section,"MaxMsgSize",mail->max_msg_size,&style))
                    928:                        break;
                    929: 
                    930:                if(strcmp(mail->host_name,global->host_name)==0
                    931:             || strcmp(bbs->host_name,cfg->sys_inetaddr)==0)
                    932:                        iniRemoveKey(lp,section,strHostName);
                    933:                else if(!iniSetString(lp,section,strHostName,mail->host_name,&style))
                    934:                        break;
                    935: 
                    936:                if(stricmp(mail->temp_dir,global->temp_dir)==0)
                    937:                        iniRemoveKey(lp,section,strTempDirectory);
                    938:                else if(!iniSetString(lp,section,strTempDirectory,mail->temp_dir,&style))
                    939:                        break;
                    940: 
                    941:                if(!iniSetString(lp,section,"RelayServer",mail->relay_server,&style))
                    942:                        break;
                    943:                if(!iniSetString(lp,section,"RelayUsername",mail->relay_user,&style))
                    944:                        break;
                    945:                if(!iniSetString(lp,section,"RelayPassword",mail->relay_pass,&style))
                    946:                        break;
                    947: 
                    948:                if(!iniSetString(lp,section,"DNSServer",mail->dns_server,&style))
                    949:                        break;
                    950: 
                    951:                if(!iniSetString(lp,section,"DefaultCharset",mail->default_charset,&style))
                    952:                        break;
                    953: 
                    954:                if(!iniSetString(lp,section,"DefaultUser",mail->default_user,&style))
                    955:                        break;
                    956: 
                    957:                if(!iniSetString(lp,section,"DNSBlacklistHeader",mail->dnsbl_hdr,&style))
                    958:                        break;
                    959:                if(!iniSetString(lp,section,"DNSBlacklistSubject",mail->dnsbl_tag,&style))
                    960:                        break;
                    961: 
                    962:                if(!iniSetString(lp,section,"POP3Sound",mail->pop3_sound,&style))
                    963:                        break;
                    964:                if(!iniSetString(lp,section,"InboundSound",mail->inbound_sound,&style))
                    965:                        break;
                    966:                if(!iniSetString(lp,section,"OutboundSound",mail->outbound_sound,&style))
                    967:                        break;
                    968: 
                    969:                /* JavaScript Operating Parameters */
                    970:                if(!sbbs_set_js_settings(lp,section,&mail->js,&global->js,&style))
                    971:                        break;
                    972: 
                    973:                if(!iniSetBitField(lp,section,strOptions,mail_options,mail->options,&style))
                    974:                        break;
                    975: 
                    976:                if(mail->bind_retry_count==global->bind_retry_count)
                    977:                        iniRemoveValue(lp,section,strBindRetryCount);
                    978:                else if(!iniSetInteger(lp,section,strBindRetryCount,mail->bind_retry_count,&style))
                    979:                        break;
                    980:                if(mail->bind_retry_delay==global->bind_retry_delay)
                    981:                        iniRemoveValue(lp,section,strBindRetryDelay);
                    982:                else if(!iniSetInteger(lp,section,strBindRetryDelay,mail->bind_retry_delay,&style))
                    983:                        break;
                    984:        }
                    985: 
                    986:        /***********************************************************************/
                    987:        if(services!=NULL) {
                    988: 
                    989:                section = "Services";
                    990: 
                    991:                if(!iniSetBool(lp,section,strAutoStart,run_services,&style))
                    992:                        break;
                    993: 
                    994:                if(services->interface_addr==global->interface_addr)
                    995:                        iniRemoveValue(lp,section,strInterface);
                    996:                else if(!iniSetIpAddress(lp,section,strInterface,services->interface_addr,&style))
                    997:                        break;
                    998: 
                    999:                if(services->sem_chk_freq==global->sem_chk_freq)
                   1000:                        iniRemoveValue(lp,section,strSemFileCheckFrequency);
                   1001:                else if(!iniSetShortInt(lp,section,strSemFileCheckFrequency,services->sem_chk_freq,&style))
                   1002:                        break;
                   1003: 
                   1004:                if(services->log_level==global->log_level)
                   1005:                        iniRemoveValue(lp,section,strLogLevel);
                   1006:                else if(!iniSetLogLevel(lp,section,strLogLevel,services->log_level,&style))
                   1007:                        break;
                   1008: 
                   1009:                /* Configurable JavaScript default parameters */
                   1010:                if(!sbbs_set_js_settings(lp,section,&services->js,&global->js,&style))
                   1011:                        break;
                   1012: 
                   1013:                if(strcmp(services->host_name,global->host_name)==0
                   1014:             || strcmp(bbs->host_name,cfg->sys_inetaddr)==0)
                   1015:                        iniRemoveKey(lp,section,strHostName);
                   1016:                else if(!iniSetString(lp,section,strHostName,services->host_name,&style))
                   1017:                        break;
                   1018: 
                   1019:                if(stricmp(services->temp_dir,global->temp_dir)==0)
                   1020:                        iniRemoveKey(lp,section,strTempDirectory);
                   1021:                else if(!iniSetString(lp,section,strTempDirectory,services->temp_dir,&style))
                   1022:                        break;
                   1023: 
                   1024:                if(!iniSetString(lp,section,strAnswerSound,services->answer_sound,&style))
                   1025:                        break;
                   1026:                if(!iniSetString(lp,section,strHangupSound,services->hangup_sound,&style))
                   1027:                        break;
                   1028: 
                   1029:                if(!iniSetBitField(lp,section,strOptions,service_options,services->options,&style))
                   1030:                        break;
                   1031: 
                   1032:                if(services->bind_retry_count==global->bind_retry_count)
                   1033:                        iniRemoveValue(lp,section,strBindRetryCount);
                   1034:                else if(!iniSetInteger(lp,section,strBindRetryCount,services->bind_retry_count,&style))
                   1035:                        break;
                   1036:                if(services->bind_retry_delay==global->bind_retry_delay)
                   1037:                        iniRemoveValue(lp,section,strBindRetryDelay);
                   1038:                else if(!iniSetInteger(lp,section,strBindRetryDelay,services->bind_retry_delay,&style))
                   1039:                        break;
                   1040:        }
                   1041: 
                   1042:        /***********************************************************************/
                   1043:        if(web!=NULL) {
                   1044: 
                   1045:                section = "Web";
                   1046: 
                   1047:                if(!iniSetBool(lp,section,strAutoStart,run_web,&style))
                   1048:                        break;
                   1049: 
                   1050:                if(web->interface_addr==global->interface_addr)
                   1051:                        iniRemoveValue(lp,section,strInterface);
                   1052:                else if(!iniSetIpAddress(lp,section,strInterface,web->interface_addr,&style))
                   1053:                        break;
                   1054: 
                   1055:                if(!iniSetShortInt(lp,section,strPort,web->port,&style))
                   1056:                        break;
                   1057:                if(!iniSetShortInt(lp,section,strMaxClients,web->max_clients,&style))
                   1058:                        break;
                   1059:                if(!iniSetShortInt(lp,section,strMaxInactivity,web->max_inactivity,&style))
                   1060:                        break;
                   1061: 
                   1062:                if(web->sem_chk_freq==global->sem_chk_freq)
                   1063:                        iniRemoveValue(lp,section,strSemFileCheckFrequency);
                   1064:                else if(!iniSetShortInt(lp,section,strSemFileCheckFrequency,web->sem_chk_freq,&style))
                   1065:                        break;
                   1066: 
                   1067:                if(web->log_level==global->log_level)
                   1068:                        iniRemoveValue(lp,section,strLogLevel);
                   1069:                else if(!iniSetLogLevel(lp,section,strLogLevel,web->log_level,&style))
                   1070:                        break;
                   1071: 
                   1072:                /* JavaScript Operating Parameters */
                   1073:                if(!sbbs_set_js_settings(lp,section,&web->js,&global->js,&style))
                   1074:                        break;
                   1075: 
                   1076:                if(strcmp(web->host_name,global->host_name)==0
                   1077:             || strcmp(bbs->host_name,cfg->sys_inetaddr)==0)
                   1078:                        iniRemoveKey(lp,section,strHostName);
                   1079:                else if(!iniSetString(lp,section,strHostName,web->host_name,&style))
                   1080:                        break;
                   1081: 
                   1082:                if(stricmp(web->temp_dir,global->temp_dir)==0)
                   1083:                        iniRemoveKey(lp,section,strTempDirectory);
                   1084:                else if(!iniSetString(lp,section,strTempDirectory,web->temp_dir,&style))
                   1085:                        break;
                   1086: 
                   1087:                if(!iniSetString(lp,section,"RootDirectory",web->root_dir,&style))
                   1088:                        break;
                   1089:                if(!iniSetString(lp,section,"ErrorDirectory",web->error_dir,&style))
                   1090:                        break;
                   1091:                if(!iniSetString(lp,section,"CGIDirectory",web->cgi_dir,&style))
                   1092:                        break;
                   1093:                if(!iniSetString(lp,section,"HttpLogFile",web->logfile_base,&style))
                   1094:                        break;
                   1095: 
                   1096:                if(!iniSetString(lp,section,"DefaultCGIContent",web->default_cgi_content,&style))
                   1097:                        break;
                   1098: 
                   1099:                if(!iniSetStringList(lp,section,"IndexFileNames", "," ,web->index_file_name,&style))
                   1100:                        break;
                   1101:                if(!iniSetStringList(lp,section,"CGIExtensions", "," ,web->cgi_ext,&style))
                   1102:                        break;
                   1103: 
                   1104:                if(!iniSetString(lp,section,"JavaScriptExtension",web->ssjs_ext,&style))
                   1105:                        break;
                   1106: 
                   1107:                if(!iniSetShortInt(lp,section,strMaxInactivity,web->max_inactivity,&style))
                   1108:                        break;
                   1109:                if(!iniSetShortInt(lp,section,"MaxCgiInactivity",web->max_cgi_inactivity,&style))
                   1110:                        break;
                   1111: 
                   1112:                if(!iniSetString(lp,section,strAnswerSound,web->answer_sound,&style))
                   1113:                        break;
                   1114:                if(!iniSetString(lp,section,strHangupSound,web->hangup_sound,&style))
                   1115:                        break;
                   1116:                if(!iniSetString(lp,section,strHackAttemptSound,web->hack_sound,&style))
                   1117:                        break;
                   1118: 
                   1119:                if(!iniSetBitField(lp,section,strOptions,web_options,web->options,&style))
                   1120:                        break;
                   1121: 
                   1122:                if(web->bind_retry_count==global->bind_retry_count)
                   1123:                        iniRemoveValue(lp,section,strBindRetryCount);
                   1124:                else if(!iniSetInteger(lp,section,strBindRetryCount,web->bind_retry_count,&style))
                   1125:                        break;
                   1126:                if(web->bind_retry_delay==global->bind_retry_delay)
                   1127:                        iniRemoveValue(lp,section,strBindRetryDelay);
                   1128:                else if(!iniSetInteger(lp,section,strBindRetryDelay,web->bind_retry_delay,&style))
                   1129:                        break;
                   1130:                if(!iniSetShortInt(lp,section,"OutbufHighwaterMark",web->outbuf_highwater_mark,&style))
                   1131:                        break;
                   1132:                if(!iniSetShortInt(lp,section,"OutbufDrainTimeout",web->outbuf_drain_timeout,&style))
                   1133:                        break;
                   1134:        }
                   1135: 
                   1136:        /***********************************************************************/
                   1137:        result=iniWriteFile(fp,list);
                   1138: 
                   1139:        } while(0);     /* finally */
                   1140: 
                   1141:        iniFreeStringList(list);
                   1142: 
                   1143:        return(result);
                   1144: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.