public static int Init(string[] args, fMain f)
{
// configure log4net
log4net.Config.XmlConfigurator.Configure();
log.Info("application started");
log.DebugFormat("command line : \"{0}\"", string.Join("\", \"", args));
// started with no arguments?
if (args.Length == 0) Usage();
// started by chrome?
else if (args[args.Length - 1].StartsWith("chrome-extension://")) RunNativeMessagingHost(args, f);
// register command?
else if (args[args.Length - 1] == "register") RegisterNativeMessagingHost(args);
// invalid command line
else InvalidCommand(args[args.Length - 1]);
log.Info("application stopped");
return 0;
}