#!/usr/bin/perl ##print "Content-type: text/html\n\nData Data
"; ## ## ascii2sgfa.pl ## CGI-script that converts ASCII-go diagrams to SGF format. ## See my web page at http://www.dse.nl/~toni/go/ascii2sgf/ ## for more information. ## ## Copyright (C) 1999 Toni Cornelissen (toni@dse.nl) ## ## This program 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. ## ## This program 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 this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ## ## This script (with the name ascii2sgf.pl) was written by Toni Cornelissen. ## It was then modified so much by Nick Wedd that it is not worth indicating ## the modifications separately. ## require 'cgi-utils.pl'; require 'tc-utils.pl'; require 'go-utils.pl'; %param = &get_query(); $URLImage = "http://www.weddslist.com/g"; $edgelist=""; if ( $param{'topedge'} eq 'on' ) { $edgelist = $edgelist . 't'; } if ( $param{'bottomedge'} eq 'on' ) { $edgelist = $edgelist . 'b'; } if ( $param{'leftedge'} eq 'on' ) { $edgelist = $edgelist . 'l'; } if ( $param{'rightedge'} eq 'on' ) { $edgelist = $edgelist . 'r'; } $labellist=""; if ( $param{'toplabel'} eq 'on' ) { $labellist = $labellist . 't'; } if ( $param{'bottomlabel'} eq 'on' ) { $labellist = $labellist . 'b'; } if ( $param{'leftlabel'} eq 'on' ) { $labellist = $labellist . 'l'; } if ( $param{'rightlabel'} eq 'on' ) { $labellist = $labellist . 'r'; } @board = make_board(clean_board($param{'ascii'}), "pl=$param{'pl'}", "edge=$edgelist", "sq=$param{'sq'}", "label=$labellist"); $sgf = board2sgf(@board); if ($param{'out'} eq "sgf") { print "Content-type: application/x-go-sgf\n\n"; print $sgf; exit(0); } $size = 15; if ($param{'size'}) { $size = $param{'size'}; } print "Content-type: text/html\n\n"; #print $head; print"\n"; print"\n"; print"\n"; print"Goban presented by Toni's script\n"; print"\n"; print"\n"; print"\n"; print"\n"; print"\n"; print"

Goban presented by Toni's script

\n"; print"\n"; print "The diagram:

\n"; print"\n"; if ($param{'out'} eq "ascii") { print "

" . &board2ascii(@board) . "
"; ##
added here } else { ## set img attributes $abssize = $size; if ( $abssize<0 ) { $abssize = -$abssize; } $board[0]{'width'} = $abssize; $board[0]{'height'} = $abssize; $board[0]{'alt'} = ""; if ( $size < 0 ) { print &board2html("${URLImage}/", @board); } else { print &board2html("${URLImage}/${size}/", @board); } } print"\n\n"; print "\n

\nIs converted to the following SGF:
\n"; print "

$sgf
\n"; #print $foot; print"

\n"; print". . back\n"; print"\n"; print"\n"; print"\n";