| 1 | #! @PERL@ |
| 2 | # -*-perl-*- |
| 3 | # |
| 4 | # $Id: sw.in,v 1.1 1999/07/30 18:46:38 mdw Exp $ |
| 5 | # |
| 6 | # CGI interface for software installations |
| 7 | # |
| 8 | # (c) 1999 EBI |
| 9 | # |
| 10 | |
| 11 | #----- Licensing notice ----------------------------------------------------- |
| 12 | # |
| 13 | # This file is part of sw-tools. |
| 14 | # |
| 15 | # sw-tools is free software; you can redistribute it and/or modify |
| 16 | # it under the terms of the GNU General Public License as published by |
| 17 | # the Free Software Foundation; either version 2 of the License, or |
| 18 | # (at your option) any later version. |
| 19 | # |
| 20 | # sw-tools is distributed in the hope that it will be useful, |
| 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 | # GNU General Public License for more details. |
| 24 | # |
| 25 | # You should have received a copy of the GNU General Public License |
| 26 | # along with sw-tools; if not, write to the Free Software Foundation, |
| 27 | # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 28 | |
| 29 | #----- Revision history ----------------------------------------------------- |
| 30 | # |
| 31 | # $Log: sw.in,v $ |
| 32 | # Revision 1.1 1999/07/30 18:46:38 mdw |
| 33 | # New CGI script for browsing installed software and documentation. |
| 34 | # |
| 35 | |
| 36 | #----- Required packages ---------------------------------------------------- |
| 37 | |
| 38 | use lib qw(@pkgdatadir@); |
| 39 | |
| 40 | use POSIX; |
| 41 | use IO; |
| 42 | |
| 43 | use SWConfig; |
| 44 | use SW; |
| 45 | use SWCGI qw(:DEFAULT :debug); |
| 46 | |
| 47 | #----- Get packages implementing various actions ---------------------------- |
| 48 | |
| 49 | BEGIN { %ACT = (); } |
| 50 | use SWList; |
| 51 | use SWDoc; |
| 52 | use SWMan; |
| 53 | use SWInfo; |
| 54 | |
| 55 | #----- Some built-in debugging actions -------------------------------------- |
| 56 | |
| 57 | sub debug($\%) { |
| 58 | my ($what, $h) = @_; |
| 59 | SWCGI::header($what); |
| 60 | SWCGI::dumphash(%$h); |
| 61 | SWCGI::footer(); |
| 62 | } |
| 63 | |
| 64 | $ACT{"show-config"} = sub { debug("configuration", %C); }; |
| 65 | $ACT{"show-environment"} = sub { debug("configuration", %ENV); }; |
| 66 | $ACT{"show-query"} = sub { debug("configuration", %Q); }; |
| 67 | |
| 68 | #----- Snarf arguments ------------------------------------------------------ |
| 69 | |
| 70 | $C{"edited-config-file"} eq "yes" or |
| 71 | barf("Config file $C{datadir}/sw.conf hasn't been edited."); |
| 72 | |
| 73 | SWCGI::read(); |
| 74 | $act = $Q{"act"} || "list"; |
| 75 | if ($ACT{$act}) { |
| 76 | &{$ACT{$act}}; |
| 77 | } else { |
| 78 | barf("unknown action `$act'"); |
| 79 | } |
| 80 | |
| 81 | #----- That's all, folks ---------------------------------------------------- |
| 82 | |
| 83 | exit; |