use strict;
use threads;
use threads::shared;
+use Getopt::Long;
use Thread::Queue;
use Linux::Inotify2;
+require Guardian::Config;
require Guardian::Parser;
require Guardian::Socket;
+# Define version.
+my $version ="2.0";
+
# Array to store the monitored logfiles.
my @monitored_files = (
"/var/log/snort/alert",
);
+# Get and store the given command line arguments in a hash.
+my %cmdargs = ();
+
+&GetOptions (\%cmdargs,
+ 'foreground|f',
+ 'config|c=s',
+ 'help|h',
+ 'version|v',
+);
+
+# Show help / version information.
+if (defined($cmdargs{"help"})) {
+ print "Guardian $version \n";
+ print "Usage: guardian <optional arguments>\n";
+ print " -c, --config\t\tspecifiy a configuration file other than the default (/etc/guardian/guardian.conf)\n";
+ print " -f, --foreground\trun in the foreground (doesn't fork, any output goes to STDOUT)\n";
+ print " -h, --help\t\tshows this help\n";
+ print " -v, --version\t\tdisplay programm version and exit.\n";
+ exit;
+} elsif (defined($cmdargs{"version"})) {
+ print "Guardian $version \n";
+ exit;
+}
+
+# Read-in the configuration file and store the settings.
+# Push the may be given config file argument.
+my %mainsettings = &Guardian::Config::UseConfig($cmdargs{"config"});
+
# Create the main queue. It is used to store and process all events which are
# reported and enqueued by the worker threads.
my $queue :shared = new Thread::Queue or die "Could not create new, empty queue. $!\n";;