summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xserver/scireserver.pl83
1 files changed, 35 insertions, 48 deletions
diff --git a/server/scireserver.pl b/server/scireserver.pl
index 358ba3e..d7181bd 100755
--- a/server/scireserver.pl
+++ b/server/scireserver.pl
@@ -25,61 +25,48 @@ print STDERR "Connecting to $connect_string\n";
while(<>) {
chomp( my $line = $_);
- if ($line =~ /^STARTRESPONSE (.+?) (.+)$/) { #If it's multi-line, parse accordingly.
- print STDERR "Handling multiline response\n";
- my ($size,$md5) = ($1,$2);
- my $full_cmd = "";
- while(<>) {
- my $multi_line = $_;
- last if $multi_line =~ /^ENDRESPONSE$/;
- $full_cmd .= $multi_line;
- }
- #Verify size and md5. FIXME agaffney can you code this part?
- #FIXME code what to do. no use yet. will be used for returning jobs.
-
- } else { #Handle normal single-line commands.
- print STDERR "Handling single-line response\n";
- print STDERR "DEBUG: line is: $line\n";
- if($line =~ /^QUIT$/) {
- print "OK\n";
- exit;
- }
+ print STDERR "Handling single-line response\n";
+ print STDERR "DEBUG: line is: $line\n";
+ if($line =~ /^QUIT$/) {
+ print "OK\n";
+ exit;
+ }
- if ($line =~ /^REGISTER "(.+?)" "(.+)"$/) {
- my ($mac,$ip) = ($1, $2);
- register_client($mac, $ip);
- next; #End switch here. You can go no further.
- }
+ if ($line =~ /^REGISTER "(.+?)" "(.+)"$/) {
+ my ($mac,$ip) = ($1, $2);
+ register_client($mac, $ip);
+ next; #End switch here. You can go no further.
+ }
- if($line =~ /^IDENTIFY (.+)$/) {
- my $fingerprint = $1;
- identify_client($fingerprint);
- next; #End switch here. You can go no further.
- }
- unless($identified == 1) {
- print "ERROR This client has not yet been authorized. Please identify!\n";
- next;
- }
+ if($line =~ /^IDENTIFY (.+)$/) {
+ my $fingerprint = $1;
+ identify_client($fingerprint);
+ next; #End switch here. You can go no further.
+ }
+ unless($identified == 1) {
+ print "ERROR This client has not yet been authorized. Please identify!\n";
+ next;
+ }
- if ($line =~ /^GET_JOBS(.*)$/) {
- my @existing_jobs = split(/ /,$1) if defined($1);
- get_jobs(@existing_jobs);
-
- } elsif ($line =~ /^GET_JOB (.+)$/) {
- my $job = $1;
- get_job($job);
-
- } elsif ($line =~ /^SET_JOB_STATUS (.+?) "(.+)"$/) {
- my ($jobid,$status) = ($1, $2);
- set_job_status($jobid,$status);
-
- } else {
- print "ERROR This command $line, is unknown. Please try again.\n";
- }
+ if ($line =~ /^GET_JOBS(.*)$/) {
+ my @existing_jobs = split(/ /,$1) if defined($1);
+ get_jobs(@existing_jobs);
+
+ } elsif ($line =~ /^GET_JOB (.+)$/) {
+ my $job = $1;
+ get_job($job);
+
+ } elsif ($line =~ /^SET_JOB_STATUS (.+?) "(.+)"$/) {
+ my ($jobid,$status) = ($1, $2);
+ set_job_status($jobid,$status);
+
+ } else {
+ print "ERROR This command $line, is unknown. Please try again.\n";
}
}
+
sub read_config_file {
my $conf_file = shift;
open(FH, "< ${conf_file}") or die("Couldn't open the config file ${conf_file}: $!");