Index: util/cgi_common.sh
===================================================================
--- util/cgi_common.sh (nonexistent)
+++ util/cgi_common.sh (revision 755)
@@ -0,0 +1,118 @@
+#!/bin/sh
+
+# shell lib
+
+url_decode()
+{
+awk '
+ function cd(n)
+ {
+ chr=sprintf("%c", n);
+ if (chr == "&")
+ chr = "\\&"
+ code="%" sprintf("%02x", n);
+ CODE[tolower(code)] = chr;
+ CODE[toupper(code)] = chr;
+ }
+
+ BEGIN {
+ for(n = 1; n < 256; n++)
+ cd(n);
+ }
+
+ {
+ tmp = $0;
+ gsub("[+]", " ", tmp);
+ for(c in CODE) {
+ gsub(c, CODE[c], tmp)
+ }
+ print tmp
+ }
+'
+}
+
+error()
+{
+ echo "Content-type: text/plain"
+ echo ""
+ echo "Error: $*"
+ exit 0
+}
+
+radio()
+{
+ local chk
+ if test "$3" = "$2"
+ then
+ chk=" checked=\"true\""
+ fi
+ echo ""
+}
+
+checked()
+{
+ if test ! -z "$1"
+ then
+ echo " checked=\"true\""
+ fi
+}
+
+fix_ltgt()
+{
+ sed "s/\</g;s/>/\>/g"
+}
+
+cgi_png()
+{
+ echo "Content-type: image/png"
+ echo ""
+ cparm=""
+ if test ! -z "$QS_mm"
+ then
+ cparm="$cparm --mm"
+ fi
+ if test ! -z "$QS_grid"
+ then
+ cparm="$cparm --grid-unit $QS_grid"
+ fi
+ if test ! -z "$QS_annotation"
+ then
+ annot=$QS_annotation
+ fi
+ if test ! -z "$QS_diamond"
+ then
+ cparm="$cparm --diamond"
+ fi
+ if test ! -z "$QS_photo"
+ then
+ cparm="$cparm --photo"
+ fi
+ if test ! -z "$QS_dimvalue"
+ then
+ annot="$annot:dimvalue"
+ fi
+ if test ! -z "$QS_dimname"
+ then
+ annot="$annot:dimname"
+ fi
+ if test ! -z "$QS_pins"
+ then
+ annot="$annot:pins"
+ fi
+ if test ! -z "$QS_background"
+ then
+ annot="$annot:background"
+ fi
+ case "$QS_thumb"
+ in
+ 1) animarg="-x 64 -y 48" ;;
+ 2) animarg="-x 128 -y 96" ;;
+ 3) animarg="-x 192 -y 144" ;;
+ *) animarg="" ;;
+ esac
+ if test ! -z "$annot"
+ then
+ cparm="$cparm --annotation $annot"
+ fi
+ (echo "$fptext" | $fp2anim $cparm; echo 'screenshot "/dev/stdout"') | $animator -H $animarg
+}
Property changes on: util/cgi_common.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: util/pcblib-param.cgi
===================================================================
--- util/pcblib-param.cgi (revision 754)
+++ util/pcblib-param.cgi (revision 755)
@@ -3,12 +3,17 @@
ulimit -t 5
ulimit -v 80000
+pcb_rnd_trunk=/home/igor2/C/pcb-rnd
+pcb_rnd_util=$pcb_rnd_trunk/util
+
CGI=/cgi-bin/pcblib-param.cgi
-gendir=/home/igor2/C/pcb-rnd/pcblib/parametric/
+gendir=$pcb_rnd_trunk/pcblib/parametric/
animator=/usr/local/bin/animator
-fp2anim=/home/igor2/C/pcb-rnd/util/fp2anim
-urldecode=/home/igor2/C/libporty/trunk/src/porty/c99tree/url.sh
+fp2anim=$pcb_rnd_util/fp2anim
+# import the lib
+. $pcb_rnd_util/cgi_common.sh
+
gen()
{
cd $gendir
@@ -258,14 +263,6 @@
}
-error()
-{
- echo "Content-type: text/plain"
- echo ""
- echo "Error: $*"
- exit 0
-}
-
list_gens()
{
awk -v "CGI=$CGI" '
@@ -309,29 +306,6 @@
' $gendir/*
}
-radio()
-{
- local chk
- if test "$3" = "$2"
- then
- chk=" checked=\"true\""
- fi
- echo ""
-}
-
-checked()
-{
- if test ! -z "$1"
- then
- echo " checked=\"true\""
- fi
-}
-
-fix_ltgt()
-{
- sed "s/\</g;s/>/\>/g"
-}
-
qs=`echo "$QUERY_STRING" | tr "&" "\n"`
for n in $qs
@@ -340,7 +314,7 @@
export $exp
done
-export QS_cmd=`echo "$QS_cmd" | $urldecode`
+export QS_cmd=`echo "$QS_cmd" | url_decode`
if test -z "$QS_cmd"
then
@@ -391,57 +365,7 @@
if test "$QS_output" = "png"
then
- echo "Content-type: image/png"
- echo ""
- cparm=""
- if test ! -z "$QS_mm"
- then
- cparm="$cparm --mm"
- fi
- if test ! -z "$QS_grid"
- then
- cparm="$cparm --grid-unit $QS_grid"
- fi
- if test ! -z "$QS_annotation"
- then
- annot=$QS_annotation
- fi
- if test ! -z "$QS_diamond"
- then
- cparm="$cparm --diamond"
- fi
- if test ! -z "$QS_photo"
- then
- cparm="$cparm --photo"
- fi
- if test ! -z "$QS_dimvalue"
- then
- annot="$annot:dimvalue"
- fi
- if test ! -z "$QS_dimname"
- then
- annot="$annot:dimname"
- fi
- if test ! -z "$QS_pins"
- then
- annot="$annot:pins"
- fi
- if test ! -z "$QS_background"
- then
- annot="$annot:background"
- fi
- case "$QS_thumb"
- in
- 1) animarg="-x 64 -y 48" ;;
- 2) animarg="-x 128 -y 96" ;;
- 3) animarg="-x 192 -y 144" ;;
- *) animarg="" ;;
- esac
- if test ! -z "$annot"
- then
- cparm="$cparm --annotation $annot"
- fi
- (echo "$fptext" | $fp2anim $cparm; echo 'screenshot "/dev/stdout"') | $animator -H $animarg
+ cgi_png
exit
fi
Index: util/pcblib-static.cgi
===================================================================
--- util/pcblib-static.cgi (revision 754)
+++ util/pcblib-static.cgi (revision 755)
@@ -3,13 +3,20 @@
ulimit -t 5
ulimit -v 80000
+pcb_rnd_trunk=/home/igor2/C/pcb-rnd
+pcb_rnd_util=$pcb_rnd_trunk/util
+
CGI=/cgi-bin/pcblib-static.cgi
-fpdir=/home/igor2/C/pcb-rnd/pcblib/
-sdir=/var/www/tmp/pcblib
-urldecode=/home/igor2/C/libporty/trunk/src/porty/c99tree/url.sh
-fp2anim=/home/igor2/C/pcb-rnd/util/fp2anim
+gendir=$pcb_rnd_trunk/pcblib/parametric/
animator=/usr/local/bin/animator
+fp2anim=$pcb_rnd_util/fp2anim
+# import the lib
+. $pcb_rnd_util/cgi_common.sh
+
+fpdir=$pcb_rnd_trunk/pcblib/
+sdir=/var/www/tmp/pcblib
+
find_fp()
{
awk -v "fp=$QS_fp" -v "fpdir=$fpdir" '
@@ -76,29 +83,6 @@
'
}
-radio()
-{
- local chk
- if test "$3" = "$2"
- then
- chk=" checked=\"true\""
- fi
- echo ""
-}
-
-checked()
-{
- if test ! -z "$1"
- then
- echo " checked=\"true\""
- fi
-}
-
-fix_ltgt()
-{
- sed "s/\</g;s/>/\>/g"
-}
-
qs=`echo "$QUERY_STRING" | tr "&" "\n"`
for n in $qs
@@ -107,7 +91,7 @@
export $exp
done
-export QS_cmd=`echo "$QS_cmd" | $urldecode`
+export QS_cmd=`echo "$QS_cmd" | url_decode`
if test -z "$QS_fp"
then