// *** Synnergy Networks

// * Description:
//
// Sends message to everyone on unix system via syslog()  

// * Author:
//
// headflux (hf@synnergy.net)
// Synnergy Networks (c) 1999, http://www.synnergy.net

// * Comments:
//
// For more details, read the source.

// *** Synnergy Networks

#include <stdio.h>
#include <syslog.h>
#include <signal.h>

int main(int argc, int *argv[])
{
	char log_msg[1024];
	char space[2] = " ";
	char temp[80] = "  ";
	size_t len;
	int i = 1;

	if(argc < 2)
	{
		printf("usage: %s <-n process name> <message>\n", argv[0]);
		exit(1);
	}

	if(strcmp(argv[1], "-n") == 0)
	{
		strcat(temp, argv[2]);
		strcpy(argv[0], temp);
		signal(SIGCHLD, SIG_IGN);
		i = 3;
	}

	for(; i < argc; i++)
	{
		strcat(log_msg, argv[i]);
		strcat(log_msg, space);
	}

	len = strlen(log_msg);
	log_msg[len - 1] = '\0';

	syslog(LOG_EMERG, log_msg);

	return(0);
}

// EOF

