: # use perl -*- Perl -*- eval 'exec perl -S $0 ${1+"$@"}' if $runnning_under_some_shell; # File: map2html -*- Perl -*- # Created by: Alex K (wtwf.com) Sun Mar 3 21:02:43 1996 # Last Modified: Time-stamp: # RCS $Id: map2html,v 1.9 1998/02/19 19:45:26 ark Exp $ ##!/usr/local/bin/perl # try this if the above calling perl stuff doesn't work # convert a map file to client side HTML! # you can find out more about this and get the latest version from # http://www.tardis.ed.ac.uk/~ark/map2html # http://www.BungeeZone.com/~ark/map2html # THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT WARRANTY OF ANY KIND. # USE AT YOUR OWN RISK # use of this software by commercial organizations for commercial # products or gain is not permitted # only cern and NCSA server maps are supported at the moment, # but others can be added # the spec for client imagemaps can be found at # http://ds.internic.net/rfc/rfc1980.txt # CERN information from: # http://www.w3.org/hypertext/WWW/Daemon/User/CGI/HTImageDoc.html # NCSA information from: # http://hoohoo.ncsa.uiuc.edu/docs/tutorials/imagemapping.html $server="CERN"; # the default server $name="map"; # the default map name &usage() if( $#ARGV == -1 ); for $arg (@ARGV) { if( $arg =~ /-[u?]/i ){ &usage(); } elsif( $arg =~ /^-sc$/i || $arg =~ /^-cern$/i ){ $server="CERN"; } elsif( $arg =~ /^-sn$/i || $arg =~ /^-ncsa$/i ){ $server="NCSA"; } elsif( $arg =~ /^-[an]$/i ){ $name=shift; } elsif( $arg =~ /^-nd$/i ){ $nodefault=1; } else { &domap( $arg ); } } # translate a file sub domap { local($filename)=@_; $default=""; open(FILE, "<$filename") || warn "Can't open: $filename\n",return; print "\n"; # header &doline($_) while( ); # the middle bit! if( !defined($nodefault) ){ print "$default\n"; # the default URL (must be last!) } print "\n"; # the end of map tag close FILE; # close the map file } # translate a line in the map file (or record the default) sub doline { local( $line ) = @_; local( @coords ); local($coords, $href, $type); $type='dodgy'; # make sure that it doesn't print anything unless it's set if( $server =~ /CERN/i ){ if( $line =~ /^\s*default\s+(\S+)\s*$/i ){ $default=""; return; }elsif($line=~/^\s*(circle|poly|rect)\s+([^\000]+)\s+(\S+)\s*$/i){ $type=$1; $href=$3; $coords=$2; $type=~s/poly/polygon/; # CERN uses poly but we want polygon } else { chop $line; print "\n"; } } elsif ( $server =~ /NCSA/i ){ if( $line =~ /^\s*default\s+(\S+)\s*$/i ){ $default="\n"; return; }elsif($line=~/^\s*(circle|poly|rect|point|rectangle)\s+(\S+)\s+([^\000]+)$/i ){ $type=$1; $href=$2; $coords=$3; $type=~s/rectangle/rect/i; # NCSA uses rectangle but we want rect $type=~s/poly/polygon/i; # NCSA uses poly but we want rectangle } else { chop $line; print "\n"; } } else { # if you know of any other map format mail me and I'll add it here print "Dodgy server set!\n"; exit; } if( $type =~ /(circle|polygon|rect)/i ){ # convert the coords to a comma separated list of numbers @coords=(); push(@coords, $1 ) while( $coords =~ s/^\D*(\d+)//); $coords=join( ",", @coords ); print "\n"; } } # tell the stupid user how to use this program sub usage { print "usage: map2html [-u] [-sc] [-sn] [-nd] [-a name] mapfile\n"; print " -u : This usage\n"; print " -sc : CERN map format (default)\n"; print " -sn : NCSA map format\n"; print " -nd : don't include default URL\n"; print " -a name : Produce a map called name (default is \"map\")\n\n"; print "see: http://www.tardis.ed.ac.uk/~ark/map2html/ \n"; print " or: http://www.BungeeZone.com/~ark/map2html/ for more info\n"; print "This is verion $Id: map2html,v 1.9 1998/02/19 19:45:26 ark Exp $ \n"; exit; }