Annotation of sbbs/src/sbbs3/startup.h, revision 1.1.1.2

1.1       root        1: /* startup.h */
                      2: 
                      3: /* Synchronet main/telnet server thread startup structure */
                      4: 
1.1.1.2 ! root        5: /* $Id: startup.h,v 1.68 2011/09/01 02:50:16 rswindell Exp $ */
1.1       root        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:  *                                                                                                                                                     *
1.1.1.2 ! root       11:  * Copyright 2011 Rob Swindell - http://www.synchro.net/copyright.html         *
1.1       root       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: #ifndef _STARTUP_H_
                     39: #define _STARTUP_H_
                     40: 
                     41: #include <stddef.h>            /* offsetof */
                     42: #include "client.h"
                     43: #include "ringbuf.h"
                     44: #include "semwrap.h"   /* sem_t */
                     45: #include "ini_file.h"  /* INI_MAX_VALUE_LEN */
                     46: #include "sbbsdefs.h"  /* LOG_* (syslog.h) values */
1.1.1.2 ! root       47: #ifndef LINK_LIST_THREADSAFE
        !            48:        #define LINK_LIST_THREADSAFE
        !            49: #endif
        !            50: #include "link_list.h"
1.1       root       51: 
                     52: typedef struct {
                     53:        ulong   max_bytes;              /* max allocated bytes before garbage collection */
                     54:        ulong   cx_stack;               /* bytes for script execution stack */
                     55:        ulong   thread_stack;   /* limit of stack size for native execution thread */
                     56:        ulong   branch_limit;   /* maximum number of branches (for infinite loop detection) */
                     57:        ulong   gc_interval;    /* number of branches between garbage collection attempts */
                     58:        ulong   yield_interval; /* number of branches between time-slice yields */
1.1.1.2 ! root       59:        char    load_path[INI_MAX_VALUE_LEN];   /* additional (comma-separated) directories to search for load()ed scripts */
1.1       root       60: } js_startup_t;
                     61: 
                     62: typedef struct {
                     63: 
                     64:        char    ctrl_dir[INI_MAX_VALUE_LEN];
                     65:        char    temp_dir[INI_MAX_VALUE_LEN];
                     66:        char    host_name[INI_MAX_VALUE_LEN];
                     67:        ushort  sem_chk_freq;
                     68:        ulong   interface_addr;
                     69:        int             log_level;
                     70:        js_startup_t js;
                     71:        uint    bind_retry_count;               /* Number of times to retry bind() calls */
                     72:        uint    bind_retry_delay;               /* Time to wait between each bind() retry */
1.1.1.2 ! root       73:        ulong   login_attempt_delay;
        !            74:        ulong   login_attempt_throttle;
        !            75:        ulong   login_attempt_hack_threshold;
        !            76:        ulong   login_attempt_filter_threshold;
1.1       root       77: 
                     78: } global_startup_t;
                     79: 
                     80: typedef struct {
                     81: 
                     82:        DWORD   size;                           /* sizeof(bbs_struct_t) */
                     83:     WORD       first_node;
                     84:     WORD       last_node;
                     85:        WORD    telnet_port;
                     86:        WORD    rlogin_port;
                     87:        WORD    ssh_port;
                     88:        WORD    outbuf_highwater_mark;  /* output block size control */
                     89:        WORD    outbuf_drain_timeout;
                     90:        WORD    sem_chk_freq;           /* semaphore file checking frequency (in seconds) */
                     91:     DWORD   telnet_interface;
                     92:     DWORD      options;                        /* See BBS_OPT definitions */
                     93:     DWORD      rlogin_interface;
                     94:        DWORD   ssh_interface;
                     95:     RingBuf** node_spybuf;                     /* Spy output buffer (each node)        */
                     96:     RingBuf** node_inbuf;                      /* User input buffer (each node)        */
                     97:     sem_t**    node_spysem;                    /* Spy output semaphore (each node)     */
                     98: 
                     99:        void*   cbdata;                                 /* Private data passed to callbacks */ 
1.1.1.2 ! root      100:        void*   event_cbdata;                   /* Private data passed to event_lputs callback */
1.1       root      101: 
                    102:        /* Callbacks (NULL if unused) */
1.1.1.2 ! root      103:        int     (*lputs)(void*, int , const char*);                     /* Log - put string                                     */
        !           104:     int        (*event_lputs)(void*, int, const char*);        /* Event log - put string                       */
        !           105:        void    (*errormsg)(void*, int level, const char* msg);
        !           106:        void    (*status)(void*, const char*);
1.1       root      107:     void       (*started)(void*);
                    108:        void    (*recycle)(void*);
                    109:     void       (*terminated)(void*, int code);
                    110:     void       (*clients)(void*, int active);
                    111:     void       (*thread_up)(void*, BOOL up, BOOL setuid);
                    112:        void    (*socket_open)(void*, BOOL open);
                    113:     void       (*client_on)(void*, BOOL on, int sock, client_t*, BOOL update);
                    114:     BOOL       (*seteuid)(BOOL user);  /* Set Unix uid for thread (bind) */
                    115:        BOOL    (*setuid)(BOOL force);
                    116: 
                    117:        /* Paths */
                    118:     char    ctrl_dir[128];
                    119:     char       dosemu_path[128];
                    120:     char       temp_dir[128];
                    121:        char    answer_sound[128];
                    122:        char    hangup_sound[128];
                    123: 
                    124:        /* Miscellaneous */
                    125:        char    xtrn_term_ansi[32];             /* external ANSI terminal type (e.g. "ansi-bbs") */
                    126:        char    xtrn_term_dumb[32];             /* external dumb terminal type (e.g. "dumb") */
                    127:        char    host_name[128];
                    128:        BOOL    recycle_now;
                    129:        BOOL    shutdown_now;
                    130:        int             log_level;
                    131:        uint    bind_retry_count;               /* Number of times to retry bind() calls */
                    132:        uint    bind_retry_delay;               /* Time to wait between each bind() retry */
                    133: 
                    134:        /* JavaScript operating parameters */
                    135:        js_startup_t js;
                    136: 
1.1.1.2 ! root      137:        /* Login Attempt parameters */
        !           138:        ulong   login_attempt_delay;
        !           139:        ulong   login_attempt_throttle;
        !           140:        ulong   login_attempt_hack_threshold;
        !           141:        ulong   login_attempt_filter_threshold;
        !           142:        link_list_t* login_attempt_list;
        !           143: 
1.1       root      144: } bbs_startup_t;
                    145: 
                    146: /* startup options that requires re-initialization/recycle when changed */
                    147: #define OFFSET_AND_SIZE(s, f)  { offsetof(s,f), sizeof(((s *)0)->f) }
                    148: 
                    149: #if defined(STARTUP_INIT_FIELD_TABLES)
                    150: static struct init_field {
                    151:        size_t  offset;
                    152:        size_t  size;
                    153: } bbs_init_fields[] = { 
                    154:         OFFSET_AND_SIZE(bbs_startup_t,first_node)
                    155:        ,OFFSET_AND_SIZE(bbs_startup_t,last_node)
                    156:        ,OFFSET_AND_SIZE(bbs_startup_t,telnet_port)
                    157:        ,OFFSET_AND_SIZE(bbs_startup_t,rlogin_port)
                    158:        ,OFFSET_AND_SIZE(bbs_startup_t,telnet_interface)
                    159:        ,OFFSET_AND_SIZE(bbs_startup_t,rlogin_interface)
                    160:        ,OFFSET_AND_SIZE(bbs_startup_t,ctrl_dir)
                    161:        ,OFFSET_AND_SIZE(bbs_startup_t,temp_dir)
                    162:        ,{ 0,0 }        /* terminator */
                    163: };
                    164: #endif
                    165: 
                    166: #define BBS_OPT_XTRN_MINIMIZED         (1<<1)  /* Run externals minimized                      */
                    167: #define BBS_OPT_AUTO_LOGON                     (1<<2)  /* Auto-logon via IP                            */
                    168: #define BBS_OPT_DEBUG_TELNET           (1<<3)  /* Debug telnet commands                        */
                    169: #define BBS_OPT_SYSOP_AVAILABLE                (1<<4)  /* Available for chat                           */
                    170: #define BBS_OPT_ALLOW_RLOGIN           (1<<5)  /* Allow logins via BSD RLogin          */
                    171: #define BBS_OPT_USE_2ND_RLOGIN         (1<<6)  /* Use 2nd username in BSD RLogin       */
                    172: #define BBS_OPT_NO_QWK_EVENTS          (1<<7)  /* Don't run QWK-related events         */
                    173: #define BBS_OPT_NO_TELNET_GA           (1<<8)  /* Don't send periodic Telnet GAs       */
                    174: #define BBS_OPT_NO_EVENTS                      (1<<9)  /* Don't run event thread                       */
                    175: #define BBS_OPT_NO_SPY_SOCKETS         (1<<10) /* Don't create spy sockets                     */
                    176: #define BBS_OPT_NO_HOST_LOOKUP         (1<<11)
                    177: #define BBS_OPT_ALLOW_SSH                      (1<<12) /* Allow logins via BSD SSH                     */
                    178: #define BBS_OPT_NO_RECYCLE                     (1<<27) /* Disable recycling of server          */
                    179: #define BBS_OPT_GET_IDENT                      (1<<28) /* Get Identity (RFC 1413)                      */
                    180: #define BBS_OPT_NO_JAVASCRIPT          (1<<29) /* JavaScript disabled                          */
                    181: #define BBS_OPT_MUTE                           (1<<31) /* Mute sounds                                          */
                    182: 
                    183: /* bbs_startup_t.options bits that require re-init/recycle when changed */
                    184: #define BBS_INIT_OPTS  (BBS_OPT_ALLOW_RLOGIN|BBS_OPT_ALLOW_SSH|BBS_OPT_NO_EVENTS|BBS_OPT_NO_SPY_SOCKETS \
1.1.1.2 ! root      185:                                                |BBS_OPT_NO_JAVASCRIPT)
1.1       root      186: 
                    187: #if defined(STARTUP_INI_BITDESC_TABLES)
                    188: static ini_bitdesc_t bbs_options[] = {
                    189: 
                    190:        { BBS_OPT_XTRN_MINIMIZED                ,"XTRN_MINIMIZED"               },
                    191:        { BBS_OPT_AUTO_LOGON                    ,"AUTO_LOGON"                   },
                    192:        { BBS_OPT_DEBUG_TELNET                  ,"DEBUG_TELNET"                 },
                    193:        { BBS_OPT_SYSOP_AVAILABLE               ,"SYSOP_AVAILABLE"              },
                    194:        { BBS_OPT_ALLOW_RLOGIN                  ,"ALLOW_RLOGIN"                 },
                    195:        { BBS_OPT_USE_2ND_RLOGIN                ,"USE_2ND_RLOGIN"               },
                    196:        { BBS_OPT_NO_QWK_EVENTS                 ,"NO_QWK_EVENTS"                },
                    197:        { BBS_OPT_NO_TELNET_GA                  ,"NO_TELNET_GA"                 },
                    198:        { BBS_OPT_NO_EVENTS                             ,"NO_EVENTS"                    },
                    199:        { BBS_OPT_NO_HOST_LOOKUP                ,"NO_HOST_LOOKUP"               },
                    200:        { BBS_OPT_NO_SPY_SOCKETS                ,"NO_SPY_SOCKETS"               },
                    201:        { BBS_OPT_ALLOW_SSH                             ,"ALLOW_SSH"                    },
                    202:        { BBS_OPT_NO_RECYCLE                    ,"NO_RECYCLE"                   },
                    203:        { BBS_OPT_GET_IDENT                             ,"GET_IDENT"                    },
                    204:        { BBS_OPT_NO_JAVASCRIPT                 ,"NO_JAVASCRIPT"                },
                    205:        { BBS_OPT_MUTE                                  ,"MUTE"                                 },
                    206:        /* terminator */                                                                                
                    207:        { 0                                                             ,NULL                                   }
                    208: };
                    209: 
                    210: #endif
                    211: 
                    212: #ifdef __cplusplus
                    213: extern "C" {
                    214: #endif
                    215: 
                    216: #ifdef DLLEXPORT
                    217: #undef DLLEXPORT
                    218: #endif
                    219: #ifdef DLLCALL
                    220: #undef DLLCALL
                    221: #endif
                    222: 
                    223: #ifdef _WIN32
                    224:        #ifdef SBBS_EXPORTS
                    225:                #define DLLEXPORT __declspec(dllexport)
                    226:        #else
                    227:                #define DLLEXPORT __declspec(dllimport)
                    228:        #endif
                    229:        #ifdef __BORLANDC__
                    230:                #define DLLCALL __stdcall
                    231:        #else
                    232:                #define DLLCALL
                    233:        #endif
                    234: #else
                    235:        #define DLLEXPORT
                    236:        #define DLLCALL
                    237: #endif
                    238: 
                    239: /* arg is pointer to static bbs_startup_t* */
                    240: DLLEXPORT void                 DLLCALL bbs_thread(void* arg);
                    241: DLLEXPORT void                 DLLCALL bbs_terminate(void);
                    242: DLLEXPORT const char*  DLLCALL js_ver(void);
                    243: DLLEXPORT const char*  DLLCALL bbs_ver(void);
                    244: DLLEXPORT long                 DLLCALL bbs_ver_num(void);
                    245: 
                    246: #ifdef __cplusplus
                    247: }
                    248: #endif
                    249: 
                    250: #endif /* Don't add anything after this line */

unix.superglobalmegacorp.com

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