utils.pm.in 728 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package utils;
  2. require Exporter;
  3. @ISA = qw(Exporter);
  4. @EXPORT_OK = qw($TIMEOUT %ERRORS &print_revision &support &usage);
  5. #use strict;
  6. #use vars($TIMEOUT %ERRORS);
  7. sub print_revision ($$);
  8. sub usage;
  9. sub support();
  10. $TIMEOUT = 15;
  11. %ERRORS=('UNKNOWN'=>-1,'OK'=>0,'WARNING'=>1,'CRITICAL'=>2);
  12. sub print_revision ($$) {
  13. my $commandName = shift;
  14. my $pluginRevision = shift;
  15. $pluginRevision =~ s/^\$Revision: //;
  16. $pluginRevision =~ s/ \$\s*$//;
  17. print "$commandName (@PACKAGE@ @VERSION@) $pluginRevision\n";
  18. print "@WARRANTY@";
  19. }
  20. sub support () {
  21. my $support='@SUPPORT@';
  22. $support =~ s/@/\@/g;
  23. $support =~ s/\\n/\n/g;
  24. print $support;
  25. }
  26. sub usage {
  27. my $format=shift;
  28. printf($format,@_);
  29. exit $ERRORS{'UNKNOWN'};
  30. }
  31. 1;