Annotation of sbbs/src/sbbs3/con_hi.cpp, revision 1.1.1.2

1.1       root        1: /* con_hi.cpp */
                      2: 
                      3: /* Synchronet hi-level console routines */
                      4: 
1.1.1.2 ! root        5: /* $Id: con_hi.cpp,v 1.20 2009/11/09 02:54:55 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 2009 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: #include "sbbs.h"
                     39: 
                     40: /****************************************************************************/
                     41: /* Redraws str using i as current cursor position and l as length           */
1.1.1.2 ! root       42: /* Currently only used by getstr() - so should be moved to getstr.cpp?         */
1.1       root       43: /****************************************************************************/
                     44: void sbbs_t::redrwstr(char *strin, int i, int l, long mode)
                     45: {
1.1.1.2 ! root       46:        cursor_left(i);
1.1       root       47:        if(mode&K_MSG)
1.1.1.2 ! root       48:                bprintf("%-*.*s",l,l,strin);
1.1       root       49:        else
1.1.1.2 ! root       50:                column+=rprintf("%-*.*s",l,l,strin);
        !            51:        cleartoeol();
        !            52:        if(i<l)
        !            53:                cursor_left(l-i); 
1.1       root       54: }
                     55: 
1.1.1.2 ! root       56: int sbbs_t::uselect(int add, uint n, const char *title, const char *item, const uchar *ar)
1.1       root       57: {
                     58:        char    str[128];
                     59:        int             i;
                     60:        uint    t,u;
                     61: 
                     62:        if(uselect_total>=sizeof(uselect_num)/sizeof(uselect_num[0]))   /* out of bounds */
                     63:                uselect_total=0;
                     64: 
                     65:        if(add) {
1.1.1.2 ! root       66:                if(ar && !chk_ar(ar,&useron,&client))
1.1       root       67:                        return(0);
                     68:                if(!uselect_total)
                     69:                        bprintf(text[SelectItemHdr],title);
                     70:                uselect_num[uselect_total++]=n;
                     71:                bprintf(text[SelectItemFmt],uselect_total,item);
1.1.1.2 ! root       72:                return(0)        !            73:        }
1.1       root       74: 
                     75:        if(!uselect_total)
                     76:                return(-1);
                     77: 
                     78:        for(u=0;u<uselect_total;u++)
                     79:                if(uselect_num[u]==n)
                     80:                        break;
                     81:        if(u==uselect_total)
                     82:                u=0;
                     83:        sprintf(str,text[SelectItemWhich],u+1);
                     84:        mnemonics(str);
                     85:        i=getnum(uselect_total);
                     86:        t=uselect_total;
                     87:        uselect_total=0;
                     88:        if(i<0)
                     89:                return(-1);
                     90:        if(!i) {                                        /* User hit ENTER, use default */
                     91:                for(u=0;u<t;u++)
                     92:                        if(uselect_num[u]==n)
                     93:                                return(uselect_num[u]);
                     94:                if(n<t)
                     95:                        return(uselect_num[n]);
1.1.1.2 ! root       96:                return(-1); 
        !            97:        }
1.1       root       98:        return(uselect_num[i-1]);
                     99: }
                    100: 
                    101: /****************************************************************************/
                    102: /* Prompts user for System Password. Returns 1 if user entered correct PW      */
                    103: /****************************************************************************/
                    104: bool sbbs_t::chksyspass()
                    105: {
                    106:        char    str[256],str2[256];
                    107:        int     orgcon=console;
                    108: 
                    109:        if(online==ON_REMOTE && !(cfg.sys_misc&SM_R_SYSOP)) {
1.1.1.2 ! root      110:                logline(LOG_NOTICE,"S!","Remote sysop access disabled");
1.1       root      111:                return(false);
                    112:        }
                    113:        bputs(text[SystemPassword]);
1.1.1.2 ! root      114:        getstr(str,40,K_UPPER|K_NOECHO);
1.1       root      115:        CRLF;
                    116:        if(strcmp(cfg.sys_pass,str)) {
                    117:                if(cfg.sys_misc&SM_ECHO_PW) 
1.1.1.2 ! root      118:                        SAFEPRINTF3(str2,"%s #%u System password attempt: '%s'"
1.1       root      119:                                ,useron.alias,useron.number,str);
                    120:                else
1.1.1.2 ! root      121:                        SAFEPRINTF2(str2,"%s #%u System password verification failure"
1.1       root      122:                                ,useron.alias,useron.number);
1.1.1.2 ! root      123:                logline(LOG_NOTICE,"S!",str2);
1.1       root      124:                return(false); 
                    125:        }
                    126:        return(true);
                    127: }

unix.superglobalmegacorp.com

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