blob: b7518e3f797554b32b4b70300c23368572932aa9 [file] [log] [blame]
wdenkfe8c2802002-11-03 00:38:21 +00001<?php // php pages made with phpMyBuilder <http://kyber.dk/phpMyBuilder> ?>
2<?php
3 // (C) Copyright 2001
Wolfgang Denkb3b0fd52005-08-12 23:20:59 +02004 // Murray Jensen <Murray.Jensen@csiro.au>
wdenkfe8c2802002-11-03 00:38:21 +00005 // CSIRO Manufacturing Science and Technology, Preston Lab
6
7 // contains mysql user id and password - keep secret
8 require("config.php");
9
Wolfgang Denkd992daf2005-08-12 23:27:18 +020010 if (isset($_REQUEST['logout'])) {
wdenkfe8c2802002-11-03 00:38:21 +000011 Header("status: 401 Unauthorized");
12 Header("HTTP/1.0 401 Unauthorized");
13 Header("WWW-authenticate: basic realm=\"$bddb_label\"");
14
15 echo "<html><head><title>" .
16 "Access to '$bddb_label' Denied" .
17 "</title></head>\n";
18 echo "<body bgcolor=#ffffff><br></br><br></br><center><h1>" .
19 "You must be an Authorised User " .
20 "to access the '$bddb_label'" .
21 "</h1>\n</center></body></html>\n";
22 exit;
23 }
24
25 // contents of the various enumerated types - if first item is
26 // empty ('') then the enum is allowed to be null (ie "not null"
27 // is not set on the column)
28
29 // all column names in the database table
30 $columns = array(
31 'serno','ethaddr','date','batch',
32 'type','rev','location','comments',
33 'sdram0','sdram1','sdram2','sdram3',
34 'flash0','flash1','flash2','flash3',
35 'zbt0','zbt1','zbt2','zbt3','zbt4','zbt5','zbt6','zbt7',
36 'zbt8','zbt9','zbta','zbtb','zbtc','zbtd','zbte','zbtf',
37 'xlxtyp0','xlxtyp1','xlxtyp2','xlxtyp3',
38 'xlxspd0','xlxspd1','xlxspd2','xlxspd3',
39 'xlxtmp0','xlxtmp1','xlxtmp2','xlxtmp3',
40 'xlxgrd0','xlxgrd1','xlxgrd2','xlxgrd3',
41 'cputyp','cpuspd','cpmspd','busspd',
42 'hstype','hschin','hschout'
43 );
44
45 // board type
46 $type_vals = array('IO','CLP','DSP','INPUT','ALT-INPUT','DISPLAY');
47
Wolfgang Denkd992daf2005-08-12 23:27:18 +020048 // Xilinx fpga types
49 $xlxtyp_vals = array('','XCV300E','XCV400E','XCV600E','XC2V2000','XC2V3000','XC2V4000','XC2V6000','XC2VP2','XC2VP4','XC2VP7','XC2VP20','XC2VP30','XC2VP50','XC4VFX20','XC4VFX40','XC4VFX60','XC4VFX100','XC4VFX140');
wdenkfe8c2802002-11-03 00:38:21 +000050
Wolfgang Denkd992daf2005-08-12 23:27:18 +020051 // Xilinx fpga speeds
52 $xlxspd_vals = array('','6','7','8','4','5','9','10','11','12');
wdenkfe8c2802002-11-03 00:38:21 +000053
Wolfgang Denkd992daf2005-08-12 23:27:18 +020054 // Xilinx fpga temperatures (commercial or industrial)
wdenkfe8c2802002-11-03 00:38:21 +000055 $xlxtmp_vals = array('','COM','IND');
Wolfgang Denkd992daf2005-08-12 23:27:18 +020056
57 // Xilinx fpga grades (normal or engineering sample)
wdenkfe8c2802002-11-03 00:38:21 +000058 $xlxgrd_vals = array('','NORMAL','ENGSAMP');
59
Wolfgang Denkd992daf2005-08-12 23:27:18 +020060 // CPU types
61 $cputyp_vals = array('','MPC8260(HIP3)','MPC8260A(HIP4)','MPC8280(HIP7)','MPC8560');
62
63 // CPU/BUS/CPM clock speeds
64 $clk_vals = array('','33MHZ','66MHZ','100MHZ','133MHZ','166MHZ','200MHZ','233MHZ','266MHZ','300MHZ','333MHZ','366MHZ','400MHZ','433MHZ','466MHZ','500MHZ','533MHZ','566MHZ','600MHZ','633MHZ','666MHZ','700MHZ','733MHZ','766MHZ','800MHZ','833MHZ','866MHZ','900MHZ','933MHZ','966MHZ','1000MHZ','1033MHZ','1066MHZ','1100MHZ','1133MHZ','1166MHZ','1200MHZ','1233MHZ','1266MHZ','1300MHZ','1333MHZ');
65
66 // sdram sizes (nbits array is for eeprom config file)
67 $sdram_vals = array('','32M','64M','128M','256M','512M','1G','2G','4G');
68 $sdram_nbits = array(0,25,26,27,28,29,30,31,32);
69
70 // flash sizes (nbits array is for eeprom config file)
71 $flash_vals = array('','4M','8M','16M','32M','64M','128M','256M','512M','1G');
72 $flash_nbits = array(0,22,23,24,25,26,27,28,29,30);
73
74 // zbt ram sizes (nbits array is for write into eeprom config file)
75 $zbt_vals = array('','512K','1M','2M','4M','8M','16M');
76 $zbt_nbits = array(0,19,20,21,22,23,24);
wdenkfe8c2802002-11-03 00:38:21 +000077
78 // high-speed serial attributes
Wolfgang Denkd992daf2005-08-12 23:27:18 +020079 $hstype_vals = array('','AMCC-S2064A','Xilinx-Rockets');
80 $hschin_vals = array('0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16');
81 $hschout_vals = array('0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16');
wdenkfe8c2802002-11-03 00:38:21 +000082
83 // value filters - used when outputting html
84 function rev_filter($num) {
85 if ($num == 0)
86 return "001";
87 else
88 return sprintf("%03d", $num);
89 }
90
91 function text_filter($str) {
92 return urldecode($str);
93 }
94
95 mt_srand(time() | getmypid());
96
97 // set up MySQL connection
98 mysql_connect("", $mysql_user, $mysql_pw) || die("cannot connect");
99 mysql_select_db($mysql_db) || die("cannot select db");
100
101 // page header
102 function pg_head($title)
103 {
104 echo "<html>\n<head>\n";
105 echo "<link rel=stylesheet href=\"bddb.css\" type=\"text/css\" title=\"style sheet\"></link>\n";
106 echo "<title>$title</title>\n";
107 echo "</head>\n";
108 echo "<body>\n";
109 echo "<center><h1>$title</h1></center>\n";
110 echo "<hr></hr>\n";
111 }
112
113 // page footer
114 function pg_foot()
115 {
116 echo "<hr></hr>\n";
117 echo "<table width=\"100%\"><tr><td align=left>\n<address>" .
118 "If you have any problems, email " .
Wolfgang Denkb3b0fd52005-08-12 23:20:59 +0200119 "<a href=\"mailto:Murray.Jensen@csiro.au\">" .
wdenkfe8c2802002-11-03 00:38:21 +0000120 "Murray Jensen" .
121 "</a></address>\n" .
122 "</td><td align=right>\n" .
123 "<a href=\"index.php?logout=true\">logout</a>\n" .
124 "</td></tr></table>\n";
125 echo "<p><small><i>Made with " .
126 "<a href=\"http://kyber.dk/phpMyBuilder/\">" .
127 "Kyber phpMyBuilder</a></i></small></p>\n";
128 echo "</body>\n";
129 echo "</html>\n";
130 }
131
132 // some support functions
133
134 if (!function_exists('array_search')) {
135
136 function array_search($needle, $haystack, $strict = false) {
137
138 if (is_array($haystack) && count($haystack)) {
139
140 $ntype = gettype($needle);
141
142 foreach ($haystack as $key => $value) {
143
144 if ($value == $needle && (!$strict ||
145 gettype($value) == $ntype))
146 return $key;
147 }
148 }
149
150 return false;
151 }
152 }
153
154 if (!function_exists('in_array')) {
155
156 function in_array($needle, $haystack, $strict = false) {
157
158 if (is_array($haystack) && count($haystack)) {
159
160 $ntype = gettype($needle);
161
162 foreach ($haystack as $key => $value) {
163
164 if ($value == $needle && (!$strict ||
165 gettype($value) == $ntype))
166 return true;
167 }
168 }
169
170 return false;
171 }
172 }
173
174 function key_in_array($key, $array) {
175 return in_array($key, array_keys($array), true);
176 }
177
178 function enum_to_index($name, $vals) {
179 $index = array_search($GLOBALS[$name], $vals);
180 if ($vals[0] != '')
181 $index++;
182 return $index;
183 }
184
185 // fetch a value from an array - return empty string is not present
186 function get_key_value($key, $array) {
187 if (key_in_array($key, $array))
188 return $array[$key];
189 else
190 return '';
191 }
192
193 function fprintf() {
194 $n = func_num_args();
195 if ($n < 2)
196 return FALSE;
197 $a = func_get_args();
198 $fp = array_shift($a);
199 $x = "\$s = sprintf";
200 $sep = '(';
201 foreach ($a as $z) {
202 $x .= "$sep'$z'";
203 $sep = ',';
204 }
205 $x .= ');';
206 eval($x);
207 $l = strlen($s);
208 $r = fwrite($fp, $s, $l);
209 if ($r != $l)
210 return FALSE;
211 else
212 return TRUE;
213 }
214
215 // functions to display (print) a database table and its columns
216
217 function begin_table($ncols) {
218 global $table_ncols;
219 $table_ncols = $ncols;
220 echo "<table align=center width=\"100%\""
221 . " border=1 cellpadding=4 cols=$table_ncols>\n";
222 }
223
224 function begin_field($name, $span = 0) {
225 global $table_ncols;
226 echo "<tr valign=top>\n";
227 echo "\t<th align=center>$name</th>\n";
228 if ($span <= 0)
229 $span = $table_ncols - 1;
230 if ($span > 1)
231 echo "\t<td colspan=$span>\n";
232 else
233 echo "\t<td>\n";
234 }
235
236 function cont_field($span = 1) {
237 echo "\t</td>\n";
238 if ($span > 1)
239 echo "\t<td colspan=$span>\n";
240 else
241 echo "\t<td>\n";
242 }
243
244 function end_field() {
245 echo "\t</td>\n";
246 echo "</tr>\n";
247 }
248
249 function end_table() {
250 echo "</table>\n";
251 }
252
253 function print_field($name, $array, $size = 0, $filt='') {
254
255 begin_field($name);
256
257 if (key_in_array($name, $array))
258 $value = $array[$name];
259 else
260 $value = '';
261
262 if ($filt != '')
263 $value = $filt($value);
264
265 echo "\t\t<input name=$name value=\"$value\"";
266 if ($size > 0)
267 echo " size=$size maxlength=$size";
268 echo "></input>\n";
269
270 end_field();
271 }
272
273 function print_field_multiline($name, $array, $cols, $rows, $filt='') {
274
275 begin_field($name);
276
277 if (key_in_array($name, $array))
278 $value = $array[$name];
279 else
280 $value = '';
281
282 if ($filt != '')
283 $value = $filt($value);
284
285 echo "\t\t<textarea name=$name " .
286 "cols=$cols rows=$rows wrap=off>\n";
287 echo "$value";
288 echo "</textarea>\n";
289
290 end_field();
291 }
292
293 // print a mysql ENUM as an html RADIO INPUT
294 function print_enum($name, $array, $vals, $def = -1) {
295
296 begin_field($name);
297
298 if (key_in_array($name, $array))
299 $chk = array_search($array[$name], $vals, FALSE);
300 else
301 $chk = $def;
302
303 $nval = count($vals);
304
305 for ($i = 0; $i < $nval; $i++) {
306
307 $val = $vals[$i];
308 if ($val == '')
309 $pval = "none";
310 else
311 $pval = "$val";
312
313 printf("\t\t<input type=radio name=$name"
314 . " value=\"$val\"%s>$pval</input>\n",
315 $i == $chk ? " checked" : "");
316 }
317
318 end_field();
319 }
320
Wolfgang Denkd992daf2005-08-12 23:27:18 +0200321 // print a mysql ENUM as an html SELECT INPUT
322 function print_enum_select($name, $array, $vals, $def = -1) {
323
324 begin_field($name);
325
326 echo "\t\t<select name=$name>\n";
327
328 if (key_in_array($name, $array))
329 $chk = array_search($array[$name], $vals, FALSE);
330 else
331 $chk = $def;
332
333 $nval = count($vals);
334
335 for ($i = 0; $i < $nval; $i++) {
336
337 $val = $vals[$i];
338 if ($val == '')
339 $pval = "none";
340 else
341 $pval = "$val";
342
343 printf("\t\t\t<option " .
344 "value=\"%s\"%s>%s</option>\n",
345 $val, $i == $chk ? " selected" : "", $pval);
346 }
347
348 echo "\t\t</select>\n";
349
350 end_field();
351 }
352
wdenkfe8c2802002-11-03 00:38:21 +0000353 // print a group of mysql ENUMs (e.g. name0,name1,...) as an html SELECT
354 function print_enum_multi($base, $array, $vals, $cnt, $defs, $grp = 0) {
355
356 global $table_ncols;
357
358 if ($grp <= 0)
359 $grp = $cnt;
360 $ncell = $cnt / $grp;
361 $span = ($table_ncols - 1) / $ncell;
362
363 begin_field($base, $span);
364
365 $nval = count($vals);
366
367 for ($i = 0; $i < $cnt; $i++) {
368
369 if ($i > 0 && ($i % $grp) == 0)
370 cont_field($span);
371
372 $name = sprintf("%s%x", $base, $i);
373
374 echo "\t\t<select name=$name>\n";
375
376 if (key_in_array($name, $array))
377 $ai = array_search($array[$name], $vals, FALSE);
378 else {
379 if (key_in_array($i, $defs))
380 $ai = $defs[$i];
381 else
382 $ai = 0;
383 }
384
385 for ($j = 0; $j < $nval; $j++) {
386
387 $val = $vals[$j];
388 if ($val == '')
389 $pval = "&nbsp;";
390 else
391 $pval = "$val";
392
393 printf("\t\t\t<option " .
394 "value=\"%s\"%s>%s</option>\n",
395 $val,
396 $j == $ai ? " selected" : "",
397 $pval);
398 }
399
400 echo "\t\t</select>\n";
401 }
402
403 end_field();
404 }
405
406 // functions to handle the form input
407
408 // fetch all the parts of an "enum_multi" into a string suitable
409 // for a MySQL query
410 function gather_enum_multi_query($base, $cnt) {
411
412 $retval = '';
413
414 for ($i = 0; $i < $cnt; $i++) {
415
416 $name = sprintf("%s%x", $base, $i);
417
Wolfgang Denkd992daf2005-08-12 23:27:18 +0200418 if (isset($_REQUEST[$name])) {
wdenkfe8c2802002-11-03 00:38:21 +0000419 $retval .= sprintf(", %s='%s'",
Wolfgang Denkd992daf2005-08-12 23:27:18 +0200420 $name, $_REQUEST[$name]);
wdenkfe8c2802002-11-03 00:38:21 +0000421 }
422 }
423
424 return $retval;
425 }
426
427 // fetch all the parts of an "enum_multi" into a string suitable
428 // for a display e.g. in an html table cell
429 function gather_enum_multi_print($base, $cnt, $array) {
430
431 $retval = '';
432
433 for ($i = 0; $i < $cnt; $i++) {
434
435 $name = sprintf("%s%x", $base, $i);
436
437 if ($array[$name] != '') {
438 if ($retval != '')
439 $retval .= ',';
440 $retval .= $array[$name];
441 }
442 }
443
444 return $retval;
445 }
446
447 // fetch all the parts of an "enum_multi" into a string suitable
448 // for writing to the eeprom data file
449 function gather_enum_multi_write($base, $cnt, $vals, $xfrm = array()) {
450
451 $retval = '';
452
453 for ($i = 0; $i < $cnt; $i++) {
454
455 $name = sprintf("%s%x", $base, $i);
456
457 if ($GLOBALS[$name] != '') {
458 if ($retval != '')
459 $retval .= ',';
460 $index = enum_to_index($name, $vals);
461 if ($xfrm != array())
462 $retval .= $xfrm[$index];
463 else
464 $retval .= $index;
465 }
466 }
467
468 return $retval;
469 }
470
471 // count how many parts of an "enum_multi" are actually set
472 function count_enum_multi($base, $cnt) {
473
474 $retval = 0;
475
476 for ($i = 0; $i < $cnt; $i++) {
477
478 $name = sprintf("%s%x", $base, $i);
479
Wolfgang Denkd992daf2005-08-12 23:27:18 +0200480 if (isset($_REQUEST[$name]))
wdenkfe8c2802002-11-03 00:38:21 +0000481 $retval++;
482 }
483
484 return $retval;
485 }
486
487 // ethernet address functions
488
489 // generate a (possibly not unique) random vendor ethernet address
490 // (setting bit 6 in the ethernet address - motorola wise i.e. bit 0
491 // is the most significant bit - means it is not an assigned ethernet
wdenk6dd652f2003-06-19 23:40:20 +0000492 // address - it is a "locally administered" address). Also, make sure
493 // it is NOT a multicast ethernet address (by setting bit 7 to 0).
494 // e.g. the first byte of all ethernet addresses generated here will
495 // have 2 in the bottom two bits (incidentally, these are the first
496 // two bits transmitted on the wire, since the octets in ethernet
497 // addresses are transmitted LSB first).
498
wdenkfe8c2802002-11-03 00:38:21 +0000499 function gen_eth_addr($serno) {
500
Wolfgang Denkd992daf2005-08-12 23:27:18 +0200501 $ethaddr_hgh = (mt_rand(0, 65535) & 0xfeff) | 0x0200;
502 $ethaddr_mid = mt_rand(0, 65535);
503 $ethaddr_low = mt_rand(0, 65535);
wdenkfe8c2802002-11-03 00:38:21 +0000504
505 return sprintf("%02lx:%02lx:%02lx:%02lx:%02lx:%02lx",
Wolfgang Denkd992daf2005-08-12 23:27:18 +0200506 $ethaddr_hgh >> 8, $ethaddr_hgh & 0xff,
507 $ethaddr_mid >> 8, $ethaddr_mid & 0xff,
508 $ethaddr_low >> 8, $ethaddr_low & 0xff);
wdenkfe8c2802002-11-03 00:38:21 +0000509 }
510
511 // check that an ethernet address is valid
512 function eth_addr_is_valid($ethaddr) {
513
514 $ethbytes = split(':', $ethaddr);
515
516 if (count($ethbytes) != 6)
517 return FALSE;
518
519 for ($i = 0; $i < 6; $i++) {
520 $ethbyte = $ethbytes[$i];
521 if (!ereg('^[0-9a-f][0-9a-f]$', $ethbyte))
522 return FALSE;
523 }
524
525 return TRUE;
526 }
527
528 // write a simple eeprom configuration file
529 function write_eeprom_cfg_file() {
530
531 global $sernos, $nsernos, $bddb_cfgdir, $numerrs, $cfgerrs;
532 global $date, $batch, $type_vals, $rev;
533 global $sdram_vals, $sdram_nbits;
534 global $flash_vals, $flash_nbits;
535 global $zbt_vals, $zbt_nbits;
536 global $xlxtyp_vals, $xlxspd_vals, $xlxtmp_vals, $xlxgrd_vals;
537 global $cputyp, $cputyp_vals, $clk_vals;
538 global $hstype, $hstype_vals, $hschin, $hschout;
539
540 $numerrs = 0;
541 $cfgerrs = array();
542
543 for ($i = 0; $i < $nsernos; $i++) {
544
545 $serno = sprintf("%010d", $sernos[$i]);
546
547 $wfp = @fopen($bddb_cfgdir . "/$serno.cfg", "w");
548 if (!$wfp) {
549 $cfgerrs[$i] = 'file create fail';
550 $numerrs++;
551 continue;
552 }
553 set_file_buffer($wfp, 0);
554
555 if (!fprintf($wfp, "serno=%d\n", $sernos[$i])) {
556 $cfgerrs[$i] = 'cfg wr fail (serno)';
557 fclose($wfp);
558 $numerrs++;
559 continue;
560 }
561
562 if (!fprintf($wfp, "date=%s\n", $date)) {
563 $cfgerrs[$i] = 'cfg wr fail (date)';
564 fclose($wfp);
565 $numerrs++;
566 continue;
567 }
568
569 if ($batch != '') {
570 if (!fprintf($wfp, "batch=%s\n", $batch)) {
571 $cfgerrs[$i] = 'cfg wr fail (batch)';
572 fclose($wfp);
573 $numerrs++;
574 continue;
575 }
576 }
577
578 $typei = enum_to_index("type", $type_vals);
579 if (!fprintf($wfp, "type=%d\n", $typei)) {
580 $cfgerrs[$i] = 'cfg wr fail (type)';
581 fclose($wfp);
582 $numerrs++;
583 continue;
584 }
585
586 if (!fprintf($wfp, "rev=%d\n", $rev)) {
587 $cfgerrs[$i] = 'cfg wr fail (rev)';
588 fclose($wfp);
589 $numerrs++;
590 continue;
591 }
592
593 $s = gather_enum_multi_write("sdram", 4,
594 $sdram_vals, $sdram_nbits);
595 if ($s != '') {
596 $b = fprintf($wfp, "sdram=%s\n", $s);
597 if (!$b) {
598 $cfgerrs[$i] = 'cfg wr fail (sdram)';
599 fclose($wfp);
600 $numerrs++;
601 continue;
602 }
603 }
604
605 $s = gather_enum_multi_write("flash", 4,
606 $flash_vals, $flash_nbits);
607 if ($s != '') {
608 $b = fprintf($wfp, "flash=%s\n", $s);
609 if (!$b) {
610 $cfgerrs[$i] = 'cfg wr fail (flash)';
611 fclose($wfp);
612 $numerrs++;
613 continue;
614 }
615 }
616
617 $s = gather_enum_multi_write("zbt", 16,
618 $zbt_vals, $zbt_nbits);
619 if ($s != '') {
620 $b = fprintf($wfp, "zbt=%s\n", $s);
621 if (!$b) {
622 $cfgerrs[$i] = 'cfg wr fail (zbt)';
623 fclose($wfp);
624 $numerrs++;
625 continue;
626 }
627 }
628
629 $s = gather_enum_multi_write("xlxtyp", 4, $xlxtyp_vals);
630 if ($s != '') {
631 $b = fprintf($wfp, "xlxtyp=%s\n", $s);
632 if (!$b) {
633 $cfgerrs[$i] = 'cfg wr fail (xlxtyp)';
634 fclose($wfp);
635 $numerrs++;
636 continue;
637 }
638 }
639
640 $s = gather_enum_multi_write("xlxspd", 4, $xlxspd_vals);
641 if ($s != '') {
642 $b = fprintf($wfp, "xlxspd=%s\n", $s);
643 if (!$b) {
644 $cfgerrs[$i] = 'cfg wr fail (xlxspd)';
645 fclose($wfp);
646 $numerrs++;
647 continue;
648 }
649 }
650
651 $s = gather_enum_multi_write("xlxtmp", 4, $xlxtmp_vals);
652 if ($s != '') {
653 $b = fprintf($wfp, "xlxtmp=%s\n", $s);
654 if (!$b) {
655 $cfgerrs[$i] = 'cfg wr fail (xlxtmp)';
656 fclose($wfp);
657 $numerrs++;
658 continue;
659 }
660 }
661
662 $s = gather_enum_multi_write("xlxgrd", 4, $xlxgrd_vals);
663 if ($s != '') {
664 $b = fprintf($wfp, "xlxgrd=%s\n", $s);
665 if (!$b) {
666 $cfgerrs[$i] = 'cfg wr fail (xlxgrd)';
667 fclose($wfp);
668 $numerrs++;
669 continue;
670 }
671 }
672
673 if ($cputyp != '') {
674 $cputypi = enum_to_index("cputyp",$cputyp_vals);
675 $cpuspdi = enum_to_index("cpuspd", $clk_vals);
676 $busspdi = enum_to_index("busspd", $clk_vals);
677 $cpmspdi = enum_to_index("cpmspd", $clk_vals);
678 $b = fprintf($wfp, "cputyp=%d\ncpuspd=%d\n" .
679 "busspd=%d\ncpmspd=%d\n",
680 $cputypi, $cpuspdi, $busspdi, $cpmspdi);
681 if (!$b) {
682 $cfgerrs[$i] = 'cfg wr fail (cputyp)';
683 fclose($wfp);
684 $numerrs++;
685 continue;
686 }
687 }
688
689 if ($hstype != '') {
690 $hstypei = enum_to_index("hstype",$hstype_vals);
691 $b = fprintf($wfp, "hstype=%d\n" .
692 "hschin=%s\nhschout=%s\n",
693 $hstypei, $hschin, $hschout);
694 if (!$b) {
695 $cfgerrs[$i] = 'cfg wr fail (hstype)';
696 fclose($wfp);
697 $numerrs++;
698 continue;
699 }
700 }
701
702 if (!fclose($wfp)) {
703 $cfgerrs[$i] = 'file cls fail';
704 $numerrs++;
705 }
706 }
707
708 return $numerrs;
709 }
710?>