Annotation of sbbs/sbbs2/logio.c, revision 1.1

1.1     ! root        1: #line 1 "LOGIO.C"
        !             2: 
        !             3: /* Developed 1990-1997 by Rob Swindell; PO Box 501, Yorba Linda, CA 92885 */
        !             4: 
        !             5: /********************************/
        !             6: /* Log file reading and writing */
        !             7: /********************************/
        !             8: 
        !             9: #include "sbbs.h"
        !            10: 
        !            11: void logentry(char *code, char *entry)
        !            12: {
        !            13:        char str[512];
        !            14: 
        !            15: now=time(NULL);
        !            16: sprintf(str,"Node %2d  %s\r\n   %s",node_num,timestr(&now),entry);
        !            17: logline(code,str);
        !            18: }
        !            19: 
        !            20: /****************************************************************************/
        !            21: /* Writes 'str' verbatim into node.log                                                                                 */
        !            22: /****************************************************************************/
        !            23: void log(char *str)
        !            24: {
        !            25: if(!(sys_status&SS_LOGOPEN) || online==ON_LOCAL) return;
        !            26: if(logcol>=78 || (78-logcol)<strlen(str)) {
        !            27:        write(logfile,crlf,2);
        !            28:        logcol=1; }
        !            29: if(logcol==1) {
        !            30:        write(logfile,"   ",3);
        !            31:        logcol=4; }
        !            32: write(logfile,str,strlen(str));
        !            33: if(str[strlen(str)-1]==LF)
        !            34:        logcol=1;
        !            35: else
        !            36:        logcol+=strlen(str);
        !            37: }
        !            38: 
        !            39: /****************************************************************************/
        !            40: /* Writes 'str' on it's own line in node.log                                                           */
        !            41: /****************************************************************************/
        !            42: void logline(char *code, char *str)
        !            43: {
        !            44:        char line[1024];
        !            45: 
        !            46: if(!(sys_status&SS_LOGOPEN) || (online==ON_LOCAL && strcmp(code,"!!"))) return;
        !            47: if(logcol!=1)
        !            48:        write(logfile,crlf,2);
        !            49: sprintf(line,"%-2.2s %s\r\n",code,str);
        !            50: write(logfile,line,strlen(line));
        !            51: logcol=1;
        !            52: }
        !            53: 
        !            54: /****************************************************************************/
        !            55: /* Writes a comma then 'ch' to log, tracking column.                                           */
        !            56: /****************************************************************************/
        !            57: void logch(char ch, char comma)
        !            58: {
        !            59:        char slash='/';
        !            60: 
        !            61: if(!(sys_status&SS_LOGOPEN) || (online==ON_LOCAL)) return;
        !            62: if((uchar)ch<SP)       /* Don't log control chars */
        !            63:        return;
        !            64: if(logcol==1) {
        !            65:        logcol=4;
        !            66:        write(logfile,"   ",3); }
        !            67: else if(logcol>=78) {
        !            68:        logcol=4;
        !            69:        write(logfile,"\r\n   ",5); }
        !            70: if(comma && logcol!=4) {
        !            71:        write(logfile,",",1);
        !            72:        logcol++; }
        !            73: if(ch&0x80) {
        !            74:        ch&=0x7f;
        !            75:        if(ch<SP)
        !            76:                return;
        !            77:        write(logfile,&slash,1); }
        !            78: write(logfile,&ch,1);
        !            79: logcol++;
        !            80: }
        !            81: 

unix.superglobalmegacorp.com

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