cScm Configuration Daemon

cScm – is a tool to convert SCM configuration files into binary format and store its in shared memory for reading by cSvn-ui and cGit-ui CGI scripts

12 Commits   0 Branches   1 Tag
     5         kx 
     5         kx /**********************************************************************
     5         kx 
     5         kx   Copyright 2019 Andrey V.Kosteltsev
     5         kx 
     5         kx   Licensed under the Radix.pro License, Version 1.0 (the "License");
     5         kx   you may not use this file  except  in compliance with the License.
     5         kx   You may obtain a copy of the License at
     5         kx 
     5         kx      https://radix.pro/licenses/LICENSE-1.0-en_US.txt
     5         kx 
     5         kx   Unless required by applicable law or agreed to in writing, software
     5         kx   distributed under the License is distributed on an "AS IS" BASIS,
     5         kx   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
     5         kx   implied.
     5         kx 
     5         kx  **********************************************************************/
     5         kx 
     5         kx #ifdef HAVE_CONFIG_H
     5         kx #include <config.h>
     5         kx #endif
     5         kx 
     5         kx #include <stdlib.h>
     5         kx #include <stdio.h>
     5         kx #include <stdarg.h>
     5         kx #include <unistd.h>
     5         kx #include <time.h>
     5         kx #include <sys/time.h>
     5         kx 
     5         kx #include <msglog.h>
     5         kx 
     5         kx FILE *errlog;
     5         kx 
     5         kx void (*fatal_error_hook)( void );
     5         kx 
     5         kx void logmsg( FILE *logfile, enum _msg_type type, char *format, ... )
     5         kx {
     5         kx   va_list argp;
     5         kx 
     5         kx   if( ! format ) return;
     5         kx 
     5         kx   {
     5         kx     time_t     t = time( NULL );
     5         kx     struct tm tm = *localtime(&t);
     5         kx 
     5         kx     fprintf( logfile, "[%04d-%02d-%02d %02d:%02d:%02d]: ",
     5         kx                         tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
     5         kx                                        tm.tm_hour, tm.tm_min, tm.tm_sec );
     5         kx   }
     5         kx 
     5         kx   switch( type )
     5         kx   {
     5         kx     case MSG_FATAL:   fprintf( logfile, "%s: FATAL: ",   program ); break;
     5         kx     case MSG_ERROR:   fprintf( logfile, "%s: ERROR: ",   program ); break;
     5         kx     case MSG_WARNING: fprintf( logfile, "%s: WARNING: ", program ); break;
     5         kx     case MSG_NOTICE:  fprintf( logfile, "%s: NOTE: ",    program ); break;
     5         kx     case MSG_INFO:    fprintf( logfile, "%s: INFO: ",    program ); break;
     5         kx     case MSG_DEBUG:   fprintf( logfile, "%s: DEBUG: ",   program ); break;
     5         kx     case MSG_LOG:
     5         kx       fprintf( logfile, "%s: ", program );
     5         kx       break;
     5         kx     default:
     5         kx       fprintf( logfile, "%s: ", program );
     5         kx       break;
     5         kx   }
     5         kx   va_start( argp, format );
     5         kx   vfprintf( errlog, format, argp );
     5         kx   fprintf( errlog, "\n" );
     5         kx   (void)fflush( errlog );
     5         kx }