diff --git a/src/warden-server/sh/perlCommon.pm b/src/warden-server/sh/perlCommon.pm new file mode 100755 index 0000000000000000000000000000000000000000..276afecf248716f0dd0e0b08332ad43d55032eed --- /dev/null +++ b/src/warden-server/sh/perlCommon.pm @@ -0,0 +1,73 @@ +# perlCommon.pm +# +# Copyright (C) 2011-2014 Cesnet z.s.p.o +# +# Use of this source is governed by a BSD-style license, see LICENSE file. + +package perlCommon; + +use warnings; +use strict; + +################################################################################ +# VARIABLES +################################################################################ +our $VERSION = "2.2"; + +################################################################################ +# FUNCTIONS +################################################################################ +sub getConfHash { + my $arg = shift; + my $hash; + our %VALID_STRINGS; + require $arg; + while (my ($key, $value_ref) = each %VALID_STRINGS) { + $hash .= " \"$key\" => [\"$value_ref->[0]\""; + shift($value_ref); + foreach my $element (@$value_ref) { + $hash .= ", \"$element\""; + } + $hash .= "],\n"; + } + print $hash; +} + +sub getConfArrayPre { + my $arg = shift; + my $array; + our @SQL_PRECONDITION; + require $arg; + foreach my $element (@SQL_PRECONDITION) { + $array .= "'$element', "; + } + print $array; +} + +sub getConfArrayPost { + my $arg = shift; + my $array; + our @SQL_POSTCONDITION; + require $arg; + foreach my $element (@SQL_POSTCONDITION) { + $array .= "'$element', "; + } + print $array; +} + +sub getConfArrayQueries { + my $arg = shift; + my $array; + our @SQL_QUERIES; + require $arg; + foreach my $hash_ref (@SQL_QUERIES) { + $array .= "{"; + while (my ($key, $value_ref) = each $hash_ref) { + $array .= "$key => \"$value_ref\", "; + } + $array .= "},\n"; + } + print $array; +} + +1;