1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
|
#!/bin/bash
ulimit -t 5
ulimit -v 80000
export HOME=/tmp
cd /tmp
# read the config
. /etc/pcblib.cgi.conf
CGI=$CGI_static
# import the lib
. $pcb_rnd_util/cgi_common.sh
find_fp()
{
awk -v "fp=$QS_fp" -v "fpdir=$fpdir" '
BEGIN {
fp=tolower(fp)
}
($1 == "S") {
n=tolower($2)
sub("^.*/", "", n)
sub(".fp$", "", n)
sub(".ele$", "", n)
if (n == fp) {
print fpdir $2
exit
}
}
' < $sdir/cache
}
list_fps()
{
find $fpdir | awk -v "fpdir=$fpdir" -v "CGI=$CGI" '
/.svn/ { next }
/.scad$/ { next }
/parametric/ { next }
{
name=$0
sub(fpdir, "", name)
if (!(name ~ "/"))
next
dir=name
fn=name
sub("/.*", "", dir)
sub("^[^/]*/", "", fn)
vfn = fn
sub(".fp$", "", vfn)
LLEN[dir] += length(vfn)
vfn = "<a href=" q CGI "?fp=" vfn q ">" vfn "</a>"
if (LLEN[dir] > 8) {
LLEN[dir] = 0
sep = "<br>"
}
else
sep = " "
if (DIR[dir] != "")
DIR[dir] = DIR[dir] sep vfn
else
DIR[dir] = vfn
}
END {
print "<table border=1 cellpadding=20>"
print "<tr>"
for(n in DIR)
print "<th>" n
print "<tr>"
for(n in DIR)
print "<td valign=top>" DIR[n]
print "</table>"
}
'
}
qs=`echo "$QUERY_STRING" | tr "&" "\n"`
for n in $qs
do
exp="QS_$n"
export $exp
done
export QS_cmd=`echo "$QS_cmd" | url_decode`
if test -z "$QS_fp"
then
export QS_fp='TO220'
gen=connector
fi
case "$QS_fp"
in
*/*) error "invalid footprint name";;
esac
fn=`find_fp`
if test ! "$?" = 0
then
echo "Content-type: text/plain"
echo ""
echo "Error: couldn't find $QS_fp"
exit
fi
fptext=`cat $fn`
if test ! "$?" = 0
then
echo "Content-type: text/plain"
echo ""
echo "Error reading footprint file for $QS_fp $fn"
exit
fi
if test "$QS_output" = "text"
then
echo "Content-type: text/plain"
echo ""
echo "$fptext"
exit
fi
if test "$QS_output" = "svg"
then
echo "Content-type: image/svg+xml"
echo ""
cparm=""
if test ! -z "$QS_mm"
then
cparm="$cparm --mm"
fi
if test ! -z "$QS_photo"
then
cparm="$cparm --photo"
fi
if test ! -z "$QS_struct"
then
cparm="$cparm --struct"
fi
fptmp=`mktemp`
$fp2preview --outfile $fptmp $cparm "$QS_fp" >/dev/null 2>&1
cat $fptmp
rm $fptmp
exit
fi
echo "Content-type: text/html"
echo ""
echo "<html>"
echo "<body>"
echo "<H1> pcblib-static browse page </H1>"
echo '
<table border=1 cellpadding=10 cellspacing=0>
<tr><td bgcolor="lightgrey">
<i>
An outburst while looking for a powerjack connector <br>
footprint in the stock library: <br>
"What on earth is an <i>MSP430F1121 <u>footprint</u></i> and <br>
why do I need it in the default library?!"</i>
</table>
<br> <br>
<p>
<table border=0 cellpadding=10 cellspacing=10>
<tr>
<td valign=top width=40%>
<h3> pcblib </h3>
<p>
The default library in <a href="http://repo.hu/projects/pcb-rnd">pcb-rnd</a>
was called the "pcblib" (lib and newlib are already used by vanilla pcb) and
is called footprint/ from 3.0.0.
This footprint library content consists of
<a href="http://igor2.repo.hu/cgi-bin/pcblib-param.cgi">parametric (generated) footprints</a>
and static footprints ("file elements"). This page queries static footprints.
<p>
The goal of this lib is to ship a minimalistic library of the real essential
parts, targeting small projects and hobbysts. This assumes users can
grow their own library by downloading footprints from various online sources
(e.g. <a href="http://gedasymbols.org"> gedasymbols</a>) or draw their own
as needed. Thus instead of trying to be a complete collection of footprints
ever drawn, it tries to collect the common base so that it is likely that 90%
of users will use 90% of the footprints of this lib in their projects.
<td>
<td valign=top bgcolor="#eefeee">
<h3>List of static footprints</h3>
<ul>
'
list_fps
echo '
</ul>
</table>
'
echo "<h2> Search and preview </h2>"
echo "<form action=\"$CGI\" method=get>"
echo "name: <input name=\"fp\" value=\"$QS_fp\">"
echo "<ul>"
echo " <li><input type=\"checkbox\" name=\"mm\" value=\"1\" `checked $QS_mm`> draw grid in mm"
echo " <li><input type=\"checkbox\" name=\"photo\" value=\"1\" `checked $QS_photo`> draw in \"photo mode\""
echo " <li><input type=\"checkbox\" name=\"struct\" value=\"1\" `checked $QS_struct`> draw in \"mask and paste\""
echo "</ul>"
echo "<p>"
echo "<input type=\"submit\" value=\"Find my footprint!\">"
echo "</form>"
QS_format=${QS_cmd##*_}
QS_fp_=${QS_cmd%%_*}
if test ! -z "$QS_fp"
then
echo "<h2> Result </h2>"
echo "<h3> $QS_fp </H3>"
echo "<p>Download <a href=\"$CGI?fp=$QS_fp&output=text\">footprint file</a>"
echo "<br><img src=\"$CGI?$QUERY_STRING&output=svg\" width=100%>"
fi
echo "</body>"
echo "</html>"
|