serverspy/src/serverspy.cxx
//------------------------------------------------------------------------------
// This function will write to the logfile when clients connect or
// disconnect.  
//------------------------------------------------------------------------------
This function will write to the logfile when clients connect or
disconnect.
This function will write to the logfile when clients connect or disconnect .
void LogConnectionEvent ( ClientDescriptor *cd, int connect ) {
    if ( logfile_str != NULL && cd != NULL ) {
        FILE *file = fopen(logfile_str, "a");
        if (file) {
            char now[32];
            time_t s   = time(NULL);
            char *t    = ctime (&s);
            for( int i=0; i<32 && t[i]; i++) {
                now[i] = t[i];
                if ( t[i] == '\n' ) {
                    now[i] = '\0';
                    break;
                }
            }
            now[31] = '\0';
            fprintf(file, "%s %s : user %s (ID %d) %s.  %d clients connected.\n", now, ExternalServiceName(), cd->m_UserName, cd->m_ID, (connect ? "connected" : "disconnected"), ClientDescriptor::m_NumberClients);
            fclose(file);
        }
    }
}
void LogConnectionEvent ( ClientDescriptor * cd , int connect ) { if ( logfile_str != NULL && cd != NULL ) { FILE * file = fopen ( logfile_str , " " ) ; if ( file ) { char now [ 32 ] ; time_t s = time ( NULL ) ; char * t = ctime ( & s ) ; for ( int i = 0 ; i < 32 && t [ i ] ; i ++ ) { now [ i ] = t [ i ] ; if ( t [ i ] == ' \n ' ) { now [ i ] = ' \0 ' ; break ; } } now [ 31 ] = ' \0 ' ; fprintf ( file , " \n " , now , ExternalServiceName ( ) , cd -> m_UserName , cd -> m_ID , ( connect ? " " : " " ) , ClientDescriptor :: m_NumberClients ) ; fclose ( file ) ; } } }
This function will write to the logfile when clients connect or
disconnect.
This function will write to the logfile when clients connect or disconnect .