home | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code


package com.ice.syslogd;

import java.awt.*;
import java.util.*;
import java.applet.*;

import com.ice.util.UserProperties;


public class
SyslogD
	{
	public static final String		RCS_ID = "$Id: SyslogD.java,v 1.1.1.1 1998/02/22 05:47:54 time Exp $";
	public static final String		RCS_REV = "$Revision: 1.1.1.1 $";
	public static final String		RCS_NAME = "$Name:  $";

	static public final String		VERSION_STR = "2.2";

	static private Frame			frame;
	static private Applet			applet;
	static private SyslogServer		server;
	static private RepeatThread		repeat;


	static public void
	main( String argv[] )
		{
		boolean		isDaemon = false;
		String		configPath = null;
		String		prefix = "SyslogD";
		Properties	props = new Properties();

		for ( int iArg = 0 ; iArg < argv.length ; ++iArg )
			{
			if ( argv[iArg].equals( "-daemon" ) )
				{
				isDaemon = true;
				}
			else if ( argv[iArg].equals( "-config" )
						&& (iArg + 1) < argv.length )
				{
				configPath = argv[++iArg];
				}
			else if ( argv[iArg].equals( "-prefix" )
						&& (iArg + 1) < argv.length )
				{
				prefix = argv[++iArg];
				}
			else if ( argv[iArg].equals( "-propfile" )
						&& (iArg + 1) < argv.length )
				{
				props.put
					( "SyslogD.global.localPropertyFile",
						argv[++iArg] );
				}
			else if ( argv[iArg].equals( "-?" )
						|| argv[iArg].equals( "-usage" ) )
				{
				SyslogD.printUsage();
				return;
				}
			else
				{
				System.err.println
					( "ERROR unknown option '" + argv[iArg] + "'" );
				SyslogD.printUsage();
				return;
				}
			}

		TimeZone.setDefault( TimeZone.getDefault() );

		UserProperties.setPropertyPrefix( "SyslogD." );

		UserProperties.loadProperties( "com.ice.syslogd", props );

		SyslogConfig config = new SyslogConfig();

		if ( configPath != null )
			{
			config.setConfigPathname( configPath );
			}

		config.loadConfiguration();

		SyslogD.server = new SyslogServer();
		
		SyslogD.server.setConfiguration( config );

		SyslogD.repeat =
			new RepeatThread( config.getConfigEntries() );
		
		if ( ! isDaemon )
			{
			SyslogD.applet =
				new SyslogDApplet( SyslogD.server );

			int x =
				UserProperties.getProperty
					( "mainWindow.x", 20 );
			int y =
				UserProperties.getProperty
					( "mainWindow.y", 20 );
			int w =
				UserProperties.getProperty
					( "mainWindow.width", -1 );
			int h =
				UserProperties.getProperty
					( "mainWindow.height", -1 );
			String title =
				UserProperties.getProperty
					( "mainWindow.title", "SyslogD" );

			SyslogD.frame =
				new SyslogDFrame
					( title, SyslogD.applet, x, y, w, h );
			}

		SyslogD.server.start();

		SyslogD.repeat.start();

		if ( false )
			{
			Runtime rt = Runtime.getRuntime();
			System.err.println
				( "TOTAL: " + rt.totalMemory() +"\n"
					+ "FREE: " + rt.freeMemory() );
			}
		}

	public static void
	printUsage()
		{
		System.err.println( "usage: Syslogd [options...]" );
		System.err.println( "options:" );
		System.err.println
			( "   -daemon             -- "
				+ "run as a daemon (no windows)" );
		System.err.println
			( "   -prefix prefix      -- "
				+ "sets property prefix" );
		System.err.println
			( "   -config filename    -- "
				+ "sets syslog configuration file name" );
		System.err.println
			( "   -propfile filename  -- "
				+ "sets user property file name" );
		}

	}



my book on functional programming

 

new blog posts

 

Copyright 1998-2019 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.