| 1 | |||
| 2 | ################################################################################### | ||
| 3 | # | ||
| 4 | # Embperl - Copyright (c) 1997-2008 Gerald Richter / ecos gmbh www.ecos.de | ||
| 5 | # Embperl - Copyright (c) 2008-2015 Gerald Richter | ||
| 6 | # Embperl - Copyright (c) 2015-2023 actevy.io | ||
| 7 | # | ||
| 8 | # You may distribute under the terms of either the GNU General Public | ||
| 9 | # License or the Artistic License, as specified in the Perl README file. | ||
| 10 | # | ||
| 11 | # THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR | ||
| 12 | # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | ||
| 13 | # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
| 14 | # | ||
| 15 | ################################################################################### | ||
| 16 | |||
| 17 | |||
| 18 | package Embperl::Run ; | ||
| 19 | |||
| 20 | use Embperl ; | ||
| 21 | use Embperl::Constant ; | ||
| 22 | use Embperl::Log ; | ||
| 23 | |||
| 24 | use Getopt::Long ; | ||
| 25 | |||
| 26 | no warnings "uninitialized" ; | ||
| 27 | |||
| 28 | |||
| 29 | sub run (;\@$) | ||
| 30 | |||
| 31 | { | ||
| 32 | @ARGV = @{$_[0]} if (ref $_[0] eq 'ARRAY') ; | ||
| 33 | |||
| 34 | eval { Getopt::Long::Configure ('bundling') } ; | ||
| 35 | $@ = "" ; | ||
| 36 | my %param ; | ||
| 37 | my $ret = GetOptions (\%param, | ||
| 38 | "outputfile|o=s", "inputfile|i=s", | ||
| 39 | "log|l=s", "debug|d=i", "options|t=i", | ||
| 40 | "param|p=s@", "syntax|s=s", "fdat|f=s%") ; | ||
| 41 | |||
| 42 | return undef if (!$ret) ; | ||
| 43 | |||
| 44 | if (@ARGV) | ||
| 45 | { | ||
| 46 | $ENV{PATH_TRANSLATED} = $param{'inputfile'} = shift @ARGV ; | ||
| 47 | } | ||
| 48 | |||
| 49 | if (@ARGV) | ||
| 50 | { | ||
| 51 | $ENV{QUERY_STRING} = shift @ARGV ; | ||
| 52 | undef $ENV{CONTENT_LENGTH} if (defined ($ENV{CONTENT_LENGTH})) ; | ||
| 53 | } | ||
| 54 | |||
| 55 | |||
| 56 | $param{'param'} = $_[1] if (defined ($_[1])) ; | ||
| 57 | $param{'use_env'} = 1 ; | ||
| 58 | |||
| 59 | $rc = Embperl::Execute (\%param) ; | ||
| 60 | |||
| 61 | return $rc ; | ||
| 62 | } | ||
| 63 | |||
| 64 | 1 ; | ||
| 65 |