#!/usr/bin/perl use strict; use warnings; my($app_svnid) = '$HeadURL$ $LastChangedRevision$'; ## no critic (RequireInterpolationOfMetachars) use lib substr(`ade-config ade_share_prefix`,0,-1) . '/include'; ## no critic (ProhibitBacktickOperators) use ADE; use Getopt::Long qw(:config no_ignore_case); my(%adeperlf_defined_errors) = ( adeperlf_err_misc => { fmt => '%s' }, ); # Options #my(); sub adeperlf { my($errstack_ref) = @_; my($rc, $perlcode); ########################################################################### # # Set ADE options # ########################################################################### # Register application-specific errors ADE::register_error_types(\%adeperlf_defined_errors); ########################################################################## # # Process options # ########################################################################## # Defaults for options # Register options if (($rc=ADE::register_options($errstack_ref, undef, undef, 'main::handle_option_%s')) != $ADE::OK) { return($rc); } # Register handler functions if (($rc=ADE::set_callbacks($errstack_ref, \&adeperlf_usage_help, \&adeperlf_version, \&adeperlf_paths)) != $ADE::OK) { return($rc); } # Process options ADE::debug($errstack_ref, 10, 'adeperlf: processing options ...'); if (($rc=ADE::process_options($errstack_ref)) != $ADE::OK) { return($rc); } ########################################################################## # # Process arguments # ########################################################################## ADE::show_bad_usage($errstack_ref) if ((not $ARGV[0]) or $ARGV[1]); $perlcode = $ARGV[0]; ADE::debug($errstack_ref, 10, "main: perlcode=$perlcode"); $rc = eval $perlcode; ## no critic (ProhibitStringyEval) if (not defined $rc) { chomp $@; ADE::error($errstack_ref, 'adeperlf_err_misc', "code failed to run; the error was: $@"); return($ADE::FAIL); } elsif ($rc == $ADE::OK) { return($rc); } elsif ($rc == $ADE::FAIL) { ADE::error($errstack_ref, 'adeperlf_err_misc', 'code ran but returned failure'); return($rc); } else { ADE::error($errstack_ref, 'adeperlf_err_misc', "code ran but returned a non-compliant return code; the return code was: $rc"); return($ADE::FAIL); } # Ensure sensible return code return($ADE::OK); } sub adeperlf_version { my($errstack_ref, $version_text_ref) = @_; return(ADE::extract_version($errstack_ref, $app_svnid, $version_text_ref)); } sub adeperlf_paths { my($errstack_ref, $pathlist_text_ref) = @_; my($rc); ${$pathlist_text_ref} = undef; return($ADE::OK); } sub adeperlf_usage_help { my($errstack_ref, $usage_text_short_ref, $usage_text_long_ref) = @_; ${$usage_text_short_ref} = "\n"; ${$usage_text_long_ref} = undef; return($ADE::OK); } ADE::main(\&adeperlf);