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

2 Commits   0 Branches   1 Tag
12c7b1c5 (kx 2023-03-24 02:53:04 +0300  1) 
12c7b1c5 (kx 2023-03-24 02:53:04 +0300  2) /**********************************************************************
12c7b1c5 (kx 2023-03-24 02:53:04 +0300  3) 
12c7b1c5 (kx 2023-03-24 02:53:04 +0300  4)   Copyright 2019 Andrey V.Kosteltsev
12c7b1c5 (kx 2023-03-24 02:53:04 +0300  5) 
12c7b1c5 (kx 2023-03-24 02:53:04 +0300  6)   Licensed under the Radix.pro License, Version 1.0 (the "License");
12c7b1c5 (kx 2023-03-24 02:53:04 +0300  7)   you may not use this file  except  in compliance with the License.
12c7b1c5 (kx 2023-03-24 02:53:04 +0300  8)   You may obtain a copy of the License at
12c7b1c5 (kx 2023-03-24 02:53:04 +0300  9) 
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 10)      https://radix.pro/licenses/LICENSE-1.0-en_US.txt
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 11) 
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 12)   Unless required by applicable law or agreed to in writing, software
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 13)   distributed under the License is distributed on an "AS IS" BASIS,
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 14)   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 15)   implied.
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 16) 
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 17)  **********************************************************************/
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 18) 
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 19) #ifdef HAVE_CONFIG_H
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 20) #include <config.h>
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 21) #endif
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 22) 
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 23) #include <stdlib.h>
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 24) #include <stdio.h>
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 25) #include <stdarg.h>
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 26) #include <unistd.h>
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 27) #include <time.h>
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 28) #include <sys/time.h>
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 29) 
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 30) #include <msglog.h>
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 31) 
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 32) FILE *errlog;
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 33) 
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 34) void (*fatal_error_hook)( void );
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 35) 
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 36) void logmsg( FILE *logfile, enum _msg_type type, char *format, ... )
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 37) {
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 38)   va_list argp;
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 39) 
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 40)   if( ! format ) return;
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 41) 
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 42)   {
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 43)     time_t     t = time( NULL );
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 44)     struct tm tm = *localtime(&t);
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 45) 
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 46)     fprintf( logfile, "[%04d-%02d-%02d %02d:%02d:%02d]: ",
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 47)                         tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 48)                                        tm.tm_hour, tm.tm_min, tm.tm_sec );
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 49)   }
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 50) 
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 51)   switch( type )
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 52)   {
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 53)     case MSG_FATAL:   fprintf( logfile, "%s: FATAL: ",   program ); break;
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 54)     case MSG_ERROR:   fprintf( logfile, "%s: ERROR: ",   program ); break;
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 55)     case MSG_WARNING: fprintf( logfile, "%s: WARNING: ", program ); break;
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 56)     case MSG_NOTICE:  fprintf( logfile, "%s: NOTE: ",    program ); break;
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 57)     case MSG_INFO:    fprintf( logfile, "%s: INFO: ",    program ); break;
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 58)     case MSG_DEBUG:   fprintf( logfile, "%s: DEBUG: ",   program ); break;
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 59)     case MSG_LOG:
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 60)       fprintf( logfile, "%s: ", program );
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 61)       break;
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 62)     default:
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 63)       fprintf( logfile, "%s: ", program );
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 64)       break;
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 65)   }
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 66)   va_start( argp, format );
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 67)   vfprintf( errlog, format, argp );
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 68)   fprintf( errlog, "\n" );
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 69)   (void)fflush( errlog );
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 70) }