# include <syslog.h>

// Write log messages on Linux.
//
// receives 2 input parms:
//
//   parm1 must be lower case alert, crit, etc. (see list below).
//   parm2 is the message test to be written to the syslog.
//
// Calls are to look like this:
// 
//syslog(LOG_ALERT,"This is my alert message.\n");
//syslog(LOG_CRIT,"This is my critical message.\n");
//syslog(LOG_DEBUG,"This is my debug.\n");
//syslog(LOG_EMERG,"This is my emerg.\n");
//syslog(LOG_ERR,"This is my error.\n");
//syslog(LOG_INFO,"This is my info.\n");
//syslog(LOG_NOTICE,"This is my notice.\n");
//syslog(LOG_WARNING,"This is my warning.\n");
//
// Michael Cook
// Skyline Services Inc.
// http//www.skyprod.com
//
// Aug 7 2000.
//
// Tested on Red Hat 6.1
//
// Updated 2007-12-16 for Ubuntu 7.10 in order to ... 
// 	correct compilation error on exit statement.
// Ignore compilation warnings.

void main(int argc, char *argv[])
{
	int count; 
	int j;
  	static char n[2]  = "\n"; 
        static char t[80] = "message";  

// for testing:
//
//	for (count=0; count < argc; count++)
//		show_args (argv[count]);
  
	j = strcmp(argv[1],"alert");
  	if ( j == 0)
		syslog(LOG_ALERT,strcat(argv[2],n)); 

  	j = strcmp(argv[1],"crit");
  	if ( j == 0)
		syslog(LOG_CRIT,strcat(argv[2],n));

  	j = strcmp(argv[1],"debug");
  	if ( j == 0)
		syslog(LOG_DEBUG,strcat(argv[2],n));

  	j = strcmp(argv[1],"emerg");
  	if ( j == 0)
		syslog(LOG_EMERG,strcat(argv[2],n));

  	j = strcmp(argv[1],"err");
  	if ( j == 0)
		syslog(LOG_ERR,strcat(argv[2],n));

  	j = strcmp(argv[1],"info");
  	if ( j == 0)
		syslog(LOG_INFO,strcat(argv[2],n));

  	j = strcmp(argv[1],"notice");
  	if ( j == 0)
		syslog(LOG_NOTICE,strcat(argv[2],n));

  	j = strcmp(argv[1],"warning");
  	if ( j == 0)
		syslog(LOG_WARNING,strcat(argv[2],n));

	exit(0);
}

void show_args(char *argument) // Shows arguments for testing - not used.
{
	printf("ARGV: %s\n", argument );
}

