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

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdarg.h>
#include <limits.h>
#include <locale.h>
#include <wchar.h>
#include <wctype.h>

#include <defs.h>

#include <error.h>
#include <msglog.h>
#include <utf8ing.h>
#include <lex.h>


extern char *config_fname;

int errors   = 0;
int warnings = 0;


void error( char *fmt, ... )
{
  va_list arg_ptr;
  char  buf[MAX_ERROR_MSG_SIZE];
  char  msg[MAX_ERROR_MSG_SIZE];
  char *format = "%s:%d:%d: %s";

  va_start( arg_ptr, fmt );

  vsnprintf( msg, MAX_ERROR_MSG_SIZE, (const void *)fmt, arg_ptr );

  va_end( arg_ptr ); /* Reset variable arguments. */

  snprintf( buf, MAX_ERROR_MSG_SIZE, format, config_fname, lineno, colno, msg );

  ERROR( "%s", buf );

  ++errors;
}

void warning( char *fmt, ... )
{
  va_list arg_ptr;
  char  buf[MAX_ERROR_MSG_SIZE];
  char  msg[MAX_ERROR_MSG_SIZE];
  char *format = "%s:%d:%d: %s";

  va_start( arg_ptr, fmt );

  vsnprintf( msg, MAX_ERROR_MSG_SIZE, (const void *)fmt, arg_ptr );

  va_end( arg_ptr ); /* Reset variable arguments. */

  snprintf( buf, MAX_ERROR_MSG_SIZE, format, config_fname, lineno, colno, msg );

  WARNING( "%s", buf );

  ++warnings;
}

void no_space( void )
{
  char  buf[MAX_ERROR_MSG_SIZE];
  char *format = "%s: Cannot allocate memory";

  snprintf( buf, MAX_ERROR_MSG_SIZE, format, config_fname );

  FATAL_ERROR( "%s", buf );

  ++errors;
}

void unterminated_comment( void )
{
  char  buf[MAX_ERROR_MSG_SIZE];
  char *format = "%s:%d:%d: Unterminated comment";

  snprintf( buf, MAX_ERROR_MSG_SIZE, format, config_fname, lineno, colno );

  ERROR( "%s", buf );

  ++errors;
}