#!/usr/bin/perl
-system '(date;env) >debug.txt';
-
use POSIX;
-if ($ENV{'BCP5REGISTRY_NOCGI'}) {
- $scriptdir= '.';
+if ($ARGV[0] eq '--cgi') {
+ shift @ARGV;
+ $invokestyle= 'cgi';
+} elsif ($ENV{'SERVER_SOFTWARE'} =~ m/^Lynx/) {
+ $invokestyle= 'lynxcgi';
+} else {
$invokestyle= 'manual';
+}
+
+if ($invokestyle eq 'manual') {
open DEBUG,">&STDERR" or die $!;
+} elsif ($invokestyle eq 'lynxcgi') {
+ open DEBUG,">>debug.txt" or die $!;
+} elsif ($invokestyle eq 'cgi') {
+ open DEBUG,">/dev/null" or die $!;
+}
+
+if ($invokestyle eq 'cgi') {
+ $scriptdir= shift @ARGV;
+ $datadir= shift @ARGV;
} else {
+ $scriptdir= '.';
+ $datadir= '.';
+}
+
+if ($invokestyle ne 'manual') {
$ct= 'BCP5REGISTRY_CONTENTTYPEDONE';
if (!$ENV{$ct}) {
$|=1;
$|=0;
$ENV{$ct}= 1;
}
-
- if ($ENV{'SERVER_SOFTWARE'} =~ m/Lynx/) {
- open DEBUG,">>debug.txt" or die $!;
- $scriptdir= '.';
- $invokestyle= 'lynxcgi';
- } else {
- open DEBUG,"/dev/null" or die $!;
- $scriptdir= $ENV{'SCRIPT_FILENAME'};
- $scriptdir =~ s,/[^/]+$,,;
- $invokestyle= 'cgi';
- }
}
-chdir($scriptdir) or die $!;
+push @INC,$scriptdir;
+chdir($datadir) or die $!;
+
require 'config.pl';
require 'database.pl';
require 'utils.pl';