Annotation of sbbs/sbbs3/logfile.cpp, revision 1.1

1.1     ! root        1: /* logfile.cpp */
        !             2: 
        !             3: /* Synchronet log file routines */
        !             4: 
        !             5: /* $Id: logfile.cpp,v 1.1.1.1 2000/10/10 11:23:57 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 2000 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: #include "sbbs.h"
        !            39: 
        !            40: void sbbs_t::logentry(char *code, char *entry)
        !            41: {
        !            42:        char str[512];
        !            43: 
        !            44:        now=time(NULL);
        !            45:        sprintf(str,"Node %2d  %s\r\n   %s",cfg.node_num,timestr(&now),entry);
        !            46:        logline(code,str);
        !            47: }
        !            48: 
        !            49: /****************************************************************************/
        !            50: /* Writes 'str' verbatim into node.log                                                                                 */
        !            51: /****************************************************************************/
        !            52: void sbbs_t::log(char *str)
        !            53: {
        !            54:        if(logfile_fp==NULL || online==ON_LOCAL) return;
        !            55:        if(logcol>=78 || (78-logcol)<strlen(str)) {
        !            56:                fprintf(logfile_fp,"\r\n");
        !            57:                logcol=1; }
        !            58:        if(logcol==1) {
        !            59:                fprintf(logfile_fp,"   ");
        !            60:                logcol=4; }
        !            61:        fprintf(logfile_fp,str);
        !            62:        if(str[strlen(str)-1]==LF)
        !            63:                logcol=1;
        !            64:        else
        !            65:                logcol+=strlen(str);
        !            66: }
        !            67: 
        !            68: /****************************************************************************/
        !            69: /* Writes 'str' on it's own line in node.log                                                           */
        !            70: /****************************************************************************/
        !            71: void sbbs_t::logline(char *code, char *str)
        !            72: {
        !            73:        lprintf("Node %d %s", cfg.node_num, str);
        !            74:        if(logfile_fp==NULL || (online==ON_LOCAL && strcmp(code,"!!"))) return;
        !            75:        if(logcol!=1)
        !            76:                fprintf(logfile_fp,"\r\n");
        !            77:        fprintf(logfile_fp,"%-2.2s %s\r\n",code,str);
        !            78:        logcol=1;
        !            79: }
        !            80: 
        !            81: /****************************************************************************/
        !            82: /* Writes a comma then 'ch' to log, tracking column.                                           */
        !            83: /****************************************************************************/
        !            84: void sbbs_t::logch(char ch, char comma)
        !            85: {
        !            86: 
        !            87:        if(logfile_fp==NULL || (online==ON_LOCAL)) return;
        !            88:        if((uchar)ch<SP)        /* Don't log control chars */
        !            89:                return;
        !            90:        if(logcol==1) {
        !            91:                logcol=4;
        !            92:                fprintf(logfile_fp,"   "); 
        !            93:        }
        !            94:        else if(logcol>=78) {
        !            95:                logcol=4;
        !            96:                fprintf(logfile_fp,"\r\n   "); 
        !            97:        }
        !            98:        if(comma && logcol!=4) {
        !            99:                fprintf(logfile_fp,",");
        !           100:                logcol++; 
        !           101:        }
        !           102:        if(ch&0x80) {
        !           103:                ch&=0x7f;
        !           104:                if(ch<SP)
        !           105:                        return;
        !           106:                fprintf(logfile_fp,"/"); 
        !           107:        }
        !           108:        fprintf(logfile_fp,"%c",ch);
        !           109:        logcol++;
        !           110: }
        !           111: 

unix.superglobalmegacorp.com

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