New CGI script for browsing installed software and documentation.
[sw-tools] / perl / sw.in
diff --git a/perl/sw.in b/perl/sw.in
new file mode 100644 (file)
index 0000000..854be1f
--- /dev/null
@@ -0,0 +1,83 @@
+#! @PERL@
+# -*-perl-*-
+#
+# $Id: sw.in,v 1.1 1999/07/30 18:46:38 mdw Exp $
+#
+# CGI interface for software installations
+#
+# (c) 1999 EBI
+#
+
+#----- Licensing notice -----------------------------------------------------
+#
+# This file is part of sw-tools.
+#
+# sw-tools is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# sw-tools is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with sw-tools; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#----- Revision history -----------------------------------------------------
+#
+# $Log: sw.in,v $
+# Revision 1.1  1999/07/30 18:46:38  mdw
+# New CGI script for browsing installed software and documentation.
+#
+
+#----- Required packages ----------------------------------------------------
+
+use lib qw(@pkgdatadir@);
+
+use POSIX;
+use IO;
+
+use SWConfig;
+use SW;
+use SWCGI qw(:DEFAULT :debug);
+
+#----- Get packages implementing various actions ----------------------------
+
+BEGIN { %ACT = (); }
+use SWList;
+use SWDoc;
+use SWMan;
+use SWInfo;
+
+#----- Some built-in debugging actions --------------------------------------
+
+sub debug($\%) {
+  my ($what, $h) = @_;
+  SWCGI::header($what);
+  SWCGI::dumphash(%$h);
+  SWCGI::footer();
+}
+
+$ACT{"show-config"} = sub { debug("configuration", %C); };
+$ACT{"show-environment"} = sub { debug("configuration", %ENV); };
+$ACT{"show-query"} = sub { debug("configuration", %Q); };
+
+#----- Snarf arguments ------------------------------------------------------
+
+$C{"edited-config-file"} eq "yes" or
+  barf("Config file $C{datadir}/sw.conf hasn't been edited.");
+
+SWCGI::read();
+$act = $Q{"act"} || "list";
+if ($ACT{$act}) {
+  &{$ACT{$act}};
+} else {
+  barf("unknown action `$act'");
+}
+
+#----- That's all, folks ----------------------------------------------------
+
+exit;