#!/usr/bin/perl -w
# mkhub - generate shape files for hubs
# taggart 20031209

die "Usage: mkhub [ports]\n" if (! $ARGV[0]);

$num=$ARGV[0];
$len=($num*0.5)+0.75;
$mid=$len/2;

print <<HEADER;
<?xml version="1.0"?>
<shape xmlns="http://www.daa.com.au/~james/dia-shape-ns"
       xmlns:svg="http://www.w3.org/2000/svg">
  <name>Network - Hub$num</name>
  <icon>hub$num.xpm</icon>
  <connections>
HEADER

# one connection in the middle
print qq(     <point x="$mid" y="2.2"/>\n);

foreach $i (0 .. ($num-1)) {
	$x=(($i*0.5)+0.625);
	print qq(     <point x="$x" y=".87"/>\n);
}

print <<MIDDLE;
  </connections>
  <aspectratio type="fixed"/>
  <textbox x1="0" y1="2.3" x2="$len" y2="5.3" align="center" resize="no"/>
  <svg:svg width="${len}cm" height="2.2cm">
    <svg:rect style="stroke: foreground; stroke-width:.8; fill:#B3B3B3"
     x="0" y="0" width="$len" height="2.2"/>
MIDDLE

foreach $i (1 .. $num) {
	$x=$i*0.5;
	print qq(    <svg:rect style="stroke:none; fill:foreground"\n);
	print qq(     x="$x" y=".75" width=".25" height=".24"/>\n);
}

print <<FOOTER;
  </svg:svg>
</shape>
FOOTER
